Inital commit.
FossilOrigin-Name: ac07b6350f51326a8ef4af3e18f337b4cbe9aa188a329c03cb615e28f9136b45
This commit is contained in:
		
							
								
								
									
										28
									
								
								src/capwap/avltree_foreach_from_lr.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/capwap/avltree_foreach_from_lr.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,28 @@ | ||||
| #include "avltree.h" | ||||
|  | ||||
| int avltree_foreach_from_lr(struct avltree *t, struct avlnode *n, void *data,int (*callback)(void *,void *),void *cbpriv) | ||||
| { | ||||
|         if (!n) | ||||
|                 return 1; | ||||
|  | ||||
|         int rc=t->cmp(data,n->data); | ||||
|         if (rc<0){ | ||||
|                 if(!avltree_foreach_from_lr(t,n->left,data,callback,cbpriv)) | ||||
| 			return 0; | ||||
|                 if (!callback(cbpriv,n->data)) | ||||
| 			return 0; | ||||
|                 return avltree_foreach_lr(n->right,callback,cbpriv); | ||||
|         } | ||||
|  | ||||
|         if (rc>0) { | ||||
|                 avltree_foreach_from_lr(t,n->right,data,callback,cbpriv); | ||||
|                 return 0; | ||||
|         } | ||||
|  | ||||
|         if (!callback(cbpriv,n->data)) | ||||
| 		return 0; | ||||
|  | ||||
| 	return avltree_foreach_lr(n->right,callback,cbpriv); | ||||
| } | ||||
|  | ||||
|  | ||||
							
								
								
									
										39
									
								
								src/capwap/avltree_get_node.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								src/capwap/avltree_get_node.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,39 @@ | ||||
| /* | ||||
|     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 <stdio.h> | ||||
|  | ||||
| #include "avltree.h" | ||||
|  | ||||
|  | ||||
| struct avlnode * avltree_get_node(struct avltree *t ,void *data) | ||||
| { | ||||
| 	struct avlnode *n = t->root; | ||||
| 	while(n){ | ||||
| 		int rc=t->cmp(data,n->data); | ||||
| 		if (rc==0) | ||||
| 			return n; | ||||
| 		if (rc<0) | ||||
| 			n=n->left; | ||||
| 		else | ||||
| 			n=n->right; | ||||
| 	} | ||||
| 	return NULL; | ||||
| } | ||||
|  | ||||
							
								
								
									
										76
									
								
								src/capwap/capwap_actions.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								src/capwap/capwap_actions.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,76 @@ | ||||
| /* | ||||
|     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/>. | ||||
|  | ||||
| */ | ||||
|  | ||||
| #ifndef __CAPWAP_ACTIONS_H | ||||
| #define __CAPWAP_ACTIONS_H | ||||
|  | ||||
|  | ||||
| #include "capwap.h" | ||||
| #include "capwap_items.h" | ||||
|  | ||||
|  | ||||
| #define CW_ACTION_IN_LOCATION_DATA 	\ | ||||
| 	CW_ELEM_LOCATION_DATA, 		/* Element ID*/			\ | ||||
| 	cw_in_generic, 0,		/* start/end callback */	\ | ||||
| 	CW_ITEMTYPE_STR, 		/* Type of element */		\ | ||||
| 	CW_ITEM_LOCATION_DATA,		/* ID to use store */		\ | ||||
| 	1, 1024				/* min/max length */ | ||||
|  | ||||
|  | ||||
| #define CW_ACTION_IN_WTP_NAME	 	\ | ||||
| 	CW_ELEM_WTP_NAME, 		/* Element ID*/			\ | ||||
| 	cw_in_generic, 0,		/* start/end callback */	\ | ||||
| 	CW_ITEMTYPE_STR, 		/* Type of element */		\ | ||||
| 	CW_ITEM_WTP_NAME,		/* ID to use store */		\ | ||||
| 	1, 1024				/* min/max length */ | ||||
|  | ||||
| #define CW_ACTION_IN_SESSION_ID	 	\ | ||||
| 	CW_ELEM_SESSION_ID, 		/* Element ID*/			\ | ||||
| 	cw_in_generic, 0,		/* start/end callback */	\ | ||||
| 	CW_ITEMTYPE_BSTR, 		/* Type of element */		\ | ||||
| 	CW_ITEM_SESSION_ID,		/* ID to use store */		\ | ||||
| 	16, 16				/* min/max length */ | ||||
|  | ||||
| #define CW_ACTION_IN_WTP_FRAME_TUNNEL_MODE	 	\ | ||||
| 	CW_ELEM_WTP_FRAME_TUNNEL_MODE,	/* Element ID*/			\ | ||||
| 	cw_in_generic, 0,		/* start/end callback */	\ | ||||
| 	CW_ITEMTYPE_BYTE, 		/* Type of element */		\ | ||||
| 	CW_ITEM_WTP_FRAME_TUNNEL_MODE,	/* ID to use store */		\ | ||||
| 	1, 1				/* min/max length */ | ||||
|  | ||||
|  | ||||
| #define CW_ACTION_IN_WTP_MAC_TYPE	 	\ | ||||
| 	CW_ELEM_WTP_MAC_TYPE,		/* Element ID*/			\ | ||||
| 	cw_in_generic, 0,		/* start/end callback */	\ | ||||
| 	CW_ITEMTYPE_BYTE, 		/* Type of element */		\ | ||||
| 	CW_ITEM_WTP_MAC_TYPE,		/* ID to use store */		\ | ||||
| 	1, 1				/* min/max length */ | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| #define CW_ACTION_IN_WTP_BOARD_DATA	\ | ||||
| 	CW_ELEM_WTP_BOARD_DATA,		/* Element ID */		\ | ||||
| 	cw_in_wtp_board_data, 0		/* start/end callback */	\ | ||||
|  | ||||
| #define CW_ACTION_IN_WTP_DESCRIPTOR	\ | ||||
| 	CW_ELEM_WTP_DESCRIPTOR,		/* Element ID */		\ | ||||
| 	cw_in_wtp_descriptor, 0		/* start/end callback */	\ | ||||
| 	 | ||||
|  | ||||
| #endif | ||||
							
								
								
									
										203
									
								
								src/capwap/capwap_actions_ac.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										203
									
								
								src/capwap/capwap_actions_ac.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,203 @@ | ||||
