Removed a lot of old stuff, compiles almost w/o warnings
This commit is contained in:
		@ -18,7 +18,6 @@ CWSRC=\
 | 
			
		||||
	cw_in_capwap_local_ipv4_address.c\
 | 
			
		||||
	cw_in_capwap_local_ipv6_address.c\
 | 
			
		||||
	cw_in_generic_with_index.c\
 | 
			
		||||
	cw_in_radio_generic_struct.c\
 | 
			
		||||
	cw_in_idx_generic.c\
 | 
			
		||||
	cw_in_idx_generic_struct.c\
 | 
			
		||||
	cw_in_generic_indexed_enum.c\
 | 
			
		||||
@ -77,6 +76,7 @@ CWSRC=\
 | 
			
		||||
#	
 | 
			
		||||
#	cw_process_element.c\
 | 
			
		||||
#	cw_out_generic_struct.c\
 | 
			
		||||
	cw_in_radio_generic_struct.c\
 | 
			
		||||
 | 
			
		||||
KTVSRC=\
 | 
			
		||||
	cfg.c\
 | 
			
		||||
 | 
			
		||||
@ -1,36 +0,0 @@
 | 
			
		||||
 | 
			
		||||
#include "capwap.h"
 | 
			
		||||
#include "msgset.h"
 | 
			
		||||
#include "val.h"
 | 
			
		||||
#include "log.h"
 | 
			
		||||
#include "dbg.h"
 | 
			
		||||
 | 
			
		||||
int cw_in_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params,
 | 
			
		||||
		uint8_t * elem_data, int elem_len)
 | 
			
		||||
{
 | 
			
		||||
	cw_dbg(DBG_X,"STRUCT KEY: %s",handler->key);
 | 
			
		||||
	stop();
 | 
			
		||||
/*	const char * key;
 | 
			
		||||
	char tmpkey[CW_CFG_MAX_KEY_LEN];
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	if (handler->mkkey != NULL){
 | 
			
		||||
		handler->mkkey(key,elem_data,elem_len, tmpkey);
 | 
			
		||||
		key = tmpkey;
 | 
			
		||||
	}
 | 
			
		||||
	else{
 | 
			
		||||
		key = handler->key;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
//printf("CW_IN_GENERIC STRUCT: %s\n",key);	
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	if (!handler->type){
 | 
			
		||||
		cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name);
 | 
			
		||||
		return CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cw_ktv_read_struct(params->cfg,handler->type,key,elem_data,elem_len);
 | 
			
		||||
*/
 | 
			
		||||
	return CAPWAP_RESULT_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
@ -10,12 +10,14 @@
 | 
			
		||||
int cw_in_idx_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params,
 | 
			
		||||
		uint8_t * elem_data, int elem_len)
 | 
			
		||||
{
 | 
			
		||||
	stop();
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	char key[CW_CFG_MAX_KEY_LEN];
 | 
			
		||||
	int idx;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	cw_dbg(DBG_X,"Fix cw_in_idx_generic_struct");
 | 
			
		||||
	stop();
 | 
			
		||||
	
 | 
			
		||||
	if (!handler->type){
 | 
			
		||||
		cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name);
 | 
			
		||||
@ -26,6 +28,6 @@ int cw_in_idx_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHand
 | 
			
		||||
	sprintf(key, handler->key, idx);
 | 
			
		||||
 | 
			
		||||
	cw_ktv_read_struct(params->cfg,handler->type,key,elem_data+1,elem_len-1);
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
	return CAPWAP_RESULT_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,48 +0,0 @@
 | 
			
		||||
#include "capwap.h"
 | 
			
		||||
#include "msgset.h"
 | 
			
		||||
#include "val.h"
 | 
			
		||||
#include "log.h"
 | 
			
		||||
#include "cw.h"
 | 
			
		||||
 | 
			
		||||
#include "dbg.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int cw_out_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
			
		||||
			, uint8_t * dst)
 | 
			
		||||
{
 | 
			
		||||
	cw_dbg(DBG_X,"Key: %s",handler->key);
 | 
			
		||||
	stop();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	int start;
 | 
			
		||||
	int len;
 | 
			
		||||
	cw_Val_t search, *result;
 | 
			
		||||
 | 
			
		||||
	if (!handler->type){
 | 
			
		||||
		cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name);
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	search.key = (char*)handler->key;
 | 
			
		||||
	result = mavl_get_first(params->cfg,&search);
 | 
			
		||||
	if (result == NULL ){
 | 
			
		||||
		if (params->elemdata->mand)
 | 
			
		||||
			cw_log(LOG_ERR,"Can't put mandatory message element %s, no data available",handler->name);
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	if (strncmp(result->key,handler->key, strlen(handler->key))!=0){
 | 
			
		||||
		if (params->elemdata->mand)
 | 
			
		||||
			cw_log(LOG_ERR,"Can't put mandatory message element %s, no data available",handler->name);
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	start = params->msgset->header_len(handler);
 | 
			
		||||
 | 
			
		||||
	len = cw_ktv_write_struct(params->cfg,
 | 
			
		||||
		params->cfg,
 | 
			
		||||
		handler->type,handler->key,dst+start);
 | 
			
		||||
	
 | 
			
		||||
	return params->msgset->write_header(handler,dst,len);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -7,7 +7,7 @@ int cw_out_idx_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHan
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	stop();
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
	char key[CW_CFG_MAX_KEY_LEN];
 | 
			
		||||
	struct cw_Val * elem, search;
 | 
			
		||||
	int i;
 | 
			
		||||
@ -26,7 +26,7 @@ int cw_out_idx_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHan
 | 
			
		||||
		
 | 
			
		||||
		sprintf(key,handler->key,i);
 | 
			
		||||
		search.key=key;
 | 
			
		||||
		/*elem = mavl_get(params->conn->local_cfg, &search);*/
 | 
			
		||||
		/ * elem = mavl_get(params->conn->local_cfg, &search); * /
 | 
			
		||||
		elem = mavl_get_first(params->cfg,&search);
 | 
			
		||||
		if(elem != NULL){
 | 
			
		||||
			printf("Elem key: %s\n",elem->key);
 | 
			
		||||
@ -55,14 +55,16 @@ int cw_out_idx_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHan
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
/*	radios = cw_ktv_get_byte(params->conn->local_cfg,"wtp-descriptor/max-radios",0);
 | 
			
		||||
/ *	radios = cw_ktv_get_byte(params->conn->local_cfg,"wtp-descriptor/max-radios",0);
 | 
			
		||||
 | 
			
		||||
	for(i=1;i<radios+1;i++){
 | 
			
		||||
		l = cw_write_radio_element(handler,params,i,dst+len);
 | 
			
		||||
		cw_dbg_elem(DBG_ELEM_OUT,params->conn,params->msgdata->type,handler,dst,l);
 | 
			
		||||
		len+=l;
 | 
			
		||||
	}
 | 
			
		||||
*/
 | 
			
		||||
* /
 | 
			
		||||
 | 
			
		||||
	return mdst-dst;
 | 
			
		||||
	*/ return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,89 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
    This file is part of libcapwap.
 | 
			
		||||
 | 
			
		||||
    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/>.
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @file
 | 
			
		||||
 * @brief bstr_create_from_cfgstr function
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
#include "bstr.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Create a bstr16_t string from a string read from config file.
 | 
			
		||||
 * 
 | 
			
		||||
 * @param s String from config file.
 | 
			
		||||
 * @return The create bstr_t string.
 | 
			
		||||
 *
 | 
			
		||||
 * The string from config file is an ASCII-text which is interpreted
 | 
			
		||||
 * as hexadecimal string if it starts with ".x"
 | 
			
		||||
 *
 | 
			
		||||
 * @see bstr16_t
 | 
			
		||||
 */
 | 
			
		||||
uint8_t * bstr16_create_from_cfgstr(const char * s)
 | 
			
		||||
{
 | 
			
		||||
	int l = strlen(s);
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	if (s[0]!='.')
 | 
			
		||||
		return bstr16_create((uint8_t*)s,l);
 | 
			
		||||
 | 
			
		||||
	if (l<=2)
 | 
			
		||||
		return bstr16_create((uint8_t*)s,l);
 | 
			
		||||
 | 
			
		||||
	if (s[1]=='.')
 | 
			
		||||
		return bstr16_create((uint8_t*)s+1,l-1);
 | 
			
		||||
 | 
			
		||||
	if (s[1]=='x'){
 | 
			
		||||
		uint8_t * ns=0;
 | 
			
		||||
		int len=0;
 | 
			
		||||
 | 
			
		||||
		int ch,cl;
 | 
			
		||||
		const char *ss = s+2;
 | 
			
		||||
		int rc ;
 | 
			
		||||
		do {
 | 
			
		||||
			rc = sscanf(ss,"%01X",&ch);
 | 
			
		||||
			if (rc!=1)
 | 
			
		||||
				break;
 | 
			
		||||
			ss++;
 | 
			
		||||
			rc = sscanf(ss,"%01X",&cl);
 | 
			
		||||
			if (rc!=1)
 | 
			
		||||
				cl=0;
 | 
			
		||||
			ss++;
 | 
			
		||||
			int c=(ch<<4) | cl;
 | 
			
		||||
			
 | 
			
		||||
			len++;
 | 
			
		||||
			ns = realloc(ns,len);
 | 
			
		||||
			ns[len-1]=c;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		}while (rc==1);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		return bstr16_create(ns,len);
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,67 +0,0 @@
 | 
			
		||||
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
#include "bstr.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Create a bstr1616_t string from a string read from config file.
 | 
			
		||||
 * 
 | 
			
		||||
 * @param s String from config file.
 | 
			
		||||
 * @return The create bstr16_t string.
 | 
			
		||||
 *
 | 
			
		||||
 * The string from config file is an ASCII-text which is interpreted
 | 
			
		||||
 * as hexadecimal string if it starts with ".x"
 | 
			
		||||
 *
 | 
			
		||||
 * @see bstr16_t
 | 
			
		||||
 */
 | 
			
		||||
uint8_t * bstr16cfgstr(const char * s)
 | 
			
		||||
{
 | 
			
		||||
	int l = strlen(s);
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	if (s[0]!='.')
 | 
			
		||||
		return bstr16_create((uint8_t*)s,l);
 | 
			
		||||
 | 
			
		||||
	if (l<=2)
 | 
			
		||||
		return bstr16_create((uint8_t*)s,l);
 | 
			
		||||
 | 
			
		||||
	if (s[1]=='.')
 | 
			
		||||
		return bstr16_create((uint8_t*)s+1,l-1);
 | 
			
		||||
 | 
			
		||||
	if (s[1]=='x'){
 | 
			
		||||
		uint8_t * ns=0;
 | 
			
		||||
		int len=0;
 | 
			
		||||
 | 
			
		||||
		int ch,cl;
 | 
			
		||||
		const char *ss = s+2;
 | 
			
		||||
		int rc ;
 | 
			
		||||
		do {
 | 
			
		||||
			rc = sscanf(ss,"%01X",&ch);
 | 
			
		||||
			if (rc!=1)
 | 
			
		||||
				break;
 | 
			
		||||
			ss++;
 | 
			
		||||
			rc = sscanf(ss,"%01X",&cl);
 | 
			
		||||
			if (rc!=1)
 | 
			
		||||
				cl=0;
 | 
			
		||||
			ss++;
 | 
			
		||||
			int c=(ch<<4) | cl;
 | 
			
		||||
			
 | 
			
		||||
			len++;
 | 
			
		||||
			ns = realloc(ns,len);
 | 
			
		||||
			ns[len-1]=c;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		}while (rc==1);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		return bstr16_create(ns,len);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,90 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
    This file is part of libcapwap.
 | 
			
		||||
 | 
			
		||||
    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/>.
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @file
 | 
			
		||||
 * @brief bstr_create_from_cfgstr function
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
#include "bstr.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Create a bstr_t string from a string read from config file.
 | 
			
		||||
 * 
 | 
			
		||||
 * @param s String from config file.
 | 
			
		||||
 * @return The create bstr_t string.
 | 
			
		||||
 *
 | 
			
		||||
 * The string from config file is an ASCII-text which is interpreted
 | 
			
		||||
 * as hexadecimal string if it starts with ".x"
 | 
			
		||||
 *
 | 
			
		||||
 * @see bstr_t
 | 
			
		||||
 */
 | 
			
		||||
uint8_t * bstr_create_from_cfgstr(const char * s)
 | 
			
		||||
{
 | 
			
		||||
	int l = strlen(s);
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	if (s[0]!='.')
 | 
			
		||||
		return bstr_create((uint8_t*)s,l);
 | 
			
		||||
 | 
			
		||||
	if (l<=2)
 | 
			
		||||
		return bstr_create((uint8_t*)s,l);
 | 
			
		||||
 | 
			
		||||
	if (s[1]=='.')
 | 
			
		||||
		return bstr_create((uint8_t*)s+1,l-1);
 | 
			
		||||
 | 
			
		||||
	if (s[1]=='x'){
 | 
			
		||||
		uint8_t * ns=0;
 | 
			
		||||
		int len=0;
 | 
			
		||||
 | 
			
		||||
		int ch,cl;
 | 
			
		||||
		const char *ss = s+2;
 | 
			
		||||
		int rc ;
 | 
			
		||||
		do {
 | 
			
		||||
			rc = sscanf(ss,"%01X",&ch);
 | 
			
		||||
			if (rc!=1)
 | 
			
		||||
				break;
 | 
			
		||||
			ss++;
 | 
			
		||||
			rc = sscanf(ss,"%01X",&cl);
 | 
			
		||||
			if (rc!=1)
 | 
			
		||||
				cl=0;
 | 
			
		||||
			ss++;
 | 
			
		||||
			int c=(ch<<4) | cl;
 | 
			
		||||
			
 | 
			
		||||
			len++;
 | 
			
		||||
			ns = realloc(ns,len);
 | 
			
		||||
			ns[len-1]=c;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		}while (rc==1);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		return bstr_create(ns,len);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,38 +0,0 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
#include "bstr.h"
 | 
			
		||||
#include "cw_util.h"
 | 
			
		||||
 | 
			
		||||
int bstr_to_str(char *dst, bstr_t str,char * def)
 | 
			
		||||
{
 | 
			
		||||
	if (!str){
 | 
			
		||||
		if (!def) 
 | 
			
		||||
			return 0;
 | 
			
		||||
		return sprintf(dst,"%s",def);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	int printable = cw_is_printable(bstr_data(str),bstr_len(str));
 | 
			
		||||
	int l=bstr_len(str);
 | 
			
		||||
 | 
			
		||||
	if (printable){
 | 
			
		||||
		memcpy((char*)dst,bstr_data(str),l);
 | 
			
		||||
		*(dst+l)=0;
 | 
			
		||||
		return l;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	int i;
 | 
			
		||||
	int c=0;
 | 
			
		||||
	char *s = dst; 
 | 
			
		||||
	for (i=0; i<l; i++){
 | 
			
		||||
		if (!c){
 | 
			
		||||
 | 
			
		||||
			s += sprintf(s,"%02X",bstr_data(str)[i]);
 | 
			
		||||
			c=1;
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
			s += sprintf(s,",%02X",bstr_data(str)[i]);
 | 
			
		||||
	}	
 | 
			
		||||
 | 
			
		||||
	return s-dst;
 | 
			
		||||
}
 | 
			
		||||
@ -1,126 +0,0 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
#include "capwap80211_types.h"
 | 
			
		||||
#include "dot11.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 | 
			
		||||
static int to_str(void *item,char *dst)
 | 
			
		||||
{
 | 
			
		||||
	mbag_item_t *it= item;
 | 
			
		||||
 | 
			
		||||
	uint8_t *data = (uint8_t*)it->u2.data;
 | 
			
		||||
	int n=*data;
 | 
			
		||||
	data++;
 | 
			
		||||
 | 
			
		||||
	char *d=dst;
 | 
			
		||||
	char *space="";
 | 
			
		||||
	int i;
 | 
			
		||||
	for (i=0; i<n; i++){
 | 
			
		||||
		int val = data[i];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		d+=sprintf(d,"%s",space);
 | 
			
		||||
		if (val & 0x80){
 | 
			
		||||
			d+=sprintf(d,"*");
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		d+=sprintf(d,"%0.1f",dot11_rate2float(val & 0x7f));
 | 
			
		||||
 | 
			
		||||
		space=" ";
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return d-dst;	
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static struct mbag_item *  from_str(const char *src)
 | 
			
		||||
{
 | 
			
		||||
	mbag_item_t * item = mbag_item_new(CAPWAP80211_TYPE_RATESET);
 | 
			
		||||
	if (!item)
 | 
			
		||||
		return NULL;
 | 
			
		||||
 | 
			
		||||
	if (strlen(src)==0)
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	uint8_t rates[64];
 | 
			
		||||
	int nrates =0;
 | 
			
		||||
 | 
			
		||||
	const char *s = src;
 | 
			
		||||
 | 
			
		||||
	while (*s!=0){
 | 
			
		||||
		while (*s==' ') 
 | 
			
		||||
			s++;
 | 
			
		||||
		int m=0;
 | 
			
		||||
		if(*s=='*'){
 | 
			
		||||
			m=0x80;
 | 
			
		||||
			s++;
 | 
			
		||||
		}
 | 
			
		||||
		else{
 | 
			
		||||
			m=0;
 | 
			
		||||
		}
 | 
			
		||||
	
 | 
			
		||||
		float val;
 | 
			
		||||
		int n=sscanf(s,"%f",&val);
 | 
			
		||||
		if (n!=1)
 | 
			
		||||
			break;
 | 
			
		||||
		
 | 
			
		||||
		int r = dot11_float2rate(val) | m;
 | 
			
		||||
 | 
			
		||||
		rates[nrates++]=r;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		while (*s!=0 && *s!=' ')
 | 
			
		||||
			s++;
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	uint8_t *data = malloc(nrates+1);
 | 
			
		||||
	*data=nrates;
 | 
			
		||||
	memcpy(data+1,rates,nrates);
 | 
			
		||||
 | 
			
		||||
	item->u2.data=data;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	return item;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static struct mbag_item *  get(const uint8_t *src,int len)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	mbag_item_t * item = mbag_item_new(CAPWAP80211_TYPE_RATESET);
 | 
			
		||||
	if (!item)
 | 
			
		||||
		return NULL;
 | 
			
		||||
 | 
			
		||||
	uint8_t *data = malloc(len+1);
 | 
			
		||||
	if (!data){
 | 
			
		||||
		free (item);
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
	*data=len;
 | 
			
		||||
	memcpy(data+1,src,len);
 | 
			
		||||
	item->u2.data=data;
 | 
			
		||||
	return item;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static  int put(struct mbag_item *i,uint8_t *dst)
 | 
			
		||||
{
 | 
			
		||||
	int l=*((uint8_t*)(i->u2.data));
 | 
			
		||||
	memcpy(dst,i->u2.data+1,l);
 | 
			
		||||
	return l;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
const struct mbag_typedef capwap80211_type_rateset = {
 | 
			
		||||
	.name = "802.11 Rate Set",
 | 
			
		||||
	.del = free,
 | 
			
		||||
	.from_str = from_str,
 | 
			
		||||
	.to_str = to_str,
 | 
			
		||||
	.get = get,
 | 
			
		||||
	.put = put
 | 
			
		||||
};
 | 
			
		||||
*/
 | 
			
		||||
@ -1,59 +0,0 @@
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Add a Cisco AP Timesync message element to a buffer
 | 
			
		||||
 * @param dst destination buffer
 | 
			
		||||
 * @param time a unix timestamp
 | 
			
		||||
 * @param type of time
 | 
			
		||||
 * @return number of bytes put (5)
 | 
			
		||||
 */
 | 
			
		||||
/*
 | 
			
		||||
int cw_put_cisco_ap_timesync(uint8_t * dst, time_t time, uint8_t type)
 | 
			
		||||
{
 | 
			
		||||
	cw_put_dword(dst , time);
 | 
			
		||||
	cw_put_byte(dst + 4, type);
 | 
			
		||||
	return 5;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
int cw_addelem_cisco_ap_regulatory_domain(uint8_t *dst, struct radioinfo * ri){
 | 
			
		||||
	uint8_t *d=dst+10;
 | 
			
		||||
	
 | 
			
		||||
	d+=cw_put_byte(d,ri->rid);	// Band ID 
 | 
			
		||||
	d+=cw_put_byte(d,1);		// Set True/False 
 | 
			
		||||
	d+=cw_put_byte(d,ri->rid);	// Slot ID 
 | 
			
		||||
	d+=cw_put_word(d,ri->regDomain);
 | 
			
		||||
	return 5 + cw_put_elem_vendor_hdr(dst, CW_VENDOR_ID_CISCO, CW_CISCO_AP_REGULATORY_DOMAIN, 5);
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/** 
 | 
			
		||||
 * Add a Cisco Certificate payload message element
 | 
			
		||||
 * @param dst destination buffer
 | 
			
		||||
 * @param src pointer to DER certificate
 | 
			
		||||
 * @param len length of certificate
 | 
			
		||||
 * @return number of bytes put
 | 
			
		||||
 */
 | 
			
		||||
/*
 | 
			
		||||
int cw_addelem_cisco_certificate(uint8_t*dst,uint8_t*src,int len){
 | 
			
		||||
	int l = lw_put_certificate(dst+10,src,len);
 | 
			
		||||
	return l+cw_put_elem_vendor_hdr(dst,CW_VENDOR_ID_CISCO,CW_CISCO_CERTIFICATE,l);
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
int cw_addelem_cisco_wtp_radio_cfg(uint8_t * dst,struct radioinfo *ri){
 | 
			
		||||
	int l = lw_put_80211_wtp_wlan_radio_configuration(dst+10,ri);
 | 
			
		||||
	return l+cw_put_elem_vendor_hdr(dst,CW_VENDOR_ID_CISCO,CW_CISCO_STATION_CFG,l);
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
int cw_readelem_cisco_station_cfg(uint8_t *src,int len){
 | 
			
		||||
	
 | 
			
		||||
//	lw_readelem_
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
@ -1,175 +0,0 @@
 | 
			
		||||
#include "capwap.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "radio.h"
 | 
			
		||||
#include "log.h"
 | 
			
		||||
#include "dbg.h"
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
int cw_put_cisco_wtp_radio_cfg(uint8_t *dst, int rid, mbag_t radio)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	cw_put_byte(dst,rid);
 | 
			
		||||
 | 
			
		||||
	cw_put_byte(dst+1,0); //?
 | 
			
		||||
	cw_put_word(dst+2,mbag_get_word(radio,CW_RADIO_OCCUPANCY_LIMIT,12));
 | 
			
		||||
	cw_put_byte(dst+4,mbag_get_byte(radio,CW_RADIO_CFP_PERIOD,8));
 | 
			
		||||
 | 
			
		||||
	cw_put_word(dst+5,mbag_get_word(radio,CW_RADIO_CFP_MAX_DURATION,200));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	bstr_t	grmac = mbag_get_bstr(radio,CW_RADIO_BSSID,NULL);
 | 
			
		||||
 | 
			
		||||
//printf("GRMAC: %d\n",bstr_len(grmac));
 | 
			
		||||
	if ( grmac) {
 | 
			
		||||
		if (bstr_len(grmac)!=6){
 | 
			
		||||
			cw_log(LOG_ERR,"Wrong bssid size");
 | 
			
		||||
exit(0);
 | 
			
		||||
			grmac =NULL;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	bstr_t rmac;
 | 
			
		||||
 | 
			
		||||
	if (!grmac){
 | 
			
		||||
		uint8_t defrmac[]={0,0,0,0,0,0};
 | 
			
		||||
		rmac = bstr_create(defrmac,6);
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
		rmac = grmac;
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
	cw_put_bstr(dst+7,rmac);
 | 
			
		||||
 | 
			
		||||
	if ( !grmac )
 | 
			
		||||
		free(rmac);
 | 
			
		||||
	
 | 
			
		||||
	cw_put_word(dst+13,0); // beacon period
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	cw_put_data(dst+15,mbag_get_raw(radio,CW_RADIO_COUNTRY_STRING,"DE "),3);
 | 
			
		||||
	cw_put_data(dst+18,mbag_get_raw(radio,CW_RADIO_COUNTRY_STRING,"DE "),3);
 | 
			
		||||
 | 
			
		||||
	cw_put_byte(dst+21,10); // gPeriod
 | 
			
		||||
 | 
			
		||||
	cw_put_dword(dst+22,0x3538);	// ?
 | 
			
		||||
 | 
			
		||||
	cw_put_word(dst+26,0);
 | 
			
		||||
 | 
			
		||||
	return 26+2; //+cw_put_elem_vendor_hdr(dst,CW_VENDOR_ID_CISCO,CW_CISCO_WTP_RADIO_CFG,28);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
int cw_put_elem_cisco_ap_regulatory_domain(uint8_t *dst,int rid, mbag_t radio)
 | 
			
		||||
{
 | 
			
		||||
	//int l=0;
 | 
			
		||||
	uint8_t *d=dst+10;
 | 
			
		||||
	
 | 
			
		||||
	d+=cw_put_byte(d,rid);		//Band ID 
 | 
			
		||||
	d+=cw_put_byte(d,1);		// Set True/False 
 | 
			
		||||
	d+=cw_put_byte(d,rid);		//* Slot ID 
 | 
			
		||||
	d+=cw_put_word(d,mbag_get_word(radio,CW_RADIO_REG_DOMAIN,1));
 | 
			
		||||
 | 
			
		||||
	return 5 + cw_put_elem_vendor_hdr(dst, CW_VENDOR_ID_CISCO, CW_CISCO_AP_REGULATORY_DOMAIN, 5);
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
int cw_put_elem_cisco_radio_cfg(uint8_t * dst,int rid, mbag_t radio)
 | 
			
		||||
{
 | 
			
		||||
	int l = cw_put_cisco_wtp_radio_cfg(dst+10,rid,radio);
 | 
			
		||||
	return l+cw_put_elem_vendor_hdr(dst,CW_VENDOR_ID_CISCO,CW_CISCO_WTP_RADIO_CFG,l);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int cw_out_cisco_wtp_radio_cfg(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	int l=0;
 | 
			
		||||
	MAVLITER_DEFINE(it,conn->radios);
 | 
			
		||||
	mavliter_foreach(&it){
 | 
			
		||||
		struct mbag_item *i = mavliter_get(&it);
 | 
			
		||||
		if ( i->type != MBAG_MBAG ) {
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
//		l+=cw_put_elem_radio_info(dst+l,i->id,i->data);
 | 
			
		||||
		l+=cw_put_elem_cisco_radio_cfg(dst+l,i->u1.iid,i->u2.data);
 | 
			
		||||
		l+=cw_put_elem_cisco_ap_regulatory_domain(dst+l,i->u1.iid,i->u2.data);
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	return l;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//	MAVLITER_DEFINE
 | 
			
		||||
//	int l = cw_out_cisco_wtp_radio_cfg_(conn,a,dst,0);
 | 
			
		||||
 | 
			
		||||
//	return l+cw_out_cisco_wtp_radio_cfg_(conn,a,dst+l,1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int cw_in_cisco_radio_cfg(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
 | 
			
		||||
		  struct sockaddr *from)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	int rid = cw_get_byte(data);
 | 
			
		||||
	mbag_t radio = mbag_i_get_mbag(conn->radios,rid,NULL);
 | 
			
		||||
	if ( !radio){
 | 
			
		||||
		cw_dbg(DBG_ELEM_ERR,"Radio ID %d not defined",rid);
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
//	printf("Here we are %d\n",rid);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int cw_radio_cisco_set_state(struct conn * conn, uint8_t *data, int len, int cause)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	int rid = cw_get_byte(data);
 | 
			
		||||
	int state = cw_get_byte(data+1);
 | 
			
		||||
	if (rid != 255)
 | 
			
		||||
		return cw_radio_set_admin_state(conn->radios,rid,state,cause);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	MAVLITER_DEFINE(it,conn->radios);
 | 
			
		||||
	mavliter_foreach(&it){
 | 
			
		||||
		mbag_item_t *i = mavliter_get(&it);
 | 
			
		||||
		cw_radio_set_admin_state(conn->radios,i->u1.iid,state,cause);
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	return 1;	
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int cw_in_cisco_radio_administrative_state(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
 | 
			
		||||
		  struct sockaddr *from)
 | 
			
		||||
{
 | 
			
		||||
	return cw_radio_cisco_set_state(conn,data,len,-1);	
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int cw_in_cisco_radio_administrative_state_wtp(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
 | 
			
		||||
		  struct sockaddr *from)
 | 
			
		||||
{
 | 
			
		||||
	return cw_radio_cisco_set_state(conn,data,len,3);	
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
@ -1,33 +0,0 @@
 | 
			
		||||
 | 
			
		||||
#include "capwap.h"
 | 
			
		||||
 | 
			
		||||
#include "conn.h"
 | 
			
		||||
 | 
			
		||||
#include "mavl.h"
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
void conn_clear_upd(struct conn *conn, int merge)
 | 
			
		||||
{
 | 
			
		||||
	if (merge){
 | 
			
		||||
		mavl_merge(conn->config, conn->config_upd);
 | 
			
		||||
 | 
			
		||||
		MAVLITER_DEFINE (it,conn->radios_upd);
 | 
			
		||||
 | 
			
		||||
		mavliter_foreach(&it){
 | 
			
		||||
			struct mbag_item * ruitem = mavliter_get(&it);
 | 
			
		||||
			mavl_t radio_upd = ruitem->u2.data;
 | 
			
		||||
 | 
			
		||||
			mbag_t radio = mbag_i_get_mbag(conn->radios,ruitem->u1.iid,NULL);
 | 
			
		||||
			if (radio){
 | 
			
		||||
				mavl_merge(radio,radio_upd);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		}		
 | 
			
		||||
		
 | 
			
		||||
	}
 | 
			
		||||
	mavl_del_all(conn->config_upd);
 | 
			
		||||
	mavl_del_all(conn->radios_upd);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
@ -1,26 +0,0 @@
 | 
			
		||||
#include "capwap.h"
 | 
			
		||||
#include "cw.h"
 | 
			
		||||
 | 
			
		||||
int cw_addelem_cisco_wtp_radio_cfg(uint8_t*dst,struct radioinfo *ri)
 | 
			
		||||
{
 | 
			
		||||
	cw_put_byte(dst+10,ri->rid);
 | 
			
		||||
	cw_put_byte(dst+10+1,0);
 | 
			
		||||
	cw_put_word(dst+10+2,ri->occupancy_limit);
 | 
			
		||||
	cw_put_byte(dst+10+4,ri->cfp_period);
 | 
			
		||||
	cw_put_word(dst+10+5,ri->cfp_max_duration);
 | 
			
		||||
 | 
			
		||||
	/* XXX catch rmac shorter or longer than 6*/
 | 
			
		||||
 | 
			
		||||
	cw_put_bstr(dst+10+7,ri->rmac);	/* length MUST be 6 */
 | 
			
		||||
	
 | 
			
		||||
	cw_put_word(dst+10+13,ri->beacon_period);
 | 
			
		||||
	cw_put_data(dst+10+15,ri->country_str,3);
 | 
			
		||||
	cw_put_data(dst+10+18,ri->country_str2,3);
 | 
			
		||||
 | 
			
		||||
	cw_put_byte(dst+10+21,10); // gPeriod
 | 
			
		||||
 | 
			
		||||
	cw_put_dword(dst+10+22,0x3538);	// ?
 | 
			
		||||
 | 
			
		||||
/*	return 28+cw_put_elem_vendor_hdr(dst,CW_VENDOR_ID_CISCO,CW_CISCO_WTP_RADIO_CFG,28);*/
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,18 +0,0 @@
 | 
			
		||||
#include "cw.h"
 | 
			
		||||
#include "dbg.h"
 | 
			
		||||
#include "cw_80211.h"
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
int cw_in_80211_mac_operation(struct conn *conn, struct cw_action_in *a, uint8_t * data,
 | 
			
		||||
			 int len, struct sockaddr *from)
 | 
			
		||||
{
 | 
			
		||||
	int rid = cw_get_byte(data);
 | 
			
		||||
	mbag_t r = mbag_i_get_mbag(conn->radios,rid,NULL);
 | 
			
		||||
	if (!r){
 | 
			
		||||
		cw_dbg(DBG_ELEM_ERR,"Radio %d not defined. Can't set mac operation.");
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return cw_read_80211_mac_operation(data+2,r);
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
@ -1,38 +0,0 @@
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "dbg.h"
 | 
			
		||||
 | 
			
		||||
#include "capwap.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
int cw_in_cisco_image_identifier(struct conn *conn,struct cw_action_in * a,uint8_t *data,int len,struct sockaddr *from)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	if (len<a->min_len) {
 | 
			
		||||
		cw_dbg(DBG_ELEM_ERR,"Message element too short, %d < %d", len,a->min_len);
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	uint32_t vendor_id = cw_get_dword(data);
 | 
			
		||||
	int dstart;
 | 
			
		||||
 | 
			
		||||
	switch (vendor_id) {
 | 
			
		||||
		case CW_VENDOR_ID_ZYXEL:
 | 
			
		||||
		case CW_VENDOR_ID_CISCO:
 | 
			
		||||
		case CW_VENDOR_ID_FSF:
 | 
			
		||||
		case 0:
 | 
			
		||||
			dstart=4;
 | 
			
		||||
			len-=4;
 | 
			
		||||
			break;
 | 
			
		||||
		default:
 | 
			
		||||
			vendor_id=CW_VENDOR_ID_CISCO;
 | 
			
		||||
			dstart=0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
//	mbag_set(conn->remote,a->item_id,a->itemtype,data+dstart,len);
 | 
			
		||||
//	mbag_set_bstrv(conn->incomming,a->item_id,vendor_id,data+dstart,len);
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
@ -1,22 +0,0 @@
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "dbg.h"
 | 
			
		||||
#include "log.h"
 | 
			
		||||
 | 
			
		||||
#include "cw.h"
 | 
			
		||||
#include "radio.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int cw_in_radio_administrative_state(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
 | 
			
		||||
		  struct sockaddr *from)
 | 
			
		||||
{
 | 
			
		||||
/*	int rid = cw_get_byte(data);
 | 
			
		||||
	int state = cw_get_byte(data+1);
 | 
			
		||||
	return cw_radio_set_admin_state(conn->radios,rid,state,-1);
 | 
			
		||||
*/
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,26 +0,0 @@
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "dbg.h"
 | 
			
		||||
#include "log.h"
 | 
			
		||||
 | 
			
		||||
#include "capwap.h"
 | 
			
		||||
#include "radio.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int cw_in_radio_administrative_state_wtp(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
 | 
			
		||||
		  struct sockaddr *from)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	if (!cw_in_radio_administrative_state(conn,a,data,len,from) ) 
 | 
			
		||||
		return 0; 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	return 1;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,123 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
    This file is part of libcapwap.
 | 
			
		||||
 | 
			
		||||
    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 "cw.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "cw_util.h"
 | 
			
		||||
#include "dbg.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
static void readsubelems_wtp_board_data(mbag_t itemstore, uint8_t * msgelem,
 | 
			
		||||
					int len)
 | 
			
		||||
{
 | 
			
		||||
	if (len<4)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	int i = 0;
 | 
			
		||||
//	uint32_t val;
 | 
			
		||||
	do {
 | 
			
		||||
//		val = ntohl(*((uint32_t *) (msgelem + i)));
 | 
			
		||||
//		int subtype = (val >> 16) & 0xffff;
 | 
			
		||||
//		int sublen = val & 0xffff;
 | 
			
		||||
//
 | 
			
		||||
		int subtype = cw_get_word(msgelem+i);
 | 
			
		||||
		int sublen = cw_get_word(msgelem+i+2);
 | 
			
		||||
		i += 4;
 | 
			
		||||
		if (sublen + i > len) {
 | 
			
		||||
			cw_dbg(DBG_ELEM_ERR,
 | 
			
		||||
			       "WTP Board data sub-element too long, type=%d,len=%d",
 | 
			
		||||
			       subtype, sublen);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		cw_dbg(DBG_SUBELEM, "board data sub-element, type=%d (%s), len=%d",
 | 
			
		||||
		       subtype, cw_strboardelem(subtype),sublen);
 | 
			
		||||
 | 
			
		||||
		cw_dbg_dmp(DBG_SUBELEM,msgelem+i,sublen,"Dump...");
 | 
			
		||||
 | 
			
		||||
		switch (subtype) {
 | 
			
		||||
			case CW_BOARDDATA_MODELNO:
 | 
			
		||||
				mbag_set_bstrn(itemstore,
 | 
			
		||||
						       CW_ITEM_WTP_BOARD_MODELNO,
 | 
			
		||||
						       msgelem + i, sublen);
 | 
			
		||||
				break;
 | 
			
		||||
			case CW_BOARDDATA_SERIALNO:
 | 
			
		||||
				mbag_set_bstrn(itemstore,
 | 
			
		||||
						       CW_ITEM_WTP_BOARD_SERIALNO,
 | 
			
		||||
						       msgelem + i, sublen);
 | 
			
		||||
 | 
			
		||||
				break;
 | 
			
		||||
			case CW_BOARDDATA_MACADDRESS:
 | 
			
		||||
				mbag_set_bstrn(itemstore,
 | 
			
		||||
						       CW_ITEM_WTP_BOARD_MACADDRESS,
 | 
			
		||||
						       msgelem + i, sublen);
 | 
			
		||||
 | 
			
		||||
				break;
 | 
			
		||||
			case CW_BOARDDATA_BOARDID:
 | 
			
		||||
				mbag_set_bstrn(itemstore, CW_ITEM_WTP_BOARD_ID,
 | 
			
		||||
						       msgelem + i, sublen);
 | 
			
		||||
				break;
 | 
			
		||||
			case CW_BOARDDATA_REVISION:
 | 
			
		||||
				mbag_set_bstrn(itemstore,
 | 
			
		||||
						       CW_ITEM_WTP_BOARD_REVISION,
 | 
			
		||||
						       msgelem + i, sublen);
 | 
			
		||||
			default:
 | 
			
		||||
				break;
 | 
			
		||||
		}
 | 
			
		||||
		i += sublen;
 | 
			
		||||
 | 
			
		||||
	} while (i < len);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Parse a WTP Board Data messag element and put results to itemstore.
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
 
 | 
			
		||||
 /*
 | 
			
		||||
int cw_in_wtp_board_data(struct conn *conn, struct cw_action_in *a, uint8_t * data,
 | 
			
		||||
			 int len, struct sockaddr *from)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	if (len < 4) {
 | 
			
		||||
		cw_dbg(DBG_ELEM_ERR,
 | 
			
		||||
		       "Discarding WTP_BOARD_DATA msgelem, wrong size, type=%d, len=%d",
 | 
			
		||||
		       a->elem_id, len);
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	mbag_t itemstore = conn->incomming;
 | 
			
		||||
	mbag_set_dword(itemstore, CW_ITEM_WTP_BOARD_VENDOR, cw_get_dword(data));
 | 
			
		||||
 | 
			
		||||
	readsubelems_wtp_board_data(itemstore, data + 4, len - 4);
 | 
			
		||||
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
@ -1,36 +0,0 @@
 | 
			
		||||
#include "cw.h"
 | 
			
		||||
#include "capwap80211.h"
 | 
			
		||||
#include "radio.h"
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
int cw_put_elem_80211_supported_rates(uint8_t*dst,int radio_id,mbag_t radio)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	struct mbag_item * sr = mbag_get(radio,CW_RADIO_SUPPORTED_RATES);
 | 
			
		||||
	if (!sr)
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	int n = cw_put_byte(dst+4,radio_id);
 | 
			
		||||
 | 
			
		||||
	n+=cw_put_mbag_item(dst+5,sr);
 | 
			
		||||
	return 5 + cw_put_elem_hdr(dst,CW_ELEM80211_SUPPORTED_RATES,5);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int cw_out_80211_supported_rates(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	int l=0;
 | 
			
		||||
	MAVLITER_DEFINE(it,conn->radios);
 | 
			
		||||
	mavliter_foreach(&it){
 | 
			
		||||
		struct mbag_item *i = mavliter_get(&it);
 | 
			
		||||
		if ( i->type != MBAG_MBAG ) {
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
		l+=cw_put_elem_80211_supported_rates(dst+l,i->u1.iid,i->u2.data);
 | 
			
		||||
	}
 | 
			
		||||
	return l;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
@ -1,42 +0,0 @@
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "cw.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "dbg.h"
 | 
			
		||||
#include "log.h"
 | 
			
		||||
 | 
			
		||||
#include "acpriolist.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int cw_put_ac_name_with_priority(uint8_t *dst,cw_acprio_t * acprio)
 | 
			
		||||
{
 | 
			
		||||
	int len = strlen(acprio->name);
 | 
			
		||||
	cw_put_byte(dst,acprio->prio);
 | 
			
		||||
	cw_put_data(dst+1,(uint8_t*)acprio->name,len);
 | 
			
		||||
	return len+1;
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int cw_out_ac_name_with_priority(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
 | 
			
		||||
{
 | 
			
		||||
/*	cw_acpriolist_t prios = mbag_get_mavl(conn->config,CW_ITEM_AC_NAME_WITH_PRIORITY);
 | 
			
		||||
	if (!prios)
 | 
			
		||||
		return 0;
 | 
			
		||||
	
 | 
			
		||||
	uint8_t *d = dst;
 | 
			
		||||
	
 | 
			
		||||
	MAVLITER_DEFINE(it,prios);
 | 
			
		||||
	mavliter_foreach(&it){
 | 
			
		||||
		cw_acprio_t * ac = mavliter_get(&it);
 | 
			
		||||
		
 | 
			
		||||
		int l = cw_put_ac_name_with_priority(d+4,ac);
 | 
			
		||||
		d+=cw_put_elem_hdr(d,CW_ELEM_AC_NAME_WITH_PRIORITY,l)+l;		
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return d-dst;
 | 
			
		||||
*/
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,57 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
    This file is part of libcapwap.
 | 
			
		||||
 | 
			
		||||
    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/>.
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @file 
 | 
			
		||||
 * @brief Implementation output handler of capwap cw_out_local_ip_address
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <sys/socket.h>
 | 
			
		||||
#include <netinet/in.h>
 | 
			
		||||
#include <arpa/inet.h>
 | 
			
		||||
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include "cw.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "dbg.h"
 | 
			
		||||
#include "log.h"
 | 
			
		||||
#include "conn.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Output handler for Capwap Local IP Address message element.
 | 
			
		||||
 *
 | 
			
		||||
 * @param conn Connection object
 | 
			
		||||
 * @param action Pointer to action which called this handler
 | 
			
		||||
 * @param dst Destination buffer
 | 
			
		||||
 *
 | 
			
		||||
 * This handler determines the IP address from #conn->sock.
 | 
			
		||||
 * It can deal both with IPv4 and IPv6 sockets.
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
 /*
 | 
			
		||||
int cw_out_capwap_local_ip_address(struct conn *conn, struct cw_action_out *action,
 | 
			
		||||
				   uint8_t * dst)
 | 
			
		||||
{
 | 
			
		||||
	return cw_put_local_ip_address(conn->sock,dst,CW_ELEM_CAPWAP_LOCAL_IPV4_ADDRESS,CW_ELEM_CAPWAP_LOCAL_IPV6_ADDRESS);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
@ -1,58 +0,0 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
 | 
			
		||||
#include "cw.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "log.h"
 | 
			
		||||
#include "dbg.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "sock.h"
 | 
			
		||||
 | 
			
		||||
#include "lwapp.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int cw_out_image_data(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
 | 
			
		||||
{
 | 
			
		||||
	/*
 | 
			
		||||
	mbag_item_t * item = mbag_get(conn->outgoing,CW_ITEM_IMAGE_FILEHANDLE);
 | 
			
		||||
	if (!item) {
 | 
			
		||||
		cw_log(LOG_ERR,"Can't put element Image Data, no image filehandle found");
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	FILE *infile = item->u2.data;
 | 
			
		||||
	if (infile==NULL){
 | 
			
		||||
		cw_log(LOG_ERR,"Image Data Request infile = NULL");
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	int bytes=0;
 | 
			
		||||
	switch ( conn->capwap_mode_out){
 | 
			
		||||
		case CW_MODE_CISCO:
 | 
			
		||||
			bytes = lw_put_image_data(dst+4,infile);
 | 
			
		||||
			if ( bytes != LW_BLOCKSIZE_IMAGE_DATA + 3) {
 | 
			
		||||
       		        	avltree_del(conn->outgoing, item);
 | 
			
		||||
			}
 | 
			
		||||
			break;
 | 
			
		||||
		default:
 | 
			
		||||
			bytes = cw_put_image_data(dst+4,infile);
 | 
			
		||||
			if (dst[4] != 1){
 | 
			
		||||
       		        	avltree_del(conn->outgoing, item);
 | 
			
		||||
			}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ( ferror(infile)){
 | 
			
		||||
		cw_log(LOG_ERROR,"Aborting image data transfer: %s",strerror(errno));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return bytes + cw_put_elem_hdr(dst,a->elem_id,bytes);
 | 
			
		||||
	 */
 | 
			
		||||
	 return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,50 +0,0 @@
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 | 
			
		||||
#include "cw.h"
 | 
			
		||||
#include "cw/dbg.h"
 | 
			
		||||
 | 
			
		||||
int cw_out_radio_generic(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
 | 
			
		||||
{
 | 
			
		||||
cw_dbg(DBG_X,"Radio Generic out %s",a->item_id);
 | 
			
		||||
	
 | 
			
		||||
	int l=0;
 | 
			
		||||
	MAVLITER_DEFINE(it,conn->radios_upd);
 | 
			
		||||
	mavliter_foreach(&it){
 | 
			
		||||
		struct mbag_item *radio = mavliter_get(&it);
 | 
			
		||||
		if ( radio->type != MBAG_MBAG ) {
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Size for msg elem header depends on 
 | 
			
		||||
		  // vendor specific payload 
 | 
			
		||||
		int start = a->vendor_id ? 10 : 4;
 | 
			
		||||
 | 
			
		||||
		uint8_t * d = dst+l;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		struct mbag_item * item = mbag_get(radio->u2.data,a->item_id);
 | 
			
		||||
		if (!item){
 | 
			
		||||
cw_dbg(DBG_X,"Not found! %s for rid %d",a->item_id,radio->u1.iid);
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
		int len=0;
 | 
			
		||||
		len += cw_put_byte(d+start,radio->u1.iid);
 | 
			
		||||
 | 
			
		||||
	cw_dbg(DBG_X, "Radio generic out '%s' fro rid %d",a->item_id,radio->u1.iid);
 | 
			
		||||
		len += cw_put_mbag_item(d + start+1, item);
 | 
			
		||||
 | 
			
		||||
		if (a->vendor_id)
 | 
			
		||||
			l+= len + cw_put_elem_vendor_hdr(d, a->vendor_id, a->elem_id, len);
 | 
			
		||||
		else
 | 
			
		||||
			l += len + cw_put_elem_hdr(d, a->elem_id, len);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	return l;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
@ -1,42 +0,0 @@
 | 
			
		||||
 | 
			
		||||
#include "cw.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "radio.h"
 | 
			
		||||
 | 
			
		||||
#include "dbg.h"
 | 
			
		||||
#include "log.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
int cw_put_elem_radio_info(uint8_t*dst,int radio_id,mbag_t radio)
 | 
			
		||||
{
 | 
			
		||||
	cw_put_byte(dst+4,radio_id);
 | 
			
		||||
	cw_put_dword(dst+5,mbag_get_dword(radio,CW_RADIOITEM80211_WTP_RADIO_INFORMATION,0));
 | 
			
		||||
	return 5 + cw_put_elem_hdr(dst,CW_ELEM80211_WTP_RADIO_INFORMATION,5);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int cw_out_radio_infos(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	int l=0;
 | 
			
		||||
	MAVLITER_DEFINE(it,conn->radios);
 | 
			
		||||
	mavliter_foreach(&it){
 | 
			
		||||
		struct mbag_item *i = mavliter_get(&it);
 | 
			
		||||
		if ( i->type != MBAG_MBAG ) {
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
		l+=cw_put_elem_radio_info(dst+l,i->u1.iid,i->u2.data);
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	return l;
 | 
			
		||||
	 
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,80 +0,0 @@
 | 
			
		||||
#include "log.h"
 | 
			
		||||
#include "capwap.h"
 | 
			
		||||
#include "conn.h"
 | 
			
		||||
#include "cw.h"
 | 
			
		||||
 | 
			
		||||
#define CW_MODE_CISCO 1
 | 
			
		||||
 | 
			
		||||
static int cw_put_encryption_subelems(uint8_t *dst,int capwap_mode)
 | 
			
		||||
{
 | 
			
		||||
	if (capwap_mode==CW_MODE_CISCO){
 | 
			
		||||
		cw_put_word(dst,0x01);
 | 
			
		||||
		return 2;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	int n=2;
 | 
			
		||||
	
 | 
			
		||||
	dst+=cw_put_byte(dst,n);	
 | 
			
		||||
 | 
			
		||||
	int i;
 | 
			
		||||
	for (i=0; i<n; i++){
 | 
			
		||||
		dst+=cw_put_byte(dst,0);
 | 
			
		||||
		dst+=cw_put_byte(dst,0);
 | 
			
		||||
		dst+=cw_put_byte(dst,0);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return 3*n+1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
int cw_out_wtp_descriptor(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	mbag_t mbag = conn->config;
 | 
			
		||||
 | 
			
		||||
	// XXX Dummy WTP Descriptor Header
 | 
			
		||||
	uint8_t *d = dst+4;
 | 
			
		||||
 | 
			
		||||
	d+=cw_put_byte(d,conn->radios->count);	//max radios
 | 
			
		||||
	d+=cw_put_byte(d,2);	//radios in use
 | 
			
		||||
 | 
			
		||||
	d+=cw_put_encryption_subelems(d,conn->capwap_mode);
 | 
			
		||||
 | 
			
		||||
	mbag_item_t * i;
 | 
			
		||||
	i = mbag_get(mbag,CW_ITEM_WTP_HARDWARE_VERSION);
 | 
			
		||||
/*	if ( i ) {	
 | 
			
		||||
	 	d += cw_put_version(d,CW_SUBELEM_WTP_HARDWARE_VERSION,i->u2.data);
 | 
			
		||||
	}
 | 
			
		||||
	else {
 | 
			
		||||
		cw_log(LOG_ERR, "Can't send Hardware Version in WTP Descriptor, not set.");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	i = mbag_get(mbag,CW_ITEM_WTP_SOFTWARE_VERSION);
 | 
			
		||||
	if ( i ) {	
 | 
			
		||||
	 	d += cw_put_version(d,CW_SUBELEM_WTP_SOFTWARE_VERSION,i->u2.data);
 | 
			
		||||
	}
 | 
			
		||||
	else {
 | 
			
		||||
		cw_log(LOG_ERR, "Can't send Software Version in WTP descriptor, not set.");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
        i = mbag_get(mbag,CW_ITEM_WTP_BOOT_VERSION);
 | 
			
		||||
        if ( i ) {
 | 
			
		||||
                d += cw_put_version(d,CW_SUBELEM_WTP_BOOTLOADER_VERSION,i->u2.data);
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
                cw_log(LOG_INFO, "Can't send Boot Version in WTP descriptor, not set.");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        i = mbag_get(mbag,CW_ITEM_WTP_OTHER_VERSION);
 | 
			
		||||
        if ( i ) {
 | 
			
		||||
                d += cw_put_version(d,CW_SUBELEM_WTP_OTHERSOFTWARE_VERSION,i->u2.data);
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
                cw_log(LOG_INFO, "Can't send Other Version in WTP descriptor, not set.");
 | 
			
		||||
        }
 | 
			
		||||
*
 | 
			
		||||
//	int len = d-dst-4;
 | 
			
		||||
//	return len + cw_put_elem_hdr(dst,a->elem_id,len);
 | 
			
		||||
}	
 | 
			
		||||
*/
 | 
			
		||||
@ -1,56 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
    This file is part of libcapwap.
 | 
			
		||||
 | 
			
		||||
    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/>.
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @file 
 | 
			
		||||
 * @brief Implementation output handler of capwap cw_out_local_ip_address
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <sys/socket.h>
 | 
			
		||||
#include <netinet/in.h>
 | 
			
		||||
#include <arpa/inet.h>
 | 
			
		||||
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include "cw.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "dbg.h"
 | 
			
		||||
#include "log.h"
 | 
			
		||||
#include "conn.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Output handler for Capwap Local IP Address message element.
 | 
			
		||||
 *
 | 
			
		||||
 * @param conn Connection object
 | 
			
		||||
 * @param action Pointer to action which called this handler
 | 
			
		||||
 * @param dst Destination buffer
 | 
			
		||||
 *
 | 
			
		||||
 * This handler determines the IP address from #conn->sock.
 | 
			
		||||
 * It can deal both with IPv4 and IPv6 sockets.
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
 /*
 | 
			
		||||
int cw_out_wtp_ip_address(struct conn *conn, struct cw_action_out *action,
 | 
			
		||||
				   uint8_t * dst)
 | 
			
		||||
{
 | 
			
		||||
	return cw_put_local_ip_address(conn->sock,dst,CAPWAP_ELEM_WTP_IPV4_IP_ADDRESS,CAPWAP_ELEM_WTP_IPV6_IP_ADDRESS);
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
@ -1,65 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
    This file is part of actube.
 | 
			
		||||
 | 
			
		||||
    actube 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 "log.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "cw.h"
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
int cw_out_wtp_reboot_statistics(struct conn *conn, struct cw_action_out *a,
 | 
			
		||||
				 uint8_t * dst)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	if (!a->get) {
 | 
			
		||||
		cw_log(LOG_ERROR, "Can't set WTP resboot stats. No get method");
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	struct mbag_item *i = a->get(conn, a);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	if (!i) {
 | 
			
		||||
		if (a->mand) {
 | 
			
		||||
			cw_log(LOG_ERR,
 | 
			
		||||
			       "Can't put mandatory element WTP_REBOOT_STATISTICS");
 | 
			
		||||
			return 0;
 | 
			
		||||
		}
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	mbag_t rs = (mbag_t) i->u2.data;
 | 
			
		||||
 | 
			
		||||
	uint8_t *d = dst + 4;
 | 
			
		||||
	d += cw_put_word(d, mbag_get_word(rs, CW_ITEM_REBOOT_COUNT, 0));
 | 
			
		||||
	d += cw_put_word(d, mbag_get_word(rs, CW_ITEM_REBOOT_AC_INITIATED_COUNT, 0));
 | 
			
		||||
	d += cw_put_word(d, mbag_get_word(rs, CW_ITEM_REBOOT_LINK_FAILURE_COUNT, 0));
 | 
			
		||||
	d += cw_put_word(d, mbag_get_word(rs, CW_ITEM_REBOOT_SW_FAILURE_COUNT, 0));
 | 
			
		||||
	d += cw_put_word(d, mbag_get_word(rs, CW_ITEM_REBOOT_HW_FAILURE_COUNT, 0));
 | 
			
		||||
	d += cw_put_word(d, mbag_get_word(rs, CW_ITEM_REBOOT_OTHER_FAILURE_COUNT, 0));
 | 
			
		||||
	d += cw_put_word(d, mbag_get_word(rs, CW_ITEM_REBOOT_UNKNOWN_FAILURE_COUNT, 0));
 | 
			
		||||
	d += cw_put_byte(d, mbag_get_byte(rs, CW_ITEM_REBOOT_LAST_FAILURE_TYPE, 255));
 | 
			
		||||
 | 
			
		||||
	int l = d - dst - 4;
 | 
			
		||||
	return l + cw_put_elem_hdr(dst, a->elem_id, l);
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
@ -1,31 +0,0 @@
 | 
			
		||||
#include "cw.h"
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Put an cw_ac_stauts structure to a buffer
 | 
			
		||||
 * @param dst destination buffer
 | 
			
		||||
 * @param s #cw_ac_status to put
 | 
			
		||||
 * @return number of bytes put
 | 
			
		||||
 * This function is only useful (used) in conjunction with 
 | 
			
		||||
 * putting AC Descriptor message elements.
 | 
			
		||||
 */
 | 
			
		||||
int cw_put_ac_status(uint8_t * dst, struct cw_ac_status *s, struct conn * conn)
 | 
			
		||||
{
 | 
			
		||||
	uint8_t *d;
 | 
			
		||||
 | 
			
		||||
	d = dst;
 | 
			
		||||
 | 
			
		||||
	d += cw_put_dword(d, (s->stations << 16) | (s->limit));
 | 
			
		||||
	d += cw_put_dword(d, (s->active_wtps << 16) | (s->max_wtps));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	int security = 0;
 | 
			
		||||
	security |= conn->dtls_cert_file ? CAPWAP_FLAG_AC_SECURITY_X : 0;
 | 
			
		||||
	security |= conn->dtls_psk ? CAPWAP_FLAG_AC_SECURITY_S : 0;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	d += cw_put_dword(d,
 | 
			
		||||
			  (security << 24) | (s->rmac_field << 16) | (s->dtls_policy));
 | 
			
		||||
	return d - dst;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,96 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
    This file is part of actube.
 | 
			
		||||
 | 
			
		||||
    actube 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/>.
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @file
 | 
			
		||||
 * @brief Implementation of cw_put_radio_operational_states
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "cw.h"
 | 
			
		||||
 | 
			
		||||
#include "radio.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Put all radio operational states 
 | 
			
		||||
 */
 | 
			
		||||
//int xxcw_put_radio_operational_states(struct xaaa * radios, uint8_t * dst, int *nerror, int d7mode)
 | 
			
		||||
//{/
 | 
			
		||||
	//uint8_t *d=dst;
 | 
			
		||||
 | 
			
		||||
	/* Iterate through all radios and send the CW_RADIO_OPER_STATE item if found.
 | 
			
		||||
	   We assume, that any other processes, dealing with setting the 
 | 
			
		||||
	   the Radio Admin state, adds a CW_RADIO_OPER_STATE item to the radio, 
 | 
			
		||||
	   depending on results. */
 | 
			
		||||
 | 
			
		||||
//	int nerror=0;
 | 
			
		||||
	
 | 
			
		||||
//	*nerror=0;
 | 
			
		||||
 | 
			
		||||
//	MAVLITER_DEFINE(it,radios);
 | 
			
		||||
//	mavliter_foreach(&it){
 | 
			
		||||
 | 
			
		||||
//		mbag_item_t * radioitem = mavliter_get(&it);
 | 
			
		||||
//		mbag_item_t *ositem = mbag_get(radioitem->u2.data,CW_RADIOITEM_OPER_STATE);
 | 
			
		||||
		//if (!ositem){
 | 
			
		||||
	//		(*nerror)++;
 | 
			
		||||
//			continue;//
 | 
			
		||||
//		}//
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		/* Put the radio ID */
 | 
			
		||||
//		cw_put_byte(d+4,radioitem->u1.iid);
 | 
			
		||||
		
 | 
			
		||||
		/* Get the operational state and cause */
 | 
			
		||||
//		uint16_t os = ositem->u2.word;
 | 
			
		||||
 | 
			
		||||
//		if ( d7mode ){//
 | 
			
		||||
			// Isolate Oper Sate from cause 
 | 
			
		||||
//			uint8_t o=os>>8; 
 | 
			
		||||
 | 
			
		||||
//			/* Invert oper state for Cisco, if oper state is 2 or 1 */
 | 
			
		||||
//			if (o!=0 && o<=2) {
 | 
			
		||||
//				/*  2 becomes 1 and 1 becomes 2 */
 | 
			
		||||
//				os = (os & 0x00ff ) | ((3-o)<<8);
 | 
			
		||||
//			}
 | 
			
		||||
//		}
 | 
			
		||||
 | 
			
		||||
//		/* Put oper state */
 | 
			
		||||
//		cw_put_word(d+5,os);
 | 
			
		||||
//		d+=3+cw_put_elem_hdr(d,CW_ELEM_RADIO_OPERATIONAL_STATE,3);
 | 
			
		||||
 | 
			
		||||
		/* delete the operational state item, so it won't be 
 | 
			
		||||
		   sent again, until it is set by a change through
 | 
			
		||||
		   Set Radio Admin State */
 | 
			
		||||
//		mbag_del(radioitem->u2.data,CW_RADIOITEM_OPER_STATE);
 | 
			
		||||
 | 
			
		||||
//	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*	if (nerror) {
 | 
			
		||||
		if (a->mand) {
 | 
			
		||||
			cw_log(LOG_ERROR,"Could not send Radio Operational State for all radios. Sent %d out of %d.",
 | 
			
		||||
				conn->radios->count-nerror,conn->radios->count);
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
*/
 | 
			
		||||
//	return d-dst;
 | 
			
		||||
//}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,16 +0,0 @@
 | 
			
		||||
#include "cw.h"
 | 
			
		||||
 | 
			
		||||
#include "dbg.h"
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
int cw_read_80211_mac_operation(uint8_t *data,mbag_t r)
 | 
			
		||||
{
 | 
			
		||||
	mbag_set_word( r, CW_RADIOITEM80211_RTS_THRESHOLD,cw_get_word(data) );
 | 
			
		||||
	mbag_set_byte( r, CW_RADIOITEM80211_SHORT_RETRY,cw_get_byte(data+2) );
 | 
			
		||||
	mbag_set_byte( r, CW_RADIOITEM80211_LONG_RETRY,cw_get_byte(data+3) );
 | 
			
		||||
	mbag_set_word( r, CW_RADIOITEM80211_FRAGMENTATION_THRESHOLD,cw_get_word(data+4) );
 | 
			
		||||
	mbag_set_dword( r, CW_RADIOITEM80211_TX_MSDU_LIFETIME,cw_get_dword(data+6) );
 | 
			
		||||
	mbag_set_dword( r, CW_RADIOITEM80211_RX_MSDU_LIFETIME,cw_get_dword(data+10) );
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
@ -1,25 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 | 
			
		||||
#include "capwap_cisco.h"
 | 
			
		||||
#include "cw_log.h"
 | 
			
		||||
 | 
			
		||||
int cw_readelem_cisco_wtp_radio_cfg(int elem_id,uint8_t *elem, int len,struct radioinfo *ri)
 | 
			
		||||
{
 | 
			
		||||
	if (elem_id != CW_CISCO_WTP_RADIO_CFG)
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	if (len!=24){
 | 
			
		||||
		cw_dbg(DBG_ELEM,"LWAPP Radio Cfg element too short, %d < 21",len);
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	ri->rid = lw_get_byte(elem);
 | 
			
		||||
	ri->occupancy_limit = lw_get_word(elem+2);
 | 
			
		||||
	bstr_replace(&ri->bssid,bstr_create(elem+7,6));
 | 
			
		||||
	ri->beacon_period = lw_get_word(elem+13);
 | 
			
		||||
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
*/	
 | 
			
		||||
@ -1,40 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
    This file is part of libcapwap.
 | 
			
		||||
 | 
			
		||||
    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/>.
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
/**
 | 
			
		||||
 * @file
 | 
			
		||||
 * @brief Implnts send echo response
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "capwap.h"
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Send an echo response message
 | 
			
		||||
 * @param conn connection, see #conn
 | 
			
		||||
 * @param seqnum sequence number to use
 | 
			
		||||
 * @param radioinfo radioinfo to use, should me NULL
 | 
			
		||||
 * @return 1=Success\nOtherwise Error.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
int cw_send_echo_response(struct conn * conn,int seqnum,struct radioinfo * radioinfo)
 | 
			
		||||
{
 | 
			
		||||
	struct cwmsg * cwmsg = &conn->resp_msg;	
 | 
			
		||||
//	cwmsg_init(cwmsg,conn->resp_buffer,CW_MSG_ECHO_RESPONSE,seqnum,radioinfo);
 | 
			
		||||
 | 
			
		||||
//	conn_send_response(conn,cwmsg,seqnum);
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
@ -1,44 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
    This file is part of libcapwap.
 | 
			
		||||
 | 
			
		||||
    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 <string.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "capwap.h"
 | 
			
		||||
#include "conn.h"
 | 
			
		||||
#include "cwmsg.h"
 | 
			
		||||
 | 
			
		||||
#include <stdio.h> 
 | 
			
		||||
 | 
			
		||||
void cwmsg_addelem_mtu_discovery_padding(struct cwmsg * msg, struct conn* conn)
 | 
			
		||||
{
 | 
			
		||||
	int len = conn->mtu - (msg->msgelems-msg->buffer+msg->pos)-4;
 | 
			
		||||
 | 
			
		||||
printf("MTU discovery len %d %d and pos %d:\n",conn->mtu,len,msg->pos);
 | 
			
		||||
 | 
			
		||||
	if (len < 0 )
 | 
			
		||||
		return;
 | 
			
		||||
	
 | 
			
		||||
	uint32_t val = CAPWAP_ELEM_MTU_DISCOVERY_PADDING<<16|len;
 | 
			
		||||
	*((uint32_t*)(msg->msgelems+msg->pos))=htonl(val);
 | 
			
		||||
	memset(msg->msgelems+4+msg->pos,0xff,len);	
 | 
			
		||||
	msg->pos+=4+len;
 | 
			
		||||
 | 
			
		||||
printf("Nenpos = %d\n",msg->pos);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,63 +0,0 @@
 | 
			
		||||
 | 
			
		||||
#include "lwapp_cisco.h"
 | 
			
		||||
 | 
			
		||||
const char * lw_cisco_id_to_str(int elem_id)
 | 
			
		||||
{
 | 
			
		||||
	switch (elem_id){
 | 
			
		||||
		case LW_CISCO_AP_LOGHOST_CONFIG:
 | 
			
		||||
			return "AP Loghost Config and Last Joined Controller";
 | 
			
		||||
		case LW_CISCO_PATH_MTU:
 | 
			
		||||
			return "Path MTU";
 | 
			
		||||
		case LW_CISCO_MWAR_HASH_VALUE:
 | 
			
		||||
			return "MWAR Hash Value";
 | 
			
		||||
		case LW_CISCO_MWAR_HASH_VALUE_1:
 | 
			
		||||
			return "MWAR Hah Value 1";			
 | 
			
		||||
		case LW_CISCO_AP_USERNAME_PASSWORD:
 | 
			
		||||
			return "AP Username and Password";
 | 
			
		||||
		case LW_CISCO_AC_IP_ADDR_WITH_INDEX:
 | 
			
		||||
			return "AC IP Addr with Index";
 | 
			
		||||
		case LW_CISCO_AP_SUBMODE:
 | 
			
		||||
			return "AP Submode";
 | 
			
		||||
		case LW_CISCO_SSC_HASH_VALIDATION:
 | 
			
		||||
			return "SSC Hash Validation";
 | 
			
		||||
 | 
			
		||||
		case LW_CISCO_DOT11R_WLC_MAC_AND_IP:
 | 
			
		||||
			return "802.11r WLC MAC and IP";
 | 
			
		||||
		case LW_CISCO_AP_JOIN_IP_PREF_MODE:
 | 
			
		||||
			return "AP Join IP Pref Mode";
 | 
			
		||||
			
 | 
			
		||||
		case LW_CISCO_MCAST_MGID_INFO:
 | 
			
		||||
			return "MCAST MGID Info";
 | 
			
		||||
		case LW_CISCO_RADIO_MODULE_INFO:
 | 
			
		||||
			return "Radio Module Info";
 | 
			
		||||
		case LW_CISCO_TELNET_SSH:
 | 
			
		||||
			return "Telnet SSH";
 | 
			
		||||
		case LW_CISCO_AP_DTLS_DATA_CFG:
 | 
			
		||||
			return "AP DTLS Data Config";
 | 
			
		||||
 | 
			
		||||
		case LW_CISCO_PRIMED_JOIN_TIMEOUT:
 | 
			
		||||
			return "Primed Join Timeout";			
 | 
			
		||||
 | 
			
		||||
		case LW_CISCO_PRIMED_DISCOVERY_TIMEOUT:
 | 
			
		||||
			return "Primed Discovery Timeout";
 | 
			
		||||
 | 
			
		||||
		case LW_CISCO_RAD_EXTENDED_CONFIG:
 | 
			
		||||
			return "RAD Extended Config";
 | 
			
		||||
 | 
			
		||||
		case LW_CISCO_MANAGER_IP_ADDR:
 | 
			
		||||
			return "Manager IP Address";
 | 
			
		||||
 | 
			
		||||
		case LW_CISCO_ADD_WLAN:
 | 
			
		||||
			return "Add WLAN?";
 | 
			
		||||
 | 
			
		||||
		case LW_CISCO_DELETE_WLAN:
 | 
			
		||||
			return "Delete WLAN?";
 | 
			
		||||
 | 
			
		||||
		default: 
 | 
			
		||||
			return "Unknown";
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return "Unknown";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,53 +0,0 @@
 | 
			
		||||
 | 
			
		||||
#include "cw.h"
 | 
			
		||||
#include "dbg.h"
 | 
			
		||||
#include "log.h"
 | 
			
		||||
/*#include "stravltree.h"*/
 | 
			
		||||
 | 
			
		||||
/** 
 | 
			
		||||
 * @file 
 | 
			
		||||
 * @brief Implementation of LWAPP Vendor Specific Payload
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Default handler for LWAPP Vendor Specific Payload message elements.
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
 /*
 | 
			
		||||
int lw_in_vendor_specific(struct conn *conn, struct cw_action_in *a,
 | 
			
		||||
				  uint8_t * data, int len, struct sockaddr *from)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	cw_action_in_t as, *af;
 | 
			
		||||
	as = *a;
 | 
			
		||||
 | 
			
		||||
	as.vendor_id = cw_get_dword(data);
 | 
			
		||||
	as.elem_id = cw_get_word(data + 4);
 | 
			
		||||
	as.proto = CW_ACTION_PROTO_LWAPP;
 | 
			
		||||
 | 
			
		||||
// TODO XXXX
 | 
			
		||||
	//af = cw_actionlist_in_get(conn->actions->in, &as);
 | 
			
		||||
//	
 | 
			
		||||
	af = 0;
 | 
			
		||||
 | 
			
		||||
	if (!af) {
 | 
			
		||||
		cw_dbg(DBG_WARN,
 | 
			
		||||
		       "Can't handle Vendor Specific LWAPP Payload %s/%d, in msg %d (%s) in %s state.",
 | 
			
		||||
		       cw_strvendor(as.vendor_id), as.elem_id, as.msg_id,
 | 
			
		||||
		       cw_strmsg(as.msg_id), cw_strstate(as.capwap_state));
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (af->start) {
 | 
			
		||||
		int afrc = af->start(conn, af, data + 6, len - 6, from);
 | 
			
		||||
		if (af->mand && afrc) {
 | 
			
		||||
			// add found mandatory message element 
 | 
			
		||||
			   //to mand list 
 | 
			
		||||
// XXXX			stravltree_add(conn->mand, af->item_id); 
 | 
			
		||||
		}
 | 
			
		||||
		return afrc;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
@ -1,44 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
    This file is part of libcapwap.
 | 
			
		||||
 | 
			
		||||
    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/>.
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @file
 | 
			
		||||
 * @brief Implementation of lw_put_cisco_path_mtu
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "lwapp_cisco.h"
 | 
			
		||||
#include "lw.h"
 | 
			
		||||
#include "vendors.h"
 | 
			
		||||
 | 
			
		||||
/** 
 | 
			
		||||
 * Put message element data for Cisco vendor specific LWAPP message
 | 
			
		||||
 * Csico Path MTU.
 | 
			
		||||
 * @param dst destination buffer
 | 
			
		||||
 * @param max maximum MTU
 | 
			
		||||
 * @param padding number of bytes to append
 | 
			
		||||
 * @return number of bytes put to buffer 
 | 
			
		||||
 */
 | 
			
		||||
int lw_put_cisco_path_mtu(uint8_t *dst, uint16_t max, uint16_t padding)
 | 
			
		||||
{
 | 
			
		||||
	lw_set_dword(dst,LW_VENDOR_ID_CISCO);
 | 
			
		||||
	lw_set_word(dst+4,LW_CISCO_PATH_MTU);
 | 
			
		||||
	lw_set_word(dst+6,max);
 | 
			
		||||
	lw_set_word(dst+8,padding+4);
 | 
			
		||||
	memset(dst+10,0,padding);
 | 
			
		||||
	return padding+10;
 | 
			
		||||
}
 | 
			
		||||
@ -1,32 +0,0 @@
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "log.h"
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
int mbag_get_upd(mbag_t b, mbag_t b_upd, const char *id, uint8_t *dst, int *found)
 | 
			
		||||
{
 | 
			
		||||
	struct mbag_item *i = mbag_get(b_upd, id);
 | 
			
		||||
	if (i) {
 | 
			
		||||
		if (!i->type->put ){
 | 
			
		||||
			cw_log(LOG_ERROR,"No put method for %s",i->type->name);
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
		(*found)++;
 | 
			
		||||
		return i->type->put(i, dst);
 | 
			
		||||
	}
 | 
			
		||||
	i = mbag_get(b,id);
 | 
			
		||||
	if (i) {
 | 
			
		||||
		if (!i->type->put){
 | 
			
		||||
			cw_log(LOG_ERROR,"No put method for %s",i->type->name);
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return i->type->put(i, dst);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return -1;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
@ -1,54 +0,0 @@
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
#include "radio.h"
 | 
			
		||||
#include "dbg.h"
 | 
			
		||||
 | 
			
		||||
const char CW_RADIO_TYPE[]="radio_type";
 | 
			
		||||
const char CW_RADIO_REG_DOMAIN[]="reg_domain";
 | 
			
		||||
const char CW_RADIO_BSSID[]="bssid";
 | 
			
		||||
const char CW_RADIO_SHORT_PREAMBLE[]="short_preamble";
 | 
			
		||||
const char CW_RADIO_COUNTRY_STRING[]="country_string";
 | 
			
		||||
const char CW_RADIO_DECRYPTION_ERROR_REPORT_PERIOD[]="decryption_error_report_period";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
const char CW_RADIO_SUPPORTED_RATES[]="supported_rates";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Cisco 
 | 
			
		||||
 | 
			
		||||
const char CW_RADIO_OCCUPANCY_LIMIT[]="occupancy_limit";
 | 
			
		||||
const char CW_RADIO_CFP_PERIOD[]="cfp_period";
 | 
			
		||||
const char CW_RADIO_CFP_MAX_DURATION[]="cfp_max_duration";
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
struct cw_itemdef xxxcapwap_radioitemdefs[] = {
 | 
			
		||||
//{CW_RADIO_ADMIN_STATE,CW_ITEM_NONE,MBAG_BYTE},
 | 
			
		||||
{CW_RADIO_TYPE,CW_ITEM_NONE,MTYPE_DWORD},
 | 
			
		||||
{CW_RADIO_DECRYPTION_ERROR_REPORT_PERIOD,CW_ITEM_NONE,MBAG_WORD},
 | 
			
		||||
 | 
			
		||||
{CW_RADIO_BSSID,CW_ITEM_NONE,MBAG_BSTR16},
 | 
			
		||||
{CW_RADIO_SUPPORTED_RATES,CW_ITEM_NONE,MBAG_DATA},
 | 
			
		||||
 | 
			
		||||
{CW_ITEM_NONE}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int cw_radio_set_all_admin_states(mbag_t radios,int state, int cause)
 | 
			
		||||
{
 | 
			
		||||
	MAVLITER_DEFINE(it,radios);
 | 
			
		||||
	mavliter_foreach(&it){
 | 
			
		||||
		mbag_item_t *i = mavliter_get(&it);
 | 
			
		||||
		cw_radio_set_admin_state(radios,i->u1.iid,state,cause);
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	return 1;	
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
@ -1,62 +0,0 @@
 | 
			
		||||
#ifndef __CW_RADIO_H
 | 
			
		||||
#define __CW_RADIO_H
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "conn.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
//extern const char CW_RADIO_ADMIN_STATE[];
 | 
			
		||||
//extern const char CW_RADIO_OPER_STATE[];
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
extern const char CW_RADIO_SUPPORTED_RATES[];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
extern const char CW_RADIO_TYPE[];
 | 
			
		||||
extern const char CW_RADIO_REG_DOMAIN[];
 | 
			
		||||
extern const char CW_RADIO_BSSID[];
 | 
			
		||||
extern const char CW_RADIO_SHORT_PREAMBLE[];
 | 
			
		||||
extern const char CW_RADIO_COUNTRY_STRING[];
 | 
			
		||||
extern const char CW_RADIO_DECRYPTION_ERROR_REPORT_PERIOD[];
 | 
			
		||||
 | 
			
		||||
/* Cisco */
 | 
			
		||||
 | 
			
		||||
extern const char CW_RADIO_OCCUPANCY_LIMIT[];
 | 
			
		||||
extern const char CW_RADIO_CFP_PERIOD[];
 | 
			
		||||
extern const char CW_RADIO_CFP_MAX_DURATION[];
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
enum radiodata{
 | 
			
		||||
	CW_RADIO_ADMIN_STATE=10000,
 | 
			
		||||
	CW_RADIO_OPER_STATE,
 | 
			
		||||
	CW_RADIO_TYPE,
 | 
			
		||||
	CW_RADIO_REG_DOMAIN,
 | 
			
		||||
	CW_RADIO_BSSID,
 | 
			
		||||
	CW_RADIO_SHORT_PREAMBLE,
 | 
			
		||||
	CW_RADIO_COUNTRY_STRING,
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	CW_RADIO_OCCUPANCY_LIMIT,
 | 
			
		||||
	CW_RADIO_CFP_PERIOD,
 | 
			
		||||
	CW_RADIO_CFP_MAX_DURATION
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}[];
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
int cw_radio_update_oper_states(mbag_t radios,int cause);
 | 
			
		||||
extern struct cw_itemdef capwap_radioitemdefs[];
 | 
			
		||||
extern int cw_radio_set_all_admin_states(mbag_t radios,int state, int cause);
 | 
			
		||||
 | 
			
		||||
int cw_out_80211_supported_rates(struct conn *conn, struct cw_action_out *a, uint8_t * dst);
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
@ -429,10 +429,13 @@ static struct cw_ElemHandler handlers[] = {
 | 
			
		||||
		CAPWAP_ELEM_RADIO_OPERATIONAL_STATE,		/* Element ID */
 | 
			
		||||
		0, 0,						/* Vendor / Proto */
 | 
			
		||||
		3, 3,						/* min/max length */
 | 
			
		||||
		radio_operational_state,			/* type */
 | 
			
		||||
		CW_TYPE_STRUCT,					/* type */
 | 
			
		||||
		"capwap/operational-state",			/* Key */
 | 
			
		||||
		cw_in_radio_generic_struct,			/* get */
 | 
			
		||||
		cw_out_radio_generic_struct			/* put */
 | 
			
		||||
		cw_in_radio_generic,				/* get */
 | 
			
		||||
		cw_out_radio_generic,				/* put */
 | 
			
		||||
		NULL,
 | 
			
		||||
		NULL,
 | 
			
		||||
		radio_operational_state
 | 
			
		||||
	}
 | 
			
		||||
	,
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -9,7 +9,7 @@
 | 
			
		||||
 | 
			
		||||
#include "mod_capwap.h"
 | 
			
		||||
 | 
			
		||||
static int init(struct cw_Mod * mod, mavl_t global_cfg, int role)
 | 
			
		||||
static int init(struct cw_Mod * mod, cw_Cfg_t * global_cfg, int role)
 | 
			
		||||
{
 | 
			
		||||
	cw_dbg(DBG_INFO,"CAPWAP: Inititalizing mod_capwap.");
 | 
			
		||||
	
 | 
			
		||||
@ -51,7 +51,7 @@ int static setup_cfg(struct cw_Conn  * conn)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//	stop();
 | 
			
		||||
//	cw_ktv_set_byte(conn->local_cfg,"ac-descriptor/security",security);
 | 
			
		||||
	cw_cfg_set_int(conn->local_cfg,"ac-descriptor/security",security);
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -18,7 +18,7 @@ static int init()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int elems_len,
 | 
			
		||||
static int detect(struct cw_Conn *conn, const uint8_t * rawmsg, int rawlen, int elems_len,
 | 
			
		||||
		  struct sockaddr *from, int mode)
 | 
			
		||||
{
 | 
			
		||||
	int wbid;
 | 
			
		||||
@ -68,4 +68,4 @@ struct cw_Mod *mod_capwap80211_ac()
 | 
			
		||||
{
 | 
			
		||||
	return &capwap80211_ac;
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
@ -1833,10 +1833,13 @@ static struct cw_ElemHandler handlers70[] = {
 | 
			
		||||
		CISCO_ELEM_AP_QOS,			/* Element ID */
 | 
			
		||||
		CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
			
		||||
		52,52,					/* min/max length */
 | 
			
		||||
		cisco_ap_qos,				/* type */
 | 
			
		||||
		CW_TYPE_STRUCT,				/* type */
 | 
			
		||||
		"cisco/ap-qos",				/* Key */
 | 
			
		||||
		cw_in_radio_generic_struct,		/* get */
 | 
			
		||||
		cw_out_radio_generic_struct		/* put */
 | 
			
		||||
		cw_in_radio_generic,		/* get */
 | 
			
		||||
		cw_out_radio_generic, /* put */
 | 
			
		||||
		NULL,
 | 
			
		||||
		NULL,
 | 
			
		||||
		cisco_ap_qos,
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	{ 
 | 
			
		||||
@ -2092,10 +2095,13 @@ static struct cw_ElemHandler handlers70[] = {
 | 
			
		||||
		CISCO_LWELEM_RAD_EXTENDED_CONFIG,	/* Element ID */
 | 
			
		||||
		CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP,	/* Vendor / Proto */
 | 
			
		||||
		13,13,					/* min/max length */
 | 
			
		||||
		cisco_rad_extended_config,		/* type */
 | 
			
		||||
		CW_TYPE_STRUCT,				/* type */
 | 
			
		||||
		"cisco/rad-extended-config",		/* Key */
 | 
			
		||||
		cw_in_radio_generic_struct,		/* get */
 | 
			
		||||
		cw_out_radio_generic_struct		/* put */
 | 
			
		||||
		cw_in_radio_generic,		/* get */
 | 
			
		||||
		cw_out_radio_generic,		/* put */
 | 
			
		||||
		NULL,
 | 
			
		||||
		NULL,
 | 
			
		||||
		cisco_rad_extended_config,
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	{
 | 
			
		||||
@ -2732,10 +2738,13 @@ static struct cw_ElemHandler handlers73[] = {
 | 
			
		||||
		CISCO_ELEM_WTP_RADIO_CONFIGURATION,	/* Element ID */
 | 
			
		||||
		CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
			
		||||
		27,27,					/* min/max length */
 | 
			
		||||
		cisco_wtp_radio_config73,		/* type */
 | 
			
		||||
		CW_TYPE_STRUCT,				/* type */
 | 
			
		||||
		"cisco/wtp-radio-config",		/* Key */
 | 
			
		||||
		cw_in_radio_generic_struct,		/* get */
 | 
			
		||||
		cw_out_radio_generic_struct		/* put */
 | 
			
		||||
		cw_in_radio_generic,		/* get */
 | 
			
		||||
		cw_out_radio_generic,		/* put */
 | 
			
		||||
		NULL,
 | 
			
		||||
		NULL,
 | 
			
		||||
		cisco_wtp_radio_config73,
 | 
			
		||||
	}
 | 
			
		||||
	,
 | 
			
		||||
 | 
			
		||||
@ -2765,10 +2774,13 @@ static struct cw_ElemHandler handlers75[] = {
 | 
			
		||||
		CISCO_ELEM_WTP_RADIO_CONFIGURATION,	/* Element ID */
 | 
			
		||||
		CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
			
		||||
		28,28,					/* min/max length */
 | 
			
		||||
		cisco_wtp_radio_config75,		/* type */
 | 
			
		||||
		CW_TYPE_STRUCT,				/* type */
 | 
			
		||||
		"cisco/wtp-radio-config",		/* Key */
 | 
			
		||||
		cw_in_radio_generic_struct,		/* get */
 | 
			
		||||
		cw_out_radio_generic_struct		/* put */
 | 
			
		||||
		cw_in_radio_generic,			/* get */
 | 
			
		||||
		cw_out_radio_generic,			/* put */
 | 
			
		||||
		NULL,
 | 
			
		||||
		NULL,
 | 
			
		||||
		cisco_wtp_radio_config75,
 | 
			
		||||
	}
 | 
			
		||||
	,
 | 
			
		||||
	{ 
 | 
			
		||||
@ -2776,10 +2788,13 @@ static struct cw_ElemHandler handlers75[] = {
 | 
			
		||||
		CISCO_ELEM_MAC_OPERATION,		/* Element ID */
 | 
			
		||||
		CW_VENDOR_ID_CISCO,0,			/* Vendor / Proto */
 | 
			
		||||
		17,17,					/* min/max length */
 | 
			
		||||
		cisco_mac_operation75,			/* type */
 | 
			
		||||
		CW_TYPE_STRUCT,				/* type */
 | 
			
		||||
		"cisco/mac-operation",			/* Key */
 | 
			
		||||
		cw_in_radio_generic_struct,		/* get */
 | 
			
		||||
		cw_out_radio_generic_struct		/* put */
 | 
			
		||||
		cw_in_radio_generic,			/* get */
 | 
			
		||||
		cw_out_radio_generic,			/* put */
 | 
			
		||||
		NULL,
 | 
			
		||||
		NULL,
 | 
			
		||||
		cisco_mac_operation75,
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	{0,0,0,0,0,0,0,0}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user