From 44273aed6fbecadca0b9cd60fde5551763855e1d Mon Sep 17 00:00:00 2001 From: goldsimon Date: Wed, 17 Feb 2010 16:55:36 +0000 Subject: [PATCH] minor: fixed source code layout --- ports/unix/netif/delif.c | 37 ++++++++++++++++------------------ ports/unix/netif/pcapif.c | 42 ++++++++++++++++++++++----------------- ports/unix/netif/tapif.c | 28 ++++++++++++-------------- 3 files changed, 54 insertions(+), 53 deletions(-) diff --git a/ports/unix/netif/delif.c b/ports/unix/netif/delif.c index eef3d57..6371e84 100644 --- a/ports/unix/netif/delif.c +++ b/ports/unix/netif/delif.c @@ -87,16 +87,16 @@ delif_input_timeout(void *arg) dp = input_list; while (dp != NULL) { now = sys_now(); - + if (dp->time <= now) { delif->input(dp->p, netif); if (dp->next != NULL) { - if (dp->next->time > now) { - timeout = dp->next->time - now; - } else { - timeout = 0; - } - LWIP_DEBUGF(DELIF_DEBUG, ("delif_output_timeout: timeout %u.\n", timeout)); + if (dp->next->time > now) { + timeout = dp->next->time - now; + } else { + timeout = 0; + } + LWIP_DEBUGF(DELIF_DEBUG, ("delif_output_timeout: timeout %u.\n", timeout)); } input_list = dp->next; @@ -122,26 +122,26 @@ delif_output_timeout(void *arg) netif = arg; delif = netif->state; - + /* Check if there is anything on the output list. */ dp = output_list; while (dp != NULL) { now = sys_now(); if (dp->time <= now) { LWIP_DEBUGF(DELIF_DEBUG, ("delif_output_timeout: now %u dp->time %u\n", - now, dp->time)); + now, dp->time)); delif->netif->output(delif->netif, dp->p, dp->ipaddr); if (dp->next != NULL) { - if (dp->next->time > now) { - timeout = dp->next->time - now; - } else { - timeout = 0; - } - LWIP_DEBUGF(DELIF_DEBUG, ("delif_output_timeout: timeout %u.\n", timeout)); - + if (dp->next->time > now) { + timeout = dp->next->time - now; + } else { + timeout = 0; + } + LWIP_DEBUGF(DELIF_DEBUG, ("delif_output_timeout: timeout %u.\n", timeout)); + } pbuf_free(dp->p); - + output_list = dp->next; free(dp); dp = output_list; @@ -321,6 +321,3 @@ delif_init_thread(struct netif *netif) } /*-----------------------------------------------------------------------------------*/ - - - diff --git a/ports/unix/netif/pcapif.c b/ports/unix/netif/pcapif.c index f722f88..bf3710c 100644 --- a/ports/unix/netif/pcapif.c +++ b/ports/unix/netif/pcapif.c @@ -79,8 +79,7 @@ static char errbuf[PCAP_ERRBUF_SIZE]; /*-----------------------------------------------------------------------------------*/ static err_t -pcapif_output(struct netif *netif, struct pbuf *p, - ip_addr_t *ipaddr) +pcapif_output(struct netif *netif, struct pbuf *p, ip_addr_t *ipaddr) { return ERR_OK; } @@ -107,15 +106,15 @@ timeout(void *arg) if (p != NULL) { /* We iterate over the pbuf chain until we have read the entire - packet into the pbuf. */ + packet into the pbuf. */ bufptr = (u_char *)pcapif->pkt; for(q = p; q != NULL; q = q->next) { - /* Read enough bytes to fill this pbuf in the chain. The - available data in the pbuf is given by the q->len - variable. */ - /* read data into(q->payload, q->len); */ - bcopy(bufptr, q->payload, q->len); - bufptr += q->len; + /* Read enough bytes to fill this pbuf in the chain. The + available data in the pbuf is given by the q->len + variable. */ + /* read data into(q->payload, q->len); */ + bcopy(bufptr, q->payload, q->len); + bufptr += q->len; } #if defined(LWIP_DEBUG) && defined(LWIP_TCPDUMP) @@ -124,17 +123,24 @@ timeout(void *arg) ethhdr = p->payload; switch (htons(ethhdr->type)) { + /* IP or ARP packet? */ case ETHTYPE_IP: - etharp_ip_input(netif, p); - pbuf_header(p, -14); - netif->input(p, netif); - break; case ETHTYPE_ARP: - etharp_arp_input(netif, pcapif->ethaddr, p); - break; - default: - pbuf_free(p); - break; +#if PPPOE_SUPPORT + /* PPPoE packet? */ + case ETHTYPE_PPPOEDISC: + case ETHTYPE_PPPOE: +#endif /* PPPOE_SUPPORT */ + /* full packet send to tcpip_thread to process */ + if (netif->input(p, netif) != ERR_OK) { + LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n")); + pbuf_free(p); + p = NULL; + } + break; + default: + pbuf_free(p); + break; } } } else { diff --git a/ports/unix/netif/tapif.c b/ports/unix/netif/tapif.c index ffd048c..556586b 100644 --- a/ports/unix/netif/tapif.c +++ b/ports/unix/netif/tapif.c @@ -289,22 +289,20 @@ tapif_input(struct netif *netif) ethhdr = p->payload; switch(htons(ethhdr->type)) { + /* IP or ARP packet? */ case ETHTYPE_IP: - LWIP_DEBUGF(TAPIF_DEBUG, ("tapif_input: IP packet\n")); -#if 0 -/* CSi disabled ARP table update on ingress IP packets. - This seems to work but needs thorough testing. */ - etharp_ip_input(netif, p); -#endif - pbuf_header(p, -14); -#if defined(LWIP_DEBUG) && defined(LWIP_TCPDUMP) - tcpdump(p); -#endif /* LWIP_DEBUG && LWIP_TCPDUMP */ - netif->input(p, netif); - break; case ETHTYPE_ARP: - LWIP_DEBUGF(TAPIF_DEBUG, ("tapif_input: ARP packet\n")); - etharp_arp_input(netif, tapif->ethaddr, p); +#if PPPOE_SUPPORT + /* PPPoE packet? */ + case ETHTYPE_PPPOEDISC: + case ETHTYPE_PPPOE: +#endif /* PPPOE_SUPPORT */ + /* full packet send to tcpip_thread to process */ + if (netif->input(p, netif) != ERR_OK) { + LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n")); + pbuf_free(p); + p = NULL; + } break; default: pbuf_free(p); @@ -334,7 +332,7 @@ tapif_init(struct netif *netif) netif->name[1] = IFNAME1; netif->output = etharp_output; netif->linkoutput = low_level_output; - netif->mtu = 1500; + netif->mtu = 1500; /* hardware address length */ netif->hwaddr_len = 6;