• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * netlink/route/link.h		Links (Interfaces)
3  *
4  *	This library is free software; you can redistribute it and/or
5  *	modify it under the terms of the GNU Lesser General Public
6  *	License as published by the Free Software Foundation version 2.1
7  *	of the License.
8  *
9  * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
10  */
11 
12 #ifndef NETLINK_LINK_H_
13 #define NETLINK_LINK_H_
14 
15 #include <netlink/netlink.h>
16 #include <netlink/cache.h>
17 #include <netlink/addr.h>
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 struct rtnl_link;
24 
25 enum rtnl_link_st {
26 	RTNL_LINK_RX_PACKETS,
27 	RTNL_LINK_TX_PACKETS,
28 	RTNL_LINK_RX_BYTES,
29 	RTNL_LINK_TX_BYTES,
30 	RTNL_LINK_RX_ERRORS,
31 	RTNL_LINK_TX_ERRORS,
32 	RTNL_LINK_RX_DROPPED,
33 	RTNL_LINK_TX_DROPPED,
34 	RTNL_LINK_RX_COMPRESSED,
35 	RTNL_LINK_TX_COMPRESSED,
36 	RTNL_LINK_RX_FIFO_ERR,
37 	RTNL_LINK_TX_FIFO_ERR,
38 	RTNL_LINK_RX_LEN_ERR,
39 	RTNL_LINK_RX_OVER_ERR,
40 	RTNL_LINK_RX_CRC_ERR,
41 	RTNL_LINK_RX_FRAME_ERR,
42 	RTNL_LINK_RX_MISSED_ERR,
43 	RTNL_LINK_TX_ABORT_ERR,
44 	RTNL_LINK_TX_CARRIER_ERR,
45 	RTNL_LINK_TX_HBEAT_ERR,
46 	RTNL_LINK_TX_WIN_ERR,
47 	RTNL_LINK_TX_COLLISIONS,
48 	RTNL_LINK_MULTICAST,
49 	__RTNL_LINK_STATS_MAX,
50 };
51 
52 #define RTNL_LINK_STATS_MAX (__RTNL_LINK_STATS_MAX - 1)
53 
54 /* link object allocation/freeage */
55 extern struct rtnl_link *rtnl_link_alloc(void);
56 extern void	rtnl_link_put(struct rtnl_link *);
57 extern void	rtnl_link_free(struct rtnl_link *);
58 
59 /* link cache management */
60 extern int	rtnl_link_alloc_cache(struct nl_sock *, struct nl_cache **);
61 extern struct rtnl_link *rtnl_link_get(struct nl_cache *, int);
62 extern struct rtnl_link *rtnl_link_get_by_name(struct nl_cache *, const char *);
63 
64 
65 extern int	rtnl_link_build_change_request(struct rtnl_link *,
66 					       struct rtnl_link *, int,
67 					       struct nl_msg **);
68 extern int	rtnl_link_change(struct nl_sock *, struct rtnl_link *,
69 				 struct rtnl_link *, int);
70 
71 /* Name <-> Index Translations */
72 extern char * 	rtnl_link_i2name(struct nl_cache *, int, char *, size_t);
73 extern int	rtnl_link_name2i(struct nl_cache *, const char *);
74 
75 /* Name <-> Statistic Translations */
76 extern char *	rtnl_link_stat2str(int, char *, size_t);
77 extern int	rtnl_link_str2stat(const char *);
78 
79 /* Link Flags Translations */
80 extern char *	rtnl_link_flags2str(int, char *, size_t);
81 extern int	rtnl_link_str2flags(const char *);
82 
83 extern char *	rtnl_link_operstate2str(int, char *, size_t);
84 extern int	rtnl_link_str2operstate(const char *);
85 
86 extern char *	rtnl_link_mode2str(int, char *, size_t);
87 extern int	rtnl_link_str2mode(const char *);
88 
89 /* Access Functions */
90 extern void	rtnl_link_set_qdisc(struct rtnl_link *, const char *);
91 extern char *	rtnl_link_get_qdisc(struct rtnl_link *);
92 
93 extern void	rtnl_link_set_name(struct rtnl_link *, const char *);
94 extern char *	rtnl_link_get_name(struct rtnl_link *);
95 
96 extern void	rtnl_link_set_flags(struct rtnl_link *, unsigned int);
97 extern void	rtnl_link_unset_flags(struct rtnl_link *, unsigned int);
98 extern unsigned int rtnl_link_get_flags(struct rtnl_link *);
99 
100 extern void	rtnl_link_set_mtu(struct rtnl_link *, unsigned int);
101 extern unsigned int rtnl_link_get_mtu(struct rtnl_link *);
102 
103 extern void	rtnl_link_set_txqlen(struct rtnl_link *, unsigned int);
104 extern unsigned int rtnl_link_get_txqlen(struct rtnl_link *);
105 
106 extern void	rtnl_link_set_weight(struct rtnl_link *, unsigned int);
107 extern unsigned int rtnl_link_get_weight(struct rtnl_link *);
108 
109 extern void	rtnl_link_set_ifindex(struct rtnl_link *, int);
110 extern int	rtnl_link_get_ifindex(struct rtnl_link *);
111 
112 extern void	rtnl_link_set_family(struct rtnl_link *, int);
113 extern int	rtnl_link_get_family(struct rtnl_link *);
114 
115 extern void	rtnl_link_set_arptype(struct rtnl_link *, unsigned int);
116 extern unsigned int rtnl_link_get_arptype(struct rtnl_link *);
117 
118 extern void	rtnl_link_set_addr(struct rtnl_link *, struct nl_addr *);
119 extern struct nl_addr *rtnl_link_get_addr(struct rtnl_link *);
120 
121 extern void	rtnl_link_set_broadcast(struct rtnl_link *, struct nl_addr *);
122 extern struct nl_addr *rtnl_link_get_broadcast(struct rtnl_link *);
123 
124 extern void	rtnl_link_set_link(struct rtnl_link *, int);
125 extern int	rtnl_link_get_link(struct rtnl_link *);
126 
127 extern void	rtnl_link_set_master(struct rtnl_link *, int);
128 extern int	rtnl_link_get_master(struct rtnl_link *);
129 
130 extern void	rtnl_link_set_operstate(struct rtnl_link *, uint8_t);
131 extern uint8_t	rtnl_link_get_operstate(struct rtnl_link *);
132 
133 extern void	rtnl_link_set_linkmode(struct rtnl_link *, uint8_t);
134 extern uint8_t	rtnl_link_get_linkmode(struct rtnl_link *);
135 
136 extern uint64_t rtnl_link_get_stat(struct rtnl_link *, int);
137 
138 extern int	rtnl_link_set_info_type(struct rtnl_link *, const char *);
139 extern char *	rtnl_link_get_info_type(struct rtnl_link *);
140 
141 #ifdef __cplusplus
142 }
143 #endif
144 
145 #endif
146