2
2
* Interface MIB architecture support
4
* $Id: interface_ioctl.c,v 1.8 2004/10/17 01:52:52 rstory Exp $
4
* $Id: interface_ioctl.c,v 1.12.2.1 2006/01/25 16:26:38 dts12 Exp $
6
6
#include <net-snmp/net-snmp-config.h>
7
7
#include <net-snmp/net-snmp-includes.h>
22
23
#include <sys/ioctl.h>
26
#include "interface_ioctl.h"
27
#include "ip-mib/data_access/ipaddress_ioctl.h"
28
32
* @param fd : socket fd to use w/ioctl, or -1 to open/close one
29
* @param ifentry : ifentry to update
35
* param ifentry : ifentry to update
31
38
* @retval 0 : success
32
39
* @retval -1 : invalid parameters
365
372
* interface entry ifIndex ioctl wrapper
367
374
* @param fd : socket fd to use w/ioctl, or -1 to open/close one
368
* @param ifentry : ifentry to update
375
* @param name : ifentry to update
370
377
* @retval 0 : not found
371
378
* @retval !0 : ifIndex
388
395
return ifrq.ifr_ifindex;
389
396
#endif /* SIOCGIFINDEX */
400
* check an interface for ipv4 addresses
402
* @param sd : open socket descriptor
403
* @param if_name : optional name. takes precedent over if_index.
404
* @param if_index: optional if index. only used if no if_name specified
407
* @retval < 0 : error
408
* @retval 0 : no ip v4 addresses
409
* @retval 1 : 1 or more ip v4 addresses
412
netsnmp_access_interface_ioctl_has_ipv4(int sd, const char *if_name,
413
int if_index, u_int *flags)
415
int i, interfaces = 0;
422
if ((NULL == flags) ||
423
((0 == if_index) && (NULL == if_name))) {
427
interfaces = netsnmp_access_ipaddress_ioctl_get_interface_count(sd, &ifc);
432
netsnmp_assert(NULL != ifc.ifc_buf);
434
*flags &= ~NETSNMP_INTERFACE_FLAGS_HAS_IPV4;
437
for(i=0; i < interfaces; ++i, ++ifrp) {
439
DEBUGMSGTL(("access:ipaddress:container",
440
" interface %d, %s\n", i, ifrp->ifr_name));
443
* search for matching if_name or if_index
445
if (NULL != if_name) {
446
if (strncmp(if_name, ifrp->ifr_name, sizeof(ifrp->ifr_name)) != 0)
451
* I think that Linux and Solaris both use ':' in the
452
* interface name for aliases.
454
char *ptr = strchr(ifrp->ifr_name, ':');
459
netsnmp_access_interface_ioctl_ifindex_get(sd, ifrp->ifr_name))
464
* check and set v4 or v6 flag, and break if we've found both
466
if (AF_INET == ifrp->ifr_addr.sa_family) {
467
*flags |= NETSNMP_INTERFACE_FLAGS_HAS_IPV4;