|
|
|
@ -192,20 +192,22 @@ mmsMsg_parseDataElement(Data_t* dataElement)
|
|
|
|
|
if (componentCount > 0) {
|
|
|
|
|
value = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
|
|
|
|
|
|
|
|
|
|
value->type = MMS_ARRAY;
|
|
|
|
|
value->value.structure.size = componentCount;
|
|
|
|
|
value->value.structure.components = (MmsValue**) GLOBAL_CALLOC(componentCount, sizeof(MmsValue*));
|
|
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < componentCount; i++) {
|
|
|
|
|
value->value.structure.components[i] =
|
|
|
|
|
mmsMsg_parseDataElement(dataElement->choice.array->list.array[i]);
|
|
|
|
|
|
|
|
|
|
if (value->value.structure.components[i] == NULL) {
|
|
|
|
|
MmsValue_delete(value);
|
|
|
|
|
value = NULL;
|
|
|
|
|
break;
|
|
|
|
|
if (value) {
|
|
|
|
|
value->type = MMS_ARRAY;
|
|
|
|
|
value->value.structure.size = componentCount;
|
|
|
|
|
value->value.structure.components = (MmsValue**) GLOBAL_CALLOC(componentCount, sizeof(MmsValue*));
|
|
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < componentCount; i++) {
|
|
|
|
|
value->value.structure.components[i] =
|
|
|
|
|
mmsMsg_parseDataElement(dataElement->choice.array->list.array[i]);
|
|
|
|
|
|
|
|
|
|
if (value->value.structure.components[i] == NULL) {
|
|
|
|
|
MmsValue_delete(value);
|
|
|
|
|
value = NULL;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -222,20 +224,22 @@ mmsMsg_parseDataElement(Data_t* dataElement)
|
|
|
|
|
if (componentCount > 0) {
|
|
|
|
|
value = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
|
|
|
|
|
|
|
|
|
|
value->type = MMS_STRUCTURE;
|
|
|
|
|
value->value.structure.size = componentCount;
|
|
|
|
|
value->value.structure.components = (MmsValue**) GLOBAL_CALLOC(componentCount, sizeof(MmsValue*));
|
|
|
|
|
if (value) {
|
|
|
|
|
value->type = MMS_STRUCTURE;
|
|
|
|
|
value->value.structure.size = componentCount;
|
|
|
|
|
value->value.structure.components = (MmsValue**) GLOBAL_CALLOC(componentCount, sizeof(MmsValue*));
|
|
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < componentCount; i++) {
|
|
|
|
|
value->value.structure.components[i] =
|
|
|
|
|
mmsMsg_parseDataElement(dataElement->choice.structure->list.array[i]);
|
|
|
|
|
for (i = 0; i < componentCount; i++) {
|
|
|
|
|
value->value.structure.components[i] =
|
|
|
|
|
mmsMsg_parseDataElement(dataElement->choice.structure->list.array[i]);
|
|
|
|
|
|
|
|
|
|
if (value->value.structure.components[i] == NULL) {
|
|
|
|
|
MmsValue_delete(value);
|
|
|
|
|
value = NULL;
|
|
|
|
|
break;
|
|
|
|
|
if (value->value.structure.components[i] == NULL) {
|
|
|
|
|
MmsValue_delete(value);
|
|
|
|
|
value = NULL;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -251,7 +255,8 @@ mmsMsg_parseDataElement(Data_t* dataElement)
|
|
|
|
|
Asn1PrimitiveValue* berInteger = BerInteger_createFromBuffer(
|
|
|
|
|
dataElement->choice.integer.buf, dataElement->choice.integer.size);
|
|
|
|
|
|
|
|
|
|
value = MmsValue_newIntegerFromBerInteger(berInteger);
|
|
|
|
|
if (berInteger)
|
|
|
|
|
value = MmsValue_newIntegerFromBerInteger(berInteger);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (DEBUG_MMS_CLIENT)
|
|
|
|
@ -264,7 +269,8 @@ mmsMsg_parseDataElement(Data_t* dataElement)
|
|
|
|
|
Asn1PrimitiveValue* berInteger = BerInteger_createFromBuffer(
|
|
|
|
|
dataElement->choice.Unsigned.buf, dataElement->choice.Unsigned.size);
|
|
|
|
|
|
|
|
|
|
value = MmsValue_newUnsignedFromBerInteger(berInteger);
|
|
|
|
|
if (berInteger)
|
|
|
|
|
value = MmsValue_newUnsignedFromBerInteger(berInteger);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (DEBUG_MMS_CLIENT)
|
|
|
|
@ -297,20 +303,32 @@ mmsMsg_parseDataElement(Data_t* dataElement)
|
|
|
|
|
if ((bitSize > 0) && (maxSize >= bitSize)) {
|
|
|
|
|
value = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
|
|
|
|
|
|
|
|
|
|
value->type = MMS_BIT_STRING;
|
|
|
|
|
if (value) {
|
|
|
|
|
|
|
|
|
|
value->type = MMS_BIT_STRING;
|
|
|
|
|
|
|
|
|
|
value->value.bitString.size = bitSize;
|
|
|
|
|
value->value.bitString.size = bitSize;
|
|
|
|
|
|
|
|
|
|
value->value.bitString.buf = (uint8_t*) GLOBAL_MALLOC(size);
|
|
|
|
|
memcpy(value->value.bitString.buf,
|
|
|
|
|
dataElement->choice.bitstring.buf, size);
|
|
|
|
|
value->value.bitString.buf = (uint8_t*) GLOBAL_MALLOC(size);
|
|
|
|
|
|
|
|
|
|
if (value->value.bitString.buf) {
|
|
|
|
|
memcpy(value->value.bitString.buf,
|
|
|
|
|
dataElement->choice.bitstring.buf, size);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
GLOBAL_FREEMEM(value);
|
|
|
|
|
value = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (bitSize == 0) {
|
|
|
|
|
value = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
|
|
|
|
|
|
|
|
|
|
value->type = MMS_BIT_STRING;
|
|
|
|
|
value->value.bitString.size = 0;
|
|
|
|
|
value->value.bitString.buf = NULL;
|
|
|
|
|
if (value) {
|
|
|
|
|
value->type = MMS_BIT_STRING;
|
|
|
|
|
value->value.bitString.size = 0;
|
|
|
|
|
value->value.bitString.buf = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (DEBUG_MMS_CLIENT)
|
|
|
|
@ -329,35 +347,41 @@ mmsMsg_parseDataElement(Data_t* dataElement)
|
|
|
|
|
if (size == 5) { /* FLOAT32 */
|
|
|
|
|
|
|
|
|
|
value = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
|
|
|
|
|
value->type = MMS_FLOAT;
|
|
|
|
|
|
|
|
|
|
value->value.floatingPoint.formatWidth = 32;
|
|
|
|
|
value->value.floatingPoint.exponentWidth = dataElement->choice.floatingpoint.buf[0];
|
|
|
|
|
if (value) {
|
|
|
|
|
value->type = MMS_FLOAT;
|
|
|
|
|
|
|
|
|
|
value->value.floatingPoint.formatWidth = 32;
|
|
|
|
|
value->value.floatingPoint.exponentWidth = dataElement->choice.floatingpoint.buf[0];
|
|
|
|
|
|
|
|
|
|
uint8_t* floatBuf = (dataElement->choice.floatingpoint.buf + 1);
|
|
|
|
|
uint8_t* floatBuf = (dataElement->choice.floatingpoint.buf + 1);
|
|
|
|
|
|
|
|
|
|
#if (ORDER_LITTLE_ENDIAN == 1)
|
|
|
|
|
memcpyReverseByteOrder(value->value.floatingPoint.buf, floatBuf, 4);
|
|
|
|
|
memcpyReverseByteOrder(value->value.floatingPoint.buf, floatBuf, 4);
|
|
|
|
|
#else
|
|
|
|
|
memcpy(value->value.floatingPoint.buf, floatBuf, 4);
|
|
|
|
|
memcpy(value->value.floatingPoint.buf, floatBuf, 4);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (size == 9) { /* FLOAT64 */
|
|
|
|
|
|
|
|
|
|
value = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
|
|
|
|
|
value->type = MMS_FLOAT;
|
|
|
|
|
|
|
|
|
|
value->value.floatingPoint.formatWidth = 64;
|
|
|
|
|
value->value.floatingPoint.exponentWidth = dataElement->choice.floatingpoint.buf[0];
|
|
|
|
|
if (value) {
|
|
|
|
|
value->type = MMS_FLOAT;
|
|
|
|
|
|
|
|
|
|
uint8_t* floatBuf = (dataElement->choice.floatingpoint.buf + 1);
|
|
|
|
|
value->value.floatingPoint.formatWidth = 64;
|
|
|
|
|
value->value.floatingPoint.exponentWidth = dataElement->choice.floatingpoint.buf[0];
|
|
|
|
|
|
|
|
|
|
uint8_t* floatBuf = (dataElement->choice.floatingpoint.buf + 1);
|
|
|
|
|
|
|
|
|
|
#if (ORDER_LITTLE_ENDIAN == 1)
|
|
|
|
|
memcpyReverseByteOrder(value->value.floatingPoint.buf, floatBuf, 8);
|
|
|
|
|
memcpyReverseByteOrder(value->value.floatingPoint.buf, floatBuf, 8);
|
|
|
|
|
#else
|
|
|
|
|
memcpy(value->value.floatingPoint.buf, floatBuf, 8);
|
|
|
|
|
memcpy(value->value.floatingPoint.buf, floatBuf, 8);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (dataElement->present == Data_PR_utctime) {
|
|
|
|
@ -366,8 +390,11 @@ mmsMsg_parseDataElement(Data_t* dataElement)
|
|
|
|
|
|
|
|
|
|
if (size == 8) {
|
|
|
|
|
value = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
|
|
|
|
|
value->type = MMS_UTC_TIME;
|
|
|
|
|
memcpy(value->value.utcTime, dataElement->choice.utctime.buf, 8);
|
|
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
|
value->type = MMS_UTC_TIME;
|
|
|
|
|
memcpy(value->value.utcTime, dataElement->choice.utctime.buf, 8);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (DEBUG_MMS_CLIENT)
|
|
|
|
@ -378,12 +405,28 @@ mmsMsg_parseDataElement(Data_t* dataElement)
|
|
|
|
|
|
|
|
|
|
if (dataElement->choice.octetstring.size >= 0) {
|
|
|
|
|
value = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
|
|
|
|
|
value->type = MMS_OCTET_STRING;
|
|
|
|
|
int size = dataElement->choice.octetstring.size;
|
|
|
|
|
value->value.octetString.size = size;
|
|
|
|
|
value->value.octetString.maxSize = size;
|
|
|
|
|
value->value.octetString.buf = (uint8_t*) GLOBAL_MALLOC(size);
|
|
|
|
|
memcpy(value->value.octetString.buf, dataElement->choice.octetstring.buf, size);
|
|
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
|
value->type = MMS_OCTET_STRING;
|
|
|
|
|
int size = dataElement->choice.octetstring.size;
|
|
|
|
|
|
|
|
|
|
value->value.octetString.size = size;
|
|
|
|
|
|
|
|
|
|
if (size > 0)
|
|
|
|
|
value->value.octetString.maxSize = -size;
|
|
|
|
|
else
|
|
|
|
|
value->value.octetString.maxSize = -8;
|
|
|
|
|
|
|
|
|
|
value->value.octetString.buf = (uint8_t*) GLOBAL_MALLOC(abs(value->value.octetString.maxSize));
|
|
|
|
|
|
|
|
|
|
if (value->value.octetString.buf) {
|
|
|
|
|
memcpy(value->value.octetString.buf, dataElement->choice.octetstring.buf, size);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
GLOBAL_FREEMEM(value);
|
|
|
|
|
value = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -392,9 +435,12 @@ mmsMsg_parseDataElement(Data_t* dataElement)
|
|
|
|
|
|
|
|
|
|
if ((size == 4) || (size == 6)) {
|
|
|
|
|
value = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
|
|
|
|
|
value->type = MMS_BINARY_TIME;
|
|
|
|
|
value->value.binaryTime.size = size;
|
|
|
|
|
memcpy(value->value.binaryTime.buf, dataElement->choice.binarytime.buf, size);
|
|
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
|
value->type = MMS_BINARY_TIME;
|
|
|
|
|
value->value.binaryTime.size = size;
|
|
|
|
|
memcpy(value->value.binaryTime.buf, dataElement->choice.binarytime.buf, size);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (DEBUG_MMS_CLIENT)
|
|
|
|
|