]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
fc2f9534 LP |
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; | |
f4859fc7 | 24 | typedef struct NetworkConfigSection NetworkConfigSection; |
fc2f9534 | 25 | |
fc2f9534 LP |
26 | #include "networkd-network.h" |
27 | ||
28 | struct Route { | |
29 | Network *network; | |
f4859fc7 | 30 | NetworkConfigSection *section; |
fc2f9534 | 31 | |
1c8e710c TG |
32 | Link *link; |
33 | ||
fc2f9534 | 34 | int family; |
09f5dfad SS |
35 | int quickack; |
36 | ||
fc2f9534 LP |
37 | unsigned char dst_prefixlen; |
38 | unsigned char src_prefixlen; | |
39 | unsigned char scope; | |
fc2f9534 | 40 | unsigned char protocol; /* RTPROT_* */ |
983226f3 | 41 | unsigned char type; /* RTN_* */ |
bb7ae737 | 42 | unsigned char tos; |
86655331 | 43 | uint32_t priority; /* note that ip(8) calls this 'metric' */ |
c953b24c | 44 | uint32_t table; |
d6fceaf1 | 45 | uint32_t mtu; |
323d9329 SS |
46 | uint32_t initcwnd; |
47 | uint32_t initrwnd; | |
3b015d40 TG |
48 | unsigned char pref; |
49 | unsigned flags; | |
fc2f9534 | 50 | |
2ce40956 TG |
51 | union in_addr_union gw; |
52 | union in_addr_union dst; | |
53 | union in_addr_union src; | |
54 | union in_addr_union prefsrc; | |
fc2f9534 | 55 | |
f833694d TG |
56 | usec_t lifetime; |
57 | sd_event_source *expire; | |
58 | ||
fc2f9534 LP |
59 | LIST_FIELDS(Route, routes); |
60 | }; | |
61 | ||
f4859fc7 | 62 | int route_new_static(Network *network, const char *filename, unsigned section_line, Route **ret); |
ed9e361a | 63 | int route_new(Route **ret); |
fc2f9534 LP |
64 | void route_free(Route *route); |
65 | int route_configure(Route *route, Link *link, sd_netlink_message_handler_t callback); | |
91b5f997 | 66 | int route_remove(Route *route, Link *link, sd_netlink_message_handler_t callback); |
fc2f9534 | 67 | |
14d20d2b SS |
68 | 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); |
69 | 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); | |
70 | 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); | |
bbd15900 | 71 | 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); |
1c8e710c | 72 | |
f833694d TG |
73 | int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdata); |
74 | ||
fc2f9534 LP |
75 | DEFINE_TRIVIAL_CLEANUP_FUNC(Route*, route_free); |
76 | #define _cleanup_route_free_ _cleanup_(route_freep) | |
77 | ||
78 | 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); | |
0d07e595 | 79 | 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); |
fc2f9534 LP |
80 | 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); |
81 | 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); | |
82 | 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); | |
c953b24c | 83 | 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); |
28959f7d | 84 | 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); |
b5bf6f64 | 85 | 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); |
c83ecc04 | 86 | 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); |
983226f3 | 87 | 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); |
323d9329 | 88 | int config_parse_tcp_window(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); |
09f5dfad | 89 | int config_parse_quickack(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); |