LCOV - code coverage report
Current view: top level - network - networkd-network.h (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 1 1 100.0 %
Date: 2019-08-22 15:41:25 Functions: 1 1 100.0 %

          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             : 
       7             : #include "condition.h"
       8             : #include "conf-parser.h"
       9             : #include "hashmap.h"
      10             : #include "netdev/bridge.h"
      11             : #include "netdev/netdev.h"
      12             : #include "networkd-address-label.h"
      13             : #include "networkd-address.h"
      14             : #include "networkd-brvlan.h"
      15             : #include "networkd-dhcp-common.h"
      16             : #include "networkd-dhcp4.h"
      17             : #include "networkd-fdb.h"
      18             : #include "networkd-ipv6-proxy-ndp.h"
      19             : #include "networkd-lldp-rx.h"
      20             : #include "networkd-lldp-tx.h"
      21             : #include "networkd-neighbor.h"
      22             : #include "networkd-radv.h"
      23             : #include "networkd-route.h"
      24             : #include "networkd-routing-policy-rule.h"
      25             : #include "networkd-util.h"
      26             : #include "ordered-set.h"
      27             : #include "resolve-util.h"
      28             : 
      29             : typedef enum IPv6PrivacyExtensions {
      30             :         /* The values map to the kernel's /proc/sys/net/ipv6/conf/xxx/use_tempaddr values */
      31             :         IPV6_PRIVACY_EXTENSIONS_NO,
      32             :         IPV6_PRIVACY_EXTENSIONS_PREFER_PUBLIC,
      33             :         IPV6_PRIVACY_EXTENSIONS_YES, /* aka prefer-temporary */
      34             :         _IPV6_PRIVACY_EXTENSIONS_MAX,
      35             :         _IPV6_PRIVACY_EXTENSIONS_INVALID = -1,
      36             : } IPv6PrivacyExtensions;
      37             : 
      38             : typedef enum KeepConfiguration {
      39             :         KEEP_CONFIGURATION_NO            = 0,
      40             :         KEEP_CONFIGURATION_DHCP_ON_START = 1 << 0,
      41             :         KEEP_CONFIGURATION_DHCP_ON_STOP  = 1 << 1,
      42             :         KEEP_CONFIGURATION_DHCP          = KEEP_CONFIGURATION_DHCP_ON_START | KEEP_CONFIGURATION_DHCP_ON_STOP,
      43             :         KEEP_CONFIGURATION_STATIC        = 1 << 2,
      44             :         KEEP_CONFIGURATION_YES           = KEEP_CONFIGURATION_DHCP | KEEP_CONFIGURATION_STATIC,
      45             :         _KEEP_CONFIGURATION_MAX,
      46             :         _KEEP_CONFIGURATION_INVALID = -1,
      47             : } KeepConfiguration;
      48             : 
      49             : typedef struct Manager Manager;
      50             : 
      51             : struct Network {
      52             :         Manager *manager;
      53             : 
      54             :         char *filename;
      55             :         char *name;
      56             : 
      57             :         unsigned n_ref;
      58             : 
      59             :         Set *match_mac;
      60             :         char **match_path;
      61             :         char **match_driver;
      62             :         char **match_type;
      63             :         char **match_name;
      64             :         char **match_property;
      65             :         LIST_HEAD(Condition, conditions);
      66             : 
      67             :         char *description;
      68             : 
      69             :         NetDev *bridge;
      70             :         NetDev *bond;
      71             :         NetDev *vrf;
      72             :         NetDev *xfrm;
      73             :         Hashmap *stacked_netdevs;
      74             :         char *bridge_name;
      75             :         char *bond_name;
      76             :         char *vrf_name;
      77             :         Hashmap *stacked_netdev_names;
      78             : 
      79             :         /* DHCP Client Support */
      80             :         AddressFamily dhcp;
      81             :         DHCPClientIdentifier dhcp_client_identifier;
      82             :         char *dhcp_vendor_class_identifier;
      83             :         char **dhcp_user_class;
      84             :         char *dhcp_hostname;
      85             :         uint64_t dhcp_max_attempts;
      86             :         unsigned dhcp_route_metric;
      87             :         uint32_t dhcp_route_table;
      88             :         uint16_t dhcp_client_port;
      89             :         bool dhcp_anonymize;
      90             :         bool dhcp_send_hostname;
      91             :         bool dhcp_broadcast;
      92             :         int dhcp_critical;
      93             :         bool dhcp_use_dns;
      94             :         bool dhcp_routes_to_dns;
      95             :         bool dhcp_use_ntp;
      96             :         bool dhcp_use_mtu;
      97             :         bool dhcp_use_routes;
      98             :         bool dhcp_use_timezone;
      99             :         bool rapid_commit;
     100             :         bool dhcp_use_hostname;
     101             :         bool dhcp_route_table_set;
     102             :         bool dhcp_send_release;
     103             :         DHCPUseDomains dhcp_use_domains;
     104             :         Set *dhcp_black_listed_ip;
     105             : 
     106             :         /* DHCPv6 Client support*/
     107             :         bool dhcp6_use_dns;
     108             :         bool dhcp6_use_ntp;
     109             : 
     110             :         /* DHCP Server Support */
     111             :         bool dhcp_server;
     112             :         bool dhcp_server_emit_dns;
     113             :         struct in_addr *dhcp_server_dns;
     114             :         unsigned n_dhcp_server_dns;
     115             :         bool dhcp_server_emit_ntp;
     116             :         struct in_addr *dhcp_server_ntp;
     117             :         unsigned n_dhcp_server_ntp;
     118             :         bool dhcp_server_emit_router;
     119             :         bool dhcp_server_emit_timezone;
     120             :         char *dhcp_server_timezone;
     121             :         usec_t dhcp_server_default_lease_time_usec, dhcp_server_max_lease_time_usec;
     122             :         uint32_t dhcp_server_pool_offset;
     123             :         uint32_t dhcp_server_pool_size;
     124             : 
     125             :         /* IPV4LL Support */
     126             :         AddressFamily link_local;
     127             :         bool ipv4ll_route;
     128             : 
     129             :         bool default_route_on_device;
     130             : 
     131             :         /* IPv6 prefix delegation support */
     132             :         RADVPrefixDelegation router_prefix_delegation;
     133             :         usec_t router_lifetime_usec;
     134             :         uint8_t router_preference;
     135             :         bool router_managed;
     136             :         bool router_other_information;
     137             :         bool router_emit_dns;
     138             :         bool router_emit_domains;
     139             :         usec_t router_dns_lifetime_usec;
     140             :         struct in6_addr *router_dns;
     141             :         unsigned n_router_dns;
     142             :         OrderedSet *router_search_domains;
     143             :         bool dhcp6_force_pd_other_information; /* Start DHCPv6 PD also when 'O'
     144             :                                                   RA flag is set, see RFC 7084,
     145             :                                                   WPD-4 */
     146             : 
     147             :         /* Bridge Support */
     148             :         int use_bpdu;
     149             :         int hairpin;
     150             :         int fast_leave;
     151             :         int allow_port_to_be_root;
     152             :         int unicast_flood;
     153             :         int multicast_flood;
     154             :         int multicast_to_unicast;
     155             :         int neighbor_suppression;
     156             :         int learning;
     157             :         int bridge_proxy_arp;
     158             :         int bridge_proxy_arp_wifi;
     159             :         uint32_t cost;
     160             :         uint16_t priority;
     161             :         MulticastRouter multicast_router;
     162             : 
     163             :         bool use_br_vlan;
     164             :         uint16_t pvid;
     165             :         uint32_t br_vid_bitmap[BRIDGE_VLAN_BITMAP_LEN];
     166             :         uint32_t br_untagged_bitmap[BRIDGE_VLAN_BITMAP_LEN];
     167             : 
     168             :         /* CAN support */
     169             :         size_t can_bitrate;
     170             :         unsigned can_sample_point;
     171             :         usec_t can_restart_us;
     172             :         int can_triple_sampling;
     173             : 
     174             :         AddressFamily ip_forward;
     175             :         bool ip_masquerade;
     176             : 
     177             :         int ipv6_accept_ra;
     178             :         int ipv6_dad_transmits;
     179             :         int ipv6_hop_limit;
     180             :         int ipv6_proxy_ndp;
     181             :         int proxy_arp;
     182             :         uint32_t ipv6_mtu;
     183             : 
     184             :         bool ipv6_accept_ra_use_dns;
     185             :         bool ipv6_accept_ra_use_autonomous_prefix;
     186             :         bool ipv6_accept_ra_use_onlink_prefix;
     187             :         bool active_slave;
     188             :         bool primary_slave;
     189             :         DHCPUseDomains ipv6_accept_ra_use_domains;
     190             :         uint32_t ipv6_accept_ra_route_table;
     191             :         bool ipv6_accept_ra_route_table_set;
     192             :         Set *ndisc_black_listed_prefix;
     193             : 
     194             :         union in_addr_union ipv6_token;
     195             :         IPv6PrivacyExtensions ipv6_privacy_extensions;
     196             : 
     197             :         struct ether_addr *mac;
     198             :         uint32_t mtu;
     199             :         int arp;
     200             :         int multicast;
     201             :         int allmulticast;
     202             :         bool unmanaged;
     203             :         bool configure_without_carrier;
     204             :         bool ignore_carrier_loss;
     205             :         KeepConfiguration keep_configuration;
     206             :         uint32_t iaid;
     207             :         DUID duid;
     208             : 
     209             :         bool iaid_set;
     210             : 
     211             :         bool required_for_online; /* Is this network required to be considered online? */
     212             :         LinkOperationalState required_operstate_for_online;
     213             : 
     214             :         LLDPMode lldp_mode; /* LLDP reception */
     215             :         LLDPEmit lldp_emit; /* LLDP transmission */
     216             : 
     217             :         LIST_HEAD(Address, static_addresses);
     218             :         LIST_HEAD(Route, static_routes);
     219             :         LIST_HEAD(FdbEntry, static_fdb_entries);
     220             :         LIST_HEAD(IPv6ProxyNDPAddress, ipv6_proxy_ndp_addresses);
     221             :         LIST_HEAD(Neighbor, neighbors);
     222             :         LIST_HEAD(AddressLabel, address_labels);
     223             :         LIST_HEAD(Prefix, static_prefixes);
     224             :         LIST_HEAD(RoutingPolicyRule, rules);
     225             : 
     226             :         unsigned n_static_addresses;
     227             :         unsigned n_static_routes;
     228             :         unsigned n_static_fdb_entries;
     229             :         unsigned n_ipv6_proxy_ndp_addresses;
     230             :         unsigned n_neighbors;
     231             :         unsigned n_address_labels;
     232             :         unsigned n_static_prefixes;
     233             :         unsigned n_rules;
     234             : 
     235             :         Hashmap *addresses_by_section;
     236             :         Hashmap *routes_by_section;
     237             :         Hashmap *fdb_entries_by_section;
     238             :         Hashmap *neighbors_by_section;
     239             :         Hashmap *address_labels_by_section;
     240             :         Hashmap *prefixes_by_section;
     241             :         Hashmap *rules_by_section;
     242             : 
     243             :         /* All kinds of DNS configuration */
     244             :         struct in_addr_data *dns;
     245             :         unsigned n_dns;
     246             :         OrderedSet *search_domains, *route_domains;
     247             : 
     248             :         int dns_default_route;
     249             :         ResolveSupport llmnr;
     250             :         ResolveSupport mdns;
     251             :         DnssecMode dnssec_mode;
     252             :         DnsOverTlsMode dns_over_tls_mode;
     253             :         Set *dnssec_negative_trust_anchors;
     254             : 
     255             :         char **ntp;
     256             :         char **bind_carrier;
     257             : };
     258             : 
     259             : Network *network_ref(Network *network);
     260             : Network *network_unref(Network *network);
     261          26 : DEFINE_TRIVIAL_CLEANUP_FUNC(Network*, network_unref);
     262             : 
     263             : int network_load(Manager *manager);
     264             : int network_load_one(Manager *manager, const char *filename);
     265             : int network_verify(Network *network);
     266             : 
     267             : int network_get_by_name(Manager *manager, const char *name, Network **ret);
     268             : int network_get(Manager *manager, sd_device *device, const char *ifname, const struct ether_addr *mac, Network **ret);
     269             : int network_apply(Network *network, Link *link);
     270             : void network_apply_anonymize_if_set(Network *network);
     271             : 
     272             : bool network_has_static_ipv6_addresses(Network *network);
     273             : 
     274             : CONFIG_PARSER_PROTOTYPE(config_parse_stacked_netdev);
     275             : CONFIG_PARSER_PROTOTYPE(config_parse_tunnel);
     276             : CONFIG_PARSER_PROTOTYPE(config_parse_ipv6token);
     277             : CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_privacy_extensions);
     278             : CONFIG_PARSER_PROTOTYPE(config_parse_domains);
     279             : CONFIG_PARSER_PROTOTYPE(config_parse_dns);
     280             : CONFIG_PARSER_PROTOTYPE(config_parse_hostname);
     281             : CONFIG_PARSER_PROTOTYPE(config_parse_timezone);
     282             : CONFIG_PARSER_PROTOTYPE(config_parse_dnssec_negative_trust_anchors);
     283             : CONFIG_PARSER_PROTOTYPE(config_parse_ntp);
     284             : CONFIG_PARSER_PROTOTYPE(config_parse_required_for_online);
     285             : CONFIG_PARSER_PROTOTYPE(config_parse_keep_configuration);
     286             : 
     287             : const struct ConfigPerfItem* network_network_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
     288             : 
     289             : const char* ipv6_privacy_extensions_to_string(IPv6PrivacyExtensions i) _const_;
     290             : IPv6PrivacyExtensions ipv6_privacy_extensions_from_string(const char *s) _pure_;
     291             : 
     292             : const char* keep_configuration_to_string(KeepConfiguration i) _const_;
     293             : KeepConfiguration keep_configuration_from_string(const char *s) _pure_;

Generated by: LCOV version 1.14