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