Compare commits
	
		
			9 Commits
		
	
	
		
			v0.0.0
			...
			1598abee34
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 1598abee34 | |||
| 156466eab9 | |||
| 04d469b970 | |||
| 0e07e42167 | |||
| 4c37d89f03 | |||
| 6d9da94863 | |||
| 1616d77a0f | |||
| a389003199 | |||
| eac5e73528 | 
							
								
								
									
										137
									
								
								src/ac/ac_main.c
									
									
									
									
									
								
							
							
						
						
									
										137
									
								
								src/ac/ac_main.c
									
									
									
									
									
								
							@ -48,7 +48,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "cw/cfg.h"
 | 
					#include "cw/cfg.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int ac_run();
 | 
					int ac_run(cw_Cfg_t * cfg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <getopt.h>
 | 
					#include <getopt.h>
 | 
				
			||||||
@ -64,7 +65,7 @@ static int parse_args (int argc, char *argv[], struct bootcfg * bootcfg)
 | 
				
			|||||||
	int c;
 | 
						int c;
 | 
				
			||||||
	opterr = 1;
 | 
						opterr = 1;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	bootcfg->cfgfilename = "config.atv";
 | 
						bootcfg->cfgfilename = "config.ckv";
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	while ( (c = getopt (argc, argv, "vc:d:p:")) != -1) {
 | 
						while ( (c = getopt (argc, argv, "vc:d:p:")) != -1) {
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
@ -141,52 +142,6 @@ extern void test_sets();
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "discovery_cache.h"
 | 
					#include "discovery_cache.h"
 | 
				
			||||||
void tester1()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	struct cw_DiscoveryCache * cache;
 | 
					 | 
				
			||||||
	struct sockaddr_storage addr;
 | 
					 | 
				
			||||||
	int rc;
 | 
					 | 
				
			||||||
	const char *c,*b;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	cache = discovery_cache_create(1);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	sock_strtoaddr("192.168.0.12:1234",(struct sockaddr*)&addr);
 | 
					 | 
				
			||||||
	discovery_cache_add(cache,(struct sockaddr*)&addr,"Nase","Loeffel");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	sock_strtoaddr("192.168.0.13:1234",(struct sockaddr*)&addr);
 | 
					 | 
				
			||||||
	discovery_cache_add(cache,(struct sockaddr*)&addr,"Nase","Loeffel");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	rc = discovery_cache_get(cache,(struct sockaddr*)&addr,&c,&b);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (rc) {
 | 
					 | 
				
			||||||
		printf("RC: %d, %s %s\n",rc,c,b);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void show_cfg (FILE *out, mavl_t ktv)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	char value[500];
 | 
					 | 
				
			||||||
	struct cw_Val * data;
 | 
					 | 
				
			||||||
	mavliter_t it;
 | 
					 | 
				
			||||||
	const struct cw_Type * type;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	mavliter_init(&it,ktv);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	mavliter_foreach(&it){
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		data = mavliter_get(&it);
 | 
					 | 
				
			||||||
		type = data->type;
 | 
					 | 
				
			||||||
		type->to_str(data,value,0);
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		fprintf(out,"%s :%s: %s\n",data->key,type->get_type_name(data), value);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		cw_Cfg_t * cfg;
 | 
							cw_Cfg_t * cfg;
 | 
				
			||||||
@ -221,7 +176,7 @@ int main (int argc, char *argv[])
 | 
				
			|||||||
	int rc = 0;
 | 
						int rc = 0;
 | 
				
			||||||
	struct bootcfg bootcfg;
 | 
						struct bootcfg bootcfg;
 | 
				
			||||||
	FILE * file;
 | 
						FILE * file;
 | 
				
			||||||
	mavl_t types_tree, acglobal_cfg;
 | 
						mavl_t types_tree;
 | 
				
			||||||
	const cw_Type_t **ti;
 | 
						const cw_Type_t **ti;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -239,75 +194,17 @@ int main (int argc, char *argv[])
 | 
				
			|||||||
	rc = cw_cfg_load(bootcfg.cfgfilename,global_cfg);
 | 
						rc = cw_cfg_load(bootcfg.cfgfilename,global_cfg);
 | 
				
			||||||
	if (rc)
 | 
						if (rc)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		if (rc<0)
 | 
							if (rc)
 | 
				
			||||||
			fprintf(stderr,"Can't load cfg '%s': %s\n",bootcfg.cfgfilename,strerror(errno));
 | 
								fprintf(stderr,"Can't load cfg '%s': %s\n",bootcfg.cfgfilename,strerror(errno));
 | 
				
			||||||
		goto errX;
 | 
							goto errX;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* open config file */
 | 
					 | 
				
			||||||
        file = fopen("config.ktv","r");
 | 
					 | 
				
			||||||
        if (file == NULL){
 | 
					 | 
				
			||||||
                cw_log(LOG_ERR,"Cant open config file '%s': %s", 
 | 
					 | 
				
			||||||
				bootcfg.cfgfilename, strerror(errno));
 | 
					 | 
				
			||||||
                exit(EXIT_FAILURE);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* create types tree with default types */
 | 
					 | 
				
			||||||
	types_tree = cw_ktv_create_types_tree();
 | 
					 | 
				
			||||||
	for (ti=CW_KTV_STD_TYPES;*ti;ti++){
 | 
					 | 
				
			||||||
		mavl_insert_ptr(types_tree,*ti);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	acglobal_cfg = cw_ktv_create();
 | 
					 | 
				
			||||||
	if (acglobal_cfg == NULL){
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR,"Can't create local_cfg: %s",strerror(errno));
 | 
					 | 
				
			||||||
		exit(EXIT_FAILURE);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_ktv_read_file(file,acglobal_cfg,types_tree);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	fclose(file);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	actube_global_cfg = acglobal_cfg;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_dbg_ktv_dump(acglobal_cfg,DBG_INFO,NULL,"CFG:",NULL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_log_name = "AC-Tube";
 | 
						cw_log_name = "AC-Tube";
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	if (!read_config ("ac.conf"))
 | 
					 | 
				
			||||||
		return 1;
 | 
					 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
	start_shell();
 | 
						start_shell();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* Show debug options if there are any set */
 | 
					 | 
				
			||||||
	if (cw_dbg_opt_level)
 | 
					 | 
				
			||||||
		cw_log (LOG_INFO, "Debug Options: %08X", cw_dbg_opt_level);
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
	/* XXX Hard coded debug settigns, set it by config in the future */
 | 
					 | 
				
			||||||
//	cw_dbg_opt_display = DBG_DISP_ASC_DMP | DBG_DISP_COLORS;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	/* Warn, if the "secret" debugging feature for
 | 
					 | 
				
			||||||
	   developers is turned on ;) */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
//	DBGX("Attention! %s", "DBG X is ON!");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	cw_mod_set_mod_path("../../lib/actube");
 | 
					 | 
				
			||||||
	//cw_mod_load("capwap");
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* Init DTLS library */
 | 
						/* Init DTLS library */
 | 
				
			||||||
	dtls_init();
 | 
						dtls_init();
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
@ -322,15 +219,20 @@ int main (int argc, char *argv[])
 | 
				
			|||||||
	if (!dataman_list_init())
 | 
						if (!dataman_list_init())
 | 
				
			||||||
		goto errX;
 | 
							goto errX;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ac_conf_init(global_cfg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cw_cfg_dump(global_cfg);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
	cw_log (LOG_INFO, "Starting AC-Tube, Name=%s, ID=%s", conf_acname, conf_acid);
 | 
						cw_log (LOG_INFO, "Starting AC-Tube, Name=%s, ID=%s", conf_acname, conf_acid);
 | 
				
			||||||
	rc = ac_run();
 | 
						rc = ac_run(global_cfg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
errX:
 | 
					errX:
 | 
				
			||||||
	if (global_cfg)
 | 
						if (global_cfg)
 | 
				
			||||||
		mavl_destroy(global_cfg);
 | 
							mavl_destroy(global_cfg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (discovery_cache)
 | 
				
			||||||
 | 
							discovery_cache_destroy(discovery_cache);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* XXX There is more cleanup to do */
 | 
					 | 
				
			||||||
	wtplist_destroy();
 | 
						wtplist_destroy();
 | 
				
			||||||
	socklist_destroy();
 | 
						socklist_destroy();
 | 
				
			||||||
	return rc;
 | 
						return rc;
 | 
				
			||||||
@ -339,23 +241,23 @@ errX:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void process_ctrl_packet (int index, struct sockaddr *addr, uint8_t * buffer, int len);
 | 
					void process_ctrl_packet (int index, struct sockaddr *addr, uint8_t * buffer, int len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void process_cw_data_packet (int index, struct sockaddr *addr, uint8_t * buffer, int len);
 | 
					void process_cw_data_packet (int index, struct sockaddr *addr, uint8_t * buffer, int len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int ac_run()
 | 
					int ac_run(cw_Cfg_t * cfg)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!conf_listen_addrs_len) {
 | 
						if (1 /*!conf_listen_addrs_len*/) {
 | 
				
			||||||
		cw_log (LOG_ERR, "Fatal error: No listen addresses found.");
 | 
							cw_log (LOG_ERR, "Fatal error: No listen addresses found.");
 | 
				
			||||||
		return 1;
 | 
					//		return 1;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
						extern void cw_cfg_iterate(cw_Cfg_t *);	
 | 
				
			||||||
 | 
						cw_cfg_iterate(cfg);	
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return 1;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	/* it is important to create the unicast sockets first,
 | 
						/* it is important to create the unicast sockets first,
 | 
				
			||||||
	 * because when we create the mcast an bcast sockets next
 | 
						 * because when we create the mcast an bcast sockets next
 | 
				
			||||||
@ -364,7 +266,7 @@ int ac_run()
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
	int i;
 | 
						int i;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	for (i = 0; i < conf_listen_addrs_len; i++) {
 | 
					/*	for (i = 0; i < conf_listen_addrs_len; i++) {
 | 
				
			||||||
		char addr[100];
 | 
							char addr[100];
 | 
				
			||||||
		char port[50];
 | 
							char port[50];
 | 
				
			||||||
		int proto;
 | 
							int proto;
 | 
				
			||||||
@ -373,6 +275,7 @@ int ac_run()
 | 
				
			|||||||
		
 | 
							
 | 
				
			||||||
		socklist_add_unicast (addr, port, proto);
 | 
							socklist_add_unicast (addr, port, proto);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (socklist_len == 0) {
 | 
						if (socklist_len == 0) {
 | 
				
			||||||
		cw_log (LOG_ERR, "Fatal error: Could not setup any listen socket");
 | 
							cw_log (LOG_ERR, "Fatal error: Could not setup any listen socket");
 | 
				
			||||||
 | 
				
			|||||||
@ -36,6 +36,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "conf.h"
 | 
					#include "conf.h"
 | 
				
			||||||
#include "ac.h"
 | 
					#include "ac.h"
 | 
				
			||||||
 | 
					#include "cw/cfg.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "cw/mavltypes.h"
 | 
					#include "cw/mavltypes.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -60,8 +61,6 @@ long conf_max_wtps = CONF_DEFAULT_MAXWTPS;
 | 
				
			|||||||
char *conf_logfilename = CONF_DEFAULT_LOGFILENAME;
 | 
					char *conf_logfilename = CONF_DEFAULT_LOGFILENAME;
 | 
				
			||||||
struct sockaddr_storage *conf_salist = NULL;
 | 
					struct sockaddr_storage *conf_salist = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
char **conf_listen_addrs;
 | 
					 | 
				
			||||||
int conf_listen_addrs_len = 0;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
char **conf_mcast_groups = 0;
 | 
					char **conf_mcast_groups = 0;
 | 
				
			||||||
@ -215,41 +214,23 @@ static int init_control_port()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <ifaddrs.h>
 | 
					#include <ifaddrs.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int init_listen_addrs()
 | 
					static int init_listen_addrs(cw_Cfg_t * cfg)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						char key[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct ifaddrs *ifap, *ifa;
 | 
						struct ifaddrs *ifap, *ifa;
 | 
				
			||||||
	int rc;
 | 
						int rc;
 | 
				
			||||||
	int ctr;
 | 
						int ctr;
 | 
				
			||||||
 | 
						const char * a0;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	if (conf_listen_addrs != 0)
 | 
						a0 = cw_cfg_get(cfg,"actube/listen.0",NULL);
 | 
				
			||||||
 | 
						if (a0)
 | 
				
			||||||
		return 1;
 | 
							return 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	rc = getifaddrs(&ifap);
 | 
						rc = getifaddrs(&ifap);
 | 
				
			||||||
	if (rc == -1)
 | 
						if (rc == -1)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* count the addresses */
 | 
					 | 
				
			||||||
	ctr = 0;
 | 
					 | 
				
			||||||
	for (ifa = ifap; ifa != 0; ifa = ifa->ifa_next) {
 | 
					 | 
				
			||||||
		if (!ifa->ifa_addr)
 | 
					 | 
				
			||||||
			continue;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (ifa->ifa_addr->sa_family == AF_INET && conf_ipv4)
 | 
					 | 
				
			||||||
			ctr++;
 | 
					 | 
				
			||||||
		if (ifa->ifa_addr->sa_family == AF_INET6 && conf_ipv6)
 | 
					 | 
				
			||||||
			ctr++;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	conf_listen_addrs = malloc(sizeof(char *) * ctr);
 | 
					 | 
				
			||||||
	if (!conf_listen_addrs) {
 | 
					 | 
				
			||||||
		rc = 0;
 | 
					 | 
				
			||||||
		goto errX;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	memset(conf_listen_addrs, 0, sizeof(char *) * ctr);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ctr = 0;
 | 
						ctr = 0;
 | 
				
			||||||
	/* get the addresses */
 | 
						/* get the addresses */
 | 
				
			||||||
	for (ifa = ifap; ifa != 0; ifa = ifa->ifa_next) {
 | 
						for (ifa = ifap; ifa != 0; ifa = ifa->ifa_next) {
 | 
				
			||||||
@ -267,12 +248,9 @@ static int init_listen_addrs()
 | 
				
			|||||||
		if (ifa->ifa_addr->sa_family == AF_INET && conf_ipv4) {
 | 
							if (ifa->ifa_addr->sa_family == AF_INET && conf_ipv4) {
 | 
				
			||||||
			sock_addrtostr(ifa->ifa_addr, str, 100,0);
 | 
								sock_addrtostr(ifa->ifa_addr, str, 100,0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			conf_listen_addrs[ctr] =
 | 
					 | 
				
			||||||
			    (char *) cw_setstr((uint8_t **) & conf_listen_addrs[ctr],
 | 
					 | 
				
			||||||
					       (uint8_t *) str, strlen(str));
 | 
					 | 
				
			||||||
			if (conf_listen_addrs[ctr])
 | 
					 | 
				
			||||||
				ctr++;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								sprintf(key,"actube/listen.%d",ctr++);
 | 
				
			||||||
 | 
								cw_cfg_set(cfg,key,str);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (ifa->ifa_addr->sa_family == AF_INET6 && conf_ipv6) {
 | 
							if (ifa->ifa_addr->sa_family == AF_INET6 && conf_ipv6) {
 | 
				
			||||||
			sock_addrtostr(ifa->ifa_addr, str, 100,0);
 | 
								sock_addrtostr(ifa->ifa_addr, str, 100,0);
 | 
				
			||||||
@ -281,14 +259,10 @@ static int init_listen_addrs()
 | 
				
			|||||||
				strcat(str, "%");
 | 
									strcat(str, "%");
 | 
				
			||||||
				strcat(str, ifa->ifa_name);
 | 
									strcat(str, ifa->ifa_name);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			conf_listen_addrs[ctr] =
 | 
								sprintf(key,"actube/listen.%d",ctr++);
 | 
				
			||||||
			    (char *) cw_setstr((uint8_t **) & conf_listen_addrs[ctr],
 | 
								cw_cfg_set(cfg,key,str);
 | 
				
			||||||
					       (uint8_t *) str, strlen(str));
 | 
					 | 
				
			||||||
			if (conf_listen_addrs[ctr])
 | 
					 | 
				
			||||||
				ctr++;
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	conf_listen_addrs_len = ctr;
 | 
					 | 
				
			||||||
	rc = 1;
 | 
						rc = 1;
 | 
				
			||||||
      errX:
 | 
					      errX:
 | 
				
			||||||
	freeifaddrs(ifap);
 | 
						freeifaddrs(ifap);
 | 
				
			||||||
@ -703,9 +677,6 @@ int read_config(const char *filename)
 | 
				
			|||||||
	/* read debug options */
 | 
						/* read debug options */
 | 
				
			||||||
	conf_read_dbg_level(cfg);
 | 
						conf_read_dbg_level(cfg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* read the listen addresses */
 | 
					 | 
				
			||||||
	conf_read_strings(cfg, "listen", &conf_listen_addrs, &conf_listen_addrs_len);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* read multi cast groups */
 | 
						/* read multi cast groups */
 | 
				
			||||||
	conf_read_strings(cfg, "mcast_groups", &conf_mcast_groups,
 | 
						conf_read_strings(cfg, "mcast_groups", &conf_mcast_groups,
 | 
				
			||||||
			  &conf_mcast_groups_len);
 | 
								  &conf_mcast_groups_len);
 | 
				
			||||||
@ -763,7 +734,6 @@ int read_config(const char *filename)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	init_listen_addrs();
 | 
					 | 
				
			||||||
	init_mcast_groups();
 | 
						init_mcast_groups();
 | 
				
			||||||
	init_bcast_addrs();
 | 
						init_bcast_addrs();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -775,3 +745,13 @@ void free_config()
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void ac_conf_init(cw_Cfg_t *cfg)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						printf("ac conf\n");
 | 
				
			||||||
 | 
						init_listen_addrs(cfg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -31,7 +31,7 @@
 | 
				
			|||||||
#include "cw/bstr.h"
 | 
					#include "cw/bstr.h"
 | 
				
			||||||
#include "cw/mod.h"
 | 
					#include "cw/mod.h"
 | 
				
			||||||
#include "cw/vendors.h"
 | 
					#include "cw/vendors.h"
 | 
				
			||||||
 | 
					#include "cw/cfg.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern struct cw_Mod ** conf_mods;
 | 
					extern struct cw_Mod ** conf_mods;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -94,8 +94,6 @@ extern bstr_t conf_cisco_software_version;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern char **conf_listen_addrs;
 | 
					 | 
				
			||||||
extern int conf_listen_addrs_len;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern struct sockaddr *conf_ac_ips;
 | 
					extern struct sockaddr *conf_ac_ips;
 | 
				
			||||||
extern int conf_ac_ips_len;
 | 
					extern int conf_ac_ips_len;
 | 
				
			||||||
@ -141,5 +139,8 @@ extern int conf_parse_listen_addr(const char *addr, char *saddr, char *port, int
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#define CFG_ENTRY_MODS "mods"
 | 
					#define CFG_ENTRY_MODS "mods"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define CONF_PREFIX "actube"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void ac_conf_init(cw_Cfg_t *cfg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										14
									
								
								src/ac/config.ckv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								src/ac/config.ckv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,14 @@
 | 
				
			|||||||
 | 
					#Cfg
 | 
				
			||||||
 | 
					capwap/ssl-cipher: DHE-RSA:RSA:AES-256-CBC:AES-128-CBC:SHA1:PSK
 | 
				
			||||||
 | 
					capwap/ssl-psk-enable: false
 | 
				
			||||||
 | 
					capwap/ssl-psk: 123456
 | 
				
			||||||
 | 
					capwap/ssl-dhbits: 1024
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cisco/ssl-keyfile:  "../../ssl/intermediate-ca/int-ca.key"
 | 
				
			||||||
 | 
					cisco/ssl-certfile: "../../ssl/intermediate-ca/int-ca.crt"
 | 
				
			||||||
 | 
					cisco/ssl-cipher: DEFAULT
 | 
				
			||||||
 | 
					cisco/ssl-dhbits: 2048
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#actube/listen.hitler : 123456789
 | 
				
			||||||
 | 
					actube/listen.17 : 123456789
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -32,6 +32,9 @@ void discovery_cache_destroy(struct cw_DiscoveryCache * c)
 | 
				
			|||||||
	if (c->byaddrp)
 | 
						if (c->byaddrp)
 | 
				
			||||||
		mavl_destroy(c->byaddrp);
 | 
							mavl_destroy(c->byaddrp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (c->queue)
 | 
				
			||||||
 | 
							free(c->queue);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	free(c);
 | 
						free(c);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -3,7 +3,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "cw/mod.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct cw_DiscoveryCache * discovery_cache_create(int len);
 | 
					struct cw_DiscoveryCache * discovery_cache_create(int len);
 | 
				
			||||||
@ -14,4 +14,5 @@ void discovery_cache_add(struct cw_DiscoveryCache *cache,
 | 
				
			|||||||
int discovery_cache_get(struct cw_DiscoveryCache * cache,struct sockaddr *addr, 
 | 
					int discovery_cache_get(struct cw_DiscoveryCache * cache,struct sockaddr *addr, 
 | 
				
			||||||
			struct cw_Mod ** modcapwap, struct cw_Mod **modbindings);
 | 
								struct cw_Mod ** modcapwap, struct cw_Mod **modbindings);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void discovery_cache_destroy(struct cw_DiscoveryCache * c);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
							
								
								
									
										87
									
								
								src/cw/cfg.c
									
									
									
									
									
								
							
							
						
						
									
										87
									
								
								src/cw/cfg.c
									
									
									
									
									
								
							@ -52,13 +52,13 @@ int cw_cfg_set(cw_Cfg_t * cfg,const char *key, const char *val)
 | 
				
			|||||||
	return -1;
 | 
						return -1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
char * cw_cfg_get(cw_Cfg_t * cfg, char *key)
 | 
					const char * cw_cfg_get(cw_Cfg_t * cfg, char *key, const char *def)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct cw_Cfg_entry e,*r;
 | 
						struct cw_Cfg_entry e,*r;
 | 
				
			||||||
	e.key = key;
 | 
						e.key = key;
 | 
				
			||||||
	r = mavl_get(cfg,&e);
 | 
						r = mavl_get(cfg,&e);
 | 
				
			||||||
	if (!r)
 | 
						if (!r)
 | 
				
			||||||
		return NULL;
 | 
							return def;
 | 
				
			||||||
	return r->val;
 | 
						return r->val;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -368,5 +368,86 @@ int cw_cfg_load(const char *filename,cw_Cfg_t * cfg)
 | 
				
			|||||||
		return errno;
 | 
							return errno;
 | 
				
			||||||
	errs = cw_cfg_read_from_file(f,cfg);
 | 
						errs = cw_cfg_read_from_file(f,cfg);
 | 
				
			||||||
	fclose(f);
 | 
						fclose(f);
 | 
				
			||||||
	return errs;
 | 
					
 | 
				
			||||||
 | 
						if (errs)
 | 
				
			||||||
 | 
							errno = EINVAL;
 | 
				
			||||||
 | 
						return errno;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int cw_cfg_get_next_idx(cw_Cfg_t * cfg, const char *key, int n)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						char ikey[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
 | 
						struct cw_Cfg_entry search, * result;
 | 
				
			||||||
 | 
						char *d;
 | 
				
			||||||
 | 
						int i;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						sprintf(ikey,"%s.%d",key,n);
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
						search.key=ikey;
 | 
				
			||||||
 | 
						result = mavl_get_first(cfg,&search);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						printf("KEY: %s\n",search.key);
 | 
				
			||||||
 | 
						printf("NNNNN: %s\n",result->key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						if (result==NULL)
 | 
				
			||||||
 | 
							return -1;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						d=NULL;
 | 
				
			||||||
 | 
						for (i = strlen(ikey); i>=0; i--){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (ikey[i]=='.'){
 | 
				
			||||||
 | 
								d = result->key+i;
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						if (d==NULL){
 | 
				
			||||||
 | 
							return -1;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						if(result->key[i]!='.'){
 | 
				
			||||||
 | 
							return -1;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						if (strncmp(result->key,ikey,i)!=0)
 | 
				
			||||||
 | 
							return -1;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						printf("TRANSFER %s\n",result->key+i+1);
 | 
				
			||||||
 | 
						return atoi(result->key+i+1);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void cw_cfg_iterate(cw_Cfg_t * cfg)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						printf("Iterate\n");
 | 
				
			||||||
 | 
						struct cw_Cfg_entry *e;
 | 
				
			||||||
 | 
						struct cw_Cfg_entry search;
 | 
				
			||||||
 | 
						search.key="actube/listen";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						int i=0;
 | 
				
			||||||
 | 
						i = cw_cfg_get_next_idx(cfg,"actube/listen",i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						printf("This i %d\n",i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						while ( (i = cw_cfg_get_next_idx(cfg,"actube/listen",i))!=-1) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							printf("Here i %d\n",i);
 | 
				
			||||||
 | 
							printf("we have key: %s.%d\n","actube/listen",i);
 | 
				
			||||||
 | 
							printf("Next=%d\n",i);
 | 
				
			||||||
 | 
							i++;
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						e = mavl_get_first(cfg,&search);
 | 
				
			||||||
 | 
						if (!e){
 | 
				
			||||||
 | 
							printf("NULL\n");
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						printf("%s : %s\n",e->key,e->val);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -18,7 +18,7 @@ struct cw_Cfg_entry{
 | 
				
			|||||||
	char *val;
 | 
						char *val;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
char * cw_cfg_get(cw_Cfg_t * cfg, char *key);
 | 
					const char * cw_cfg_get(cw_Cfg_t * cfg, char *key, const char *def);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
@ -133,6 +133,9 @@ void connlist_destroy ( struct connlist * cl )
 | 
				
			|||||||
		
 | 
							
 | 
				
			||||||
	if ( cl->by_addr )
 | 
						if ( cl->by_addr )
 | 
				
			||||||
		mavl_destroy ( cl->by_addr );
 | 
							mavl_destroy ( cl->by_addr );
 | 
				
			||||||
 | 
						if ( cl->by_session_id)
 | 
				
			||||||
 | 
							mavl_destroy ( cl->by_session_id );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
	pthread_mutex_destroy ( &cl->connlist_mutex );
 | 
						pthread_mutex_destroy ( &cl->connlist_mutex );
 | 
				
			||||||
	free ( cl );
 | 
						free ( cl );
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user