Added code to auto-genarate ac name from macadress of primary network interface.
FossilOrigin-Name: 02621cc08f5e0007b0274a9a4905ed76564c84c8fad7a68a5ad5d3cd7fe857a5
This commit is contained in:
parent
ed5d340bc6
commit
5ca3793054
@ -34,6 +34,8 @@
|
||||
|
||||
#include "socklist.h"
|
||||
|
||||
|
||||
|
||||
int ac_run();
|
||||
|
||||
int main (int argc, const char * argv[])
|
||||
@ -44,13 +46,11 @@ int main (int argc, const char * argv[])
|
||||
read_config("ac.conf");
|
||||
cw_log_debug_level=conf_debug_level;
|
||||
|
||||
cw_log(LOG_INFO,"Starting AC-Tube");
|
||||
cw_log(LOG_INFO,"Starting AC-Tube, Name=%s, ID=%s",conf_acname,conf_acid);
|
||||
|
||||
db_init();
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef WITH_DTLS
|
||||
dtls_init();
|
||||
#endif
|
||||
|
@ -29,9 +29,17 @@
|
||||
#include "cw_log.h"
|
||||
#include "cw_util.h"
|
||||
|
||||
uint8_t conf_macaddress[12];
|
||||
uint8_t conf_macaddress_len=0;
|
||||
|
||||
|
||||
char * conf_acname = NULL;
|
||||
int conf_acname_len = 0;
|
||||
|
||||
char * conf_acid = NULL;
|
||||
|
||||
char * conf_primary_if = NULL;
|
||||
|
||||
long conf_max_wtps = CONF_DEFAULT_MAXWTPS;
|
||||
char * conf_logfilename=CONF_DEFAULT_LOGFILENAME;
|
||||
struct sockaddr_storage * conf_salist=NULL;
|
||||
@ -85,12 +93,51 @@ cfg_bool_t conf_ignore_wtp_source_port = cfg_false;
|
||||
static int init_acname()
|
||||
{
|
||||
if (conf_acname == NULL){
|
||||
conf_acname=CONF_DEFAULT_ACNAME;
|
||||
conf_acname=malloc(strlen(CONF_DEFAULT_ACNAME)+strlen(conf_acid)+1);
|
||||
sprintf(conf_acname,"%s%s",CONF_DEFAULT_ACNAME,conf_acid);
|
||||
}
|
||||
conf_acname_len=strlen(conf_acname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int init_acid()
|
||||
{
|
||||
|
||||
if (conf_acid != NULL)
|
||||
return 1;
|
||||
|
||||
|
||||
#ifdef WITH_IPV6
|
||||
conf_primary_if = sock_get_primary_if(AF_INET6);
|
||||
if (!conf_primary_if)
|
||||
conf_primary_if = sock_get_primary_if(AF_INET);
|
||||
#else
|
||||
conf_primary_if = get_primary_if(AF_INET);
|
||||
#endif
|
||||
|
||||
if (!conf_primary_if){
|
||||
cw_log(LOG_ERR,"Fatal: Unable to detect primary interface, needed to set ac_id. Pleas use confiPleas u to set ac_id");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!sock_getifhwaddr(conf_primary_if,conf_macaddress,&conf_macaddress_len)){
|
||||
cw_log(LOG_ERR,"Fatal: Unable to detect link layer address for %s\n",conf_primary_if);
|
||||
return 0;
|
||||
};
|
||||
|
||||
int i;
|
||||
|
||||
|
||||
conf_acid = malloc(2*conf_macaddress_len+1);
|
||||
char *s = conf_acid;
|
||||
|
||||
for (i=0; i<conf_macaddress_len; i++){
|
||||
s+=sprintf(s,"%02X",conf_macaddress[i]);
|
||||
}
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
static int init_dtls()
|
||||
{
|
||||
if (conf_dtls_psk!=NULL){
|
||||
@ -379,6 +426,7 @@ static int conf_read_strings( cfg_t * cfg, char * name, char ***dst,int *len)
|
||||
int read_config(const char * filename){
|
||||
int i,n;
|
||||
|
||||
|
||||
cfg_opt_t opts[] = {
|
||||
CFG_STR_LIST("listen", "{}", CFGF_NONE),
|
||||
CFG_STR_LIST("mcast_groups", "{}", CFGF_NONE),
|
||||
@ -461,6 +509,9 @@ int read_config(const char * filename){
|
||||
|
||||
cfg_free(cfg);
|
||||
|
||||
if (!init_acid())
|
||||
return 0;
|
||||
|
||||
if (!init_acname() )
|
||||
return 0;
|
||||
|
||||
|
@ -62,6 +62,7 @@
|
||||
|
||||
|
||||
extern char * conf_acname;
|
||||
extern char * conf_acid;
|
||||
extern int conf_acname_len;
|
||||
extern long conf_max_wtps;
|
||||
extern char * conf_logfilename;
|
||||
|
Loading…
Reference in New Issue
Block a user