diff options
author | Linus Nordberg <linus@nordu.net> | 2010-10-02 21:31:50 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2010-10-02 21:31:50 +0200 |
commit | be4b786700ad03de5226951c043fefb345c0df4c (patch) | |
tree | e048b100e34ddcfebadabb459f9af7c55d01b3ce /lib/examples | |
parent | 7ec20f4101e5a1ef0b5f2537f25a4f8d74ad1104 (diff) |
WIP
Diffstat (limited to 'lib/examples')
-rw-r--r-- | lib/examples/Makefile | 11 | ||||
-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); |