/*
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 .
*/
#ifndef __LWAPP_H
#define __LWAPP_H
#include
#include
#include
#include
#include
#include "bstr.h"
/**
* @defgroup LWAPPConstants LWAPP Constats
* @{
*/
/** LWAPP Version */
#define LW_VERSION 0
/** LWAPP Control Port */
#define LWAPP_CONTROL_PORT 12222
/** LWAPP Control Port as string */
#define LWAPP_CONTROL_PORT_STR "12222"
/** LWAPP Data Port */
#define LWAPP_DATA_PRT 12223
/** LWAPP Data Port as String */
#define LWAPP_DATA_PORT_STR "12223"
/** Block Size for Image Data */
#define LW_BLOCKSIZE_IMAGE_DATA 1024
/**@}*/
/* 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)
#define LWTH_SET_VERSION(th,v) (th[0] = (th[0]&0x3f) | (v<<6))
#define LWTH_SET_C_FLAG(th,v) (th[0] = (th[0]&0xfB) | (v<<2))
#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)
//#define LWAPP_PACKET_PREAMBLE (CW_VERSION<<4)
//#define LWAPP_DTLS_PACKET_PREAMBLE (CW_VERSION<<4|1)
#define LW_MSG_DISCOVERY_REQUEST 1
#define LW_MSG_DISCOVERY_RESPONSE 2
#define LW_MSG_JOIN_REQUEST 3
#define LW_MSG_JOIN_RESPONSE 4
/*
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
*/
/* LWAPP message elements */
#define LW_ELEM_AC_ADDRESS 2
#define LW_ELEM_WTP_DESCRIPTOR 3
#define LW_ELEM_WTP_NAME 5
#define LW_ELEM_AC_DESCRIPTOR 6
#define LW_ELEM_ADD_WLAN 7
#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
#define LW_ELEM_CHANGE_STATE_EVENT 26
#define LW_ELEM_80211_DELETE_WLAN 28
#define LW_ELEM_AC_NAME 31
#define LW_ELEM_LOCATION_DATA 35
#define LW_ELEM_STATISTICS_TIMER 37
#define LW_ELEM_RATE_SET 16
#define LW_ELEM_SUPPORTED_RATES 16
#define LW_ELEM_TEST 18
#define LW_ELEM_CERTIFICATE 44
#define LW_ELEM_WTP_BOARD_DATA 50
#define LW_BCAST_SSID_MODE 51
#define LW_ELEM_WTP_MODE_AND_TYPE 54
#define LW_ELEM_QOS 57
#define LW_ELEM_AC_IPV4_LIST 59
#define LW_ELEM_LWAPP_TIMERS 68
#define LW_ELEM_AP_IP_ADDR 82
#define LW_ELEM_VENDOR_SPECIFIC 104
/* LWAPP IEEE 802.11 bindings */
#define LW_ELEM_80211_ADD_WLAN LW_ELEM_ADD_WLAN
#define LW_ELEM_80211_WTP_WLAN_RADIO_CONFIGURATION 8
#define LW_ELEM_80211_MULTI_DOMAIN_CAPABILITY 10
#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 */
#define LW_CHANGE_STATE_CAUSE_NORMAL 0
#define LW_CHANGE_STATE_CAUSE_RADIO_FAILURE 1
#define LW_CHANGE_STATE_CAUSE_SOFTWARE_FAILURE 2
/* useful macros and inline functions */
/**
* @defgroup LWAPPFunctions LWAPP Functions
* @{
*/
#define lw_foreach_elem(d,msg,len) for(d=msg; d