fixed some byte-order issues
authorMartin Willi <martin@strongswan.org>
Tue, 12 Dec 2006 08:41:04 +0000 (08:41 -0000)
committerMartin Willi <martin@strongswan.org>
Tue, 12 Dec 2006 08:41:04 +0000 (08:41 -0000)
src/charon/encoding/generator.c
src/charon/encoding/payloads/ke_payload.c

index 847fda4..07db45f 100644 (file)
@@ -381,11 +381,14 @@ static void generate_u_int_type (private_generator_t *this,encoding_type_t int_t
                        /* get value of attribute format flag */
                        u_int8_t attribute_format_flag = *(this->out_position) & 0x80;
                        /* get attribute type value as 16 bit integer*/
-                       u_int16_t int16_val = htons(*((u_int16_t*)(this->data_struct + offset)));
-                       /* last bit must be unset */
-                       int16_val = int16_val & 0xFF7F;
-                       
-                       int16_val = int16_val | attribute_format_flag;
+                       u_int16_t int16_val = *((u_int16_t*)(this->data_struct + offset));
+                       /* unset most significant bit */
+                       int16_val &= 0x7FFF;
+                       if (attribute_format_flag)
+                       {
+                               int16_val |= 0x8000;
+                       }
+                       int16_val = htons(int16_val);
                        DBG3(DBG_ENC, "   => %d", int16_val);
                        /* write bytes to buffer (set bit is overwritten)*/                             
                        this->write_bytes_to_buffer(this,&int16_val,sizeof(u_int16_t));
index 5a83fd0..8926b15 100644 (file)
@@ -58,7 +58,7 @@ struct private_ke_payload_t {
        /**
         * DH Group Number.
         */
-       diffie_hellman_group_t dh_group_number;
+       u_int16_t dh_group_number;
        
        /**
         * Key Exchange Data of this KE payload.