summaryrefslogtreecommitdiff
path: root/lib/examples/client-blocking.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/examples/client-blocking.c')
-rw-r--r--lib/examples/client-blocking.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/lib/examples/client-blocking.c b/lib/examples/client-blocking.c
index f26cd6c..773a26c 100644
--- a/lib/examples/client-blocking.c
+++ b/lib/examples/client-blocking.c
@@ -6,8 +6,8 @@
#include <stdlib.h>
#include <assert.h>
#include <event2/event.h>
-#include <freeradius/libradius.h>
#include <radsec/radsec.h>
+#include <radsec/radsec-impl.h>
#include <radsec/request.h>
#include "err.h"
#include "debug.h" /* For rs_dump_packet(). */
@@ -25,20 +25,19 @@ blocking_client (const char *config_fn, const char *configuration,
struct rs_request *request = NULL;
struct rs_packet *req = NULL, *resp = NULL;
struct rs_error *err = NULL;
+ int r;
- if (rs_context_create (&h))
+ r = rs_context_create (&h);
+ if (r)
{
- err = err_create (RSE_INTERNAL, NULL, 0, "unable to create context");
- assert (err != NULL);
- return err;
+ assert(r == RSE_NOMEM);
+ assert (!"out of RAM -- unable to create libradsec context");
}
#if !defined (USE_CONFIG_FILE)
{
struct rs_peer *server;
- if (rs_context_init_freeradius_dict (h, "/usr/share/freeradius/dictionary"))
- goto cleanup;
if (rs_conn_create (h, &conn, NULL))
goto cleanup;
rs_conn_set_type (conn, RS_CONN_TYPE_UDP);
@@ -54,22 +53,20 @@ blocking_client (const char *config_fn, const char *configuration,
#else /* defined (USE_CONFIG_FILE) */
if (rs_context_read_config (h, config_fn))
goto cleanup;
- if (rs_context_init_freeradius_dict (h, NULL))
- goto cleanup;
if (rs_conn_create (h, &conn, configuration))
goto cleanup;
#endif /* defined (USE_CONFIG_FILE) */
if (use_request_object_flag)
{
- if (rs_request_create_authn (conn, &request, USER_NAME, USER_PW))
+ if (rs_request_create_authn (conn, &request, USER_NAME, USER_PW, SECRET))
goto cleanup;
if (rs_request_send (request, &resp))
goto cleanup;
}
else
{
- if (rs_packet_create_authn_request (conn, &req, USER_NAME, USER_PW))
+ if (rs_packet_create_authn_request (conn, &req, USER_NAME, USER_PW, SECRET))
goto cleanup;
if (rs_packet_send (req, NULL))
goto cleanup;
@@ -80,10 +77,10 @@ blocking_client (const char *config_fn, const char *configuration,
if (resp)
{
rs_dump_packet (resp);
- if (rs_packet_frpkt (resp)->code == PW_AUTHENTICATION_ACK)
+ if (rs_packet_code (resp) == PW_ACCESS_ACCEPT)
printf ("Good auth.\n");
else
- printf ("Bad auth: %d\n", rs_packet_frpkt (resp)->code);
+ printf ("Bad auth: %d\n", rs_packet_code (resp));
}
else
fprintf (stderr, "%s: no response\n", __func__);
@@ -128,7 +125,7 @@ main (int argc, char *argv[])
err = blocking_client (argv[1], argv[2], use_request_object_flag);
if (err)
{
- fprintf (stderr, "%s\n", rs_err_msg (err));
+ fprintf (stderr, "error: %s: %d\n", rs_err_msg (err), rs_err_code (err, 0));
return rs_err_code (err, 1);
}
return 0;