Line data Source code
1 : /* SPDX-License-Identifier: LGPL-2.1+ */ 2 : #pragma once 3 : 4 : #include "sd-bus.h" 5 : #include "sd-device.h" 6 : #include "sd-event.h" 7 : #include "sd-id128.h" 8 : #include "sd-netlink.h" 9 : #include "sd-resolve.h" 10 : 11 : #include "dhcp-identifier.h" 12 : #include "hashmap.h" 13 : #include "list.h" 14 : #include "time-util.h" 15 : 16 : #include "networkd-address-pool.h" 17 : #include "networkd-link.h" 18 : #include "networkd-network.h" 19 : 20 : struct Manager { 21 : sd_netlink *rtnl; 22 : /* lazy initialized */ 23 : sd_netlink *genl; 24 : sd_event *event; 25 : sd_resolve *resolve; 26 : sd_bus *bus; 27 : sd_device_monitor *device_monitor; 28 : Hashmap *polkit_registry; 29 : 30 : bool enumerating:1; 31 : bool dirty:1; 32 : 33 : Set *dirty_links; 34 : 35 : char *state_file; 36 : LinkOperationalState operational_state; 37 : LinkCarrierState carrier_state; 38 : LinkAddressState address_state; 39 : 40 : Hashmap *links; 41 : Hashmap *netdevs; 42 : OrderedHashmap *networks; 43 : Hashmap *dhcp6_prefixes; 44 : LIST_HEAD(AddressPool, address_pools); 45 : 46 : usec_t network_dirs_ts_usec; 47 : 48 : DUID duid; 49 : sd_id128_t product_uuid; 50 : bool has_product_uuid; 51 : Set *links_requesting_uuid; 52 : Set *duids_requesting_uuid; 53 : 54 : char* dynamic_hostname; 55 : char* dynamic_timezone; 56 : 57 : Set *rules; 58 : Set *rules_foreign; 59 : Set *rules_saved; 60 : 61 : /* For link speed meter*/ 62 : bool use_speed_meter; 63 : sd_event_source *speed_meter_event_source; 64 : usec_t speed_meter_interval_usec; 65 : usec_t speed_meter_usec_new; 66 : usec_t speed_meter_usec_old; 67 : }; 68 : 69 : int manager_new(Manager **ret); 70 : void manager_free(Manager *m); 71 : 72 : int manager_connect_bus(Manager *m); 73 : int manager_start(Manager *m); 74 : 75 : int manager_load_config(Manager *m); 76 : bool manager_should_reload(Manager *m); 77 : 78 : int manager_rtnl_enumerate_links(Manager *m); 79 : int manager_rtnl_enumerate_addresses(Manager *m); 80 : int manager_rtnl_enumerate_neighbors(Manager *m); 81 : int manager_rtnl_enumerate_routes(Manager *m); 82 : int manager_rtnl_enumerate_rules(Manager *m); 83 : 84 : int manager_rtnl_process_address(sd_netlink *nl, sd_netlink_message *message, void *userdata); 85 : int manager_rtnl_process_neighbor(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 : int manager_rtnl_process_rule(sd_netlink *nl, sd_netlink_message *message, void *userdata); 88 : 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 : int manager_set_hostname(Manager *m, const char *hostname); 96 : int manager_set_timezone(Manager *m, const char *timezone); 97 : int manager_request_product_uuid(Manager *m, Link *link); 98 : 99 2 : DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);