diff --git a/cpu/native/net/wpcap-service.c b/cpu/native/net/wpcap-service.c index 7b9789475..60afb62da 100644 --- a/cpu/native/net/wpcap-service.c +++ b/cpu/native/net/wpcap-service.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: wpcap-service.c,v 1.1 2007/04/01 20:39:38 oliverschmidt Exp $ + * @(#)$Id: wpcap-service.c,v 1.2 2007/04/01 21:06:30 oliverschmidt Exp $ */ #include "contiki-net.h" @@ -37,15 +37,15 @@ #define BUF ((struct uip_eth_hdr *)&uip_buf[0]) -static u8_t output(void); +u8_t wpcap_output(void); -SERVICE(wpcap_service, packet_service, { output }); +SERVICE(wpcap_service, packet_service, { wpcap_output }); PROCESS(wpcap_process, "WinPcap driver"); /*---------------------------------------------------------------------------*/ -static u8_t -output(void) +u8_t +wpcap_output(void) { uip_arp_out(); wpcap_send(); diff --git a/platform/netsim/Makefile.netsim b/platform/netsim/Makefile.netsim index b7f5d7f5e..6351678d0 100644 --- a/platform/netsim/Makefile.netsim +++ b/platform/netsim/Makefile.netsim @@ -9,13 +9,16 @@ CONTIKI_TARGET_DIRS = . dev apps net SENSORS = sensors.c beep.c button-sensor.c pir-sensor.c vib-sensor.c \ radio-sensor.c irq.c eeprom.c \ dummy-sensors.c leds.c leds-arch.c esb-sensors.c -NETSIM = ether.c ethernode.c ethernode-uip.c lpm.c \ - tapdev-service.c tapdev.c rs232.c flash.c \ +NETSIM = ether.c ethernode.c ethernode-uip.c lpm.c rs232.c flash.c \ node.c nodes.c sensor.c display.c random.c radio.c \ dlloader.c main.c netsim-init.c contiki-main.c symtab.c symbols.c tr1001.c tr1001-drv.c \ - ethernode-rime.c + ethernode-rime.c -CONTIKI_TARGET_SOURCEFILES = $(NETSIM) $(SENSORS) +ifeq ($(OS),Windows_NT) +CONTIKI_TARGET_SOURCEFILES = $(NETSIM) $(SENSORS) wpcap-service.c wpcap.c +else +CONTIKI_TARGET_SOURCEFILES = $(NETSIM) $(SENSORS) tapdev-service.c tapdev.c +endif CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES) @@ -29,6 +32,10 @@ include $(CONTIKI)/cpu/native/Makefile.native CFLAGS += `gtk-config --cflags` -DNETSIM=1 TARGET_LIBFILES = `gtk-config --libs` +ifeq ($(OS),Windows_NT) +TARGET_LIBFILES += /lib/w32api/libws2_32.a /lib/w32api/libiphlpapi.a +endif + ### Setup directory search path for source files CONTIKI_TARGET_DIRS_CONCAT = ${addprefix $(CONTIKI)/platform/$(TARGET)/, \ diff --git a/platform/netsim/contiki-main.c b/platform/netsim/contiki-main.c index ee55c8efc..d823430f7 100644 --- a/platform/netsim/contiki-main.c +++ b/platform/netsim/contiki-main.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: contiki-main.c,v 1.12 2007/03/29 22:24:47 adamdunkels Exp $ + * $Id: contiki-main.c,v 1.13 2007/04/01 21:05:17 oliverschmidt Exp $ */ #include "contiki.h" @@ -41,8 +41,11 @@ #include "net/rime.h" -#include "net/tapdev.h" +#ifdef __CYGWIN__ +#include "net/wpcap-service.h" +#else #include "net/tapdev-service.h" +#endif #include "net/ethernode-uip.h" #include "net/ethernode-rime.h" #include "net/ethernode.h" @@ -60,9 +63,15 @@ #include "dev/radio-sensor.h" #include "dev/leds.h" +#ifdef __CYGWIN__ +u8_t wpcap_output(void); +static struct uip_fw_netif extif = + {UIP_FW_NETIF(0,0,0,0, 0,0,0,0, wpcap_output)}; +#else u8_t tapdev_output(void); -static struct uip_fw_netif tapif = +static struct uip_fw_netif extif = {UIP_FW_NETIF(0,0,0,0, 0,0,0,0, tapdev_output)}; +#endif static struct uip_fw_netif meshif = {UIP_FW_NETIF(172,16,0,0, 255,255,0,0, uip_over_mesh_send)}; /*static struct uip_fw_netif ethernodeif = @@ -97,9 +106,13 @@ contiki_main(int flag) uip_over_mesh_init(0); if(flag == 1) { +#ifdef __CYGWIN__ + process_start(&wpcap_process, NULL); +#else process_start(&tapdev_process, NULL); +#endif uip_fw_register(&meshif); - uip_fw_default(&tapif); + uip_fw_default(&extif); printf("uip_hostaddr %02x%02x\n", uip_hostaddr.u16[0], uip_hostaddr.u16[1]); } else { uip_fw_default(&meshif); diff --git a/platform/netsim/net/ethernode-uip.c b/platform/netsim/net/ethernode-uip.c index 7dc6b9c5e..6f782e36e 100644 --- a/platform/netsim/net/ethernode-uip.c +++ b/platform/netsim/net/ethernode-uip.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: ethernode-uip.c,v 1.4 2007/03/27 21:47:18 oliverschmidt Exp $ + * $Id: ethernode-uip.c,v 1.5 2007/04/01 21:05:17 oliverschmidt Exp $ */ #include "contiki.h" @@ -39,7 +39,11 @@ #include "net/uip-fw.h" #include "net/hc.h" +#ifdef __CYGWIN__ +#include "net/wpcap.h" +#else #include "net/tapdev.h" +#endif #include "node-id.h" @@ -76,7 +80,11 @@ PROCESS_THREAD(ethernode_uip_process, ev, data) uip_len = hc_inflate(&uip_buf[UIP_LLH_LEN], uip_len); +#ifdef __CYGWIN__ + wpcap_send(); +#else tapdev_send(); +#endif /* if(uip_fw_forward() == UIP_FW_LOCAL)*/ { /* A frame was avaliable (and is now read into the uip_buf), so we process it. */