summaryrefslogtreecommitdiff
path: root/lib/examples
diff options
context:
space:
mode:
Diffstat (limited to 'lib/examples')
-rw-r--r--lib/examples/client-blocking.c24
-rw-r--r--lib/examples/client.conf4
2 files changed, 24 insertions, 4 deletions
diff --git a/lib/examples/client-blocking.c b/lib/examples/client-blocking.c
index 2cfd617..7d3869a 100644
--- a/lib/examples/client-blocking.c
+++ b/lib/examples/client-blocking.c
@@ -4,10 +4,12 @@
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
+#include <assert.h>
#include <event2/event.h>
#include <radsec/radsec.h>
#include <radsec/radsec-impl.h>
#include <radsec/request.h>
+#include "err.h"
#include "debug.h" /* For rs_dump_packet(). */
#define SECRET "sikrit"
@@ -15,7 +17,8 @@
#define USER_PW "password"
struct rs_error *
-blocking_client (const char *av1, const char *av2, int use_request_object_flag)
+blocking_client (const char *config_fn, const char *configuration,
+ int use_request_object_flag)
{
struct rs_context *h = NULL;
struct rs_connection *conn = NULL;
@@ -24,7 +27,11 @@ blocking_client (const char *av1, const char *av2, int use_request_object_flag)
struct rs_error *err = NULL;
if (rs_context_create (&h))
- return NULL;
+ {
+ err = err_create (RSE_INTERNAL, NULL, 0, "unable to create context");
+ assert (err != NULL);
+ return err;
+ }
#if !defined (USE_CONFIG_FILE)
{
@@ -43,9 +50,9 @@ blocking_client (const char *av1, const char *av2, int use_request_object_flag)
goto cleanup;
}
#else /* defined (USE_CONFIG_FILE) */
- if (rs_context_read_config (h, av1))
+ if (rs_context_read_config (h, config_fn))
goto cleanup;
- if (rs_conn_create (h, &conn, av2))
+ if (rs_conn_create (h, &conn, configuration))
goto cleanup;
#endif /* defined (USE_CONFIG_FILE) */
@@ -93,6 +100,13 @@ blocking_client (const char *av1, const char *av2, int use_request_object_flag)
return err;
}
+void
+usage (int argc, char *argv[])
+{
+ fprintf (stderr, "usage: %s: [-r] config-file config-name\n", argv[0]);
+ exit (1);
+}
+
int
main (int argc, char *argv[])
{
@@ -105,6 +119,8 @@ main (int argc, char *argv[])
argc--;
argv++;
}
+ if (argc < 3)
+ usage (argc, argv);
err = blocking_client (argv[1], argv[2], use_request_object_flag);
if (err)
{
diff --git a/lib/examples/client.conf b/lib/examples/client.conf
index 47528c8..bf57434 100644
--- a/lib/examples/client.conf
+++ b/lib/examples/client.conf
@@ -16,6 +16,10 @@ realm blocking-tls {
cacertfile = "tests/demoCA/newcerts/01.pem"
certfile = "tests/demoCA/newcerts/02.pem"
certkeyfile = "tests/demoCA/private/c2key.pem"
+ #pskstr = "sikrit psk"
+ pskhexstr = "deadbeef4711"
+ pskid = "Client_identity"
+ pskex = "PSK"
server {
hostname = "localhost"
service = "2083"