]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/network/networkd-route.h
Fix #7704 and #7708. (#7712)
[thirdparty/systemd.git] / src / network / networkd-route.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 This file is part of systemd.
6
7 Copyright 2013 Tom Gundersen <teg@jklm.no>
8
9 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
13
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21 ***/
22
23 typedef struct Route Route;
24 typedef struct NetworkConfigSection NetworkConfigSection;
25
26 #include "networkd-network.h"
27
28 struct Route {
29 Manager *m;
30 Network *network;
31 NetworkConfigSection *section;
32
33 Link *link;
34
35 int family;
36 unsigned char dst_prefixlen;
37 unsigned char src_prefixlen;
38 unsigned char scope;
39 unsigned char protocol; /* RTPROT_* */
40 unsigned char type; /* RTN_* */
41 unsigned char tos;
42 uint32_t priority; /* note that ip(8) calls this 'metric' */
43 uint32_t table;
44 uint32_t mtu;
45 unsigned char pref;
46 unsigned flags;
47
48 union in_addr_union gw;
49 union in_addr_union dst;
50 union in_addr_union src;
51 union in_addr_union prefsrc;
52
53 usec_t lifetime;
54 sd_event_source *expire;
55
56 LIST_FIELDS(Route, routes);
57 };
58
59 int route_new_static(Network *network, const char *filename, unsigned section_line, Route **ret);
60 int route_new(Route **ret);
61 void route_free(Route *route);
62 int route_configure(Route *route, Link *link, sd_netlink_message_handler_t callback);
63 int route_remove(Route *route, Link *link, sd_netlink_message_handler_t callback);
64
65 int route_get(Link *link, int family, const union in_addr_union *dst, unsigned char dst_prefixlen, unsigned char tos, uint32_t priority, uint32_t table, Route **ret);
66 int route_add(Link *link, int family, const union in_addr_union *dst, unsigned char dst_prefixlen, unsigned char tos, uint32_t priority, uint32_t table, Route **ret);
67 int route_add_foreign(Link *link, int family, const union in_addr_union *dst, unsigned char dst_prefixlen, unsigned char tos, uint32_t priority, uint32_t table, Route **ret);
68 void route_update(Route *route, const union in_addr_union *src, unsigned char src_prefixlen, const union in_addr_union *gw, const union in_addr_union *prefsrc, unsigned char scope, unsigned char protocol, unsigned char type);
69
70 int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdata);
71
72 DEFINE_TRIVIAL_CLEANUP_FUNC(Route*, route_free);
73 #define _cleanup_route_free_ _cleanup_(route_freep)
74
75 int config_parse_gateway(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_preferred_src(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_destination(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_route_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);
79 int config_parse_route_scope(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);
80 int config_parse_route_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);
81 int config_parse_gateway_onlink(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);
82 int config_parse_ipv6_route_preference(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);
83 int config_parse_route_protocol(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);
84 int config_parse_route_type(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);