diff --git a/platform/minimal-net/net/tapdev-service.c b/platform/minimal-net/net/tapdev-service.c index d08d638c7..b186185c6 100644 --- a/platform/minimal-net/net/tapdev-service.c +++ b/platform/minimal-net/net/tapdev-service.c @@ -28,28 +28,34 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: tapdev-service.c,v 1.2 2006/08/10 19:23:13 bg- Exp $ + * @(#)$Id: tapdev-service.c,v 1.3 2007/03/27 20:41:10 oliverschmidt Exp $ */ #include "contiki-net.h" #include "tapdev.h" #include "net/uip-neighbor.h" -/*static struct uip_eth_addr addr = - {{0x08, 0x12, 0x23, 0x89, 0xa3, 0x94}};*/ - #define BUF ((struct uip_eth_hdr *)&uip_buf[0]) -#define IPBUF ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN]) -SERVICE(tapdev_service, packet_service, { tapdev_send }); +static u8_t output(void); + +SERVICE(tapdev_service, packet_service, { output }); PROCESS(tapdev_process, "TAP driver"); +/*---------------------------------------------------------------------------*/ +static u8_t +output(void) +{ + uip_arp_out(); + tapdev_send(); + + return 0; +} /*---------------------------------------------------------------------------*/ static void pollhandler(void) { - /* tapdev_service_request_poll();*/ process_poll(&tapdev_process); uip_len = tapdev_poll(); @@ -61,13 +67,7 @@ pollhandler(void) } else #endif /* UIP_CONF_IPV6 */ if(BUF->type == htons(UIP_ETHTYPE_IP)) { - /* uip_arp_ipin(); - uip_len -= sizeof(struct uip_eth_hdr);*/ - /* uip_input();*/ tcpip_input(); - /* If the above function invocation resulted in data that - should be sent out on the network, the global variable - uip_len is set to a value > 0. */ } else if(BUF->type == htons(UIP_ETHTYPE_ARP)) { uip_arp_arpin(); /* If the above function invocation resulted in data that @@ -80,11 +80,8 @@ pollhandler(void) } } /*---------------------------------------------------------------------------*/ - PROCESS_THREAD(tapdev_process, ev, data) { - PROCESS_POLLHANDLER(pollhandler()); - PROCESS_BEGIN(); tapdev_init(); @@ -102,3 +99,4 @@ PROCESS_THREAD(tapdev_process, ev, data) PROCESS_END(); } +/*---------------------------------------------------------------------------*/ diff --git a/platform/minimal-net/net/tapdev-service.h b/platform/minimal-net/net/tapdev-service.h index 24f9d2427..309bc22ea 100644 --- a/platform/minimal-net/net/tapdev-service.h +++ b/platform/minimal-net/net/tapdev-service.h @@ -28,8 +28,9 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: tapdev-service.h,v 1.1 2006/06/17 22:41:30 adamdunkels Exp $ + * @(#)$Id: tapdev-service.h,v 1.2 2007/03/27 20:41:10 oliverschmidt Exp $ */ + #ifndef __TAPDEV_SERVICE_H__ #define __TAPDEV_SERVICE_H__ diff --git a/platform/minimal-net/net/tapdev.c b/platform/minimal-net/net/tapdev.c index dd1da894c..baf199452 100644 --- a/platform/minimal-net/net/tapdev.c +++ b/platform/minimal-net/net/tapdev.c @@ -31,10 +31,9 @@ * * Author: Adam Dunkels * - * $Id: tapdev.c,v 1.1 2006/06/17 22:41:30 adamdunkels Exp $ + * $Id: tapdev.c,v 1.2 2007/03/27 20:41:10 oliverschmidt Exp $ */ - #include #include #include @@ -47,7 +46,6 @@ #include #include - #ifdef linux #include #include @@ -57,9 +55,8 @@ #define DEVTAP "/dev/tap0" #endif /* linux */ -#include "tapdev.h" - #include "contiki-net.h" +#include "tapdev.h" #define DROP 0 @@ -73,37 +70,6 @@ static unsigned long lasttime; #define BUF ((struct uip_eth_hdr *)&uip_buf[0]) -static void do_send(void); -u8_t tapdev_send(void); - - -u16_t -tapdev_poll(void) -{ - fd_set fdset; - struct timeval tv; - int ret; - - tv.tv_sec = 0; - tv.tv_usec = 0; - - FD_ZERO(&fdset); - if(fd > 0) { - FD_SET(fd, &fdset); - } - - ret = select(fd + 1, &fdset, NULL, NULL, &tv); - - if(ret == 0) { - return 0; - } - ret = read(fd, uip_buf, UIP_BUFSIZE); - - if(ret == -1) { - perror("tapdev_poll: read"); - } - return ret; -} /*---------------------------------------------------------------------------*/ void tapdev_init(void) @@ -133,24 +99,48 @@ tapdev_init(void) printf("%s\n", buf); lasttime = 0; - - /* gdk_input_add(fd, GDK_INPUT_READ, - read_callback, NULL);*/ - } /*---------------------------------------------------------------------------*/ -static void -do_send(void) +u16_t +tapdev_poll(void) +{ + fd_set fdset; + struct timeval tv; + int ret; + + tv.tv_sec = 0; + tv.tv_usec = 0; + + FD_ZERO(&fdset); + if(fd > 0) { + FD_SET(fd, &fdset); + } + + ret = select(fd + 1, &fdset, NULL, NULL, &tv); + + if(ret == 0) { + return 0; + } + ret = read(fd, uip_buf, UIP_BUFSIZE); + + if(ret == -1) { + perror("tapdev_poll: read"); + } + return ret; +} +/*---------------------------------------------------------------------------*/ +void +tapdev_send(void) { int ret; if(fd <= 0) { return; } - /* printf("tapdev_send: sending %d bytes\n", size);*/ /* check_checksum(uip_buf, size);*/ + #if DROP drop++; if(drop % 8 == 7) { @@ -167,18 +157,3 @@ do_send(void) } } /*---------------------------------------------------------------------------*/ -u8_t -tapdev_send(void) -{ - uip_arp_out(); - - do_send(); - return 0; -} -/*---------------------------------------------------------------------------*/ -void -tapdev_do_send(void) -{ - do_send(); -} -/*---------------------------------------------------------------------------*/ diff --git a/platform/minimal-net/net/tapdev.h b/platform/minimal-net/net/tapdev.h index a7f491dc2..fb282e921 100644 --- a/platform/minimal-net/net/tapdev.h +++ b/platform/minimal-net/net/tapdev.h @@ -31,16 +31,14 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: tapdev.h,v 1.1 2006/06/17 22:41:30 adamdunkels Exp $ - * + * $Id: tapdev.h,v 1.2 2007/03/27 20:41:10 oliverschmidt Exp $ */ + #ifndef __TAPDEV_H__ #define __TAPDEV_H__ -#include "contiki-net.h" - void tapdev_init(void); -u8_t tapdev_send(void); u16_t tapdev_poll(void); -void tapdev_do_send(void); +void tapdev_send(void); + #endif /* __TAPDEV_H__ */ diff --git a/platform/minimal-net/net/wpcap-service.c b/platform/minimal-net/net/wpcap-service.c index 2ab966ef9..50236515b 100644 --- a/platform/minimal-net/net/wpcap-service.c +++ b/platform/minimal-net/net/wpcap-service.c @@ -28,9 +28,7 @@ * * This file is part of the Contiki operating system. * - * Author: Oliver Schmidt - * - * @(#)$Id: wpcap-service.c,v 1.1 2007/03/26 02:53:54 oliverschmidt Exp $ + * @(#)$Id: wpcap-service.c,v 1.2 2007/03/27 20:41:10 oliverschmidt Exp $ */ #include "contiki-net.h" @@ -70,9 +68,6 @@ pollhandler(void) #endif /* UIP_CONF_IPV6 */ if(BUF->type == htons(UIP_ETHTYPE_IP)) { tcpip_input(); - /* If the above function invocation resulted in data that - should be sent out on the network, the global variable - uip_len is set to a value > 0. */ } else if(BUF->type == htons(UIP_ETHTYPE_ARP)) { uip_arp_arpin(); /* If the above function invocation resulted in data that @@ -87,8 +82,6 @@ pollhandler(void) /*---------------------------------------------------------------------------*/ PROCESS_THREAD(wpcap_process, ev, data) { - PROCESS_POLLHANDLER(pollhandler()); - PROCESS_BEGIN(); wpcap_init(); diff --git a/platform/minimal-net/net/wpcap-service.h b/platform/minimal-net/net/wpcap-service.h index e4afeeee4..2cfa9ff46 100644 --- a/platform/minimal-net/net/wpcap-service.h +++ b/platform/minimal-net/net/wpcap-service.h @@ -28,9 +28,7 @@ * * This file is part of the Contiki operating system. * - * Author: Oliver Schmidt - * - * $Id: wpcap-service.h,v 1.1 2007/03/26 02:53:55 oliverschmidt Exp $ + * $Id: wpcap-service.h,v 1.2 2007/03/27 20:41:10 oliverschmidt Exp $ */ #ifndef __WPCAP_SERVICE_H__