summaryrefslogtreecommitdiff
path: root/lib/examples
diff options
context:
space:
mode:
Diffstat (limited to 'lib/examples')
-rw-r--r--lib/examples/Makefile11
-rw-r--r--lib/examples/client-blocking.c (renamed from lib/examples/client.c)13
2 files changed, 14 insertions, 10 deletions
diff --git a/lib/examples/Makefile b/lib/examples/Makefile
index f9f2ee1..618afdb 100644
--- a/lib/examples/Makefile
+++ b/lib/examples/Makefile
@@ -1,12 +1,11 @@
-CFLAGS = -Wall -g
+CFLAGS = -Wall -g -I ../include
-all: client
+HFILES = ../include/radsec/libradsec.h ../include/radsec/libradsec-impl.h
-blocking.o: blocking.c blocking.h ../libradsec-base.h ../libradsec.h
- $(CC) $(CFLAGS) -c -I .. $^
+all: client-blocking
-client: client.c ../libradsec.a ../libradsec.h ../libradsec-impl.h
+client-blocking: client-blocking.c ../libradsec.a $(HFILES)
$(CC) $(CFLAGS) -o $@ $< -L /usr/lib/freeradius -lfreeradius-radius -L .. -lradsec -L /usr/local/lib -levent_core
clean:
- -rm *.o client
+ -rm *.o client-blocking *.gch
diff --git a/lib/examples/client.c b/lib/examples/client-blocking.c
index 1e9f209..0d2a58a 100644
--- a/lib/examples/client.c
+++ b/lib/examples/client-blocking.c
@@ -5,7 +5,8 @@
#include <unistd.h>
#include <stdlib.h>
#include <event2/event.h>
-#include "../libradsec.h"
+#include <freeradius/libradius.h>
+#include <radsec/libradsec.h>
#define SECRET "sikrit"
#define USER_NAME "bob"
@@ -18,6 +19,8 @@ rsx_client (const char *srvname, int srvport)
struct rs_connection *conn;
struct rs_peer *server;
struct rs_packet *req, *resp;
+ RADIUS_PACKET *fr_pkt;
+ VALUE_PAIR *fr_vp;
if (rs_context_create (&h, "/usr/share/freeradius/dictionary"))
return NULL;
@@ -33,7 +36,7 @@ rsx_client (const char *srvname, int srvport)
if (rs_packet_create_acc_request (conn, &req, USER_NAME, USER_PW))
return rs_conn_err_pop (conn);
- if (rs_packet_send (conn, req, NULL))
+ if (rs_packet_send (req, NULL))
return rs_conn_err_pop (conn);
req = NULL;
@@ -46,9 +49,11 @@ rsx_client (const char *srvname, int srvport)
req = NULL;
#endif
- if (rs_packet_receive (conn, &resp))
+ if (rs_conn_receive_packet (conn, &resp))
return rs_conn_err_pop (conn);
- /* TODO: do something interesting with the response */
+ fr_pkt = rs_packet_frpkt (resp);
+ fr_vp = fr_pkt->vps; /* FIXME: Is there an accessor? */
+ vp_printlist(stdout, fr_vp);
rs_packet_destroy (resp);
rs_conn_destroy (conn);