Commit 35c08d81 authored by Cedric Roux's avatar Cedric Roux

- Bug fix for PCO decoding procedure

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4763 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 65ede03d
...@@ -513,6 +513,7 @@ int emm_proc_security_mode_complete(unsigned int ueid) ...@@ -513,6 +513,7 @@ int emm_proc_security_mode_complete(unsigned int ueid)
*/ */
emm_sap.primitive = EMMREG_COMMON_PROC_CNF; emm_sap.primitive = EMMREG_COMMON_PROC_CNF;
emm_sap.u.emm_reg.ueid = ueid; emm_sap.u.emm_reg.ueid = ueid;
emm_sap.u.emm_reg.ctx = emm_ctx;
emm_sap.u.emm_reg.u.common.is_attached = emm_ctx->is_attached; emm_sap.u.emm_reg.u.common.is_attached = emm_ctx->is_attached;
} else { } else {
LOG_TRACE(ERROR, "EMM-PROC - No EPS security context exists"); LOG_TRACE(ERROR, "EMM-PROC - No EPS security context exists");
...@@ -521,6 +522,7 @@ int emm_proc_security_mode_complete(unsigned int ueid) ...@@ -521,6 +522,7 @@ int emm_proc_security_mode_complete(unsigned int ueid)
*/ */
emm_sap.primitive = EMMREG_COMMON_PROC_REJ; emm_sap.primitive = EMMREG_COMMON_PROC_REJ;
emm_sap.u.emm_reg.ueid = ueid; emm_sap.u.emm_reg.ueid = ueid;
emm_sap.u.emm_reg.ctx = emm_ctx;
} }
rc = emm_sap_send(&emm_sap); rc = emm_sap_send(&emm_sap);
......
...@@ -60,11 +60,11 @@ static int _esm_msg_encode_header(const esm_msg_header_t *header, uint8_t *buffe ...@@ -60,11 +60,11 @@ static int _esm_msg_encode_header(const esm_msg_header_t *header, uint8_t *buffe
***************************************************************************/ ***************************************************************************/
int esm_msg_decode(ESM_msg *msg, uint8_t *buffer, uint32_t len) int esm_msg_decode(ESM_msg *msg, uint8_t *buffer, uint32_t len)
{ {
LOG_FUNC_IN;
int header_result; int header_result;
int decode_result; int decode_result;
LOG_FUNC_IN;
/* First decode the ESM message header */ /* First decode the ESM message header */
header_result = _esm_msg_decode_header(&msg->header, buffer, len); header_result = _esm_msg_decode_header(&msg->header, buffer, len);
if (header_result < 0) { if (header_result < 0) {
...@@ -148,11 +148,12 @@ int esm_msg_decode(ESM_msg *msg, uint8_t *buffer, uint32_t len) ...@@ -148,11 +148,12 @@ int esm_msg_decode(ESM_msg *msg, uint8_t *buffer, uint32_t len)
LOG_TRACE(ERROR, "ESM-MSG - Unexpected message type: 0x%x", LOG_TRACE(ERROR, "ESM-MSG - Unexpected message type: 0x%x",
msg->header.message_type); msg->header.message_type);
decode_result = TLV_DECODE_WRONG_MESSAGE_TYPE; decode_result = TLV_DECODE_WRONG_MESSAGE_TYPE;
break;
} }
if (decode_result < 0) { if (decode_result < 0) {
LOG_TRACE(ERROR, "ESM-MSG - Failed to decode L3 ESM message 0x%x " LOG_TRACE(ERROR, "ESM-MSG - Failed to decode L3 ESM message 0x%x "
"(%d)", msg->header.message_type, decode_result); "(%u)", msg->header.message_type, decode_result);
LOG_FUNC_RETURN (decode_result); LOG_FUNC_RETURN (decode_result);
} }
LOG_FUNC_RETURN (header_result + decode_result); LOG_FUNC_RETURN (header_result + decode_result);
......
...@@ -401,17 +401,19 @@ static int _esm_sap_recv(int msg_type, int is_standalone, ...@@ -401,17 +401,19 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
const OctetString *req, OctetString *rsp, const OctetString *req, OctetString *rsp,
esm_sap_error_t *err) esm_sap_error_t *err)
{ {
LOG_FUNC_IN;
esm_proc_procedure_t esm_procedure = NULL; esm_proc_procedure_t esm_procedure = NULL;
int esm_cause = ESM_CAUSE_SUCCESS; int esm_cause = ESM_CAUSE_SUCCESS;
int rc = RETURNerror; int rc = RETURNerror;
int decoder_rc;
ESM_msg esm_msg; ESM_msg esm_msg;
LOG_FUNC_IN;
memset(&esm_msg, 0 , sizeof(ESM_msg)); memset(&esm_msg, 0 , sizeof(ESM_msg));
/* Decode the received ESM message */ /* Decode the received ESM message */
int decoder_rc = esm_msg_decode(&esm_msg, req->value, req->length); decoder_rc = esm_msg_decode(&esm_msg, req->value, req->length);
/* Process decoding errors */ /* Process decoding errors */
if (decoder_rc < 0) { if (decoder_rc < 0) {
......
...@@ -2,14 +2,13 @@ ...@@ -2,14 +2,13 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include "TLVEncoder.h" #include "TLVEncoder.h"
#include "TLVDecoder.h" #include "TLVDecoder.h"
#include "ProtocolConfigurationOptions.h" #include "ProtocolConfigurationOptions.h"
int decode_protocol_configuration_options(ProtocolConfigurationOptions *protocolconfigurationoptions, uint8_t iei, uint8_t *buffer, uint32_t len) int decode_protocol_configuration_options(ProtocolConfigurationOptions *protocolconfigurationoptions, uint8_t iei, uint8_t *buffer, uint32_t len)
{ {
int decoded = 0; uint32_t decoded = 0;
uint8_t ielen = 0; uint8_t ielen = 0;
int decode_result; int decode_result;
if (iei > 0) if (iei > 0)
...@@ -20,20 +19,31 @@ int decode_protocol_configuration_options(ProtocolConfigurationOptions *protocol ...@@ -20,20 +19,31 @@ int decode_protocol_configuration_options(ProtocolConfigurationOptions *protocol
ielen = *(buffer + decoded); ielen = *(buffer + decoded);
decoded++; decoded++;
CHECK_LENGTH_DECODER(len - decoded, ielen); CHECK_LENGTH_DECODER(len - decoded, ielen);
if (((*buffer >> 7) & 0x1) != 1) if (((*(buffer + decoded) >> 7) & 0x1) != 1)
{
errorCodeDecoder = TLV_DECODE_VALUE_DOESNT_MATCH;
return TLV_DECODE_VALUE_DOESNT_MATCH;
}
/* Bits 7 to 4 of octet 3 are spare, read as 0 */
if (((*(buffer + decoded) & 0x78) >> 3) != 0)
{ {
errorCodeDecoder = TLV_DECODE_VALUE_DOESNT_MATCH; errorCodeDecoder = TLV_DECODE_VALUE_DOESNT_MATCH;
return TLV_DECODE_VALUE_DOESNT_MATCH; return TLV_DECODE_VALUE_DOESNT_MATCH;
} }
protocolconfigurationoptions->configurationprotol = (*(buffer + decoded) >> 1) & 0x7; protocolconfigurationoptions->configurationprotol = (*(buffer + decoded) >> 1) & 0x7;
decoded++;
//IES_DECODE_U16(protocolconfigurationoptions->protocolid, *(buffer + decoded)); //IES_DECODE_U16(protocolconfigurationoptions->protocolid, *(buffer + decoded));
while ((len - decoded) > 0) {
IES_DECODE_U16(buffer, decoded, protocolconfigurationoptions->protocolid); IES_DECODE_U16(buffer, decoded, protocolconfigurationoptions->protocolid);
protocolconfigurationoptions->lengthofprotocolid = *(buffer + decoded); DECODE_U8(buffer + decoded, protocolconfigurationoptions->lengthofprotocolid, decoded);
decoded++; if ((decode_result = decode_octet_string(&protocolconfigurationoptions->protocolidcontents,
if ((decode_result = decode_octet_string(&protocolconfigurationoptions->protocolidcontents, ielen, buffer + decoded, len - decoded)) < 0) protocolconfigurationoptions->lengthofprotocolid, buffer + decoded, len - decoded)) < 0)
{
return decode_result; return decode_result;
else } else {
decoded += decode_result; decoded += decode_result;
}
}
#if defined (NAS_DEBUG) #if defined (NAS_DEBUG)
dump_protocol_configuration_options_xml(protocolconfigurationoptions, iei); dump_protocol_configuration_options_xml(protocolconfigurationoptions, iei);
#endif #endif
......
...@@ -10,6 +10,25 @@ ...@@ -10,6 +10,25 @@
#define PROTOCOL_CONFIGURATION_OPTIONS_MINIMUM_LENGTH 3 #define PROTOCOL_CONFIGURATION_OPTIONS_MINIMUM_LENGTH 3
#define PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH 253 #define PROTOCOL_CONFIGURATION_OPTIONS_MAXIMUM_LENGTH 253
/* 3GPP TS 24.008 Table 10.5.154
* MS to network table
*/
typedef enum ProtocolConfigurationOptionsList_ids_tag{
PCO_UNKNOWN = 0,
PCO_P_CSCF_IPV6_ADDRESS_REQ = 1,
PCO_IM_CN_SUBSYSTEM_SIGNALING_FLAG = 2,
PCO_DNS_SERVER_IPV6_ADDRESS_REQ = 3,
PCO_NOT_SUPPORTED = 4,
PCO_MS_SUPPORTED_OF_NETWORK_REQUESTED_BEARER_CONTROL_INDICATOR = 5,
PCO_RESERVED = 6,
/* TODO: complete me */
} ProtocolConfigurationOptionsList_ids;
/* 3GPP TS 24.008 Table 10.5.154
* network to MS table
* TODO
*/
typedef struct ProtocolConfigurationOptions_tag { typedef struct ProtocolConfigurationOptions_tag {
uint8_t configurationprotol:3; uint8_t configurationprotol:3;
uint16_t protocolid; uint16_t protocolid;
......
...@@ -51,6 +51,7 @@ typedef enum { ...@@ -51,6 +51,7 @@ typedef enum {
TLV_DECODE_UNEXPECTED_IEI = -1, TLV_DECODE_UNEXPECTED_IEI = -1,
TLV_DECODE_MANDATORY_FIELD_NOT_PRESENT = -2, TLV_DECODE_MANDATORY_FIELD_NOT_PRESENT = -2,
TLV_DECODE_VALUE_DOESNT_MATCH = -3, TLV_DECODE_VALUE_DOESNT_MATCH = -3,
/* Fatal errors - received message should not be processed */ /* Fatal errors - received message should not be processed */
TLV_DECODE_WRONG_MESSAGE_TYPE = -10, TLV_DECODE_WRONG_MESSAGE_TYPE = -10,
TLV_DECODE_PROTOCOL_NOT_SUPPORTED = -11, TLV_DECODE_PROTOCOL_NOT_SUPPORTED = -11,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment