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