~ubuntu-branches/ubuntu/trusty/net-snmp/trusty

« back to all changes in this revision

Viewing changes to agent/mibgroup/if-mib/data_access/interface_solaris2.c

  • Committer: Bazaar Package Importer
  • Author(s): Jochen Friedrich
  • Date: 2009-11-12 16:17:40 UTC
  • mto: (1.4.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 32.
  • Revision ID: james.westby@ubuntu.com-20091112161740-t2xvix834vmtxa9f
Tags: upstream-5.4.2.1~dfsg
ImportĀ upstreamĀ versionĀ 5.4.2.1~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
#include <sys/ioctl.h>
15
15
#include <sys/sockio.h>
16
16
#include <strings.h>
 
17
#include <string.h>
17
18
 
18
19
static int _set_ip_flags_v4(netsnmp_interface_entry *, mib2_ifEntry_t *);
19
20
static int _match_ifname_v4addr(void *ifname, void *ipaddr);
43
44
#if defined(HAVE_IF_NAMETOINDEX)
44
45
    return if_nametoindex(name);
45
46
#else /* use GIFINDEX */
46
 
    int             sd;
47
 
    struct ifreq    ifr;
48
 
 
49
 
    if (name == 0) {
50
 
        return (0);
51
 
    }
52
 
 
53
 
    if ((sd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
54
 
        return (0);
55
 
    }
56
 
 
57
 
    strncpy(ifr.ifr_name, name, IFNAMSIZ);
58
 
    if (ioctl(sd, SIOCGIFINDEX, (char *) &ifr) < 0) {
59
 
        close(sd);
60
 
        return (0);
61
 
    }
62
 
 
63
 
    close(sd);
64
 
    return (ifr.ifr_index);
 
47
    return solaris2_if_nametoindex(name, strlen(name));
65
48
#endif /* defined(HAVE_IF_NAMETOINDEX) */
66
49
}
67
50