Added network support to the Win32 platform.
Network I/O is done using the usual suspect - which is WinPcap. There's no need for the WinPcap Developer's Pack! An ordinary WinPcap install - as it is i.e. part of Ethereal - is sufficient. The code is still under development. But as I recently successfully opened HTML pages with the Contiki web browser I thought it might be the right time for an initial commit.
This commit is contained in:
parent
f601f3a0ac
commit
328071ff10
|
@ -87,6 +87,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "webserver.prg", "webserver.
|
||||||
{DD219C2D-D3F8-4C76-B2AA-376978722232} = {DD219C2D-D3F8-4C76-B2AA-376978722232}
|
{DD219C2D-D3F8-4C76-B2AA-376978722232} = {DD219C2D-D3F8-4C76-B2AA-376978722232}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wpcap.drv", "wpcap.drv.vcproj", "{39F3E492-1EE3-4904-8962-D482011AB375}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{DD219C2D-D3F8-4C76-B2AA-376978722232} = {DD219C2D-D3F8-4C76-B2AA-376978722232}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wpcap.dsc", "wpcap.dsc.vcproj", "{618101EC-0777-4FA6-B1B7-3B7C1981707B}"
|
||||||
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "www.dsc", "www.dsc.vcproj", "{76D7F9A9-9C9E-41C9-9BF8-DB305BCEEF71}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "www.dsc", "www.dsc.vcproj", "{76D7F9A9-9C9E-41C9-9BF8-DB305BCEEF71}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "www.prg", "www.prg.vcproj", "{2A1D67D7-7FAE-42D3-AC99-DB68A3570735}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "www.prg", "www.prg.vcproj", "{2A1D67D7-7FAE-42D3-AC99-DB68A3570735}"
|
||||||
|
@ -128,6 +135,10 @@ Global
|
||||||
{DAD91041-E4DE-42FE-9360-2237F03AB05C}.Debug|Win32.Build.0 = Debug|Win32
|
{DAD91041-E4DE-42FE-9360-2237F03AB05C}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{DAD91041-E4DE-42FE-9360-2237F03AB05C}.Release|Win32.ActiveCfg = Release|Win32
|
{DAD91041-E4DE-42FE-9360-2237F03AB05C}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{DAD91041-E4DE-42FE-9360-2237F03AB05C}.Release|Win32.Build.0 = Release|Win32
|
{DAD91041-E4DE-42FE-9360-2237F03AB05C}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{41417495-F60E-47CC-BDEF-4B9614E5DA08}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{41417495-F60E-47CC-BDEF-4B9614E5DA08}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{41417495-F60E-47CC-BDEF-4B9614E5DA08}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{41417495-F60E-47CC-BDEF-4B9614E5DA08}.Release|Win32.Build.0 = Release|Win32
|
||||||
{1EAF4006-F7AF-46E9-9390-43E0626CB4E5}.Debug|Win32.ActiveCfg = Debug|Win32
|
{1EAF4006-F7AF-46E9-9390-43E0626CB4E5}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{1EAF4006-F7AF-46E9-9390-43E0626CB4E5}.Debug|Win32.Build.0 = Debug|Win32
|
{1EAF4006-F7AF-46E9-9390-43E0626CB4E5}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{1EAF4006-F7AF-46E9-9390-43E0626CB4E5}.Release|Win32.ActiveCfg = Release|Win32
|
{1EAF4006-F7AF-46E9-9390-43E0626CB4E5}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
@ -196,18 +207,22 @@ Global
|
||||||
{C741203A-ADD3-4C4A-9BF1-82978105F057}.Debug|Win32.Build.0 = Debug|Win32
|
{C741203A-ADD3-4C4A-9BF1-82978105F057}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{C741203A-ADD3-4C4A-9BF1-82978105F057}.Release|Win32.ActiveCfg = Release|Win32
|
{C741203A-ADD3-4C4A-9BF1-82978105F057}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{C741203A-ADD3-4C4A-9BF1-82978105F057}.Release|Win32.Build.0 = Release|Win32
|
{C741203A-ADD3-4C4A-9BF1-82978105F057}.Release|Win32.Build.0 = Release|Win32
|
||||||
{2A1D67D7-7FAE-42D3-AC99-DB68A3570735}.Debug|Win32.ActiveCfg = Debug|Win32
|
{39F3E492-1EE3-4904-8962-D482011AB375}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{2A1D67D7-7FAE-42D3-AC99-DB68A3570735}.Debug|Win32.Build.0 = Debug|Win32
|
{39F3E492-1EE3-4904-8962-D482011AB375}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{2A1D67D7-7FAE-42D3-AC99-DB68A3570735}.Release|Win32.ActiveCfg = Release|Win32
|
{39F3E492-1EE3-4904-8962-D482011AB375}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{2A1D67D7-7FAE-42D3-AC99-DB68A3570735}.Release|Win32.Build.0 = Release|Win32
|
{39F3E492-1EE3-4904-8962-D482011AB375}.Release|Win32.Build.0 = Release|Win32
|
||||||
{41417495-F60E-47CC-BDEF-4B9614E5DA08}.Debug|Win32.ActiveCfg = Debug|Win32
|
{618101EC-0777-4FA6-B1B7-3B7C1981707B}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{41417495-F60E-47CC-BDEF-4B9614E5DA08}.Debug|Win32.Build.0 = Debug|Win32
|
{618101EC-0777-4FA6-B1B7-3B7C1981707B}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{41417495-F60E-47CC-BDEF-4B9614E5DA08}.Release|Win32.ActiveCfg = Release|Win32
|
{618101EC-0777-4FA6-B1B7-3B7C1981707B}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{41417495-F60E-47CC-BDEF-4B9614E5DA08}.Release|Win32.Build.0 = Release|Win32
|
{618101EC-0777-4FA6-B1B7-3B7C1981707B}.Release|Win32.Build.0 = Release|Win32
|
||||||
{76D7F9A9-9C9E-41C9-9BF8-DB305BCEEF71}.Debug|Win32.ActiveCfg = Debug|Win32
|
{76D7F9A9-9C9E-41C9-9BF8-DB305BCEEF71}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{76D7F9A9-9C9E-41C9-9BF8-DB305BCEEF71}.Debug|Win32.Build.0 = Debug|Win32
|
{76D7F9A9-9C9E-41C9-9BF8-DB305BCEEF71}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{76D7F9A9-9C9E-41C9-9BF8-DB305BCEEF71}.Release|Win32.ActiveCfg = Release|Win32
|
{76D7F9A9-9C9E-41C9-9BF8-DB305BCEEF71}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{76D7F9A9-9C9E-41C9-9BF8-DB305BCEEF71}.Release|Win32.Build.0 = Release|Win32
|
{76D7F9A9-9C9E-41C9-9BF8-DB305BCEEF71}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{2A1D67D7-7FAE-42D3-AC99-DB68A3570735}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{2A1D67D7-7FAE-42D3-AC99-DB68A3570735}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{2A1D67D7-7FAE-42D3-AC99-DB68A3570735}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{2A1D67D7-7FAE-42D3-AC99-DB68A3570735}.Release|Win32.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
74
platform/win32/net/wpcap-dsc.c
Normal file
74
platform/win32/net/wpcap-dsc.c
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006, 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: Oliver Schmidt <ol.sc@web.de>
|
||||||
|
*
|
||||||
|
* $Id: wpcap-dsc.c,v 1.1 2006/09/23 20:25:02 oliverschmidt Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "sys/dsc.h"
|
||||||
|
|
||||||
|
extern struct ctk_icon wpcap_icon;
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
DSC(wpcap_dsc,
|
||||||
|
"WinPcap driver",
|
||||||
|
"wpcap.drv",
|
||||||
|
wpcap_process,
|
||||||
|
&wpcap_icon);
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
#if CTK_CONF_ICON_BITMAPS
|
||||||
|
static unsigned char wpcapicon_bitmap[3*3*8] = {
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||||
|
};
|
||||||
|
#endif /* CTK_CONF_ICON_BITMAPS */
|
||||||
|
|
||||||
|
#if CTK_CONF_ICON_TEXTMAPS
|
||||||
|
static char wpcapicon_textmap[9] = {
|
||||||
|
'W', 'i', 'n',
|
||||||
|
' ', 'P', ' ',
|
||||||
|
'c', 'a', 'p'
|
||||||
|
};
|
||||||
|
#endif /* CTK_CONF_ICON_TEXTMAPS */
|
||||||
|
|
||||||
|
#if CTK_CONF_ICONS
|
||||||
|
static struct ctk_icon wpcap_icon =
|
||||||
|
{CTK_ICON("WinPcap driver", wpcapicon_bitmap, wpcapicon_textmap)};
|
||||||
|
#endif /* CTK_CONF_ICONS */
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
199
platform/win32/net/wpcap-service.c
Normal file
199
platform/win32/net/wpcap-service.c
Normal file
|
@ -0,0 +1,199 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006, 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: Oliver Schmidt <ol.sc@web.de>
|
||||||
|
*
|
||||||
|
* $Id: wpcap-service.c,v 1.1 2006/09/23 20:25:03 oliverschmidt Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#include <windows.h>
|
||||||
|
#include <winsock2.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#pragma comment(lib, "wsock32")
|
||||||
|
|
||||||
|
#define htons /* Avoid 'redefinition' error. */
|
||||||
|
#include "contiki.h"
|
||||||
|
#include "contiki-net.h"
|
||||||
|
|
||||||
|
void send_packet(void);
|
||||||
|
|
||||||
|
SERVICE(wpcap_service, packet_service, { (u8_t (*)(void))send_packet });
|
||||||
|
|
||||||
|
PROCESS(wpcap_service_process, "WinPcap driver");
|
||||||
|
|
||||||
|
struct pcap;
|
||||||
|
|
||||||
|
struct pcap_if {
|
||||||
|
struct pcap_if *next;
|
||||||
|
char *name;
|
||||||
|
char *description;
|
||||||
|
struct pcap_addr {
|
||||||
|
struct pcap_addr *next;
|
||||||
|
struct sockaddr *addr;
|
||||||
|
struct sockaddr *netmask;
|
||||||
|
struct sockaddr *broadaddr;
|
||||||
|
struct sockaddr *dstaddr;
|
||||||
|
} *addresses;
|
||||||
|
unsigned __int32 flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct pcap_pkthdr {
|
||||||
|
struct timeval ts;
|
||||||
|
unsigned __int32 caplen;
|
||||||
|
unsigned __int32 len;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct pcap *pcap;
|
||||||
|
|
||||||
|
static int (* pcap_findalldevs)(struct pcap_if **, char *);
|
||||||
|
static struct pcap *(* pcap_open_live)(char *, int, int, int, char *);
|
||||||
|
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])
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static void
|
||||||
|
pollhandler(void)
|
||||||
|
{
|
||||||
|
struct pcap_pkthdr *packet_header;
|
||||||
|
unsigned char *packet;
|
||||||
|
|
||||||
|
process_poll(&wpcap_service_process);
|
||||||
|
|
||||||
|
switch(pcap_next_ex(pcap, &packet_header, &packet)) {
|
||||||
|
case -1:
|
||||||
|
exit(1);
|
||||||
|
case 0:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uip_len = packet_header->caplen;
|
||||||
|
CopyMemory(uip_buf, packet, uip_len);
|
||||||
|
|
||||||
|
if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
|
||||||
|
tcpip_input();
|
||||||
|
} else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
|
||||||
|
uip_arp_arpin();
|
||||||
|
if(uip_len > 0) {
|
||||||
|
if(pcap_sendpacket(pcap, uip_buf, uip_len) == -1) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static void
|
||||||
|
send_packet(void)
|
||||||
|
{
|
||||||
|
uip_arp_out();
|
||||||
|
|
||||||
|
if(pcap_sendpacket(pcap, uip_buf, uip_len) == -1) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
PROCESS_THREAD(wpcap_service_process, ev, data)
|
||||||
|
{
|
||||||
|
static HMODULE wpcap;
|
||||||
|
|
||||||
|
PROCESS_POLLHANDLER(pollhandler());
|
||||||
|
|
||||||
|
PROCESS_BEGIN();
|
||||||
|
|
||||||
|
wpcap = LoadLibrary("wpcap.dll");
|
||||||
|
(FARPROC)pcap_findalldevs = GetProcAddress(wpcap, "pcap_findalldevs");
|
||||||
|
(FARPROC)pcap_open_live = GetProcAddress(wpcap, "pcap_open_live");
|
||||||
|
(FARPROC)pcap_next_ex = GetProcAddress(wpcap, "pcap_next_ex");
|
||||||
|
(FARPROC)pcap_sendpacket = GetProcAddress(wpcap, "pcap_sendpacket");
|
||||||
|
|
||||||
|
if(pcap_findalldevs == NULL || pcap_open_live == NULL ||
|
||||||
|
pcap_next_ex == NULL || pcap_sendpacket == NULL) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
struct in_addr cmdline_addr;
|
||||||
|
struct pcap_if *interfaces;
|
||||||
|
char error[256];
|
||||||
|
|
||||||
|
cmdline_addr.s_addr = inet_addr(__argv[1]);
|
||||||
|
if(cmdline_addr.s_addr == INADDR_NONE) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
debug_printf("Cmdline address: %s\n", inet_ntoa(cmdline_addr));
|
||||||
|
|
||||||
|
if(pcap_findalldevs(&interfaces, error) == -1) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
while(interfaces != NULL) {
|
||||||
|
debug_printf("Found interface: %s\n", interfaces->description);
|
||||||
|
if(interfaces->addresses != NULL &&
|
||||||
|
interfaces->addresses->addr != NULL &&
|
||||||
|
interfaces->addresses->addr->sa_family == AF_INET) {
|
||||||
|
struct in_addr interface_addr;
|
||||||
|
interface_addr = ((struct sockaddr_in *)interfaces->addresses->addr)->sin_addr;
|
||||||
|
debug_printf(" With address: %s\n", inet_ntoa(interface_addr));
|
||||||
|
if(interface_addr.s_addr == cmdline_addr.s_addr) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
interfaces = interfaces->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(interfaces == NULL) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
pcap = pcap_open_live(interfaces->name, UIP_BUFSIZE, 0, -1, error);
|
||||||
|
if(pcap == NULL) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uip_arp_init();
|
||||||
|
|
||||||
|
SERVICE_REGISTER(wpcap_service);
|
||||||
|
|
||||||
|
process_poll(&wpcap_service_process);
|
||||||
|
|
||||||
|
PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_EXIT ||
|
||||||
|
ev == PROCESS_EVENT_SERVICE_REMOVED);
|
||||||
|
|
||||||
|
SERVICE_REMOVE(wpcap_service);
|
||||||
|
|
||||||
|
FreeLibrary(wpcap);
|
||||||
|
|
||||||
|
PROCESS_END();
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
43
platform/win32/net/wpcap-service.h
Normal file
43
platform/win32/net/wpcap-service.h
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006, 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: Oliver Schmidt <ol.sc@web.de>
|
||||||
|
*
|
||||||
|
* $Id: wpcap-service.h,v 1.1 2006/09/23 20:25:03 oliverschmidt Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __WPCAP_SERVICE_H__
|
||||||
|
#define __WPCAP_SERVICE_H__
|
||||||
|
|
||||||
|
#include "contiki.h"
|
||||||
|
|
||||||
|
PROCESS_NAME(wpcap_service_process);
|
||||||
|
|
||||||
|
#endif /* __WPCAP_SERVICE_H__ */
|
200
platform/win32/wpcap.drv.vcproj
Normal file
200
platform/win32/wpcap.drv.vcproj
Normal file
|
@ -0,0 +1,200 @@
|
||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="8,00"
|
||||||
|
Name="wpcap.drv"
|
||||||
|
ProjectGUID="{39F3E492-1EE3-4904-8962-D482011AB375}"
|
||||||
|
RootNamespace="wpcapdrv"
|
||||||
|
Keyword="Win32Proj"
|
||||||
|
>
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"
|
||||||
|
/>
|
||||||
|
</Platforms>
|
||||||
|
<ToolFiles>
|
||||||
|
</ToolFiles>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
|
ConfigurationType="2"
|
||||||
|
CharacterSet="2"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories=".;../../core;../../apps/program-handler"
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;PROCESS_LOADABLE;WITH_LOADER_ARCH"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="3"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="true"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
CompileAs="0"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies=""$(OutDir)\contiki.lib""
|
||||||
|
OutputFile="$(OutDir)\$(ProjectName)"
|
||||||
|
LinkIncremental="2"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
SubSystem="1"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
|
ConfigurationType="2"
|
||||||
|
CharacterSet="2"
|
||||||
|
WholeProgramOptimization="1"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalIncludeDirectories=".;../../core;../../apps/program-handler"
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;PROCESS_LOADABLE;WITH_LOADER_ARCH"
|
||||||
|
RuntimeLibrary="2"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="true"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
CompileAs="0"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies=""$(OutDir)\contiki.lib""
|
||||||
|
OutputFile="$(OutDir)\$(ProjectName)"
|
||||||
|
LinkIncremental="1"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="net"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\core\net\uip_arp.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\core\net\uip_arp.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<File
|
||||||
|
RelativePath=".\net\wpcap-service.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\net\wpcap-service.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
180
platform/win32/wpcap.dsc.vcproj
Normal file
180
platform/win32/wpcap.dsc.vcproj
Normal file
|
@ -0,0 +1,180 @@
|
||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="8,00"
|
||||||
|
Name="wpcap.dsc"
|
||||||
|
ProjectGUID="{618101EC-0777-4FA6-B1B7-3B7C1981707B}"
|
||||||
|
RootNamespace="wpcapdsc"
|
||||||
|
Keyword="Win32Proj"
|
||||||
|
>
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"
|
||||||
|
/>
|
||||||
|
</Platforms>
|
||||||
|
<ToolFiles>
|
||||||
|
</ToolFiles>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
|
ConfigurationType="2"
|
||||||
|
CharacterSet="2"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories=".;../../core"
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;WITH_LOADER_ARCH"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="3"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="true"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
CompileAs="0"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
OutputFile="$(OutDir)\$(ProjectName)"
|
||||||
|
LinkIncremental="2"
|
||||||
|
SubSystem="1"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
|
ConfigurationType="2"
|
||||||
|
CharacterSet="2"
|
||||||
|
WholeProgramOptimization="1"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalIncludeDirectories=".;../../core"
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;WITH_LOADER_ARCH"
|
||||||
|
RuntimeLibrary="2"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="true"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
CompileAs="0"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
OutputFile="$(OutDir)\$(ProjectName)"
|
||||||
|
LinkIncremental="1"
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<File
|
||||||
|
RelativePath=".\net\wpcap-dsc.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
Loading…
Reference in a new issue