]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
bce67bbe SS |
2 | #pragma once |
3 | ||
4 | /*** | |
5 | This file is part of systemd. | |
6 | ||
7 | Copyright 2017 Susant Sahani | |
8 | ||
9 | systemd is free software; you can redistribute it and/or modify it | |
10 | under the terms of the GNU Lesser General Public License as published by | |
11 | the Free Software Foundation; either version 2.1 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | systemd is distributed in the hope that it will be useful, but | |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | Lesser General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU Lesser General Public License | |
20 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
21 | ***/ | |
22 | ||
23 | #include <inttypes.h> | |
24 | #include <stdbool.h> | |
25 | ||
26 | #include "in-addr-util.h" | |
27 | ||
28 | typedef struct RoutingPolicyRule RoutingPolicyRule; | |
29 | ||
30 | #include "networkd-link.h" | |
31 | #include "networkd-network.h" | |
32 | ||
33 | typedef struct Network Network; | |
34 | typedef struct Link Link; | |
35 | typedef struct NetworkConfigSection NetworkConfigSection; | |
36 | ||
37 | struct RoutingPolicyRule { | |
38 | Network *network; | |
39 | Link *link; | |
40 | NetworkConfigSection *section; | |
41 | ||
42 | uint8_t tos; | |
43 | ||
44 | uint32_t table; | |
45 | uint32_t fwmark; | |
46 | uint32_t fwmask; | |
47 | uint32_t priority; | |
48 | ||
49 | int family; | |
50 | unsigned char to_prefixlen; | |
51 | unsigned char from_prefixlen; | |
52 | ||
53 | union in_addr_union to; | |
54 | union in_addr_union from; | |
55 | ||
56 | LIST_FIELDS(RoutingPolicyRule, rules); | |
57 | }; | |
58 | ||
59 | int routing_policy_rule_new(RoutingPolicyRule **ret); | |
60 | void routing_policy_rule_free(RoutingPolicyRule *rule); | |
61 | ||
62 | DEFINE_TRIVIAL_CLEANUP_FUNC(RoutingPolicyRule*, routing_policy_rule_free); | |
63 | #define _cleanup_routing_policy_rule_free_ _cleanup_(routing_policy_rule_freep) | |
64 | ||
65 | int routing_policy_rule_configure(RoutingPolicyRule *address, Link *link, sd_netlink_message_handler_t callback, bool update); | |
66 | int routing_policy_rule_remove(RoutingPolicyRule *routing_policy_rule, Link *link, sd_netlink_message_handler_t callback); | |
67 | int link_routing_policy_rule_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata); | |
68 | int link_routing_policy_rule_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata); | |
69 | ||
70 | 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, | |
71 | uint8_t tos, uint32_t fwmark, uint32_t table, RoutingPolicyRule **ret); | |
72 | 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, | |
73 | uint8_t tos, uint32_t fwmark, uint32_t table, RoutingPolicyRule **ret); | |
74 | 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, | |
75 | uint32_t fwmark, uint32_t table, RoutingPolicyRule **ret); | |
76 | int routing_policy_rule_make_local(Manager *m, RoutingPolicyRule *rule); | |
77 | int routing_policy_rule_load(Manager *m); | |
78 | void routing_policy_rule_purge(Manager *m, Link *link); | |
79 | ||
80 | int config_parse_routing_policy_rule_tos(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data,void *userdata); | |
81 | int config_parse_routing_policy_rule_table(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); | |
82 | int config_parse_routing_policy_rule_fwmark_mask(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); | |
83 | int config_parse_routing_policy_rule_prefix(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); | |
84 | int config_parse_routing_policy_rule_priority(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data,void *userdata); |