<commit_before>/*
    This file is part of actube.

    libcapwap is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    libcapwap is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
*/

#include <stdlib.h>
#include <string.h>
#include <sys/utsname.h>


#include "cw/capwap.h"
#include "cw/sock.h"

#include "cw/log.h"
#include "cw/dbg.h"
#include "cw/cw_util.h"
#include "cw/dtls.h"

     #include <sys/param.h>
     #include <sys/time.h>
     #include <sys/socket.h>
     #include <net/if.h>

#include "conf.h"
#include "ac.h"
#include "cw/cfg.h"

#include "cw/mavltypes.h"

/*uint8_t conf_macaddress[12];
uint8_t conf_macaddress_len = 0;
*/

long conf_strict_capwap = 1;
long conf_strict_headers = 0;
/*int conf_capwap_mode = CW_MODE_CAPWAP;*/



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;



char **conf_mcast_groups = 0;
int conf_mcast_groups_len = 0;


struct sockaddr_storage *conf_bsalist = NULL;

int conf_salist_len = 0;
int conf_bsalist_len = 0;

struct sockaddr *conf_ac_ips;
int conf_ac_ips_len;

char *conf_sslcertfilename = NULL;
char *conf_sslkeyfilename = NULL;
char *conf_sslkeypass = NULL;
char *conf_dtls_psk = NULL;

int conf_security = 0;
long conf_vendor_id = CONF_DEFAULT_VENDOR_ID;


bstr_t conf_hardware_version = NULL;
bstr_t conf_software_version = NULL;

bstr_t conf_cisco_hardware_version = NULL;
bstr_t conf_cisco_software_version = NULL;


int conf_use_loopback = 0;

long conf_debug_level = -1;

char *conf_db_file = 0;

int conf_ipv4 = 1;
#ifdef WITH_IPV6
int conf_ipv6 = 1;
#endif


#ifdef WITH_LWAPP
int conf_lwapp = 1;
char *conf_lw_control_port = 0;
#endif

char *conf_image_dir = 0;


char *conf_control_port = 0;


int conf_dtls_verify_peer = 1;

static int init_ac_name(cw_Cfg_t * cfg)
{
	char *s;
	char *primary_if=NULL;
	char ac_name[CAPWAP_MAX_AC_NAME_LEN+1];
	uint8_t macaddress[128];
	uint8_t macaddress_len;
	char acid[128];
	int i;


	s= cw_cfg_get(cfg,"capwap/ac-name",NULL);
	if (s!=NULL)
		return 1;

//	primary_if = sock_get_primary_if(AF_INET6);
	if (!primary_if)
		primary_if = sock_get_primary_if(AF_INET);

	acid[0]=0;

	if (primary_if) {
		macaddress_len=8;
		if (!sock_getifhwaddr(primary_if, macaddress, &macaddress_len)) {
			cw_dbg(DBG_INFO, "Fatal: Unable to detect link layer address for %s\n",
			       primary_if);
		}
		else{
			s=acid;
			for (i = 0; i < macaddress_len; i++) {
				s += sprintf(s, "%02X", macaddress[i]);
			}

		}
	}

	sprintf(ac_name,"actube%s",acid);
	cw_cfg_set(cfg,"capwap/ac-name",ac_name);
	return 1;
}

#include "../mod/modload.h"




static int init_dtls()
{
	if (conf_dtls_psk != NULL) {
/*
		//              conf_security=CW_SECURITY_FLAGS_S;
*/
	}

	return 1;
}


static int init_vendor_id()
{
	return 1;
}<commit_msg>Fixed: free interface name<commit_after>/*
    This file is part of actube.

    libcapwap is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    libcapwap is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
*/

#include <stdlib.h>
#include <string.h>
#include <sys/utsname.h>


#include "cw/capwap.h"
#include "cw/sock.h"

#include "cw/log.h"
#include "cw/dbg.h"
#include "cw/cw_util.h"
#include "cw/dtls.h"

     #include <sys/param.h>
     #include <sys/time.h>
     #include <sys/socket.h>
     #include <net/if.h>

#include "conf.h"
#include "ac.h"
#include "cw/cfg.h"

#include "cw/mavltypes.h"

/*uint8_t conf_macaddress[12];
uint8_t conf_macaddress_len = 0;
*/

long conf_strict_capwap = 1;
long conf_strict_headers = 0;
/*int conf_capwap_mode = CW_MODE_CAPWAP;*/



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;



char **conf_mcast_groups = 0;
int conf_mcast_groups_len = 0;


struct sockaddr_storage *conf_bsalist = NULL;

int conf_salist_len = 0;
int conf_bsalist_len = 0;

struct sockaddr *conf_ac_ips;
int conf_ac_ips_len;

char *conf_sslcertfilename = NULL;
char *conf_sslkeyfilename = NULL;
char *conf_sslkeypass = NULL;
char *conf_dtls_psk = NULL;

int conf_security = 0;
long conf_vendor_id = CONF_DEFAULT_VENDOR_ID;


bstr_t conf_hardware_version = NULL;
bstr_t conf_software_version = NULL;

bstr_t conf_cisco_hardware_version = NULL;
bstr_t conf_cisco_software_version = NULL;


int conf_use_loopback = 0;

long conf_debug_level = -1;

char *conf_db_file = 0;

int conf_ipv4 = 1;
#ifdef WITH_IPV6
int conf_ipv6 = 1;
#endif


#ifdef WITH_LWAPP
int conf_lwapp = 1;
char *conf_lw_control_port = 0;
#endif

char *conf_image_dir = 0;


char *conf_control_port = 0;


int conf_dtls_verify_peer = 1;

static int init_ac_name(cw_Cfg_t * cfg)
{
	char *s;
	char *primary_if=NULL;
	char ac_name[CAPWAP_MAX_AC_NAME_LEN+1];
	uint8_t macaddress[128];
	uint8_t macaddress_len;
	char acid[128];
	int i;


	s= cw_cfg_get(cfg,"capwap/ac-name",NULL);
	if (s!=NULL)
		return 1;

//	primary_if = sock_get_primary_if(AF_INET6);
	if (!primary_if)
		primary_if = sock_get_primary_if(AF_INET);

	acid[0]=0;

	if (primary_if) {
		macaddress_len=8;
		if (!sock_getifhwaddr(primary_if, macaddress, &macaddress_len)) {
			cw_dbg(DBG_INFO, "Fatal: Unable to detect link layer address for %s\n",
			       primary_if);
		}
		else{
			s=acid;
			for (i = 0; i < macaddress_len; i++) {
				s += sprintf(s, "%02X", macaddress[i]);
			}

		}
		free(primary_if);
	}

	sprintf(ac_name,"actube%s",acid);
	cw_cfg_set(cfg,"capwap/ac-name",ac_name);
	return 1;
}

#include "../mod/modload.h"




static int init_dtls()
{
	if (conf_dtls_psk != NULL) {
/*
		//              conf_security=CW_SECURITY_FLAGS_S;
*/
	}

	return 1;
}


static int init_vendor_id()
{
	return 1;
}
{'fraction_non_alphanumeric': 0.10965364775239499, 'fraction_numerical': 0.013559322033898305, 'mean_word_length': 4.113790504898267, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4174294', 'n_tokens_mistral': 2836, 'n_tokens_neox': 2659, 'n_words': 674}