mirror of
https://github.com/ntop/n2n.git
synced 2024-09-20 00:51:10 +02:00
b3f564e58c
* Add new file 'network_traffic_filter.c/.h" * Add feature to drop or accept specific packet transmit over edge network interface by rules. * fix CMakeLists.txt typo * Update Rule String Format * replace -F (filter) with -R (rule) for traffic restrictions. * Update edge help (-h) message. Update documents. * Pass Build on CircleCI and local Windows 10 VS2019 * Fix cmake build failed because of sn_selection * fix operate void* cause vs2016 build failed * Fix typo to pass build on windows. * add inttypes.h for n2n_typedefs.h to pass windows build * modify headers to pass build on windows.
83 lines
2.2 KiB
C
83 lines
2.2 KiB
C
/*
|
|
|
|
(C) 2007-09 - Luca Deri <deri@ntop.org>
|
|
|
|
*/
|
|
|
|
#ifndef _N2N_WIN32_H_
|
|
#define _N2N_WIN32_H_
|
|
|
|
#ifndef _CRT_SECURE_NO_WARNINGS
|
|
#define _CRT_SECURE_NO_WARNINGS
|
|
#endif
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#if defined(__MINGW32__)
|
|
/* should be defined here and before winsock gets included */
|
|
#ifndef _WIN32_WINNT
|
|
#define _WIN32_WINNT 0x501 //Otherwise the linker doesnt find getaddrinfo
|
|
#endif /* #ifndef _WIN32_WINNT */
|
|
#include <inttypes.h>
|
|
#endif /* #if defined(__MINGW32__) */
|
|
|
|
#include <winsock2.h>
|
|
#include <windows.h>
|
|
#include <winioctl.h>
|
|
|
|
|
|
#include "wintap.h"
|
|
|
|
#undef EAFNOSUPPORT
|
|
#define EAFNOSUPPORT WSAEAFNOSUPPORT
|
|
#define MAX(a,b) (a > b ? a : b)
|
|
#define MIN(a,b) (a < b ? a : b)
|
|
|
|
#define snprintf _snprintf
|
|
#define strdup _strdup
|
|
|
|
#define socklen_t int
|
|
|
|
|
|
/* ************************************* */
|
|
|
|
struct ip {
|
|
#if BYTE_ORDER == LITTLE_ENDIAN
|
|
u_char ip_hl:4, /* header length */
|
|
ip_v:4; /* version */
|
|
#else
|
|
u_char ip_v:4, /* version */
|
|
ip_hl:4; /* header length */
|
|
#endif
|
|
u_char ip_tos; /* type of service */
|
|
short ip_len; /* total length */
|
|
u_short ip_id; /* identification */
|
|
short ip_off; /* fragment offset field */
|
|
#define IP_DF 0x4000 /* dont fragment flag */
|
|
#define IP_MF 0x2000 /* more fragments flag */
|
|
#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
|
|
u_char ip_ttl; /* time to live */
|
|
u_char ip_p; /* protocol */
|
|
u_short ip_sum; /* checksum */
|
|
struct in_addr ip_src,ip_dst; /* source and dest address */
|
|
};
|
|
|
|
|
|
/* ************************************* */
|
|
|
|
typedef struct tuntap_dev {
|
|
HANDLE device_handle;
|
|
char *device_name;
|
|
char *ifName;
|
|
OVERLAPPED overlap_read, overlap_write;
|
|
n2n_mac_t mac_addr;
|
|
uint32_t ip_addr;
|
|
uint32_t device_mask;
|
|
unsigned int mtu;
|
|
} tuntap_dev;
|
|
|
|
#define index(a, b) strchr(a, b)
|
|
#define sleep(x) Sleep(x * 1000)
|
|
|
|
#endif
|