handlers for header_len and write_headr in conn
FossilOrigin-Name: 672de93a2c0d038b6d8c9104a8e0b4fdacbe7f181485ee2f185cb81626876391
This commit is contained in:
@ -40,6 +40,7 @@
|
||||
|
||||
#include "intavltree.h"
|
||||
#include "bstr.h"
|
||||
#include "msgset.h"
|
||||
|
||||
#include "mod.h"
|
||||
|
||||
@ -75,7 +76,8 @@ struct conn {
|
||||
mavl_t local_cfg;
|
||||
mavl_t global_cfg;
|
||||
|
||||
|
||||
int (*write_header)(struct cw_ElemHandler * handler, uint8_t * dst, int len);
|
||||
int (*header_len)(struct cw_ElemHandler *handler);
|
||||
|
||||
/* mbag_t outgoing;
|
||||
mbag_t incomming;
|
||||
|
@ -30,6 +30,9 @@
|
||||
#include "conn.h"
|
||||
#include "sock.h"
|
||||
|
||||
#include "msgset.h"
|
||||
#include "cw.h"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -27,6 +27,21 @@
|
||||
|
||||
#include "conn.h"
|
||||
#include "capwap.h"
|
||||
#include "cw.h"
|
||||
|
||||
static int write_header(struct cw_ElemHandler * handler, uint8_t * dst, int len)
|
||||
{
|
||||
if (handler->vendor)
|
||||
return len + cw_put_elem_vendor_hdr(dst, handler->vendor, handler->id, len);
|
||||
|
||||
return len + cw_put_elem_hdr(dst, handler->id, len);
|
||||
}
|
||||
|
||||
static int header_len(struct cw_ElemHandler * handler)
|
||||
{
|
||||
return handler->vendor ? 10 : 4;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Basic initialization of a conn object
|
||||
@ -48,7 +63,8 @@ void conn_init(struct conn * conn)
|
||||
conn->process_packet=conn_process_packet;
|
||||
conn->process_message=process_message;
|
||||
|
||||
|
||||
conn->write_header = write_header;
|
||||
conn->header_len = header_len;
|
||||
|
||||
|
||||
}
|
||||
|
@ -21,11 +21,12 @@ int cw_ktv_write_struct(mavl_t ktv, const cw_KTVStruct_t * stru, const char *pke
|
||||
result = cw_ktv_get(ktv,key,stru[i].type);
|
||||
|
||||
if (result == NULL){
|
||||
cw_log(LOG_ERR,"Can't put %s, no value found",key);
|
||||
continue;
|
||||
cw_log(LOG_ERR,"Can't put %s, no value found, filling zero.",key);
|
||||
memset(dst+pos,0,stru[i].len);
|
||||
}
|
||||
else{
|
||||
result->type->put(result,dst+pos);
|
||||
}
|
||||
|
||||
result->type->put(result,dst+pos);
|
||||
|
||||
pos+=stru[i].len;
|
||||
|
||||
|
@ -44,17 +44,21 @@ int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams
|
||||
|
||||
/* Size for msg elem header depends on
|
||||
vendor specific payload */
|
||||
start = handler->vendor ? 10 : 4;
|
||||
/* start = handler->vendor ? 10 : 4; */
|
||||
start = params->conn->header_len(handler);
|
||||
|
||||
len = ((const cw_Type_t*)(handler->type))->put(elem,dst+start);
|
||||
|
||||
/* ((const cw_Type_t*)(handler->type))->to_str(elem,detail,120);
|
||||
sprintf(params->debug_details, " Value = %s", detail);
|
||||
params->elem = elem;*/
|
||||
|
||||
if (handler->vendor)
|
||||
/* if (handler->vendor)
|
||||
return len + cw_put_elem_vendor_hdr(dst, handler->vendor, handler->id, len);
|
||||
|
||||
l = len + cw_put_elem_hdr(dst, handler->id, len);
|
||||
l = len + cw_put_elem_hdr(dst, handler->id, len); */
|
||||
l = params->conn->write_header(handler,dst,len);
|
||||
|
||||
cw_dbg_elem(DBG_ELEM_OUT,params->conn,params->msgdata->type,handler,dst,l);
|
||||
return l;
|
||||
}
|
||||
|
@ -10,20 +10,25 @@ int cw_out_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandler
|
||||
int start;
|
||||
int len,l;
|
||||
|
||||
start = handler->vendor ? 10 : 4;
|
||||
|
||||
|
||||
if (!handler->type){
|
||||
cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name);
|
||||
return CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
start = params->conn->header_len(handler);
|
||||
|
||||
|
||||
len = cw_ktv_write_struct(params->conn->local_cfg,handler->type,handler->key,dst+start);
|
||||
|
||||
if (handler->vendor)
|
||||
return params->conn->write_header(handler,dst,len);
|
||||
|
||||
/* if (handler->vendor)
|
||||
return len + cw_put_elem_vendor_hdr(dst, handler->vendor, handler->id, len);
|
||||
|
||||
l = len + cw_put_elem_hdr(dst, handler->id, len);
|
||||
|
||||
*/
|
||||
return l;
|
||||
|
||||
|
||||
|
@ -13,7 +13,7 @@ cw_KTVStruct_t acstatus [] = {
|
||||
/* type key len, pos */
|
||||
{CW_TYPE_WORD, "stations", 2, -1},
|
||||
{CW_TYPE_WORD, "station-limit", 2, -1},
|
||||
{CW_TYPE_WORD, "avtive-wtps", 2, -1},
|
||||
{CW_TYPE_WORD, "active-wtps", 2, -1},
|
||||
{CW_TYPE_WORD, "max-wtps", 2, -1},
|
||||
{CW_TYPE_BYTE, "security", 1, -1},
|
||||
{CW_TYPE_BYTE, "r-mac-field", 1, -1},
|
||||
|
12
src/cw/cw_write_header.c
Normal file
12
src/cw/cw_write_header.c
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
#include "msgset.h"
|
||||
#include "cw.h"
|
||||
|
||||
int cw_write_header(struct cw_ElemHandler * handler, uint8_t * dst, int len)
|
||||
{
|
||||
if (handler->vendor)
|
||||
return len + cw_put_elem_vendor_hdr(dst, handler->vendor, handler->id, len);
|
||||
|
||||
return len + cw_put_elem_hdr(dst, handler->id, len);
|
||||
}
|
||||
|
Reference in New Issue
Block a user