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
16extern "C" {
17#endif
18
19struct rtnl_rule;
20
21/* General */
22extern struct rtnl_rule * rtnl_rule_alloc(void);
23extern void rtnl_rule_put(struct rtnl_rule *);
24
25extern int rtnl_rule_alloc_cache(struct nl_sock *, int,
26 struct nl_cache **);
27extern void rtnl_rule_dump(struct rtnl_rule *, FILE *, struct nl_dump_params *);
28
29extern int rtnl_rule_build_add_request(struct rtnl_rule *, int,
30 struct nl_msg **);
31extern int rtnl_rule_add(struct nl_sock *, struct rtnl_rule *, int);
32extern int rtnl_rule_build_delete_request(struct rtnl_rule *, int,
33 struct nl_msg **);
34extern int rtnl_rule_delete(struct nl_sock *, struct rtnl_rule *, int);
35
36
37/* attribute modification */
38extern void rtnl_rule_set_family(struct rtnl_rule *, int);
39extern int rtnl_rule_get_family(struct rtnl_rule *);
40extern void rtnl_rule_set_prio(struct rtnl_rule *, uint32_t);
41extern uint32_t rtnl_rule_get_prio(struct rtnl_rule *);
42extern void rtnl_rule_set_mark(struct rtnl_rule *, uint32_t);
43extern uint32_t rtnl_rule_get_mark(struct rtnl_rule *);
44extern void rtnl_rule_set_mask(struct rtnl_rule *, uint32_t);
45extern uint32_t rtnl_rule_get_mask(struct rtnl_rule *);
46extern void rtnl_rule_set_table(struct rtnl_rule *, uint32_t);
47extern uint32_t rtnl_rule_get_table(struct rtnl_rule *);
48extern void rtnl_rule_set_dsfield(struct rtnl_rule *, uint8_t);
49extern uint8_t rtnl_rule_get_dsfield(struct rtnl_rule *);
50extern int rtnl_rule_set_src(struct rtnl_rule *, struct nl_addr *);
51extern struct nl_addr * rtnl_rule_get_src(struct rtnl_rule *);
52extern int rtnl_rule_set_dst(struct rtnl_rule *, struct nl_addr *);
53extern struct nl_addr * rtnl_rule_get_dst(struct rtnl_rule *);
54extern void rtnl_rule_set_action(struct rtnl_rule *, uint8_t);
55extern uint8_t rtnl_rule_get_action(struct rtnl_rule *);
56extern int rtnl_rule_set_iif(struct rtnl_rule *, const char *);
57extern char * rtnl_rule_get_iif(struct rtnl_rule *);
58extern int rtnl_rule_set_oif(struct rtnl_rule *, const char *);
59extern char * rtnl_rule_get_oif(struct rtnl_rule *);
60extern void rtnl_rule_set_realms(struct rtnl_rule *, uint32_t);
61extern uint32_t rtnl_rule_get_realms(struct rtnl_rule *);
62extern void rtnl_rule_set_goto(struct rtnl_rule *, uint32_t);
63extern uint32_t rtnl_rule_get_goto(struct rtnl_rule *);
64extern void rtnl_rule_set_l3mdev(struct rtnl_rule *, int);
65extern int rtnl_rule_get_l3mdev(struct rtnl_rule *);
66extern int rtnl_rule_set_protocol(struct rtnl_rule *, uint8_t);
67extern int rtnl_rule_get_protocol(struct rtnl_rule *, uint8_t *);
68extern int rtnl_rule_set_ipproto(struct rtnl_rule *, uint8_t);
69extern int rtnl_rule_get_ipproto(struct rtnl_rule *, uint8_t *);
70extern int rtnl_rule_set_sport(struct rtnl_rule *, uint16_t start);
71extern int rtnl_rule_set_sport_range(struct rtnl_rule *,
72 uint16_t start,
73 uint16_t end);
74extern int rtnl_rule_get_sport(struct rtnl_rule *, uint16_t *start,
75 uint16_t *end);
76extern int rtnl_rule_set_dport(struct rtnl_rule *, uint16_t start);
77extern int rtnl_rule_set_dport_range(struct rtnl_rule *,
78 uint16_t start,
79 uint16_t end);
80extern 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
int rtnl_rule_delete(struct nl_sock *, struct rtnl_rule *, int)
Delete a rule.
Definition: rule.c:598
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
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
int rtnl_rule_get_l3mdev(struct rtnl_rule *)
Get l3mdev value of the rule (FRA_L3MDEV)
Definition: rule.c:806
void rtnl_rule_set_l3mdev(struct rtnl_rule *, int)
Set l3mdev value of the rule (FRA_L3MDEV)
Definition: rule.c:786
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
int rtnl_rule_add(struct nl_sock *, struct rtnl_rule *, int)
Add a new rule.
Definition: rule.c:543
Dumping parameters.
Definition: types.h:28