Added a message method to set the "higher version supported" flag
authorMartin Willi <martin@revosec.ch>
Wed, 24 Nov 2010 16:45:12 +0000 (17:45 +0100)
committerMartin Willi <martin@revosec.ch>
Wed, 5 Jan 2011 15:45:52 +0000 (16:45 +0100)
src/libcharon/encoding/message.c
src/libcharon/encoding/message.h
src/libcharon/encoding/payloads/ike_header.c
src/libcharon/encoding/payloads/ike_header.h

index 9d66df5..c9959ab 100644 (file)
@@ -491,6 +491,11 @@ struct private_message_t {
        bool is_request;
 
        /**
+        * Higher version supported?
+        */
+       bool version_flag;
+
+       /**
         * Reserved bits in IKE header
         */
        bool reserved[5];
@@ -658,6 +663,12 @@ METHOD(message_t, get_request, bool,
        return this->is_request;
 }
 
+METHOD(message_t, set_version_flag, void,
+       private_message_t *this)
+{
+       this->version_flag = TRUE;
+}
+
 METHOD(message_t, get_reserved_header_bit, bool,
        private_message_t *this, u_int nr)
 {
@@ -1105,6 +1116,7 @@ METHOD(message_t, generate, status_t,
        ike_header->set_exchange_type(ike_header, this->exchange_type);
        ike_header->set_message_id(ike_header, this->message_id);
        ike_header->set_response_flag(ike_header, !this->is_request);
+       ike_header->set_version_flag(ike_header, this->version_flag);
        ike_header->set_initiator_flag(ike_header,
                                                this->ike_sa_id->is_initiator(this->ike_sa_id));
        ike_header->set_initiator_spi(ike_header,
@@ -1497,6 +1509,7 @@ message_t *message_create_from_packet(packet_t *packet)
                        .get_first_payload_type = _get_first_payload_type,
                        .set_request = _set_request,
                        .get_request = _get_request,
+                       .set_version_flag = _set_version_flag,
                        .get_reserved_header_bit = _get_reserved_header_bit,
                        .set_reserved_header_bit = _set_reserved_header_bit,
                        .add_payload = _add_payload,
index 0cc00ac..a04048e 100644 (file)
@@ -154,6 +154,11 @@ struct message_t {
        bool (*get_request) (message_t *this);
 
        /**
+        * Set the version flag in the IKE header.
+        */
+       void (*set_version_flag)(message_t *this);
+
+       /**
         * Get a reserved bit in the IKE header.
         *
         * @param nr                    reserved bit to get in IKE header, 0-4
index d061bd2..e035b2b 100644 (file)
@@ -292,6 +292,12 @@ METHOD(ike_header_t, get_version_flag, bool,
        return this->flags.version;
 }
 
+METHOD(ike_header_t, set_version_flag, void,
+       private_ike_header_t *this, bool version)
+{
+       this->flags.version = version;
+}
+
 METHOD(ike_header_t, get_initiator_flag, bool,
        private_ike_header_t *this)
 {
@@ -363,6 +369,7 @@ ike_header_t *ike_header_create()
                        .get_response_flag = _get_response_flag,
                        .set_response_flag = _set_response_flag,
                        .get_version_flag = _get_version_flag,
+                       .set_version_flag = _set_version_flag,
                        .get_initiator_flag = _get_initiator_flag,
                        .set_initiator_flag = _set_initiator_flag,
                        .get_exchange_type = _get_exchange_type,
index 7bb33a5..f52c852 100644 (file)
@@ -176,6 +176,7 @@ struct ike_header_t {
         * @param response              response flag
         */
        void (*set_response_flag) (ike_header_t *this, bool response);
+
        /**
         * Get "higher version supported"-flag.
         *
@@ -184,6 +185,13 @@ struct ike_header_t {
        bool (*get_version_flag) (ike_header_t *this);
 
        /**
+        * Set the "higher version supported"-flag.
+        *
+        * @param version               flag value
+        */
+       void (*set_version_flag)(ike_header_t *this, bool version);
+
+       /**
         * Get the initiator flag.
         *
         * @return                              initiator flag