comparison packages/net/snmp/agent/current/src/mibgroup/mibII/ip.c @ 775:7b1ce5baf938

Imported from trunk into 2.0 branch: * include/mibgroup/mibII/itf_helpers.h: * src/mibgroup/mibII/helpers.c: (New) Functions for finding the interface structure for Free and open BSD. * src/mibgroup/mibII/interfaces.c: Use the helper functions and other changes needed for the FreeBSD stack. * src/mibgroup/mibII/ip.c: Ditto * src/mibgroup/mibII/udp.c: Ditto * src/mibgroup/mibII/tcp.c: Ditto * src/mibgroup/mibII/dot3.c: Ditto * cdl/snmpagent.cdl: Removed the requirement for the OpenBSD stack. * doc/snmp.sgml: Removed the documented requirement for the OpenBSD stack.
author asl
date Tue, 25 Mar 2003 16:56:41 +0000
parents d2c90368aeef
children
comparison
equal deleted inserted replaced
774:bd672be526a4 775:7b1ce5baf938
52 //####UCDSNMPCOPYRIGHTEND#### 52 //####UCDSNMPCOPYRIGHTEND####
53 //========================================================================== 53 //==========================================================================
54 //#####DESCRIPTIONBEGIN#### 54 //#####DESCRIPTIONBEGIN####
55 // 55 //
56 // Author(s): hmt 56 // Author(s): hmt
57 // Contributors: hmt 57 // Contributors: hmt, Andrew Lunn
58 // Date: 2000-05-30 58 // Date: 2000-05-30
59 // Purpose: Port of UCD-SNMP distribution to eCos. 59 // Purpose: Port of UCD-SNMP distribution to eCos.
60 // Description: 60 // Description:
61 // 61 //
62 // 62 //
90 CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 90 CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
91 *********************************************************************/ 91 *********************************************************************/
92 /* This file was generated by mib2c and is intended for use as a mib module 92 /* This file was generated by mib2c and is intended for use as a mib module
93 for the ucd-snmp snmpd agent. */ 93 for the ucd-snmp snmpd agent. */
94 94
95 #include <sys/param.h>
96 #include <sys/param.h>
97 #include <sys/socket.h>
98 #include <sys/time.h>
99 #include <net/if.h>
100 #ifdef CYGPKG_NET_FREEBSD_STACK
101 #include <net/if_var.h>
102 #endif
103 #include <netinet/in.h>
104 #include <netinet/if_ether.h>
105 #include <net/if_arp.h>
106 #include <netinet/in_var.h>
107 #include <netinet/ip_var.h>
95 108
96 /* This should always be included first before anything else */ 109 /* This should always be included first before anything else */
97 #include <config.h> 110 #include <config.h>
98
99 111
100 /* minimal include directives */ 112 /* minimal include directives */
101 #include "mibincl.h" 113 #include "mibincl.h"
102 #include "mibgroup/util_funcs.h" 114 #include "mibgroup/util_funcs.h"
103 #include "mibgroup/mibII/ip.h" 115 #include "mibgroup/mibII/ip.h"
104 116
105 #define _KERNEL 1 117 #include <cyg/io/eth/eth_drv.h>
106
107 #include <netinet/in_var.h>
108 #include <netinet/ip_var.h>
109 118
110 extern struct in_ifaddrhead in_ifaddr; 119 extern struct in_ifaddrhead in_ifaddr;
111 extern struct ifnet_head ifnet;
112
113 #include <cyg/io/eth/eth_drv.h>
114 120
115 /* 121 /*
116 * ip_variables_oid: 122 * ip_variables_oid:
117 * this is the top level oid that we want to register under. This 123 * this is the top level oid that we want to register under. This
118 * is essentially a prefix, with the suffix appearing in the 124 * is essentially a prefix, with the suffix appearing in the
119 * variable below. 125 * variable below.
120 */ 126 */
121 127
122 128
123 oid ip_variables_oid[] = { 1,3,6,1,2,1,4 }; 129 oid ip_variables_oid[] = { 1,3,6,1,2,1,4 };
124
125 130
126 /* 131 /*
127 * variable4 ip_variables: 132 * variable4 ip_variables:
128 * this variable defines function callbacks and type return information 133 * this variable defines function callbacks and type return information
129 * for the ip mib section 134 * for the ip mib section
292 long_ret = ipstat.ips_badsum 297 long_ret = ipstat.ips_badsum
293 + ipstat.ips_badhlen 298 + ipstat.ips_badhlen
294 + ipstat.ips_badlen 299 + ipstat.ips_badlen
295 + ipstat.ips_badoptions 300 + ipstat.ips_badoptions
296 + ipstat.ips_badvers 301 + ipstat.ips_badvers
302 #ifdef CYGPKG_NET_OPENBSD_STACK
297 + ipstat.ips_badfrags 303 + ipstat.ips_badfrags
304 #endif
298 + ipstat.ips_toolong 305 + ipstat.ips_toolong
299 ; 306 ;
300 return (unsigned char *) &long_ret; 307 return (unsigned char *) &long_ret;
301 308
302 case IPINADDRERRORS: 309 case IPINADDRERRORS:
317 ipstat.ips_badsum 324 ipstat.ips_badsum
318 + ipstat.ips_badhlen 325 + ipstat.ips_badhlen
319 + ipstat.ips_badlen 326 + ipstat.ips_badlen
320 + ipstat.ips_badoptions 327 + ipstat.ips_badoptions
321 + ipstat.ips_badvers 328 + ipstat.ips_badvers
329 #ifdef CYGPKG_NET_OPENBSD_STACK
322 + ipstat.ips_badfrags 330 + ipstat.ips_badfrags
331 #endif
323 + ipstat.ips_toolong 332 + ipstat.ips_toolong
324 ) - 333 ) -
325 ipstat.ips_cantforward; 334 ipstat.ips_cantforward;
326 if ( 0 > long_ret ) 335 if ( 0 > long_ret )
327 long_ret = 0; 336 long_ret = 0;
415 int interface_count = 1; 424 int interface_count = 1;
416 425
417 /* fill in object part of name for current (less sizeof instance part) */ 426 /* fill in object part of name for current (less sizeof instance part) */
418 memcpy( (char *)current,(char *)vp->name, (int)vp->namelen * sizeof(oid)); 427 memcpy( (char *)current,(char *)vp->name, (int)vp->namelen * sizeof(oid));
419 428
420 for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) { 429 for (
430 #ifdef CYGPKG_NET_OPENBSD_STACK
431 ia = in_ifaddr.tqh_first; ia;
432 ia = ia->ia_list.tqe_next
433 #endif
434 #ifdef CYGPKG_NET_FREEBSD_STACK
435 ia = in_ifaddrhead.tqh_first; ia;
436 ia = ia->ia_link.tqe_next
437 #endif
438 ) {
421 cp = (u_char *)&(ia->ia_addr.sin_addr.s_addr); 439 cp = (u_char *)&(ia->ia_addr.sin_addr.s_addr);
422 440
423 op = current + 10; 441 op = current + 10;
424 *op++ = *cp++; 442 *op++ = *cp++;
425 *op++ = *cp++; 443 *op++ = *cp++;
542 register struct in_ifaddr *low_ia = NULL; 560 register struct in_ifaddr *low_ia = NULL;
543 561
544 /* fill in object part of name for current (less sizeof instance part) */ 562 /* fill in object part of name for current (less sizeof instance part) */
545 memcpy((char *)current, (char *)vp->name, (int)vp->namelen * sizeof(oid)); 563 memcpy((char *)current, (char *)vp->name, (int)vp->namelen * sizeof(oid));
546 564
547 for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) { 565 for (
566 #ifdef CYGPKG_NET_OPENBSD_STACK
567 ia = in_ifaddr.tqh_first; ia;
568 ia = ia->ia_list.tqe_next
569 #endif
570 #ifdef CYGPKG_NET_FREEBSD_STACK
571 ia = in_ifaddrhead.tqh_first; ia;
572 ia = ia->ia_link.tqe_next
573 #endif
574 ) {
548 // interface number 575 // interface number
549 current[10] = ia->ia_ifa.ifa_ifp->if_index; 576 current[10] = ia->ia_ifa.ifa_ifp->if_index;
550 // IP address 577 // IP address
551 cp = (u_char *)&(ia->ia_addr.sin_addr.s_addr); 578 cp = (u_char *)&(ia->ia_addr.sin_addr.s_addr);
552 op = current + 11; 579 op = current + 11;