X-Git-Url: https://git.strongswan.org/?p=strongswan.git;a=blobdiff_plain;f=src%2Fcharon%2Fencoding%2Fgenerator.c;h=efa845bb38c6446104a50e34dc4c2d4d4499b2b5;hp=847fda49ff91f62fd538d86c4748c9cc7fb45951;hb=b17e0db3726f4389ac3185f48e91ca6641f3ae18;hpb=db7ef62494fb6859df150e2b06b3ca91881d95af;ds=sidebyside diff --git a/src/charon/encoding/generator.c b/src/charon/encoding/generator.c index 847fda4..efa845b 100644 --- a/src/charon/encoding/generator.c +++ b/src/charon/encoding/generator.c @@ -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)); @@ -735,7 +738,7 @@ static void generate_payload (private_generator_t *this,payload_t *payload) case SPIS: case CONFIGURATION_ATTRIBUTE_VALUE: case VID_DATA: - case EAP_MESSAGE: + case EAP_DATA: { u_int32_t payload_length_position_offset; u_int16_t length_of_payload; @@ -774,7 +777,7 @@ static void generate_payload (private_generator_t *this,payload_t *payload) case CONFIGURATION_ATTRIBUTE_VALUE: header_length = CONFIGURATION_ATTRIBUTE_HEADER_LENGTH; break; - case EAP_MESSAGE: + case EAP_DATA: header_length = EAP_PAYLOAD_HEADER_LENGTH; break; default: