2017-11-18 17:09:20 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
2017-09-14 21:51:39 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include "in-addr-util.h"
|
2018-05-22 13:10:17 +02:00
|
|
|
#include "conf-parser.h"
|
2017-09-14 21:51:39 +02:00
|
|
|
|
|
|
|
typedef struct RoutingPolicyRule RoutingPolicyRule;
|
|
|
|
|
|
|
|
#include "networkd-link.h"
|
|
|
|
#include "networkd-network.h"
|
|
|
|
|
|
|
|
typedef struct Network Network;
|
|
|
|
typedef struct Link Link;
|
|
|
|
typedef struct NetworkConfigSection NetworkConfigSection;
|
2017-12-21 13:27:45 +01:00
|
|
|
typedef struct Manager Manager;
|
2017-09-14 21:51:39 +02:00
|
|
|
|
|
|
|
struct RoutingPolicyRule {
|
2018-01-24 15:57:53 +01:00
|
|
|
Manager *manager;
|
2017-09-14 21:51:39 +02:00
|
|
|
Network *network;
|
|
|
|
Link *link;
|
|
|
|
NetworkConfigSection *section;
|
|
|
|
|
|
|
|
uint8_t tos;
|
|
|
|
|
|
|
|
uint32_t table;
|
|
|
|
uint32_t fwmark;
|
|
|
|
uint32_t fwmask;
|
|
|
|
uint32_t priority;
|
|
|
|
|
|
|
|
int family;
|
|
|
|
unsigned char to_prefixlen;
|
|
|
|
unsigned char from_prefixlen;
|
|
|
|
|
2017-11-21 11:51:50 +01:00
|
|
|
char *iif;
|
|
|
|
char *oif;
|
|
|
|
|
2017-09-14 21:51:39 +02:00
|
|
|
union in_addr_union to;
|
|
|
|
union in_addr_union from;
|
|
|
|
|
|
|
|
LIST_FIELDS(RoutingPolicyRule, rules);
|
|
|
|
};
|
|
|
|
|
|
|
|
int routing_policy_rule_new(RoutingPolicyRule **ret);
|
|
|
|
void routing_policy_rule_free(RoutingPolicyRule *rule);
|
|
|
|
|
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(RoutingPolicyRule*, routing_policy_rule_free);
|
|
|
|
|
|
|
|
int routing_policy_rule_configure(RoutingPolicyRule *address, Link *link, sd_netlink_message_handler_t callback, bool update);
|
|
|
|
int routing_policy_rule_remove(RoutingPolicyRule *routing_policy_rule, Link *link, sd_netlink_message_handler_t callback);
|
|
|
|
int link_routing_policy_rule_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata);
|
|
|
|
int link_routing_policy_rule_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata);
|
|
|
|
|
|
|
|
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,
|
2018-09-27 10:27:04 +02:00
|
|
|
uint8_t tos, uint32_t fwmark, uint32_t table, const char *iif, const char *oif, RoutingPolicyRule **ret);
|
2017-09-14 21:51:39 +02:00
|
|
|
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,
|
2018-09-27 10:27:04 +02:00
|
|
|
uint8_t tos, uint32_t fwmark, uint32_t table, const char *iif, const char *oif, RoutingPolicyRule **ret);
|
2017-09-14 21:51:39 +02:00
|
|
|
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,
|
2018-09-27 10:27:04 +02:00
|
|
|
uint32_t fwmark, uint32_t table, const char *iif, const char *oif, RoutingPolicyRule **ret);
|
2017-09-14 21:51:39 +02:00
|
|
|
int routing_policy_rule_make_local(Manager *m, RoutingPolicyRule *rule);
|
2017-11-27 11:22:51 +01:00
|
|
|
int routing_policy_serialize_rules(Set *rules, FILE *f);
|
|
|
|
int routing_policy_load_rules(const char *state_file, Set **rules);
|
2017-09-14 21:51:39 +02:00
|
|
|
void routing_policy_rule_purge(Manager *m, Link *link);
|
|
|
|
|
2018-05-22 13:10:17 +02:00
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_tos);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_table);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_fwmark_mask);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_prefix);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_priority);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_device);
|