updates for tinyfec

This commit is contained in:
wangyu- 2018-08-20 07:58:32 -05:00
parent e7153d101d
commit 9a622ce463
5 changed files with 33 additions and 17 deletions

View File

@ -103,6 +103,7 @@ const int max_addr_len=100;
const int max_data_len=3600;
const int buf_len=max_data_len+200;
const int default_mtu=1250;
//const u32_t timer_interval=400;
////const u32_t conv_timeout=180000;
@ -228,7 +229,6 @@ struct address_t //TODO scope id
{
clear();
}*/
void clear()
{
memset(&inner,0,sizeof(inner));
@ -270,10 +270,16 @@ struct address_t //TODO scope id
char* get_str();
void to_str(char *);
inline u32_t get_type()
inline int is_vaild()
{
u32_t ret=((sockaddr*)&inner)->sa_family;
assert(ret==AF_INET||ret==AF_INET6);
return (ret==AF_INET||ret==AF_INET6);
}
inline u32_t get_type()
{
assert(is_vaild());
u32_t ret=((sockaddr*)&inner)->sa_family;
return ret;
}

View File

@ -26,7 +26,7 @@ extern int debug_fec_dec;
struct fec_parameter_t
{
int version=0;
int mtu=1250;
int mtu=default_mtu;
int queue_len=200;
int timeout=8*1000;
int mode=0;

View File

@ -98,6 +98,7 @@ void sigint_cb(struct ev_loop *l, ev_signal *w, int revents)
int main(int argc, char *argv[])
{
working_mode=tunnel_mode;
init_ws();
//unit_test();
@ -118,8 +119,6 @@ int main(int argc, char *argv[])
ev_signal_init(&signal_watcher_sigint, sigint_cb, SIGINT);
ev_signal_start(loop, &signal_watcher_sigint);
//working_mode=tunnel_mode;
assert(sizeof(u64_t)==8);
assert(sizeof(i64_t)==8);
assert(sizeof(u32_t)==4);
@ -143,13 +142,9 @@ int main(int argc, char *argv[])
}
}
process_arg(argc,argv);
delay_manager.set_capacity(delay_capacity);
//local_ip_uint32=inet_addr(local_ip);
//remote_ip_uint32=inet_addr(remote_ip);
sub_net_uint32=inet_addr(sub_net);// used only in tinyfecVPN
if(strlen(tun_dev)==0)
{

View File

@ -52,8 +52,10 @@ int keep_reconnect=0;
int tun_mtu=1500;
int mssfix=1;
int mssfix=default_mtu;
int manual_set_tun=0;
int persist_tun=0;
char rs_par_str[rs_str_len]="20:10";
@ -660,8 +662,10 @@ void process_arg(int argc, char *argv[])
{"sub-net", required_argument, 0, 1},
{"tun-dev", required_argument, 0, 1},
{"tun-mtu", required_argument, 0, 1},
{"disable-mssfix", no_argument, 0, 1},
{"mssfix", required_argument, 0, 1},
{"keep-reconnect", no_argument, 0, 1},
{"persist-tun", no_argument, 0, 1},
{"manual-set-tun", no_argument, 0, 1},
{"interval", required_argument, 0,'i'},
{NULL, 0, 0, 0}
};
@ -972,6 +976,16 @@ void process_arg(int argc, char *argv[])
keep_reconnect=1;
mylog(log_info,"keep_reconnect enabled\n");
}
else if(strcmp(long_options[option_index].name,"manual-set-tun")==0)
{
manual_set_tun=1;
mylog(log_info,"manual_set_tun enabled\n");
}
else if(strcmp(long_options[option_index].name,"persist-tun")==0)
{
persist_tun=1;
mylog(log_info,"persist_tun enabled\n");
}
else if(strcmp(long_options[option_index].name,"sub-net")==0)
{
sscanf(optarg,"%s",sub_net);
@ -983,8 +997,6 @@ void process_arg(int argc, char *argv[])
sscanf(optarg,"%s",tun_dev);
mylog(log_info,"tun_dev=%s\n",tun_dev);
mylog(log_info,"running at tun-dev mode\n");
working_mode=tun_dev_mode;
}
else if(strcmp(long_options[option_index].name,"tun-mtu")==0)
{
@ -996,10 +1008,10 @@ void process_arg(int argc, char *argv[])
sscanf(optarg,"%d",&header_overhead);
mylog(log_warn,"changed header_overhead,header_overhead=%d\n",header_overhead);
}
else if(strcmp(long_options[option_index].name,"disable-mssfix")==0)
else if(strcmp(long_options[option_index].name,"mssfix")==0)
{
mssfix=0;
mylog(log_warn,"mssfix disabled\n");
sscanf(optarg,"%d",&mssfix);
mylog(log_warn,"mssfix=%d\n",mssfix);
}
else
{

3
misc.h
View File

@ -55,6 +55,9 @@ extern int tun_mtu;
extern int mssfix;
extern int manual_set_tun;
extern int persist_tun;
int from_normal_to_fec(conn_info_t & conn_info,char *data,int len,int & out_n,char **&out_arr,int *&out_len,my_time_t *&out_delay);
int from_fec_to_normal(conn_info_t & conn_info,char *data,int len,int & out_n,char **&out_arr,int *&out_len,my_time_t *&out_delay);