1 /* SPDX-License-Identifier: LGPL-2.1-or-later */ 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 "firewall-util.h" 13 #include "hashmap.h" 14 #include "networkd-link.h" 15 #include "networkd-network.h" 16 #include "ordered-set.h" 17 #include "set.h" 18 #include "time-util.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 int ethtool_fd; 30 31 KeepConfiguration keep_configuration; 32 33 bool test_mode; 34 bool enumerating; 35 bool dirty; 36 bool restarting; 37 bool manage_foreign_routes; 38 bool manage_foreign_rules; 39 40 Set *dirty_links; 41 42 char *state_file; 43 LinkOperationalState operational_state; 44 LinkCarrierState carrier_state; 45 LinkAddressState address_state; 46 LinkAddressState ipv4_address_state; 47 LinkAddressState ipv6_address_state; 48 LinkOnlineState online_state; 49 50 Hashmap *links_by_index; 51 Hashmap *links_by_name; 52 Hashmap *links_by_hw_addr; 53 Hashmap *links_by_dhcp_pd_subnet_prefix; 54 Hashmap *netdevs; 55 OrderedHashmap *networks; 56 OrderedSet *address_pools; 57 Set *dhcp_pd_subnet_ids; 58 59 usec_t network_dirs_ts_usec; 60 61 DUID dhcp_duid; 62 DUID dhcp6_duid; 63 DUID duid_product_uuid; 64 bool has_product_uuid; 65 bool product_uuid_requested; 66 67 char* dynamic_hostname; 68 char* dynamic_timezone; 69 70 Set *rules; 71 72 /* Manage nexthops by id. */ 73 Hashmap *nexthops_by_id; 74 75 /* Manager stores nexthops without RTA_OIF attribute. */ 76 Set *nexthops; 77 78 /* Manager stores routes without RTA_OIF attribute. */ 79 unsigned route_remove_messages; 80 Set *routes; 81 Set *routes_foreign; 82 83 /* Route table name */ 84 Hashmap *route_table_numbers_by_name; 85 Hashmap *route_table_names_by_number; 86 87 /* Wiphy */ 88 Hashmap *wiphy_by_index; 89 Hashmap *wiphy_by_name; 90 91 /* For link speed meter */ 92 bool use_speed_meter; 93 sd_event_source *speed_meter_event_source; 94 usec_t speed_meter_interval_usec; 95 usec_t speed_meter_usec_new; 96 usec_t speed_meter_usec_old; 97 98 bool dhcp4_prefix_root_cannot_set_table; 99 bool bridge_mdb_on_master_not_supported; 100 101 FirewallContext *fw_ctx; 102 103 OrderedSet *request_queue; 104 }; 105 106 int manager_new(Manager **ret, bool test_mode); 107 Manager* manager_free(Manager *m); 108 109 int manager_setup(Manager *m); 110 int manager_start(Manager *m); 111 112 int manager_load_config(Manager *m); 113 bool manager_should_reload(Manager *m); 114 115 int manager_enumerate(Manager *m); 116 117 int manager_set_hostname(Manager *m, const char *hostname); 118 int manager_set_timezone(Manager *m, const char *timezone); 119 120 DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free); 121