diff --git a/CHANGELOG b/CHANGELOG index cdf1579a..ce690d23 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,11 @@ HISTORY ++ New features: + 2007-05-18 Simon Goldschmidt + * netif.h, ethernetif.c, slipif.c, loopif.c: Added define + NETIF_INIT_SNMP(type, speed) to initialize per-netif snmp variables, added + initialization of those to slipif and loopif. + 2007-05-18 Simon Goldschmidt * opt.h, ip_frag.c, ip_frag.h, ip.c: Added option IP_FRAG_USES_STATIC_BUF (defaulting to off for now) that can be set to 0 to send fragmented diff --git a/src/include/lwip/netif.h b/src/include/lwip/netif.h index 562e9a1a..9cacb13a 100644 --- a/src/include/lwip/netif.h +++ b/src/include/lwip/netif.h @@ -150,6 +150,26 @@ struct netif { #endif /* LWIP_IGMP */ }; +#if LWIP_SNMP +#define NETIF_INIT_SNMP(type, speed) \ + /* ifType ethernetCsmacd(6) @see RFC1213 */ \ + netif->link_type = type; \ + /* your link speed here */ \ + netif->link_speed = speed; \ + netif->ts = 0; \ + netif->ifinoctets = 0; \ + netif->ifinucastpkts = 0; \ + netif->ifinnucastpkts = 0; \ + netif->ifindiscards = 0; \ + netif->ifoutoctets = 0; \ + netif->ifoutucastpkts = 0; \ + netif->ifoutnucastpkts = 0; \ + netif->ifoutdiscards = 0 +#else /* LWIP_SNMP */ +#define NETIF_INIT_SNMP(type, speed) +#endif /* LWIP_SNMP */ + + /** The list of network interfaces. */ extern struct netif *netif_list; /** The default network interface. */ diff --git a/src/netif/ethernetif.c b/src/netif/ethernetif.c index e044dcf2..ad1900c3 100644 --- a/src/netif/ethernetif.c +++ b/src/netif/ethernetif.c @@ -341,22 +341,9 @@ ethernetif_init(struct netif *netif) netif->hostname = "lwip"; #endif /* LWIP_NETIF_HOSTNAME */ -#if LWIP_SNMP /* initialize the snmp variables and counters inside the struct netif */ /* ifType ethernetCsmacd(6) @see RFC1213 */ - netif->link_type = 6; - /* your link speed here */ - netif->link_speed = ; - netif->ts = 0; - netif->ifinoctets = 0; - netif->ifinucastpkts = 0; - netif->ifinnucastpkts = 0; - netif->ifindiscards = 0; - netif->ifoutoctets = 0; - netif->ifoutucastpkts = 0; - netif->ifoutnucastpkts = 0; - netif->ifoutdiscards = 0; -#endif /* LWIP_SNMP */ + NETIF_INIT_SNMP(6, ???); netif->state = ethernetif; netif->name[0] = IFNAME0; diff --git a/src/netif/loopif.c b/src/netif/loopif.c index 982404a5..91777b50 100644 --- a/src/netif/loopif.c +++ b/src/netif/loopif.c @@ -196,6 +196,12 @@ loopif_init(struct netif *netif) netif->state = priv; #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(24, 0); + netif->name[0] = 'l'; netif->name[1] = 'o'; netif->output = loopif_output; diff --git a/src/netif/slipif.c b/src/netif/slipif.c index 9d39cfe0..9b3c43c3 100644 --- a/src/netif/slipif.c +++ b/src/netif/slipif.c @@ -253,6 +253,13 @@ slipif_init(struct netif *netif) return ERR_IF; } + /* 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(22, 0); + /* Create a thread to poll the serial line. */ sys_thread_new(slipif_loop, netif, SLIPIF_THREAD_PRIO); return ERR_OK;