Compiler warning fixed.
[strongswan.git] / src / libcharon / encoding / payloads / ike_header.c
index 9c1bbbe..80dcee0 100644 (file)
@@ -84,6 +84,11 @@ struct private_ike_header_t {
        } flags;
 
        /**
+        * Reserved bits of IKE header
+        */
+       bool reserved[5];
+
+       /**
         * Associated Message-ID.
         */
        u_int32_t message_id;
@@ -127,22 +132,22 @@ encoding_rule_t ike_header_encodings[] = {
        /* 4 Bit minor version, stored in the field min_version */
        { U_INT_4,              offsetof(private_ike_header_t, min_version)             },
        /* 8 Bit for the exchange type */
-       { U_INT_8,              offsetof(private_ike_header_t, exchange_type)   },
-       /* 2 Bit reserved bits, nowhere stored */
-       { RESERVED_BIT, 0                                                                                               },
-       { RESERVED_BIT, 0                                                                                               },
+       { U_INT_8,              offsetof(private_ike_header_t, exchange_type)   },
+       /* 2 Bit reserved bits */
+       { RESERVED_BIT, offsetof(private_ike_header_t, reserved[0])             },
+       { RESERVED_BIT, offsetof(private_ike_header_t, reserved[1])             },
        /* 3 Bit flags, stored in the fields response, version and initiator */
        { FLAG,                 offsetof(private_ike_header_t, flags.response)  },
        { FLAG,                 offsetof(private_ike_header_t, flags.version)   },
        { FLAG,                 offsetof(private_ike_header_t, flags.initiator) },
-       /* 3 Bit reserved bits, nowhere stored */
-       { RESERVED_BIT, 0                                                                                               },
-       { RESERVED_BIT, 0                                                                                               },
-       { RESERVED_BIT, 0                                                                                               },
+       /* 3 Bit reserved bits */
+       { RESERVED_BIT, offsetof(private_ike_header_t, reserved[2])             },
+       { RESERVED_BIT, offsetof(private_ike_header_t, reserved[3])             },
+       { RESERVED_BIT, offsetof(private_ike_header_t, reserved[4])             },
        /* 4 Byte message id, stored in the field message_id */
-       { U_INT_32,             offsetof(private_ike_header_t, message_id)              },
+       { U_INT_32,             offsetof(private_ike_header_t, message_id)              },
        /* 4 Byte length fied, stored in the field length */
-       { HEADER_LENGTH,offsetof(private_ike_header_t, length)                  },
+       { HEADER_LENGTH,offsetof(private_ike_header_t, length)                  },
 };
 
 
@@ -287,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)
 {
@@ -358,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,
@@ -369,8 +381,10 @@ ike_header_t *ike_header_create()
                .maj_version = IKE_MAJOR_VERSION,
                .min_version = IKE_MINOR_VERSION,
                .exchange_type = EXCHANGE_TYPE_UNDEFINED,
-               .flags.initiator = TRUE,
-               .flags.version = HIGHER_VERSION_SUPPORTED_FLAG,
+               .flags = {
+                       .initiator = TRUE,
+                       .version = HIGHER_VERSION_SUPPORTED_FLAG,
+               },
                .length = IKE_HEADER_LENGTH,
        );