[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] minimal echo running in cygwin
From: |
Pedro Alves |
Subject: |
Re: [lwip-users] minimal echo running in cygwin |
Date: |
Mon, 03 Jul 2006 12:58:07 +0100 |
User-agent: |
Mozilla Thunderbird 1.0.2 (Windows/20050317) |
Hi all,
Evgeny Belyanco wrote:
>Thursday, March 30, 2006, 1:13:01 PM, you wrote:
>
>PA> address@hidden wrote:
>
>>>Has anyone been able to get the minimal application (i.e. echo server)
>>>to run under cygwin? I can successfully compile it, but it fails
because
>>>it cannot find the tap interface. I found only a
>>>few archive messages about cygwin, but nothing specific about
running echop.
>>>
>PA> I am running the contrib/msvc6 port compiled with visual studio
2003. It
>PA> uses winpcap for the interface. I guess it should be possible to
compile
>PA> it in cygwin too.
>PA> It doesn't compile out of the box, because the port is a little bit
>PA> outdated, but the changes required are minimal. If you want I can
give
>PA> you a tarball
>PA> that works for me.
>
>Can you upload this tarball?
>
Please find attached a patch against cvs contrib/ports/msvc6/
This patch adapts the msvc6 port to build under VS2003, plus a few other
tweaks.
Using the provided solution depends on having the following environment
variables set:
LWIP_SRC -> the lwip/src directory.
WINPCAP_SDK -> the winpcap sdk directory.
Winpcap builds under cygwin, so there shouldn't be major problems
there.
There is room for improvement. For example, the desired interface
and the ip/gw/mask should be passed on the command line,
instead of being hardcoded.
Also, I think it would be better to write an nmake makefile than to
rely on MS Solutions and projects. I will leave that to someone else.
Cheers,
Pedro Alves
P.S. Since there is no ChangeLog in ports/, I've written the ChangeLog
entry in gnu style.
---
ChangeLog
2006-07-03 Pedro Alves <address@hidden>
* contrib/ports/msvc6/include/arch/sys_arch.h (sys_sem,
sys_sem_t, sys_mbox, sys_mbox_t, sys_thread, sys_thread_t):
Remove.
* contrib/ports/msvc6/pktdrv.c (get_adapter_name): New function
based on init_adapter.
(init_adapter_by_name): New function based on init_adapter.
(init_adapter) : Adapt to the split.
* contrib/ports/msvc6/pktif.c (ethernetif_input): Use sizeof
struct eth_hdr, instead of numeric constant.
* contrib/ports/msvc6/test.c (main_loop): Adapt to ptkdrv.c
changes. Call netif_set_up, and raw_init.
* contrib/ports/msvc6/test.sln : New file for VS2003.
* contrib/ports/msvc6/test.vcproj : Ditto.
* contrib/ports/msvc6/pktif.vcproj : Ditto.
* contrib/ports/msvc6/lwip4.vcproj : Ditto.
diff -Nurp -x CVS -x BuildLog.htm msvc6.org/include/arch/sys_arch.h
msvc6/include/arch/sys_arch.h
--- msvc6.org/include/arch/sys_arch.h 2006-07-03 10:59:18.781250000 +0100
+++ msvc6/include/arch/sys_arch.h 2006-07-03 11:08:37.343750000 +0100
@@ -35,14 +35,5 @@
#define SYS_MBOX_NULL NULL
#define SYS_SEM_NULL NULL
-struct sys_sem;
-typedef struct sys_sem * sys_sem_t;
-
-struct sys_mbox;
-typedef struct sys_mbox *sys_mbox_t;
-
-struct sys_thread;
-typedef struct sys_thread * sys_thread_t;
-
#endif /* __ARCH_SYS_ARCH_H__ */
diff -Nurp -x CVS -x BuildLog.htm msvc6.org/lwip4.vcproj msvc6/lwip4.vcproj
--- msvc6.org/lwip4.vcproj 1970-01-01 00:00:00.000000000 +0000
+++ msvc6/lwip4.vcproj 2006-07-03 11:33:48.796875000 +0100
@@ -0,0 +1,495 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="lwip4"
+ RootNamespace="lwip4"
+ SccProjectName=""
+ SccLocalPath="">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="4"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ InlineFunctionExpansion="1"
+
AdditionalIncludeDirectories="$(LWIP_SRC)\include,$(LWIP_SRC)\include\ipv4,.\include,.\"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+ StringPooling="TRUE"
+ RuntimeLibrary="4"
+ EnableFunctionLevelLinking="TRUE"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderFile=".\Release/lwip4.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLibrarianTool"
+ OutputFile=".\Release\lwip4.lib"
+ SuppressStartupBanner="TRUE"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1031"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="4"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+
AdditionalIncludeDirectories="$(LWIP_SRC)\include,$(LWIP_SRC)\include\ipv4,.\include,.\"
+
PreprocessorDefinitions="_LIB;WIN32;_DEBUG;LWIP_DEBUG"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderFile=".\Debug/lwip4.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ DebugInformationFormat="4"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLibrarianTool"
+ OutputFile="Debug\lwip4_d.lib"
+ SuppressStartupBanner="TRUE"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1031"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quellcodedateien"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
+ <File
+ RelativePath="$(LWIP_SRC)\core\ipv4\icmp.c">
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\core\inet.c">
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\core\ipv4\ip.c">
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\core\ipv4\ip_addr.c">
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\core\ipv4\ip_frag.c">
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\core\mem.c">
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\core\memp.c">
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\core\netif.c">
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\core\pbuf.c">
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\..\lwip\src\core\raw.c">
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\core\stats.c">
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\core\sys.c">
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\core\tcp.c">
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\core\tcp_in.c">
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\core\tcp_out.c">
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\core\udp.c">
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header-Dateien"
+ Filter="h;hpp;hxx;hm;inl">
+ <File
+ RelativePath="$(LWIP_SRC)\include\lwip\api.h">
+ </File>
+ <File
+
RelativePath="$(LWIP_SRC)\include\lwip\api_msg.h">
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\include\lwip\arch.h">
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\include\lwip\debug.h">
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\include\lwip\def.h">
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\include\lwip\err.h">
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\include\lwip\event.h">
+ </File>
+ <File
+
RelativePath="$(LWIP_SRC)\include\ipv4\lwip\icmp.h">
+ </File>
+ <File
+
RelativePath="$(LWIP_SRC)\include\ipv4\lwip\inet.h">
+ </File>
+ <File
+
RelativePath="$(LWIP_SRC)\include\ipv4\lwip\ip.h">
+ </File>
+ <File
+
RelativePath="$(LWIP_SRC)\include\ipv4\lwip\ip_addr.h">
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\include\lwip\mem.h">
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\include\lwip\memp.h">
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\include\lwip\netif.h">
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\include\lwip\opt.h">
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\include\lwip\pbuf.h">
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\include\lwip\sys.h">
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\include\lwip\tcp.h">
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\include\lwip\tcpip.h">
+ </File>
+ <File
+ RelativePath="$(LWIP_SRC)\include\lwip\udp.h">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff -Nurp -x CVS -x BuildLog.htm msvc6.org/pktdrv.c msvc6/pktdrv.c
--- msvc6.org/pktdrv.c 2006-07-03 10:59:14.468750000 +0100
+++ msvc6/pktdrv.c 2006-07-03 11:56:57.734375000 +0100
@@ -69,6 +69,7 @@
#include <windows.h>
#include <packet32.h>
#include <ntddndis.h>
+#include <malloc.h>
LPADAPTER lpAdapter;
LPPACKET lpPacket;
@@ -77,10 +78,11 @@ unsigned char *cur_packet;
int cur_length;
unsigned char ethaddr[6];
-/*-----------------------------------------------------------------------------------*/
-int init_adapter(int adapter_num)
+int init_adapter_by_name(const char* adapter_name);
+
+int get_adapter_name(int adapter_num, char* name_buf, int name_len)
{
- #define Max_Num_Adapter 10
+#define Max_Num_Adapter 10
void *AdapterList[Max_Num_Adapter];
@@ -89,21 +91,20 @@ int init_adapter(int adapter_num)
DWORD dwWindowsMajorVersion;
//unicode strings (winnt)
- wchar_t AdapterName[8192]; // string that contains a list of
the network adapters
- wchar_t *temp,*temp1;
+ // string that contains a list of the network adapters
+ wchar_t AdapterName[4096];
+ ULONG AdapterLength = sizeof(AdapterName)/sizeof(AdapterName[0]);
+
+ wchar_t *temp,*temp1;
//ascii strings (win95)
- char AdapterNamea[8192]; // string that contains a list of
the network adapters
char *tempa,*temp1a;
int AdapterNum=0;
- ULONG AdapterLength;
-
- PPACKET_OID_DATA ppacket_oid_data;
+ int found = -1;
// obtain the name of the adapters installed on this machine
- AdapterLength=4096;
-
+
memset(AdapterList,0,sizeof(AdapterList));
i=0;
@@ -112,7 +113,8 @@ int init_adapter(int adapter_num)
// We have to check the os on which we are running
dwVersion=GetVersion();
dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
- if (!(dwVersion >= 0x80000000 && dwWindowsMajorVersion >= 4))
+ // ?? PacketGetAdapterNames is always returning ansi on Windows XP
+ if (0 && !(dwVersion >= 0x80000000 && dwWindowsMajorVersion >= 4))
{ // Windows NT
if (PacketGetAdapterNames((char
*)AdapterName,&AdapterLength)==FALSE){
printf("Unable to retrieve the list of the
adapters!\n");
@@ -136,9 +138,9 @@ int init_adapter(int adapter_num)
for (i=0; i<AdapterNum; i++)
wprintf(L"%2i: %s\n", i, AdapterList[i]);
}
-
else //windows 95
{
+ char* AdapterNamea = (char*)AdapterName;
if (PacketGetAdapterNames(AdapterNamea,&AdapterLength)==FALSE){
printf("Unable to retrieve the list of the
adapters!\n");
return -1;
@@ -158,9 +160,22 @@ int init_adapter(int adapter_num)
}
AdapterNum=i;
- AdapterNum=i;
+ while (*tempa == '\0')
+ tempa++;
+
for (i=0; i<AdapterNum; i++)
- printf("%2i: %s", i, AdapterList[i]);
+ {
+ printf("%2i: %s, %s\n", i, AdapterList[i], tempa);
+ if (i == adapter_num)
+ {
+ _snprintf(name_buf, name_len, "%s",
AdapterList[i]);
+ found = i;
+ }
+
+ while (*tempa != '\0')
+ tempa++;
+ tempa++;
+ }
}
if (AdapterNum<=0)
@@ -169,8 +184,26 @@ int init_adapter(int adapter_num)
return -1;
if (adapter_num >= AdapterNum)
return -1;
- ppacket_oid_data=malloc(sizeof(PACKET_OID_DATA)+6);
- lpAdapter=PacketOpenAdapter(AdapterList[adapter_num]);
+ return found;
+}
+
+int init_adapter(int adapter_num)
+{
+ char buf[1024];
+ if (get_adapter_name(adapter_num, buf, sizeof(buf)) < 0)
+ return -1;
+ if (init_adapter_by_name(buf) != 0)
+ return -1;
+ return 0;
+}
+
+/*-----------------------------------------------------------------------------------*/
+int init_adapter_by_name(const char* adapter_name)
+{
+ PPACKET_OID_DATA ppacket_oid_data;
+
+ ppacket_oid_data=alloca(sizeof(PACKET_OID_DATA)+6);
+ lpAdapter=PacketOpenAdapter((char*)adapter_name);
if (!lpAdapter || (lpAdapter->hFile == INVALID_HANDLE_VALUE))
return -1;
ppacket_oid_data->Oid=OID_802_3_PERMANENT_ADDRESS;
@@ -178,7 +211,6 @@ int init_adapter(int adapter_num)
if (!PacketRequest(lpAdapter,FALSE,ppacket_oid_data))
return -1;
memcpy(ðaddr,ppacket_oid_data->Data,6);
- free(ppacket_oid_data);
printf("MAC: %2X%2X%2X%2X%2X%2X\n", ethaddr[0], ethaddr[1], ethaddr[2],
ethaddr[3], ethaddr[4], ethaddr[5]);
PacketSetBuff(lpAdapter,512000);
PacketSetReadTimeout(lpAdapter,1);
@@ -188,9 +220,12 @@ int init_adapter(int adapter_num)
}
PacketInitPacket(lpPacket,(char*)buffer,256000);
+ printf("%s initialized\n", adapter_name);
return 0;
}
+
+
void shutdown_adapter(void)
{
PacketFreePacket(lpPacket);
diff -Nurp -x CVS -x BuildLog.htm msvc6.org/pktif.c msvc6/pktif.c
--- msvc6.org/pktif.c 2006-07-03 10:59:14.765625000 +0100
+++ msvc6/pktif.c 2006-07-03 11:04:51.593750000 +0100
@@ -275,7 +275,7 @@ ethernetif_input(struct netif *netif)
switch (htons(ethhdr->type)) {
case ETHTYPE_IP:
etharp_ip_input(netif, p);
- pbuf_header(p, -14);
+ pbuf_header(p, -(int)sizeof(struct eth_hdr));
netif->input(p, netif);
break;
case ETHTYPE_ARP:
diff -Nurp -x CVS -x BuildLog.htm msvc6.org/pktif.vcproj msvc6/pktif.vcproj
--- msvc6.org/pktif.vcproj 1970-01-01 00:00:00.000000000 +0000
+++ msvc6/pktif.vcproj 2006-07-03 11:30:36.171875000 +0100
@@ -0,0 +1,194 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="pktif"
+ SccProjectName=""
+ SccLocalPath="">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="4"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+
AdditionalIncludeDirectories="$(LWIP_SRC)\include,$(LWIP_SRC)\include\ipv4,.\include,.\,$(WINPCAP_SDK)\Include"
+
PreprocessorDefinitions="_LIB;WIN32;_DEBUG;LWIP_DEBUG"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderFile=".\Debug/pktif.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ DebugInformationFormat="4"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLibrarianTool"
+ OutputFile="Debug\pktif_d.lib"
+ SuppressStartupBanner="TRUE"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1031"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="4"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ InlineFunctionExpansion="1"
+
AdditionalIncludeDirectories="$(LWIP_SRC)\include,$(LWIP_SRC)\include\ipv4,.\include,.\"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+ StringPooling="TRUE"
+ RuntimeLibrary="4"
+ EnableFunctionLevelLinking="TRUE"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderFile=".\Release/pktif.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLibrarianTool"
+ OutputFile=".\Release\pktif.lib"
+ SuppressStartupBanner="TRUE"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1031"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quellcodedateien"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
+ <File
+ RelativePath="$(LWIP_SRC)\netif\etharp.c">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="pktdrv.c">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="pktif.c">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header-Dateien"
+ Filter="h;hpp;hxx;hm;inl">
+ <File
+
RelativePath="$(LWIP_SRC)\include\netif\etharp.h">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff -Nurp -x CVS -x BuildLog.htm msvc6.org/test.c msvc6/test.c
--- msvc6.org/test.c 2006-07-03 10:59:15.562500000 +0100
+++ msvc6/test.c 2006-07-03 11:58:40.296875000 +0100
@@ -54,8 +54,11 @@
//#include "ftpd.h"
//#include "fs.h"
-void ethernetif_init(struct netif *netif);
+err_t ethernetif_init(struct netif *netif);
int init_adapter(int adapter_num);
+int init_adapter_by_name(const char*);
+int get_adapter_name(int, const char*, int len);
+
void shutdown_adapter(void);
void update_adapter(void);
@@ -118,17 +121,30 @@ void main_loop()
int timer1;
int timer2;
int done;
-
+ char buf[1024];
+
IP4_ADDR(&gw, 192,168,0,1);
IP4_ADDR(&ipaddr, 192,168,0,200);
IP4_ADDR(&netmask, 255,255,255,0);
- if (init_adapter(0) != 0)
+#ifdef LWIP_ADAPTER
+ if (get_adapter_name(LWIP_ADAPTER, buf, sizeof(buf)) < 0)
+ {
+ printf("adapter not found : %d", LWIP_ADAPTER);
+ return;
+ }
+#else
+ strcpy(buf, "\\Device\\NPF_{AC3D8C40-A47A-4016-9401-33488B9326D5}");
+#endif
+
+ if (init_adapter_by_name(buf) != 0)
return;
netif_set_default(netif_add(&netif, &ipaddr, &netmask, &gw, NULL,
ethernetif_init,
ip_input));
+ netif_set_up(&netif);
+
/*
IP4_ADDR(&gw, 127,0,0,1);
IP4_ADDR(&ipaddr, 127,0,0,1);
@@ -138,6 +154,7 @@ void main_loop()
ip_input);
*/
+ raw_init();
tcp_init();
udp_init();
ip_init();
diff -Nurp -x CVS -x BuildLog.htm msvc6.org/test.sln msvc6/test.sln
--- msvc6.org/test.sln 1970-01-01 00:00:00.000000000 +0000
+++ msvc6/test.sln 2006-07-03 11:23:46.625000000 +0100
@@ -0,0 +1,39 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lwip4", "lwip4.vcproj",
"{30513EE7-B3E8-46B2-8676-29FD128B497A}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pktif", "pktif.vcproj",
"{11A3D0DE-EC55-4218-8EA7-3F06748A0720}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test.vcproj",
"{CCB1CEF6-8B9D-46B3-BB73-4F07EA42C462}"
+ ProjectSection(ProjectDependencies) = postProject
+ {11A3D0DE-EC55-4218-8EA7-3F06748A0720} =
{11A3D0DE-EC55-4218-8EA7-3F06748A0720}
+ {30513EE7-B3E8-46B2-8676-29FD128B497A} =
{30513EE7-B3E8-46B2-8676-29FD128B497A}
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {30513EE7-B3E8-46B2-8676-29FD128B497A}.Debug.ActiveCfg =
Debug|Win32
+ {30513EE7-B3E8-46B2-8676-29FD128B497A}.Debug.Build.0 =
Debug|Win32
+ {30513EE7-B3E8-46B2-8676-29FD128B497A}.Release.ActiveCfg =
Release|Win32
+ {30513EE7-B3E8-46B2-8676-29FD128B497A}.Release.Build.0 =
Release|Win32
+ {11A3D0DE-EC55-4218-8EA7-3F06748A0720}.Debug.ActiveCfg =
Debug|Win32
+ {11A3D0DE-EC55-4218-8EA7-3F06748A0720}.Debug.Build.0 =
Debug|Win32
+ {11A3D0DE-EC55-4218-8EA7-3F06748A0720}.Release.ActiveCfg =
Release|Win32
+ {11A3D0DE-EC55-4218-8EA7-3F06748A0720}.Release.Build.0 =
Release|Win32
+ {CCB1CEF6-8B9D-46B3-BB73-4F07EA42C462}.Debug.ActiveCfg =
Debug|Win32
+ {CCB1CEF6-8B9D-46B3-BB73-4F07EA42C462}.Debug.Build.0 =
Debug|Win32
+ {CCB1CEF6-8B9D-46B3-BB73-4F07EA42C462}.Release.ActiveCfg =
Release|Win32
+ {CCB1CEF6-8B9D-46B3-BB73-4F07EA42C462}.Release.Build.0 =
Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff -Nurp -x CVS -x BuildLog.htm msvc6.org/test.vcproj msvc6/test.vcproj
--- msvc6.org/test.vcproj 1970-01-01 00:00:00.000000000 +0000
+++ msvc6/test.vcproj 2006-07-03 11:41:46.390625000 +0100
@@ -0,0 +1,251 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="test"
+ SccProjectName=""
+ SccLocalPath="">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="1"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ InlineFunctionExpansion="1"
+
AdditionalIncludeDirectories="$(LWIP_SRC)\include,$(LWIP_SRC)\include\ipv4,.\include,.\"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ StringPooling="TRUE"
+ RuntimeLibrary="4"
+ EnableFunctionLevelLinking="TRUE"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderFile=".\Release/test.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="odbc32.lib odbccp32.lib
Packet.lib"
+ OutputFile=".\Release/test.exe"
+ LinkIncremental="1"
+ SuppressStartupBanner="TRUE"
+ ProgramDatabaseFile=".\Release/test.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\Release/test.tlb"
+ HeaderFileName=""/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1031"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="1"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+
AdditionalIncludeDirectories="$(LWIP_SRC)\include,$(LWIP_SRC)\include\ipv4,.\include,.\"
+
PreprocessorDefinitions="_CONSOLE;WIN32;_DEBUG;LWIP_DEBUG"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderFile=".\Debug/test.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ DebugInformationFormat="4"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="odbc32.lib odbccp32.lib
Packet.lib"
+ OutputFile=".\Debug/test.exe"
+ LinkIncremental="0"
+ SuppressStartupBanner="TRUE"
+
AdditionalLibraryDirectories="$(WINPCAP_SDK)\Lib"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile=".\Debug/test.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\Debug/test.tlb"
+ HeaderFileName=""/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1031"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quellcodedateien"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
+ <File
+ RelativePath="fs.c">
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="httpd.c">
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="test.c">
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ BasicRuntimeChecks="3"/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header-Dateien"
+ Filter="h;hpp;hxx;hm;inl">
+ </Filter>
+ <Filter
+ Name="Ressourcendateien"
+
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
+ </Filter>
+ <File
+ RelativePath="Release\lwip4.lib">
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="TRUE">
+ <Tool
+ Name="VCCustomBuildTool"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="Debug\lwip4_d.lib">
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="TRUE">
+ <Tool
+ Name="VCCustomBuildTool"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="Release\pktif.lib">
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="TRUE">
+ <Tool
+ Name="VCCustomBuildTool"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="Debug\pktif_d.lib">
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="TRUE">
+ <Tool
+ Name="VCCustomBuildTool"/>
+ </FileConfiguration>
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>