summaryrefslogtreecommitdiff
path: root/lib/request.c
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2011-02-25 13:05:46 +0100
committerLinus Nordberg <linus@nordberg.se>2011-02-25 13:05:46 +0100
commitce87482616de6f5078bd9b6c685f9ec62c220b3d (patch)
treeba1d628a55b99fe60ef6270cecaea9dab961f1e1 /lib/request.c
parent53d44d49597a515ae6c22ec20138a21986f6c3ab (diff)
API change. Have the request object create its own request message.
Diffstat (limited to 'lib/request.c')
-rw-r--r--lib/request.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/request.c b/lib/request.c
index 63645f0..5d2ae43 100644
--- a/lib/request.c
+++ b/lib/request.c
@@ -13,13 +13,18 @@
#include <radsec/request-impl.h>
int
-rs_request_create (struct rs_connection *conn, struct rs_request **req_out)
+rs_request_create (struct rs_connection *conn, struct rs_request **req_out,
+ const char *user_name, const char *user_pw)
{
struct rs_request *req = rs_malloc (conn->ctx, sizeof(*req));
if (!req)
return rs_err_conn_push_fl (conn, RSE_NOMEM, __FILE__, __LINE__, NULL);
memset (req, 0, sizeof(*req));
req->conn = conn;
+
+ if (rs_packet_create_auth_request (conn, &req->req_msg, user_name, user_pw))
+ return -1;
+
*req_out = req;
return RSE_OK;
}
@@ -27,8 +32,8 @@ rs_request_create (struct rs_connection *conn, struct rs_request **req_out)
void
rs_request_destroy (struct rs_request *request)
{
- rs_packet_destroy (request->req);
- rs_packet_destroy (request->resp);
+ rs_packet_destroy (request->req_msg);
+ rs_packet_destroy (request->resp_msg);
rs_free (request->conn->ctx, request);
}
@@ -53,7 +58,7 @@ _rs_req_disconnected(void *user_data)
}
static void
-_rs_req_packet_received(struct rs_packet *pkt, void *user_data)
+_rs_req_packet_received(struct rs_packet *msg, void *user_data)
{
//struct rs_request *request = (struct rs_request *)user_data;
}
@@ -65,17 +70,16 @@ _rs_req_packet_sent(void *user_data)
}
int
-rs_request_send(struct rs_request *request, struct rs_packet *req,
- struct rs_packet **resp)
+rs_request_send (struct rs_request *request, struct rs_packet **resp_msg)
{
int err;
struct rs_connection *conn;
assert (request);
assert (request->conn);
+ assert (request->req_msg);
conn = request->conn;
- request->req = req; /* take ownership */
request->saved_cb = conn->callbacks;
conn->callbacks.connected_cb = _rs_req_connected;
@@ -83,11 +87,11 @@ rs_request_send(struct rs_request *request, struct rs_packet *req,
conn->callbacks.received_cb = _rs_req_packet_received;
conn->callbacks.sent_cb = _rs_req_packet_sent;
- err = rs_packet_send(request->req, request);
+ err = rs_packet_send(request->req_msg, request);
if (err)
goto cleanup;
- err = rs_conn_receive_packet(request->conn, request->req, resp);
+ err = rs_conn_receive_packet(request->conn, request->req_msg, resp_msg);
if (err)
goto cleanup;