summaryrefslogtreecommitdiff
path: root/win32/libnet.h
blob: 2b1aa10da427ee07a072e62c166a5b523bd2f9a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
 *  $Id: libnet.h,v 1.7 2004/01/03 20:31:00 mike Exp $
 *
 *  libnet.h - Network routine library header file for Win32 VC++
 *
 *  Copyright (c) 1998 - 2004 Mike D. Schiffman <mike@infonexus.com>
 *  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.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
 *
 */

#ifdef _WIN32

#ifndef __LIBNET_H
#define __LIBNET_H

#include <winsock2.h>
#include <windows.h>
#include <time.h>
#include "pcap.h"


#ifdef __cplusplus
extern "C" {
#endif

/* __WIN32__ is NOT a predefined MACRO, use _WIN32
 * __CYGWIN__ is defined within the cygwin environment.
 */ 
#ifndef __WIN32__
#define __WIN32__ _WIN32
#endif

#define LIBNET_LIL_ENDIAN 1
#define HAVE_CONFIG_H 1

/* TODO Definitions and includes below should be in a private header, libnet src needs them, libnet
   library users don't (and they have negative side effects).
   */
/* Some UNIX to Win32 conversions */
#define snprintf _snprintf 
#define strdup _strdup
#define write _write
#define open _open
#define random rand
#define close closesocket
#define __func__ __FUNCTION__
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif

/* __FUNCTION__ available in VC ++ 7.0 (.NET) and greater */
#if _MSC_VER < 1300
#define __FUNCTION__ __FILE__
#endif

/* the following is only supported by MSVC and not by MinGW/MSys environments */
#ifdef _MSC_VER
#pragma comment (lib,"ws2_32")    /* Winsock 2 */
#pragma comment (lib,"iphlpapi")  /* IP Helper */
#pragma comment (lib,"wpcap")     /* Winpcap   */
#pragma comment (lib,"packet")   

#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#else
#include <unistd.h>
#endif

/* FIXME this needs manual update during release packaging. */
#define LIBNET_VERSION  "1.1.6"

/* To use Win32 native versions */
#define WPCAP 1
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <signal.h>
#include <stdint.h>
#include <stdlib.h>

#include <sys/stat.h>
#include <sys/types.h>
#include <ctype.h>

#include <errno.h>
#include <stdarg.h>

#define LIBNET_API __declspec(dllexport)

#include "libnet/libnet-macros.h"
#include "libnet/libnet-headers.h"
#include "libnet/libnet-structures.h"
#include "libnet/libnet-asn1.h"
#include "libnet/libnet-functions.h"

#ifdef __cplusplus
}
#endif

#endif  /* __LIBNET_H */

#endif