1 /* SPDX-License-Identifier: LGPL-2.1+ */
5 This file is part of systemd.
7 Copyright 2017 Susant Sahani
13 #include "in-addr-util.h"
15 typedef struct RoutingPolicyRule RoutingPolicyRule
;
17 #include "networkd-link.h"
18 #include "networkd-network.h"
20 typedef struct Network Network
;
21 typedef struct Link Link
;
22 typedef struct NetworkConfigSection NetworkConfigSection
;
23 typedef struct Manager Manager
;
25 struct RoutingPolicyRule
{
29 NetworkConfigSection
*section
;
39 unsigned char to_prefixlen
;
40 unsigned char from_prefixlen
;
45 union in_addr_union to
;
46 union in_addr_union from
;
48 LIST_FIELDS(RoutingPolicyRule
, rules
);
51 int routing_policy_rule_new(RoutingPolicyRule
**ret
);
52 void routing_policy_rule_free(RoutingPolicyRule
*rule
);
54 DEFINE_TRIVIAL_CLEANUP_FUNC(RoutingPolicyRule
*, routing_policy_rule_free
);
55 #define _cleanup_routing_policy_rule_free_ _cleanup_(routing_policy_rule_freep)
57 int routing_policy_rule_configure(RoutingPolicyRule
*address
, Link
*link
, sd_netlink_message_handler_t callback
, bool update
);
58 int routing_policy_rule_remove(RoutingPolicyRule
*routing_policy_rule
, Link
*link
, sd_netlink_message_handler_t callback
);
59 int link_routing_policy_rule_remove_handler(sd_netlink
*rtnl
, sd_netlink_message
*m
, void *userdata
);
60 int link_routing_policy_rule_handler(sd_netlink
*rtnl
, sd_netlink_message
*m
, void *userdata
);
62 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
,
63 uint8_t tos
, uint32_t fwmark
, uint32_t table
, char *iif
, char *oif
, RoutingPolicyRule
**ret
);
64 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
,
65 uint8_t tos
, uint32_t fwmark
, uint32_t table
, char *iif
, char *oif
, 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
, char *iif
, char *oif
, RoutingPolicyRule
**ret
);
68 int routing_policy_rule_make_local(Manager
*m
, RoutingPolicyRule
*rule
);
69 int routing_policy_serialize_rules(Set
*rules
, FILE *f
);
70 int routing_policy_load_rules(const char *state_file
, Set
**rules
);
71 void routing_policy_rule_purge(Manager
*m
, Link
*link
);
73 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
);
74 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
);
75 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
);
76 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
);
77 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
);
78 int config_parse_routing_policy_rule_device(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
);