diff options
author | Linus Nordberg <linus@nordu.net> | 2010-10-02 21:31:50 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2010-10-02 21:31:50 +0200 |
commit | be4b786700ad03de5226951c043fefb345c0df4c (patch) | |
tree | e048b100e34ddcfebadabb459f9af7c55d01b3ce /lib/examples/client.c | |
parent | 7ec20f4101e5a1ef0b5f2537f25a4f8d74ad1104 (diff) |
WIP
Diffstat (limited to 'lib/examples/client.c')
-rw-r--r-- | lib/examples/client.c | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/lib/examples/client.c b/lib/examples/client.c deleted file mode 100644 index 1e9f209..0000000 --- a/lib/examples/client.c +++ /dev/null @@ -1,75 +0,0 @@ -/* RADIUS client doing blocking i/o. */ - -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <stdlib.h> -#include <event2/event.h> -#include "../libradsec.h" - -#define SECRET "sikrit" -#define USER_NAME "bob" -#define USER_PW "hemligt" - -struct rs_error * -rsx_client (const char *srvname, int srvport) -{ - struct rs_handle *h; - struct rs_connection *conn; - struct rs_peer *server; - struct rs_packet *req, *resp; - - if (rs_context_create (&h, "/usr/share/freeradius/dictionary")) - return NULL; - - if (rs_conn_create (h, &conn)) - return rs_conn_err_pop (conn); - if (rs_conn_add_server (conn, &server, RS_CONN_TYPE_UDP, srvname, srvport)) - return rs_conn_err_pop (conn); - rs_server_set_timeout (server, 10); - rs_server_set_tries (server, 3); - rs_server_set_secret (server, SECRET); - - if (rs_packet_create_acc_request (conn, &req, USER_NAME, USER_PW)) - return rs_conn_err_pop (conn); - - if (rs_packet_send (conn, req, NULL)) - return rs_conn_err_pop (conn); - req = NULL; - -#if 0 - if (rs_packet_create_acc_request (conn, &req, USER_NAME, USER_PW)) - return rs_conn_err_pop (conn); - - if (rs_packet_send (conn, req, NULL)) - return rs_conn_err_pop (conn); - req = NULL; -#endif - - if (rs_packet_receive (conn, &resp)) - return rs_conn_err_pop (conn); - /* TODO: do something interesting with the response */ - rs_packet_destroy (resp); - - rs_conn_destroy (conn); - rs_context_destroy (h); - return NULL; -} - -int -main (int argc, char *argv[]) -{ - struct rs_error *err; - char *host; - int port; - - host = strsep (argv + 1, ":"); - port = atoi (argv[1]); - err = rsx_client (host, port); - if (err) - { - fprintf (stderr, "%s\n", rs_err_msg (err, 0)); - return rs_err_code (err, 1); - } - return 0; -} |