Added Cygwin networking support using WinPcap.

This commit is contained in:
oliverschmidt 2007-04-01 21:05:17 +00:00
parent 01b9b31952
commit 5bceecfbb0
4 changed files with 42 additions and 14 deletions

View file

@ -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();

View file

@ -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)/, \

View file

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $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);

View file

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $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. */