Subject: pkg/7799: ucd snmpd does not return mib-2.ip.ipAddrTable (+fix)
To: None <gnats-bugs@gnats.netbsd.org>
From: Zdenek Salvet <salvet@ics.muni.cz>
List: netbsd-bugs
Date: 06/17/1999 02:23:51
>Number:         7799
>Category:       pkg
>Synopsis:       ucd snmpd does not return mib-2.ip.ipAddrTable
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager (NetBSD software packages system bug manager)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 17 02:20:00 1999
>Last-Modified:
>Originator:     Zdenek Salvet
>Organization:
Masaryk University, Brno, Czech Republic
>Release:        1.3
>Environment:
NetBSD/i386 1.3
>Description:
1)   ucd snmpd does not return mib-2.ip.ipAddrTable, because
Interface_Scan_Next routine is left unimplemented in USE_SYSCTL_IFLIST case;
2)   #ifdef netbsd1 is used throughout the code, one should use
     LOWER_OPSYS=netbsd1 to have it defined

>How-To-Repeat:
try to fetch ipAddrTable with some SNMP client

>Fix:
 2) add LOWER_OPSYS=netbsd1 to pkgsrc/net/ucd-snmp/Makefile (?)
 1) being inexperienced with interface sysctl result format, I have choosen
    to switch to kvm method and fixed it to work with 1.3 (untried with 1.4)
 
diff -ru work/ucd-snmp-3.6.1/agent/mibgroup/mibII/interfaces.c work.new/ucd-snmp-3.6.1/agent/mibgroup/mibII/interfaces.c
--- work/ucd-snmp-3.6.1/agent/mibgroup/mibII/interfaces.c	Tue Mar 16 00:46:12 1999
+++ work.new/ucd-snmp-3.6.1/agent/mibgroup/mibII/interfaces.c	Thu Jun 17 10:21:06 1999
@@ -114,7 +114,7 @@
 
 #if HAVE_SYS_SYSCTL_H
 #include <sys/sysctl.h>
-# if defined(CTL_NET) && !defined(freebsd2)
+# if defined(CTL_NET) && !defined(freebsd2) && !defined(netbsd1)
 #  ifdef PF_ROUTE
 #   ifdef NET_RT_IFLIST
 #    define USE_SYSCTL_IFLIST
@@ -1462,16 +1462,31 @@
 	    cp = strchr(saveName, '\0');
 	    string_append_int (cp, ifnet.if_unit);
 #endif
-	    if (1 || strcmp(saveName,"lo0") != 0) {  /* XXX */
+	    if (1) {  /* XXX */
 		/*
 		 *  Try to find an address for this interface
 		 */
 
 		auto_nlist(IFADDR_SYMBOL, (char *)&ia, sizeof(ia));
+#ifdef netbsd1
+           ia=(struct in_ifaddr *)ifnet.if_addrlist.tqh_first; 
+#endif
 		while (ia) {
 		    klookup((unsigned long)ia ,  (char *)&in_ifaddr, sizeof(in_ifaddr));
+#ifdef netbsd1
+#define CP(x) ((char *)(x))
+{ char *cp; struct sockaddr * sa;
+                          cp = (CP(in_ifaddr.ia_ifa.ifa_addr) - CP(ia)) +
+                                CP(&in_ifaddr); sa = (struct sockaddr *)cp;
+if (sa->sa_family==AF_INET) 
+#endif
 		    if (in_ifaddr.ia_ifp == ifnetaddr) break;
+}
+#ifdef netbsd1
+                    ia=(struct in_ifaddr *)in_ifaddr.ia_ifa.ifa_list.tqe_next;
+#else
 		    ia = in_ifaddr.ia_next;
+#endif
 		}
 
 #if !defined(netbsd1) && !defined(freebsd2) && !defined(openbsd2) && !defined(STRUCT_IFNET_HAS_IF_ADDRLIST)
diff -ru work/ucd-snmp-3.6.1/agent/mibgroup/mibII/ip.c work.new/ucd-snmp-3.6.1/agent/mibgroup/mibII/ip.c
--- work/ucd-snmp-3.6.1/agent/mibgroup/mibII/ip.c	Fri Mar 12 18:15:05 1999
+++ work.new/ucd-snmp-3.6.1/agent/mibgroup/mibII/ip.c	Thu Jun 17 10:08:11 1999
@@ -728,7 +728,11 @@
 #ifdef linux
             return (u_char *)&((struct sockaddr_in *)&lowin_ifnet.ia_subnetmask)->sin_addr.s_addr;
 #else
+#ifdef netbsd1
+	    long_return = lowin_ifaddr.ia_subnetmask;
+#else
 	    long_return = ntohl(lowin_ifaddr.ia_subnetmask);
+#endif
 	    return(u_char *) &long_return;
 #endif
 #endif
@@ -737,7 +741,11 @@
 #if defined(linux) || defined(sunV3)
 	    long_return = ntohl(((struct sockaddr_in *) &lowin_ifnet.ifu_broadaddr)->sin_addr.s_addr) & 1;
 #else
+#ifdef netbsd1
+          long_return = (((struct sockaddr_in *) &lowin_ifaddr.ia_broadaddr)->sin_addr.s_addr) & 1;
+#else
           long_return = ntohl(((struct sockaddr_in *) &lowin_ifaddr.ia_broadaddr)->sin_addr.s_addr) & 1;
+#endif
 #endif
 	    return(u_char *) &long_return;	   
 	case IPADREASMMAX:

>Audit-Trail:
>Unformatted: