2015-04-05 02:10:37 +02:00
|
|
|
|
2016-03-11 22:23:00 +01:00
|
|
|
#include "cw.h"
|
2015-04-05 02:10:37 +02:00
|
|
|
#include "capwap_items.h"
|
|
|
|
|
2015-04-11 19:00:51 +02:00
|
|
|
#include "dbg.h"
|
2015-04-10 17:52:01 +02:00
|
|
|
#include "log.h"
|
2015-04-07 07:42:36 +02:00
|
|
|
|
2015-04-05 02:10:37 +02:00
|
|
|
|
2016-04-11 04:17:23 +02:00
|
|
|
int cw_out_generic(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
|
2015-04-05 02:10:37 +02:00
|
|
|
{
|
2015-04-05 20:27:17 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Get the item to put */
|
2015-04-19 23:27:44 +02:00
|
|
|
struct mbag_item *item = NULL;
|
2015-04-10 17:14:55 +02:00
|
|
|
if (a->get) {
|
|
|
|
item = a->get(conn, a);
|
2015-04-05 20:27:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Size for msg elem header depends on
|
|
|
|
vendor specific payload */
|
2015-04-10 17:14:55 +02:00
|
|
|
int start = a->vendor_id ? 10 : 4;
|
|
|
|
|
2015-04-05 20:27:17 +02:00
|
|
|
|
2015-04-05 02:10:37 +02:00
|
|
|
int len;
|
2015-04-10 17:14:55 +02:00
|
|
|
if (!item) {
|
2015-04-19 16:44:20 +02:00
|
|
|
const char *vendor="";
|
|
|
|
if ( a->vendor_id ) {
|
|
|
|
vendor=cw_strvendor(a->vendor_id);
|
|
|
|
}
|
2015-04-10 17:14:55 +02:00
|
|
|
if (a->mand) {
|
2015-04-11 19:00:51 +02:00
|
|
|
cw_log(LOG_ERR,
|
2016-04-11 03:25:40 +02:00
|
|
|
"Can't put mandatory element %s %d - (%s) into %s. No value for '%s' found.",
|
2015-04-19 16:44:20 +02:00
|
|
|
vendor,
|
2015-04-11 19:00:51 +02:00
|
|
|
a->elem_id, cw_strelemp(conn->actions, a->elem_id)
|
|
|
|
, cw_strmsg(a->msg_id)
|
2016-04-11 03:25:40 +02:00
|
|
|
, a->item_id
|
2015-04-11 19:00:51 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
else{
|
2015-05-02 02:02:06 +02:00
|
|
|
cw_dbg(DBG_WARN,"No output for element %s%d -(%s) in %s. Item %s not found.",
|
2015-04-19 16:44:20 +02:00
|
|
|
vendor,
|
2015-04-11 19:00:51 +02:00
|
|
|
a->elem_id, cw_strelemp(conn->actions, a->elem_id)
|
|
|
|
, cw_strmsg(a->msg_id),a->item_id);
|
|
|
|
|
2015-04-07 07:42:36 +02:00
|
|
|
}
|
|
|
|
return 0;
|
2015-04-10 17:14:55 +02:00
|
|
|
} else {
|
2016-03-28 10:46:49 +02:00
|
|
|
len = cw_put_mbag_item(dst + start, item);
|
2015-04-05 20:27:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-10 17:14:55 +02:00
|
|
|
if (a->vendor_id)
|
|
|
|
return len + cw_put_elem_vendor_hdr(dst, a->vendor_id, a->elem_id, len);
|
2015-04-05 20:27:17 +02:00
|
|
|
|
2015-04-10 17:14:55 +02:00
|
|
|
return len + cw_put_elem_hdr(dst, a->elem_id, len);
|
2015-04-05 02:10:37 +02:00
|
|
|
}
|
2015-04-28 10:23:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|