1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
|
/*
* interface data access header
*
* $Id: interface.h 18100 2010-02-05 09:48:46Z jsafranek $
*/
#ifndef NETSNMP_ACCESS_INTERFACE_H
#define NETSNMP_ACCESS_INTERFACE_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* define flags to indicate the availability of certain data
*/
#define NETSNMP_INTERFACE_FLAGS_ACTIVE 0x00000001
#define NETSNMP_INTERFACE_FLAGS_HAS_BYTES 0x00000002
#define NETSNMP_INTERFACE_FLAGS_HAS_DROPS 0x00000004
#define NETSNMP_INTERFACE_FLAGS_HAS_MCAST_PKTS 0x00000008
#define NETSNMP_INTERFACE_FLAGS_HAS_HIGH_BYTES 0x00000010
#define NETSNMP_INTERFACE_FLAGS_HAS_HIGH_PACKETS 0x00000020
#define NETSNMP_INTERFACE_FLAGS_HAS_HIGH_SPEED 0x00000040
#define NETSNMP_INTERFACE_FLAGS_DYNAMIC_SPEED 0x00000080
#define NETSNMP_INTERFACE_FLAGS_HAS_LASTCHANGE 0x00000100
#define NETSNMP_INTERFACE_FLAGS_HAS_DISCONTINUITY 0x00000200
#define NETSNMP_INTERFACE_FLAGS_HAS_IF_FLAGS 0x00000400
#define NETSNMP_INTERFACE_FLAGS_CAN_DOWN_PROTOCOL 0x00000800
#define NETSNMP_INTERFACE_FLAGS_HAS_IPV4 0x00001000
#define NETSNMP_INTERFACE_FLAGS_HAS_IPV6 0x00002000
#define NETSNMP_INTERFACE_FLAGS_HAS_V4_RETRANSMIT 0x00004000
#define NETSNMP_INTERFACE_FLAGS_HAS_V4_REASMMAX 0x00008000
#define NETSNMP_INTERFACE_FLAGS_HAS_V6_RETRANSMIT 0x00010000
#define NETSNMP_INTERFACE_FLAGS_HAS_V6_REASMMAX 0x00020000
#define NETSNMP_INTERFACE_FLAGS_HAS_V6_REACHABLE 0x00040000
#define NETSNMP_INTERFACE_FLAGS_HAS_V6_IFID 0x00080000
#define NETSNMP_INTERFACE_FLAGS_HAS_V6_FORWARDING 0x00100000
/*************************************************************
* constants for enums for the MIB node
* ifAdminStatus (INTEGER / ASN_INTEGER)
*
* since a Textual Convention may be referenced more than once in a
* MIB, protect againt redifinitions of the enum values.
*/
#ifndef ifAdminStatus_ENUMS
#define ifAdminStatus_ENUMS
#define IFADMINSTATUS_UP 1
#define IFADMINSTATUS_DOWN 2
#define IFADMINSTATUS_TESTING 3
#endif /* ifAdminStatus_ENUMS */
/*************************************************************
* constants for enums for the MIB node
* ifOperStatus (INTEGER / ASN_INTEGER)
*
* since a Textual Convention may be referenced more than once in a
* MIB, protect againt redifinitions of the enum values.
*/
#ifndef ifOperStatus_ENUMS
#define ifOperStatus_ENUMS
#define IFOPERSTATUS_UP 1
#define IFOPERSTATUS_DOWN 2
#define IFOPERSTATUS_TESTING 3
#define IFOPERSTATUS_UNKNOWN 4
#define IFOPERSTATUS_DORMANT 5
#define IFOPERSTATUS_NOTPRESENT 6
#define IFOPERSTATUS_LOWERLAYERDOWN 7
#endif /* ifOperStatus_ENUMS */
/* nominal speed of network interface - used when the real speed is unknown */
#define NOMINAL_LINK_SPEED 10000000
/**---------------------------------------------------------------------*/
/*
* structure definitions
*
* NOTE: if you add fields, update code dealing with
* stats in interface_common.c, particularly
* netsnmp_access_interface_entry_update_stats()
*
*/
typedef struct netsnmp_interface_stats_s {
/*
* "Dynamic" fields
* Cached versions of byte/packet counters, etc
* (saved as a 'struct counter64' even if the
* high order half isn't actually used)
*
*/
/** input */
struct counter64 ibytes;
struct counter64 iucast;
struct counter64 imcast;
struct counter64 ibcast;
unsigned int ierrors;
unsigned int idiscards;
unsigned int iunknown_protos;
unsigned int inucast;
/** output */
struct counter64 obytes;
struct counter64 oucast;
struct counter64 omcast;
struct counter64 obcast;
unsigned int oerrors;
unsigned int odiscards;
unsigned int oqlen;
unsigned int collisions;
unsigned int onucast;
} netsnmp_interface_stats;
/*
*
* NOTE: if you add fields, update code dealing with
* them in interface_common.c, particularly
* netsnmp_access_interface_entry_copy().
*/
typedef struct netsnmp_interface_entry_s {
netsnmp_index oid_index;
u_int ns_flags; /* net-snmp flags */
oid index;
/*
* "Static" information
* Typically constant for a given interface
*/
char *name;
char *descr;
int type;
u_int speed;
u_int speed_high;
char *paddr;
u_int paddr_len;
u_int mtu;
u_int retransmit_v4; /* milliseconds */
u_int retransmit_v6; /* milliseconds */
u_int reachable_time; /* ipv6 / milliseconds */
u_long lastchange;
time_t discontinuity;
uint16_t reasm_max_v4; /* 0..65535 */
uint16_t reasm_max_v6; /* 1500..65535 */
char admin_status;
char oper_status;
/** booleans (not TruthValues!) */
char promiscuous;
char connector_present;
char forwarding_v6;
char v6_if_id_len;
u_char v6_if_id[8];
/*-----------------------------------------------
* platform/arch/access specific data
*/
u_int os_flags; /* iff NETSNMP_INTERFACE_FLAGS_HAS_IF_FLAGS */
/*
* statistics
*/
netsnmp_interface_stats stats;
/** old_stats is used in netsnmp_access_interface_entry_update_stats */
netsnmp_interface_stats *old_stats;
} netsnmp_interface_entry;
/*
* conf file overrides
*/
typedef struct _conf_if_list {
const char *name;
int type;
uint64_t speed;
struct _conf_if_list *next;
} netsnmp_conf_if_list;
typedef netsnmp_conf_if_list conf_if_list; /* backwards compat */
/**---------------------------------------------------------------------*/
/*
* ACCESS function prototypes
*/
void init_interface(void);
void netsnmp_access_interface_init(void);
/*
* ifcontainer init
*/
netsnmp_container * netsnmp_access_interface_container_init(u_int init_flags);
#define NETSNMP_ACCESS_INTERFACE_INIT_NOFLAGS 0x0000
#define NETSNMP_ACCESS_INTERFACE_INIT_ADDL_IDX_BY_NAME 0x0001
/*
* ifcontainer load and free
*/
netsnmp_container*
netsnmp_access_interface_container_load(netsnmp_container* container,
u_int load_flags);
#define NETSNMP_ACCESS_INTERFACE_LOAD_NOFLAGS 0x0000
#define NETSNMP_ACCESS_INTERFACE_LOAD_NO_STATS 0x0001
#define NETSNMP_ACCESS_INTERFACE_LOAD_IP4_ONLY 0x0002
#define NETSNMP_ACCESS_INTERFACE_LOAD_IP6_ONLY 0x0004
void netsnmp_access_interface_container_free(netsnmp_container *container,
u_int free_flags);
#define NETSNMP_ACCESS_INTERFACE_FREE_NOFLAGS 0x0000
#define NETSNMP_ACCESS_INTERFACE_FREE_DONT_CLEAR 0x0001
/*
* create/free an ifentry
*/
netsnmp_interface_entry *
netsnmp_access_interface_entry_create(const char *name, oid if_index);
void netsnmp_access_interface_entry_free(netsnmp_interface_entry * entry);
int
netsnmp_access_interface_entry_set_admin_status(netsnmp_interface_entry * entry,
int ifAdminStatus);
/*
* find entry in container
*/
netsnmp_interface_entry *
netsnmp_access_interface_entry_get_by_name(netsnmp_container *container,
const char *name);
netsnmp_interface_entry *
netsnmp_access_interface_entry_get_by_index(netsnmp_container *container,
oid index);
/*
* find ifIndex for given interface. 0 == not found.
*/
oid netsnmp_access_interface_index_find(const char *name);
/*
* find name for given index
*/
const char *netsnmp_access_interface_name_find(oid index);
/*
* copy interface entry data
*/
int netsnmp_access_interface_entry_copy(netsnmp_interface_entry * lhs,
netsnmp_interface_entry * rhs);
/*
* utility routines
*/
void netsnmp_access_interface_entry_guess_speed(netsnmp_interface_entry *);
void netsnmp_access_interface_entry_overrides(netsnmp_interface_entry *);
netsnmp_conf_if_list *
netsnmp_access_interface_entry_overrides_get(const char * name);
/**---------------------------------------------------------------------*/
#if defined( USING_IF_MIB_IFTABLE_IFTABLE_DATA_ACCESS_MODULE ) && \
! defined( NETSNMP_NO_BACKWARDS_COMPATABILITY )
void
Interface_Scan_Init(void);
int
Interface_Scan_Next(short *index, char *name, netsnmp_interface_entry **entry,
void *dc);
#endif
/**---------------------------------------------------------------------*/
#ifdef __cplusplus
}
#endif
#endif /* NETSNMP_ACCESS_INTERFACE_H */
|