From 217d24060890986d38848e0a9fd68ae6e7d1727f Mon Sep 17 00:00:00 2001
From: Linus Nordberg <linus@nordu.net>
Date: Mon, 21 Mar 2011 13:33:22 +0100
Subject: API AND CONFIG CHANGE: rs_context_create() doesn't take DICT any
 more.

Use rs_context_create() to read FreeRADIUS dictionary, possibly by
taking dict file from configuration file.

CONFIG CHANGE: s/config/realm/g.
---
 lib/examples/client-blocking.c | 14 ++++++++++----
 lib/examples/client-tls.conf   | 14 --------------
 lib/examples/client-udp.conf   | 10 ----------
 lib/examples/client.conf       | 27 +++++++++++++++++++++++++++
 4 files changed, 37 insertions(+), 28 deletions(-)
 delete mode 100644 lib/examples/client-tls.conf
 delete mode 100644 lib/examples/client-udp.conf
 create mode 100644 lib/examples/client.conf

(limited to 'lib/examples')

diff --git a/lib/examples/client-blocking.c b/lib/examples/client-blocking.c
index 718dc47..23cd674 100644
--- a/lib/examples/client-blocking.c
+++ b/lib/examples/client-blocking.c
@@ -23,13 +23,15 @@ blocking_client (const char *av1, const char *av2, int use_request_object_flag)
   struct rs_packet *req = NULL, *resp = NULL;
   struct rs_error *err = NULL;
 
-  if (rs_context_create (&h, "/usr/share/freeradius/dictionary"))
+  if (rs_context_create (&h))
     return NULL;
 
 #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);
@@ -42,12 +44,14 @@ blocking_client (const char *av1, const char *av2, int use_request_object_flag)
     if (rs_peer_set_secret (server, SECRET))
       goto cleanup;
   }
-#else
+#else  /* defined (USE_CONFIG_FILE) */
   if (rs_context_read_config (h, av1))
     goto cleanup;
+  if (rs_context_init_freeradius_dict (h, NULL))
+    goto cleanup;
   if (rs_conn_create (h, &conn, av2))
     goto cleanup;
-#endif	/* USE_CONFIG_FILE */
+#endif	/* defined (USE_CONFIG_FILE) */
 
   if (use_request_object_flag)
     {
@@ -78,7 +82,9 @@ blocking_client (const char *av1, const char *av2, int use_request_object_flag)
     fprintf (stderr, "%s: no response\n", __func__);
 
  cleanup:
-  err = rs_err_conn_pop (conn);
+  err = rs_err_ctx_pop (h);
+  if (err == RSE_OK)
+    err = rs_err_conn_pop (conn);
   if (resp)
     rs_packet_destroy (resp);
   if (request)
diff --git a/lib/examples/client-tls.conf b/lib/examples/client-tls.conf
deleted file mode 100644
index 4d0904d..0000000
--- a/lib/examples/client-tls.conf
+++ /dev/null
@@ -1,14 +0,0 @@
-config blocking-tls {
-    type = "TLS"
-    timeout = 1
-    retries = 3
-    cacertfile = "/home/linus/nordberg-ca.crt"
-#    cacertfile = "/home/linus/p/moonshot/demoCA/cacert.pem"
-    certfile = "/home/linus/p/moonshot/radsecproxy-test.crt"
-    certkeyfile = "/home/linus/p/moonshot/radsecproxy-test.key"
-    server {
-        hostname = "localhost"
-	service = "2083"
-	secret = "sikrit"
-    }
-}
diff --git a/lib/examples/client-udp.conf b/lib/examples/client-udp.conf
deleted file mode 100644
index 8578e8b..0000000
--- a/lib/examples/client-udp.conf
+++ /dev/null
@@ -1,10 +0,0 @@
-config blocking-udp {
-    type = "UDP"
-    timeout = 2
-    retries = 2
-    server {
-        hostname = "127.0.0.1"
-	service = "1820"
-	secret = "sikrit"
-    }
-}
diff --git a/lib/examples/client.conf b/lib/examples/client.conf
new file mode 100644
index 0000000..c9500e8
--- /dev/null
+++ b/lib/examples/client.conf
@@ -0,0 +1,27 @@
+dictionary = "/usr/share/freeradius/dictionary"
+
+realm blocking-udp {
+    type = "UDP"
+    timeout = 2
+    retries = 2
+    server {
+        hostname = "127.0.0.1"
+	service = "1820"
+	secret = "sikrit"
+    }
+}
+
+realm blocking-tls {
+    type = "TLS"
+    timeout = 1
+    retries = 3
+    cacertfile = "/home/linus/nordberg-ca.crt"
+    #cacertfile = "/home/linus/p/moonshot/demoCA/cacert.pem"
+    certfile = "/home/linus/p/moonshot/radsecproxy-test.crt"
+    certkeyfile = "/home/linus/p/moonshot/radsecproxy-test.key"
+    server {
+        hostname = "localhost"
+	service = "2083"
+	secret = "sikrit"
+    }
+}
-- 
cgit v1.1