From 85fef90c94037945564e4a0477270108f230cbd4 Mon Sep 17 00:00:00 2001 From: fbernon Date: Fri, 31 Aug 2007 10:14:09 +0000 Subject: [PATCH] Add enum snmp_ifType in snmp.h, and use it in network interfaces for NETIF_INIT_SNMP --- src/include/lwip/netif.h | 4 ++-- src/include/lwip/snmp.h | 38 ++++++++++++++++++++++++++++++++++++++ src/netif/ethernetif.c | 5 ++--- src/netif/loopif.c | 4 ++-- src/netif/slipif.c | 4 ++-- 5 files changed, 46 insertions(+), 9 deletions(-) diff --git a/src/include/lwip/netif.h b/src/include/lwip/netif.h index 693692a2..d320e7c5 100644 --- a/src/include/lwip/netif.h +++ b/src/include/lwip/netif.h @@ -140,7 +140,7 @@ struct netif { /** number of this interface */ u8_t num; #if LWIP_SNMP - /** link type (ifType values per RFC1213) */ + /** link type (from "snmp_ifType" enum from snmp.h) */ u8_t link_type; /** (estimate) link speed */ u32_t link_speed; @@ -167,7 +167,7 @@ struct netif { #if LWIP_SNMP #define NETIF_INIT_SNMP(netif, type, speed) \ - /* ifType ethernetCsmacd(6) @see RFC1213 */ \ + /* use "snmp_ifType" enum from snmp.h for "type", snmp_ifType_ethernet_csmacd by example */ \ netif->link_type = type; \ /* your link speed here */ \ netif->link_speed = speed; \ diff --git a/src/include/lwip/snmp.h b/src/include/lwip/snmp.h index b75e8e2c..9cf8fcba 100644 --- a/src/include/lwip/snmp.h +++ b/src/include/lwip/snmp.h @@ -41,6 +41,44 @@ extern "C" { #endif +/** + * @see RFC1213, "MIB-II, 6. Definitions" + */ +enum snmp_ifType { + snmp_ifType_other=1, /* none of the following */ + snmp_ifType_regular1822, + snmp_ifType_hdh1822, + snmp_ifType_ddn_x25, + snmp_ifType_rfc877_x25, + snmp_ifType_ethernet_csmacd, + snmp_ifType_iso88023_csmacd, + snmp_ifType_iso88024_tokenBus, + snmp_ifType_iso88025_tokenRing, + snmp_ifType_iso88026_man, + snmp_ifType_starLan, + snmp_ifType_proteon_10Mbit, + snmp_ifType_proteon_80Mbit, + snmp_ifType_hyperchannel, + snmp_ifType_fddi, + snmp_ifType_lapb, + snmp_ifType_sdlc, + snmp_ifType_ds1, /* T-1 */ + snmp_ifType_e1, /* european equiv. of T-1 */ + snmp_ifType_basicISDN, + snmp_ifType_primaryISDN, /* proprietary serial */ + snmp_ifType_propPointToPointSerial, + snmp_ifType_ppp, + snmp_ifType_softwareLoopback, + snmp_ifType_eon, /* CLNP over IP [11] */ + snmp_ifType_ethernet_3Mbit, + snmp_ifType_nsip, /* XNS over IP */ + snmp_ifType_slip, /* generic SLIP */ + snmp_ifType_ultra, /* ULTRA technologies */ + snmp_ifType_ds3, /* T-3 */ + snmp_ifType_sip, /* SMDS */ + snmp_ifType_frame_relay +}; + /* SNMP support available? */ #if defined(LWIP_SNMP) && (LWIP_SNMP > 0) diff --git a/src/netif/ethernetif.c b/src/netif/ethernetif.c index 8104de5b..b69bc4f6 100644 --- a/src/netif/ethernetif.c +++ b/src/netif/ethernetif.c @@ -49,7 +49,7 @@ #include "lwip/pbuf.h" #include "lwip/sys.h" #include - +#include #include "netif/etharp.h" #include "netif/ppp_oe.h" @@ -289,8 +289,7 @@ ethernetif_init(struct netif *netif) #endif /* LWIP_NETIF_HOSTNAME */ /* initialize the snmp variables and counters inside the struct netif */ - /* ifType ethernetCsmacd(6) @see RFC1213 */ - NETIF_INIT_SNMP(netif, 6, ???); + NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, ???); netif->state = ethernetif; netif->name[0] = IFNAME0; diff --git a/src/netif/loopif.c b/src/netif/loopif.c index f9bf6a35..adffdcf3 100644 --- a/src/netif/loopif.c +++ b/src/netif/loopif.c @@ -41,6 +41,7 @@ #include "netif/loopif.h" #include "lwip/pbuf.h" +#include "lwip/snmp.h" #include @@ -203,10 +204,9 @@ loopif_init(struct netif *netif) #endif /* LWIP_LOOPIF_MULTITHREADING */ /* initialize the snmp variables and counters inside the struct netif - * ifType: softwareLoopback(24) @see RFC1213 * ifSpeed: no assumption can be made! */ - NETIF_INIT_SNMP(netif, 24, 0); + NETIF_INIT_SNMP(netif, snmp_ifType_softwareLoopback, 0); netif->name[0] = 'l'; netif->name[1] = 'o'; diff --git a/src/netif/slipif.c b/src/netif/slipif.c index a1d96100..eadb3c31 100644 --- a/src/netif/slipif.c +++ b/src/netif/slipif.c @@ -48,6 +48,7 @@ #include "lwip/pbuf.h" #include "lwip/sys.h" #include "lwip/stats.h" +#include "lwip/snmp.h" #include "lwip/sio.h" #define SLIP_END 0300 @@ -260,11 +261,10 @@ slipif_init(struct netif *netif) } /* initialize the snmp variables and counters inside the struct netif - * ifType: we're using propPointToPointSerial(22) @see RFC1213 * ifSpeed: no assumption can be made without knowing more about the * serial line! */ - NETIF_INIT_SNMP(netif, 22, 0); + NETIF_INIT_SNMP(netif, snmp_ifType_slip, 0); /* Create a thread to poll the serial line. */ sys_thread_new(slipif_loop, netif, SLIPIF_THREAD_PRIO);