1 /* SPDX-License-Identifier: LGPL-2.1+ */
5 #include <linux/fib_rules.h>
8 #include "in-addr-util.h"
9 #include "conf-parser.h"
10 #include "missing_fib_rules.h"
12 typedef struct RoutingPolicyRule RoutingPolicyRule
;
14 #include "networkd-link.h"
15 #include "networkd-network.h"
17 typedef struct Network Network
;
18 typedef struct Link Link
;
19 typedef struct NetworkConfigSection NetworkConfigSection
;
20 typedef struct Manager Manager
;
22 struct RoutingPolicyRule
{
26 NetworkConfigSection
*section
;
37 unsigned char to_prefixlen
;
38 unsigned char from_prefixlen
;
43 union in_addr_union to
;
44 union in_addr_union from
;
46 struct fib_rule_port_range sport
;
47 struct fib_rule_port_range dport
;
49 LIST_FIELDS(RoutingPolicyRule
, rules
);
52 int routing_policy_rule_new(RoutingPolicyRule
**ret
);
53 void routing_policy_rule_free(RoutingPolicyRule
*rule
);
55 DEFINE_TRIVIAL_CLEANUP_FUNC(RoutingPolicyRule
*, routing_policy_rule_free
);
57 int routing_policy_rule_configure(RoutingPolicyRule
*address
, Link
*link
, link_netlink_message_handler_t callback
, bool update
);
58 int routing_policy_rule_remove(RoutingPolicyRule
*routing_policy_rule
, Link
*link
, link_netlink_message_handler_t callback
);
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
, const char *iif
, const char *oif
, uint8_t protocol
, const struct fib_rule_port_range
*sport
,
62 const struct fib_rule_port_range
*dport
, RoutingPolicyRule
**ret
);
63 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
,
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
);
66 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
,
67 uint32_t fwmark
, uint32_t table
, const char *iif
, const char *oif
, uint8_t protocol
, struct fib_rule_port_range
*sport
,
68 struct fib_rule_port_range
*dport
, RoutingPolicyRule
**ret
);
69 int routing_policy_rule_make_local(Manager
*m
, RoutingPolicyRule
*rule
);
70 int routing_policy_serialize_rules(Set
*rules
, FILE *f
);
71 int routing_policy_load_rules(const char *state_file
, Set
**rules
);
72 void routing_policy_rule_purge(Manager
*m
, Link
*link
);
74 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_tos
);
75 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_table
);
76 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_fwmark_mask
);
77 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_prefix
);
78 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_priority
);
79 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_device
);
80 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_port_range
);
81 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_ip_protocol
);