diff --git a/common.cpp b/common.cpp index dcecb1b..ba746d4 100644 --- a/common.cpp +++ b/common.cpp @@ -86,10 +86,15 @@ u32_t get_true_random_number_nz() //nz for non-zero } return ret; } - +inline int is_big_endian() +{ + int i=1; + return ! *((char *)&i); +} u64_t ntoh64(u64_t a) { - if(__BYTE_ORDER == __LITTLE_ENDIAN) + static int big_endian=is_big_endian(); + if(!big_endian) { u32_t h=get_u64_h(a); u32_t l=get_u64_l(a); @@ -101,15 +106,7 @@ u64_t ntoh64(u64_t a) } u64_t hton64(u64_t a) { - if(__BYTE_ORDER == __LITTLE_ENDIAN) - { - u32_t h=get_u64_h(a); - u32_t l=get_u64_l(a); - return pack_u64(ntohl(l),ntohl(h)); - //return bswap_64( a); - } - else return a; - + return ntoh64(u64_t a); } void setnonblocking(int sock) { @@ -158,7 +155,7 @@ unsigned short csum(const unsigned short *ptr,int nbytes) {//works both for big int set_buf_size(int fd,int socket_buf_size,int force_socket_buf) { - if(force_socket_buf) + /*if(force_socket_buf) { if(setsockopt(fd, SOL_SOCKET, SO_SNDBUFFORCE, &socket_buf_size, sizeof(socket_buf_size))<0) { @@ -171,7 +168,7 @@ int set_buf_size(int fd,int socket_buf_size,int force_socket_buf) myexit(1); } } - else + else*/ { if(setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &socket_buf_size, sizeof(socket_buf_size))<0) { diff --git a/main.cpp b/main.cpp index e703d95..b4ea764 100755 --- a/main.cpp +++ b/main.cpp @@ -666,7 +666,7 @@ int client_event_loop() local_me.sin_addr.s_addr = local_ip_uint32; - if (bind(udp_fd, (struct sockaddr*) &local_me, slen) == -1) { + if (::bind(udp_fd, (struct sockaddr*) &local_me, slen) == -1) { mylog(log_fatal,"socket bind error\n"); myexit(1); } diff --git a/network.cpp b/network.cpp index 481b4a9..c6a96d9 100644 --- a/network.cpp +++ b/network.cpp @@ -455,6 +455,7 @@ void init_filter(int port) void remove_filter() { filter_port=0; +/* int dummy; int ret=setsockopt(raw_recv_fd, SOL_SOCKET, SO_DETACH_FILTER, &dummy, sizeof(dummy)); if (ret != 0) @@ -463,9 +464,12 @@ void remove_filter() //perror("filter"); //exit(-1); } +*/ } + int init_ifindex(const char * if_name,int &index) { +/* struct ifreq ifr; size_t if_name_len=strlen(if_name); if (if_name_len