diff --git a/cpu/native/net/wpcap-drv.c b/cpu/native/net/wpcap-drv.c index 5162e191b..670b9e61d 100644 --- a/cpu/native/net/wpcap-drv.c +++ b/cpu/native/net/wpcap-drv.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: wpcap-drv.c,v 1.4 2008/06/23 19:53:16 adamdunkels Exp $ + * @(#)$Id: wpcap-drv.c,v 1.5 2009/08/08 19:51:25 dak664 Exp $ */ #include "contiki-net.h" @@ -43,14 +43,16 @@ PROCESS(wpcap_process, "WinPcap driver"); /*---------------------------------------------------------------------------*/ +#if !UIP_CONF_IPV6 u8_t wpcap_output(void) { - uip_arp_out(); - wpcap_send(); - - return 0; + uip_arp_out(); + wpcap_send(); + + return 0; } +#endif /*---------------------------------------------------------------------------*/ static void pollhandler(void) @@ -61,7 +63,7 @@ pollhandler(void) if(uip_len > 0) { #if UIP_CONF_IPV6 if(BUF->type == htons(UIP_ETHTYPE_IPV6)) { - uip_neighbor_add(&IPBUF->srcipaddr, &BUF->src); +// uip_neighbor_add(&IPBUF->srcipaddr, &BUF->src); tcpip_input(); } else #endif /* UIP_CONF_IPV6 */ @@ -69,13 +71,17 @@ pollhandler(void) uip_len -= sizeof(struct uip_eth_hdr); tcpip_input(); } else if(BUF->type == htons(UIP_ETHTYPE_ARP)) { - uip_arp_arpin(); +#if !UIP_CONF_IPV6 //math + 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) { - wpcap_send(); - } + should be sent out on the network, the global variable + uip_len is set to a value > 0. */ + if(uip_len > 0) { + wpcap_send(); + } +#endif +// } else { +// uip_len = 0; } } } @@ -88,7 +94,11 @@ PROCESS_THREAD(wpcap_process, ev, data) wpcap_init(); +#if !UIP_CONF_IPV6 tcpip_set_outputfunc(wpcap_output); +#else + tcpip_set_outputfunc(wpcap_send); +#endif process_poll(&wpcap_process); diff --git a/cpu/native/net/wpcap.c b/cpu/native/net/wpcap.c index f847d3336..05fbbac24 100644 --- a/cpu/native/net/wpcap.c +++ b/cpu/native/net/wpcap.c @@ -30,7 +30,7 @@ * * Author: Oliver Schmidt * - * $Id: wpcap.c,v 1.14 2008/06/23 19:52:44 adamdunkels Exp $ + * $Id: wpcap.c,v 1.15 2009/08/08 19:51:25 dak664 Exp $ */ #define WIN32_LEAN_AND_MEAN @@ -60,6 +60,11 @@ __attribute__((dllimport)) extern char **__argv[]; #endif /* __CYGWIN__ */ +#if UIP_CONF_IPV6 /*TODO: put this in the right place */ +//CCIF struct uip_eth_addr uip_ethaddr={{0xff,0xff,0xff,0xff,0xff,0xff}}; +struct uip_eth_addr uip_ethaddr={{0xff,0xff,0xff,0xff,0xff,0xff}}; +#endif /* #if UIP_CONF_IPV6 */ + struct pcap; struct pcap_if { @@ -92,6 +97,7 @@ static int (* pcap_next_ex)(struct pcap *, struct pcap_pkthdr **, unsigned char static int (* pcap_sendpacket)(struct pcap *, unsigned char *, int); #define BUF ((struct uip_eth_hdr *)&uip_buf[0]) +#define IPBUF ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN]) /*---------------------------------------------------------------------------*/ static void @@ -187,8 +193,9 @@ set_ethaddr(struct in_addr addr) adapters->PhysicalAddress[2], adapters->PhysicalAddress[3], adapters->PhysicalAddress[4], adapters->PhysicalAddress[5]); log_message("set_ethaddr: ethernetaddr: ", buffer); - +#if !UIP_CONF_IPV6 uip_setethaddr((*(struct uip_eth_addr *)adapters->PhysicalAddress)); +#endif break; } } @@ -255,6 +262,37 @@ wpcap_poll(void) return (u16_t)packet_header->caplen; } /*---------------------------------------------------------------------------*/ +#if UIP_CONF_IPV6 +u8_t +wpcap_send(uip_lladdr_t *lladdr) +{ + if(lladdr == NULL) { + /* the dest must be multicast */ + (&BUF->dest)->addr[0] = 0x33; + (&BUF->dest)->addr[1] = 0x33; +// (&BUF->dest)->addr[2] = IPBUF->destipaddr.u8[12]; //destipaddr is zero +// (&BUF->dest)->addr[3] = IPBUF->destipaddr.u8[13]; +// (&BUF->dest)->addr[4] = IPBUF->destipaddr.u8[14]; +// (&BUF->dest)->addr[5] = IPBUF->destipaddr.u8[15]; + (&BUF->dest)->addr[2] = uip_ethaddr.addr[2]; + (&BUF->dest)->addr[3] = uip_ethaddr.addr[3]; + (&BUF->dest)->addr[4] = uip_ethaddr.addr[4]; + (&BUF->dest)->addr[5] = uip_ethaddr.addr[5]; + } else { + memcpy(&BUF->dest, lladdr, UIP_LLADDR_LEN); + } + if ((&BUF->src)->addr[0]) { //Linux tap6 does this always + memcpy(&BUF->src, &uip_lladdr, UIP_LLADDR_LEN); + } +// BUF->type = HTONS(UIP_ETHTYPE_IPV6); //math tmp //This causes a silent exit + + uip_len += sizeof(struct uip_eth_hdr); + if(pcap_sendpacket(pcap, uip_buf, uip_len) == -1) { + error_exit("error on send\n"); + } +return 0; +} +#else /* UIP_CONF_IPV6 */ void wpcap_send(void) { @@ -265,10 +303,11 @@ wpcap_send(void) printf("Send\n"); }*/ - if(pcap_sendpacket(pcap, uip_buf, uip_len) == -1) { + if(pcap_sendpacket(pcap, uip_buf, uip_len) == -1) { error_exit("error on send\n"); } } +#endif /* UIP_CONF_IPV6 */ /*---------------------------------------------------------------------------*/ void wpcap_exit(void) diff --git a/cpu/native/net/wpcap.h b/cpu/native/net/wpcap.h index 67099bd7d..69b96a369 100644 --- a/cpu/native/net/wpcap.h +++ b/cpu/native/net/wpcap.h @@ -30,7 +30,7 @@ * * Author: Oliver Schmidt * - * $Id: wpcap.h,v 1.2 2007/05/20 21:32:24 oliverschmidt Exp $ + * $Id: wpcap.h,v 1.3 2009/08/08 19:51:25 dak664 Exp $ */ #ifndef __WPCAP_H__ @@ -38,7 +38,11 @@ void wpcap_init(void); u16_t wpcap_poll(void); +#if UIP_CONF_IPV6 +u8_t wpcap_send(uip_lladdr_t *lladdr); +#else void wpcap_send(void); +#endif void wpcap_exit(void); #endif /* __WPCAP_H__ */