summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordu.net>2011-02-28 11:46:14 +0100
committerLinus Nordberg <linus@nordu.net>2011-02-28 11:46:14 +0100
commit9e601f905d91f55c7a36f15fe5998d694c38444f (patch)
treed01ef4bbdafa4185517a4ca86cce2ac30213a7f4 /lib
parent2befa02ee876e83a8f8849388e61250e74d75eaf (diff)
API changes: rs_client* --> rs_peer.
Move peer (former server) things to new file peer.c. Update examples.
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am1
-rw-r--r--lib/examples/client-blocking.c10
-rw-r--r--lib/include/radsec/radsec.h14
-rw-r--r--lib/peer.c70
-rw-r--r--lib/radsec.c62
5 files changed, 83 insertions, 74 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index d43198b..311d3cc 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -15,6 +15,7 @@ libradsec_la_SOURCES = \
debug.c \
err.c \
packet.c \
+ peer.c \
radsec.c \
request.c
diff --git a/lib/examples/client-blocking.c b/lib/examples/client-blocking.c
index a7fc03d..80d6cce 100644
--- a/lib/examples/client-blocking.c
+++ b/lib/examples/client-blocking.c
@@ -30,13 +30,13 @@ blocking_client (const char *av1, const char *av2, int use_request_object_flag)
if (rs_conn_create (h, &conn, NULL))
return rs_err_conn_pop (conn);
rs_conn_set_type (conn, RS_CONN_TYPE_UDP);
- if (rs_server_create (conn, &server))
+ if (rs_peer_create (conn, &server))
return rs_err_conn_pop (conn);
- if (rs_server_set_address (server, av1, av2))
+ if (rs_peer_set_address (server, av1, av2))
return rs_err_conn_pop (conn);
- rs_server_set_timeout (server, 1);
- rs_server_set_tries (server, 3);
- if (rs_server_set_secret (server, SECRET))
+ rs_peer_set_timeout (server, 1);
+ rs_peer_set_retries (server, 3);
+ if (rs_peer_set_secret (server, SECRET))
return rs_err_conn_pop (conn);
}
#else
diff --git a/lib/include/radsec/radsec.h b/lib/include/radsec/radsec.h
index 5d08617..d398e8d 100644
--- a/lib/include/radsec/radsec.h
+++ b/lib/include/radsec/radsec.h
@@ -111,13 +111,13 @@ int rs_conn_receive_packet(struct rs_connection *conn,
struct rs_packet **pkt_out);
int rs_conn_fd(struct rs_connection *conn);
-/* Client and server. */
-int rs_server_create(struct rs_connection *conn, struct rs_peer **server);
-int rs_server_set_address(struct rs_peer *server, const char *hostname,
- const char *service);
-int rs_server_set_secret(struct rs_peer *server, const char *secret);
-void rs_server_set_timeout(struct rs_peer *server, int timeout);
-void rs_server_set_retries(struct rs_peer *server, int retries);
+/* Peers. */
+int rs_peer_create(struct rs_connection *conn, struct rs_peer **peer_out);
+int rs_peer_set_address(struct rs_peer *peer, const char *hostname,
+ const char *service);
+int rs_peer_set_secret(struct rs_peer *peer, const char *secret);
+void rs_peer_set_timeout(struct rs_peer *peer, int timeout);
+void rs_peer_set_retries(struct rs_peer *peer, int retries);
/* Packet. */
int rs_packet_create(struct rs_connection *conn, struct rs_packet **pkt_out);
diff --git a/lib/peer.c b/lib/peer.c
new file mode 100644
index 0000000..4fbb54f
--- /dev/null
+++ b/lib/peer.c
@@ -0,0 +1,70 @@
+/* See the file COPYING for licensing information. */
+#if defined HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <assert.h>
+#include <radsec/radsec.h>
+#include <radsec/radsec-impl.h>
+
+int
+rs_peer_create (struct rs_connection *conn, struct rs_peer **peer_out)
+{
+ struct rs_peer *peer;
+
+ peer = _rs_peer_create (conn->ctx, &conn->peers);
+ if (peer)
+ {
+ peer->conn = conn;
+ peer->realm->timeout = 2;
+ peer->realm->retries = 2;
+ }
+ else
+ return rs_err_conn_push_fl (conn, RSE_NOMEM, __FILE__, __LINE__, NULL);
+ if (*peer_out)
+ *peer_out = peer;
+ return RSE_OK;
+}
+
+int
+rs_peer_set_address (struct rs_peer *peer, const char *hostname,
+ const char *service)
+{
+ struct rs_error *err;
+
+ assert (peer);
+ assert (peer->realm);
+
+ err = _rs_resolv (&peer->addr, peer->realm->type, hostname, service);
+ if (err)
+ return _rs_err_conn_push_err (peer->conn, err);
+ return RSE_OK;
+}
+
+void
+rs_peer_set_timeout (struct rs_peer *peer, int timeout)
+{
+ assert (peer);
+ assert (peer->realm);
+ peer->realm->timeout = timeout;
+}
+void
+rs_peer_set_retries (struct rs_peer *peer, int retries)
+{
+ assert (peer);
+ assert (peer->realm);
+ peer->realm->retries = retries;
+}
+
+int
+rs_peer_set_secret (struct rs_peer *peer, const char *secret)
+{
+ if (peer->secret)
+ free (peer->secret);
+ peer->secret = (char *) malloc (strlen(secret) + 1);
+ if (!peer->secret)
+ return rs_err_conn_push (peer->conn, RSE_NOMEM, NULL);
+ strcpy (peer->secret, secret);
+ return RSE_OK;
+}
+
diff --git a/lib/radsec.c b/lib/radsec.c
index c821566..b9c9e35 100644
--- a/lib/radsec.c
+++ b/lib/radsec.c
@@ -149,65 +149,3 @@ int rs_context_set_alloc_scheme(struct rs_context *ctx,
return rs_err_ctx_push_fl (ctx, RSE_NOSYS, __FILE__, __LINE__,
"%s: NYI", __func__);
}
-
-int
-rs_server_create (struct rs_connection *conn, struct rs_peer **server)
-{
- struct rs_peer *srv;
-
- srv = _rs_peer_create (conn->ctx, &conn->peers);
- if (srv)
- {
- srv->conn = conn;
- srv->realm->timeout = 2;
- srv->realm->retries = 2;
- }
- else
- return rs_err_conn_push_fl (conn, RSE_NOMEM, __FILE__, __LINE__, NULL);
- if (*server)
- *server = srv;
- return RSE_OK;
-}
-
-int
-rs_server_set_address (struct rs_peer *server, const char *hostname,
- const char *service)
-{
- struct rs_error *err;
-
- assert (server);
- assert (server->realm);
-
- err = _rs_resolv (&server->addr, server->realm->type, hostname, service);
- if (err)
- return _rs_err_conn_push_err (server->conn, err);
- return RSE_OK;
-}
-
-void
-rs_server_set_timeout (struct rs_peer *server, int timeout)
-{
- assert (server);
- assert (server->realm);
- server->realm->timeout = timeout;
-}
-void
-rs_server_set_retries (struct rs_peer *server, int retries)
-{
- assert (server);
- assert (server->realm);
- server->realm->retries = retries;
-}
-
-int
-rs_server_set_secret (struct rs_peer *server, const char *secret)
-{
- if (server->secret)
- free (server->secret);
- server->secret = (char *) malloc (strlen(secret) + 1);
- if (!server->secret)
- return rs_err_conn_push (server->conn, RSE_NOMEM, NULL);
- strcpy (server->secret, secret);
- return RSE_OK;
-}
-