1 --- net-snmp-5.4.1/agent/mibgroup/ip-mib/data_access/systemstats_solaris2.c (revision 0) |
|
2 +++ net-snmp-5.4.1-patch/agent/mibgroup/ip-mib/data_access/systemstats_solaris2.c (revision 0) |
|
3 @@ -0,0 +1,199 @@ |
|
4 +#include <net-snmp/net-snmp-config.h> |
|
5 +#include <net-snmp/net-snmp-includes.h> |
|
6 + |
|
7 +#include <net-snmp/agent/net-snmp-agent-includes.h> |
|
8 +#include <net-snmp/data_access/ipstats.h> |
|
9 +#include <net-snmp/data_access/systemstats.h> |
|
10 + |
|
11 +#include "kernel_sunos5.h" |
|
12 + |
|
13 +static int _systemstats(mibgroup_e, netsnmp_container *, u_int); |
|
14 +static void _add_ipstats(mib2_ipIfStatsEntry_t *, mib2_ipIfStatsEntry_t *); |
|
15 +static int _insert_entry(netsnmp_container *, mib2_ipIfStatsEntry_t *); |
|
16 + |
|
17 +void |
|
18 +netsnmp_access_systemstats_arch_init(void) |
|
19 +{ |
|
20 + init_kernel_sunos5(); |
|
21 +} |
|
22 + |
|
23 +/* |
|
24 + * @retval 0 success |
|
25 + * @retval -1 container error |
|
26 + * @retval -2 could not create entry (probably malloc) |
|
27 + */ |
|
28 +int |
|
29 +netsnmp_access_systemstats_container_arch_load(netsnmp_container* container, |
|
30 + u_int load_flags) |
|
31 +{ |
|
32 + int rc; |
|
33 + |
|
34 + if (container == NULL) |
|
35 + return (-1); |
|
36 + |
|
37 + if ((rc = _systemstats(MIB_IP_TRAFFIC_STATS, container, load_flags)) < 0) |
|
38 + return (rc); |
|
39 +#if defined(NETSNMP_ENABLE_IPV6) |
|
40 + if ((rc = _systemstats(MIB_IP6, container, load_flags)) < 0) { |
|
41 + netsnmp_access_systemstats_container_free(container, |
|
42 + NETSNMP_ACCESS_SYSTEMSTATS_FREE_NOFLAGS); |
|
43 + return (rc); |
|
44 + } |
|
45 +#endif |
|
46 + return (0); |
|
47 +} |
|
48 + |
|
49 +/* |
|
50 + * @retval 0 success |
|
51 + * @retval <0 error |
|
52 + */ |
|
53 +static int |
|
54 +_systemstats(mibgroup_e mib, netsnmp_container *container, u_int load_flags) |
|
55 +{ |
|
56 + mib2_ipIfStatsEntry_t ipe, iptot; |
|
57 + req_e req = GET_FIRST; |
|
58 + int ipversion = (mib == MIB_IP6) ? MIB2_INETADDRESSTYPE_ipv6 : |
|
59 + MIB2_INETADDRESSTYPE_ipv4; |
|
60 + bzero((void *)&iptot, sizeof(iptot)); |
|
61 + |
|
62 + while (getMibstat(mib, &ipe, sizeof(ipe), req, |
|
63 + &Get_everything, NULL) == 0) { |
|
64 + req = GET_NEXT; |
|
65 + netsnmp_assert(ipe.ipIfStatsIPVersion == ipversion); |
|
66 + _add_ipstats(&iptot, &ipe); |
|
67 + } |
|
68 + iptot.ipIfStatsIPVersion = ipversion; |
|
69 + return _insert_entry(container, &iptot); |
|
70 +} |
|
71 + |
|
72 +static void |
|
73 +_add_ipstats(mib2_ipIfStatsEntry_t *o1, mib2_ipIfStatsEntry_t *o2) |
|
74 +{ |
|
75 + o1->ipIfStatsInHdrErrors += o2->ipIfStatsInHdrErrors; |
|
76 + o1->ipIfStatsInTooBigErrors += o2->ipIfStatsInTooBigErrors; |
|
77 + o1->ipIfStatsInNoRoutes += o2->ipIfStatsInNoRoutes; |
|
78 + o1->ipIfStatsInAddrErrors += o2->ipIfStatsInAddrErrors; |
|
79 + o1->ipIfStatsInUnknownProtos += o2->ipIfStatsInUnknownProtos; |
|
80 + o1->ipIfStatsInTruncatedPkts += o2->ipIfStatsInTruncatedPkts; |
|
81 + o1->ipIfStatsInDiscards += o2->ipIfStatsInDiscards; |
|
82 + o1->ipIfStatsOutDiscards += o2->ipIfStatsOutDiscards; |
|
83 + o1->ipIfStatsOutFragOKs += o2->ipIfStatsOutFragOKs; |
|
84 + o1->ipIfStatsOutFragFails += o2->ipIfStatsOutFragFails; |
|
85 + o1->ipIfStatsOutFragCreates += o2->ipIfStatsOutFragCreates; |
|
86 + o1->ipIfStatsReasmReqds += o2->ipIfStatsReasmReqds; |
|
87 + o1->ipIfStatsReasmOKs += o2->ipIfStatsReasmOKs; |
|
88 + o1->ipIfStatsReasmFails += o2->ipIfStatsReasmFails; |
|
89 + o1->ipIfStatsOutNoRoutes += o2->ipIfStatsOutNoRoutes; |
|
90 + o1->ipIfStatsReasmDuplicates += o2->ipIfStatsReasmDuplicates; |
|
91 + o1->ipIfStatsReasmPartDups += o2->ipIfStatsReasmPartDups; |
|
92 + o1->ipIfStatsForwProhibits += o2->ipIfStatsForwProhibits; |
|
93 + o1->udpInCksumErrs += o2->udpInCksumErrs; |
|
94 + o1->udpInOverflows += o2->udpInOverflows; |
|
95 + o1->rawipInOverflows += o2->rawipInOverflows; |
|
96 + o1->ipIfStatsInWrongIPVersion += o2->ipIfStatsInWrongIPVersion; |
|
97 + o1->ipIfStatsOutWrongIPVersion += o2->ipIfStatsOutWrongIPVersion; |
|
98 + o1->ipIfStatsOutSwitchIPVersion += o2->ipIfStatsOutSwitchIPVersion; |
|
99 + o1->ipIfStatsHCInReceives += o2->ipIfStatsHCInReceives; |
|
100 + o1->ipIfStatsHCInOctets += o2->ipIfStatsHCInOctets; |
|
101 + o1->ipIfStatsHCInForwDatagrams += o2->ipIfStatsHCInForwDatagrams; |
|
102 + o1->ipIfStatsHCInDelivers += o2->ipIfStatsHCInDelivers; |
|
103 + o1->ipIfStatsHCOutRequests += o2->ipIfStatsHCOutRequests; |
|
104 + o1->ipIfStatsHCOutForwDatagrams += o2->ipIfStatsHCOutForwDatagrams; |
|
105 + o1->ipIfStatsOutFragReqds += o2->ipIfStatsOutFragReqds; |
|
106 + o1->ipIfStatsHCOutTransmits += o2->ipIfStatsHCOutTransmits; |
|
107 + o1->ipIfStatsHCOutOctets += o2->ipIfStatsHCOutOctets; |
|
108 + o1->ipIfStatsHCInMcastPkts += o2->ipIfStatsHCInMcastPkts; |
|
109 + o1->ipIfStatsHCInMcastOctets += o2->ipIfStatsHCInMcastOctets; |
|
110 + o1->ipIfStatsHCOutMcastPkts += o2->ipIfStatsHCOutMcastPkts; |
|
111 + o1->ipIfStatsHCOutMcastOctets += o2->ipIfStatsHCOutMcastOctets; |
|
112 + o1->ipIfStatsHCInBcastPkts += o2->ipIfStatsHCInBcastPkts; |
|
113 + o1->ipIfStatsHCOutBcastPkts += o2->ipIfStatsHCOutBcastPkts; |
|
114 + o1->ipsecInSucceeded += o2->ipsecInSucceeded; |
|
115 + o1->ipsecInFailed += o2->ipsecInFailed; |
|
116 + o1->ipInCksumErrs += o2->ipInCksumErrs; |
|
117 + o1->tcpInErrs += o2->tcpInErrs; |
|
118 + o1->udpNoPorts += o2->udpNoPorts; |
|
119 +} |
|
120 + |
|
121 +/* |
|
122 + * @retval 0 entry was successfully inserted in the container |
|
123 + * @retval -1 container error |
|
124 + * @retval -2 memory allocation error |
|
125 + */ |
|
126 +static int |
|
127 +_insert_entry(netsnmp_container *container, mib2_ipIfStatsEntry_t *ipe) |
|
128 +{ |
|
129 + netsnmp_systemstats_entry *ep = |
|
130 + netsnmp_access_systemstats_entry_create(ipe->ipIfStatsIPVersion); |
|
131 + |
|
132 + DEBUGMSGTL(("access:systemstats:arch", "insert entry for v%d\n", |
|
133 + ipe->ipIfStatsIPVersion)); |
|
134 + if (ep == NULL) { |
|
135 + DEBUGMSGT(("access:systemstats:arch", "insert failed (alloc)")); |
|
136 + return (-2); |
|
137 + } |
|
138 + |
|
139 + ep->stats.HCInReceives.low = |
|
140 + ipe->ipIfStatsHCInReceives & 0xffffffff; |
|
141 + ep->stats.HCInReceives.high = ipe->ipIfStatsHCInReceives >> 32; |
|
142 + ep->stats.HCInOctets.low = |
|
143 + ipe->ipIfStatsHCInOctets & 0xffffffff; |
|
144 + ep->stats.HCInOctets.high = ipe->ipIfStatsHCInOctets >> 32; |
|
145 + ep->stats.InHdrErrors = ipe->ipIfStatsInHdrErrors; |
|
146 + ep->stats.InAddrErrors = ipe->ipIfStatsInAddrErrors; |
|
147 + ep->stats.InUnknownProtos = ipe->ipIfStatsInUnknownProtos; |
|
148 + ep->stats.InTruncatedPkts = ipe->ipIfStatsInTruncatedPkts; |
|
149 + ep->stats.HCInForwDatagrams.low = |
|
150 + ipe->ipIfStatsHCInForwDatagrams & 0xffffffff; |
|
151 + ep->stats.HCInForwDatagrams.high = |
|
152 + ipe->ipIfStatsHCInForwDatagrams >> 32; |
|
153 + ep->stats.ReasmReqds = ipe->ipIfStatsReasmReqds; |
|
154 + ep->stats.ReasmOKs = ipe->ipIfStatsReasmOKs; |
|
155 + ep->stats.ReasmFails = ipe->ipIfStatsReasmFails; |
|
156 + ep->stats.InDiscards = ipe->ipIfStatsInDiscards; |
|
157 + ep->stats.HCInDelivers.low = |
|
158 + ipe->ipIfStatsHCInDelivers & 0xffffffff; |
|
159 + ep->stats.HCInDelivers.high = |
|
160 + ipe->ipIfStatsHCInDelivers >> 32; |
|
161 + ep->stats.HCOutRequests.low = |
|
162 + ipe->ipIfStatsHCOutRequests & 0xffffffff; |
|
163 + ep->stats.HCOutRequests.high = |
|
164 + ipe->ipIfStatsHCOutRequests >> 32; |
|
165 + ep->stats.OutNoRoutes = ipe->ipIfStatsOutNoRoutes; |
|
166 + ep->stats.HCOutForwDatagrams.low = |
|
167 + ipe->ipIfStatsHCOutForwDatagrams & 0xffffffff; |
|
168 + ep->stats.HCOutForwDatagrams.high = |
|
169 + ipe->ipIfStatsHCOutForwDatagrams >> 32; |
|
170 + ep->stats.OutDiscards = ipe->ipIfStatsOutDiscards; |
|
171 + ep->stats.OutFragOKs = ipe->ipIfStatsOutFragOKs; |
|
172 + ep->stats.OutFragFails = ipe->ipIfStatsOutFragFails; |
|
173 + ep->stats.OutFragCreates = ipe->ipIfStatsOutFragCreates; |
|
174 + ep->stats.HCOutTransmits.low = |
|
175 + ipe->ipIfStatsHCOutTransmits & 0xffffffff; |
|
176 + ep->stats.HCOutTransmits.high = ipe->ipIfStatsHCOutTransmits >> 32; |
|
177 + ep->stats.HCOutOctets.low = ipe->ipIfStatsHCOutOctets & 0xffffffff; |
|
178 + ep->stats.HCOutOctets.high = ipe->ipIfStatsHCOutOctets >> 32; |
|
179 + ep->stats.HCInMcastPkts.low = ipe->ipIfStatsHCInMcastPkts & 0xffffffff; |
|
180 + ep->stats.HCInMcastPkts.high = ipe->ipIfStatsHCInMcastPkts >> 32; |
|
181 + ep->stats.HCInMcastOctets.low = |
|
182 + ipe->ipIfStatsHCInMcastOctets & 0xffffffff; |
|
183 + ep->stats.HCInMcastOctets.high = ipe->ipIfStatsHCInMcastOctets >> 32; |
|
184 + ep->stats.HCOutMcastPkts.low = |
|
185 + ipe->ipIfStatsHCOutMcastPkts & 0xffffffff; |
|
186 + ep->stats.HCOutMcastPkts.high = ipe->ipIfStatsHCOutMcastPkts >> 32; |
|
187 + ep->stats.HCOutMcastOctets.low = |
|
188 + ipe->ipIfStatsHCOutMcastOctets & 0xffffffff; |
|
189 + ep->stats.HCOutMcastOctets.high = ipe->ipIfStatsHCOutMcastOctets >> 32; |
|
190 + ep->stats.HCInBcastPkts.low = ipe->ipIfStatsHCInBcastPkts & 0xffffffff; |
|
191 + ep->stats.HCInBcastPkts.high = ipe->ipIfStatsHCInBcastPkts >> 32; |
|
192 + ep->stats.HCOutBcastPkts.low = |
|
193 + ipe->ipIfStatsHCOutBcastPkts & 0xffffffff; |
|
194 + ep->stats.HCOutBcastPkts.high = ipe->ipIfStatsHCOutBcastPkts >> 32; |
|
195 + |
|
196 + if (CONTAINER_INSERT(container, ep) < 0) { |
|
197 + DEBUGMSGT(("access:systemstats:arch", "unable to insert entry")); |
|
198 + netsnmp_access_systemstats_entry_free(ep); |
|
199 + return (-1); |
|
200 + } |
|
201 + return (0); |
|
202 +} |
|
203 --- net-snmp-5.4.1/agent/mibgroup/ip-mib/data_access/ipaddress_solaris2.c (revision 0) |
|
204 +++ net-snmp-5.4.1-patch/agent/mibgroup/ip-mib/data_access/ipaddress_solaris2.c (revision 0) |
|
205 @@ -0,0 +1,286 @@ |
|
206 +/* |
|
207 + * IP-MIB architecture support |
|
208 + * |
|
209 + */ |
|
210 +#include <net-snmp/net-snmp-config.h> |
|
211 +#include <net-snmp/net-snmp-includes.h> |
|
212 + |
|
213 +#include <net-snmp/agent/net-snmp-agent-includes.h> |
|
214 +#include <net-snmp/data_access/ipaddress.h> |
|
215 +#include <net-snmp/data_access/interface.h> |
|
216 + |
|
217 +#include "ip-mib/ipAddressTable/ipAddressTable_constants.h" |
|
218 + |
|
219 +#include "kernel_sunos5.h" |
|
220 +#include "mibII/mibII_common.h" |
|
221 + |
|
222 +static int _load_v4(netsnmp_container *container, int idx_offset); |
|
223 +#if defined( NETSNMP_ENABLE_IPV6 ) |
|
224 +static int _load_v6(netsnmp_container *container, int idx_offset); |
|
225 +#endif |
|
226 + |
|
227 +/* |
|
228 + * initialize arch specific storage |
|
229 + * |
|
230 + * @retval 0: success |
|
231 + * @retval <0: error |
|
232 + */ |
|
233 +int |
|
234 +netsnmp_arch_ipaddress_entry_init(netsnmp_ipaddress_entry *entry) |
|
235 +{ |
|
236 + init_kernel_sunos5(); |
|
237 + return 0; |
|
238 +} |
|
239 + |
|
240 +/* |
|
241 + * cleanup arch specific storage |
|
242 + */ |
|
243 +void |
|
244 +netsnmp_arch_ipaddress_entry_cleanup(netsnmp_ipaddress_entry *entry) |
|
245 +{ |
|
246 + /* |
|
247 + * Nothing to do. |
|
248 + */ |
|
249 +} |
|
250 + |
|
251 +/* |
|
252 + * copy arch specific storage |
|
253 + */ |
|
254 +int |
|
255 +netsnmp_arch_ipaddress_entry_copy(netsnmp_ipaddress_entry *lhs, |
|
256 + netsnmp_ipaddress_entry *rhs) |
|
257 +{ |
|
258 + /* |
|
259 + * Nothing to do. |
|
260 + */ |
|
261 + return 0; |
|
262 +} |
|
263 + |
|
264 +/* |
|
265 + * create a new entry |
|
266 + */ |
|
267 +int |
|
268 +netsnmp_arch_ipaddress_create(netsnmp_ipaddress_entry *entry) |
|
269 +{ |
|
270 + if (NULL == entry) |
|
271 + return -1; |
|
272 + |
|
273 + DEBUGMSGT(("access:ipaddress:create", "not applicable\n")); |
|
274 + return 0; |
|
275 +} |
|
276 + |
|
277 +/* |
|
278 + * delete an entry |
|
279 + */ |
|
280 +int |
|
281 +netsnmp_arch_ipaddress_delete(netsnmp_ipaddress_entry *entry) |
|
282 +{ |
|
283 + if (NULL == entry) |
|
284 + return -1; |
|
285 + |
|
286 + DEBUGMSGT(("access:ipaddress:create", "not applicable\n")); |
|
287 + return 0; |
|
288 +} |
|
289 + |
|
290 +/** |
|
291 + * |
|
292 + * @retval 0 no errors |
|
293 + * @retval !0 errors |
|
294 + */ |
|
295 +int |
|
296 +netsnmp_arch_ipaddress_container_load(netsnmp_container *container, |
|
297 + u_int load_flags) |
|
298 +{ |
|
299 + int rc = 0, idx_offset = 0; |
|
300 + |
|
301 + if (!(load_flags & NETSNMP_ACCESS_IPADDRESS_LOAD_IPV6_ONLY)) { |
|
302 + rc = _load_v4(container, idx_offset); |
|
303 + if(rc < 0) { |
|
304 + u_int flags = NETSNMP_ACCESS_IPADDRESS_FREE_KEEP_CONTAINER; |
|
305 + netsnmp_access_ipaddress_container_free(container, flags); |
|
306 + } |
|
307 + } |
|
308 + |
|
309 +#if defined( NETSNMP_ENABLE_IPV6 ) |
|
310 + |
|
311 + if (!(load_flags & NETSNMP_ACCESS_IPADDRESS_LOAD_IPV4_ONLY)) { |
|
312 + if (rc < 0) |
|
313 + rc = 0; |
|
314 + |
|
315 + idx_offset = rc; |
|
316 + |
|
317 + rc = _load_v6(container, idx_offset); |
|
318 + if(rc < 0) { |
|
319 + u_int flags = NETSNMP_ACCESS_IPADDRESS_FREE_KEEP_CONTAINER; |
|
320 + netsnmp_access_ipaddress_container_free(container, flags); |
|
321 + } |
|
322 + } |
|
323 +#endif |
|
324 + |
|
325 + /* |
|
326 + * return no errors (0) if we found any interfaces |
|
327 + */ |
|
328 + if(rc > 0) |
|
329 + rc = 0; |
|
330 + return rc; |
|
331 +} |
|
332 + |
|
333 +/* |
|
334 + * @retval >=idx_offset ok |
|
335 + * @retval -1 memory allocation error |
|
336 + * @retval -2 interface lookup error |
|
337 + * @retval -3 container error |
|
338 + */ |
|
339 +static int |
|
340 +_load_v4(netsnmp_container *container, int idx_offset) |
|
341 +{ |
|
342 + mib2_ipAddrEntry_t ipae; |
|
343 + netsnmp_ipaddress_entry *entry; |
|
344 + req_e req = GET_FIRST; |
|
345 + int rc = 0; |
|
346 + |
|
347 + DEBUGMSGTL(("access:ipaddress:container", "loading v4\n")); |
|
348 + while ((rc = getMibstat(MIB_IP_ADDR, &ipae, sizeof(ipae), req, |
|
349 + &Get_everything, NULL)) == 0) { |
|
350 + req = GET_NEXT; |
|
351 + entry = netsnmp_access_ipaddress_entry_create(); |
|
352 + if (entry == NULL) |
|
353 + return (-1); |
|
354 + if (ipae.ipAdEntAddr == INADDR_ANY) |
|
355 + continue; |
|
356 + |
|
357 + ipae.ipAdEntIfIndex.o_bytes[ipae.ipAdEntIfIndex.o_length] = '\0'; |
|
358 + DEBUGMSGTL(("access:ipaddress:container", "found if %s\n", |
|
359 + ipae.ipAdEntIfIndex.o_bytes)); |
|
360 + /* Obtain interface index */ |
|
361 + entry->if_index = |
|
362 + netsnmp_access_interface_index_find(ipae.ipAdEntIfIndex.o_bytes); |
|
363 + if (entry->if_index == 0) { |
|
364 + DEBUGMSGTL(("access:ipaddress:container", "cannot find if %s\n", |
|
365 + ipae.ipAdEntIfIndex)); |
|
366 + netsnmp_access_ipaddress_entry_free(entry); |
|
367 + return (-2); |
|
368 + } |
|
369 + |
|
370 + if (strchr((const char *)&ipae.ipAdEntIfIndex.o_bytes, ':') != 0) |
|
371 + entry->flags |= NETSNMP_ACCESS_IPADDRESS_ISALIAS; |
|
372 + |
|
373 + /* Get the address */ |
|
374 + entry->ia_address_len = sizeof(ipae.ipAdEntAddr); |
|
375 + netsnmp_assert(entry->ia_address_len == 4 && |
|
376 + entry->ia_address_len <= sizeof(entry->ia_address)); |
|
377 + memcpy(&entry->ia_address, &ipae.ipAdEntAddr, entry->ia_address_len); |
|
378 + |
|
379 + /* prefix */ |
|
380 + entry->ia_prefix_len = ipae.ipAdEntInfo.ae_subnet_len; |
|
381 + |
|
382 + /* set the Origin */ |
|
383 + if (ipae.ipAdEntInfo.ae_flags & IFF_DHCPRUNNING) |
|
384 + entry->ia_origin = IPADDRESSORIGINTC_DHCP; |
|
385 + else |
|
386 + entry->ia_origin = IPADDRESSORIGINTC_MANUAL; |
|
387 + |
|
388 + /* set ipv4 constants */ |
|
389 + entry->ia_type = IPADDRESSTYPE_UNICAST; |
|
390 + entry->ia_status = IPADDRESSSTATUSTC_PREFERRED; |
|
391 + |
|
392 + entry->ns_ia_index = ++idx_offset; |
|
393 + |
|
394 + DEBUGMSGTL(("access:ipaddress:container", "insert if %d, addrlen %d\n", |
|
395 + entry->if_index, entry->ia_address_len)); |
|
396 + |
|
397 + if (CONTAINER_INSERT(container, entry) < 0) { |
|
398 + DEBUGMSGTL(("access:ipaddress:container", "unable to insert %s\n", |
|
399 + ipae.ipAdEntIfIndex.o_bytes)); |
|
400 + netsnmp_access_ipaddress_entry_free(entry); |
|
401 + return (-3); |
|
402 + } |
|
403 + } |
|
404 + return (idx_offset); |
|
405 +} |
|
406 + |
|
407 +/* |
|
408 + * @retval >=idx_offset ok |
|
409 + * @retval -1 memory allocation error |
|
410 + * @retval -2 interface lookup error |
|
411 + * @retval -3 container error |
|
412 + */ |
|
413 +#if defined( NETSNMP_ENABLE_IPV6 ) |
|
414 +static int |
|
415 +_load_v6(netsnmp_container *container, int idx_offset) |
|
416 +{ |
|
417 + mib2_ipv6AddrEntry_t ip6ae; |
|
418 + netsnmp_ipaddress_entry *entry; |
|
419 + req_e req = GET_FIRST; |
|
420 + int rc = 0; |
|
421 + |
|
422 + DEBUGMSGTL(("access:ipaddress:container", "loading v6... cache %d\n", |
|
423 + MIB_IP6_ADDR)); |
|
424 + while ((rc = getMibstat(MIB_IP6_ADDR, &ip6ae, sizeof(ip6ae), req, |
|
425 + &Get_everything, NULL)) == 0) { |
|
426 + req = GET_NEXT; |
|
427 + entry = netsnmp_access_ipaddress_entry_create(); |
|
428 + if (entry == NULL) |
|
429 + return (-1); |
|
430 + if (bcmp((const void *)&ip6ae.ipv6AddrAddress, |
|
431 + (const void *)&in6addr_any, |
|
432 + sizeof (ip6ae.ipv6AddrAddress)) == 0) |
|
433 + continue; |
|
434 + |
|
435 + ip6ae.ipv6AddrIfIndex.o_bytes[ip6ae.ipv6AddrIfIndex.o_length] = '\0'; |
|
436 + DEBUGMSGTL(("access:ipaddress:container", "found if %s\n", |
|
437 + ip6ae.ipv6AddrIfIndex.o_bytes)); |
|
438 + |
|
439 + /* Obtain interface index */ |
|
440 + entry->if_index = |
|
441 + netsnmp_access_interface_index_find( |
|
442 + ip6ae.ipv6AddrIfIndex.o_bytes); |
|
443 + if (entry->if_index == 0) { |
|
444 + DEBUGMSGTL(("access:ipaddress:container", "cannot find if %s\n", |
|
445 + ip6ae.ipv6AddrIfIndex.o_bytes)); |
|
446 + netsnmp_access_ipaddress_entry_free(entry); |
|
447 + return (-2); |
|
448 + } |
|
449 + |
|
450 + /* Get the address */ |
|
451 + entry->ia_address_len = sizeof(ip6ae.ipv6AddrAddress); |
|
452 + netsnmp_assert(entry->ia_address_len == 16 && |
|
453 + entry->ia_address_len <= sizeof(entry->ia_address)); |
|
454 + memcpy(&entry->ia_address, &ip6ae.ipv6AddrAddress, |
|
455 + entry->ia_address_len); |
|
456 + |
|
457 + /* prefix */ |
|
458 + entry->ia_prefix_len = ip6ae.ipv6AddrPfxLength; |
|
459 + |
|
460 + /* type is anycast? (mib2.h: 1 = yes, 2 = no) */ |
|
461 + entry->ia_type = (ip6ae.ipv6AddrAnycastFlag == 1) ? |
|
462 + IPADDRESSTYPE_ANYCAST : IPADDRESSTYPE_UNICAST; |
|
463 + |
|
464 + /* origin (mib2.h: 1 = stateless, 2 = stateful, 3 = unknown) */ |
|
465 + DEBUGMSGTL(("access:ipaddress:container", "origin %d\n", |
|
466 + ip6ae.ipv6AddrType)); |
|
467 + if (ip6ae.ipv6AddrType == 1) |
|
468 + entry->ia_origin = IPADDRESSORIGINTC_LINKLAYER; |
|
469 + else if (ip6ae.ipv6AddrInfo.ae_flags & IFF_DHCPRUNNING) |
|
470 + entry->ia_origin = IPADDRESSORIGINTC_DHCP; |
|
471 + else |
|
472 + entry->ia_origin = IPADDRESSORIGINTC_MANUAL; |
|
473 + |
|
474 + /* status */ |
|
475 + entry->ia_status = ip6ae.ipv6AddrStatus; |
|
476 + |
|
477 + entry->ns_ia_index = ++idx_offset; |
|
478 + |
|
479 + DEBUGMSGTL(("access:ipaddress:container", "insert if %d, addrlen %d\n", |
|
480 + entry->if_index, entry->ia_address_len)); |
|
481 + |
|
482 + if (CONTAINER_INSERT(container, entry) < 0) { |
|
483 + DEBUGMSGTL(("access:ipaddress:container", "unable to insert %s\n", |
|
484 + ip6ae.ipv6AddrIfIndex.o_bytes)); |
|
485 + netsnmp_access_ipaddress_entry_free(entry); |
|
486 + return (-3); |
|
487 + } |
|
488 + } |
|
489 + return (idx_offset); |
|
490 +} |
|
491 +#endif /* defined( NETSNMP_ENABLE_IPV6 ) */ |
|