mirror of
https://github.com/wangyu-/udp2raw.git
synced 2025-02-07 23:59:36 +08:00
remove non-portable code on mac
This commit is contained in:
parent
5d4ea64d00
commit
2198e23026
23
common.cpp
23
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)
|
||||
{
|
||||
|
2
main.cpp
2
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);
|
||||
}
|
||||
|
@ -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<sizeof(ifr.ifr_name)) {
|
||||
@ -482,6 +486,7 @@ int init_ifindex(const char * if_name,int &index)
|
||||
}
|
||||
index=ifr.ifr_ifindex;
|
||||
mylog(log_info,"ifname:%s ifindex:%d\n",if_name,index);
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
bool interface_has_arp(const char * interface) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user