diff options
author | harti <harti@FreeBSD.org> | 2016-01-21 16:11:20 +0000 |
---|---|---|
committer | harti <harti@FreeBSD.org> | 2016-01-21 16:11:20 +0000 |
commit | 9695459665ca68a66ba2e9f04d4bf57787e95b34 (patch) | |
tree | 4d51c55ca0675baf4673ad2810858addce99e2cb /contrib/bsnmp/snmp_mibII/mibII.c | |
parent | d6a31ebe03d5c26e102e7ef256ccdb0bbc1f438f (diff) | |
download | FreeBSD-src-9695459665ca68a66ba2e9f04d4bf57787e95b34.zip FreeBSD-src-9695459665ca68a66ba2e9f04d4bf57787e95b34.tar.gz |
Fill the ifAlias leaf of the ifXTable with the interface description
if there is one available and it fits into the maximum size (64 characters).
Diffstat (limited to 'contrib/bsnmp/snmp_mibII/mibII.c')
-rw-r--r-- | contrib/bsnmp/snmp_mibII/mibII.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/contrib/bsnmp/snmp_mibII/mibII.c b/contrib/bsnmp/snmp_mibII/mibII.c index d3fe27a..b62ee66 100644 --- a/contrib/bsnmp/snmp_mibII/mibII.c +++ b/contrib/bsnmp/snmp_mibII/mibII.c @@ -443,6 +443,7 @@ mib_fetch_ifmib(struct mibif *ifp) size_t len; void *newmib; struct ifmibdata oldmib = ifp->mib; + struct ifreq irr; if (fetch_generic_mib(ifp, &oldmib) == -1) return (-1); @@ -514,6 +515,18 @@ mib_fetch_ifmib(struct mibif *ifp) } out: + strncpy(irr.ifr_name, ifp->name, sizeof(irr.ifr_name)); + irr.ifr_buffer.buffer = MIBIF_PRIV(ifp)->alias; + irr.ifr_buffer.length = sizeof(MIBIF_PRIV(ifp)->alias); + if (ioctl(mib_netsock, SIOCGIFDESCR, &irr) == -1) { + MIBIF_PRIV(ifp)->alias[0] = 0; + if (errno != ENOMSG) + syslog(LOG_WARNING, "SIOCGIFDESCR (%s): %m", ifp->name); + } else if (irr.ifr_buffer.buffer == NULL) { + MIBIF_PRIV(ifp)->alias[0] = 0; + syslog(LOG_WARNING, "SIOCGIFDESCR (%s): too long (%zu)", + ifp->name, irr.ifr_buffer.length); + } ifp->mibtick = get_ticks(); return (0); } |