actube/src/cw/cw_check_missing_mand.c

57 lines
1.1 KiB
C
Raw Normal View History

#include "capwap.h"
#include "dbg.h"
#include "log.h"
2022-08-17 18:41:17 +02:00
int cw_check_missing_mand(struct cw_MsgData *msgdata, mavl_t keys, mavl_t handlers_by_key )
{
mlistelem_t * elem;
char *mandkey, *result;
mlist_t missing;
int count;
2022-08-22 01:59:23 +02:00
if (msgdata==NULL)
return 0;
missing = mlist_create_conststr();
if (missing==NULL){
cw_log(LOG_ERR, "Can't allocate memory for check of missing mand elems: %s", strerror(errno));
return 0;
}
mlist_foreach(elem, msgdata->mand_keys){
mandkey = mlistelem_get_str(elem);
result = mavl_get_str(keys,mandkey);
if (result == NULL){
mlist_append_ptr(missing,mandkey);
}
}
mlist_foreach(elem,missing){
2022-08-17 18:41:17 +02:00
const char * str;
struct cw_ElemHandler search, *result;
str = mlistelem_get_str(elem);
search.key = str;
result = mavl_get(handlers_by_key,&search);
if (result == NULL){
cw_log(LOG_ERR,"Can't find handler for for key %s",str);
}
else {
cw_dbg(DBG_RFC,"Missing mandatory message element: %s: %d - %s",
str,result->id, result->name);
}
}
count = missing->count;
mlist_destroy(missing);
return count;
}