RADIUS message constructor accepts a message code parameter
authorMartin Willi <martin@revosec.ch>
Mon, 30 Jan 2012 18:11:08 +0000 (19:11 +0100)
committerMartin Willi <martin@revosec.ch>
Mon, 30 Jan 2012 18:11:08 +0000 (19:11 +0100)
src/libcharon/plugins/eap_radius/eap_radius.c
src/libcharon/plugins/eap_radius/radius_message.c
src/libcharon/plugins/eap_radius/radius_message.h

index dfe0e2e..ebb745a 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();
+       request = radius_message_create_request(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);
@@ -289,11 +289,11 @@ METHOD(eap_method_t, process, status_t,
        status_t status = FAILED;
        chunk_t data;
 
-       request = radius_message_create_request();
+       request = radius_message_create_request(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);
+
        /* fragment data suitable for RADIUS (not more than 253 bytes) */
        while (data.len > 253)
        {
index 23a29b7..35f3741 100644 (file)
@@ -423,12 +423,12 @@ static private_radius_message_t *radius_message_create()
 /**
  * See header
  */
-radius_message_t *radius_message_create_request()
+radius_message_t *radius_message_create_request(radius_message_code_t code)
 {
        private_radius_message_t *this = radius_message_create();
 
        INIT(this->msg,
-               .code = RMC_ACCESS_REQUEST,
+               .code = code,
                .identifier = 0,
                .length = htons(sizeof(rmsg_t)),
        );
index 266839d..18a2bce 100644 (file)
@@ -259,11 +259,12 @@ struct radius_message_t {
 };
 
 /**
- * Create an empty RADIUS request message (RMT_ACCESS_REQUEST).
+ * Create an empty RADIUS request message.
  *
+ * @code                               request type
  * @return                             radius_message_t object
  */
-radius_message_t *radius_message_create_request();
+radius_message_t *radius_message_create_request(radius_message_code_t code);
 
 /**
  * Parse and verify a recevied RADIUS response.