|
@ -171,9 +171,9 @@ static void help() { |
|
|
|
|
|
|
|
|
/* *************************************************** */ |
|
|
/* *************************************************** */ |
|
|
|
|
|
|
|
|
static int setOption(int optkey, char *optarg, edge_conf_t *ec, n2n_edge_t *eee) { |
|
|
static int setOption(int optkey, char *optargument, edge_conf_t *ec, n2n_edge_t *eee) { |
|
|
|
|
|
|
|
|
//traceEvent(TRACE_NORMAL, "Option %c = %s", optkey, optarg ? optarg : "");
|
|
|
//traceEvent(TRACE_NORMAL, "Option %c = %s", optkey, optargument ? optargument : "");
|
|
|
|
|
|
|
|
|
switch(optkey) { |
|
|
switch(optkey) { |
|
|
case'K': |
|
|
case'K': |
|
@ -182,7 +182,7 @@ static int setOption(int optkey, char *optarg, edge_conf_t *ec, n2n_edge_t *eee) |
|
|
fprintf(stderr, "Error: -K and -k options are mutually exclusive.\n"); |
|
|
fprintf(stderr, "Error: -K and -k options are mutually exclusive.\n"); |
|
|
exit(1); |
|
|
exit(1); |
|
|
} else { |
|
|
} else { |
|
|
strncpy(eee->keyschedule, optarg, N2N_PATHNAME_MAXLEN-1); |
|
|
strncpy(eee->keyschedule, optargument, N2N_PATHNAME_MAXLEN-1); |
|
|
/* strncpy does not add NULL if the source has no NULL. */ |
|
|
/* strncpy does not add NULL if the source has no NULL. */ |
|
|
eee->keyschedule[N2N_PATHNAME_MAXLEN-1] = 0; |
|
|
eee->keyschedule[N2N_PATHNAME_MAXLEN-1] = 0; |
|
|
|
|
|
|
|
@ -196,14 +196,14 @@ static int setOption(int optkey, char *optarg, edge_conf_t *ec, n2n_edge_t *eee) |
|
|
{ |
|
|
{ |
|
|
scan_address(ec->ip_addr, N2N_NETMASK_STR_SIZE, |
|
|
scan_address(ec->ip_addr, N2N_NETMASK_STR_SIZE, |
|
|
ec->ip_mode, N2N_IF_MODE_SIZE, |
|
|
ec->ip_mode, N2N_IF_MODE_SIZE, |
|
|
optarg); |
|
|
optargument); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
case 'c': /* community as a string */ |
|
|
case 'c': /* community as a string */ |
|
|
{ |
|
|
{ |
|
|
memset(eee->community_name, 0, N2N_COMMUNITY_SIZE); |
|
|
memset(eee->community_name, 0, N2N_COMMUNITY_SIZE); |
|
|
strncpy((char *)eee->community_name, optarg, N2N_COMMUNITY_SIZE); |
|
|
strncpy((char *)eee->community_name, optargument, N2N_COMMUNITY_SIZE); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -217,13 +217,13 @@ static int setOption(int optkey, char *optarg, edge_conf_t *ec, n2n_edge_t *eee) |
|
|
#ifndef WIN32 |
|
|
#ifndef WIN32 |
|
|
case 'u': /* unprivileged uid */ |
|
|
case 'u': /* unprivileged uid */ |
|
|
{ |
|
|
{ |
|
|
ec->userid = atoi(optarg); |
|
|
ec->userid = atoi(optargument); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
case 'g': /* unprivileged uid */ |
|
|
case 'g': /* unprivileged uid */ |
|
|
{ |
|
|
{ |
|
|
ec->groupid = atoi(optarg); |
|
|
ec->groupid = atoi(optargument); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
@ -238,13 +238,13 @@ static int setOption(int optkey, char *optarg, edge_conf_t *ec, n2n_edge_t *eee) |
|
|
|
|
|
|
|
|
case 'm' : /* TUNTAP MAC address */ |
|
|
case 'm' : /* TUNTAP MAC address */ |
|
|
{ |
|
|
{ |
|
|
strncpy(ec->device_mac,optarg,N2N_MACNAMSIZ); |
|
|
strncpy(ec->device_mac,optargument,N2N_MACNAMSIZ); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
case 'M' : /* TUNTAP MTU */ |
|
|
case 'M' : /* TUNTAP MTU */ |
|
|
{ |
|
|
{ |
|
|
ec->mtu = atoi(optarg); |
|
|
ec->mtu = atoi(optargument); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -255,7 +255,7 @@ static int setOption(int optkey, char *optarg, edge_conf_t *ec, n2n_edge_t *eee) |
|
|
exit(1); |
|
|
exit(1); |
|
|
} else { |
|
|
} else { |
|
|
traceEvent(TRACE_DEBUG, "encrypt_key = '%s'\n", ec->encrypt_key); |
|
|
traceEvent(TRACE_DEBUG, "encrypt_key = '%s'\n", ec->encrypt_key); |
|
|
ec->encrypt_key = strdup(optarg); |
|
|
ec->encrypt_key = strdup(optargument); |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
@ -269,8 +269,9 @@ static int setOption(int optkey, char *optarg, edge_conf_t *ec, n2n_edge_t *eee) |
|
|
case 'l': /* supernode-list */ |
|
|
case 'l': /* supernode-list */ |
|
|
{ |
|
|
{ |
|
|
if(eee->sn_num < N2N_EDGE_NUM_SUPERNODES) { |
|
|
if(eee->sn_num < N2N_EDGE_NUM_SUPERNODES) { |
|
|
strncpy((eee->sn_ip_array[eee->sn_num]), optarg, N2N_EDGE_SN_HOST_SIZE); |
|
|
strncpy((eee->sn_ip_array[eee->sn_num]), optargument, N2N_EDGE_SN_HOST_SIZE); |
|
|
traceEvent(TRACE_DEBUG, "Adding supernode[%u] = %s\n", (unsigned int)eee->sn_num, (eee->sn_ip_array[eee->sn_num])); |
|
|
traceEvent(TRACE_DEBUG, "Adding supernode[%u] = %s\n", |
|
|
|
|
|
(unsigned int)eee->sn_num, (eee->sn_ip_array[eee->sn_num])); |
|
|
++eee->sn_num; |
|
|
++eee->sn_num; |
|
|
} else { |
|
|
} else { |
|
|
fprintf(stderr, "Too many supernodes!\n"); |
|
|
fprintf(stderr, "Too many supernodes!\n"); |
|
@ -282,7 +283,7 @@ static int setOption(int optkey, char *optarg, edge_conf_t *ec, n2n_edge_t *eee) |
|
|
#if defined(N2N_CAN_NAME_IFACE) |
|
|
#if defined(N2N_CAN_NAME_IFACE) |
|
|
case 'd': /* TUNTAP name */ |
|
|
case 'd': /* TUNTAP name */ |
|
|
{ |
|
|
{ |
|
|
strncpy(ec->tuntap_dev_name, optarg, N2N_IFNAMSIZ); |
|
|
strncpy(ec->tuntap_dev_name, optargument, N2N_IFNAMSIZ); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
@ -295,13 +296,13 @@ static int setOption(int optkey, char *optarg, edge_conf_t *ec, n2n_edge_t *eee) |
|
|
|
|
|
|
|
|
case 'p': |
|
|
case 'p': |
|
|
{ |
|
|
{ |
|
|
ec->local_port = atoi(optarg); |
|
|
ec->local_port = atoi(optargument); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
case 't': |
|
|
case 't': |
|
|
{ |
|
|
{ |
|
|
ec->mgmt_port = atoi(optarg); |
|
|
ec->mgmt_port = atoi(optargument); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -310,7 +311,7 @@ static int setOption(int optkey, char *optarg, edge_conf_t *ec, n2n_edge_t *eee) |
|
|
if(0 != ec->got_s) { |
|
|
if(0 != ec->got_s) { |
|
|
traceEvent(TRACE_WARNING, "Multiple subnet masks supplied."); |
|
|
traceEvent(TRACE_WARNING, "Multiple subnet masks supplied."); |
|
|
} |
|
|
} |
|
|
strncpy(ec->netmask, optarg, N2N_NETMASK_STR_SIZE); |
|
|
strncpy(ec->netmask, optargument, N2N_NETMASK_STR_SIZE); |
|
|
ec->got_s = 1; |
|
|
ec->got_s = 1; |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|