libnl 3.7.0
link.h
1/* SPDX-License-Identifier: LGPL-2.1-only */
2/*
3 * Copyright (c) 2003-2012 Thomas Graf <tgraf@suug.ch>
4 */
5
6#ifndef NETLINK_LINK_H_
7#define NETLINK_LINK_H_
8
9#include <netlink/netlink.h>
10#include <netlink/cache.h>
11#include <netlink/addr.h>
12#include <sys/types.h>
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18/**
19 * @struct rtnl_link link.h "netlink/route/link.h"
20 * @brief Link object
21 * @implements nl_object
22 * @ingroup link
23 *
24 * @copydoc private_struct
25 */
26struct rtnl_link;
27
28/**
29 * @ingroup link
30 */
31typedef enum {
32 RTNL_LINK_RX_PACKETS, /*!< Packets received */
33 RTNL_LINK_TX_PACKETS, /*!< Packets sent */
34 RTNL_LINK_RX_BYTES, /*!< Bytes received */
35 RTNL_LINK_TX_BYTES, /*!< Bytes sent */
36 RTNL_LINK_RX_ERRORS, /*!< Receive errors */
37 RTNL_LINK_TX_ERRORS, /*!< Send errors */
38 RTNL_LINK_RX_DROPPED, /*!< Received packets dropped */
39 RTNL_LINK_TX_DROPPED, /*!< Packets dropped during transmit */
40 RTNL_LINK_RX_COMPRESSED, /*!< Compressed packets received */
41 RTNL_LINK_TX_COMPRESSED, /*!< Compressed packets sent */
42 RTNL_LINK_RX_FIFO_ERR, /*!< Receive FIFO errors */
43 RTNL_LINK_TX_FIFO_ERR, /*!< Send FIFO errors */
44 RTNL_LINK_RX_LEN_ERR, /*!< Length errors */
45 RTNL_LINK_RX_OVER_ERR, /*!< Over errors */
46 RTNL_LINK_RX_CRC_ERR, /*!< CRC errors */
47 RTNL_LINK_RX_FRAME_ERR, /*!< Frame errors */
48 RTNL_LINK_RX_MISSED_ERR, /*!< Missed errors */
49 RTNL_LINK_TX_ABORT_ERR, /*!< Aborted errors */
50 RTNL_LINK_TX_CARRIER_ERR, /*!< Carrier errors */
51 RTNL_LINK_TX_HBEAT_ERR, /*!< Heartbeat errors */
52 RTNL_LINK_TX_WIN_ERR, /*!< Window errors */
53 RTNL_LINK_COLLISIONS, /*!< Send collisions */
54 RTNL_LINK_MULTICAST, /*!< Multicast */
55 RTNL_LINK_IP6_INPKTS, /*!< IPv6 SNMP InReceives */
56 RTNL_LINK_IP6_INHDRERRORS, /*!< IPv6 SNMP InHdrErrors */
57 RTNL_LINK_IP6_INTOOBIGERRORS, /*!< IPv6 SNMP InTooBigErrors */
58 RTNL_LINK_IP6_INNOROUTES, /*!< IPv6 SNMP InNoRoutes */
59 RTNL_LINK_IP6_INADDRERRORS, /*!< IPv6 SNMP InAddrErrors */
60 RTNL_LINK_IP6_INUNKNOWNPROTOS, /*!< IPv6 SNMP InUnknownProtos */
61 RTNL_LINK_IP6_INTRUNCATEDPKTS, /*!< IPv6 SNMP InTruncatedPkts */
62 RTNL_LINK_IP6_INDISCARDS, /*!< IPv6 SNMP InDiscards */
63 RTNL_LINK_IP6_INDELIVERS, /*!< IPv6 SNMP InDelivers */
64 RTNL_LINK_IP6_OUTFORWDATAGRAMS, /*!< IPv6 SNMP OutForwDatagrams */
65 RTNL_LINK_IP6_OUTPKTS, /*!< IPv6 SNMP OutRequests */
66 RTNL_LINK_IP6_OUTDISCARDS, /*!< IPv6 SNMP OutDiscards */
67 RTNL_LINK_IP6_OUTNOROUTES, /*!< IPv6 SNMP OutNoRoutes */
68 RTNL_LINK_IP6_REASMTIMEOUT, /*!< IPv6 SNMP ReasmTimeout */
69 RTNL_LINK_IP6_REASMREQDS, /*!< IPv6 SNMP ReasmReqds */
70 RTNL_LINK_IP6_REASMOKS, /*!< IPv6 SNMP ReasmOKs */
71 RTNL_LINK_IP6_REASMFAILS, /*!< IPv6 SNMP ReasmFails */
72 RTNL_LINK_IP6_FRAGOKS, /*!< IPv6 SNMP FragOKs */
73 RTNL_LINK_IP6_FRAGFAILS, /*!< IPv6 SNMP FragFails */
74 RTNL_LINK_IP6_FRAGCREATES, /*!< IPv6 SNMP FragCreates */
75 RTNL_LINK_IP6_INMCASTPKTS, /*!< IPv6 SNMP InMcastPkts */
76 RTNL_LINK_IP6_OUTMCASTPKTS, /*!< IPv6 SNMP OutMcastPkts */
77 RTNL_LINK_IP6_INBCASTPKTS, /*!< IPv6 SNMP InBcastPkts */
78 RTNL_LINK_IP6_OUTBCASTPKTS, /*!< IPv6 SNMP OutBcastPkts */
79 RTNL_LINK_IP6_INOCTETS, /*!< IPv6 SNMP InOctets */
80 RTNL_LINK_IP6_OUTOCTETS, /*!< IPv6 SNMP OutOctets */
81 RTNL_LINK_IP6_INMCASTOCTETS, /*!< IPv6 SNMP InMcastOctets */
82 RTNL_LINK_IP6_OUTMCASTOCTETS, /*!< IPv6 SNMP OutMcastOctets */
83 RTNL_LINK_IP6_INBCASTOCTETS, /*!< IPv6 SNMP InBcastOctets */
84 RTNL_LINK_IP6_OUTBCASTOCTETS, /*!< IPv6 SNMP OutBcastOctets */
85 RTNL_LINK_ICMP6_INMSGS, /*!< ICMPv6 SNMP InMsgs */
86 RTNL_LINK_ICMP6_INERRORS, /*!< ICMPv6 SNMP InErrors */
87 RTNL_LINK_ICMP6_OUTMSGS, /*!< ICMPv6 SNMP OutMsgs */
88 RTNL_LINK_ICMP6_OUTERRORS, /*!< ICMPv6 SNMP OutErrors */
89 RTNL_LINK_ICMP6_CSUMERRORS, /*!< ICMPv6 SNMP InCsumErrors */
90 RTNL_LINK_IP6_CSUMERRORS, /*!< IPv6 SNMP InCsumErrors */
91 RTNL_LINK_IP6_NOECTPKTS, /*!< IPv6 SNMP InNoECTPkts */
92 RTNL_LINK_IP6_ECT1PKTS, /*!< IPv6 SNMP InECT1Pkts */
93 RTNL_LINK_IP6_ECT0PKTS, /*!< IPv6 SNMP InECT0Pkts */
94 RTNL_LINK_IP6_CEPKTS, /*!< IPv6 SNMP InCEPkts */
95 RTNL_LINK_RX_NOHANDLER, /*!< Received packets dropped on inactive device */
96 RTNL_LINK_REASM_OVERLAPS, /*!< SNMP ReasmOverlaps */
97 __RTNL_LINK_STATS_MAX,
99
100#define RTNL_LINK_STATS_MAX (__RTNL_LINK_STATS_MAX - 1)
101
102extern struct nla_policy rtln_link_policy[];
103
104extern struct rtnl_link *rtnl_link_alloc(void);
105extern void rtnl_link_put(struct rtnl_link *);
106
107extern int rtnl_link_alloc_cache(struct nl_sock *, int, struct nl_cache **);
108extern int rtnl_link_alloc_cache_flags(struct nl_sock *, int,
109 struct nl_cache **,
110 unsigned int flags);
111extern struct rtnl_link *rtnl_link_get(struct nl_cache *, int);
112extern struct rtnl_link *rtnl_link_get_by_name(struct nl_cache *, const char *);
113
114
115extern int rtnl_link_build_add_request(struct rtnl_link *, int,
116 struct nl_msg **);
117extern int rtnl_link_add(struct nl_sock *, struct rtnl_link *, int);
118extern int rtnl_link_build_change_request(struct rtnl_link *,
119 struct rtnl_link *, int,
120 struct nl_msg **);
121extern int rtnl_link_change(struct nl_sock *, struct rtnl_link *,
122 struct rtnl_link *, int);
123
124extern int rtnl_link_build_delete_request(const struct rtnl_link *,
125 struct nl_msg **);
126extern int rtnl_link_delete(struct nl_sock *, const struct rtnl_link *);
127extern int rtnl_link_build_get_request(int, const char *,
128 struct nl_msg **);
129extern int rtnl_link_get_kernel(struct nl_sock *, int, const char *,
130 struct rtnl_link **);
131
132/* Name <-> Index Translations */
133extern char * rtnl_link_i2name(struct nl_cache *, int, char *, size_t);
134extern int rtnl_link_name2i(struct nl_cache *, const char *);
135
136/* Name <-> Statistic Translations */
137extern char * rtnl_link_stat2str(int, char *, size_t);
138extern int rtnl_link_str2stat(const char *);
139
140/* Link Flags Translations */
141extern char * rtnl_link_flags2str(int, char *, size_t);
142extern int rtnl_link_str2flags(const char *);
143
144extern char * rtnl_link_operstate2str(uint8_t, char *, size_t);
145extern int rtnl_link_str2operstate(const char *);
146
147extern char * rtnl_link_mode2str(uint8_t, char *, size_t);
148extern int rtnl_link_str2mode(const char *);
149
150/* Carrier State Translations */
151extern char * rtnl_link_carrier2str(uint8_t, char *, size_t);
152extern int rtnl_link_str2carrier(const char *);
153
154/* Access Functions */
155extern void rtnl_link_set_qdisc(struct rtnl_link *, const char *);
156extern char * rtnl_link_get_qdisc(struct rtnl_link *);
157
158extern void rtnl_link_set_name(struct rtnl_link *, const char *);
159extern char * rtnl_link_get_name(struct rtnl_link *);
160
161extern void rtnl_link_set_group(struct rtnl_link *, uint32_t);
162extern uint32_t rtnl_link_get_group(struct rtnl_link *);
163
164extern void rtnl_link_set_flags(struct rtnl_link *, unsigned int);
165extern void rtnl_link_unset_flags(struct rtnl_link *, unsigned int);
166extern unsigned int rtnl_link_get_flags(struct rtnl_link *);
167
168extern void rtnl_link_set_mtu(struct rtnl_link *, unsigned int);
169extern unsigned int rtnl_link_get_mtu(struct rtnl_link *);
170
171extern void rtnl_link_set_txqlen(struct rtnl_link *, unsigned int);
172extern unsigned int rtnl_link_get_txqlen(struct rtnl_link *);
173
174extern void rtnl_link_set_ifindex(struct rtnl_link *, int);
175extern int rtnl_link_get_ifindex(struct rtnl_link *);
176
177extern void rtnl_link_set_family(struct rtnl_link *, int);
178extern int rtnl_link_get_family(struct rtnl_link *);
179
180extern void rtnl_link_set_arptype(struct rtnl_link *, unsigned int);
181extern unsigned int rtnl_link_get_arptype(struct rtnl_link *);
182
183extern void rtnl_link_set_addr(struct rtnl_link *, struct nl_addr *);
184extern struct nl_addr *rtnl_link_get_addr(struct rtnl_link *);
185
186extern void rtnl_link_set_broadcast(struct rtnl_link *, struct nl_addr *);
187extern struct nl_addr *rtnl_link_get_broadcast(struct rtnl_link *);
188
189extern void rtnl_link_set_link(struct rtnl_link *, int);
190extern int rtnl_link_get_link(struct rtnl_link *);
191
192extern void rtnl_link_set_master(struct rtnl_link *, int);
193extern int rtnl_link_get_master(struct rtnl_link *);
194
195extern void rtnl_link_set_carrier(struct rtnl_link *, uint8_t);
196extern uint8_t rtnl_link_get_carrier(struct rtnl_link *);
197
198extern int rtnl_link_get_carrier_changes(struct rtnl_link *, uint32_t *);
199
200extern void rtnl_link_set_operstate(struct rtnl_link *, uint8_t);
201extern uint8_t rtnl_link_get_operstate(struct rtnl_link *);
202
203extern void rtnl_link_set_linkmode(struct rtnl_link *, uint8_t);
204extern uint8_t rtnl_link_get_linkmode(struct rtnl_link *);
205
206int rtnl_link_set_link_netnsid(struct rtnl_link *link, int32_t link_netnsid);
207int rtnl_link_get_link_netnsid(const struct rtnl_link *link, int32_t *out_link_netnsid);
208
209extern const char * rtnl_link_get_ifalias(struct rtnl_link *);
210extern void rtnl_link_set_ifalias(struct rtnl_link *, const char *);
211
212extern int rtnl_link_get_num_vf(struct rtnl_link *, uint32_t *);
213
214extern uint64_t rtnl_link_get_stat(struct rtnl_link *, rtnl_link_stat_id_t);
216 const uint64_t);
217
218extern int rtnl_link_set_type(struct rtnl_link *, const char *);
219extern char * rtnl_link_get_type(struct rtnl_link *);
220
221extern int rtnl_link_set_slave_type(struct rtnl_link *, const char *);
222extern const char * rtnl_link_get_slave_type(const struct rtnl_link *);
223
224extern void rtnl_link_set_promiscuity(struct rtnl_link *, uint32_t);
225extern uint32_t rtnl_link_get_promiscuity(struct rtnl_link *);
226
227extern void rtnl_link_set_num_tx_queues(struct rtnl_link *, uint32_t);
228extern uint32_t rtnl_link_get_num_tx_queues(struct rtnl_link *);
229
230extern void rtnl_link_set_num_rx_queues(struct rtnl_link *, uint32_t);
231extern uint32_t rtnl_link_get_num_rx_queues(struct rtnl_link *);
232
233extern int rtnl_link_get_gso_max_segs(struct rtnl_link *, uint32_t *);
234
235extern int rtnl_link_get_gso_max_size(struct rtnl_link *, uint32_t *);
236
237extern struct nl_data * rtnl_link_get_phys_port_id(struct rtnl_link *);
238
239extern char* rtnl_link_get_phys_port_name(struct rtnl_link *);
240
241extern struct nl_data * rtnl_link_get_phys_switch_id(struct rtnl_link *);
242
243extern void rtnl_link_set_ns_fd(struct rtnl_link *, int);
244extern int rtnl_link_get_ns_fd(struct rtnl_link *);
245extern void rtnl_link_set_ns_pid(struct rtnl_link *, pid_t);
246extern pid_t rtnl_link_get_ns_pid(struct rtnl_link *);
247
248extern int rtnl_link_enslave_ifindex(struct nl_sock *, int, int);
249extern int rtnl_link_enslave(struct nl_sock *, struct rtnl_link *,
250 struct rtnl_link *);
251extern int rtnl_link_release_ifindex(struct nl_sock *, int);
252extern int rtnl_link_release(struct nl_sock *, struct rtnl_link *);
253extern int rtnl_link_fill_info(struct nl_msg *, struct rtnl_link *);
254extern int rtnl_link_info_parse(struct rtnl_link *, struct nlattr **);
255
256extern int rtnl_link_has_vf_list(struct rtnl_link *);
257extern void rtnl_link_set_vf_list(struct rtnl_link *);
258extern void rtnl_link_unset_vf_list(struct rtnl_link *);
259
260
261/* deprecated */
262extern int rtnl_link_set_info_type(struct rtnl_link *, const char *) __attribute__((deprecated));
263extern char * rtnl_link_get_info_type(struct rtnl_link *) __attribute__((deprecated));
264extern void rtnl_link_set_weight(struct rtnl_link *, unsigned int) __attribute__((deprecated));
265extern unsigned int rtnl_link_get_weight(struct rtnl_link *) __attribute__((deprecated));
266
267
268#ifdef __cplusplus
269}
270#endif
271
272#endif
Attribute validation policy.
Definition: attr.h:63