2017-11-18 17:09:20 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
2016-02-16 20:05:15 +01:00
|
|
|
#pragma once
|
|
|
|
|
2013-10-17 03:18:36 +02:00
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
2015-11-18 22:46:33 +01:00
|
|
|
#include "sd-bus.h"
|
2013-10-17 03:18:36 +02:00
|
|
|
#include "sd-event.h"
|
2015-06-12 16:31:33 +02:00
|
|
|
#include "sd-netlink.h"
|
2017-12-18 15:17:06 +01:00
|
|
|
#include "sd-resolve.h"
|
2016-04-29 04:52:04 +02:00
|
|
|
#include "udev.h"
|
2013-10-17 03:18:36 +02:00
|
|
|
|
2016-04-29 04:52:04 +02:00
|
|
|
#include "dhcp-identifier.h"
|
2013-10-17 03:18:36 +02:00
|
|
|
#include "hashmap.h"
|
|
|
|
#include "list.h"
|
|
|
|
|
2015-08-27 13:59:06 +02:00
|
|
|
#include "networkd-address-pool.h"
|
|
|
|
#include "networkd-link.h"
|
2015-11-18 22:46:33 +01:00
|
|
|
#include "networkd-network.h"
|
2014-06-18 18:22:14 +02:00
|
|
|
|
2016-04-29 04:52:04 +02:00
|
|
|
extern const char* const network_dirs[];
|
|
|
|
|
2013-10-17 03:18:36 +02:00
|
|
|
struct Manager {
|
2015-06-12 16:31:33 +02:00
|
|
|
sd_netlink *rtnl;
|
2017-12-18 15:17:06 +01:00
|
|
|
/* lazy initialized */
|
|
|
|
sd_netlink *genl;
|
2013-10-17 03:18:36 +02:00
|
|
|
sd_event *event;
|
2017-12-18 15:17:06 +01:00
|
|
|
sd_resolve *resolve;
|
2014-01-13 23:48:28 +01:00
|
|
|
sd_bus *bus;
|
2013-10-17 03:18:36 +02:00
|
|
|
struct udev *udev;
|
|
|
|
struct udev_monitor *udev_monitor;
|
|
|
|
sd_event_source *udev_event_source;
|
|
|
|
|
2015-09-30 18:17:43 +02:00
|
|
|
bool enumerating:1;
|
|
|
|
bool dirty:1;
|
|
|
|
|
|
|
|
Set *dirty_links;
|
2015-02-04 10:08:12 +01:00
|
|
|
|
2014-05-08 17:21:37 +02:00
|
|
|
char *state_file;
|
2015-02-04 11:44:37 +01:00
|
|
|
LinkOperationalState operational_state;
|
2014-05-08 17:21:37 +02:00
|
|
|
|
2013-10-17 03:18:36 +02:00
|
|
|
Hashmap *links;
|
2014-01-21 21:58:08 +01:00
|
|
|
Hashmap *netdevs;
|
2015-02-08 13:29:35 +01:00
|
|
|
Hashmap *networks_by_name;
|
2018-01-04 14:11:58 +01:00
|
|
|
Hashmap *dhcp6_prefixes;
|
2013-10-17 03:18:36 +02:00
|
|
|
LIST_HEAD(Network, networks);
|
2014-06-18 18:22:14 +02:00
|
|
|
LIST_HEAD(AddressPool, address_pools);
|
2013-10-17 03:18:36 +02:00
|
|
|
|
|
|
|
usec_t network_dirs_ts_usec;
|
2016-03-31 01:33:55 +02:00
|
|
|
|
networkd: rework duid_{type,duid_type,duid,duid_len} setting
Separate fields are replaced with a struct.
Second second duid type field is removed. The first field was used to carry
the result of DUIDType= configuration, and the second was either a copy of
this, or contained the type extracted from DuidRawData. The semantics are changed
so that the type specified in DUIDType is always used. DUIDRawData= no longer
overrides the type setting.
The networkd code is now more constrained than the sd-dhcp code:
DUIDRawData cannot have 0 length, length 0 is treated the same as unsetting.
Likewise, it is not possible to set a DUIDType=0. If it ever becomes necessary
to set type=0 or a zero-length duid, the code can be changed to support that.
Nevertheless, I think that's unlikely.
This addresses #3127 § 1 and 3.
v2:
- rename DUID.duid, DUID.duid_len to DUID.raw_data, DUID.raw_data_len
2016-04-29 05:23:45 +02:00
|
|
|
DUID duid;
|
2016-11-22 08:36:20 +01:00
|
|
|
char* dynamic_hostname;
|
|
|
|
char* dynamic_timezone;
|
2017-09-14 21:51:39 +02:00
|
|
|
|
|
|
|
Set *rules;
|
|
|
|
Set *rules_foreign;
|
|
|
|
Set *rules_saved;
|
2013-10-17 03:18:36 +02:00
|
|
|
};
|
|
|
|
|
2015-02-04 11:44:37 +01:00
|
|
|
extern const sd_bus_vtable manager_vtable[];
|
|
|
|
|
2018-07-18 05:37:50 +02:00
|
|
|
int manager_new(Manager **ret);
|
2013-10-17 03:18:36 +02:00
|
|
|
void manager_free(Manager *m);
|
|
|
|
|
2015-02-05 18:00:16 +01:00
|
|
|
int manager_connect_bus(Manager *m);
|
2016-11-28 20:42:40 +01:00
|
|
|
int manager_start(Manager *m);
|
2015-02-04 15:00:20 +01:00
|
|
|
|
2013-11-24 23:37:56 +01:00
|
|
|
int manager_load_config(Manager *m);
|
|
|
|
bool manager_should_reload(Manager *m);
|
|
|
|
|
2014-04-15 14:21:44 +02:00
|
|
|
int manager_rtnl_enumerate_links(Manager *m);
|
2014-12-08 19:54:06 +01:00
|
|
|
int manager_rtnl_enumerate_addresses(Manager *m);
|
2015-10-25 14:46:21 +01:00
|
|
|
int manager_rtnl_enumerate_routes(Manager *m);
|
2017-09-14 21:51:39 +02:00
|
|
|
int manager_rtnl_enumerate_rules(Manager *m);
|
2013-10-17 03:18:36 +02:00
|
|
|
|
2015-09-22 17:18:20 +02:00
|
|
|
int manager_rtnl_process_address(sd_netlink *nl, sd_netlink_message *message, void *userdata);
|
2015-10-25 14:46:21 +01:00
|
|
|
int manager_rtnl_process_route(sd_netlink *nl, sd_netlink_message *message, void *userdata);
|
2017-09-14 21:51:39 +02:00
|
|
|
int manager_rtnl_process_rule(sd_netlink *nl, sd_netlink_message *message, void *userdata);
|
2015-09-22 17:18:20 +02:00
|
|
|
|
2015-02-04 11:44:37 +01:00
|
|
|
int manager_send_changed(Manager *m, const char *property, ...) _sentinel_;
|
2015-09-30 18:17:43 +02:00
|
|
|
void manager_dirty(Manager *m);
|
2014-01-05 23:01:10 +01:00
|
|
|
|
2014-07-18 16:09:30 +02:00
|
|
|
int manager_address_pool_acquire(Manager *m, int family, unsigned prefixlen, union in_addr_union *found);
|
2014-06-18 18:22:14 +02:00
|
|
|
|
2015-08-27 16:45:24 +02:00
|
|
|
Link* manager_find_uplink(Manager *m, Link *exclude);
|
|
|
|
|
2016-11-21 23:15:41 +01:00
|
|
|
int manager_set_hostname(Manager *m, const char *hostname);
|
|
|
|
int manager_set_timezone(Manager *m, const char *timezone);
|
|
|
|
|
2018-01-04 14:11:58 +01:00
|
|
|
Link *manager_dhcp6_prefix_get(Manager *m, struct in6_addr *addr);
|
|
|
|
int manager_dhcp6_prefix_add(Manager *m, struct in6_addr *addr, Link *link);
|
|
|
|
int manager_dhcp6_prefix_remove(Manager *m, struct in6_addr *addr);
|
|
|
|
int manager_dhcp6_prefix_remove_all(Manager *m, Link *link);
|
|
|
|
|
2013-10-17 03:18:36 +02:00
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
|