This is the correct patch.
Subject: if-mib: add support for ifAlias
Linux has a way of recording an ifAlias value for each interface.
The value is configurable with iproute utilities or sysfs.
---
agent/mibgroup/if-mib/data_access/interface.c | 6 ++++
agent/mibgroup/if-mib/data_access/interface_linux.c | 28 ++++++++++++++++++++
agent/mibgroup/if-mib/ifTable/ifTable_defs.h | 1
include/net-snmp/data_access/interface.h | 1
4 files changed, 36 insertions(+)
--- a/agent/mibgroup/if-mib/data_access/interface.c 2010-08-31
16:54:49.579990097 -0700
+++ b/agent/mibgroup/if-mib/data_access/interface.c 2010-08-31
16:55:42.193906713 -0700
@@ -331,6 +331,9 @@ netsnmp_access_interface_entry_free(nets
if (NULL != entry->descr)
free(entry->descr);
+ if (NULL != entry->alias)
+ free(entry->alias);
+
if (NULL != entry->paddr)
free(entry->paddr);
@@ -754,6 +757,9 @@ netsnmp_access_interface_entry_overrides
if(entry->descr && (strlen(entry->descr) > 255))
entry->descr[255] = 0;
+ if(entry->alias && (strlen(entry->alias) > 255))
+ entry->alias[255] = 0;
+
if_ptr =
netsnmp_access_interface_entry_overrides_get(entry->name);
if (if_ptr) {
--- a/agent/mibgroup/if-mib/ifTable/ifTable_defs.h 2010-08-31
16:54:49.623991694 -0700
+++ b/agent/mibgroup/if-mib/ifTable/ifTable_defs.h 2010-08-31
16:55:42.197906859 -0700
@@ -1,4 +1,5 @@
#define ifDescr ifentry->descr
+#define ifAlias ifentry->alias
#define ifType ifentry->type
#define ifMtu ifentry->mtu
#define ifSpeed ifentry->speed
--- a/include/net-snmp/data_access/interface.h 2010-08-31 16:54:49.643992419
-0700
+++ b/include/net-snmp/data_access/interface.h 2010-08-31 16:55:42.197906859
-0700
@@ -149,6 +149,7 @@ typedef struct netsnmp_interface_entry_s
*/
char *name;
char *descr;
+ char *alias;
int type;
u_int speed;
u_int speed_high;
--- a/agent/mibgroup/if-mib/data_access/interface_linux.c 2010-08-31
16:54:49.599990824 -0700
+++ b/agent/mibgroup/if-mib/data_access/interface_linux.c 2010-08-31
16:55:42.197906859 -0700
@@ -89,6 +89,9 @@ pthread_t thread1;
static void *netsnmp_prefix_listen(void *formal);
#endif
+
+#define SYSFS_CLASS_NET_IFALIAS "/sys/class/net/%s/ifalias"
+
void
netsnmp_arch_interface_init(void)
{
@@ -234,6 +237,27 @@ _arch_interface_has_ipv6(oid if_index, u
* @internal
*/
static void
+_arch_interface_ifalias_get(netsnmp_interface_entry *entry)
+{
+ FILE *fin;
+ char line[256];
+
+ snprintf(line,sizeof(line), SYSFS_CLASS_NET_IFALIAS, entry->name);
+ if (!(fin = fopen(line, "r"))) {
+ DEBUGMSGTL(("access:interface",
+ "Failed to open %s\n", line));
+ return;
+ }
+ if (fgets(line, sizeof(line), fin)) {
+ if (line[strlen(line) - 1] == '\n')
+ line[strlen(line) - 1] = '\0';
+
+ entry->alias = strdup(line);
+ }
+ fclose(fin);
+}
+
+static void
_arch_interface_flags_v4_get(netsnmp_interface_entry *entry)
{
FILE *fin;
@@ -617,6 +641,10 @@ netsnmp_arch_interface_container_load(ne
* xxx-rks: get descr by linking mem from /proc/pci and /proc/iomem
*/
+ /*
+ * get interface alias
+ */
+ _arch_interface_ifalias_get(entry);
/*
* use ioctls for some stuff
--
------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:
Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders