55 lines
1.9 KiB
C
55 lines
1.9 KiB
C
|
|
#include "action.h"
|
|
#include "dbg.h"
|
|
#include "log.h"
|
|
#include "itemstore.h"
|
|
#include "capwap.h"
|
|
|
|
|
|
|
|
int cw_in_generic(struct conn *conn,struct cw_action_in * a,uint8_t *data,int len,struct sockaddr *from)
|
|
{
|
|
if (len<a->min_len) {
|
|
cw_dbg(DBG_ELEM_ERR,"%d (%s) message element too short, lan=%d, min len=%d", a->elem_id, cw_strelemp(conn->actions,a->elem_id),len,a->min_len);
|
|
return 0;
|
|
}
|
|
if (len>a->max_len) {
|
|
cw_dbg(DBG_ELEM_ERR,"%d (%s) message element too big, len=%d, max len=%d", a->elem_id, cw_strelemp(conn->actions,a->elem_id),len,a->max_len);
|
|
return 0;
|
|
}
|
|
|
|
|
|
cw_itemstore_t itemstore = conn->incomming;
|
|
|
|
switch (a->itemtype) {
|
|
case CW_ITEMTYPE_BYTE:
|
|
cw_itemstore_set_byte(itemstore,a->item_id,*data);
|
|
break;
|
|
case CW_ITEMTYPE_WORD:
|
|
cw_itemstore_set_word(itemstore,a->item_id,cw_get_word(data));
|
|
break;
|
|
case CW_ITEMTYPE_DWORD:
|
|
cw_itemstore_set_dword(itemstore,a->item_id,cw_get_dword(data));
|
|
break;
|
|
case CW_ITEMTYPE_STR:
|
|
cw_itemstore_set_strn(itemstore,a->item_id,(char*)data,len);
|
|
break;
|
|
case CW_ITEMTYPE_BSTR:
|
|
cw_itemstore_set_bstrn(itemstore,a->item_id,data,len);
|
|
break;
|
|
case CW_ITEMTYPE_DATA:
|
|
cw_itemstore_set_data(itemstore,a->item_id,data,len);
|
|
break;
|
|
case CW_ITEMTYPE_VENDORSTR:
|
|
cw_itemstore_set_vendorstr(itemstore,a->item_id,
|
|
cw_get_dword(data),data+4,len-4);
|
|
default:
|
|
cw_log(LOG_ERR,"Can't handle item type %d in definition for incomming msg %d (%s) - %d, cw_in_generic.", a->itemtype,a->msg_id,cw_strmsg(a->msg_id), a->elem_id);
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
return 1;
|
|
}
|