diff options
author | Linus Nordberg <linus@nordu.net> | 2011-03-07 15:25:33 +0100 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2011-03-07 15:25:33 +0100 |
commit | a379adb7d6cf86ebf2c60451fab1df588060de23 (patch) | |
tree | 56f00b7409d5f6157aa809ffd4756d48aebed1da /lib | |
parent | cbcaa6a7c8f8a6704f6b4a68f260020957214a07 (diff) |
Requests are now high level, i.e. not for user doing the dispatching.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/request.c | 67 |
1 files changed, 7 insertions, 60 deletions
diff --git a/lib/request.c b/lib/request.c index 80a0a81..8cb8b7e 100644 --- a/lib/request.c +++ b/lib/request.c @@ -12,6 +12,7 @@ #include <radsec/radsec-impl.h> #include <radsec/request.h> #include <radsec/request-impl.h> +#include "conn.h" int rs_request_create (struct rs_connection *conn, struct rs_request **req_out) @@ -68,75 +69,21 @@ _timer_cb (evutil_socket_t fd, short what, void *arg) } #endif -static void -_rs_req_connected (void *user_data) -{ - struct rs_request *request = (struct rs_request *) user_data; - assert (request); - assert (request->conn); - if (request->saved_cb.connected_cb) - request->saved_cb.connected_cb (request->saved_user_data); -} - -static void -_rs_req_disconnected (void *user_data) -{ - struct rs_request *request = (struct rs_request *) user_data; - assert (request); - assert (request->conn); - if (request->saved_cb.disconnected_cb) - request->saved_cb.disconnected_cb (request->saved_user_data); -} - -static void -_rs_req_packet_received (struct rs_packet *msg, void *user_data) -{ - struct rs_request *request = (struct rs_request *) user_data; - assert (request); - assert (request->conn); - if (request->saved_cb.received_cb) - request->saved_cb.received_cb (msg, request->saved_user_data); -} - -static void -_rs_req_packet_sent (void *user_data) -{ - struct rs_request *request = (struct rs_request *) user_data; - assert (request); - assert (request->conn); - if (request->saved_cb.sent_cb) - request->saved_cb.sent_cb (request->saved_user_data); -} - int rs_request_send (struct rs_request *request, struct rs_packet **resp_msg) { - int err = 0; struct rs_connection *conn = NULL; if (!request || !request->conn || !request->req_msg || !resp_msg) return rs_err_conn_push_fl (conn, RSE_INVAL, __FILE__, __LINE__, NULL); conn = request->conn; + assert (!conn_user_dispatch_p (conn)); /* This function is high level. */ - request->saved_user_data = conn->user_data; - conn->user_data = request; - - request->saved_cb = conn->callbacks; - conn->callbacks.connected_cb = _rs_req_connected; - conn->callbacks.disconnected_cb = _rs_req_disconnected; - conn->callbacks.received_cb = _rs_req_packet_received; - conn->callbacks.sent_cb = _rs_req_packet_sent; - - err = rs_packet_send (request->req_msg, request); - if (err) - goto cleanup; + if (rs_packet_send (request->req_msg, request)) + return -1; - err = rs_conn_receive_packet (request->conn, request->req_msg, resp_msg); - if (err) - goto cleanup; + if (rs_conn_receive_packet (request->conn, request->req_msg, resp_msg)) + return -1; -cleanup: - conn->user_data = request->saved_user_data; - conn->callbacks = request->saved_cb; - return err; + return RSE_OK; } |