2018-04-07 19:28:00 +02:00
|
|
|
#include "capwap.h"
|
|
|
|
#include "msgset.h"
|
2022-07-31 17:15:32 +02:00
|
|
|
#include "val.h"
|
2018-04-07 19:28:00 +02:00
|
|
|
#include "log.h"
|
|
|
|
#include "cw.h"
|
|
|
|
|
2022-08-13 09:47:12 +02:00
|
|
|
#include "dbg.h"
|
|
|
|
|
|
|
|
|
2018-04-07 19:28:00 +02:00
|
|
|
int cw_out_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
|
|
|
|
, uint8_t * dst)
|
|
|
|
{
|
2022-08-14 12:26:34 +02:00
|
|
|
cw_dbg(DBG_X,"Key: %s",handler->key);
|
2022-08-13 09:47:12 +02:00
|
|
|
stop();
|
|
|
|
|
|
|
|
|
2018-04-07 19:28:00 +02:00
|
|
|
int start;
|
2018-04-13 17:42:12 +02:00
|
|
|
int len;
|
2022-07-31 17:15:32 +02:00
|
|
|
cw_Val_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;
|
2022-08-13 09:47:12 +02:00
|
|
|
result = mavl_get_first(params->cfg,&search);
|
2018-04-13 17:42:12 +02:00
|
|
|
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
|
|
|
|
2022-07-29 12:11:19 +02:00
|
|
|
start = params->msgset->header_len(handler);
|
2018-04-09 09:27:38 +02:00
|
|
|
|
2022-08-13 09:47:12 +02:00
|
|
|
len = cw_ktv_write_struct(params->cfg,
|
2022-08-14 12:26:34 +02:00
|
|
|
params->cfg,
|
2018-05-14 23:30:48 +02:00
|
|
|
handler->type,handler->key,dst+start);
|
2018-04-07 19:28:00 +02:00
|
|
|
|
2022-07-29 12:11:19 +02:00
|
|
|
return params->msgset->write_header(handler,dst,len);
|
2018-04-07 19:28:00 +02:00
|
|
|
|
|
|
|
}
|