From 682a426b16c8cc225ce952bf4aa1c7cc210dde71 Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Mon, 28 Feb 2011 13:15:13 +0100 Subject: Rename relevant functions to reflect authn as opposed to authz. Also add a "bare" create request function. --- lib/examples/client-blocking.c | 4 ++-- lib/include/radsec/radsec.h | 8 ++++---- lib/include/radsec/request.h | 11 +++++++---- lib/packet.c | 6 +++--- lib/request.c | 25 ++++++++++++++++++++++--- 5 files changed, 38 insertions(+), 16 deletions(-) (limited to 'lib') diff --git a/lib/examples/client-blocking.c b/lib/examples/client-blocking.c index 80d6cce..27f87ca 100644 --- a/lib/examples/client-blocking.c +++ b/lib/examples/client-blocking.c @@ -50,7 +50,7 @@ blocking_client (const char *av1, const char *av2, int use_request_object_flag) { struct rs_request *request; - if (rs_request_create (conn, &request, USER_NAME, USER_PW)) + if (rs_request_create_authn (conn, &request, USER_NAME, USER_PW)) return rs_err_conn_pop (conn); if (rs_request_send (request, &resp)) return rs_err_conn_pop (conn); @@ -58,7 +58,7 @@ blocking_client (const char *av1, const char *av2, int use_request_object_flag) } else { - if (rs_packet_create_auth_request (conn, &req, USER_NAME, USER_PW)) + if (rs_packet_create_authn_request (conn, &req, USER_NAME, USER_PW)) return rs_err_conn_pop (conn); if (rs_packet_send (req, NULL)) diff --git a/lib/include/radsec/radsec.h b/lib/include/radsec/radsec.h index d398e8d..b89d47c 100644 --- a/lib/include/radsec/radsec.h +++ b/lib/include/radsec/radsec.h @@ -125,10 +125,10 @@ void rs_packet_destroy(struct rs_packet *pkt); void rs_packet_add_attr(struct rs_packet *pkt, struct rs_attr *attr); int rs_packet_send(struct rs_packet *pkt, void *data); struct radius_packet *rs_packet_frpkt(struct rs_packet *pkt); -int rs_packet_create_auth_request(struct rs_connection *conn, - struct rs_packet **pkt, - const char *user_name, - const char *user_pw); +int rs_packet_create_authn_request(struct rs_connection *conn, + struct rs_packet **pkt, + const char *user_name, + const char *user_pw); /* Attribute. */ /* FIXME: Replace (or complement) with a wrapper for paircreate(). */ diff --git a/lib/include/radsec/request.h b/lib/include/radsec/request.h index ca7b688..4a540bd 100644 --- a/lib/include/radsec/request.h +++ b/lib/include/radsec/request.h @@ -6,10 +6,13 @@ struct rs_request; extern "C" { #endif -int rs_request_create(struct rs_connection *conn, - struct rs_request **req_out, - const char *user_name, - const char *user_pw); +int rs_request_create(struct rs_connection *conn, struct rs_request **req_out); +void rs_request_add_reqpkt(struct rs_request *req, struct rs_packet *reqpkt); + +int rs_request_create_authn(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); diff --git a/lib/packet.c b/lib/packet.c index 90782f7..f13434b 100644 --- a/lib/packet.c +++ b/lib/packet.c @@ -601,9 +601,9 @@ rs_packet_create (struct rs_connection *conn, struct rs_packet **pkt_out) } int -rs_packet_create_auth_request (struct rs_connection *conn, - struct rs_packet **pkt_out, - const char *user_name, const char *user_pw) +rs_packet_create_authn_request (struct rs_connection *conn, + struct rs_packet **pkt_out, + const char *user_name, const char *user_pw) { struct rs_packet *pkt; struct rs_attr *attr; diff --git a/lib/request.c b/lib/request.c index 5d2ae43..cfd0ddb 100644 --- a/lib/request.c +++ b/lib/request.c @@ -13,16 +13,35 @@ #include int -rs_request_create (struct rs_connection *conn, struct rs_request **req_out, - const char *user_name, const char *user_pw) +rs_request_create (struct rs_connection *conn, struct rs_request **req_out) { 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; + *req_out = req; + return RSE_OK; +} + +void +rs_request_add_reqpkt (struct rs_request *req, struct rs_packet *reqpkt) +{ + req->req_msg = reqpkt; +} + +int +rs_request_create_authn (struct rs_connection *conn, + struct rs_request **req_out, + const char *user_name, + const char *user_pw) +{ + struct rs_request *req; + + if (rs_request_create (conn, &req)) + return -1; - if (rs_packet_create_auth_request (conn, &req->req_msg, user_name, user_pw)) + if (rs_packet_create_authn_request (conn, &req->req_msg, user_name, user_pw)) return -1; *req_out = req; -- cgit v1.1