projects
/
libradsec.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge libradsec-new-client.
[libradsec.git]
/
lib
/
examples
/
client-blocking.c
diff --git
a/lib/examples/client-blocking.c
b/lib/examples/client-blocking.c
index
419be8c
..
7d3869a
100644
(file)
--- a/
lib/examples/client-blocking.c
+++ b/
lib/examples/client-blocking.c
@@
-4,11
+4,12
@@
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
+#include <assert.h>
#include <event2/event.h>
#include <event2/event.h>
-#include <freeradius/libradius.h>
#include <radsec/radsec.h>
#include <radsec/radsec-impl.h>
#include <radsec/request.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"
#include "debug.h" /* For rs_dump_packet(). */
#define SECRET "sikrit"
@@
-16,7
+17,8
@@
#define USER_PW "password"
struct rs_error *
#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;
{
struct rs_context *h = NULL;
struct rs_connection *conn = NULL;
@@
-25,14
+27,16
@@
blocking_client (const char *av1, const char *av2, int use_request_object_flag)
struct rs_error *err = NULL;
if (rs_context_create (&h))
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)
{
struct rs_peer *server;
#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);
if (rs_conn_create (h, &conn, NULL))
goto cleanup;
rs_conn_set_type (conn, RS_CONN_TYPE_UDP);
@@
-46,11
+50,9
@@
blocking_client (const char *av1, const char *av2, int use_request_object_flag)
goto cleanup;
}
#else /* defined (USE_CONFIG_FILE) */
goto cleanup;
}
#else /* defined (USE_CONFIG_FILE) */
- if (rs_context_read_config (h, av1))
- goto cleanup;
- if (rs_context_init_freeradius_dict (h, NULL))
+ if (rs_context_read_config (h, config_fn))
goto cleanup;
goto cleanup;
- if (rs_conn_create (h, &conn,
av2
))
+ if (rs_conn_create (h, &conn,
configuration
))
goto cleanup;
#endif /* defined (USE_CONFIG_FILE) */
goto cleanup;
#endif /* defined (USE_CONFIG_FILE) */
@@
-74,10
+76,10
@@
blocking_client (const char *av1, const char *av2, int use_request_object_flag)
if (resp)
{
rs_dump_packet (resp);
if (resp)
{
rs_dump_packet (resp);
- if (rs_packet_
frpkt (resp)->code
== PW_ACCESS_ACCEPT)
+ if (rs_packet_
code (resp)
== PW_ACCESS_ACCEPT)
printf ("Good auth.\n");
else
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__);
}
else
fprintf (stderr, "%s: no response\n", __func__);
@@
-98,6
+100,13
@@
blocking_client (const char *av1, const char *av2, int use_request_object_flag)
return err;
}
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[])
{
int
main (int argc, char *argv[])
{
@@
-110,6
+119,8
@@
main (int argc, char *argv[])
argc--;
argv++;
}
argc--;
argv++;
}
+ if (argc < 3)
+ usage (argc, argv);
err = blocking_client (argv[1], argv[2], use_request_object_flag);
if (err)
{
err = blocking_client (argv[1], argv[2], use_request_object_flag);
if (err)
{