mirror of
https://github.com/wangyu-/udp2raw.git
synced 2025-01-19 14:29:34 +08:00
deleted my exit
This commit is contained in:
parent
63e7dbb240
commit
2245fbdb54
19
common.cpp
19
common.cpp
@ -47,13 +47,6 @@ char * my_ntoa(uint32_t ip)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void myexit(int a)
|
|
||||||
{
|
|
||||||
if(enable_log_color)
|
|
||||||
printf(RESET);
|
|
||||||
exit(a);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void init_random_number_fd()
|
void init_random_number_fd()
|
||||||
@ -62,7 +55,7 @@ void init_random_number_fd()
|
|||||||
if(random_number_fd==-1)
|
if(random_number_fd==-1)
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"error open /dev/urandom\n");
|
mylog(log_fatal,"error open /dev/urandom\n");
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uint64_t get_true_random_number_64()
|
uint64_t get_true_random_number_64()
|
||||||
@ -112,13 +105,13 @@ void setnonblocking(int sock) {
|
|||||||
if (opts < 0) {
|
if (opts < 0) {
|
||||||
mylog(log_fatal,"fcntl(sock,GETFL)\n");
|
mylog(log_fatal,"fcntl(sock,GETFL)\n");
|
||||||
//perror("fcntl(sock,GETFL)");
|
//perror("fcntl(sock,GETFL)");
|
||||||
myexit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
opts = opts | O_NONBLOCK;
|
opts = opts | O_NONBLOCK;
|
||||||
if (fcntl(sock, F_SETFL, opts) < 0) {
|
if (fcntl(sock, F_SETFL, opts) < 0) {
|
||||||
mylog(log_fatal,"fcntl(sock,SETFL,opts)\n");
|
mylog(log_fatal,"fcntl(sock,SETFL,opts)\n");
|
||||||
//perror("fcntl(sock,SETFL,opts)");
|
//perror("fcntl(sock,SETFL,opts)");
|
||||||
myexit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -154,12 +147,12 @@ int set_buf_size(int fd)
|
|||||||
if(setsockopt(fd, SOL_SOCKET, SO_SNDBUFFORCE, &socket_buf_size, sizeof(socket_buf_size))<0)
|
if(setsockopt(fd, SOL_SOCKET, SO_SNDBUFFORCE, &socket_buf_size, sizeof(socket_buf_size))<0)
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"SO_SNDBUFFORCE fail\n");
|
mylog(log_fatal,"SO_SNDBUFFORCE fail\n");
|
||||||
myexit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if(setsockopt(fd, SOL_SOCKET, SO_RCVBUFFORCE, &socket_buf_size, sizeof(socket_buf_size))<0)
|
if(setsockopt(fd, SOL_SOCKET, SO_RCVBUFFORCE, &socket_buf_size, sizeof(socket_buf_size))<0)
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"SO_RCVBUFFORCE fail\n");
|
mylog(log_fatal,"SO_RCVBUFFORCE fail\n");
|
||||||
myexit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -168,7 +161,7 @@ void INThandler(int sig)
|
|||||||
{
|
{
|
||||||
if(enable_log_color)
|
if(enable_log_color)
|
||||||
printf(RESET);
|
printf(RESET);
|
||||||
myexit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int numbers_to_char(id_t id1,id_t id2,id_t id3,char * &data,int &len)
|
int numbers_to_char(id_t id1,id_t id2,id_t id3,char * &data,int &len)
|
||||||
|
80
main.cpp
80
main.cpp
@ -303,7 +303,7 @@ struct conn_info_t
|
|||||||
conn_info_t& operator=(const conn_info_t& b)
|
conn_info_t& operator=(const conn_info_t& b)
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"not allowed\n");
|
mylog(log_fatal,"not allowed\n");
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
~conn_info_t();
|
~conn_info_t();
|
||||||
@ -644,7 +644,7 @@ void server_clear_function(uint64_t u64)
|
|||||||
if (ret!=0)
|
if (ret!=0)
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"close fd %d failed !!!!\n",fd);
|
mylog(log_fatal,"close fd %d failed !!!!\n",fd);
|
||||||
myexit(-1); //this shouldnt happen
|
exit(-1); //this shouldnt happen
|
||||||
}
|
}
|
||||||
//mylog(log_fatal,"size:%d !!!!\n",conn_manager.udp_fd_mp.size());
|
//mylog(log_fatal,"size:%d !!!!\n",conn_manager.udp_fd_mp.size());
|
||||||
assert(conn_manager.udp_fd_mp.find(fd)!=conn_manager.udp_fd_mp.end());
|
assert(conn_manager.udp_fd_mp.find(fd)!=conn_manager.udp_fd_mp.end());
|
||||||
@ -892,7 +892,7 @@ int client_bind_to_a_new_port()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
mylog(log_fatal,"bind port fail\n");
|
mylog(log_fatal,"bind port fail\n");
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
return -1;////for compiler check
|
return -1;////for compiler check
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -912,7 +912,7 @@ int keep_connection_client(conn_info_t &conn_info) //for client
|
|||||||
if(fail_time_counter>max_fail_time)
|
if(fail_time_counter>max_fail_time)
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"max_fail_time exceed");
|
mylog(log_fatal,"max_fail_time exceed");
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
conn_info.anti_replay->re_init(); // this is not safe
|
conn_info.anti_replay->re_init(); // this is not safe
|
||||||
@ -1089,7 +1089,7 @@ int keep_connection_server_multi(conn_info_t &conn_info)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"this shouldnt happen!\n");
|
mylog(log_fatal,"this shouldnt happen!\n");
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -1176,7 +1176,7 @@ int set_timer(int epollfd,int &timer_fd)
|
|||||||
if((timer_fd=timerfd_create(CLOCK_MONOTONIC,TFD_NONBLOCK)) < 0)
|
if((timer_fd=timerfd_create(CLOCK_MONOTONIC,TFD_NONBLOCK)) < 0)
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"timer_fd create error\n");
|
mylog(log_fatal,"timer_fd create error\n");
|
||||||
myexit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
its.it_interval.tv_sec=(timer_interval/1000);
|
its.it_interval.tv_sec=(timer_interval/1000);
|
||||||
its.it_interval.tv_nsec=(timer_interval%1000)*1000ll*1000ll;
|
its.it_interval.tv_nsec=(timer_interval%1000)*1000ll*1000ll;
|
||||||
@ -1190,7 +1190,7 @@ int set_timer(int epollfd,int &timer_fd)
|
|||||||
ret=epoll_ctl(epollfd, EPOLL_CTL_ADD, timer_fd, &ev);
|
ret=epoll_ctl(epollfd, EPOLL_CTL_ADD, timer_fd, &ev);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
mylog(log_fatal,"epoll_ctl return %d\n", ret);
|
mylog(log_fatal,"epoll_ctl return %d\n", ret);
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1206,7 +1206,7 @@ int set_timer_server(int epollfd,int &timer_fd)
|
|||||||
if((timer_fd=timerfd_create(CLOCK_MONOTONIC,TFD_NONBLOCK)) < 0)
|
if((timer_fd=timerfd_create(CLOCK_MONOTONIC,TFD_NONBLOCK)) < 0)
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"timer_fd create error\n");
|
mylog(log_fatal,"timer_fd create error\n");
|
||||||
myexit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
its.it_interval.tv_sec=(timer_interval/1000);
|
its.it_interval.tv_sec=(timer_interval/1000);
|
||||||
its.it_interval.tv_nsec=(timer_interval%1000)*1000ll*1000ll;
|
its.it_interval.tv_nsec=(timer_interval%1000)*1000ll*1000ll;
|
||||||
@ -1220,7 +1220,7 @@ int set_timer_server(int epollfd,int &timer_fd)
|
|||||||
ret=epoll_ctl(epollfd, EPOLL_CTL_ADD, timer_fd, &ev);
|
ret=epoll_ctl(epollfd, EPOLL_CTL_ADD, timer_fd, &ev);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
mylog(log_fatal,"epoll_ctl return %d\n", ret);
|
mylog(log_fatal,"epoll_ctl return %d\n", ret);
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1641,12 +1641,12 @@ int server_on_raw_pre_ready(conn_info_t &conn_info,char * data,int data_len)
|
|||||||
if(!conn_manager.exist(ori_conn_info.raw_info.recv_info.src_ip,ori_conn_info.raw_info.recv_info.src_port))//TODO remove this
|
if(!conn_manager.exist(ori_conn_info.raw_info.recv_info.src_ip,ori_conn_info.raw_info.recv_info.src_port))//TODO remove this
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"[%s]this shouldnt happen\n",ip_port);
|
mylog(log_fatal,"[%s]this shouldnt happen\n",ip_port);
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
if(!conn_manager.exist(conn_info.raw_info.recv_info.src_ip,conn_info.raw_info.recv_info.src_port))//TODO remove this
|
if(!conn_manager.exist(conn_info.raw_info.recv_info.src_ip,conn_info.raw_info.recv_info.src_port))//TODO remove this
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"[%s]this shouldnt happen2\n",ip_port);
|
mylog(log_fatal,"[%s]this shouldnt happen2\n",ip_port);
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
conn_info_t *&p_ori=conn_manager.find_insert_p(ori_conn_info.raw_info.recv_info.src_ip,ori_conn_info.raw_info.recv_info.src_port);
|
conn_info_t *&p_ori=conn_manager.find_insert_p(ori_conn_info.raw_info.recv_info.src_ip,ori_conn_info.raw_info.recv_info.src_port);
|
||||||
conn_info_t *&p=conn_manager.find_insert_p(conn_info.raw_info.recv_info.src_ip,conn_info.raw_info.recv_info.src_port);
|
conn_info_t *&p=conn_manager.find_insert_p(conn_info.raw_info.recv_info.src_ip,conn_info.raw_info.recv_info.src_port);
|
||||||
@ -1677,7 +1677,7 @@ int server_on_raw_pre_ready(conn_info_t &conn_info,char * data,int data_len)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"[%s]this should never happen\n",ip_port);
|
mylog(log_fatal,"[%s]this should never happen\n",ip_port);
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2215,7 +2215,7 @@ int client_event_loop()
|
|||||||
if(get_src_adress(source_address_uint32)!=0)
|
if(get_src_adress(source_address_uint32)!=0)
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"the trick to auto get source ip failed,you should specific an ip by --source-ip\n");
|
mylog(log_fatal,"the trick to auto get source ip failed,you should specific an ip by --source-ip\n");
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
in_addr tmp;
|
in_addr tmp;
|
||||||
@ -2227,7 +2227,7 @@ int client_event_loop()
|
|||||||
if(try_to_list_and_bind(source_port)!=0)
|
if(try_to_list_and_bind(source_port)!=0)
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"bind to source_port:%d fail\n ",source_port);
|
mylog(log_fatal,"bind to source_port:%d fail\n ",source_port);
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
send_info.src_port=source_port;
|
send_info.src_port=source_port;
|
||||||
send_info.src_ip = source_address_uint32;
|
send_info.src_ip = source_address_uint32;
|
||||||
@ -2260,7 +2260,7 @@ int client_event_loop()
|
|||||||
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");
|
mylog(log_fatal,"socket bind error\n");
|
||||||
//perror("socket bind error");
|
//perror("socket bind error");
|
||||||
myexit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
setnonblocking(udp_fd);
|
setnonblocking(udp_fd);
|
||||||
epollfd = epoll_create1(0);
|
epollfd = epoll_create1(0);
|
||||||
@ -2269,7 +2269,7 @@ int client_event_loop()
|
|||||||
struct epoll_event ev, events[max_events];
|
struct epoll_event ev, events[max_events];
|
||||||
if (epollfd < 0) {
|
if (epollfd < 0) {
|
||||||
mylog(log_fatal,"epoll return %d\n", epollfd);
|
mylog(log_fatal,"epoll return %d\n", epollfd);
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ev.events = EPOLLIN;
|
ev.events = EPOLLIN;
|
||||||
@ -2277,7 +2277,7 @@ int client_event_loop()
|
|||||||
ret = epoll_ctl(epollfd, EPOLL_CTL_ADD, udp_fd, &ev);
|
ret = epoll_ctl(epollfd, EPOLL_CTL_ADD, udp_fd, &ev);
|
||||||
if (ret!=0) {
|
if (ret!=0) {
|
||||||
mylog(log_fatal,"add udp_listen_fd error\n");
|
mylog(log_fatal,"add udp_listen_fd error\n");
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
ev.events = EPOLLIN;
|
ev.events = EPOLLIN;
|
||||||
ev.data.u64 = raw_recv_fd;
|
ev.data.u64 = raw_recv_fd;
|
||||||
@ -2285,7 +2285,7 @@ int client_event_loop()
|
|||||||
ret = epoll_ctl(epollfd, EPOLL_CTL_ADD, raw_recv_fd, &ev);
|
ret = epoll_ctl(epollfd, EPOLL_CTL_ADD, raw_recv_fd, &ev);
|
||||||
if (ret!= 0) {
|
if (ret!= 0) {
|
||||||
mylog(log_fatal,"add raw_fd error\n");
|
mylog(log_fatal,"add raw_fd error\n");
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
////add_timer for fake_tcp_keep_connection_client
|
////add_timer for fake_tcp_keep_connection_client
|
||||||
@ -2304,7 +2304,7 @@ int client_event_loop()
|
|||||||
int nfds = epoll_wait(epollfd, events, max_events, 180 * 1000);
|
int nfds = epoll_wait(epollfd, events, max_events, 180 * 1000);
|
||||||
if (nfds < 0) { //allow zero
|
if (nfds < 0) { //allow zero
|
||||||
mylog(log_fatal,"epoll_wait return %d\n", nfds);
|
mylog(log_fatal,"epoll_wait return %d\n", nfds);
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
int idx;
|
int idx;
|
||||||
for (idx = 0; idx < nfds; ++idx) {
|
for (idx = 0; idx < nfds; ++idx) {
|
||||||
@ -2327,7 +2327,7 @@ int client_event_loop()
|
|||||||
if ((recv_len = recvfrom(udp_fd, buf, buf_len, 0,
|
if ((recv_len = recvfrom(udp_fd, buf, buf_len, 0,
|
||||||
(struct sockaddr *) &udp_new_addr_in, &slen)) == -1) {
|
(struct sockaddr *) &udp_new_addr_in, &slen)) == -1) {
|
||||||
mylog(log_error,"recv_from error,this shouldnt happen at client\n");
|
mylog(log_error,"recv_from error,this shouldnt happen at client\n");
|
||||||
myexit(1);
|
exit(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
mylog(log_trace,"Received packet from %s:%d,len: %d\n", inet_ntoa(udp_new_addr_in.sin_addr),
|
mylog(log_trace,"Received packet from %s:%d,len: %d\n", inet_ntoa(udp_new_addr_in.sin_addr),
|
||||||
@ -2422,7 +2422,7 @@ int server_event_loop()
|
|||||||
if (bind(bind_fd, (struct sockaddr*)&temp_bind_addr, sizeof(temp_bind_addr)) !=0)
|
if (bind(bind_fd, (struct sockaddr*)&temp_bind_addr, sizeof(temp_bind_addr)) !=0)
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"bind fail\n");
|
mylog(log_fatal,"bind fail\n");
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(raw_mode==mode_faketcp)
|
if(raw_mode==mode_faketcp)
|
||||||
@ -2431,7 +2431,7 @@ int server_event_loop()
|
|||||||
if(listen(bind_fd, SOMAXCONN) != 0 )
|
if(listen(bind_fd, SOMAXCONN) != 0 )
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"listen fail\n");
|
mylog(log_fatal,"listen fail\n");
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2446,7 +2446,7 @@ int server_event_loop()
|
|||||||
struct epoll_event ev, events[max_events];
|
struct epoll_event ev, events[max_events];
|
||||||
if (epollfd < 0) {
|
if (epollfd < 0) {
|
||||||
mylog(log_fatal,"epoll return %d\n", epollfd);
|
mylog(log_fatal,"epoll return %d\n", epollfd);
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ev.events = EPOLLIN;
|
ev.events = EPOLLIN;
|
||||||
@ -2455,7 +2455,7 @@ int server_event_loop()
|
|||||||
ret = epoll_ctl(epollfd, EPOLL_CTL_ADD, raw_recv_fd, &ev);
|
ret = epoll_ctl(epollfd, EPOLL_CTL_ADD, raw_recv_fd, &ev);
|
||||||
if (ret!= 0) {
|
if (ret!= 0) {
|
||||||
mylog(log_fatal,"add raw_fd error\n");
|
mylog(log_fatal,"add raw_fd error\n");
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
int timer_fd;
|
int timer_fd;
|
||||||
|
|
||||||
@ -2466,7 +2466,7 @@ int server_event_loop()
|
|||||||
int nfds = epoll_wait(epollfd, events, max_events, 180 * 1000);
|
int nfds = epoll_wait(epollfd, events, max_events, 180 * 1000);
|
||||||
if (nfds < 0) { //allow zero
|
if (nfds < 0) { //allow zero
|
||||||
mylog(log_fatal,"epoll_wait return %d\n", nfds);
|
mylog(log_fatal,"epoll_wait return %d\n", nfds);
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
int idx;
|
int idx;
|
||||||
for (idx = 0; idx < nfds; ++idx)
|
for (idx = 0; idx < nfds; ++idx)
|
||||||
@ -2500,12 +2500,12 @@ int server_event_loop()
|
|||||||
if(!conn_manager.exist(ip,port))//TODO remove this for peformance
|
if(!conn_manager.exist(ip,port))//TODO remove this for peformance
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"ip port no longer exits 1!!!this shouldnt happen\n");
|
mylog(log_fatal,"ip port no longer exits 1!!!this shouldnt happen\n");
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
if (p_conn_info->state.server_current_state != server_ready) //TODO remove this for peformance
|
if (p_conn_info->state.server_current_state != server_ready) //TODO remove this for peformance
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"p_conn_info->state.server_current_state!=server_ready!!!this shouldnt happen\n");
|
mylog(log_fatal,"p_conn_info->state.server_current_state!=server_ready!!!this shouldnt happen\n");
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
//conn_info_t &conn_info=conn_manager.find(ip,port);
|
//conn_info_t &conn_info=conn_manager.find(ip,port);
|
||||||
keep_connection_server_multi(*p_conn_info);
|
keep_connection_server_multi(*p_conn_info);
|
||||||
@ -2529,13 +2529,13 @@ int server_event_loop()
|
|||||||
if(!conn_manager.exist(ip,port))//TODO remove this for peformance
|
if(!conn_manager.exist(ip,port))//TODO remove this for peformance
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"ip port no longer exits 2!!!this shouldnt happen\n", nfds);
|
mylog(log_fatal,"ip port no longer exits 2!!!this shouldnt happen\n", nfds);
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p_conn_info->state.server_current_state!=server_ready)//TODO remove this for peformance
|
if(p_conn_info->state.server_current_state!=server_ready)//TODO remove this for peformance
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"p_conn_info->state.server_current_state!=server_ready!!!this shouldnt happen\n", nfds);
|
mylog(log_fatal,"p_conn_info->state.server_current_state!=server_ready!!!this shouldnt happen\n", nfds);
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
conn_info_t &conn_info=*p_conn_info;
|
conn_info_t &conn_info=*p_conn_info;
|
||||||
@ -2643,7 +2643,7 @@ void process_arg(int argc, char *argv[])
|
|||||||
if(strcmp(argv[i],"-h")==0||strcmp(argv[i],"--help")==0)
|
if(strcmp(argv[i],"-h")==0||strcmp(argv[i],"--help")==0)
|
||||||
{
|
{
|
||||||
print_help();
|
print_help();
|
||||||
myexit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i < argc; i++)
|
for (i = 0; i < argc; i++)
|
||||||
@ -2659,7 +2659,7 @@ void process_arg(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
log_bare(log_fatal,"invalid log_level\n");
|
log_bare(log_fatal,"invalid log_level\n");
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2679,7 +2679,7 @@ void process_arg(int argc, char *argv[])
|
|||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
{
|
{
|
||||||
print_help();
|
print_help();
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int no_l = 1, no_r = 1;
|
int no_l = 1, no_r = 1;
|
||||||
@ -2713,7 +2713,7 @@ void process_arg(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"-s /-c has already been set,-s option conflict\n");
|
mylog(log_fatal,"-s /-c has already been set,-s option conflict\n");
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
@ -2724,7 +2724,7 @@ void process_arg(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"-s /-c has already been set,-c option conflict\n");
|
mylog(log_fatal,"-s /-c has already been set,-c option conflict\n");
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
@ -2763,7 +2763,7 @@ void process_arg(int argc, char *argv[])
|
|||||||
if(i==mode_end)
|
if(i==mode_end)
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"no such raw_mode %s\n",optarg);
|
mylog(log_fatal,"no such raw_mode %s\n",optarg);
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(strcmp(long_options[option_index].name,"auth-mode")==0)
|
else if(strcmp(long_options[option_index].name,"auth-mode")==0)
|
||||||
@ -2779,7 +2779,7 @@ void process_arg(int argc, char *argv[])
|
|||||||
if(i==auth_end)
|
if(i==auth_end)
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"no such auth_mode %s\n",optarg);
|
mylog(log_fatal,"no such auth_mode %s\n",optarg);
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(strcmp(long_options[option_index].name,"cipher-mode")==0)
|
else if(strcmp(long_options[option_index].name,"cipher-mode")==0)
|
||||||
@ -2795,7 +2795,7 @@ void process_arg(int argc, char *argv[])
|
|||||||
if(i==cipher_end)
|
if(i==cipher_end)
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"no such cipher_mode %s\n",optarg);
|
mylog(log_fatal,"no such cipher_mode %s\n",optarg);
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(strcmp(long_options[option_index].name,"log-level")==0)
|
else if(strcmp(long_options[option_index].name,"log-level")==0)
|
||||||
@ -2824,7 +2824,7 @@ void process_arg(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"sock-buf value must be between 1 and 10240 (kbyte) \n");
|
mylog(log_fatal,"sock-buf value must be between 1 and 10240 (kbyte) \n");
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(strcmp(long_options[option_index].name,"seq-mode")==0)
|
else if(strcmp(long_options[option_index].name,"seq-mode")==0)
|
||||||
@ -2836,7 +2836,7 @@ void process_arg(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"seq_mode value must be 0,1,or 2 \n");
|
mylog(log_fatal,"seq_mode value must be 0,1,or 2 \n");
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2858,7 +2858,7 @@ void process_arg(int argc, char *argv[])
|
|||||||
if (no_l || no_r||program_mode==0)
|
if (no_l || no_r||program_mode==0)
|
||||||
{
|
{
|
||||||
print_help();
|
print_help();
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
mylog(log_info,"important variables: ", argc);
|
mylog(log_info,"important variables: ", argc);
|
||||||
|
12
network.cpp
12
network.cpp
@ -153,13 +153,13 @@ int init_raw_socket()
|
|||||||
if(raw_send_fd == -1) {
|
if(raw_send_fd == -1) {
|
||||||
mylog(log_fatal,"Failed to create raw_send_fd\n");
|
mylog(log_fatal,"Failed to create raw_send_fd\n");
|
||||||
//perror("Failed to create raw_send_fd");
|
//perror("Failed to create raw_send_fd");
|
||||||
myexit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(setsockopt(raw_send_fd, SOL_SOCKET, SO_SNDBUFFORCE, &socket_buf_size, sizeof(socket_buf_size))<0)
|
if(setsockopt(raw_send_fd, SOL_SOCKET, SO_SNDBUFFORCE, &socket_buf_size, sizeof(socket_buf_size))<0)
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"SO_SNDBUFFORCE fail\n");
|
mylog(log_fatal,"SO_SNDBUFFORCE fail\n");
|
||||||
myexit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
//raw_fd = socket(AF_PACKET, SOCK_DGRAM, htons(ETH_P_ALL));
|
//raw_fd = socket(AF_PACKET, SOCK_DGRAM, htons(ETH_P_ALL));
|
||||||
|
|
||||||
@ -168,13 +168,13 @@ int init_raw_socket()
|
|||||||
if(raw_recv_fd == -1) {
|
if(raw_recv_fd == -1) {
|
||||||
mylog(log_fatal,"Failed to create raw_recv_fd\n");
|
mylog(log_fatal,"Failed to create raw_recv_fd\n");
|
||||||
//perror("");
|
//perror("");
|
||||||
myexit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(setsockopt(raw_recv_fd, SOL_SOCKET, SO_RCVBUFFORCE, &socket_buf_size, sizeof(socket_buf_size))<0)
|
if(setsockopt(raw_recv_fd, SOL_SOCKET, SO_RCVBUFFORCE, &socket_buf_size, sizeof(socket_buf_size))<0)
|
||||||
{
|
{
|
||||||
mylog(log_fatal,"SO_RCVBUFFORCE fail\n");
|
mylog(log_fatal,"SO_RCVBUFFORCE fail\n");
|
||||||
myexit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//IP_HDRINCL to tell the kernel that headers are included in the packet
|
//IP_HDRINCL to tell the kernel that headers are included in the packet
|
||||||
@ -184,7 +184,7 @@ int init_raw_socket()
|
|||||||
if (setsockopt (raw_send_fd, IPPROTO_IP, IP_HDRINCL, val, sizeof (one)) < 0) {
|
if (setsockopt (raw_send_fd, IPPROTO_IP, IP_HDRINCL, val, sizeof (one)) < 0) {
|
||||||
mylog(log_fatal,"Error setting IP_HDRINCL %d\n",errno);
|
mylog(log_fatal,"Error setting IP_HDRINCL %d\n",errno);
|
||||||
//perror("Error setting IP_HDRINCL");
|
//perror("Error setting IP_HDRINCL");
|
||||||
myexit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
setnonblocking(raw_send_fd); //not really necessary
|
setnonblocking(raw_send_fd); //not really necessary
|
||||||
@ -232,7 +232,7 @@ void init_filter(int port)
|
|||||||
{
|
{
|
||||||
mylog(log_fatal,"error set fiter\n");
|
mylog(log_fatal,"error set fiter\n");
|
||||||
//perror("filter");
|
//perror("filter");
|
||||||
myexit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void remove_filter()
|
void remove_filter()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user