Import of the contiki-2.x development code from the SICS internal CVS server
This commit is contained in:
commit
c9e808d638
671 changed files with 95332 additions and 0 deletions
63
platform/gtk/net/tapdev-service.c
Normal file
63
platform/gtk/net/tapdev-service.c
Normal file
|
@ -0,0 +1,63 @@
|
|||
|
||||
#include "net/packet-service.h"
|
||||
#include "tapdev.h"
|
||||
|
||||
#include "net/uip_arp.h"
|
||||
|
||||
static struct uip_eth_addr addr =
|
||||
{{0x08, 0x12, 0x23, 0x89, 0xa3, 0x94}};
|
||||
|
||||
SERVICE(tapdev_service, packet_service, { tapdev_send });
|
||||
|
||||
PROCESS(tapdev_process, "TAP driver");
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
|
||||
static void
|
||||
pollhandler(void)
|
||||
{
|
||||
/* tapdev_service_request_poll();*/
|
||||
process_poll(&tapdev_process);
|
||||
uip_len = tapdev_poll();
|
||||
|
||||
if(uip_len > 0) {
|
||||
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
|
||||
should be sent out on the network, the global variable
|
||||
uip_len is set to a value > 0. */
|
||||
if(uip_len > 0) {
|
||||
tapdev_do_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();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue