2015-04-12 19:19:29 +02:00
|
|
|
#include <errno.h>
|
2015-04-08 20:09:13 +02:00
|
|
|
|
|
|
|
#include "capwap.h"
|
2015-04-10 17:14:55 +02:00
|
|
|
#include "capwap_items.h"
|
2015-04-08 20:09:13 +02:00
|
|
|
#include "intavltree.h"
|
2015-04-10 17:52:01 +02:00
|
|
|
#include "log.h"
|
2015-04-08 20:09:13 +02:00
|
|
|
#include "dbg.h"
|
|
|
|
#include "sock.h"
|
|
|
|
|
|
|
|
int cw_in_check_disc_resp(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
2015-04-12 23:28:55 +02:00
|
|
|
int len,struct sockaddr *from)
|
2015-04-08 20:09:13 +02:00
|
|
|
{
|
|
|
|
cw_action_in_t *mlist[20];
|
|
|
|
int n = cw_check_missing_mand(mlist, conn, a);
|
|
|
|
|
2015-04-11 19:00:51 +02:00
|
|
|
//cw_dbg(DBG_INFO,"This response came from: %s",sock_addr2str(&conn->addr));
|
2015-04-08 20:09:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* if mandatory elements are missing, ignore this response */
|
2015-04-12 19:19:29 +02:00
|
|
|
if (n && conn->strict_capwap) {
|
|
|
|
cw_dbg_missing_mand(DBG_MSG_ERR, conn, mlist, n, a);
|
2015-04-11 19:00:51 +02:00
|
|
|
cw_dbg(DBG_MSG_ERR,
|
2015-04-08 20:09:13 +02:00
|
|
|
"Ignoring Discovery Response from %s - missing mandatory elements.",
|
2015-04-24 19:51:07 +02:00
|
|
|
sock_addr2str(from));
|
2015-04-12 19:19:29 +02:00
|
|
|
errno = EAGAIN;
|
2015-04-08 20:09:13 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2015-04-12 19:19:29 +02:00
|
|
|
if (n) {
|
|
|
|
cw_dbg_missing_mand(DBG_RFC, conn, mlist, n, a);
|
|
|
|
}
|
2015-04-08 20:09:13 +02:00
|
|
|
|
2015-04-10 17:14:55 +02:00
|
|
|
/* we have all AC information in the incomming buffer */
|
2015-04-19 23:27:44 +02:00
|
|
|
mbag_t discs;
|
2015-04-08 20:09:13 +02:00
|
|
|
|
2015-05-01 00:16:54 +02:00
|
|
|
discs = mbag_get_mavl_c(conn->remote, CW_ITEM_DISCOVERIES,
|
|
|
|
mbag_i_create);
|
2015-04-10 17:14:55 +02:00
|
|
|
|
2015-04-20 02:26:24 +02:00
|
|
|
//mavl_del_all(discs);
|
|
|
|
//exit(0);
|
|
|
|
|
2015-04-10 17:14:55 +02:00
|
|
|
if ( !discs ) {
|
|
|
|
cw_log(LOG_ERR,"Can't allocate store for disc resp");
|
2015-04-12 19:19:29 +02:00
|
|
|
errno = ENOMEM;
|
|
|
|
return -1;
|
2015-04-10 17:14:55 +02:00
|
|
|
}
|
|
|
|
|
2015-05-01 00:16:54 +02:00
|
|
|
mbag_i_set_mavl(discs,discs->count,conn->incomming);
|
|
|
|
|
2015-04-19 23:27:44 +02:00
|
|
|
conn->incomming = mbag_create();
|
2015-04-08 20:09:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|