summaryrefslogtreecommitdiff
path: root/lib/examples
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordu.net>2010-10-03 22:51:29 +0200
committerLinus Nordberg <linus@nordu.net>2010-10-03 22:51:29 +0200
commit4d99bb55ec1368b42daccb29f0440bc166297a17 (patch)
treedff2f47b6555583c71ff38207e7efaedb9dd459e /lib/examples
parent63a5bc0182881d8f806a9acdf47b708492b8a41b (diff)
WIP
Diffstat (limited to 'lib/examples')
-rw-r--r--lib/examples/client-blocking.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/examples/client-blocking.c b/lib/examples/client-blocking.c
index 9a211c8..a9a4f32 100644
--- a/lib/examples/client-blocking.c
+++ b/lib/examples/client-blocking.c
@@ -16,7 +16,7 @@
#define USER_PW "hemligt"
struct rs_error *
-blocking_client (const char *srvname, int srvport)
+blocking_client (const char *av1, const char *av2)
{
struct rs_handle *h;
struct rs_connection *conn;
@@ -28,13 +28,23 @@ blocking_client (const char *srvname, int srvport)
if (rs_context_create (&h, "/usr/share/freeradius/dictionary"))
return NULL;
- if (rs_conn_create (h, &conn))
+ if (rs_conn_create (h, &conn, RS_CONN_TYPE_UDP))
return rs_err_conn_pop (conn);
- if (rs_conn_add_server (conn, &server, RS_CONN_TYPE_UDP, srvname, srvport))
+#if !defined (USE_CONFIG_FILE)
+ if (rs_server_create (conn, &server, NULL))
+ 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);
- rs_server_set_secret (server, SECRET);
+ if (rs_server_set_secret (server, SECRET))
+ return rs_err_conn_pop (conn);
+#else
+ if (rs_context_config_read (h, av1))
+ return rs_err_ctx_pop (h);
+ if (rs_server_create (conn, &server, av2))
+ return rs_err_conn_pop (conn);
+#endif /* USE_CONFIG_FILE */
if (rs_packet_create_acc_request (conn, &req, USER_NAME, USER_PW))
return rs_err_conn_pop (conn);
@@ -71,12 +81,8 @@ int
main (int argc, char *argv[])
{
struct rs_error *err;
- char *host;
- int port;
- host = strsep (argv + 1, ":");
- port = atoi (argv[1]);
- err = blocking_client (host, port);
+ err = blocking_client (argv[1], argv[2]);
if (err)
{
fprintf (stderr, "%s\n", rs_err_msg (err, 0));