216
216
{IFNUMBER, ASN_INTEGER, RONLY, var_interfaces, 1, {1}},
217
217
{IFINDEX, ASN_INTEGER, RONLY, var_ifEntry, 3, {2, 1, 1}},
218
218
{IFDESCR, ASN_OCTET_STR, RONLY, var_ifEntry, 3, {2, 1, 2}},
219
{IFTYPE, ASN_INTEGER, RONLY, var_ifEntry, 3, {2, 1, 3}},
219
{NETSNMP_IFTYPE, ASN_INTEGER, RONLY, var_ifEntry, 3, {2, 1, 3}},
220
220
{IFMTU, ASN_INTEGER, RONLY, var_ifEntry, 3, {2, 1, 4}},
221
221
{IFSPEED, ASN_GAUGE, RONLY, var_ifEntry, 3, {2, 1, 5}},
222
222
{IFPHYSADDRESS, ASN_OCTET_STR, RONLY, var_ifEntry, 3, {2, 1, 6}},
1322
1322
*var_len = ifstat.ifDescr.o_length;
1323
1323
(void) memcpy(return_buf, ifstat.ifDescr.o_bytes, *var_len);
1324
1324
return (u_char *) return_buf;
1325
case NETSNMP_IFTYPE:
1327
1327
long_return = if_ptr->type;
1422
1422
* Determines network interface speed. It is system specific. Only linux
1423
1423
* realization is made.
1425
unsigned int getIfSpeed(int fd, struct ifreq ifr)
1425
unsigned int getIfSpeed(int fd, struct ifreq ifr, unsigned int defaultspeed)
1428
1428
/** temporary expose internal until this module can be re-written */
1429
1429
extern unsigned int
1430
netsnmp_linux_interface_get_if_speed(int fd, const char *name);
1430
netsnmp_linux_interface_get_if_speed(int fd, const char *name,
1431
unsigned long long defaultspeed);
1432
return netsnmp_linux_interface_get_if_speed(fd, ifr.ifr_name);
1433
return netsnmp_linux_interface_get_if_speed(fd, ifr.ifr_name, defaultspeed);
1433
1434
#else /*!linux*/
1435
return defaultspeed;
1550
1551
struct ifnet *nnew;
1551
1552
char *stats, *ifstart = line;
1554
/* Ignore interfaces with no statistics. */
1555
if (strstr(line, "No statistics available."))
1553
1558
if (line[strlen(line) - 1] == '\n')
1554
1559
line[strlen(line) - 1] = '\0';
1583
1588
&coll) != 5)) {
1584
1589
if ((scan_line_to_use == scan_line_2_2)
1585
1590
&& !strstr(line, "No statistics available"))
1587
1592
"/proc/net/dev data format error, line ==|%s|",
1752
1757
* do only guess if_type from name, if we could not read
1753
1758
* * it before from SIOCGIFHWADDR
1760
unsigned int defaultspeed = NOMINAL_LINK_SPEED;
1761
if (!(nnew->if_flags & IFF_RUNNING)) {
1763
* use speed 0 if the if speed cannot be determined *and* the
1755
1769
if (!nnew->if_type)
1756
1770
nnew->if_type = if_type_from_name(nnew->if_name);
1757
nnew->if_speed = nnew->if_type == 6 ? getIfSpeed(fd, ifrq) :
1758
nnew->if_type == 24 ? 10000000 :
1759
nnew->if_type == 9 ? 4000000 : 0;
1771
switch(nnew->if_type) {
1773
nnew->if_speed = getIfSpeed(fd, ifrq, defaultspeed);
1776
nnew->if_speed = 10000000;
1779
nnew->if_speed = 4000000;
1760
1784
/*Zero speed means link problem*/
1761
1785
if(nnew->if_speed == 0 && nnew->if_flags & IFF_UP){
1762
1786
nnew->if_flags &= ~IFF_RUNNING;