Moved some functions from lwapp.h to lw.h, capwap.h to cw.h ...
FossilOrigin-Name: 8b6f76655e93cdb212b833ec890772b57e53723cf30b4fa9635130701890b0f2
This commit is contained in:
parent
f29d758df4
commit
673f59a651
@ -224,6 +224,8 @@ BSTROBJS= bstr_create.o \
|
|||||||
|
|
||||||
FRAGOBJS=fragman.o
|
FRAGOBJS=fragman.o
|
||||||
|
|
||||||
|
# cw_in_wtp_descriptor.o \
|
||||||
|
|
||||||
CWACTION=action.o \
|
CWACTION=action.o \
|
||||||
capwap_actions_ac.o \
|
capwap_actions_ac.o \
|
||||||
capwap_actions_wtp.o \
|
capwap_actions_wtp.o \
|
||||||
@ -231,7 +233,6 @@ CWACTION=action.o \
|
|||||||
capwap_80211_actions_ac.o \
|
capwap_80211_actions_ac.o \
|
||||||
cw_in_generic.o \
|
cw_in_generic.o \
|
||||||
cw_in_generic2.o \
|
cw_in_generic2.o \
|
||||||
cw_in_wtp_descriptor.o \
|
|
||||||
cw_out_wtp_board_data.o \
|
cw_out_wtp_board_data.o \
|
||||||
cw_out_ac_name_with_priority.o \
|
cw_out_ac_name_with_priority.o \
|
||||||
cw_in_ac_name_with_priority.o \
|
cw_in_ac_name_with_priority.o \
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
#include "lwapp.h"
|
#include "lwapp.h"
|
||||||
#include "strlist.h"
|
#include "strlist.h"
|
||||||
|
|
||||||
|
#include "cw.h"
|
||||||
|
|
||||||
/* capwap version and iana number */
|
/* capwap version and iana number */
|
||||||
|
|
||||||
@ -605,6 +605,7 @@ extern int cw_readmsg_configuration_update_request(uint8_t * elems, int elems_le
|
|||||||
|
|
||||||
/* Use some macros from LWAPP */
|
/* Use some macros from LWAPP */
|
||||||
|
|
||||||
|
/*
|
||||||
#define cw_put_byte lw_put_byte
|
#define cw_put_byte lw_put_byte
|
||||||
#define cw_put_word lw_put_word
|
#define cw_put_word lw_put_word
|
||||||
#define cw_put_dword lw_put_dword
|
#define cw_put_dword lw_put_dword
|
||||||
@ -619,6 +620,8 @@ extern int cw_readmsg_configuration_update_request(uint8_t * elems, int elems_le
|
|||||||
#define cw_get_word lw_get_word
|
#define cw_get_word lw_get_word
|
||||||
#define cw_get_dword lw_get_dword
|
#define cw_get_dword lw_get_dword
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/* macro to isolate bits from a dword */
|
/* macro to isolate bits from a dword */
|
||||||
#define cw_get_dword_bits(src,start,len) ((~(0xFFFFFFFF<<len)) & (src >> (32 - start - len)))
|
#define cw_get_dword_bits(src,start,len) ((~(0xFFFFFFFF<<len)) & (src >> (32 - start - len)))
|
||||||
@ -1081,15 +1084,6 @@ static inline int cw_put_ac_status(uint8_t * dst, struct cw_ac_status *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline int cw_put_version(uint8_t * dst, uint16_t subelem_id, uint8_t * v)
|
|
||||||
{
|
|
||||||
uint8_t *d = dst;
|
|
||||||
d += cw_put_dword(d, bstrv_get_vendor_id(v));
|
|
||||||
d += cw_put_dword(d, (subelem_id << 16) | bstrv_len(v));
|
|
||||||
d += cw_put_data(d, bstrv_data(v), bstrv_len(v));
|
|
||||||
return d - dst;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int cw_register_actions_capwap_ac(struct cw_actiondef *def);
|
int cw_register_actions_capwap_ac(struct cw_actiondef *def);
|
||||||
|
43
src/cw/cw.h
43
src/cw/cw.h
@ -1,6 +1,9 @@
|
|||||||
#ifndef __CW_H
|
#ifndef __CW_H
|
||||||
#define __CW_H
|
#define __CW_H
|
||||||
|
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
#include "bstr.h"
|
||||||
#include "mbag.h"
|
#include "mbag.h"
|
||||||
#include "conn.h"
|
#include "conn.h"
|
||||||
#include "action.h"
|
#include "action.h"
|
||||||
@ -12,14 +15,7 @@
|
|||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern int cw_read_wtp_descriptor(mbag_t mbag, struct conn *conn,
|
|
||||||
struct cw_action_in *a, uint8_t * data, int len);
|
|
||||||
|
|
||||||
extern int cw_read_wtp_descriptor_7(mbag_t mbag, struct conn *conn,
|
|
||||||
struct cw_action_in *a, uint8_t * data, int len);
|
|
||||||
|
|
||||||
extern int cw_read_wtp_descriptor_versions(mbag_t mbag, uint8_t * data,
|
|
||||||
int len);
|
|
||||||
|
|
||||||
/* Use some macros from LWAPP */
|
/* Use some macros from LWAPP */
|
||||||
|
|
||||||
@ -29,7 +25,7 @@ extern int cw_read_wtp_descriptor_versions(mbag_t mbag, uint8_t * data,
|
|||||||
*/
|
*/
|
||||||
#define cw_put_byte lw_put_byte
|
#define cw_put_byte lw_put_byte
|
||||||
/**
|
/**
|
||||||
* Put a word to an output buffee.
|
* Put a word to an output buffer.
|
||||||
* see #lw_put_word
|
* see #lw_put_word
|
||||||
*/
|
*/
|
||||||
#define cw_put_word lw_put_word
|
#define cw_put_word lw_put_word
|
||||||
@ -38,6 +34,37 @@ extern int cw_read_wtp_descriptor_versions(mbag_t mbag, uint8_t * data,
|
|||||||
#define cw_put_bstr lw_put_bstr
|
#define cw_put_bstr lw_put_bstr
|
||||||
#define cw_put_bstr16 lw_put_bstr16
|
#define cw_put_bstr16 lw_put_bstr16
|
||||||
|
|
||||||
|
#define cw_set_dword lw_set_dword
|
||||||
|
|
||||||
|
#define cw_get_byte lw_get_byte
|
||||||
|
#define cw_get_word lw_get_word
|
||||||
|
#define cw_get_dword lw_get_dword
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static inline int cw_put_version(uint8_t * dst, uint16_t subelem_id, bstrv_t v)
|
||||||
|
{
|
||||||
|
uint8_t *d = dst;
|
||||||
|
d += cw_put_dword(d, bstrv_get_vendor_id(v));
|
||||||
|
d += cw_put_dword(d, (subelem_id << 16) | bstrv_len(v));
|
||||||
|
d += cw_put_data(d, bstrv_data(v), bstrv_len(v));
|
||||||
|
return d - dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
extern int cw_read_wtp_descriptor(mbag_t mbag, struct conn *conn,
|
||||||
|
struct cw_action_in *a, uint8_t * data, int len);
|
||||||
|
|
||||||
|
extern int cw_read_wtp_descriptor_7(mbag_t mbag, struct conn *conn,
|
||||||
|
struct cw_action_in *a, uint8_t * data, int len);
|
||||||
|
|
||||||
|
extern int cw_read_wtp_descriptor_versions(mbag_t mbag, uint8_t * data,
|
||||||
|
int len);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@}
|
*@}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "sock.h"
|
#include "sock.h"
|
||||||
|
|
||||||
|
|
||||||
static int cw_read_wtp_descriptor_versions(mbag_t mbag, uint8_t * data,
|
static int _cw_read_wtp_descriptor_versions(mbag_t mbag, uint8_t * data,
|
||||||
int len, int silent)
|
int len, int silent)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -164,7 +164,7 @@ static int cw_read_wtp_descriptor(mbag_t mbag, struct conn *conn,
|
|||||||
pos += 3;
|
pos += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cw_read_wtp_descriptor_versions(mbag, data + pos, len - pos, silent);
|
return _cw_read_wtp_descriptor_versions(mbag, data + pos, len - pos, silent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ static int cw_read_cisco_wtp_descriptor(mbag_t mbag, struct conn *conn,
|
|||||||
cw_get_word(data + pos + 2);
|
cw_get_word(data + pos + 2);
|
||||||
pos += 2;
|
pos += 2;
|
||||||
|
|
||||||
return cw_read_wtp_descriptor_versions(mbag, data + pos, len - pos, silent);
|
return _cw_read_wtp_descriptor_versions(mbag, data + pos, len - pos, silent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
#include "capwap.h"
|
#include "capwap.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "cw.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
int cw_put_subelem_version(uint8_t *dst,uint16_t subelem_id, uint32_t vendor_id,bstr16_t data)
|
int cw_put_subelem_version(uint8_t *dst,uint16_t subelem_id, uint32_t vendor_id,bstr16_t data)
|
||||||
{
|
{
|
||||||
|
@ -5,6 +5,9 @@
|
|||||||
#include "capwap_items.h"
|
#include "capwap_items.h"
|
||||||
#include "capwap.h"
|
#include "capwap.h"
|
||||||
|
|
||||||
|
#include "cw.h"
|
||||||
|
|
||||||
|
|
||||||
static int cw_put_encryption_subelems(uint8_t *dst,int capwap_mode)
|
static int cw_put_encryption_subelems(uint8_t *dst,int capwap_mode)
|
||||||
{
|
{
|
||||||
if (capwap_mode==CW_MODE_CISCO){
|
if (capwap_mode==CW_MODE_CISCO){
|
||||||
|
63
src/cw/lw.h
63
src/cw/lw.h
@ -57,6 +57,69 @@
|
|||||||
#define lw_get_dword(src) \
|
#define lw_get_dword(src) \
|
||||||
(ntohl( *((uint32_t*)(src))))
|
(ntohl( *((uint32_t*)(src))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* the following functions are defined as static inline and not as
|
||||||
|
macro to avoid any side effects */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put some bytes to an output buffer
|
||||||
|
* @param dst Destination
|
||||||
|
* @param data Data to put
|
||||||
|
* @len length of data (iini bytes)
|
||||||
|
* @return The number of bytes put
|
||||||
|
*/
|
||||||
|
static inline int lw_put_data(uint8_t*dst,const uint8_t*data,uint16_t len)
|
||||||
|
{
|
||||||
|
memcpy(dst,data,len);
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put a #bstr_t to an output buffer
|
||||||
|
* @param dst Destination
|
||||||
|
* @param b bstr to put
|
||||||
|
* @return The number of bytes put
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put a #bstr16_t to an output buffer
|
||||||
|
* @param dst Destination
|
||||||
|
* @param b bstr16 to put
|
||||||
|
* @return The number of bytes put
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put a string to an output buffer
|
||||||
|
* @param dst Output buffer
|
||||||
|
* @param str zero-terminated string to put
|
||||||
|
* @return number of bytes put
|
||||||
|
*/
|
||||||
|
static inline int lw_put_str(uint8_t*dst,const uint8_t *str) {
|
||||||
|
return lw_put_data(dst,str,strlen((char*)str));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline int lw_put_elem_hdr(uint8_t *dst,uint8_t type,uint16_t len)
|
||||||
|
{
|
||||||
|
*dst=type;
|
||||||
|
*((uint16_t*)(dst+1)) = htons(len);
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "lwapp.h"
|
#include "lwapp.h"
|
||||||
#include "lwapp_cisco.h"
|
#include "lwapp_cisco.h"
|
||||||
|
#include "lw.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "lwapp.h"
|
#include "lwapp.h"
|
||||||
|
#include "lw.h"
|
||||||
|
|
||||||
int lw_put_ac_descriptor(uint8_t * dst)
|
int lw_put_ac_descriptor(uint8_t * dst)
|
||||||
{
|
{
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "lwapp_cisco.h"
|
#include "lwapp_cisco.h"
|
||||||
|
#include "lw.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Put message element data for Cisco vendor specific LWAPP message
|
* Put message element data for Cisco vendor specific LWAPP message
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "lwapp.h"
|
#include "lwapp.h"
|
||||||
|
#include "lw.h"
|
||||||
|
|
||||||
int lw_put_image_data(uint8_t *dst,FILE *infile)
|
int lw_put_image_data(uint8_t *dst,FILE *infile)
|
||||||
{
|
{
|
||||||
|
@ -186,6 +186,7 @@
|
|||||||
|
|
||||||
#define lw_foreach_elem(d,msg,len) for(d=msg; d<msg+len; d=d+3+LWMSGELEM_GET_LEN(d))
|
#define lw_foreach_elem(d,msg,len) for(d=msg; d<msg+len; d=d+3+LWMSGELEM_GET_LEN(d))
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
#define lw_put_byte(dst,b) \
|
#define lw_put_byte(dst,b) \
|
||||||
(*(dst)=b,1)
|
(*(dst)=b,1)
|
||||||
@ -214,18 +215,23 @@
|
|||||||
|
|
||||||
#define lw_get_dword(src) \
|
#define lw_get_dword(src) \
|
||||||
(ntohl( *((uint32_t*)(src))))
|
(ntohl( *((uint32_t*)(src))))
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* the following functions are defined as static inline and not as
|
/* the following functions are defined as static inline and not as
|
||||||
macro to avoid any side effects */
|
macro to avoid any side effects */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
static inline int lw_put_data(uint8_t*dst,const uint8_t*data,uint16_t len)
|
static inline int lw_put_data(uint8_t*dst,const uint8_t*data,uint16_t len)
|
||||||
{
|
{
|
||||||
memcpy(dst,data,len);
|
memcpy(dst,data,len);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
static inline int lw_put_bstr(uint8_t * dst, const bstr_t b){
|
static inline int lw_put_bstr(uint8_t * dst, const bstr_t b){
|
||||||
lw_put_data(dst,bstr_data(b),bstr_len(b));
|
lw_put_data(dst,bstr_data(b),bstr_len(b));
|
||||||
return bstr_len(b);
|
return bstr_len(b);
|
||||||
@ -237,7 +243,9 @@ static inline int lw_put_bstr16(uint8_t * dst, const bstr16_t b){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
static inline int lw_put_str(uint8_t*dst,const uint8_t *str) {
|
static inline int lw_put_str(uint8_t*dst,const uint8_t *str) {
|
||||||
return lw_put_data(dst,str,strlen((char*)str));
|
return lw_put_data(dst,str,strlen((char*)str));
|
||||||
}
|
}
|
||||||
@ -249,6 +257,8 @@ static inline int lw_put_elem_hdr(uint8_t *dst,uint8_t type,uint16_t len)
|
|||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ int image_update()
|
|||||||
|
|
||||||
|
|
||||||
const char *ii = "/c1130";
|
const char *ii = "/c1130";
|
||||||
mbag_set_vendorstr(conn->outgoing, CW_ITEM_IMAGE_IDENTIFIER,
|
mbag_set_bstrv(conn->outgoing, CW_ITEM_IMAGE_IDENTIFIER,
|
||||||
CW_VENDOR_ID_CISCO, (uint8_t *) ii, strlen(ii));
|
CW_VENDOR_ID_CISCO, (uint8_t *) ii, strlen(ii));
|
||||||
|
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ conn->config=mbag_create();
|
|||||||
|
|
||||||
mbag_set_mbag(conn->config, CW_ITEM_WTP_BOARD_DATA, board_data);
|
mbag_set_mbag(conn->config, CW_ITEM_WTP_BOARD_DATA, board_data);
|
||||||
|
|
||||||
// hw = vendorstr_create(conf_vendor_id,conf_hardware_version
|
// hw = bstrv_create(conf_vendor_id,conf_hardware_version
|
||||||
//mbag_set_bstr16(conn->config, CW_ITEM_WTP_HARDWARE_VERSION,conf_hardware_version);
|
//mbag_set_bstr16(conn->config, CW_ITEM_WTP_HARDWARE_VERSION,conf_hardware_version);
|
||||||
//mbag_set_bstr16(conn->config, CW_ITEM_WTP_SOFTWARE_VERSION,conf_software_version);
|
//mbag_set_bstr16(conn->config, CW_ITEM_WTP_SOFTWARE_VERSION,conf_software_version);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user