]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/network/networkd-route.h
ddc3e1da57d07555fac37e8eb678228f16dd6447
[thirdparty/systemd.git] / src / network / networkd-route.h
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;
23
24 #include "networkd-network.h"
25
26 struct Route {
27 Network *network;
28 unsigned section;
29
30 Link *link;
31
32 int family;
33 unsigned char dst_prefixlen;
34 unsigned char src_prefixlen;
35 unsigned char scope;
36 unsigned char protocol; /* RTPROT_* */
37 unsigned char tos;
38 uint32_t priority; /* note that ip(8) calls this 'metric' */
39 uint32_t table;
40 unsigned char pref;
41 unsigned flags;
42
43 union in_addr_union gw;
44 union in_addr_union dst;
45 union in_addr_union src;
46 union in_addr_union prefsrc;
47
48 usec_t lifetime;
49 sd_event_source *expire;
50
51 LIST_FIELDS(Route, routes);
52 };
53
54 int route_new_static(Network *network, unsigned section, Route **ret);
55 int route_new(Route **ret);
56 void route_free(Route *route);
57 int route_configure(Route *route, Link *link, sd_netlink_message_handler_t callback);
58 int route_remove(Route *route, Link *link, sd_netlink_message_handler_t callback);
59
60 int route_get(Link *link, int family, const union in_addr_union *dst, unsigned char dst_prefixlen, unsigned char tos, uint32_t priority, unsigned char table, Route **ret);
61 int route_add(Link *link, int family, union in_addr_union *dst, unsigned char dst_prefixlen, unsigned char tos, uint32_t priority, unsigned char table, Route **ret);
62 int route_add_foreign(Link *link, int family, union in_addr_union *dst, unsigned char dst_prefixlen, unsigned char tos, uint32_t priority, unsigned char table, Route **ret);
63 int route_update(Route *route, union in_addr_union *src, unsigned char src_prefixlen, union in_addr_union *gw, union in_addr_union *prefsrc, unsigned char scope, unsigned char protocol);
64
65 int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdata);
66
67 DEFINE_TRIVIAL_CLEANUP_FUNC(Route*, route_free);
68 #define _cleanup_route_free_ _cleanup_(route_freep)
69
70 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);
71 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);
72 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);
73 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);
74 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);
75 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);