From d464ebb9235fe78e6588e95d4d3333d5ee95ca48 Mon Sep 17 00:00:00 2001
From: Linus Nordberg <linus@nordu.net>
Date: Tue, 8 Mar 2011 13:37:46 +0100
Subject: Timeout implemented in request objects, supported by TCP.

TODO: UDP.
---
 lib/include/radsec/radsec-impl.h | 1 +
 lib/include/radsec/radsec.h      | 9 ++++++---
 2 files changed, 7 insertions(+), 3 deletions(-)

(limited to 'lib/include/radsec')

diff --git a/lib/include/radsec/radsec-impl.h b/lib/include/radsec/radsec-impl.h
index a924fc9..49f9a35 100644
--- a/lib/include/radsec/radsec-impl.h
+++ b/lib/include/radsec/radsec-impl.h
@@ -75,6 +75,7 @@ struct rs_connection {
     struct rs_peer *peers;
     struct rs_peer *active_peer;
     struct rs_error *err;
+    struct timeval timeout;
     char is_connecting;		/* FIXME: replace with a single state member */
     char is_connected;		/* FIXME: replace with a single state member */
     int fd;			/* Socket.  */
diff --git a/lib/include/radsec/radsec.h b/lib/include/radsec/radsec.h
index fcd391d..5f8f4db 100644
--- a/lib/include/radsec/radsec.h
+++ b/lib/include/radsec/radsec.h
@@ -3,6 +3,7 @@
 /* See the file COPYING for licensing information.  */
 
 #include <unistd.h>
+#include <sys/time.h>
 
 enum rs_err_code {
     RSE_OK = 0,
@@ -21,9 +22,10 @@ enum rs_err_code {
     RSE_INTERNAL = 13,
     RSE_SSLERR = 14,		/* OpenSSL error.  */
     RSE_INVALID_PKT = 15,
-    RSE_TIMEOUT_CONN = 16,
-    RSE_INVAL = 17,
-    RSE_TIMEOUT_IO = 18,
+    RSE_TIMEOUT_CONN = 16,	/* Connection timeout.  */
+    RSE_INVAL = 17,		/* Invalid argument.  */
+    RSE_TIMEOUT_IO = 18,	/* I/O timeout.  */
+    RSE_TIMEOUT = 19,		/* High level timeout.  */
 };
 
 enum rs_conn_type {
@@ -111,6 +113,7 @@ int rs_conn_receive_packet(struct rs_connection *conn,
 			   struct rs_packet *request,
 			   struct rs_packet **pkt_out);
 int rs_conn_fd(struct rs_connection *conn);
+void rs_conn_set_timeout(struct rs_connection *conn, struct timeval *tv);
 
 /* Peer -- client and server.  */
 int rs_peer_create(struct rs_connection *conn, struct rs_peer **peer_out);
-- 
cgit v1.1