diff options
author | Linus Nordberg <linus@nordu.net> | 2010-10-04 01:31:01 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2010-10-04 01:31:01 +0200 |
commit | 0065f2622cc3bdf1e5cfd322fbb890a25afef8d8 (patch) | |
tree | 078425b00c8cd28eef9d9dd5ab9ef2d714a4ae01 /lib/examples | |
parent | dcfb8bca7400c5db4fafbed7aa9395e5f3277d9b (diff) |
WIP -- reading configuration.
Diffstat (limited to 'lib/examples')
-rw-r--r-- | lib/examples/Makefile | 4 | ||||
-rw-r--r-- | lib/examples/client-blocking.c | 29 | ||||
-rw-r--r-- | lib/examples/client.conf | 10 |
3 files changed, 28 insertions, 15 deletions
diff --git a/lib/examples/Makefile b/lib/examples/Makefile index 4802c4b..cf3441b 100644 --- a/lib/examples/Makefile +++ b/lib/examples/Makefile @@ -1,6 +1,6 @@ SPECIAL = #SPECIAL += -DUSE_REQUEST_OBJECT -#SPECIAL += -DUSE_CONFIG_FILE +SPECIAL += -DUSE_CONFIG_FILE CFLAGS = -Wall -g -I ../include $(SPECIAL) @@ -9,7 +9,7 @@ HFILES = ../include/radsec/radsec.h ../include/radsec/radsec-impl.h all: client-blocking 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 + $(CC) $(CFLAGS) -o $@ $< -lconfuse -L /usr/lib/freeradius -lfreeradius-radius -L .. -lradsec -L /usr/local/lib -levent_core clean: -rm *.o *.gch client-blocking diff --git a/lib/examples/client-blocking.c b/lib/examples/client-blocking.c index 0e6ad39..8cd9968 100644 --- a/lib/examples/client-blocking.c +++ b/lib/examples/client-blocking.c @@ -20,7 +20,6 @@ blocking_client (const char *av1, const char *av2) { struct rs_handle *h; struct rs_connection *conn; - struct rs_peer *server; struct rs_packet *req, *resp; RADIUS_PACKET *fr_pkt; VALUE_PAIR *fr_vp; @@ -29,19 +28,23 @@ blocking_client (const char *av1, const char *av2) return NULL; #if !defined (USE_CONFIG_FILE) - if (rs_conn_create (h, &conn, NULL)) - return rs_err_conn_pop (conn); - rs_conn_set_type (conn, RS_CONN_TYPE_UDP); - if (rs_server_create (conn, &server)) - return rs_err_conn_pop (conn); - if (rs_server_set_address (server, av1, atoi (av2))) - return rs_err_conn_pop (conn); - rs_server_set_timeout (server, 1); - rs_server_set_tries (server, 3); - if (rs_server_set_secret (server, SECRET)) - return rs_err_conn_pop (conn); + { + struct rs_peer *server; + + if (rs_conn_create (h, &conn, NULL)) + return rs_err_conn_pop (conn); + rs_conn_set_type (conn, RS_CONN_TYPE_UDP); + if (rs_server_create (conn, &server)) + return rs_err_conn_pop (conn); + if (rs_server_set_address (server, av1, av2)) + return rs_err_conn_pop (conn); + rs_server_set_timeout (server, 1); + rs_server_set_tries (server, 3); + if (rs_server_set_secret (server, SECRET)) + return rs_err_conn_pop (conn); + } #else - if (rs_context_config_read (h, av1)) + if (rs_context_read_config (h, av1)) return rs_err_ctx_pop (h); if (rs_conn_create (h, &conn, av2)) return rs_err_conn_pop (conn); diff --git a/lib/examples/client.conf b/lib/examples/client.conf new file mode 100644 index 0000000..5f9536f --- /dev/null +++ b/lib/examples/client.conf @@ -0,0 +1,10 @@ +realm blocking { + type = "UDP" + server { + hostname = "localhost" + service = "1820" + secret = "sikrit" + timeout = 1 /* optional */ + tries = 10 /* optional */ + } +} |