sync more updates from mp

This commit is contained in:
wangyu-
2018-07-27 02:26:24 -05:00
parent 278ade5d36
commit 0980d89072
3 changed files with 93 additions and 50 deletions

View File

@@ -17,38 +17,63 @@
#include<unistd.h>
#include<errno.h>
#include <sys/epoll.h>
#include <sys/wait.h>
#include <sys/socket.h> //for socket ofcourse
#include <sys/types.h>
//#include <sys/epoll.h>
//#include <sys/wait.h>
#include <sys/stat.h>
#include <stdlib.h> //for exit(0);
#include <errno.h> //For errno - the error number
#include <netdb.h> // for gethostbyname()
//#include <netinet/tcp.h> //Provides declarations for tcp header
#include <netinet/udp.h>
//#include <netinet/ip.h> //Provides declarations for ip header
//#include <netinet/ip6.h>
#include <netinet/if_ether.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <byteswap.h>
#include <arpa/inet.h>
#include <linux/if_ether.h>
#include <linux/filter.h>
#include <sys/time.h>
#include <time.h>
#include <sys/timerfd.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <stdarg.h>
#include <assert.h>
#include <linux/if_packet.h>
#include <byteswap.h>
#include <pthread.h>
#if defined(UDP2RAW_MP)
#if !defined(__CYGWIN__) && !defined(__MINGW32__)
#include <pcap.h>
#else
#include <pcap_wrapper.h>
#define NO_LIBNET
#endif
#ifndef NO_LIBNET
#include <libnet.h>
#endif
#include <my_ev.h>
#else
#include <linux/if_ether.h>
#include <linux/filter.h>
#include <linux/if_packet.h>
#include <sys/epoll.h>
#include <sys/wait.h>
#include <netinet/if_ether.h>
#include <net/if.h>
#include <sys/timerfd.h>
#endif
#if defined(__MINGW32__)
#include <winsock2.h>
typedef unsigned char u_int8_t;
typedef unsigned short u_int16_t;
typedef unsigned int u_int32_t;
typedef int socklen_t;
#else
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
#include<unordered_map>
#include <fstream>
#include <string>
@@ -56,7 +81,6 @@
#include <map>
#include <set>
#include <list>
#include <type_traits>
using namespace std;
@@ -90,6 +114,27 @@ using namespace std;
#error "endian detection failed"
#endif
#if defined(__MINGW32__)
#define setsockopt(a,b,c,d,e) setsockopt(a,b,c,(const char *)(d),e)
#endif
char *get_sock_error();
int get_sock_errno();
#if defined(__MINGW32__)
typedef SOCKET my_fd_t;
inline int sock_close(my_fd_t fd)
{
return closesocket(fd);
}
#else
typedef int my_fd_t;
inline int sock_close(my_fd_t fd)
{
return close(fd);
}
#endif
typedef unsigned long long u64_t; //this works on most platform,avoid using the PRId64
typedef long long i64_t;
@@ -301,9 +346,6 @@ struct not_copy_able_t
};
const int max_data_len=1800;
const int buf_len=max_data_len+400;