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)
*/
emm_sap.primitive = EMMREG_COMMON_PROC_CNF;
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;
} else {
LOG_TRACE(ERROR, "EMM-PROC - No EPS security context exists");
......@@ -521,6 +522,7 @@ int emm_proc_security_mode_complete(unsigned int ueid)
*/
emm_sap.primitive = EMMREG_COMMON_PROC_REJ;
emm_sap.u.emm_reg.ueid = ueid;
emm_sap.u.emm_reg.ctx = emm_ctx;
}
rc = emm_sap_send(&emm_sap);
......
......@@ -60,17 +60,17 @@ 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)
{
LOG_FUNC_IN;
int header_result;
int decode_result;
LOG_FUNC_IN;
/* First decode the ESM message header */
header_result = _esm_msg_decode_header(&msg->header, buffer, len);
if (header_result < 0) {
LOG_TRACE(ERROR, "ESM-MSG - Failed to decode ESM message header "
"(%d)", header_result);
LOG_FUNC_RETURN(header_result);
LOG_TRACE(ERROR, "ESM-MSG - Failed to decode ESM message header "
"(%d)", header_result);
LOG_FUNC_RETURN(header_result);
}
buffer += header_result;
......@@ -146,14 +146,15 @@ int esm_msg_decode(ESM_msg *msg, uint8_t *buffer, uint32_t len)
break;
default:
LOG_TRACE(ERROR, "ESM-MSG - Unexpected message type: 0x%x",
msg->header.message_type);
decode_result = TLV_DECODE_WRONG_MESSAGE_TYPE;
msg->header.message_type);
decode_result = TLV_DECODE_WRONG_MESSAGE_TYPE;
break;
}
if (decode_result < 0) {
LOG_TRACE(ERROR, "ESM-MSG - Failed to decode L3 ESM message 0x%x "
"(%d)", msg->header.message_type, decode_result);
LOG_FUNC_RETURN (decode_result);
LOG_TRACE(ERROR, "ESM-MSG - Failed to decode L3 ESM message 0x%x "
"(%u)", msg->header.message_type, decode_result);
LOG_FUNC_RETURN (decode_result);
}
LOG_FUNC_RETURN (header_result + decode_result);
}
......@@ -305,7 +306,7 @@ static int _esm_msg_decode_header(esm_msg_header_t *header,
/* Check the buffer length */
if (len < sizeof(esm_msg_header_t)) {
return (TLV_DECODE_BUFFER_TOO_SHORT);
return (TLV_DECODE_BUFFER_TOO_SHORT);
}
/* Decode the EPS bearer identity and the protocol discriminator */
......@@ -318,9 +319,9 @@ static int _esm_msg_decode_header(esm_msg_header_t *header,
/* Check the protocol discriminator */
if (header->protocol_discriminator != EPS_SESSION_MANAGEMENT_MESSAGE)
{
LOG_TRACE(ERROR, "ESM-MSG - Unexpected protocol discriminator: 0x%x",
header->protocol_discriminator);
return (TLV_DECODE_PROTOCOL_NOT_SUPPORTED);
LOG_TRACE(ERROR, "ESM-MSG - Unexpected protocol discriminator: 0x%x",
header->protocol_discriminator);
return (TLV_DECODE_PROTOCOL_NOT_SUPPORTED);
}
return (size);
......
......@@ -401,17 +401,19 @@ static int _esm_sap_recv(int msg_type, int is_standalone,
const OctetString *req, OctetString *rsp,
esm_sap_error_t *err)
{
LOG_FUNC_IN;
esm_proc_procedure_t esm_procedure = NULL;
int esm_cause = ESM_CAUSE_SUCCESS;
int rc = RETURNerror;
int decoder_rc;
ESM_msg esm_msg;
LOG_FUNC_IN;
memset(&esm_msg, 0 , sizeof(ESM_msg));
/* 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 */
if (decoder_rc < 0) {
......
......@@ -2,14 +2,13 @@
#include <stdlib.h>
#include <stdint.h>
#include "TLVEncoder.h"
#include "TLVDecoder.h"
#include "ProtocolConfigurationOptions.h"
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;
int decode_result;
if (iei > 0)
......@@ -20,20 +19,31 @@ int decode_protocol_configuration_options(ProtocolConfigurationOptions *protocol
ielen = *(buffer + decoded);
decoded++;
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;
return TLV_DECODE_VALUE_DOESNT_MATCH;
}
protocolconfigurationoptions->configurationprotol = (*(buffer + decoded) >> 1) & 0x7;
//IES_DECODE_U16(protocolconfigurationoptions->protocolid, *(buffer + decoded));
IES_DECODE_U16(buffer, decoded, protocolconfigurationoptions->protocolid);
protocolconfigurationoptions->lengthofprotocolid = *(buffer + decoded);
decoded++;
if ((decode_result = decode_octet_string(&protocolconfigurationoptions->protocolidcontents, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
//IES_DECODE_U16(protocolconfigurationoptions->protocolid, *(buffer + decoded));
while ((len - decoded) > 0) {
IES_DECODE_U16(buffer, decoded, protocolconfigurationoptions->protocolid);
DECODE_U8(buffer + decoded, protocolconfigurationoptions->lengthofprotocolid, decoded);
if ((decode_result = decode_octet_string(&protocolconfigurationoptions->protocolidcontents,
protocolconfigurationoptions->lengthofprotocolid, buffer + decoded, len - decoded)) < 0)
{
return decode_result;
} else {
decoded += decode_result;
}
}
#if defined (NAS_DEBUG)
dump_protocol_configuration_options_xml(protocolconfigurationoptions, iei);
#endif
......
......@@ -10,6 +10,25 @@
#define PROTOCOL_CONFIGURATION_OPTIONS_MINIMUM_LENGTH 3
#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 {
uint8_t configurationprotol:3;
uint16_t protocolid;
......
......@@ -8,28 +8,28 @@
int encode_octet_string(OctetString *octetstring, uint8_t *buffer, uint32_t buflen)
{
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, octetstring->length, buflen);
memcpy((void*)buffer, (void*)octetstring->value, octetstring->length);
return octetstring->length;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, octetstring->length, buflen);
memcpy((void*)buffer, (void*)octetstring->value, octetstring->length);
return octetstring->length;
}
int decode_octet_string(OctetString *octetstring, uint16_t pdulen, uint8_t *buffer, uint32_t buflen)
{
if (buflen < pdulen)
return -1;
octetstring->length = pdulen;
octetstring->value = malloc(sizeof(uint8_t) * (pdulen+1));
memcpy((void*)octetstring->value, (void*)buffer, pdulen);
octetstring->value[pdulen] = '\0';
return octetstring->length;
if (buflen < pdulen)
return -1;
octetstring->length = pdulen;
octetstring->value = malloc(sizeof(uint8_t) * (pdulen+1));
memcpy((void*)octetstring->value, (void*)buffer, pdulen);
octetstring->value[pdulen] = '\0';
return octetstring->length;
}
void dump_octet_string_xml(OctetString *octetstring)
{
int i;
printf(" <Length>%u</Length>\n <values>", octetstring->length);
for (i = 0; i < octetstring->length; i++)
printf("0x%x ", octetstring->value[i]);
printf("</values>\n");
int i;
printf(" <Length>%u</Length>\n <values>", octetstring->length);
for (i = 0; i < octetstring->length; i++)
printf("0x%x ", octetstring->value[i]);
printf("</values>\n");
}
......@@ -47,16 +47,17 @@
DECODE_U32(bUFFER + dECODED, vALUE, dECODED)
typedef enum {
TLV_DECODE_ERROR_OK = 0,
TLV_DECODE_UNEXPECTED_IEI = -1,
TLV_DECODE_MANDATORY_FIELD_NOT_PRESENT = -2,
TLV_DECODE_VALUE_DOESNT_MATCH = -3,
/* Fatal errors - received message should not be processed */
TLV_DECODE_WRONG_MESSAGE_TYPE = -10,
TLV_DECODE_PROTOCOL_NOT_SUPPORTED = -11,
TLV_DECODE_BUFFER_TOO_SHORT = -12,
TLV_DECODE_BUFFER_NULL = -13,
TLV_DECODE_MAC_MISMATCH = -14,
TLV_DECODE_ERROR_OK = 0,
TLV_DECODE_UNEXPECTED_IEI = -1,
TLV_DECODE_MANDATORY_FIELD_NOT_PRESENT = -2,
TLV_DECODE_VALUE_DOESNT_MATCH = -3,
/* Fatal errors - received message should not be processed */
TLV_DECODE_WRONG_MESSAGE_TYPE = -10,
TLV_DECODE_PROTOCOL_NOT_SUPPORTED = -11,
TLV_DECODE_BUFFER_TOO_SHORT = -12,
TLV_DECODE_BUFFER_NULL = -13,
TLV_DECODE_MAC_MISMATCH = -14,
} tlv_decoder_error_code;
/* Defines error code limit below which received message should be discarded
......
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