| /* | ||||
|     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 "capwap.h" | ||||
| #include "action.h" | ||||
| #include "capwap_items.h" | ||||
| #include "capwap_actions.h" | ||||
|  | ||||
| int cw_in_set_state_none(struct conn *conn,struct cw_action_in * a,uint8_t *data,int len) | ||||
| { | ||||
| 	conn->capwap_state=CW_STATE_NONE; | ||||
| 	return 1; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| cw_action_in_t capwap_actions_ac_in[] = { | ||||
|  | ||||
|  | ||||
| 	/* Message Discovery Request */ | ||||
|  | ||||
| 	{0, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST, -1, | ||||
| 	 0, cw_in_set_state_none} | ||||
| 	, | ||||
|  | ||||
| 	/* Element Discovery Type */ | ||||
| 	{0, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST, CW_ELEM_DISCOVERY_TYPE, | ||||
| 	 cw_in_generic, 0, CW_ITEMTYPE_BYTE, CW_ITEM_DISCOVERY_TYPE, 1, 1} | ||||
| 	, | ||||
|  | ||||
| 	/* Element WTP Board Data */ | ||||
| 	{0, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST, CW_ACTION_IN_WTP_BOARD_DATA } | ||||
| 	, | ||||
| 	 | ||||
| 	/* Element WTP Descriptor */ | ||||
| 	{0, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST, CW_ACTION_IN_WTP_DESCRIPTOR } | ||||
| 	, | ||||
|  | ||||
| 	/* Element Frame Tunnel Mode */ | ||||
| 	{0, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST, CW_ACTION_IN_WTP_FRAME_TUNNEL_MODE} | ||||
| 	, | ||||
|  | ||||
| //	{0, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST, CW_ELEM_WTP_FRAME_TUNNEL_MODE, | ||||
| //	 cw_in_generic, 0, CW_ITEMTYPE_BYTE, CW_ITEM_WTP_FRAME_TUNNEL_MODE, 1, 1} | ||||
|  | ||||
| 	/* Element WTP Mac Tpe */ | ||||
| 	{0, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST, CW_ACTION_IN_WTP_MAC_TYPE} | ||||
| 	, | ||||
|  | ||||
| //	{0, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST, CW_ELEM_WTP_MAC_TYPE, | ||||
| //	 cw_in_generic, 0, CW_ITEMTYPE_BYTE, CW_ITEM_WTP_MAC_TYPE, 1, 1} | ||||
|  | ||||
| 	/* Vendor Specific Payload */ | ||||
| 	{0, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST, CW_ELEM_VENDOR_SPECIFIC_PAYLOAD, | ||||
| 	 cw_in_vendor_specific_payload, 0} | ||||
| 	, | ||||
|  | ||||
|  | ||||
| 	/* Message: Join Request */ | ||||
| 	{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, -1, | ||||
| 	 0, 0} | ||||
| 	, | ||||
|  | ||||
| 	/* Element Location Data */ | ||||
| 	{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, CW_ACTION_IN_LOCATION_DATA} | ||||
| 	, | ||||
| 	/* Element WTP Board Data */ | ||||
| 	{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, CW_ACTION_IN_WTP_BOARD_DATA} | ||||
| 	, | ||||
| 	/* Element WTP Board Data */ | ||||
| 	{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, CW_ACTION_IN_WTP_DESCRIPTOR} | ||||
| 	, | ||||
| 	/* Element WTP Board Data */ | ||||
| 	{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, CW_ACTION_IN_WTP_NAME} | ||||
| 	, | ||||
| 	/* Element WTP Board Data */ | ||||
| 	{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, CW_ACTION_IN_SESSION_ID} | ||||
| 	, | ||||
| 	/* Element WTP Board Data */ | ||||
| 	{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, CW_ACTION_IN_WTP_FRAME_TUNNEL_MODE} | ||||
| 	, | ||||
| 	{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, CW_ACTION_IN_WTP_MAC_TYPE} | ||||
| 	, | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| /* | ||||
| 	{0, 1, 1, CW_MSG_DISCOVERY_RESPONSE, 0, | ||||
| 	 0, 0} | ||||
| 	, | ||||
|  | ||||
|  | ||||
| 	{0, 1, 1, CW_MSG_DISCOVERY_RESPONSE, CW_ELEM_AC_NAME, | ||||
| 	 cw_out_generic, 0, CW_ITEMTYPE_DATA,CW_ITEM_AC_NAME} | ||||
| 	, | ||||
|  | ||||
| 	{0, 1, 2, CW_MSG_DISCOVERY_RESPONSE, 0, | ||||
| 	 0, 0} | ||||
| 	, | ||||
|  | ||||
|  | ||||
| */ | ||||
|  | ||||
|  | ||||
| /* | ||||
| 	{CW_VENDOR_ID_CISCO, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST, CW_CISCO_RAD_NAME, | ||||
| 	 cw_in_wtp_name, 0} | ||||
| 	, | ||||
| */ | ||||
|  | ||||
| 	{0, 0, 0} | ||||
| }; | ||||
|  | ||||
|  | ||||
| int cw_out_ac_name(uint8_t * dst, struct cw_item *item) | ||||
| { | ||||
|  | ||||
| 	printf("Putting out the AC name %s\n", item->data); | ||||
|  | ||||
| 	uint8_t *data = item->data; | ||||
| 	int len = cw_put_data(dst + 4, data, strlen((char *) data)); | ||||
| 	return len + cw_put_elem_hdr(dst, CW_ELEM_AC_NAME, len); | ||||
| } | ||||
|  | ||||
| struct cw_item *cw_get_local(struct conn *conn, uint32_t item_id) | ||||
| { | ||||
| 	struct cw_item i; | ||||
| 	i.id = item_id; | ||||
| 	return cw_itemstore_get(conn->local, item_id); | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| cw_action_out_t capwap_actions_ac_out[] = { | ||||
| 	{CW_MSG_DISCOVERY_RESPONSE, CW_ITEM_NONE} | ||||
| 	, | ||||
| 	 | ||||
| 	/* AC Descriptor */ | ||||
| 	{CW_MSG_DISCOVERY_RESPONSE, CW_ITEM_AC_DESCRIPTOR, | ||||
| 	 CW_ELEM_AC_DESCRIPTOR, cw_out_ac_descriptor, 0} | ||||
| 	, | ||||
| 	/* AC Name */ | ||||
| 	{CW_MSG_DISCOVERY_RESPONSE, CW_ITEM_AC_NAME, | ||||
| 	 CW_ELEM_AC_NAME, cw_out_generic, cw_get_local} | ||||
| 	, | ||||
|  | ||||
| 	/* List of CAPWAP Control IPv4 and IPv6 addresses */ | ||||
| 	{CW_MSG_DISCOVERY_RESPONSE, CW_ITEM_CAPWAP_CONTROL_IP_LIST, | ||||
| 	 0, cw_out_capwap_control_ip_addrs, cw_get_local} | ||||
| 	, | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| 	{CW_MSG_JOIN_RESPONSE, CW_ITEM_AC_NAME} | ||||
| 	, | ||||
| 	{CW_MSG_JOIN_RESPONSE, CW_ITEM_RESULT_CODE} | ||||
| 	, | ||||
|  | ||||
|  | ||||
| 	{0, 0} | ||||
|  | ||||
| }; | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| int cw_register_actions_capwap_ac(struct cw_actiondef *def) | ||||
| { | ||||
| 	def->in = cw_actionlist_in_create(); | ||||
| 	def->out = cw_actionlist_out_create(); | ||||
|  | ||||
| 	cw_actionlist_in_register_actions(def->in, capwap_actions_ac_in); | ||||
| 	cw_actionlist_out_register_actions(def->out, capwap_actions_ac_out); | ||||
|  | ||||
| 	return 1; | ||||
| } | ||||
							
								
								
									
										11
									
								
								src/capwap/conn_resp_init.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								src/capwap/conn_resp_init.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | ||||
|  | ||||
| #include "conn.h" | ||||
|  | ||||
|  | ||||
| void conn_resp_init(strucct conn * conn) | ||||
| { | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| } | ||||
							
								
								
									
										98
									
								
								src/capwap/conn_send_msg.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										98
									
								
								src/capwap/conn_send_msg.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,98 @@ | ||||
|  | ||||
| #include "conn.h" | ||||
| #include "capwap.h" | ||||
| #include "cw_log.h" | ||||
| #include "sock.h" | ||||
|  | ||||
|  | ||||
| int conn_send_msg(struct conn * conn, uint8_t *rawmsg) | ||||
| { | ||||
|  | ||||
| 	int packetlen = cw_get_hdr_msg_total_len(rawmsg); | ||||
|  | ||||
| 	uint8_t * msgptr = rawmsg + cw_get_hdr_msg_offset(rawmsg); | ||||
|  | ||||
|  | ||||
| 	/* Zyxel doesn't count msg element length from | ||||
| 	   behind seqnum */ | ||||
| 	if (conn->capwap_mode == CWMODE_ZYXEL){ | ||||
| 		// XXX val-=3; | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	uint8_t * ptr = rawmsg; | ||||
|  | ||||
| 	int fragoffset = 0; | ||||
|  | ||||
| 	int hlen = cw_get_hdr_hlen(rawmsg)*4; | ||||
|  | ||||
|  | ||||
| 	int mtu = conn->mtu; | ||||
|  | ||||
| 	while (packetlen>mtu){ | ||||
| 		cw_set_hdr_flags(rawmsg,CW_FLAG_HDR_F,1); | ||||
| 		cw_put_dword(ptr+4, conn->fragid<<16 | fragoffset<<3 ); | ||||
|  | ||||
|  | ||||
| 		{ | ||||
| 			char h[200]; | ||||
| 			hdr_print(h,ptr,mtu); | ||||
| 			cw_dbg(DBG_CW_PKT_OUT,"Sending capwap packet to %s:\n%s",sock_addr2str(&conn->addr),h); | ||||
| 		} | ||||
| 		cw_dbg_dmp(DBG_CW_PKT_DMP,ptr,mtu,"Sending packet ..."); | ||||
| 		 | ||||
|  | ||||
| 		if (conn->write(conn,ptr,mtu)<0) | ||||
| 			return -1; | ||||
|  | ||||
| 		ptr +=mtu-hlen; | ||||
| 		fragoffset+=(mtu-hlen)/8; | ||||
|  | ||||
| 		packetlen-=mtu-hlen; | ||||
|  | ||||
| //XXX		if (hlen>8) | ||||
| //			memcpy(ptr+8,cwmsg->ctrlhdr+8,hlen-8); | ||||
|  | ||||
| 	} | ||||
|  | ||||
| //	val = (preamble << 24) | ((hlen/4)<<19) | (cwmsg->rid<<14) |(wbid<<9) |  | ||||
| 		/*CWTH_FLAGS_T|*/ //cwmsg->flags; | ||||
|  | ||||
|  | ||||
| //printf("VAL = %08x, %08x\n",val,cwmsg->flags); | ||||
|  | ||||
| //printf("FRag offset :::::::::::::::::::::::::::: %d\n",fragoffset); | ||||
|  | ||||
| 	if (fragoffset) | ||||
| 		cw_set_hdr_flags(rawmsg,CW_FLAG_HDR_F | CW_FLAG_HDR_L,1); | ||||
| 	else | ||||
| 		cw_set_hdr_flags(rawmsg,CW_FLAG_HDR_F,0); | ||||
|  | ||||
|  | ||||
| //	printf("Setting first byte %08X\n",val); | ||||
| //	*((uint32_t*)ptr)=htonl(val); | ||||
|  | ||||
|  | ||||
| //	val = conn->fragid<<16 | fragoffset<<3; | ||||
| //	*((uint32_t*)(ptr+4))=htonl(val); | ||||
|  | ||||
| 	cw_put_dword(ptr+4, conn->fragid<<16 | fragoffset<<3 ); | ||||
|  | ||||
|  | ||||
| 	{ | ||||
| 	//	char h[1024]; | ||||
| 	//	hdr_print(h,ptr,msglen-fragoffset*8+hlen); | ||||
| 	//	cw_dbg(DBG_CW_PKT_OUT,"Sending capwap packet to %s:\n%s",sock_addr2str(&conn->addr),h); | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	cw_dbg_dmp(DBG_CW_PKT_DMP,ptr,packetlen,"Sending packet ..."); | ||||
| 	//return conn->write(conn,ptr,msglen-fragoffset*8+hlen); | ||||
|  | ||||
|  | ||||
|  | ||||
| printf("Send packet len %p %d\n",ptr,packetlen); | ||||
|  | ||||
| 	return conn->write(conn,ptr,packetlen); | ||||
| } | ||||
|  | ||||
							
								
								
									
										45
									
								
								src/capwap/cw_dbg_elem.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								src/capwap/cw_dbg_elem.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,45 @@ | ||||
| #include "cw_log.h" | ||||
| #include "capwap.h" | ||||
|  | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * print debug info for message elements | ||||
|  */ | ||||
|  | ||||
| void cw_dbg_elem_(int msg, int msgelem, const uint8_t * msgbuf, int len) | ||||
| { | ||||
| 	if (!cw_dbg_is_level(DBG_ELEM)) | ||||
| 		return; | ||||
|  | ||||
| 	const char *elemname; | ||||
| 	char vendorname[256]; | ||||
| 	char vendor_details[265]; | ||||
| 	*vendor_details = 0; | ||||
|  | ||||
| 	if (msgelem == CW_ELEM_VENDOR_SPECIFIC_PAYLOAD) { | ||||
| 		uint32_t vendor_id = ntohl(*((uint32_t *) msgbuf)); | ||||
| 		int type = ntohs(*((uint16_t *) (msgbuf + 4))); | ||||
| 		sprintf(vendorname, "%s/%s/%d", | ||||
| 			(char *) cw_strelem(msgelem), | ||||
| 			(char *) lw_vendor_id_to_str(vendor_id), type); | ||||
| 		elemname = vendorname; | ||||
| 		cw_format_vendor(vendor_details, vendor_id, type, msgbuf); | ||||
|  | ||||
| 	} else { | ||||
| 		elemname = cw_strelem(msgelem); | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	if (!cw_dbg_is_level(DBG_ELEM_DMP)) | ||||
| 		cw_dbg(DBG_ELEM, | ||||
| 		       "%s, CAWPAP element: %d (%s), len=%d%s", | ||||
| 		       cw_strmsg(msg), msgelem, elemname, len, vendor_details); | ||||
|  | ||||
| 	else | ||||
| 		cw_dbg_dmp(DBG_ELEM, msgbuf, len, | ||||
| 			   "%s, CAPWAP element: %d (%s), len=%d%s\n\tDump ...", | ||||
| 			   cw_strmsg(msg), msgelem, elemname, len, vendor_details); | ||||
| } | ||||
|  | ||||
|  | ||||
							
								
								
									
										37
									
								
								src/capwap/cw_in_generic.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								src/capwap/cw_in_generic.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | ||||
|  | ||||
| #include "action.h" | ||||
| #include "cw_log.h" | ||||
| #include "itemstore.h" | ||||
|  | ||||
|  | ||||
|  | ||||
| int cw_itemstore_set(cw_itemstore_t itemstore, uint32_t item_id, int item_type, uint8_t *data, int len) | ||||
| { | ||||
| 	switch (item_type) { | ||||
| 		case CW_ITEMTYPE_BYTE: | ||||
| 			cw_itemstore_set_byte(itemstore,item_id,*data);	 | ||||
| 			break; | ||||
|  | ||||
| 		case CW_ITEMTYPE_STR: | ||||
| 			cw_itemstore_set_strn(itemstore,item_id,(char*)data,len); | ||||
| 			break; | ||||
| 		case CW_ITEMTYPE_BSTR: | ||||
| 			cw_itemstore_set_bstrn(itemstore,item_id,data,len); | ||||
| 			break; | ||||
|  | ||||
|  | ||||
| 	} | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| int cw_in_generic(struct conn *conn,struct cw_action_in * a,uint8_t *data,int len) | ||||
| { | ||||
| 	if (len<a->min_len) { | ||||
| 		cw_dbg(DBG_ELEM_ERR,"Message element too short, %d < %d", len,a->min_len); | ||||
| 		return 0; | ||||
| 	} | ||||
|  | ||||
| 	cw_itemstore_set(conn->itemstore,a->item_id,a->itemtype,data,len); | ||||
| 	 | ||||
| 	return 0; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user