~ubuntu-branches/ubuntu/wily/net-snmp/wily-proposed

« back to all changes in this revision

Viewing changes to agent/mibgroup/mibII/interfaces.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-06-28 14:59:36 UTC
  • mfrom: (1.2.3 upstream) (1.1.12 sid)
  • Revision ID: james.westby@ubuntu.com-20100628145936-cbiallic69pn044g
Tags: 5.4.3~dfsg-1ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Set Ubuntu maintainer address.
  - net-snmp-config: Use bash. (LP: #104738)
  - Removed multiuser option when calling update-rc.d. (LP: #254261)
  - debian/snmpd.init: LSBify the init script.
  - debian/patches/52_fix_snmpcmd_1_typo.patch: Adjust a typo in snmpcmd.1
    (LP: #250459)
  - debian/snmpd.postinst: source debconf before doing work, LP: #589056
  - debian/snmp.preinst, debian/snmp.prerm: kill any/all processes owned by
    snmp user before install/uninstall, LP: #573391
  - Add apport hook (LP: #533603):
  - debian/{snmp,snmpd}.apport: Added.
  - debian/control: Build-depends on dh-apport.
  - debian/rules: 
    + Add --with apport.
    + override_dh_apport to install hook on snmpd package only.
 * Dropped patches:
   - debian/patches/99-fix-ubuntu-div0.patch: Fix dvision by zero.. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
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}},
581
581
        cp = if_name;
582
582
        *var_len = strlen(if_name);
583
583
        return (u_char *) cp;
584
 
    case IFTYPE:
 
584
    case NETSNMP_IFTYPE:
585
585
        if (if_ptr)
586
586
            long_return = if_ptr->type;
587
587
        else
756
756
        cp = Name;
757
757
        *var_len = strlen(cp);
758
758
        return (u_char *) cp;
759
 
    case IFTYPE:
 
759
    case NETSNMP_IFTYPE:
760
760
        if (if_ptr)
761
761
            long_return = if_ptr->type;
762
762
        else {
1081
1081
#endif
1082
1082
        *var_len = strlen(cp);
1083
1083
        return (u_char *) cp;
1084
 
    case IFTYPE:
 
1084
    case NETSNMP_IFTYPE:
1085
1085
        if (if_ptr)
1086
1086
            long_return = if_ptr->type;
1087
1087
        else {
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 IFTYPE:
 
1325
    case NETSNMP_IFTYPE:
1326
1326
        if (if_ptr)
1327
1327
            long_return = if_ptr->type;
1328
1328
        else
1422
1422
* Determines network interface speed. It is system specific. Only linux
1423
1423
* realization is made. 
1424
1424
*/
1425
 
unsigned int getIfSpeed(int fd, struct ifreq ifr)
 
1425
unsigned int getIfSpeed(int fd, struct ifreq ifr, unsigned int defaultspeed)
1426
1426
{
1427
1427
#ifdef linux
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);
1431
1432
 
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*/                           
1434
 
    return 10000000;
 
1435
    return defaultspeed;
1435
1436
#endif 
1436
1437
}
1437
1438
 
1550
1551
        struct ifnet   *nnew;
1551
1552
        char           *stats, *ifstart = line;
1552
1553
 
 
1554
        /* Ignore interfaces with no statistics. */
 
1555
        if (strstr(line, "No statistics available."))
 
1556
            continue;
 
1557
 
1553
1558
        if (line[strlen(line) - 1] == '\n')
1554
1559
            line[strlen(line) - 1] = '\0';
1555
1560
 
1583
1588
                                               &coll) != 5)) {
1584
1589
            if ((scan_line_to_use == scan_line_2_2)
1585
1590
                && !strstr(line, "No statistics available"))
1586
 
                snmp_log(LOG_ERR,
 
1591
                snmp_log(LOG_DEBUG,
1587
1592
                         "/proc/net/dev data format error, line ==|%s|",
1588
1593
                         line);
1589
1594
            continue;
1752
1757
             * do only guess if_type from name, if we could not read
1753
1758
             * * it before from SIOCGIFHWADDR 
1754
1759
             */
 
1760
            unsigned int defaultspeed = NOMINAL_LINK_SPEED;
 
1761
                if (!(nnew->if_flags & IFF_RUNNING)) {
 
1762
                    /* 
 
1763
                     * use speed 0 if the if speed cannot be determined *and* the
 
1764
                     * interface is down
 
1765
                     */
 
1766
                    defaultspeed = 0;
 
1767
                }
 
1768
 
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) {
 
1772
            case 6:
 
1773
                nnew->if_speed = getIfSpeed(fd, ifrq, defaultspeed);
 
1774
                break;
 
1775
            case 24:
 
1776
                nnew->if_speed = 10000000;
 
1777
                break;
 
1778
            case 9:
 
1779
                nnew->if_speed = 4000000;
 
1780
                break;
 
1781
            default:
 
1782
                nnew->if_speed = 0;
 
1783
            }
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;
2464
2488
        cp = ifmd.ifmd_name;
2465
2489
        *var_len = strlen(cp);
2466
2490
        return (u_char *) cp;
2467
 
    case IFTYPE:
 
2491
    case NETSNMP_IFTYPE:
2468
2492
        if (if_ptr)
2469
2493
            long_return = if_ptr->type;
2470
2494
        else
2695
2719
    case IFDESCR:
2696
2720
        *var_len = ifRow.dwDescrLen;
2697
2721
        return (u_char *) ifRow.bDescr;
2698
 
    case IFTYPE:
 
2722
    case NETSNMP_IFTYPE:
2699
2723
        if (if_ptr)
2700
2724
            long_return = if_ptr->type;
2701
2725
        else