1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2013 Tom Gundersen <teg@jklm.no>
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.
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.
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/>.
24 #include <arpa/inet.h>
25 #include <linux/rtnetlink.h>
31 #include "rtnl-util.h"
35 typedef struct Network Network;
36 typedef struct Link Link;
37 typedef struct Address Address;
38 typedef struct Route Route;
39 typedef struct Manager Manager;
46 struct ether_addr *match_mac;
54 LIST_HEAD(Address, addresses);
55 LIST_HEAD(Route, routes);
57 LIST_FIELDS(Network, networks);
64 unsigned char prefixlen;
67 struct in_addr netmask;
74 LIST_FIELDS(Address, addresses);
87 LIST_FIELDS(Route, routes);
94 struct ether_addr mac;
105 struct udev_monitor *udev_monitor;
106 sd_event_source *udev_event_source;
109 LIST_HEAD(Network, networks);
112 usec_t network_dirs_ts_usec;
117 int manager_new(Manager **ret);
118 void manager_free(Manager *m);
120 int manager_udev_enumerate_links(Manager *m);
121 int manager_udev_listen(Manager *m);
123 DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
124 #define _cleanup_manager_free_ _cleanup_(manager_freep)
128 int network_load(Manager *manager);
129 bool network_should_reload(Manager *manager);
131 void network_free(Network *network);
133 DEFINE_TRIVIAL_CLEANUP_FUNC(Network*, network_free);
134 #define _cleanup_network_free_ _cleanup_(network_freep)
136 int network_get(Manager *manager, struct udev_device *device, Network **ret);
137 int network_apply(Manager *manager, Network *network, Link *link);
139 const struct ConfigPerfItem* network_gperf_lookup(const char *key, unsigned length);
142 int route_new(Network *network, Route **ret);
143 void route_free(Route *route);
144 int route_configure(Manager *manager, Route *route, Link *link);
146 DEFINE_TRIVIAL_CLEANUP_FUNC(Route*, route_free);
147 #define _cleanup_route_free_ _cleanup_(route_freep)
149 int config_parse_gateway(const char *unit, const char *filename, unsigned line,
150 const char *section, const char *lvalue, int ltype,
151 const char *rvalue, void *data, void *userdata);
154 int address_new(Network *network, Address **ret);
155 void address_free(Address *address);
156 int address_configure(Manager *manager, Address *address, Link *link);
158 DEFINE_TRIVIAL_CLEANUP_FUNC(Address*, address_free);
159 #define _cleanup_address_free_ _cleanup_(address_freep)
161 int config_parse_address(const char *unit, const char *filename, unsigned line,
162 const char *section, const char *lvalue, int ltype,
163 const char *rvalue, void *data, void *userdata);
167 int link_new(Manager *manager, struct udev_device *device, Link **ret);
168 void link_free(Link *link);
169 int link_add(Manager *manager, struct udev_device *device);
170 int link_up(Manager *manager, Link *link);
172 DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_free);
173 #define _cleanup_link_free_ _cleanup_(link_freep)