]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/network/networkd-routing-policy-rule.h
tree-wide: beautify remaining copyright statements
[thirdparty/systemd.git] / src / network / networkd-routing-policy-rule.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 Copyright © 2017 Susant Sahani
6 ***/
7
8 #include <inttypes.h>
9 #include <stdbool.h>
10
11 #include "in-addr-util.h"
12 #include "conf-parser.h"
13
14 typedef struct RoutingPolicyRule RoutingPolicyRule;
15
16 #include "networkd-link.h"
17 #include "networkd-network.h"
18
19 typedef struct Network Network;
20 typedef struct Link Link;
21 typedef struct NetworkConfigSection NetworkConfigSection;
22 typedef struct Manager Manager;
23
24 struct RoutingPolicyRule {
25 Manager *manager;
26 Network *network;
27 Link *link;
28 NetworkConfigSection *section;
29
30 uint8_t tos;
31
32 uint32_t table;
33 uint32_t fwmark;
34 uint32_t fwmask;
35 uint32_t priority;
36
37 int family;
38 unsigned char to_prefixlen;
39 unsigned char from_prefixlen;
40
41 char *iif;
42 char *oif;
43
44 union in_addr_union to;
45 union in_addr_union from;
46
47 LIST_FIELDS(RoutingPolicyRule, rules);
48 };
49
50 int routing_policy_rule_new(RoutingPolicyRule **ret);
51 void routing_policy_rule_free(RoutingPolicyRule *rule);
52
53 DEFINE_TRIVIAL_CLEANUP_FUNC(RoutingPolicyRule*, routing_policy_rule_free);
54
55 int routing_policy_rule_configure(RoutingPolicyRule *address, Link *link, sd_netlink_message_handler_t callback, bool update);
56 int routing_policy_rule_remove(RoutingPolicyRule *routing_policy_rule, Link *link, sd_netlink_message_handler_t callback);
57 int link_routing_policy_rule_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata);
58 int link_routing_policy_rule_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata);
59
60 int 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,
61 uint8_t tos, uint32_t fwmark, uint32_t table, char *iif, char *oif, RoutingPolicyRule **ret);
62 int 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,
63 uint8_t tos, uint32_t fwmark, uint32_t table, char *iif, char *oif, RoutingPolicyRule **ret);
64 int 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,
65 uint32_t fwmark, uint32_t table, char *iif, char *oif, RoutingPolicyRule **ret);
66 int routing_policy_rule_make_local(Manager *m, RoutingPolicyRule *rule);
67 int routing_policy_serialize_rules(Set *rules, FILE *f);
68 int routing_policy_load_rules(const char *state_file, Set **rules);
69 void routing_policy_rule_purge(Manager *m, Link *link);
70
71 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_tos);
72 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_table);
73 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_fwmark_mask);
74 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_prefix);
75 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_priority);
76 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_device);