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