1 /* SPDX-License-Identifier: LGPL-2.1+ */
7 #include "in-addr-util.h"
8 #include "conf-parser.h"
10 typedef struct RoutingPolicyRule RoutingPolicyRule
;
12 #include "networkd-link.h"
13 #include "networkd-network.h"
15 typedef struct Network Network
;
16 typedef struct Link Link
;
17 typedef struct NetworkConfigSection NetworkConfigSection
;
18 typedef struct Manager Manager
;
20 struct RoutingPolicyRule
{
24 NetworkConfigSection
*section
;
34 unsigned char to_prefixlen
;
35 unsigned char from_prefixlen
;
40 union in_addr_union to
;
41 union in_addr_union from
;
43 LIST_FIELDS(RoutingPolicyRule
, rules
);
46 int routing_policy_rule_new(RoutingPolicyRule
**ret
);
47 void routing_policy_rule_free(RoutingPolicyRule
*rule
);
49 DEFINE_TRIVIAL_CLEANUP_FUNC(RoutingPolicyRule
*, routing_policy_rule_free
);
51 int routing_policy_rule_configure(RoutingPolicyRule
*address
, Link
*link
, sd_netlink_message_handler_t callback
, bool update
);
52 int routing_policy_rule_remove(RoutingPolicyRule
*routing_policy_rule
, Link
*link
, sd_netlink_message_handler_t callback
);
53 int link_routing_policy_rule_remove_handler(sd_netlink
*rtnl
, sd_netlink_message
*m
, void *userdata
);
54 int link_routing_policy_rule_handler(sd_netlink
*rtnl
, sd_netlink_message
*m
, void *userdata
);
56 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
,
57 uint8_t tos
, uint32_t fwmark
, uint32_t table
, const char *iif
, const char *oif
, RoutingPolicyRule
**ret
);
58 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
,
59 uint8_t tos
, uint32_t fwmark
, uint32_t table
, const char *iif
, const char *oif
, RoutingPolicyRule
**ret
);
60 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
,
61 uint32_t fwmark
, uint32_t table
, const char *iif
, const char *oif
, RoutingPolicyRule
**ret
);
62 int routing_policy_rule_make_local(Manager
*m
, RoutingPolicyRule
*rule
);
63 int routing_policy_serialize_rules(Set
*rules
, FILE *f
);
64 int routing_policy_load_rules(const char *state_file
, Set
**rules
);
65 void routing_policy_rule_purge(Manager
*m
, Link
*link
);
67 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_tos
);
68 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_table
);
69 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_fwmark_mask
);
70 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_prefix
);
71 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_priority
);
72 CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_device
);