Rename RADIUS message constructors to handle both, requests and responses
authorMartin Willi <martin@revosec.ch>
Wed, 22 Feb 2012 11:39:50 +0000 (12:39 +0100)
committerMartin Willi <martin@revosec.ch>
Mon, 5 Mar 2012 17:06:13 +0000 (18:06 +0100)
src/libcharon/plugins/eap_radius/eap_radius.c
src/libcharon/plugins/eap_radius/eap_radius_accounting.c
src/libcharon/plugins/eap_radius/eap_radius_dae.c
src/libcharon/plugins/eap_radius/radius_message.c
src/libcharon/plugins/eap_radius/radius_message.h
src/libcharon/plugins/eap_radius/radius_socket.c

index 72e707e..3d8c823 100644 (file)
@@ -162,7 +162,7 @@ METHOD(eap_method_t, initiate, status_t,
        status_t status = FAILED;
        chunk_t username;
 
-       request = radius_message_create_request(RMC_ACCESS_REQUEST);
+       request = radius_message_create(RMC_ACCESS_REQUEST);
        username = chunk_create(this->id_prefix, strlen(this->id_prefix));
        username = chunk_cata("cc", username, this->peer->get_encoding(this->peer));
        request->add(request, RAT_USER_NAME, username);
@@ -314,7 +314,7 @@ METHOD(eap_method_t, process, status_t,
        status_t status = FAILED;
        chunk_t data;
 
-       request = radius_message_create_request(RMC_ACCESS_REQUEST);
+       request = radius_message_create(RMC_ACCESS_REQUEST);
        request->add(request, RAT_USER_NAME, this->peer->get_encoding(this->peer));
        data = in->get_data(in);
        DBG3(DBG_IKE, "%N payload %B", eap_type_names, this->type, &data);
index 613569f..cd81cfc 100644 (file)
@@ -181,7 +181,7 @@ static void send_start(private_eap_radius_accounting_t *this, ike_sa_t *ike_sa)
        );
        snprintf(entry->sid, sizeof(entry->sid), "%u-%u", this->prefix, id);
 
-       message = radius_message_create_request(RMC_ACCOUNTING_REQUEST);
+       message = radius_message_create(RMC_ACCOUNTING_REQUEST);
        value = htonl(ACCT_STATUS_START);
        message->add(message, RAT_ACCT_STATUS_TYPE, chunk_from_thing(value));
        message->add(message, RAT_ACCT_SESSION_ID,
@@ -212,7 +212,7 @@ static void send_stop(private_eap_radius_accounting_t *this, ike_sa_t *ike_sa)
        this->mutex->unlock(this->mutex);
        if (entry)
        {
-               message = radius_message_create_request(RMC_ACCOUNTING_REQUEST);
+               message = radius_message_create(RMC_ACCOUNTING_REQUEST);
                value = htonl(ACCT_STATUS_STOP);
                message->add(message, RAT_ACCT_STATUS_TYPE, chunk_from_thing(value));
                message->add(message, RAT_ACCT_SESSION_ID,
index c6f5d84..ce8a36d 100644 (file)
@@ -76,7 +76,7 @@ static job_requeue_t receive(private_eap_radius_dae_t *this)
 
        if (len > 0)
        {
-               request = radius_message_parse_response(chunk_create(buf, len));
+               request = radius_message_parse(chunk_create(buf, len));
                if (request)
                {
                        switch (request->get_code(request))
index 3df7e63..7fa95e3 100644 (file)
@@ -418,7 +418,7 @@ METHOD(radius_message_t, destroy, void,
 /**
  * Generic constructor
  */
-static private_radius_message_t *radius_message_create()
+static private_radius_message_t *radius_message_create_empty()
 {
        private_radius_message_t *this;
 
@@ -443,9 +443,9 @@ static private_radius_message_t *radius_message_create()
 /**
  * See header
  */
-radius_message_t *radius_message_create_request(radius_message_code_t code)
+radius_message_t *radius_message_create(radius_message_code_t code)
 {
-       private_radius_message_t *this = radius_message_create();
+       private_radius_message_t *this = radius_message_create_empty();
 
        INIT(this->msg,
                .code = code,
@@ -459,9 +459,9 @@ radius_message_t *radius_message_create_request(radius_message_code_t code)
 /**
  * See header
  */
-radius_message_t *radius_message_parse_response(chunk_t data)
+radius_message_t *radius_message_parse(chunk_t data)
 {
-       private_radius_message_t *this = radius_message_create();
+       private_radius_message_t *this = radius_message_create_empty();
 
        this->msg = malloc(data.len);
        memcpy(this->msg, data.ptr, data.len);
index fbbfdc9..eede401 100644 (file)
@@ -268,19 +268,19 @@ struct radius_message_t {
 };
 
 /**
- * Create an empty RADIUS request message.
+ * Create an empty RADIUS message.
  *
  * @param code                 request type
  * @return                             radius_message_t object
  */
-radius_message_t *radius_message_create_request(radius_message_code_t code);
+radius_message_t *radius_message_create(radius_message_code_t code);
 
 /**
- * Parse and verify a recevied RADIUS response.
+ * Parse and verify a recevied RADIUS message.
  *
  * @param data                 received message data
  * @return                             radius_message_t object, NULL if length invalid
  */
-radius_message_t *radius_message_parse_response(chunk_t data);
+radius_message_t *radius_message_parse(chunk_t data);
 
 #endif /** RADIUS_MESSAGE_H_ @}*/
index 56b65fe..96eafb8 100644 (file)
@@ -205,7 +205,7 @@ METHOD(radius_socket_t, request, radius_message_t*,
                                         strerror(errno));
                                break;
                        }
-                       response = radius_message_parse_response(chunk_create(buf, res));
+                       response = radius_message_parse(chunk_create(buf, res));
                        if (response)
                        {
                                if (response->verify(response,