summaryrefslogtreecommitdiff
path: root/lib/examples
diff options
context:
space:
mode:
Diffstat (limited to 'lib/examples')
-rw-r--r--lib/examples/Makefile4
-rw-r--r--lib/examples/client-blocking.c19
2 files changed, 20 insertions, 3 deletions
diff --git a/lib/examples/Makefile b/lib/examples/Makefile
index 692e9d6..4a0ab8f 100644
--- a/lib/examples/Makefile
+++ b/lib/examples/Makefile
@@ -1,4 +1,6 @@
-CFLAGS = -Wall -g -I ../include
+SPECIAL = # -DUSE_REQUEST_OBJECT
+
+CFLAGS = -Wall -g -I ../include $(SPECIAL)
HFILES = ../include/radsec/radsec.h ../include/radsec/radsec-impl.h
diff --git a/lib/examples/client-blocking.c b/lib/examples/client-blocking.c
index 54fc05b..1e6ec25 100644
--- a/lib/examples/client-blocking.c
+++ b/lib/examples/client-blocking.c
@@ -7,6 +7,9 @@
#include <event2/event.h>
#include <freeradius/libradius.h>
#include <radsec/radsec.h>
+#if defined(USE_REQUEST_OBJECT)
+#include <radsec/request.h>
+#endif
#define SECRET "sikrit"
#define USER_NAME "bob"
@@ -29,19 +32,31 @@ rsx_client (const char *srvname, int srvport)
return rs_conn_err_pop (conn);
if (rs_conn_add_server (conn, &server, RS_CONN_TYPE_UDP, srvname, srvport))
return rs_conn_err_pop (conn);
- rs_server_set_timeout (server, 10);
+ rs_server_set_timeout (server, 1);
rs_server_set_tries (server, 3);
rs_server_set_secret (server, SECRET);
if (rs_packet_create_acc_request (conn, &req, USER_NAME, USER_PW))
return rs_conn_err_pop (conn);
+#if !defined(USE_REQUEST_OBJECT)
if (rs_packet_send (req, NULL))
return rs_conn_err_pop (conn);
req = NULL;
-
if (rs_conn_receive_packet (conn, &resp))
return rs_conn_err_pop (conn);
+#else
+ {
+ struct rs_request *request;
+
+ if (rs_request_new (conn, &request))
+ return rs_conn_err_pop (conn);
+ if (rs_req_send (request, req, &resp))
+ return rs_conn_err_pop (conn);
+ rs_request_destroy (request);
+ }
+#endif /* !defined(USE_REQUEST_OBJECT) */
+
fr_pkt = rs_packet_frpkt (resp);
fr_vp = fr_pkt->vps; /* FIXME: Is there an accessor? */
vp_printlist(stdout, fr_vp);