libnl: /data/src/libnl3/include/netlink/route/rule.h Source File

libnl 3.7.0

rule.h
1 /* SPDX-License-Identifier: LGPL-2.1-only */
2 /*
3 * Copyright (c) 2003-2010 Thomas Graf <tgraf@suug.ch>
4 */
5
6 #ifndef NETLINK_RULE_H_
7 #define NETLINK_RULE_H_
8
9 #include <netlink/netlink.h>
10 #include <netlink/cache.h>
11 #include <netlink/addr.h>
12 #include <netlink/route/route.h>
13 #include <linux/fib_rules.h>
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18
19 struct rtnl_rule;
20
21 /* General */
22 extern struct rtnl_rule * rtnl_rule_alloc(void);
23 extern void rtnl_rule_put(struct rtnl_rule *);
24
25 extern int rtnl_rule_alloc_cache(struct nl_sock *, int,
26 struct nl_cache **);
27 extern void rtnl_rule_dump(struct rtnl_rule *, FILE *, struct nl_dump_params *);
28
29 extern int rtnl_rule_build_add_request(struct rtnl_rule *, int,
30 struct nl_msg **);
31 extern int rtnl_rule_add(struct nl_sock *, struct rtnl_rule *, int);
32 extern int rtnl_rule_build_delete_request(struct rtnl_rule *, int,
33 struct nl_msg **);
34 extern int rtnl_rule_delete(struct nl_sock *, struct rtnl_rule *, int);
35
36
37 /* attribute modification */
38 extern void rtnl_rule_set_family(struct rtnl_rule *, int);
39 extern int rtnl_rule_get_family(struct rtnl_rule *);
40 extern void rtnl_rule_set_prio(struct rtnl_rule *, uint32_t);
41 extern uint32_t rtnl_rule_get_prio(struct rtnl_rule *);
42 extern void rtnl_rule_set_mark(struct rtnl_rule *, uint32_t);
43 extern uint32_t rtnl_rule_get_mark(struct rtnl_rule *);
44 extern void rtnl_rule_set_mask(struct rtnl_rule *, uint32_t);
45 extern uint32_t rtnl_rule_get_mask(struct rtnl_rule *);
46 extern void rtnl_rule_set_table(struct rtnl_rule *, uint32_t);
47 extern uint32_t rtnl_rule_get_table(struct rtnl_rule *);
48 extern void rtnl_rule_set_dsfield(struct rtnl_rule *, uint8_t);
49 extern uint8_t rtnl_rule_get_dsfield(struct rtnl_rule *);
50 extern int rtnl_rule_set_src(struct rtnl_rule *, struct nl_addr *);
51 extern struct nl_addr * rtnl_rule_get_src(struct rtnl_rule *);
52 extern int rtnl_rule_set_dst(struct rtnl_rule *, struct nl_addr *);
53 extern struct nl_addr * rtnl_rule_get_dst(struct rtnl_rule *);
54 extern void rtnl_rule_set_action(struct rtnl_rule *, uint8_t);
55 extern uint8_t rtnl_rule_get_action(struct rtnl_rule *);
56 extern int rtnl_rule_set_iif(struct rtnl_rule *, const char *);
57 extern char * rtnl_rule_get_iif(struct rtnl_rule *);
58 extern int rtnl_rule_set_oif(struct rtnl_rule *, const char *);
59 extern char * rtnl_rule_get_oif(struct rtnl_rule *);
60 extern void rtnl_rule_set_realms(struct rtnl_rule *, uint32_t);
61 extern uint32_t rtnl_rule_get_realms(struct rtnl_rule *);
62 extern void rtnl_rule_set_goto(struct rtnl_rule *, uint32_t);
63 extern uint32_t rtnl_rule_get_goto(struct rtnl_rule *);
64 extern void rtnl_rule_set_l3mdev(struct rtnl_rule *, int);
65 extern int rtnl_rule_get_l3mdev(struct rtnl_rule *);
66 extern int rtnl_rule_set_protocol(struct rtnl_rule *, uint8_t);
67 extern int rtnl_rule_get_protocol(struct rtnl_rule *, uint8_t *);
68 extern int rtnl_rule_set_ipproto(struct rtnl_rule *, uint8_t);
69 extern int rtnl_rule_get_ipproto(struct rtnl_rule *, uint8_t *);
70 extern int rtnl_rule_set_sport(struct rtnl_rule *, uint16_t start);
71 extern int rtnl_rule_set_sport_range(struct rtnl_rule *,
72 uint16_t start,
73 uint16_t end);
74 extern int rtnl_rule_get_sport(struct rtnl_rule *, uint16_t *start,
75 uint16_t *end);
76 extern int rtnl_rule_set_dport(struct rtnl_rule *, uint16_t start);
77 extern int rtnl_rule_set_dport_range(struct rtnl_rule *,
78 uint16_t start,
79 uint16_t end);
80 extern int rtnl_rule_get_dport(struct rtnl_rule *, uint16_t *start,
81 uint16_t *end);
82
83 #ifdef __cplusplus
84 }
85 #endif
86
87 #endif
rtnl_rule_delete
int rtnl_rule_delete(struct nl_sock *, struct rtnl_rule *, int)
Delete a rule.
Definition: rule.c:598
rtnl_rule_build_delete_request
int rtnl_rule_build_delete_request(struct rtnl_rule *, int, struct nl_msg **)
Build a netlink request message to delete a rule.
Definition: rule.c:580
rtnl_rule_alloc_cache
int rtnl_rule_alloc_cache(struct nl_sock *, int, struct nl_cache **)
Build a rule cache including all rules currently configured in the kernel.
Definition: rule.c:399
rtnl_rule_get_l3mdev
int rtnl_rule_get_l3mdev(struct rtnl_rule *)
Get l3mdev value of the rule (FRA_L3MDEV)
Definition: rule.c:806
rtnl_rule_set_l3mdev
void rtnl_rule_set_l3mdev(struct rtnl_rule *, int)
Set l3mdev value of the rule (FRA_L3MDEV)
Definition: rule.c:786
rtnl_rule_build_add_request
int rtnl_rule_build_add_request(struct rtnl_rule *, int, struct nl_msg **)
Build netlink request message to add a new rule.
Definition: rule.c:524
rtnl_rule_add
int rtnl_rule_add(struct nl_sock *, struct rtnl_rule *, int)
Add a new rule.
Definition: rule.c:543
nl_dump_params
Dumping parameters.
Definition: types.h:28