summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2012-10-23 21:16:14 +0000
committerLudovic Pouzenc <ludovic@pouzenc.fr>2012-10-23 21:16:14 +0000
commit2414450562696b45bd37b14530d5398d92a323dd (patch)
tree952fb055c217bbd00096a34710cef4101c6370ef
parent2442c62cccc97d88ca1635d2b231dec7261ca17f (diff)
download2012-tzsp-2414450562696b45bd37b14530d5398d92a323dd.tar.gz
2012-tzsp-2414450562696b45bd37b14530d5398d92a323dd.tar.bz2
2012-tzsp-2414450562696b45bd37b14530d5398d92a323dd.zip
Version qui compile sous Visual Studio 2005, CodeBlocks avec MinGW et Linux Ubuntu 12.04.
J'ai carrément fait des fichiers includes par compliateur car ça faisait des tas de #if pourris. git-svn-id: file:///var/svn/2012-tzsp/trunk@14 147d2d3d-d0bd-48ea-923a-d90ac20f5906
-rw-r--r--Makefile2
-rw-r--r--README16
-rw-r--r--pcap2tzsp.c100
-rw-r--r--pcap2tzsp.cbp64
-rw-r--r--pcap2tzsp.h50
-rw-r--r--pcap2tzsp.vcproj213
-rw-r--r--pcap2tzsp_linux.h55
-rw-r--r--pcap2tzsp_win32_mingw.h57
-rw-r--r--pcap2tzsp_win32_vs.h73
9 files changed, 548 insertions, 82 deletions
diff --git a/Makefile b/Makefile
index c9d7637..e16310a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
all : pcap2tzsp
pcap2tzsp: pcap2tzsp.o
- gcc -o pcap2tzsp pcap2tzsp.o -lpcap
+ gcc -Wall -o pcap2tzsp pcap2tzsp.o -lpcap
pcap2tzsp.o : pcap2tzsp.c
gcc -Wall -c pcap2tzsp.c
clean :
diff --git a/README b/README
new file mode 100644
index 0000000..3803e82
--- /dev/null
+++ b/README
@@ -0,0 +1,16 @@
+
+Files description :
+
+LICENCE GPL 3 licence text
+README This file
+
+Makefile Compliation directives for linux
+pcap2tzsp.cbp Project file for Code-Blocks (I use the 10.05 release)
+pcap2tzsp.vcproj Project file for Visual Studio (Express) 2005 (aka version 8)
+
+pcap2tzsp.c Main file with all the code
+pcap2tzsp.h Header included by pcap2tzsp.c. Includes the right pcap2tzsp_*.h detecting compilation env.
+pcap2tzsp_linux.h Specific header for pcap2tzsp.c library headers on Linux platform
+pcap2tzsp_win32_mingw.h Specific header for pcap2tzsp.c library headers on Windows platform using MinGW32
+pcap2tzsp_win32_vs.h Specific header for pcap2tzsp.c library headers on Windows platform using Visual Studio
+
diff --git a/pcap2tzsp.c b/pcap2tzsp.c
index bf175ea..16b6e56 100644
--- a/pcap2tzsp.c
+++ b/pcap2tzsp.c
@@ -22,70 +22,7 @@
This file is part of Pcap2tzsp. See LICENCE file.
*/
-/* Basics */
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h> /* Consider using msinttypes for Visual Studio */
-#include <signal.h>
-#include <string.h>
-
-#ifdef WIN32 /* snprintf compatiblity */
-#define my_snprintf sprintf_s
-#else
-#define my_snprintf snprintf
-#endif
-
-
-/* Packet capture stuff */
-#include <pcap.h>
-
-/* UDP stuff */
-#ifdef WIN32
-#include <winsock2.h>
-#include <ws2tcpip.h>
-#else
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <unistd.h>
-#include <netdb.h> /* Name resolution */
-#define SOCKET int
-#define INVALID_SOCKET -1
-#endif
-
-/* Time management (for bwlimit) */
-#include <time.h>
-
-/* Args parsing and basename() for usage */
-#ifdef WIN32
-#undef _UNICODE
-#include <getopt.h> /* Consider using getopt4win for WIN32 */
-
- /* Poor's men hand-written basename.
- With calloc() and this is diffent from POSIX basename() */
- char * basename(const char *path) {
- errno_t e;
- size_t len1, len2;
- char filename[256], ext[8];
- char *res=NULL;
-
- e=_splitpath_s(path, NULL, 0, NULL, 0, filename, 256, ext, 8);
- if (e != 0) {
- res=strdup("");
- } else {
- len1=strlen(filename);
- len2=strlen(ext);
- res=calloc(len1+len2 + 1, sizeof(char));
- if ( res != NULL ) {
- strcpy_s(res, len1+1, filename);
- strcpy_s(res+len1, len2+1, ext);
- }
- }
- return res;
- }
-#else
-#include <getopt.h>
-#include <libgen.h>
-#endif
+#include "pcap2tzsp.h"
/* Option default values (as strings) */
#define DEFAULT_FILTER "not ( icmp[icmptype]=icmp-unreach or (udp and dst %s and port %s) )"
@@ -93,8 +30,8 @@
#define DEFAULT_PORT "37008"
#define DEFAULT_SNAPLEN "70"
-/* MAX_TZSP_PAYLOAD is for not trying to send TZSP packets greater than the interface MTU
- MAX_TZSP_PAYLOAD = MTU - IP header - UDP header - TZSP header
+/* MAX_TZSP_PAYLOAD is for not trying to send TZSP packets greater than the interface MTU
+ MAX_TZSP_PAYLOAD = MTU - IP header - UDP header - TZSP header
I am assuming the following :
- Layer 2 overhead is the same for the captured packet and the transmitted packet
- MTU is assumed to be 1500 for now
@@ -109,13 +46,14 @@
/*
TODO List
+ * Essayer WIN32_LEAN_AND_MEAN avec VS
* Implémenter une bwlimit en sortie (ptks/s et/ou bytes/s)
* Calcul dynamique de MAX_TZSP_PAYLOAD
*/
/* Functions declaration */
-int make_dgram_socket(char host[], char service[], int hint_flags, char **resolved_address);
-void start_capture_loop(char *pcap_filter);
+SOCKET make_dgram_socket(char host[], char service[], int hint_flags, char **resolved_address);
+void start_capture_loop(char *pcap_filter);
void process_packet(u_char *void_args, const struct pcap_pkthdr* pkthdr, const u_char * packet);
/* Custom types definition */
@@ -135,7 +73,7 @@ static char *opt_host=NULL;
static char *opt_port=NULL;
static char *opt_snaplen=NULL;
-pcap_t *pcap_handle = NULL;
+pcap_t *pcap_handle = NULL;
void usage(char progname[]) {
printf("Usage : %s [--verbose] [--brief] [-i <iface>] [-h <host>] [-p <port>] [custom_pcap_filter]\n", progname);
@@ -278,7 +216,7 @@ int main(int argc, char *argv[]) {
return 0;
}
-int make_dgram_socket(char host[], char service[], int hint_flags, char **resolved_address) {
+SOCKET make_dgram_socket(char host[], char service[], int hint_flags, char **resolved_address) {
/* Code taken from Client program example of getaddrinfo(3) manpage
Tweaks added for WIN32 "compatibility"
@@ -331,7 +269,7 @@ int make_dgram_socket(char host[], char service[], int hint_flags, char **resolv
/* This part was not in the example as is */
if ( resolved_address != NULL) {
/* If wanted, return numerical form of the choosen host address */
- if ( getnameinfo(rp->ai_addr, rp->ai_addrlen, hbuf,
+ if ( getnameinfo(rp->ai_addr, rp->ai_addrlen, hbuf,
NI_MAXHOST_NUMERIC, NULL, 0, NI_NUMERICHOST) == 0 ) {
*resolved_address=strdup(hbuf);
}
@@ -342,10 +280,10 @@ int make_dgram_socket(char host[], char service[], int hint_flags, char **resolv
}
-void start_capture_loop(char *pcap_filter) {
+void start_capture_loop(char *pcap_filter) {
//Global for signal handling
- //pcap_t *pcap_handle = NULL;
+ //pcap_t *pcap_handle = NULL;
char *resolved_address=NULL;
static char *pcap_device=NULL;
char pcap_errbuf[PCAP_ERRBUF_SIZE];
@@ -355,11 +293,11 @@ void start_capture_loop(char *pcap_filter) {
int snaplen, hints_flags, pcap_filter_synthetised=0;
size_t pcap_filter_len; /* size_t is "mandatory" for WIN32 */
- memset(pcap_errbuf,0,PCAP_ERRBUF_SIZE);
- memset(&process_packet_args,0,sizeof(process_packet_args_t));
+ memset(pcap_errbuf,0,PCAP_ERRBUF_SIZE);
+ memset(&process_packet_args,0,sizeof(process_packet_args_t));
if (opt_iface == NULL) {
- /* Get the name of the first device suitable for capture */
+ /* Get the name of the first device suitable for capture */
if ( (pcap_device = pcap_lookupdev(pcap_errbuf)) == NULL){
fprintf(stderr, "ERROR: %s\n", pcap_errbuf);
exit(20);
@@ -387,7 +325,7 @@ void start_capture_loop(char *pcap_filter) {
/* pcap init */
if (opt_verbose) printf("Opening device %s for capturing\n", pcap_device);
- /* Open device in promiscuous mode */
+ /* Open device in promiscuous mode */
if ( (pcap_handle = pcap_open_live(pcap_device, snaplen, 1, 512, pcap_errbuf)) == NULL){
fprintf(stderr, "ERROR: %s\n", pcap_errbuf);
exit(21);
@@ -419,7 +357,7 @@ void start_capture_loop(char *pcap_filter) {
pcap_freecode(&pcap_filter_prog);
- /* Loop forever & call process_packet() for every received packet */
+ /* Loop forever & call process_packet() for every received packet */
if ( pcap_loop(pcap_handle, -1, process_packet, (u_char *)&process_packet_args) == -1) {
fprintf(stderr, "ERROR: %s\n", pcap_geterr(pcap_handle) );
exit(25);
@@ -427,7 +365,7 @@ void start_capture_loop(char *pcap_filter) {
fprintf(stderr, "\n%u packets captured\n%u TZSP packets sent\n",
process_packet_args.captured_pkt_count, process_packet_args.sent_pkt_count);
-
+
if (pcap_stats(pcap_handle, &stat) == -1) {
fprintf(stderr, "ERROR: %s\n", pcap_geterr(pcap_handle) );
exit(26);
@@ -460,7 +398,7 @@ void process_packet(u_char *void_args, const struct pcap_pkthdr* pkthdr, const u
char buf[UDP_SEND_BUFLEN];
/* struct timespec ts_reqsleep; // For simulation */
- process_packet_args_t *args=(process_packet_args_t *)void_args;
+ process_packet_args_t *args=(process_packet_args_t *)void_args;
/* Catpured packet counting and displaying (max once by second) */
args->captured_pkt_count++;
@@ -495,7 +433,7 @@ void process_packet(u_char *void_args, const struct pcap_pkthdr* pkthdr, const u
buf[5]=0x04; /* Tag length == 4 bytes */
/* buf[6,7,8,9] Timestamp on 4 bytes (network order) */
- memcpy(buf+6, &field_ts, 4);
+ memcpy(buf+6, &field_ts, 4);
/* Wireshark don't dissect that */
//buf[10]=0x28; /* Tag type TAG_PACKET_COUNT */
diff --git a/pcap2tzsp.cbp b/pcap2tzsp.cbp
new file mode 100644
index 0000000..f638dca
--- /dev/null
+++ b/pcap2tzsp.cbp
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<CodeBlocks_project_file>
+ <FileVersion major="1" minor="6" />
+ <Project>
+ <Option title="pcap2tzsp" />
+ <Option pch_mode="2" />
+ <Option compiler="gcc" />
+ <Build>
+ <Target title="Debug">
+ <Option output="bin\Debug\pcap2tzsp" prefix_auto="1" extension_auto="1" />
+ <Option object_output="obj\Debug\" />
+ <Option type="1" />
+ <Option compiler="gcc" />
+ <Compiler>
+ <Add option="-Wall" />
+ <Add option="-g" />
+ <Add option="-DWIN32" />
+ <Add option="-DWPCAP" />
+ <Add directory="C:\libs\WpdPack_4_1_2\WpdPack\Include" />
+ </Compiler>
+ <Linker>
+ <Add library="C:\libs\WpdPack_4_1_2\WpdPack\Lib\Packet.lib" />
+ <Add library="C:\libs\WpdPack_4_1_2\WpdPack\Lib\wpcap.lib" />
+ <Add library="C:\Program Files\CodeBlocks\MinGW\lib\libws2_32.a" />
+ </Linker>
+ </Target>
+ <Target title="Release">
+ <Option output="bin\Release\pcap2tzsp" prefix_auto="1" extension_auto="1" />
+ <Option object_output="obj\Release\" />
+ <Option type="1" />
+ <Option compiler="gcc" />
+ <Compiler>
+ <Add option="-O2" />
+ <Add option="-Wall" />
+ <Add option="-DWIN32" />
+ <Add option="-DWPCAP" />
+ <Add directory="C:\libs\WpdPack_4_1_2\WpdPack\Include" />
+ </Compiler>
+ <Linker>
+ <Add option="-s" />
+ <Add library="C:\libs\WpdPack_4_1_2\WpdPack\Lib\Packet.lib" />
+ <Add library="C:\libs\WpdPack_4_1_2\WpdPack\Lib\wpcap.lib" />
+ <Add library="C:\Program Files\CodeBlocks\MinGW\lib\libws2_32.a" />
+ </Linker>
+ </Target>
+ </Build>
+ <Compiler>
+ <Add option="-Wall" />
+ </Compiler>
+ <Unit filename="pcap2tzsp.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="pcap2tzsp.h">
+ <Option target="&lt;{~None~}&gt;" />
+ </Unit>
+ <Unit filename="pcap2tzsp_win32_mingw.h">
+ <Option target="&lt;{~None~}&gt;" />
+ </Unit>
+ <Extensions>
+ <code_completion />
+ <debugger />
+ </Extensions>
+ </Project>
+</CodeBlocks_project_file>
diff --git a/pcap2tzsp.h b/pcap2tzsp.h
new file mode 100644
index 0000000..80b5c94
--- /dev/null
+++ b/pcap2tzsp.h
@@ -0,0 +1,50 @@
+/*
+
+ Pcap2tzsp allows to capture ethernet trafic and send all headers
+ to a defined host using the TaZmen Sniffing Protocol (TZSP).
+
+ Copyright (C) 2012 Ludovic Pouzenc <lpouzenc@gmail.com>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+ This file is part of Pcap2tzsp. See LICENCE file.
+*/
+
+
+#ifndef PCAP2TZSP_H_INCLUDED
+#define PCAP2TZSP_H_INCLUDED
+
+
+/* Get the right include file */
+#if ( defined(WIN32) && defined(_MSC_VER) )
+/* Visual studio case */
+#include "pcap2tzsp_win32_vs.h"
+
+#elif ( defined(WIN32) && defined(__MINGW32__) )
+/* MinGW on Windows case*/
+#include "pcap2tzsp_win32_mingw.h"
+
+#elif ( defined(WIN32) )
+/* TODO */
+#pragma message("You are in an unspecifed case.")
+
+#else
+/* Linux case */
+#include "pcap2tzsp_linux.h"
+#endif
+
+
+#endif // PCAP2TZSP_H_INCLUDED
+
diff --git a/pcap2tzsp.vcproj b/pcap2tzsp.vcproj
new file mode 100644
index 0000000..16915c0
--- /dev/null
+++ b/pcap2tzsp.vcproj
@@ -0,0 +1,213 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8,00"
+ Name="pcap2tzsp"
+ ProjectGUID="{CA4E26AC-E43B-45C1-A9B5-12EC489B3F85}"
+ RootNamespace="pcap2tzsp"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="&quot;C:\Program Files\Microsoft SDKs\Windows\v7.1\Include&quot;;&quot;C:\libs\msinttypes-r26&quot;;C:\libs\getopt_mb_uni_vc8\getopt_mb_uni_vc8_dll;C:\libs\WpdPack_4_1_2\WpdPack\Include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;WPCAP"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkLibraryDependencies="true"
+ AdditionalDependencies="WS2_32.Lib Packet.lib wpcap.lib getopt.lib"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="&quot;C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib&quot;;C:\libs\getopt_mb_uni_vc8\bin\release\dll;C:\libs\WpdPack_4_1_2\WpdPack\Lib"
+ IgnoreAllDefaultLibraries="false"
+ 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="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="&quot;C:\Program Files\Microsoft SDKs\Windows\v7.1\Include&quot;;&quot;C:\libs\msinttypes-r26&quot;;C:\libs\getopt_mb_uni_vc8\getopt_mb_uni_vc8_dll;C:\libs\WpdPack_4_1_2\WpdPack\Include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WPCAP"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="WS2_32.Lib Packet.lib wpcap.lib getopt.lib"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="&quot;C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib&quot;;C:\libs\getopt_mb_uni_vc8\bin\release\dll;C:\libs\WpdPack_4_1_2\WpdPack\Lib"
+ 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="Fichiers sources"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\pcap2tzsp.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Fichiers d&apos;en-tête"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\pcap2tzsp.h"
+ >
+ </File>
+ <File
+ RelativePath=".\pcap2tzsp_win32_vs.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Fichiers de ressources"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/pcap2tzsp_linux.h b/pcap2tzsp_linux.h
new file mode 100644
index 0000000..6090929
--- /dev/null
+++ b/pcap2tzsp_linux.h
@@ -0,0 +1,55 @@
+/*
+
+ Pcap2tzsp allows to capture ethernet trafic and send all headers
+ to a defined host using the TaZmen Sniffing Protocol (TZSP).
+
+ Copyright (C) 2012 Ludovic Pouzenc <lpouzenc@gmail.com>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+ This file is part of Pcap2tzsp. See LICENCE file.
+*/
+
+#ifndef PCAP2TZSP_LINUX_H_INCLUDED
+#define PCAP2TZSP_LINUX_H_INCLUDED
+
+/* Basics */
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <signal.h>
+#include <string.h>
+#define my_snprintf snprintf/* snprintf "compatiblity" */
+
+/* Packet capture stuff */
+#include <pcap.h>
+
+/* UDP stuff */
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <unistd.h>
+#include <netdb.h> /* Name resolution */
+#define SOCKET int
+#define INVALID_SOCKET -1
+
+/* Time management (for bwlimit) */
+#include <time.h>
+
+/* Args parsing and basename() for usage */
+#include <getopt.h>
+#include <libgen.h>
+
+
+#endif // PCAP2TZSP_LINUX_H_INCLUDED
diff --git a/pcap2tzsp_win32_mingw.h b/pcap2tzsp_win32_mingw.h
new file mode 100644
index 0000000..3d8da83
--- /dev/null
+++ b/pcap2tzsp_win32_mingw.h
@@ -0,0 +1,57 @@
+/*
+
+ Pcap2tzsp allows to capture ethernet trafic and send all headers
+ to a defined host using the TaZmen Sniffing Protocol (TZSP).
+
+ Copyright (C) 2012 Ludovic Pouzenc <lpouzenc@gmail.com>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+ This file is part of Pcap2tzsp. See LICENCE file.
+*/
+
+#ifndef PCAP2TZSP_WIN32_MINGW_H_INCLUDED
+#define PCAP2TZSP_WIN32_MINGW_H_INCLUDED
+
+#define WINVER 0x0501
+
+/* Basics */
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <signal.h>
+#include <string.h>
+#define my_snprintf snprintf/* snprintf "compatiblity" */
+
+/* Packet capture stuff */
+#include <pcap.h>
+
+/* UDP stuff */
+#include <winsock2.h>
+#include <ws2tcpip.h>
+/* Constants missing in MINGW
+(I don't understand why and this will cause troubles) */
+#define AI_NUMERICSERV 0x00000008
+#define AI_ADDRCONFIG 0x00000400
+#define AI_V4MAPPED 0x00000800
+
+/* Time management (for bwlimit) */
+#include <time.h>
+
+/* Args parsing and basename() for usage */
+#include <getopt.h>
+#include <libgen.h>
+
+#endif // PCAP2TZSP_WIN32_MINGW_H_INCLUDED
diff --git a/pcap2tzsp_win32_vs.h b/pcap2tzsp_win32_vs.h
new file mode 100644
index 0000000..92d187e
--- /dev/null
+++ b/pcap2tzsp_win32_vs.h
@@ -0,0 +1,73 @@
+/*
+
+ Pcap2tzsp allows to capture ethernet trafic and send all headers
+ to a defined host using the TaZmen Sniffing Protocol (TZSP).
+
+ Copyright (C) 2012 Ludovic Pouzenc <lpouzenc@gmail.com>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+ This file is part of Pcap2tzsp. See LICENCE file.
+*/
+
+#ifndef PCAP2TZSP_WIN32_VS_H_INCLUDED
+#define PCAP2TZSP_WIN32_VS_H_INCLUDED
+
+/* Basics */
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h> /* Consider using msinttypes for Visual Studio */
+#include <signal.h>
+#include <string.h>
+#define my_snprintf sprintf_s /* snprintf "compatiblity" */
+
+/* Packet capture stuff */
+#include <pcap.h>
+
+/* UDP stuff */
+#include <winsock2.h>
+#include <ws2tcpip.h>
+
+/* Time management (for bwlimit) */
+#include <time.h>
+
+/* Args parsing and basename() for usage */
+#undef _UNICODE
+#include <getopt.h> /* Consider using getopt4win for WIN32 */
+
+/* Poor's men hand-written basename.
+With calloc() and this is diffent from POSIX basename() */
+char * basename(const char *path) {
+ errno_t e;
+ size_t len1, len2;
+ char filename[256], ext[8];
+ char *res=NULL;
+
+ e=_splitpath_s(path, NULL, 0, NULL, 0, filename, 256, ext, 8);
+ if (e != 0) {
+ res=strdup("");
+ } else {
+ len1=strlen(filename);
+ len2=strlen(ext);
+ res=calloc(len1+len2 + 1, sizeof(char));
+ if ( res != NULL ) {
+ strcpy_s(res, len1+1, filename);
+ strcpy_s(res+len1, len2+1, ext);
+ }
+ }
+ return res;
+}
+
+#endif // PCAP2TZSP_WIN32_VS_H_INCLUDED