]>
Commit | Line | Data |
---|---|---|
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 | #include <arpa/inet.h> | |
23 | ||
24 | #include "sd-bus.h" | |
25 | #include "sd-event.h" | |
26 | #include "sd-netlink.h" | |
27 | ||
28 | #include "hashmap.h" | |
29 | #include "list.h" | |
30 | #include "udev.h" | |
31 | ||
32 | typedef struct Manager Manager; | |
33 | ||
34 | #include "networkd-address-pool.h" | |
35 | #include "networkd-link.h" | |
36 | #include "networkd-network.h" | |
37 | #include "networkd-util.h" | |
38 | ||
39 | struct Manager { | |
40 | sd_netlink *rtnl; | |
41 | sd_event *event; | |
42 | sd_event_source *bus_retry_event_source; | |
43 | sd_bus *bus; | |
44 | sd_bus_slot *prepare_for_sleep_slot; | |
45 | struct udev *udev; | |
46 | struct udev_monitor *udev_monitor; | |
47 | sd_event_source *udev_event_source; | |
48 | ||
49 | bool enumerating:1; | |
50 | bool dirty:1; | |
51 | ||
52 | Set *dirty_links; | |
53 | ||
54 | char *state_file; | |
55 | LinkOperationalState operational_state; | |
56 | ||
57 | Hashmap *links; | |
58 | Hashmap *netdevs; | |
59 | Hashmap *networks_by_name; | |
60 | LIST_HEAD(Network, networks); | |
61 | LIST_HEAD(AddressPool, address_pools); | |
62 | ||
63 | usec_t network_dirs_ts_usec; | |
64 | }; | |
65 | ||
66 | extern const char* const network_dirs[]; | |
67 | ||
68 | /* Manager */ | |
69 | ||
70 | extern const sd_bus_vtable manager_vtable[]; | |
71 | ||
72 | int manager_new(Manager **ret); | |
73 | void manager_free(Manager *m); | |
74 | ||
75 | int manager_connect_bus(Manager *m); | |
76 | int manager_run(Manager *m); | |
77 | ||
78 | int manager_load_config(Manager *m); | |
79 | bool manager_should_reload(Manager *m); | |
80 | ||
81 | int manager_rtnl_enumerate_links(Manager *m); | |
82 | int manager_rtnl_enumerate_addresses(Manager *m); | |
83 | int manager_rtnl_enumerate_routes(Manager *m); | |
84 | ||
85 | int manager_rtnl_process_address(sd_netlink *nl, sd_netlink_message *message, void *userdata); | |
86 | int manager_rtnl_process_route(sd_netlink *nl, sd_netlink_message *message, void *userdata); | |
87 | ||
88 | int manager_send_changed(Manager *m, const char *property, ...) _sentinel_; | |
89 | void manager_dirty(Manager *m); | |
90 | ||
91 | int manager_address_pool_acquire(Manager *m, int family, unsigned prefixlen, union in_addr_union *found); | |
92 | ||
93 | Link* manager_find_uplink(Manager *m, Link *exclude); | |
94 | ||
95 | DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free); | |
96 | #define _cleanup_manager_free_ _cleanup_(manager_freep) |