2018-04-07 19:28:00 +02:00
|
|
|
#include "capwap.h"
|
|
|
|
#include "msgset.h"
|
|
|
|
#include "ktv.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "cw.h"
|
|
|
|
|
|
|
|
int cw_out_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
|
|
|
|
, uint8_t * dst)
|
|
|
|
{
|
|
|
|
int start;
|
2018-04-13 17:42:12 +02:00
|
|
|
int len;
|
|
|
|
cw_KTV_t search, *result;
|
2018-04-09 09:27:38 +02:00
|
|
|
|
2018-04-07 19:28:00 +02:00
|
|
|
if (!handler->type){
|
|
|
|
cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name);
|
2018-04-09 09:27:38 +02:00
|
|
|
return 0;
|
2018-04-07 19:28:00 +02:00
|
|
|
}
|
2018-04-13 17:42:12 +02:00
|
|
|
|
|
|
|
search.key = (char*)handler->key;
|
|
|
|
result = mavl_get_first(params->conn->local_cfg,&search);
|
|
|
|
if (result == NULL ){
|
|
|
|
if (params->elemdata->mand)
|
|
|
|
cw_log(LOG_ERR,"Can't put mandatory message element %s, no data available",handler->name);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strncmp(result->key,handler->key, strlen(handler->key))!=0){
|
|
|
|
if (params->elemdata->mand)
|
|
|
|
cw_log(LOG_ERR,"Can't put mandatory message element %s, no data available",handler->name);
|
|
|
|
return 0;
|
|
|
|
}
|
2018-04-09 09:27:38 +02:00
|
|
|
|
|
|
|
start = params->conn->header_len(handler);
|
|
|
|
|
2018-05-14 23:30:48 +02:00
|
|
|
len = cw_ktv_write_struct(params->conn->local_cfg,
|
|
|
|
params->conn->default_cfg,
|
|
|
|
handler->type,handler->key,dst+start);
|
2018-04-07 19:28:00 +02:00
|
|
|
|
2018-04-09 09:27:38 +02:00
|
|
|
return params->conn->write_header(handler,dst,len);
|
2018-04-07 19:28:00 +02:00
|
|
|
|
|
|
|
}
|