mirror of
https://github.com/wangyu-/udp2raw.git
synced 2025-02-07 23:59:36 +08:00
removed --lower-level
This commit is contained in:
parent
f44003b801
commit
499599417a
2
common.h
2
common.h
@ -48,6 +48,8 @@
|
|||||||
#include <byteswap.h>
|
#include <byteswap.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
|
#include <my_ev.h>
|
||||||
|
|
||||||
#include<unordered_map>
|
#include<unordered_map>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
75
main.cpp
75
main.cpp
@ -474,81 +474,6 @@ int client_event_loop()
|
|||||||
conn_info.prepare();
|
conn_info.prepare();
|
||||||
packet_info_t &send_info=conn_info.raw_info.send_info;
|
packet_info_t &send_info=conn_info.raw_info.send_info;
|
||||||
packet_info_t &recv_info=conn_info.raw_info.recv_info;
|
packet_info_t &recv_info=conn_info.raw_info.recv_info;
|
||||||
|
|
||||||
if(lower_level)
|
|
||||||
{
|
|
||||||
if(lower_level_manual)
|
|
||||||
{
|
|
||||||
int index;
|
|
||||||
init_ifindex(if_name,index);
|
|
||||||
//init_ifindex(if_name);
|
|
||||||
memset(&send_info.addr_ll, 0, sizeof(send_info.addr_ll));
|
|
||||||
send_info.addr_ll.sll_family = AF_PACKET;
|
|
||||||
send_info.addr_ll.sll_ifindex =index;
|
|
||||||
send_info.addr_ll.sll_halen = ETHER_ADDR_LEN;
|
|
||||||
send_info.addr_ll.sll_protocol = htons(ETH_P_IP);
|
|
||||||
memcpy(&send_info.addr_ll.sll_addr, dest_hw_addr, ETHER_ADDR_LEN);
|
|
||||||
mylog(log_info,"we are running at lower-level (manual) mode\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
u32_t dest_ip;
|
|
||||||
string if_name_string;
|
|
||||||
string hw_string;
|
|
||||||
|
|
||||||
if(retry_on_error==0)
|
|
||||||
{
|
|
||||||
if(find_lower_level_info(remote_ip_uint32,dest_ip,if_name_string,hw_string)!=0)
|
|
||||||
{
|
|
||||||
mylog(log_fatal,"auto detect lower-level info failed for %s,specific it manually\n",remote_ip);
|
|
||||||
myexit(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int ok=0;
|
|
||||||
while(!ok)
|
|
||||||
{
|
|
||||||
if(find_lower_level_info(remote_ip_uint32,dest_ip,if_name_string,hw_string)!=0)
|
|
||||||
{
|
|
||||||
mylog(log_warn,"auto detect lower-level info failed for %s,retry in %d seconds\n",remote_ip,retry_on_error_interval);
|
|
||||||
sleep(retry_on_error_interval);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ok=1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mylog(log_info,"we are running at lower-level (auto) mode,%s %s %s\n",my_ntoa(dest_ip),if_name_string.c_str(),hw_string.c_str());
|
|
||||||
|
|
||||||
u32_t hw[6];
|
|
||||||
memset(hw, 0, sizeof(hw));
|
|
||||||
sscanf(hw_string.c_str(), "%x:%x:%x:%x:%x:%x",&hw[0], &hw[1], &hw[2],
|
|
||||||
&hw[3], &hw[4], &hw[5]);
|
|
||||||
|
|
||||||
mylog(log_warn,
|
|
||||||
"make sure this is correct: if_name=<%s> dest_mac_adress=<%02x:%02x:%02x:%02x:%02x:%02x> \n",
|
|
||||||
if_name_string.c_str(), hw[0], hw[1], hw[2], hw[3], hw[4], hw[5]);
|
|
||||||
for (int i = 0; i < 6; i++) {
|
|
||||||
dest_hw_addr[i] = uint8_t(hw[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//mylog(log_fatal,"--lower-level auto for client hasnt been implemented\n");
|
|
||||||
int index;
|
|
||||||
init_ifindex(if_name_string.c_str(),index);
|
|
||||||
|
|
||||||
memset(&send_info.addr_ll, 0, sizeof(send_info.addr_ll));
|
|
||||||
send_info.addr_ll.sll_family = AF_PACKET;
|
|
||||||
send_info.addr_ll.sll_ifindex = index;
|
|
||||||
send_info.addr_ll.sll_halen = ETHER_ADDR_LEN;
|
|
||||||
send_info.addr_ll.sll_protocol = htons(ETH_P_IP);
|
|
||||||
memcpy(&send_info.addr_ll.sll_addr, dest_hw_addr, ETHER_ADDR_LEN);
|
|
||||||
//mylog(log_info,"we are running at lower-level (manual) mode\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(source_ip_uint32==0)
|
if(source_ip_uint32==0)
|
||||||
{
|
{
|
||||||
|
3
makefile
3
makefile
@ -10,7 +10,8 @@ cc_arm= /toolchains/arm-2014.05/bin/arm-none-linux-gnueabi-g++
|
|||||||
#cc_bcm2708=/home/wangyu/raspberry/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++
|
#cc_bcm2708=/home/wangyu/raspberry/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++
|
||||||
FLAGS= -std=c++11 -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers ${OPT}
|
FLAGS= -std=c++11 -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers ${OPT}
|
||||||
|
|
||||||
COMMON=main.cpp lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp connection.cpp misc.cpp fd_manager.cpp -lpthread
|
COMMON=main.cpp lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp connection.cpp misc.cpp fd_manager.cpp -lpthread my_ev.cpp -isystem libev
|
||||||
|
|
||||||
SOURCES= $(COMMON) lib/aes_faster_c/aes.c lib/aes_faster_c/wrapper.c
|
SOURCES= $(COMMON) lib/aes_faster_c/aes.c lib/aes_faster_c/wrapper.c
|
||||||
SOURCES_TINY_AES= $(COMMON) lib/aes.c
|
SOURCES_TINY_AES= $(COMMON) lib/aes.c
|
||||||
SOURCES_AES_ACC=$(COMMON) $(wildcard lib/aes_acc/aes*.c)
|
SOURCES_AES_ACC=$(COMMON) $(wildcard lib/aes_acc/aes*.c)
|
||||||
|
2
misc.cpp
2
misc.cpp
@ -435,6 +435,7 @@ void process_arg(int argc, char *argv[]) //process all options
|
|||||||
case 'h':
|
case 'h':
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
|
assert(0==1);
|
||||||
auto_add_iptables_rule=1;
|
auto_add_iptables_rule=1;
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
@ -522,6 +523,7 @@ void process_arg(int argc, char *argv[]) //process all options
|
|||||||
}
|
}
|
||||||
else if(strcmp(long_options[option_index].name,"lower-level")==0)
|
else if(strcmp(long_options[option_index].name,"lower-level")==0)
|
||||||
{
|
{
|
||||||
|
assert(0==1);
|
||||||
process_lower_level_arg();
|
process_lower_level_arg();
|
||||||
//lower_level=1;
|
//lower_level=1;
|
||||||
//strcpy(lower_level_arg,optarg);
|
//strcpy(lower_level_arg,optarg);
|
||||||
|
16
my_ev.cpp
Normal file
16
my_ev.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#pragma GCC diagnostic push
|
||||||
|
|
||||||
|
#pragma GCC diagnostic ignored "-Wextra"
|
||||||
|
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||||
|
#pragma GCC diagnostic ignored "-Wcomment"
|
||||||
|
#pragma GCC diagnostic ignored "-Wparentheses"
|
||||||
|
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-value"
|
||||||
|
|
||||||
|
#pragma GCC diagnostic ignored "-Wall"
|
||||||
|
#pragma GCC diagnostic ignored "-W"
|
||||||
|
|
||||||
|
#include "my_ev_common.h"
|
||||||
|
#include "ev.c"
|
||||||
|
|
||||||
|
#pragma GCC diagnostic pop
|
5
my_ev.h
Normal file
5
my_ev.h
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "my_ev_common.h"
|
||||||
|
#include "ev.h"
|
||||||
|
|
5
my_ev_common.h
Normal file
5
my_ev_common.h
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
#define EV_STANDALONE 1
|
||||||
|
#define EV_COMMON void *data; unsigned long long u64;
|
||||||
|
#define EV_COMPAT3 0
|
||||||
|
//#define EV_VERIFY 2
|
Loading…
x
Reference in New Issue
Block a user