Refactoring fo capwap.h

FossilOrigin-Name: eaf59431a22faf0b18914afc2e4190aa2ec934f8fa9aa5d7bee009196b90c7cb
This commit is contained in:
7u83@mail.ru
2018-02-22 22:04:15 +00:00
parent ff0cf22c49
commit 5fa4653fa6
12 changed files with 41 additions and 34 deletions

View File

@ -18,7 +18,7 @@
/**
* @file
* @brief CAPWAP desfinitions
* @brief CAPWAP definitions
*/
@ -49,14 +49,14 @@
*/
/** CAPWAP Version */
#define CAPWAP_VERSION (0)
#define CW_VERSION (0)
#define CWIANA_ENTERPRISE_NUMBER 0
#define CW_IANA_ENTERPRISE_NUMBER 0
/** CAPWAP Control Port*/
#define CAPWAP_CONTROL_PORT 5246
#define CW_CONTROL_PORT 5246
/** CAPWAP Control Port as String */
#define CAPWAP_CONTROL_PORT_STR "5246"
#define CW_CONTROL_PORT_STR "5246"
/** CAPWAP Data Port */
#define CAPWAP_DATA_PPORT 5247
@ -92,8 +92,8 @@
#define CW_WBID_EPCGLOBAL 3
#define CAPWAP_PACKET_PREAMBLE (CAPWAP_VERSION<<4)
#define CAPWAP_DTLS_PACKET_PREAMBLE (CAPWAP_VERSION<<4|1)
#define CAPWAP_PACKET_PREAMBLE (CW_VERSION<<4)
#define CAPWAP_DTLS_PACKET_PREAMBLE (CW_VERSION<<4|1)
/*
* control header stuff
@ -307,9 +307,8 @@ CW_MSG_MAXMSG = 26
#define CW_WTP_FRAME_TUNNEL_MODE_E 4 /* 802.3 mode */
#define CW_WTP_FRAME_TUNNEL_MODE_N 8 /* native mode */
#include "radioinfo.h"
/* Discovery Types */
#define CW_DISCOVERY_TYPE_UNKNOWN 0
#define CW_DISCOVERY_TYPE_STATIC 1
#define CW_DISCOVERY_TYPE_DHCP 2
@ -317,26 +316,23 @@ CW_MSG_MAXMSG = 26
#define CW_DISCOVERY_TYPE_AC_REFERRAL 4
/* wtp mac types */
/* WTP mac types */
#define CW_WTP_MAC_TYPE_LOCAL 0
#define CW_WTP_MAC_TYPE_SPLIT 1
#define CW_WTP_MAC_TYPE_BOTH 2
//#define CWMSG_MAX_SIZE 65536
#define CWMSG_MAX_SIZE 2048
//#define CWMSG_MAX_SIZE 2048
#define CW_SESSION_ID_LEN 16
/* capwap timer default values */
#define CAPWAP_DISCOVERY_INTERVAL 5
#define CAPWAP_MAX_DISCOVERY_INTERVAL 20
#define CW_DISCOVERY_INTERVAL 5
#define CW_MAX_DISCOVERY_INTERVAL 20
#define CAPWAP_RETRANSMIT_INTERVAL 3
#define CAPWAP_MAX_DISCOVERIES 10
#define CAPWAP_MAX_RETRANSMIT 5
@ -351,7 +347,7 @@ CW_MSG_MAXMSG = 26
#define CAPWAP_STATISTICS_TIMER 120
#define CAPWAP_TIMERS ((CAPWAP_DISCOVERY_INTERVAL << 8) | CAPWAP_ECHO_INTERVAL)
#define CAPWAP_TIMERS ((CW_DISCOVERY_INTERVAL << 8) | CAPWAP_ECHO_INTERVAL)
//#define CAPWAP_CIPHER "PSK-AES128-CBC-SHA:"

View File

@ -75,7 +75,7 @@ void cw_init_request(struct conn *conn, int msg_id)
cw_put_dword(buffer + 4, 0);
/* unencrypted */
cw_set_hdr_preamble(buffer, CAPWAP_VERSION << 4 | 0);
cw_set_hdr_preamble(buffer, CW_VERSION << 4 | 0);
cw_set_hdr_rmac(buffer, conn->base_rmac);
//cw_set_hdr_hlen(buffer, 2);
@ -99,7 +99,7 @@ void cw_init_data_msg(struct conn *conn)
cw_put_dword(buffer + 4, 0);
/* unencrypted */
cw_set_hdr_preamble(buffer, CAPWAP_VERSION << 4 | 0);
cw_set_hdr_preamble(buffer, CW_VERSION << 4 | 0);
@ -579,12 +579,12 @@ int conn_process_packet2(struct conn *conn, uint8_t * packet, int len,
int preamble = cw_get_hdr_preamble(packet);
if ((preamble & 0xf0) != (CAPWAP_VERSION << 4)) {
if ((preamble & 0xf0) != (CW_VERSION << 4)) {
/* wrong version */
cw_dbg(DBG_PKT_ERR,
"Discarding packet from %s, wrong version, version=%d, version %d expected.",
sock_addr2str(&conn->addr), (preamble & 0xf0) >> 4,
CAPWAP_VERSION);
CW_VERSION);
errno = EAGAIN;
return -1;
}

View File

@ -62,7 +62,7 @@ int cw_in_capwap_control_ip_address(struct conn *conn, struct cw_action_in *a,
struct sockaddr_in addr;
memcpy(&addr.sin_addr,data,4);
addr.sin_family=AF_INET;
sock_setport((struct sockaddr*)&addr,CAPWAP_CONTROL_PORT);
sock_setport((struct sockaddr*)&addr,CW_CONTROL_PORT);
memcpy(&acip->ip,&addr,sizeof(addr));
acip->index = cw_get_word(data+4);
}
@ -72,7 +72,7 @@ int cw_in_capwap_control_ip_address(struct conn *conn, struct cw_action_in *a,
memset (&addr,0,sizeof(addr));
memcpy(&addr.sin6_addr,data,16);
addr.sin6_family=AF_INET6;
sock_setport((struct sockaddr*)&addr,CAPWAP_CONTROL_PORT);
sock_setport((struct sockaddr*)&addr,CW_CONTROL_PORT);
memcpy(&acip->ip,&addr,sizeof(addr));
acip->index = cw_get_word(data+16);
}

View File

@ -248,12 +248,12 @@ int netconn_process_packet(struct netconn *nc, uint8_t * packet, int len,
int preamble = cw_get_hdr_preamble(packet);
if ((preamble & 0xf0) != (CAPWAP_VERSION << 4)) {
if ((preamble & 0xf0) != (CW_VERSION << 4)) {
/* wrong version */
cw_dbg(DBG_PKT_ERR,
"Discarding packet from %s, wrong version, version=%d, version %d expected.",
sock_addr2str(&nc->addr), (preamble & 0xf0) >> 4,
CAPWAP_VERSION);
CW_VERSION);
errno = EAGAIN;
return -1;
}