2014-08-17 18:32:13 +02:00
|
|
|
|
|
|
|
#include "capwap.h"
|
|
|
|
#include "cw_log.h"
|
|
|
|
#include "sock.h"
|
|
|
|
#include "cw_util.h"
|
|
|
|
|
|
|
|
|
|
|
|
struct cwrmsg * conn_get_response(struct conn * conn)
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
struct cwmsg * cwmsg = &conn->req_msg;
|
|
|
|
|
|
|
|
int type = cwmsg->type+1;
|
|
|
|
|
|
|
|
struct cwrmsg * cwrmsg;
|
|
|
|
|
2014-08-18 07:30:21 +02:00
|
|
|
int i;
|
|
|
|
for (i=0; i<conn->max_retransmit; i++) {
|
|
|
|
|
|
|
|
time_t r_timer = cw_timer_start(conn->retransmit_interval);
|
|
|
|
|
|
|
|
while(!cw_timer_timeout(r_timer)){
|
|
|
|
cwrmsg = conn_get_message(conn);
|
|
|
|
if (cwrmsg){
|
2015-03-28 12:51:34 +01:00
|
|
|
cw_dbg(DBG_MSG,"Received message from %s, type=%d - %s"
|
2014-08-18 07:30:21 +02:00
|
|
|
,sock_addr2str(&conn->addr),cwrmsg->type,cw_msgtostr(cwrmsg->type));
|
|
|
|
if (cwrmsg->type == type){
|
|
|
|
return cwrmsg;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (conn->dtls_error)
|
|
|
|
return 0;
|
2014-08-17 18:32:13 +02:00
|
|
|
}
|
2015-03-31 08:04:03 +02:00
|
|
|
cw_dbg(DBG_MSG_ERR,"Retransmitting message, type=%d,seq=%d",cwmsg->type,cwmsg->seqnum);
|
2014-08-18 07:30:21 +02:00
|
|
|
conn_send_cwmsg(conn,&conn->req_msg);
|
2014-08-17 18:32:13 +02:00
|
|
|
|
2014-08-18 07:30:21 +02:00
|
|
|
}
|
2015-03-31 08:04:03 +02:00
|
|
|
cw_dbg(DBG_MSG_ERR,"Max retransmit's reached, message type=%d,seq=%d",cwmsg->type,cwmsg->seqnum);
|
2014-08-17 18:32:13 +02:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|