Debian Codegraph @

src/network/networkctl-link-info.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include <linux/if.h>
5 #include <linux/if_link.h>
6 #include <linux/nl80211.h>
7
8 #include "dhcp-client-id-internal.h"
9 #include "dhcp-message.h"
10 #include "ether-addr-util.h"
11 #include "ethtool-util.h"
12 #include "shared-forward.h"
13 #include "in-addr-util.h"
14
15 typedef struct VxLanInfo {
16 uint32_t vni;
17 uint32_t link;
18
19 int local_family;
20 int group_family;
21
22 union in_addr_union local;
23 union in_addr_union group;
24
25 uint16_t dest_port;
26
27 uint8_t proxy;
28 uint8_t learning;
29 uint8_t rsc;
30 uint8_t l2miss;
31 uint8_t l3miss;
32 uint8_t tos;
33 uint8_t ttl;
34 } VxLanInfo;
35
36 typedef struct LinkInfo {
37 char name[IFNAMSIZ+1];
38 char *netdev_kind;
39 sd_device *sd_device;
40 sd_json_variant *description;
41 int ifindex;
42 unsigned short iftype;
43 struct hw_addr_data hw_address;
44 struct hw_addr_data permanent_hw_address;
45 uint32_t master;
46 uint32_t mtu;
47 uint32_t min_mtu;
48 uint32_t max_mtu;
49 uint32_t tx_queues;
50 uint32_t rx_queues;
51 uint8_t addr_gen_mode;
52 char *qdisc;
53 char **alternative_names;
54
55 union {
56 struct rtnl_link_stats64 stats64;
57 struct rtnl_link_stats stats;
58 };
59
60 uint64_t tx_bitrate;
61 uint64_t rx_bitrate;
62
63 /* DHCPv4 */
64 sd_dhcp_message *dhcp_message;
65 sd_dhcp_client_id dhcp_client_id;
66
67 /* bridge info */
68 uint32_t forward_delay;
69 uint32_t hello_time;
70 uint32_t max_age;
71 uint32_t ageing_time;
72 uint32_t stp_state;
73 uint32_t cost;
74 uint16_t priority;
75 uint8_t mcast_igmp_version;
76 uint8_t port_state;
77 uint32_t fdb_max_learned;
78 uint32_t fdb_n_learned;
79 bool has_fdb_learned;
80
81 /* vxlan info */
82 VxLanInfo vxlan_info;
83
84 /* vlan info */
85 uint16_t vlan_id;
86
87 /* tunnel info */
88 uint8_t ttl;
89 uint8_t tos;
90 uint8_t inherit;
91 uint8_t df;
92 uint8_t csum;
93 uint8_t csum6_tx;
94 uint8_t csum6_rx;
95 uint16_t tunnel_port;
96 uint32_t vni;
97 uint32_t label;
98 union in_addr_union local;
99 union in_addr_union remote;
100
101 /* bonding info */
102 uint8_t mode;
103 uint32_t miimon;
104 uint32_t updelay;
105 uint32_t downdelay;
106
107 /* macvlan and macvtap info */
108 uint32_t macvlan_mode;
109
110 /* ipvlan info */
111 uint16_t ipvlan_mode;
112 uint16_t ipvlan_flags;
113
114 /* ethtool info */
115 int autonegotiation;
116 uint64_t speed;
117 Duplex duplex;
118 NetDevPort port;
119
120 /* wlan info */
121 enum nl80211_iftype wlan_iftype;
122 char *ssid;
123 struct ether_addr bssid;
124
125 bool has_hw_address:1;
126 bool has_permanent_hw_address:1;
127 bool has_tx_queues:1;
128 bool has_rx_queues:1;
129 bool has_stats64:1;
130 bool has_stats:1;
131 bool has_bitrates:1;
132 bool has_ethtool_link_info:1;
133 bool has_wlan_link_info:1;
134 bool has_tunnel_ipv4:1;
135 bool has_ipv6_address_generation_mode:1;
136
137 bool needs_freeing:1;
138 } LinkInfo;
139
140 LinkInfo* link_info_array_free(LinkInfo *array);
141 DEFINE_TRIVIAL_CLEANUP_FUNC(LinkInfo*, link_info_array_free);
142
143 int acquire_link_info(sd_varlink *vl, sd_netlink *rtnl, char * const *patterns, LinkInfo **ret);