2020-11-09 05:23:58 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
2017-09-14 21:51:39 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
2018-11-27 06:28:54 +01:00
|
|
|
#include <linux/fib_rules.h>
|
2017-09-14 21:51:39 +02:00
|
|
|
#include <stdbool.h>
|
2020-09-29 08:29:56 +02:00
|
|
|
#include <stdio.h>
|
2017-09-14 21:51:39 +02:00
|
|
|
|
2018-05-22 13:10:17 +02:00
|
|
|
#include "conf-parser.h"
|
2020-09-29 08:29:56 +02:00
|
|
|
#include "in-addr-util.h"
|
2019-03-01 05:27:47 +01:00
|
|
|
#include "networkd-util.h"
|
2020-09-29 08:29:56 +02:00
|
|
|
#include "set.h"
|
2017-09-14 21:51:39 +02:00
|
|
|
|
|
|
|
typedef struct Network Network;
|
|
|
|
typedef struct Link Link;
|
2017-12-21 13:27:45 +01:00
|
|
|
typedef struct Manager Manager;
|
2017-09-14 21:51:39 +02:00
|
|
|
|
2020-09-29 08:29:56 +02:00
|
|
|
typedef struct RoutingPolicyRule {
|
2018-01-24 15:57:53 +01:00
|
|
|
Manager *manager;
|
2017-09-14 21:51:39 +02:00
|
|
|
Network *network;
|
|
|
|
NetworkConfigSection *section;
|
|
|
|
|
2018-12-03 13:55:30 +01:00
|
|
|
bool invert_rule;
|
|
|
|
|
2017-09-14 21:51:39 +02:00
|
|
|
uint8_t tos;
|
2018-11-27 06:28:54 +01:00
|
|
|
uint8_t protocol;
|
2017-09-14 21:51:39 +02:00
|
|
|
|
|
|
|
uint32_t table;
|
|
|
|
uint32_t fwmark;
|
|
|
|
uint32_t fwmask;
|
|
|
|
uint32_t priority;
|
|
|
|
|
2019-08-01 00:41:36 +02:00
|
|
|
AddressFamily address_family; /* Specified by Family= */
|
|
|
|
int family; /* Automatically determined by From= or To= */
|
2017-09-14 21:51:39 +02:00
|
|
|
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;
|
|
|
|
|
2018-11-27 06:28:54 +01:00
|
|
|
struct fib_rule_port_range sport;
|
|
|
|
struct fib_rule_port_range dport;
|
2020-01-26 14:22:38 +01:00
|
|
|
struct fib_rule_uid_range uid_range;
|
2018-11-27 06:28:54 +01:00
|
|
|
|
2020-02-03 00:25:48 +01:00
|
|
|
int suppress_prefixlen;
|
2020-09-29 08:29:56 +02:00
|
|
|
} RoutingPolicyRule;
|
2017-09-14 21:51:39 +02:00
|
|
|
|
2020-09-29 08:36:53 +02:00
|
|
|
RoutingPolicyRule *routing_policy_rule_free(RoutingPolicyRule *rule);
|
2020-09-29 17:50:30 +02:00
|
|
|
|
2020-10-06 20:21:59 +02:00
|
|
|
void network_drop_invalid_routing_policy_rules(Network *network);
|
2017-09-14 21:51:39 +02:00
|
|
|
|
2020-09-29 07:17:27 +02:00
|
|
|
int link_set_routing_policy_rules(Link *link);
|
|
|
|
|
2020-09-29 09:23:57 +02:00
|
|
|
int manager_rtnl_process_rule(sd_netlink *rtnl, sd_netlink_message *message, Manager *m);
|
|
|
|
|
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
|
|
|
|
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);
|
2018-11-27 06:28:54 +01:00
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_port_range);
|
2018-11-29 16:42:39 +01:00
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_ip_protocol);
|
2018-12-03 13:55:30 +01:00
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_invert);
|
2019-08-01 00:41:36 +02:00
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_family);
|
2020-01-26 14:22:38 +01:00
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_uid_range);
|
2020-02-03 00:25:48 +01:00
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_routing_policy_rule_suppress_prefixlen);
|