2014-07-25 08:30:22 +02:00
|
|
|
/*
|
|
|
|
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/>.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2015-03-15 20:53:21 +01:00
|
|
|
#ifndef __LWAPP_H
|
|
|
|
#define __LWAPP_H
|
|
|
|
|
2015-04-13 11:00:46 +02:00
|
|
|
#include <stdio.h>
|
2015-03-16 10:42:03 +01:00
|
|
|
#include <stdint.h>
|
2015-03-23 19:41:34 +01:00
|
|
|
#include <string.h>
|
2014-07-26 11:11:05 +02:00
|
|
|
#include <arpa/inet.h>
|
2015-05-04 18:53:27 +02:00
|
|
|
#include <sys/socket.h>
|
2014-07-26 11:11:05 +02:00
|
|
|
|
2015-04-13 11:00:46 +02:00
|
|
|
#include "bstr.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @defgroup LWAPPConstants LWAPP Constats
|
|
|
|
* @{
|
|
|
|
*/
|
2015-03-24 20:13:04 +01:00
|
|
|
|
2014-07-26 11:11:05 +02:00
|
|
|
|
2016-03-13 01:57:44 +01:00
|
|
|
|
2015-04-13 11:00:46 +02:00
|
|
|
/** LWAPP Version */
|
|
|
|
#define LW_VERSION 0
|
|
|
|
|
|
|
|
/** LWAPP Control Port */
|
2016-02-17 13:40:01 +01:00
|
|
|
#define LWAPP_CONTROL_PORT 12222
|
2015-04-13 11:00:46 +02:00
|
|
|
/** LWAPP Control Port as string */
|
2016-02-17 13:40:01 +01:00
|
|
|
#define LWAPP_CONTROL_PORT_STR "12222"
|
|
|
|
|
|
|
|
/** LWAPP Data Port */
|
|
|
|
#define LWAPP_DATA_PRT 12223
|
|
|
|
|
|
|
|
/** LWAPP Data Port as String */
|
2016-02-17 20:31:51 +01:00
|
|
|
#define LWAPP_DATA_PORT_STR "12223"
|
2014-07-25 08:30:22 +02:00
|
|
|
|
2015-04-13 11:00:46 +02:00
|
|
|
/** Block Size for Image Data */
|
2018-03-24 07:56:05 +01:00
|
|
|
#define LWAPP_BLOCKSIZE_IMAGE_DATA 1024
|
2015-04-13 11:00:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**@}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-07-26 11:11:05 +02:00
|
|
|
|
|
|
|
/* macros to access transport header */
|
|
|
|
#define LWTH_GET_VERSION(th) (th[0]>>6)
|
|
|
|
#define LWTH_GET_L_FLAG(th) (th[0]&0x1)
|
|
|
|
#define LWTH_GET_F_FLAG(th) (th[0]&0x2)
|
|
|
|
#define LWTH_GET_C_FLAG(th) (th[0]&0x4)
|
|
|
|
#define LWTH_GET_RID(th) ((th[0]&0x38)>>3)
|
|
|
|
#define LWTH_GET_FRAGID(th) (th[1])
|
|
|
|
#define LWTH_GET_LENGTH(th) (ntohl(*((uint32_t*)(th)))&0xffff)
|
|
|
|
|
2014-07-26 17:45:49 +02:00
|
|
|
#define LWTH_SET_VERSION(th,v) (th[0] = (th[0]&0x3f) | (v<<6))
|
2014-07-27 12:37:08 +02:00
|
|
|
#define LWTH_SET_C_FLAG(th,v) (th[0] = (th[0]&0xfB) | (v<<2))
|
2014-07-26 11:11:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
#define LWMSG_GET_TYPE(m) (m[0])
|
|
|
|
#define LWMSG_GET_SEQNUM(m) (m[1])
|
|
|
|
#define LWMSG_GET_LEN(m) ( (ntohl(*((uint32_t*)(m)))&0xffff) )
|
|
|
|
#define LWMSG_GET_SESSIONID(m) ( ntohl(* ( ( (uint32_t*)(m))[1]) ) )
|
|
|
|
#define LWMSG_GET_DATA(m) (m+8)
|
|
|
|
|
|
|
|
|
|
|
|
#define LWMSGELEM_GET_TYPE(m) (m[0])
|
|
|
|
#define LWMSGELEM_GET_LEN(m) ( (ntohl(*((uint32_t*)(m)))>>8)&0xffff )
|
|
|
|
#define LWMSGELEM_GET_DATA(m) (m+3)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-03-05 20:39:15 +01:00
|
|
|
/*
|
2014-07-26 11:11:05 +02:00
|
|
|
//#define LWAPP_PACKET_PREAMBLE (CW_VERSION<<4)
|
|
|
|
//#define LWAPP_DTLS_PACKET_PREAMBLE (CW_VERSION<<4|1)
|
2018-03-05 20:39:15 +01:00
|
|
|
*/
|
2014-07-25 08:30:22 +02:00
|
|
|
|
2014-07-25 18:49:09 +02:00
|
|
|
|
2018-03-24 07:56:05 +01:00
|
|
|
#define LWAPP_MSG_DISCOVERY_REQUEST 1
|
|
|
|
#define LWAPP_MSG_DISCOVERY_RESPONSE 2
|
2014-07-25 18:49:09 +02:00
|
|
|
|
2018-03-24 07:56:05 +01:00
|
|
|
#define LWAPP_MSG_JOIN_REQUEST 3
|
|
|
|
#define LWAPP_MSG_JOIN_RESPONSE 4
|
2015-03-23 07:48:27 +01:00
|
|
|
|
|
|
|
/*
|
2014-07-25 18:49:09 +02:00
|
|
|
Join ACK 5
|
|
|
|
Join Confirm 6
|
|
|
|
Unused 7-9
|
|
|
|
Configure Request 10
|
|
|
|
Configure Response 11
|
|
|
|
Configuration Update Request 12
|
|
|
|
Configuration Update Response 13
|
|
|
|
WTP Event Request 14
|
|
|
|
WTP Event Response 15
|
|
|
|
Change State Event Request 16
|
|
|
|
Change State Event Response 17
|
|
|
|
Unused 18-21
|
|
|
|
Echo Request 22
|
|
|
|
Echo Response 23
|
|
|
|
Image Data Request 24
|
|
|
|
Image Data Response 25
|
|
|
|
Reset Request 26
|
|
|
|
Reset Response 27
|
|
|
|
Unused 28-29
|
|
|
|
Key Update Request 30
|
|
|
|
Key Update Response 31
|
|
|
|
Primary Discovery Request 32
|
|
|
|
*/
|
2014-07-26 11:11:05 +02:00
|
|
|
|
|
|
|
|
2015-03-15 20:53:21 +01:00
|
|
|
/* LWAPP message elements */
|
2014-07-26 11:11:05 +02:00
|
|
|
|
2018-03-24 07:56:05 +01:00
|
|
|
#define LWAPP_ELEM_AC_ADDRESS 2
|
|
|
|
#define LWAPP_ELEM_WTP_DESCRIPTOR 3
|
|
|
|
#define LWAPP_ELEM_WTP_NAME 5
|
|
|
|
#define LWAPP_ELEM_AC_DESCRIPTOR 6
|
|
|
|
#define LWAPP_ELEM_ADD_WLAN 7
|
2015-03-29 15:36:23 +02:00
|
|
|
|
|
|
|
#define LW_ELEM_MAC_OPERATION 11
|
|
|
|
#define LW_ELEM_TX_POWER 12
|
|
|
|
#define LW_ELEM_TX_POWER_LEVELS 13
|
|
|
|
#define LW_ELEM_DIRECT_SEQUENCE_CONTROL 14
|
2015-03-23 07:48:27 +01:00
|
|
|
|
2016-04-12 01:39:26 +02:00
|
|
|
#define LW_ELEM_CHANGE_STATE_EVENT 26
|
2015-04-28 10:23:03 +02:00
|
|
|
#define LW_ELEM_80211_DELETE_WLAN 28
|
|
|
|
|
2015-03-28 08:29:59 +01:00
|
|
|
#define LW_ELEM_AC_NAME 31
|
2015-03-29 01:55:06 +01:00
|
|
|
#define LW_ELEM_LOCATION_DATA 35
|
|
|
|
#define LW_ELEM_STATISTICS_TIMER 37
|
|
|
|
|
2014-08-24 19:22:52 +02:00
|
|
|
|
2015-03-29 15:36:23 +02:00
|
|
|
#define LW_ELEM_RATE_SET 16
|
2015-03-28 08:29:59 +01:00
|
|
|
#define LW_ELEM_SUPPORTED_RATES 16
|
2015-03-29 15:36:23 +02:00
|
|
|
|
2015-03-28 08:29:59 +01:00
|
|
|
#define LW_ELEM_TEST 18
|
2015-03-23 07:48:27 +01:00
|
|
|
|
2015-03-28 08:29:59 +01:00
|
|
|
#define LW_ELEM_CERTIFICATE 44
|
|
|
|
#define LW_ELEM_WTP_BOARD_DATA 50
|
2016-04-07 08:01:14 +02:00
|
|
|
#define LW_BCAST_SSID_MODE 51
|
2015-03-29 15:36:23 +02:00
|
|
|
#define LW_ELEM_WTP_MODE_AND_TYPE 54
|
2015-04-28 15:29:27 +02:00
|
|
|
#define LW_ELEM_QOS 57
|
2015-03-29 15:36:23 +02:00
|
|
|
|
2015-03-29 01:55:06 +01:00
|
|
|
#define LW_ELEM_AC_IPV4_LIST 59
|
2016-03-20 21:55:06 +01:00
|
|
|
|
|
|
|
#define LW_ELEM_LWAPP_TIMERS 68
|
2015-03-28 08:29:59 +01:00
|
|
|
#define LW_ELEM_AP_IP_ADDR 82
|
2015-03-23 07:48:27 +01:00
|
|
|
|
2015-03-28 08:29:59 +01:00
|
|
|
#define LW_ELEM_VENDOR_SPECIFIC 104
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* LWAPP IEEE 802.11 bindings */
|
|
|
|
|
2018-04-23 07:51:56 +02:00
|
|
|
#define LW_ELEM_80211_ADD_WLAN LWAPP_ELEM_ADD_WLAN
|
2015-03-28 08:29:59 +01:00
|
|
|
#define LW_ELEM_80211_WTP_WLAN_RADIO_CONFIGURATION 8
|
2015-03-29 01:55:06 +01:00
|
|
|
#define LW_ELEM_80211_MULTI_DOMAIN_CAPABILITY 10
|
2015-03-29 15:36:23 +02:00
|
|
|
#define LW_ELEM_80211_MAC_OPERATION 11
|
|
|
|
#define LW_ELEM_80211_TX_POWER LW_ELEM_TX_POWER /* 12 */
|
|
|
|
#define LW_ELEM_80211_TX_POWER_LEVELS LW_ELEM_TX_POWER_LEVELS /* 13 */
|
|
|
|
#define LW_ELEM_80211_DIRECT_SEQUENCE_CONTROL LW_ELEM_DIRECT_SEQUENCE_CONTROL /* 14 */
|
|
|
|
|
|
|
|
#define LW_ELEM_80211_RATE_SET LW_ELEM_RATE_SET /* 16 */
|
|
|
|
|
|
|
|
|
|
|
|
#define LW_ELEM_80211_WTP_MODE_AND_TYPE LW_ELEM_WTP_MODE_AND_TYPE /* 54 */
|
2015-03-23 07:48:27 +01:00
|
|
|
|
2015-03-16 02:41:35 +01:00
|
|
|
|
2016-04-12 01:39:26 +02:00
|
|
|
|
|
|
|
#define LW_CHANGE_STATE_CAUSE_NORMAL 0
|
|
|
|
#define LW_CHANGE_STATE_CAUSE_RADIO_FAILURE 1
|
|
|
|
#define LW_CHANGE_STATE_CAUSE_SOFTWARE_FAILURE 2
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-03-23 07:48:27 +01:00
|
|
|
/* useful macros and inline functions */
|
|
|
|
|
2015-04-14 07:42:23 +02:00
|
|
|
/**
|
|
|
|
* @defgroup LWAPPFunctions LWAPP Functions
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2018-03-25 11:14:37 +02:00
|
|
|
|
2015-03-23 07:48:27 +01:00
|
|
|
|
2016-03-04 21:01:38 +01:00
|
|
|
/*
|
2015-03-23 19:41:34 +01:00
|
|
|
|
|
|
|
#define lw_put_byte(dst,b) \
|
|
|
|
(*(dst)=b,1)
|
|
|
|
|
|
|
|
#define lw_put_word(dst,w)\
|
|
|
|
(*((uint16_t*)(dst)) = htons(w),2)
|
|
|
|
|
|
|
|
#define lw_put_dword(dst,dw)\
|
|
|
|
(*((uint32_t*)(dst)) = htonl(dw),4)
|
|
|
|
|
2015-04-05 02:07:59 +02:00
|
|
|
#define lw_set_byte(dst,b) \
|
|
|
|
(*(dst)=b);
|
|
|
|
|
|
|
|
#define lw_set_word(dst,b) \
|
|
|
|
(*((uint16_t*)(dst)) = htons(w))
|
|
|
|
|
|
|
|
#define lw_set_dword(dst,dw)\
|
|
|
|
(*((uint32_t*)(dst)) = htonl(dw))
|
|
|
|
|
2015-03-23 19:41:34 +01:00
|
|
|
|
2015-03-28 08:59:50 +01:00
|
|
|
#define lw_get_byte(src)\
|
|
|
|
(*(uint8_t*)(src))
|
|
|
|
|
|
|
|
#define lw_get_word(src) \
|
2015-03-28 09:56:51 +01:00
|
|
|
(ntohs( *((uint16_t*)(src))))
|
2015-03-28 08:59:50 +01:00
|
|
|
|
|
|
|
#define lw_get_dword(src) \
|
2015-03-28 09:56:51 +01:00
|
|
|
(ntohl( *((uint32_t*)(src))))
|
2016-03-04 21:01:38 +01:00
|
|
|
*/
|
|
|
|
|
2015-03-28 08:59:50 +01:00
|
|
|
|
|
|
|
|
2015-03-24 20:13:04 +01:00
|
|
|
/* the following functions are defined as static inline and not as
|
|
|
|
macro to avoid any side effects */
|
2015-03-23 19:41:34 +01:00
|
|
|
|
|
|
|
|
2016-03-04 21:01:38 +01:00
|
|
|
/*
|
2015-03-23 19:41:34 +01:00
|
|
|
static inline int lw_put_data(uint8_t*dst,const uint8_t*data,uint16_t len)
|
|
|
|
{
|
|
|
|
memcpy(dst,data,len);
|
|
|
|
return len;
|
|
|
|
}
|
2016-03-04 21:01:38 +01:00
|
|
|
*/
|
2015-03-23 19:41:34 +01:00
|
|
|
|
2016-03-04 21:01:38 +01:00
|
|
|
/*
|
2015-03-23 19:41:34 +01:00
|
|
|
static inline int lw_put_bstr(uint8_t * dst, const bstr_t b){
|
|
|
|
lw_put_data(dst,bstr_data(b),bstr_len(b));
|
|
|
|
return bstr_len(b);
|
2015-03-23 07:48:27 +01:00
|
|
|
}
|
|
|
|
|
2015-04-19 16:44:20 +02:00
|
|
|
static inline int lw_put_bstr16(uint8_t * dst, const bstr16_t b){
|
|
|
|
lw_put_data(dst,bstr16_data(b),bstr16_len(b));
|
|
|
|
return bstr16_len(b);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-04 21:01:38 +01:00
|
|
|
*/
|
2015-04-19 16:44:20 +02:00
|
|
|
|
2016-03-04 21:01:38 +01:00
|
|
|
/*
|
2015-03-23 19:41:34 +01:00
|
|
|
static inline int lw_put_str(uint8_t*dst,const uint8_t *str) {
|
|
|
|
return lw_put_data(dst,str,strlen((char*)str));
|
2015-03-23 07:48:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int lw_put_elem_hdr(uint8_t *dst,uint8_t type,uint16_t len)
|
|
|
|
{
|
|
|
|
*dst=type;
|
|
|
|
*((uint16_t*)(dst+1)) = htons(len);
|
2015-03-23 19:41:34 +01:00
|
|
|
return 3;
|
2015-03-23 07:48:27 +01:00
|
|
|
}
|
2014-08-24 19:22:52 +02:00
|
|
|
|
2016-03-04 21:01:38 +01:00
|
|
|
*/
|
|
|
|
|
2015-04-14 07:42:23 +02:00
|
|
|
/**@}*/
|
|
|
|
|
|
|
|
|
2015-04-05 02:07:59 +02:00
|
|
|
|
|
|
|
|
2015-03-23 19:41:34 +01:00
|
|
|
extern int lw_put_cisco_path_mtu(uint8_t *dst, uint16_t max, uint16_t padding);
|
2015-03-28 08:29:59 +01:00
|
|
|
#define lw_put_certificate(dst,cert,len) lw_put_data(dst,cert,len)
|
2015-03-17 07:35:41 +01:00
|
|
|
|
2018-03-05 20:39:15 +01:00
|
|
|
/*
|
|
|
|
//extern int lw_put_ac_descriptor(uint8_t * dst, struct ac_info * acinfo);
|
|
|
|
*/
|
2015-03-17 07:35:41 +01:00
|
|
|
|
2014-08-24 19:22:52 +02:00
|
|
|
/* function proto types */
|
|
|
|
|
2018-03-05 20:39:15 +01:00
|
|
|
/*
|
2016-03-05 10:24:08 +01:00
|
|
|
//extern uint16_t lw_checksum(uint8_t *d,int len);
|
2015-05-01 20:34:50 +02:00
|
|
|
//extern int lw_readelem_wtp_board_data(struct wtpinfo *wtpinfo, int type, uint8_t *msgelem, int len);
|
2018-03-05 20:39:15 +01:00
|
|
|
*/
|
2014-08-24 19:22:52 +02:00
|
|
|
|
2018-03-05 20:39:15 +01:00
|
|
|
extern int lw_readelem_wtp_name(bstr_t * dst, int type, uint8_t * msgelem, int len);
|
2015-03-28 08:29:59 +01:00
|
|
|
|
2018-03-05 20:39:15 +01:00
|
|
|
/*
|
2015-05-01 20:34:50 +02:00
|
|
|
//extern int lw_put_80211_wtp_wlan_radio_configuration(uint8_t*dst,struct radioinfo *ri);
|
2018-03-05 20:39:15 +01:00
|
|
|
*/
|
2014-08-24 19:22:52 +02:00
|
|
|
|
2015-03-29 01:55:06 +01:00
|
|
|
extern const char * lw_vendor_id_to_str(uint32_t vendor_id);
|
|
|
|
extern const char * lw_elem_id_to_str(int elem_id);
|
|
|
|
extern const char * lw_msg_id_to_str(int msg_id);
|
|
|
|
|
2015-04-13 11:00:46 +02:00
|
|
|
extern int lw_put_image_data(uint8_t *dst,FILE *infile);
|
2014-08-24 19:22:52 +02:00
|
|
|
|
2015-03-23 07:48:27 +01:00
|
|
|
|
2015-03-15 20:53:21 +01:00
|
|
|
#endif
|