diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/examples/client-blocking.c | 10 | ||||
-rw-r--r-- | lib/include/radsec/request-impl.h | 4 | ||||
-rw-r--r-- | lib/include/radsec/request.h | 4 | ||||
-rw-r--r-- | lib/request.c | 22 |
4 files changed, 22 insertions, 18 deletions
diff --git a/lib/examples/client-blocking.c b/lib/examples/client-blocking.c index def0068..a7fc03d 100644 --- a/lib/examples/client-blocking.c +++ b/lib/examples/client-blocking.c @@ -46,21 +46,21 @@ blocking_client (const char *av1, const char *av2, int use_request_object_flag) return rs_err_conn_pop (conn); #endif /* USE_CONFIG_FILE */ - if (rs_packet_create_auth_request (conn, &req, USER_NAME, USER_PW)) - return rs_err_conn_pop (conn); - if (use_request_object_flag) { struct rs_request *request; - if (rs_request_create (conn, &request)) + if (rs_request_create (conn, &request, USER_NAME, USER_PW)) return rs_err_conn_pop (conn); - if (rs_request_send (request, req, &resp)) + if (rs_request_send (request, &resp)) return rs_err_conn_pop (conn); rs_request_destroy (request); } else { + if (rs_packet_create_auth_request (conn, &req, USER_NAME, USER_PW)) + return rs_err_conn_pop (conn); + if (rs_packet_send (req, NULL)) { rs_packet_destroy (req); diff --git a/lib/include/radsec/request-impl.h b/lib/include/radsec/request-impl.h index 02b7713..4f50d44 100644 --- a/lib/include/radsec/request-impl.h +++ b/lib/include/radsec/request-impl.h @@ -8,8 +8,8 @@ struct rs_request { struct rs_connection *conn; struct event *timer; - struct rs_packet *req; - struct rs_packet *resp; + struct rs_packet *req_msg; + struct rs_packet *resp_msg; struct rs_conn_callbacks saved_cb; }; diff --git a/lib/include/radsec/request.h b/lib/include/radsec/request.h index 80c2880..33957a3 100644 --- a/lib/include/radsec/request.h +++ b/lib/include/radsec/request.h @@ -6,8 +6,8 @@ struct rs_request; extern "C" { #endif -int rs_request_create(struct rs_connection *conn, struct rs_request **req_out); -int rs_request_send(struct rs_request *request, struct rs_packet *req_msg, struct rs_packet **resp_msg); +int rs_request_create(struct rs_connection *conn, struct rs_request **req_out, const char *user_name, const char *user_pw); +int rs_request_send(struct rs_request *request, struct rs_packet **resp_msg); void rs_request_destroy(struct rs_request *request); #if defined (__cplusplus) 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; |