actube/src/cw/cw_out_generic_struct.c

49 lines
1.1 KiB
C
Raw Normal View History

#include "capwap.h"
#include "msgset.h"
2022-07-31 17:15:32 +02:00
#include "val.h"
#include "log.h"
#include "cw.h"
2022-08-13 09:47:12 +02:00
#include "dbg.h"
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();
int start;
int len;
2022-07-31 17:15:32 +02:00
cw_Val_t search, *result;
if (!handler->type){
cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name);
return 0;
}
search.key = (char*)handler->key;
2022-08-13 09:47:12 +02:00
result = mavl_get_first(params->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;
}
start = params->msgset->header_len(handler);
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,
handler->type,handler->key,dst+start);
return params->msgset->write_header(handler,dst,len);
}