]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/network/networkd-routing-policy-rule.h
Merge pull request #12753 from jrouleau/fix/hibernate-resume-timeout
[thirdparty/systemd.git] / src / network / networkd-routing-policy-rule.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
bce67bbe
SS
2#pragma once
3
bce67bbe 4#include <inttypes.h>
9aa5d8ba 5#include <netinet/in.h>
926062f0 6#include <linux/fib_rules.h>
bce67bbe
SS
7#include <stdbool.h>
8
9#include "in-addr-util.h"
a2106925 10#include "conf-parser.h"
bce67bbe
SS
11
12typedef struct RoutingPolicyRule RoutingPolicyRule;
13
14#include "networkd-link.h"
15#include "networkd-network.h"
fcbf4cb7 16#include "networkd-util.h"
bce67bbe
SS
17
18typedef struct Network Network;
19typedef struct Link Link;
20typedef struct NetworkConfigSection NetworkConfigSection;
36e6e28b 21typedef struct Manager Manager;
bce67bbe
SS
22
23struct RoutingPolicyRule {
6964cf45 24 Manager *manager;
bce67bbe
SS
25 Network *network;
26 Link *link;
27 NetworkConfigSection *section;
28
8b220643
SS
29 bool invert_rule;
30
bce67bbe 31 uint8_t tos;
926062f0 32 uint8_t protocol;
bce67bbe
SS
33
34 uint32_t table;
35 uint32_t fwmark;
36 uint32_t fwmask;
37 uint32_t priority;
38
39 int family;
40 unsigned char to_prefixlen;
41 unsigned char from_prefixlen;
42
762e2659
SS
43 char *iif;
44 char *oif;
45
bce67bbe
SS
46 union in_addr_union to;
47 union in_addr_union from;
48
926062f0
SS
49 struct fib_rule_port_range sport;
50 struct fib_rule_port_range dport;
51
bce67bbe
SS
52 LIST_FIELDS(RoutingPolicyRule, rules);
53};
54
55int routing_policy_rule_new(RoutingPolicyRule **ret);
56void routing_policy_rule_free(RoutingPolicyRule *rule);
57
fcbf4cb7 58DEFINE_NETWORK_SECTION_FUNCTIONS(RoutingPolicyRule, routing_policy_rule_free);
bce67bbe 59
9f08a578 60int routing_policy_rule_configure(RoutingPolicyRule *address, Link *link, link_netlink_message_handler_t callback);
302a796f 61int routing_policy_rule_remove(RoutingPolicyRule *routing_policy_rule, Link *link, link_netlink_message_handler_t callback);
bce67bbe
SS
62
63int routing_policy_rule_add(Manager *m, int family, const union in_addr_union *from, uint8_t from_prefixlen, const union in_addr_union *to, uint8_t to_prefixlen,
926062f0
SS
64 uint8_t tos, uint32_t fwmark, uint32_t table, const char *iif, const char *oif, uint8_t protocol, const struct fib_rule_port_range *sport,
65 const struct fib_rule_port_range *dport, RoutingPolicyRule **ret);
bce67bbe 66int routing_policy_rule_add_foreign(Manager *m, int family, const union in_addr_union *from, uint8_t from_prefixlen, const union in_addr_union *to, uint8_t to_prefixlen,
926062f0
SS
67 uint8_t tos, uint32_t fwmark, uint32_t table, const char *iif, const char *oif, uint8_t protocol, const struct fib_rule_port_range *sport,
68 const struct fib_rule_port_range *dport, RoutingPolicyRule **ret);
bce67bbe 69int routing_policy_rule_get(Manager *m, int family, const union in_addr_union *from, uint8_t from_prefixlen, const union in_addr_union *to, uint8_t to_prefixlen, uint8_t tos,
926062f0
SS
70 uint32_t fwmark, uint32_t table, const char *iif, const char *oif, uint8_t protocol, struct fib_rule_port_range *sport,
71 struct fib_rule_port_range *dport, RoutingPolicyRule **ret);
bce67bbe 72int routing_policy_rule_make_local(Manager *m, RoutingPolicyRule *rule);
458d8ae3
ZJS
73int routing_policy_serialize_rules(Set *rules, FILE *f);
74int routing_policy_load_rules(const char *state_file, Set **rules);
bce67bbe
SS
75void routing_policy_rule_purge(Manager *m, Link *link);
76
a2106925
LP
77CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_tos);
78CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_table);
79CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_fwmark_mask);
80CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_prefix);
81CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_priority);
82CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_device);
926062f0 83CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_port_range);
97f9df9e 84CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_ip_protocol);
8b220643 85CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_invert);