Changed packet drivers from services to plain processes.
Now tcpip_output() is a function pointer that is supposed to be set via the macro tcpip_set_outputfunc(). Packet drivers do so on process startup. Thus if there are several packet drivers in a Contiki system the one started last is the one actually used. This behaviour is especially useful for the 'IP forwarding' "meta" packet driver.
This commit is contained in:
parent
42a952981b
commit
5f3296e943
21 changed files with 93 additions and 311 deletions
|
@ -39,7 +39,7 @@ THREADS = mt.c
|
|||
LIBS = memb.c timer.c list.c etimer.c energest.c rtimer.c
|
||||
CTK = ctk.c
|
||||
UIP = uip.c uiplib.c resolv.c tcpip.c psock.c hc.c uip-split.c \
|
||||
uip-fw.c uip-fw-service.c uipbuf.c uip_arp.c uiplib.c tcpdump.c \
|
||||
uip-fw.c uip-fw-drv.c uipbuf.c uip_arp.c uiplib.c tcpdump.c \
|
||||
uip-neighbor.c uip-udp-packet.c rawpacket-udp.c uip-over-mesh.c
|
||||
NET = $(UIP) uaodv.c uaodv-rt.c
|
||||
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: packet-service.h,v 1.1 2006/06/17 22:41:18 adamdunkels Exp $
|
||||
*/
|
||||
#ifndef __PACKET_SERVICE_H__
|
||||
#define __PACKET_SERVICE_H__
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
#define packet_service_name "Packet driver"
|
||||
|
||||
SERVICE_INTERFACE(packet_service, {
|
||||
u8_t (* output)(void);
|
||||
});
|
||||
|
||||
#endif /* __PACKET_SERVICE_H__ */
|
|
@ -30,13 +30,11 @@
|
|||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: tcpip.c,v 1.7 2007/05/20 00:04:18 oliverschmidt Exp $
|
||||
* $Id: tcpip.c,v 1.8 2007/05/20 21:29:39 oliverschmidt Exp $
|
||||
*/
|
||||
|
||||
#include "contiki-conf.h"
|
||||
#include "contiki-net.h"
|
||||
|
||||
#include "net/packet-service.h"
|
||||
#include "net/uip-split.h"
|
||||
|
||||
#include <string.h>
|
||||
|
@ -66,6 +64,8 @@ enum {
|
|||
PACKET_INPUT
|
||||
};
|
||||
|
||||
u8_t (* tcpip_output)(void); /* Called on IP packet output. */
|
||||
|
||||
unsigned char tcpip_do_forwarding; /* Forwarding enabled. */
|
||||
unsigned char tcpip_is_forwarding; /* Forwarding right now? */
|
||||
|
||||
|
@ -103,12 +103,6 @@ packet_input(void)
|
|||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
tcpip_output(void)
|
||||
{
|
||||
SERVICE_CALL(packet_service, output());
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
struct uip_conn *
|
||||
tcp_connect(uip_ipaddr_t *ripaddr, u16_t port, void *appstate)
|
||||
{
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: tcpip.h,v 1.9 2007/05/20 00:04:18 oliverschmidt Exp $
|
||||
* $Id: tcpip.h,v 1.10 2007/05/20 21:29:40 oliverschmidt Exp $
|
||||
*/
|
||||
#ifndef __TCPIP_H__
|
||||
#define __TCPIP_H__
|
||||
|
@ -296,7 +296,10 @@ CCIF extern process_event_t tcpip_event;
|
|||
*/
|
||||
CCIF void tcpip_input(void);
|
||||
|
||||
void tcpip_output(void);
|
||||
/*
|
||||
* This function is called on IP packet output.
|
||||
*/
|
||||
extern u8_t (* tcpip_output)(void);
|
||||
|
||||
/*
|
||||
* Is forwarding generally enabled?
|
||||
|
@ -308,6 +311,7 @@ extern unsigned char tcpip_do_forwarding;
|
|||
*/
|
||||
extern unsigned char tcpip_is_forwarding;
|
||||
|
||||
#define tcpip_set_outputfunc(outputfunc) tcpip_output = (outputfunc)
|
||||
#define tcpip_set_forwarding(forwarding) tcpip_do_forwarding = (forwarding)
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -30,17 +30,11 @@
|
|||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: uip-fw-service.c,v 1.1 2006/06/17 22:41:19 adamdunkels Exp $
|
||||
* $Id: uip-fw-drv.c,v 1.1 2007/05/20 21:29:40 oliverschmidt Exp $
|
||||
*/
|
||||
|
||||
#include "net/packet-service.h"
|
||||
|
||||
#include "net/uip-fw.h"
|
||||
|
||||
SERVICE(uip_fw_service, packet_service, { uip_fw_output });
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
PROCESS(uip_fw_process, "IP forwarding");
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -50,13 +44,12 @@ PROCESS_THREAD(uip_fw_process, ev, data)
|
|||
|
||||
PROCESS_SET_FLAGS(PROCESS_NO_BROADCAST);
|
||||
|
||||
SERVICE_REGISTER(uip_fw_service);
|
||||
uip_fw_init();
|
||||
|
||||
PROCESS_WAIT_UNTIL(ev == PROCESS_EVENT_EXIT ||
|
||||
ev == PROCESS_EVENT_SERVICE_REMOVED);
|
||||
tcpip_set_outputfunc(uip_fw_output);
|
||||
|
||||
PROCESS_WAIT_UNTIL(ev == PROCESS_EVENT_EXIT);
|
||||
|
||||
SERVICE_REMOVE(uip_fw_service);
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -30,14 +30,14 @@
|
|||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: uip-fw-service.h,v 1.1 2006/06/17 22:41:19 adamdunkels Exp $
|
||||
* $Id: uip-fw-drv.h,v 1.1 2007/05/20 21:29:40 oliverschmidt Exp $
|
||||
*/
|
||||
#ifndef __UIP_FW_SERVICE_H__
|
||||
#define __UIP_FW_SERVICE_H__
|
||||
#ifndef __UIP_FW_DRV_H__
|
||||
#define __UIP_FW_DRV_H__
|
||||
|
||||
#include "contiki.h"
|
||||
#include "net/uip-fw.h"
|
||||
|
||||
PROCESS_NAME(uip_fw_process);
|
||||
|
||||
#endif /* __UIP_FW_SERVICE_H__ */
|
||||
#endif /* __UIP_FW_DRV_H__ */
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: tapdev-service.c,v 1.4 2007/03/27 21:26:25 oliverschmidt Exp $
|
||||
* @(#)$Id: tapdev-drv.c,v 1.1 2007/05/20 21:32:24 oliverschmidt Exp $
|
||||
*/
|
||||
|
||||
#include "contiki-net.h"
|
||||
|
@ -37,10 +37,6 @@
|
|||
|
||||
#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
|
||||
|
||||
u8_t tapdev_output(void);
|
||||
|
||||
SERVICE(tapdev_service, packet_service, { tapdev_output });
|
||||
|
||||
PROCESS(tapdev_process, "TAP driver");
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -67,6 +63,7 @@ pollhandler(void)
|
|||
} else
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
if(BUF->type == htons(UIP_ETHTYPE_IP)) {
|
||||
uip_len -= sizeof(struct uip_eth_hdr);
|
||||
tcpip_input();
|
||||
} else if(BUF->type == htons(UIP_ETHTYPE_ARP)) {
|
||||
uip_arp_arpin();
|
||||
|
@ -80,23 +77,27 @@ pollhandler(void)
|
|||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
exithandler(void)
|
||||
{
|
||||
tapdev_exit();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(tapdev_process, ev, data)
|
||||
{
|
||||
PROCESS_POLLHANDLER(pollhandler());
|
||||
PROCESS_EXITHANDLER(exithandler());
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
tapdev_init();
|
||||
|
||||
SERVICE_REGISTER(tapdev_service);
|
||||
|
||||
tcpip_set_outputfunc(tapdev_output);
|
||||
|
||||
process_poll(&tapdev_process);
|
||||
|
||||
while(1) {
|
||||
PROCESS_YIELD();
|
||||
if(ev == PROCESS_EVENT_POLL) {
|
||||
pollhandler();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PROCESS_WAIT_UNTIL(ev == PROCESS_EVENT_EXIT);
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -28,14 +28,16 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: tapdev-service.h,v 1.2 2007/03/27 20:49:09 oliverschmidt Exp $
|
||||
* @(#)$Id: tapdev-drv.h,v 1.1 2007/05/20 21:32:24 oliverschmidt Exp $
|
||||
*/
|
||||
|
||||
#ifndef __TAPDEV_SERVICE_H__
|
||||
#define __TAPDEV_SERVICE_H__
|
||||
#ifndef __TAPDEV_DRV_H__
|
||||
#define __TAPDEV_DRV_H__
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
PROCESS_NAME(tapdev_process);
|
||||
|
||||
#endif /* __TAPDEV_SERVICE_H__ */
|
||||
u8_t tapdev_output(void);
|
||||
|
||||
#endif /* __TAPDEV_DRV_H__ */
|
|
@ -1,103 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2005, Swedish Institute of Computer Science
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: tapdev-service.c,v 1.1 2007/03/31 18:49:40 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
#include "contiki-net.h"
|
||||
#include "tapdev.h"
|
||||
#include "net/uip-neighbor.h"
|
||||
|
||||
#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
|
||||
|
||||
u8_t tapdev_output(void);
|
||||
|
||||
SERVICE(tapdev_service, packet_service, { tapdev_output });
|
||||
|
||||
PROCESS(tapdev_process, "TAP driver");
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
u8_t
|
||||
tapdev_output(void)
|
||||
{
|
||||
uip_arp_out();
|
||||
tapdev_send();
|
||||
|
||||
uip_len -= UIP_LLH_LEN;
|
||||
return UIP_FW_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
pollhandler(void)
|
||||
{
|
||||
process_poll(&tapdev_process);
|
||||
uip_len = tapdev_poll();
|
||||
|
||||
if(uip_len > 0) {
|
||||
#if UIP_CONF_IPV6
|
||||
if(BUF->type == htons(UIP_ETHTYPE_IPV6)) {
|
||||
uip_neighbor_add(&IPBUF->srcipaddr, &BUF->src);
|
||||
tcpip_input();
|
||||
} else
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
if(BUF->type == htons(UIP_ETHTYPE_IP)) {
|
||||
tcpip_input();
|
||||
} else if(BUF->type == htons(UIP_ETHTYPE_ARP)) {
|
||||
uip_arp_arpin();
|
||||
/* 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. */
|
||||
if(uip_len > 0) {
|
||||
tapdev_send();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(tapdev_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
tapdev_init();
|
||||
|
||||
SERVICE_REGISTER(tapdev_service);
|
||||
|
||||
process_poll(&tapdev_process);
|
||||
|
||||
while(1) {
|
||||
PROCESS_YIELD();
|
||||
if(ev == PROCESS_EVENT_POLL) {
|
||||
pollhandler();
|
||||
}
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2005, Swedish Institute of Computer Science
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: tapdev-service.h,v 1.1 2007/03/31 18:49:40 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
#ifndef __TAPDEV_SERVICE_H__
|
||||
#define __TAPDEV_SERVICE_H__
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
PROCESS_NAME(tapdev_process);
|
||||
|
||||
#endif /* __TAPDEV_SERVICE_H__ */
|
|
@ -31,7 +31,7 @@
|
|||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: tapdev.c,v 1.1 2007/03/31 18:49:40 adamdunkels Exp $
|
||||
* $Id: tapdev.c,v 1.2 2007/05/20 21:32:24 oliverschmidt Exp $
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
|
@ -178,3 +178,8 @@ tapdev_send(void)
|
|||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
tapdev_exit(void)
|
||||
{
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: tapdev.h,v 1.1 2007/03/31 18:49:40 adamdunkels Exp $
|
||||
* $Id: tapdev.h,v 1.2 2007/05/20 21:32:24 oliverschmidt Exp $
|
||||
*/
|
||||
|
||||
#ifndef __TAPDEV_H__
|
||||
|
@ -40,5 +40,6 @@
|
|||
void tapdev_init(void);
|
||||
u16_t tapdev_poll(void);
|
||||
void tapdev_send(void);
|
||||
void tapdev_exit(void);
|
||||
|
||||
#endif /* __TAPDEV_H__ */
|
||||
|
|
|
@ -28,19 +28,17 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: wpcap-service.c,v 1.2 2007/04/01 21:06:30 oliverschmidt Exp $
|
||||
* @(#)$Id: wpcap-drv.c,v 1.1 2007/05/20 21:32:24 oliverschmidt Exp $
|
||||
*/
|
||||
|
||||
#include "contiki-net.h"
|
||||
#include "wpcap.h"
|
||||
#include "net/uip-neighbor.h"
|
||||
|
||||
#include "wpcap-drv.h"
|
||||
|
||||
#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
|
||||
|
||||
u8_t wpcap_output(void);
|
||||
|
||||
SERVICE(wpcap_service, packet_service, { wpcap_output });
|
||||
|
||||
PROCESS(wpcap_process, "WinPcap driver");
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -67,6 +65,7 @@ pollhandler(void)
|
|||
} else
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
if(BUF->type == htons(UIP_ETHTYPE_IP)) {
|
||||
uip_len -= sizeof(struct uip_eth_hdr);
|
||||
tcpip_input();
|
||||
} else if(BUF->type == htons(UIP_ETHTYPE_ARP)) {
|
||||
uip_arp_arpin();
|
||||
|
@ -80,23 +79,27 @@ pollhandler(void)
|
|||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
exithandler(void)
|
||||
{
|
||||
wpcap_exit();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(wpcap_process, ev, data)
|
||||
{
|
||||
PROCESS_POLLHANDLER(pollhandler());
|
||||
PROCESS_EXITHANDLER(exithandler());
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
wpcap_init();
|
||||
|
||||
SERVICE_REGISTER(wpcap_service);
|
||||
|
||||
tcpip_set_outputfunc(wpcap_output);
|
||||
|
||||
process_poll(&wpcap_process);
|
||||
|
||||
while(1) {
|
||||
PROCESS_YIELD();
|
||||
if(ev == PROCESS_EVENT_POLL) {
|
||||
pollhandler();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PROCESS_WAIT_UNTIL(ev == PROCESS_EVENT_EXIT);
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -28,14 +28,16 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: wpcap-service.h,v 1.1 2007/04/01 20:39:38 oliverschmidt Exp $
|
||||
* $Id: wpcap-drv.h,v 1.1 2007/05/20 21:32:25 oliverschmidt Exp $
|
||||
*/
|
||||
|
||||
#ifndef __WPCAP_SERVICE_H__
|
||||
#define __WPCAP_SERVICE_H__
|
||||
#ifndef __WPCAP_DRV_H__
|
||||
#define __WPCAP_DRV_H__
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
PROCESS_NAME(wpcap_process);
|
||||
|
||||
#endif /* __WPCAP_SERVICE_H__ */
|
||||
u8_t wpcap_output(void);
|
||||
|
||||
#endif /* __WPCAP_DRV_H__ */
|
|
@ -30,7 +30,7 @@
|
|||
*
|
||||
* Author: Oliver Schmidt <ol.sc@web.de>
|
||||
*
|
||||
* $Id: wpcap.c,v 1.6 2007/04/11 00:21:28 oliverschmidt Exp $
|
||||
* $Id: wpcap.c,v 1.7 2007/05/20 21:32:24 oliverschmidt Exp $
|
||||
*/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
@ -249,3 +249,8 @@ wpcap_send(void)
|
|||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
wpcap_exit(void)
|
||||
{
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
*
|
||||
* Author: Oliver Schmidt <ol.sc@web.de>
|
||||
*
|
||||
* $Id: wpcap.h,v 1.1 2007/04/01 20:39:38 oliverschmidt Exp $
|
||||
* $Id: wpcap.h,v 1.2 2007/05/20 21:32:24 oliverschmidt Exp $
|
||||
*/
|
||||
|
||||
#ifndef __WPCAP_H__
|
||||
|
@ -39,5 +39,6 @@
|
|||
void wpcap_init(void);
|
||||
u16_t wpcap_poll(void);
|
||||
void wpcap_send(void);
|
||||
void wpcap_exit(void);
|
||||
|
||||
#endif /* __WPCAP_H__ */
|
||||
|
|
|
@ -11,7 +11,7 @@ CONTIKI_TARGET_MAIN = ${addprefix $(OBJECTDIR)/,contiki-main.o}
|
|||
CTKGTK = $(CTK) ctk-gtksim.c ctk-draw.c ctk-gtksim-service.c libconio.c \
|
||||
ctk-gtksim-draw.c
|
||||
|
||||
CONTIKI_TARGET_SOURCEFILES = tapdev-service.c tapdev.c contiki-main.c \
|
||||
CONTIKI_TARGET_SOURCEFILES = tapdev-drv.c tapdev.c contiki-main.c \
|
||||
dlloader.c clock.c $(CTK) $(CTKGTK) cfs-posix.c
|
||||
|
||||
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: tapdev.c,v 1.2 2007/03/27 20:49:09 oliverschmidt Exp $
|
||||
* $Id: tapdev.c,v 1.3 2007/05/20 21:34:28 oliverschmidt Exp $
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
|
@ -157,3 +157,8 @@ tapdev_send(void)
|
|||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
tapdev_exit(void)
|
||||
{
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Adam Dunkels.
|
||||
* 4. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: tapdev.h,v 1.2 2007/03/27 20:49:09 oliverschmidt Exp $
|
||||
*/
|
||||
|
||||
#ifndef __TAPDEV_H__
|
||||
#define __TAPDEV_H__
|
||||
|
||||
void tapdev_init(void);
|
||||
u16_t tapdev_poll(void);
|
||||
void tapdev_send(void);
|
||||
|
||||
#endif /* __TAPDEV_H__ */
|
|
@ -9,9 +9,9 @@ CONTIKI_TARGET_SOURCEFILES = contiki-main.c dlloader.c clock.c \
|
|||
leds.c leds-arch.c cfs-posix.c
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
CONTIKI_TARGET_SOURCEFILES += wpcap-service.c wpcap.c
|
||||
CONTIKI_TARGET_SOURCEFILES += wpcap-drv.c wpcap.c
|
||||
else
|
||||
CONTIKI_TARGET_SOURCEFILES += tapdev-service.c tapdev.c
|
||||
CONTIKI_TARGET_SOURCEFILES += tapdev-drv.c tapdev.c
|
||||
endif
|
||||
|
||||
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
*
|
||||
* This file is part of the Contiki OS
|
||||
*
|
||||
* $Id: contiki-main.c,v 1.5 2007/05/19 21:18:10 oliverschmidt Exp $
|
||||
* $Id: contiki-main.c,v 1.6 2007/05/20 21:36:31 oliverschmidt Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -37,9 +37,9 @@
|
|||
|
||||
#include "net/uip.h"
|
||||
#ifdef __CYGWIN__
|
||||
#include "net/wpcap-service.h"
|
||||
#include "net/wpcap-drv.h"
|
||||
#else
|
||||
#include "net/tapdev-service.h"
|
||||
#include "net/tapdev-drv.h"
|
||||
#endif
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
|
|
Loading…
Reference in a new issue