Add retransmission timer support (UDP).
[radsecproxy.git] / lib / send.c
index cc7fd71..0872471 100644 (file)
 #include "tcp.h"
 #include "udp.h"
 
-/* RFC 5080 2.2.1.  Retransmission Behavior */
-#define IRT 2
-#define MRC 5
-#define MRT 16
-#define MRD 30
-
 static int
 _conn_open (struct rs_connection *conn, struct rs_packet *pkt)
 {
@@ -41,6 +35,8 @@ _conn_open (struct rs_connection *conn, struct rs_packet *pkt)
   if (conn->realm->type == RS_CONN_TYPE_TCP
       || conn->realm->type == RS_CONN_TYPE_TLS)
     {
+      if (tcp_init_connect_timer (conn))
+       return -1;
       if (event_init_bufferevent (conn, conn->active_peer))
        return -1;
     }
@@ -48,6 +44,8 @@ _conn_open (struct rs_connection *conn, struct rs_packet *pkt)
     {
       if (udp_init (conn, pkt))
        return -1;
+      if (udp_init_retransmit_timer (conn))
+       return -1;
     }
 
   if (!conn->is_connected)
@@ -128,7 +126,10 @@ rs_packet_send (struct rs_packet *pkt, void *user_data)
       conn->user_data = NULL;
 
       if ((pkt->flags & rs_packet_sent_flag) == 0)
-       return -1;
+       {
+         assert (rs_err_conn_peek_code (conn));
+         return rs_err_conn_peek_code (conn);
+       }
     }
 
   return RSE_OK;