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

« back to all changes in this revision

Viewing changes to agent/mibgroup/ip-mib/data_access/arp_linux.c

  • Committer: Bazaar Package Importer
  • Author(s): Jochen Friedrich
  • Date: 2010-06-10 18:02:54 UTC
  • mto: (1.4.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100610180254-6ezvupl2clicwdqf
ImportĀ upstreamĀ versionĀ 5.4.3~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 *  Interface MIB architecture support
3
3
 *
4
 
 * $Id: arp_linux.c 16381 2007-05-17 21:53:28Z hardaker $
 
4
 * $Id: arp_linux.c 17892 2009-12-09 14:37:16Z jsafranek $
5
5
 */
6
6
#include <net-snmp/net-snmp-config.h>
7
7
#include <net-snmp/net-snmp-includes.h>
59
59
    char            line[128];
60
60
    int             rc = 0;
61
61
    netsnmp_arp_entry *entry;
62
 
    
 
62
    char           arp[3*NETSNMP_ACCESS_ARP_PHYSADDR_BUF_SIZE+1];
 
63
    char           *arp_token;
 
64
    int             i;
 
65
 
63
66
    netsnmp_assert(NULL != container);
64
67
 
65
68
#define PROCFILE "/proc/net/arp"
79
82
     */
80
83
    while (fgets(line, sizeof(line), in)) {
81
84
        
82
 
        int             za, zb, zc, zd, ze, zf, zg, zh, zi, zj;
 
85
        int             za, zb, zc, zd;
83
86
        int             tmp_flags;
84
87
        char            ifname[21];
85
88
 
86
89
        rc = sscanf(line,
87
 
                    "%d.%d.%d.%d 0x%*x 0x%x %x:%x:%x:%x:%x:%x %*[^ ] %20s\n",
88
 
                    &za, &zb, &zc, &zd, &tmp_flags, &ze, &zf, &zg, &zh, &zi,
89
 
                    &zj, ifname);
90
 
        if (12 != rc) {            
 
90
                    "%d.%d.%d.%d 0x%*x 0x%x %96s %*[^ ] %20s\n",
 
91
                    &za, &zb, &zc, &zd, &tmp_flags, arp, ifname);
 
92
        if (7 != rc) {
91
93
            snmp_log(LOG_ERR, PROCFILE " data format error (%d!=12)\n", rc);
92
94
            snmp_log(LOG_ERR, " line ==|%s|\n", line);
93
95
            continue;
94
96
        }
95
97
        DEBUGMSGTL(("access:arp:container",
96
98
                    "ip addr %d.%d.%d.%d, flags 0x%X, hw addr "
97
 
                    "%x:%x:%x:%x:%x:%x, name %s\n",
98
 
                    za,zb,zc,zd, tmp_flags, ze,zf,zg,zh,zi,zj, ifname ));
 
99
                    "%s, name %s\n",
 
100
                    za,zb,zc,zd, tmp_flags, arp, ifname ));
99
101
 
100
102
        /*
101
103
         */
134
136
        /*
135
137
         * parse hw addr
136
138
         */
137
 
        entry->arp_physaddress[0] = ze;
138
 
        entry->arp_physaddress[1] = zf;
139
 
        entry->arp_physaddress[2] = zg;
140
 
        entry->arp_physaddress[3] = zh;
141
 
        entry->arp_physaddress[4] = zi;
142
 
        entry->arp_physaddress[5] = zj;
143
 
        entry->arp_physaddress_len = 6;
 
139
        for (arp_token = strtok(arp, ":"), i=0; arp_token != NULL; arp_token = strtok(NULL, ":"), i++) {
 
140
            entry->arp_physaddress[i] = strtol(arp_token, NULL, 16);
 
141
        }
 
142
        entry->arp_physaddress_len = i;
144
143
 
145
144
        /*
146
145
         * what can we do with hw? from arp manpage: