Reading wtp descriptor works now - at least cisco
FossilOrigin-Name: ee2e8a3fdf9d353237161a0af0148367afc20e8020315108c02154d9df521938
This commit is contained in:
		@ -319,6 +319,9 @@
 | 
			
		||||
      <File Name="src/cw/cw_types_mavl_delete.c"/>
 | 
			
		||||
      <File Name="src/cw/cw_format_scan_hex_bytes.c"/>
 | 
			
		||||
      <File Name="src/cw/cw_type_version.c"/>
 | 
			
		||||
      <File Name="src/cw/cw_dbg_elem.c"/>
 | 
			
		||||
      <File Name="src/cw/cw_kvstore_mavl_delete.c"/>
 | 
			
		||||
      <File Name="src/cw/cw_format_version.c"/>
 | 
			
		||||
    </VirtualDirectory>
 | 
			
		||||
  </VirtualDirectory>
 | 
			
		||||
  <Description/>
 | 
			
		||||
 | 
			
		||||
@ -216,7 +216,7 @@ int cw_in_check_generic(struct conn *conn, struct cw_action_in *a, uint8_t * dat
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
void cw_read_elem(struct cw_ElemHandler * handler, struct conn * conn, 
 | 
			
		||||
		uint8_t * elem_data, int elem_len, struct sockaddr * from){
 | 
			
		||||
	mavldata_t data, *result;
 | 
			
		||||
@ -226,8 +226,10 @@ void cw_read_elem(struct cw_ElemHandler * handler, struct conn * conn,
 | 
			
		||||
	
 | 
			
		||||
	handler->type->to_str(result,str,30);
 | 
			
		||||
	printf("Read %d-%s: %s %s\n", handler->id, handler->name, handler->key, str);
 | 
			
		||||
	/*mavl_add(conn->remote_cfg*/
 | 
			
		||||
	//mavl_add(conn->remote_cfg
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
 | 
			
		||||
			    struct sockaddr *from)
 | 
			
		||||
@ -399,8 +401,8 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
 | 
			
		||||
		
 | 
			
		||||
		elem_len = cw_get_elem_len(elem);
 | 
			
		||||
 | 
			
		||||
printf ("Would start elem processing now %d - %s\n",handler->id, handler->name);
 | 
			
		||||
		
 | 
			
		||||
/*printf ("Would start elem processing now %d - %s\n",handler->id, handler->name);
 | 
			
		||||
*/		
 | 
			
		||||
		handler->get(conn, handler, cw_get_elem_data(elem), elem_len, from);
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -311,7 +311,7 @@ struct cw_DescriptorSubelemDef {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
extern int cw_read_descriptor_subelems(mavl_t store, uint8_t * data, int len,
 | 
			
		||||
extern int cw_read_descriptor_subelems(mavl_t store, const char * key, uint8_t * data, int len,
 | 
			
		||||
				       struct cw_DescriptorSubelemDef *elems);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										61
									
								
								src/cw/cw_dbg_elem.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								src/cw/cw_dbg_elem.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,61 @@
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
#include "dbg.h"
 | 
			
		||||
#include "format.h"
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * print debug info for message elements
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
void cw_dbg_elem_x(int level, struct conn *conn, int msg, int msgelem,
 | 
			
		||||
			 const uint8_t * msgbuf, int len)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	const char *elemname;
 | 
			
		||||
	char vendorname[256];
 | 
			
		||||
	char vendor_details[265];
 | 
			
		||||
 | 
			
		||||
	if (!cw_dbg_is_level(level))
 | 
			
		||||
		return;
 | 
			
		||||
		
 | 
			
		||||
	*vendor_details = 0;
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
/*	
 | 
			
		||||
/// TODO XXXX
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
	if (msgelem == CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD) {
 | 
			
		||||
		uint32_t vendor_id = ntohl(*((uint32_t *) msgbuf));
 | 
			
		||||
		int type = ntohs(*((uint16_t *) (msgbuf + 4)));
 | 
			
		||||
		cw_format_vendor(vendor_details, vendor_id, type, msgbuf);
 | 
			
		||||
//		sprintf(vendorname, "%s/%s/%s",
 | 
			
		||||
//			cw_strelemp(conn->actions, msgelem),
 | 
			
		||||
//			(char *) cw_strvendor(vendor_id), vendor_details);
 | 
			
		||||
 | 
			
		||||
		elemname = vendorname;
 | 
			
		||||
 | 
			
		||||
	} else {
 | 
			
		||||
		
 | 
			
		||||
//		elemname = cw_strelemp(conn->actions, msgelem);
 | 
			
		||||
 | 
			
		||||
		elemname=0;
 | 
			
		||||
	}
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/*&
 | 
			
		||||
	if (!cw_dbg_is_level(DBG_ELEM_DMP)) {
 | 
			
		||||
		cw_dbg(DBG_ELEM, "%d (%s), len=%d", msgelem, elemname, len);
 | 
			
		||||
	} else {
 | 
			
		||||
		char *dmp;
 | 
			
		||||
		dmp = cw_format_dump(msgbuf,len,NULL);
 | 
			
		||||
 | 
			
		||||
		cw_dbg(DBG_ELEM, "%d (%s), len=%d%s%s",
 | 
			
		||||
		       msgelem, elemname, len, get_dbg_color_ontext(DBG_ELEM_DMP), dmp);
 | 
			
		||||
 | 
			
		||||
		free(dmp);
 | 
			
		||||
	}
 | 
			
		||||
*/
 | 
			
		||||
  }
 | 
			
		||||
							
								
								
									
										44
									
								
								src/cw/cw_format_version.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								src/cw/cw_format_version.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,44 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include "format.h"
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Format a version element
 | 
			
		||||
 * @param s
 | 
			
		||||
 * @param version
 | 
			
		||||
 * @param len
 | 
			
		||||
 * @return number of bytes written
 | 
			
		||||
 */
 | 
			
		||||
int cw_format_version(char *s, const uint8_t * version, int len)
 | 
			
		||||
{
 | 
			
		||||
	int dot,rs,i;;
 | 
			
		||||
 | 
			
		||||
	rs = 0;
 | 
			
		||||
 | 
			
		||||
	if (format_is_utf8(version, len)) {
 | 
			
		||||
		if (len != 0)
 | 
			
		||||
			rs += sprintf(s + rs, "%.*s", len, version);
 | 
			
		||||
		else
 | 
			
		||||
			rs += sprintf(s + rs, "''");
 | 
			
		||||
	} else {
 | 
			
		||||
		for (i = 0; i < len && i < 20; i++) {
 | 
			
		||||
			rs += sprintf(s + rs, "%02X", version[i]);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		dot = 0;
 | 
			
		||||
 | 
			
		||||
		rs += sprintf(s + rs, " (");
 | 
			
		||||
		for (i = 0; i < len && i < 20; i++) {
 | 
			
		||||
			if (dot)
 | 
			
		||||
				rs += sprintf(s + rs, ".");
 | 
			
		||||
			dot = 1;
 | 
			
		||||
			rs += sprintf(s + rs, "%d", version[i]);
 | 
			
		||||
		}
 | 
			
		||||
		rs += sprintf(s + rs, ")");
 | 
			
		||||
	}
 | 
			
		||||
/*
 | 
			
		||||
	vendor = bstrv_get_vendor_id(ver);
 | 
			
		||||
	rs += sprintf(s + rs, ", Vendor Id: %d, %s", vendor, cw_strvendor(vendor));
 | 
			
		||||
*/
 | 
			
		||||
	return rs;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -36,7 +36,7 @@ int cw_in_ac_descriptor(struct conn *conn, struct cw_action_in *a, uint8_t * dat
 | 
			
		||||
		{0,0, NULL,0, 0}
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	cw_read_descriptor_subelems(conn->config, data + 12, len - 12, allowed);
 | 
			
		||||
	cw_read_descriptor_subelems(conn->config,"ackey" , data + 12, len - 12, allowed);
 | 
			
		||||
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -10,7 +10,8 @@ int cw_in_generic(struct conn * conn,  struct cw_ElemHandler * handler,
 | 
			
		||||
	result->kv.key = strdup(handler->key);
 | 
			
		||||
	
 | 
			
		||||
	handler->type->to_str(result,str,30);
 | 
			
		||||
	printf("Read %d-%s: %s %s\n", handler->id, handler->name, handler->key, str);
 | 
			
		||||
/*	printf("Read %d-%s: %s %s\n", handler->id, handler->name, handler->key, str);
 | 
			
		||||
 */
 | 
			
		||||
	mavl_add(conn->remote_cfg, result);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,13 @@
 | 
			
		||||
#include "cw_types.h"
 | 
			
		||||
 | 
			
		||||
void cw_types_mavl_delete(mavldata_t *data){
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
#include "cw_types.h"
 | 
			
		||||
#include "kvstore.h"
 | 
			
		||||
 | 
			
		||||
void cw_types_kvstore_mavl_delete(mavldata_t *data){
 | 
			
		||||
	const struct cw_Type * type = data->kv.priv;
 | 
			
		||||
	if (type->del)
 | 
			
		||||
		type->del(data);
 | 
			
		||||
	free(data->kv.key);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -34,7 +34,7 @@ int cw_read_ac_descriptor(mbag_t store, uint8_t *data, int len,
 | 
			
		||||
	if (!allowed)
 | 
			
		||||
		allowed=allowed_default;
 | 
			
		||||
 | 
			
		||||
	return cw_read_descriptor_subelems(store, data + 12, len - 12, allowed);
 | 
			
		||||
	return cw_read_descriptor_subelems(store, "key", data + 12, len - 12, allowed);
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -17,29 +17,29 @@
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include "cw.h"
 | 
			
		||||
#include "cw_types.h"
 | 
			
		||||
#include "dbg.h"
 | 
			
		||||
#include "keys.h"
 | 
			
		||||
 | 
			
		||||
int cw_read_descriptor_subelems(mavl_t store, uint8_t * data, int len,
 | 
			
		||||
int cw_read_descriptor_subelems(mavl_t cfg, const char * parent_key, 
 | 
			
		||||
				uint8_t * data, int len,
 | 
			
		||||
				struct cw_DescriptorSubelemDef *elems)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	printf("sub reader\n");
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	uint32_t vendor_id;
 | 
			
		||||
	int sublen,subtype;
 | 
			
		||||
	int errors = 0;
 | 
			
		||||
	int success = 0;
 | 
			
		||||
	int sub = 0;
 | 
			
		||||
	while (sub < len) {
 | 
			
		||||
		int i;
 | 
			
		||||
		
 | 
			
		||||
		if (len - sub < 8) {
 | 
			
		||||
			return 0;
 | 
			
		||||
		}
 | 
			
		||||
		uint32_t vendor_id = cw_get_dword(data + sub);
 | 
			
		||||
		int sublen = cw_get_word(data + sub + 6);
 | 
			
		||||
		int subtype = cw_get_word(data + sub + 4);
 | 
			
		||||
		vendor_id = cw_get_dword(data + sub);
 | 
			
		||||
		sublen = cw_get_word(data + sub + 6);
 | 
			
		||||
		subtype = cw_get_word(data + sub + 4);
 | 
			
		||||
 | 
			
		||||
		bstrv_t vstr = NULL;
 | 
			
		||||
		int i;
 | 
			
		||||
		
 | 
			
		||||
		/* search sub-element */
 | 
			
		||||
		for (i = 0; elems[i].maxlen; i++) {
 | 
			
		||||
@ -49,15 +49,15 @@ int cw_read_descriptor_subelems(mavl_t store, uint8_t * data, int len,
 | 
			
		||||
		
 | 
			
		||||
		
 | 
			
		||||
		if (!elems[i].maxlen) {
 | 
			
		||||
			vstr = bstrv_create(vendor_id, data + sub + 8, sublen);
 | 
			
		||||
			if (vstr) {
 | 
			
		||||
			cw_dbg_version_subelem(DBG_ELEM_ERR, "Not allowed",
 | 
			
		||||
						       subtype, vstr);
 | 
			
		||||
				free(vstr);
 | 
			
		||||
			}
 | 
			
		||||
				subtype, vendor_id, data+sub+8, sublen);
 | 
			
		||||
			errors++;
 | 
			
		||||
		} else {
 | 
			
		||||
			int l = sublen;
 | 
			
		||||
			mavldata_t mdata, *mdata_result;
 | 
			
		||||
			char dbgstr[1048];
 | 
			
		||||
			char key[1024];
 | 
			
		||||
			
 | 
			
		||||
			if (elems[i].maxlen < sublen) {
 | 
			
		||||
				cw_dbg(DBG_ELEM_ERR,
 | 
			
		||||
				       "SubType %d Too long (truncating), len = %d,max. len=%d",
 | 
			
		||||
@ -65,13 +65,24 @@ int cw_read_descriptor_subelems(mavl_t store, uint8_t * data, int len,
 | 
			
		||||
				l = elems[i].maxlen;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			vstr =
 | 
			
		||||
			    mbag_set_bstrv(store, elems[i].key, vendor_id,
 | 
			
		||||
					   data + sub + 8, l);
 | 
			
		||||
 | 
			
		||||
			char dbgstr[128];
 | 
			
		||||
			/* vendor */
 | 
			
		||||
			sprintf(key,"%s/%s/%s",parent_key,elems[i].key,CW_KEY_VENDOR);
 | 
			
		||||
			mdata.kv.key = strdup(key);
 | 
			
		||||
			mdata.kv.val.dword = vendor_id;
 | 
			
		||||
			mdata.kv.priv=CW_TYPE_DWORD;
 | 
			
		||||
			mavl_add(cfg,&mdata);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
			/* version */
 | 
			
		||||
			sprintf(key,"%s/%s/%s",parent_key,elems[i].key,CW_KEY_VERSION);
 | 
			
		||||
			mdata_result = cw_type_version.get(&mdata,data+sub+8,l);
 | 
			
		||||
			mdata.kv.key = strdup(key);
 | 
			
		||||
			mavl_add(cfg,mdata_result);
 | 
			
		||||
 | 
			
		||||
			cw_type_version.to_str(mdata_result,dbgstr,90);
 | 
			
		||||
			sprintf(dbgstr, "Storing '%s'", elems[i].key);
 | 
			
		||||
			cw_dbg_version_subelem(DBG_SUBELEM, dbgstr, subtype, vstr);
 | 
			
		||||
			cw_dbg_version_subelem(DBG_SUBELEM, dbgstr, subtype, vendor_id, data+sub+8,l);
 | 
			
		||||
			success++;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -82,7 +93,5 @@ int cw_read_descriptor_subelems(mavl_t store, uint8_t * data, int len,
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	return success;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -59,5 +59,5 @@ int cw_read_wtp_descriptor(mavl_t cfg, struct conn *conn,
 | 
			
		||||
		allowed=allowed_default;
 | 
			
		||||
	}
 | 
			
		||||
printf("call read subelems\n");
 | 
			
		||||
	return cw_read_descriptor_subelems(cfg, data + pos, len - pos, allowed);
 | 
			
		||||
	return cw_read_descriptor_subelems(cfg,eh->key , data + pos, len - pos, allowed);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -3,6 +3,18 @@
 | 
			
		||||
#include "capwap.h"
 | 
			
		||||
#include "capwap_items.h"
 | 
			
		||||
#include "cw_types.h"
 | 
			
		||||
#include "keys.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static struct cw_DescriptorSubelemDef allowed_default[] = {
 | 
			
		||||
	{-1,CW_SUBELEM_WTP_HARDWARE_VERSION, CW_KEY_HARDWARE, 1024,0},
 | 
			
		||||
	{-1,CW_SUBELEM_WTP_SOFTWARE_VERSION, CW_KEY_SOFTWARE, 1024.0},
 | 
			
		||||
	{-1,CW_SUBELEM_WTP_BOOTLOADER_VERSION, CW_KEY_BOOTLOADER, 1024,0},
 | 
			
		||||
	{-1,CW_SUBELEM_WTP_OTHERSOFTWARE_VERSION, CW_KEY_OTHER_SOFTWARE, 1024,0},
 | 
			
		||||
	{0,0, NULL, 0,0}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Read WTP Descriptor in Cisco-Style (Draft 7)
 | 
			
		||||
@ -30,20 +42,13 @@ int cw_read_wtp_descriptor_7(mavl_t cfg, struct conn *conn,
 | 
			
		||||
	pos = 2;
 | 
			
		||||
 | 
			
		||||
	/* Encryption element, for now dumy XXX */
 | 
			
		||||
	//cw_get_word(data + pos + 2);
 | 
			
		||||
/*	//cw_get_word(data + pos + 2);*/
 | 
			
		||||
	pos += 2;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	static struct cw_DescriptorSubelemDef allowed_default[] = {
 | 
			
		||||
		{-1,CW_SUBELEM_WTP_HARDWARE_VERSION, CW_ITEM_WTP_HARDWARE_VERSION, 1024,0},
 | 
			
		||||
		{-1,CW_SUBELEM_WTP_SOFTWARE_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024.0},
 | 
			
		||||
		{-1,CW_SUBELEM_WTP_BOOTLOADER_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024,0},
 | 
			
		||||
		{-1,CW_SUBELEM_WTP_OTHERSOFTWARE_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024,0},
 | 
			
		||||
		{0,0, NULL, 0,0}
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	if (!allowed)
 | 
			
		||||
		allowed=allowed_default;
 | 
			
		||||
 | 
			
		||||
	return cw_read_descriptor_subelems(cfg, data + pos, len - pos, allowed);
 | 
			
		||||
	return cw_read_descriptor_subelems(cfg, eh->key, data + pos, len - pos, allowed);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -53,4 +53,3 @@ const struct cw_Type cw_type_byte = {
 | 
			
		||||
	to_str,		/* to_str */
 | 
			
		||||
	from_str	/* from_str */ 
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -34,15 +34,12 @@ struct cw_Type{
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
extern const struct cw_Type  cw_type_byte;
 | 
			
		||||
#define CW_TYPE_BYTE (&cw_type_byte)
 | 
			
		||||
 | 
			
		||||
extern const struct cw_Type  cw_type_word;
 | 
			
		||||
extern const struct cw_Type  cw_type_dword;
 | 
			
		||||
extern const struct cw_Type  cw_type_version;
 | 
			
		||||
 | 
			
		||||
void cw_types_mavl_delete(mavldata_t *data);
 | 
			
		||||
 | 
			
		||||
#define cw_types_mavl_create()\
 | 
			
		||||
	mavl_create(mavl_cmp_kv, cw_types_mavl_delete)
 | 
			
		||||
#define CW_TYPE_BYTE (&cw_type_byte)
 | 
			
		||||
#define CW_TYPE_DWORD (&cw_type_dword)
 | 
			
		||||
#define CW_TYPE_VERSION (&cw_type_version)
 | 
			
		||||
 | 
			
		||||
#endif /* __CW_TYPES_H */
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										60
									
								
								src/cw/dbg.c
									
									
									
									
									
								
							
							
						
						
									
										60
									
								
								src/cw/dbg.c
									
									
									
									
									
								
							@ -472,63 +472,23 @@ int cw_format_item(char *dst, mbag_item_t * item)
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int cw_format_version(char *s, bstrv_t ver, char *def)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void cw_dbg_version_subelem(int level, const char *context, int subtype, 
 | 
			
		||||
		uint32_t vendor_id, const uint8_t * vstr, int len)
 | 
			
		||||
{
 | 
			
		||||
	int dot;
 | 
			
		||||
	uint8_t *version;
 | 
			
		||||
	int len,rs,i;
 | 
			
		||||
	uint32_t vendor;
 | 
			
		||||
	char v[2048];
 | 
			
		||||
	int n;
 | 
			
		||||
	
 | 
			
		||||
	if (!ver)
 | 
			
		||||
		return sprintf(s, "%s", def);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	version = bstrv_data(ver);
 | 
			
		||||
	len = bstrv_len(ver);
 | 
			
		||||
 | 
			
		||||
	rs = 0;
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	if (format_is_utf8(version, len)) {
 | 
			
		||||
		if (len != 0)
 | 
			
		||||
			rs += sprintf(s + rs, "%.*s", len, version);
 | 
			
		||||
		else
 | 
			
		||||
			rs += sprintf(s + rs, "''");
 | 
			
		||||
	} else {
 | 
			
		||||
		for (i = 0; i < len && i < 20; i++) {
 | 
			
		||||
			rs += sprintf(s + rs, "%02X", version[i]);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		dot = 0;
 | 
			
		||||
 | 
			
		||||
		rs += sprintf(s + rs, " (");
 | 
			
		||||
		for (i = 0; i < len && i < 20; i++) {
 | 
			
		||||
			if (dot)
 | 
			
		||||
				rs += sprintf(s + rs, ".");
 | 
			
		||||
			dot = 1;
 | 
			
		||||
			rs += sprintf(s + rs, "%d", version[i]);
 | 
			
		||||
		}
 | 
			
		||||
		rs += sprintf(s + rs, ")");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	vendor = bstrv_get_vendor_id(ver);
 | 
			
		||||
	rs += sprintf(s + rs, ", Vendor Id: %d, %s", vendor, cw_strvendor(vendor));
 | 
			
		||||
	return rs;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void cw_dbg_version_subelem(int level, const char *context, int subtype, bstrv_t vstr)
 | 
			
		||||
{
 | 
			
		||||
	char v[256];
 | 
			
		||||
	if (!cw_dbg_is_level(level))
 | 
			
		||||
		return;
 | 
			
		||||
	if (!vstr)
 | 
			
		||||
		return;
 | 
			
		||||
	cw_format_version(v, vstr, "");
 | 
			
		||||
	cw_dbg(level, "%s: SubType %d, %s", context, subtype, v);
 | 
			
		||||
	n = cw_format_version(v, vstr, len);
 | 
			
		||||
 | 
			
		||||
	sprintf(v + n, ", Vendor Id: %d, %s", vendor_id, cw_strvendor(vendor_id));
 | 
			
		||||
 | 
			
		||||
	cw_dbg(level, "%s: SubType %d, %s", context, subtype, v);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -121,7 +121,8 @@ void cw_dbg_pkt_nc(int level,struct netconn *nc, uint8_t * packet, int len,struc
 | 
			
		||||
 | 
			
		||||
void cw_dbg_msg(int level,struct conn *conn, uint8_t * packet, int len,struct sockaddr *from);
 | 
			
		||||
char * cw_dbg_mkdmp(const uint8_t * data, int len);
 | 
			
		||||
void cw_dbg_version_subelem(int level,const char*context,int subtype,bstrv_t vstr);
 | 
			
		||||
void cw_dbg_version_subelem(int level, const char *context, int subtype, 
 | 
			
		||||
		uint32_t vendor_id, const uint8_t * vstr, int len);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 | 
			
		||||
@ -81,7 +81,7 @@ struct avltree;
 | 
			
		||||
int format_hdr_flags(char *dst, uint8_t * th);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int format_is_utf8(unsigned char *str, size_t len);
 | 
			
		||||
int format_is_utf8(const unsigned char *str, size_t len);
 | 
			
		||||
 | 
			
		||||
int format_dot11_fc(char *dst, uint16_t fc);
 | 
			
		||||
 | 
			
		||||
@ -109,6 +109,7 @@ char *cw_format_dump(const uint8_t * data, int len,
 | 
			
		||||
void cw_format_get_dump_defaults(struct cw_FormatDumpSettings * settings);
 | 
			
		||||
int cw_format_pkt_hdr(char *dst, int incomming, uint8_t * packet, int len,
 | 
			
		||||
		      struct sockaddr *from);
 | 
			
		||||
int cw_format_version(char *s, const uint8_t * version, int len);
 | 
			
		||||
 | 
			
		||||
/**@}*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -30,7 +30,7 @@
 | 
			
		||||
 * @return 0 if the string is not in UTF8 format, otherwise it is UTF8.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
int format_is_utf8(unsigned char *str, size_t len)
 | 
			
		||||
int format_is_utf8(const unsigned char *str, size_t len)
 | 
			
		||||
{
 | 
			
		||||
	size_t i = 0;
 | 
			
		||||
	size_t bytes = 0;
 | 
			
		||||
 | 
			
		||||
@ -54,7 +54,7 @@
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
struct mavl_KeyVal{
 | 
			
		||||
	const char *key;
 | 
			
		||||
	char *key;
 | 
			
		||||
	const void *priv;
 | 
			
		||||
	union{
 | 
			
		||||
		void * ptr;
 | 
			
		||||
 | 
			
		||||
@ -16,7 +16,7 @@
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "cw/keys.h"
 | 
			
		||||
#include "cw/cw.h"
 | 
			
		||||
#include "cw/vendors.h"
 | 
			
		||||
#include "cw/capwap_items.h"
 | 
			
		||||
@ -27,15 +27,15 @@ int cisco_in_wtp_descriptor(struct conn *conn, struct cw_ElemHandler *eh, uint8_
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	static struct cw_DescriptorSubelemDef allowed[] = {
 | 
			
		||||
		{CW_VENDOR_ID_CISCO,CW_SUBELEM_WTP_HARDWARE_VERSION, CW_ITEM_WTP_HARDWARE_VERSION, 1024,0},
 | 
			
		||||
		{CW_VENDOR_ID_CISCO,CW_SUBELEM_WTP_SOFTWARE_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024.0},
 | 
			
		||||
		{CW_VENDOR_ID_CISCO,CW_SUBELEM_WTP_BOOTLOADER_VERSION, CW_ITEM_WTP_BOOTLOADER_VERSION, 1024.0},
 | 
			
		||||
		{CW_VENDOR_ID_CISCO,CW_SUBELEM_WTP_OTHERSOFTWARE_VERSION, "other", 1024.0},
 | 
			
		||||
		{CW_VENDOR_ID_CISCO,CW_SUBELEM_WTP_HARDWARE_VERSION, CW_KEY_HARDWARE, 1024,0},
 | 
			
		||||
		{CW_VENDOR_ID_CISCO,CW_SUBELEM_WTP_SOFTWARE_VERSION, CW_KEY_SOFTWARE, 1024.0},
 | 
			
		||||
		{CW_VENDOR_ID_CISCO,CW_SUBELEM_WTP_BOOTLOADER_VERSION, CW_KEY_BOOTLOADER, 1024.0},
 | 
			
		||||
		{CW_VENDOR_ID_CISCO,CW_SUBELEM_WTP_OTHERSOFTWARE_VERSION, CW_KEY_OTHER_SOFTWARE, 1024.0},
 | 
			
		||||
		{0,0, NULL, 0,0}
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	return cw_read_wtp_descriptor_7(conn->incomming, conn, eh, data, len, allowed);
 | 
			
		||||
	return cw_read_wtp_descriptor_7(conn->remote_cfg, conn, eh, data, len, allowed);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user