#include #include #include #include //#include #include #include #include #include #include "cw/capwap.h" #include "cw/log.h" #include "cw/dbg.h" #include "cw/cw_util.h" #include "wtp_conf.h" #include "cw/sock.h" #include "cw/log.h" #include "cw/bstr.h" #include "cw/vendors.h" char * conf_primary_if=0; char * conf_ip=0; char * conf_wtpname=0; char * conf_dtls_psk=0; char * conf_sslkeyfilename=0; char * conf_sslcertfilename=0; char * conf_sslkeypass=0; char * conf_preferred_ac=0; char * conf_dtls_cipher=0; struct sockaddr_storage * conf_preferred_ac_sa=0; char ** conf_ac_list; int conf_ac_list_len; char * conf_control_port=0; uint8_t conf_macaddress[12]; uint8_t conf_macaddress_len=0; long conf_max_discovery_interval=CONF_DEFAULT_MAX_DISCOVERY_INTERVAL; long conf_discovery_interval=CONF_DEFAULT_DISCOVERY_INTERVAL; long conf_silent_interval=CONF_DEFAULT_SILENT_INTERVAL; long conf_max_discoveries=CONF_DEFAULT_MAX_DISCOVERIES; long conf_echo_interval=CONF_DEFAULT_ECHO_INTERVAL; long conf_max_retransmit=CONF_DEFAULT_MAX_RETRANSMIT; long conf_retransmit_interval=CONF_DEFAULT_RETRANSMIT_INTERVAL; //long conf_dbg_level=CONF_DEFAULT_DEBUG_LEVEL; int conf_mtu_discovery=CONF_DEFAULT_MTU_DISCOVERY; int conf_mtu=0; uint32_t conf_vendor_id; uint32_t * conf_bootloader_vendor_id; uint8_t * conf_bootloader_version; uint32_t * conf_software_vendor_id; uint8_t * conf_software_version; uint32_t * conf_hardware_vendor_id; uint8_t * conf_hardware_version; uint8_t * conf_model_no; uint8_t * conf_serial_no; bstr_t conf_board_id; bstr_t conf_board_revision; LONGSTRS conf_timer_cfgstrs[] = { {"max_discovery_interval",&conf_max_discovery_interval}, {"discovery_interval",&conf_discovery_interval}, {"max_discoveries",&conf_max_discoveries}, {"silent_interval",&conf_silent_interval}, {0,0} }; int wtpconf_primary_if() { if (!conf_primary_if ) { conf_primary_if = sock_get_primary_if(AF_INET6); if (!conf_primary_if) conf_primary_if = sock_get_primary_if(AF_INET); } if (!conf_primary_if){ cw_log(LOG_ERR,"Fatal: Unable to detect primary interface"); 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:",conf_primary_if, strerror(errno)); return 0; }; cw_dbg(DBG_INFO, "Primary interface: %s, mac address: %s.", conf_primary_if, sock_hwaddr2str(conf_macaddress,conf_macaddress_len) ); return 1; } int wtpconf_name() { if (conf_wtpname) return 1; char name[64]; sprintf(name,"WTP%s",sock_hwaddr2idstr(conf_macaddress,conf_macaddress_len)); conf_wtpname = (char*)cw_setstr((uint8_t**)&conf_wtpname,(uint8_t*)name,strlen(name)); if (!conf_wtpname) return 0; cw_dbg(DBG_INFO,"Using self assigned wtp name: %s",conf_wtpname); return 1; } #include char * default_ac_list[] = { // "192.168.0.255", "255.255.255.255" // "224.0.1.140", //"192.168.0.77" //"192.168.56.99" }; int wtpconf_ac_list() { if (conf_ac_list) return 1; int i; int len=0; int bcrc; struct sockaddr_storage bcaddr; bcrc = sock_getifaddr(conf_primary_if,AF_INET,IFF_BROADCAST,(struct sockaddr*)&bcaddr); if (bcrc) len++; int deflen = sizeof(default_ac_list)/sizeof(char*); len += deflen; conf_ac_list = malloc(len*sizeof(char*)); if (!conf_ac_list) return 0; for (i=0; i0) { conf_ac_list=malloc(sizeof(char*)*n); if (!conf_ac_list) goto errX; conf_ac_list_len=0; for (i=0; i