- some code reformating

pull/143/head
Michael Zillgith 8 years ago
parent 60b7b673f4
commit 7b98f368dc

@ -45,7 +45,8 @@
#define ETH_P_GOOSE 0x88b8 #define ETH_P_GOOSE 0x88b8
struct sGooseReceiver { struct sGooseReceiver
{
bool running; bool running;
bool stopped; bool stopped;
char* interfaceId; char* interfaceId;
@ -57,7 +58,6 @@ struct sGooseReceiver {
#endif #endif
}; };
GooseReceiver GooseReceiver
GooseReceiver_create() GooseReceiver_create()
{ {
@ -89,7 +89,6 @@ GooseReceiver_removeSubscriber(GooseReceiver self, GooseSubscriber subscriber)
LinkedList_remove(self->subscriberList, (void*) subscriber); LinkedList_remove(self->subscriberList, (void*) subscriber);
} }
void void
GooseReceiver_setInterfaceId(GooseReceiver self, const char* interfaceId) GooseReceiver_setInterfaceId(GooseReceiver self, const char* interfaceId)
{ {
@ -122,7 +121,8 @@ parseAllData(uint8_t* buffer, int allDataLength, MmsValue* dataSetValues)
uint8_t tag = buffer[bufPos++]; uint8_t tag = buffer[bufPos++];
if (elementIndex > maxIndex) { if (elementIndex > maxIndex) {
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Malformed message: too much elements!\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Malformed message: too much elements!\n");
return 0; return 0;
} }
@ -130,41 +130,51 @@ parseAllData(uint8_t* buffer, int allDataLength, MmsValue* dataSetValues)
bufPos = BerDecoder_decodeLength(buffer, &elementLength, bufPos, allDataLength); bufPos = BerDecoder_decodeLength(buffer, &elementLength, bufPos, allDataLength);
if (bufPos < 0) { if (bufPos < 0) {
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Malformed message: failed to decode BER length tag!\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Malformed message: failed to decode BER length tag!\n");
return 0; return 0;
} }
if (bufPos + elementLength > allDataLength) { if (bufPos + elementLength > allDataLength) {
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Malformed message: sub element is too large!\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Malformed message: sub element is too large!\n");
return 0; return 0;
} }
switch (tag) { switch (tag)
{
case 0x80: /* reserved for access result */ case 0x80: /* reserved for access result */
printf("GOOSE_SUBSCRIBER: found reserved value (tag 0x80)!\n"); printf("GOOSE_SUBSCRIBER: found reserved value (tag 0x80)!\n");
break; break;
case 0xa1: /* array */ case 0xa1: /* array */
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: found array\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: found array\n");
if (MmsValue_getType(value) == MMS_ARRAY) { if (MmsValue_getType(value) == MMS_ARRAY) {
if (!parseAllData(buffer + bufPos, elementLength, value)) if (!parseAllData(buffer + bufPos, elementLength, value))
return -1; return -1;
} }
break; break;
case 0xa2: /* structure */ case 0xa2: /* structure */
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: found structure\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: found structure\n");
if (MmsValue_getType(value) == MMS_STRUCTURE) { if (MmsValue_getType(value) == MMS_STRUCTURE) {
if (!parseAllData(buffer + bufPos, elementLength, value)) if (!parseAllData(buffer + bufPos, elementLength, value))
return -1; return -1;
} }
break; break;
case 0x83: /* boolean */ case 0x83: /* boolean */
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: found boolean\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: found boolean\n");
if (MmsValue_getType(value) == MMS_BOOLEAN) { if (MmsValue_getType(value) == MMS_BOOLEAN) {
MmsValue_setBoolean(value, BerDecoder_decodeBoolean(buffer, bufPos)); MmsValue_setBoolean(value, BerDecoder_decodeBoolean(buffer, bufPos));
} }
else else
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: message contains value of wrong type!\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: message contains value of wrong type!\n");
break; break;
@ -181,6 +191,7 @@ parseAllData(uint8_t* buffer, int allDataLength, MmsValue* dataSetValues)
printf("bit-string is of wrong size"); printf("bit-string is of wrong size");
} }
break; break;
case 0x85: /* integer */ case 0x85: /* integer */
if (MmsValue_getType(value) == MMS_INTEGER) { if (MmsValue_getType(value) == MMS_INTEGER) {
if (elementLength <= value->value.integer->maxSize) { if (elementLength <= value->value.integer->maxSize) {
@ -189,6 +200,7 @@ parseAllData(uint8_t* buffer, int allDataLength, MmsValue* dataSetValues)
} }
} }
break; break;
case 0x86: /* unsigned integer */ case 0x86: /* unsigned integer */
if (MmsValue_getType(value) == MMS_UNSIGNED) { if (MmsValue_getType(value) == MMS_UNSIGNED) {
if (elementLength <= value->value.integer->maxSize) { if (elementLength <= value->value.integer->maxSize) {
@ -197,6 +209,7 @@ parseAllData(uint8_t* buffer, int allDataLength, MmsValue* dataSetValues)
} }
} }
break; break;
case 0x87: /* Float */ case 0x87: /* Float */
if (MmsValue_getType(value) == MMS_FLOAT) { if (MmsValue_getType(value) == MMS_FLOAT) {
if (elementLength == 9) { if (elementLength == 9) {
@ -216,6 +229,7 @@ parseAllData(uint8_t* buffer, int allDataLength, MmsValue* dataSetValues)
} }
} }
break; break;
case 0x8a: /* visible string */ case 0x8a: /* visible string */
if (MmsValue_getType(value) == MMS_VISIBLE_STRING) { if (MmsValue_getType(value) == MMS_VISIBLE_STRING) {
@ -235,6 +249,7 @@ parseAllData(uint8_t* buffer, int allDataLength, MmsValue* dataSetValues)
} }
break; break;
case 0x8c: /* binary time */ case 0x8c: /* binary time */
if (MmsValue_getType(value) == MMS_BINARY_TIME) { if (MmsValue_getType(value) == MMS_BINARY_TIME) {
if ((elementLength == 4) || (elementLength == 6)) { if ((elementLength == 4) || (elementLength == 6)) {
@ -242,17 +257,21 @@ parseAllData(uint8_t* buffer, int allDataLength, MmsValue* dataSetValues)
} }
} }
break; break;
case 0x91: /* Utctime */ case 0x91: /* Utctime */
if (elementLength == 8) { if (elementLength == 8) {
if (MmsValue_getType(value) == MMS_UTC_TIME) { if (MmsValue_getType(value) == MMS_UTC_TIME) {
MmsValue_setUtcTimeByBuffer(value, buffer + bufPos); MmsValue_setUtcTimeByBuffer(value, buffer + bufPos);
} }
else else
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: message contains value of wrong type!\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: message contains value of wrong type!\n");
} }
else else
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: UTCTime element is of wrong size!\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: UTCTime element is of wrong size!\n");
break; break;
default: default:
if (DEBUG_GOOSE_SUBSCRIBER) if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: found unkown tag %02x\n", tag); printf("GOOSE_SUBSCRIBER: found unkown tag %02x\n", tag);
@ -282,16 +301,19 @@ parseAllDataUnknownValue(GooseSubscriber self, uint8_t* buffer, int allDataLengt
bufPos = BerDecoder_decodeLength(buffer, &elementLength, bufPos, allDataLength); bufPos = BerDecoder_decodeLength(buffer, &elementLength, bufPos, allDataLength);
if (bufPos < 0) { if (bufPos < 0) {
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Malformed message: failed to decode BER length tag!\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Malformed message: failed to decode BER length tag!\n");
return 0; return 0;
} }
if (bufPos + elementLength > allDataLength) { if (bufPos + elementLength > allDataLength) {
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Malformed message: sub element is too large!\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Malformed message: sub element is too large!\n");
goto exit_with_error; goto exit_with_error;
} }
switch (tag) { switch (tag)
{
case 0x80: /* reserved for access result */ case 0x80: /* reserved for access result */
break; break;
case 0xa1: /* array */ case 0xa1: /* array */
@ -340,20 +362,24 @@ parseAllDataUnknownValue(GooseSubscriber self, uint8_t* buffer, int allDataLengt
bufPos = BerDecoder_decodeLength(buffer, &elementLength, bufPos, allDataLength); bufPos = BerDecoder_decodeLength(buffer, &elementLength, bufPos, allDataLength);
if (bufPos < 0) { if (bufPos < 0) {
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Malformed message: failed to decode BER length tag!\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Malformed message: failed to decode BER length tag!\n");
return 0; return 0;
} }
if (bufPos + elementLength > allDataLength) { if (bufPos + elementLength > allDataLength) {
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Malformed message: sub element is too large!\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Malformed message: sub element is too large!\n");
goto exit_with_error; goto exit_with_error;
} }
MmsValue* value = NULL; MmsValue* value = NULL;
switch (tag) { switch (tag)
{
case 0xa1: /* array */ case 0xa1: /* array */
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: found array\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: found array\n");
value = parseAllDataUnknownValue(self, buffer + bufPos, elementLength, false); value = parseAllDataUnknownValue(self, buffer + bufPos, elementLength, false);
@ -361,8 +387,10 @@ parseAllDataUnknownValue(GooseSubscriber self, uint8_t* buffer, int allDataLengt
goto exit_with_error; goto exit_with_error;
break; break;
case 0xa2: /* structure */ case 0xa2: /* structure */
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: found structure\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: found structure\n");
value = parseAllDataUnknownValue(self, buffer + bufPos, elementLength, true); value = parseAllDataUnknownValue(self, buffer + bufPos, elementLength, true);
@ -370,8 +398,10 @@ parseAllDataUnknownValue(GooseSubscriber self, uint8_t* buffer, int allDataLengt
goto exit_with_error; goto exit_with_error;
break; break;
case 0x83: /* boolean */ case 0x83: /* boolean */
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: found boolean\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: found boolean\n");
value = MmsValue_newBoolean(BerDecoder_decodeBoolean(buffer, bufPos)); value = MmsValue_newBoolean(BerDecoder_decodeBoolean(buffer, bufPos));
break; break;
@ -385,16 +415,19 @@ parseAllDataUnknownValue(GooseSubscriber self, uint8_t* buffer, int allDataLengt
} }
break; break;
case 0x85: /* integer */ case 0x85: /* integer */
value = MmsValue_newInteger(elementLength * 8); value = MmsValue_newInteger(elementLength * 8);
memcpy(value->value.integer->octets, buffer + bufPos, elementLength); memcpy(value->value.integer->octets, buffer + bufPos, elementLength);
value->value.integer->size = elementLength; value->value.integer->size = elementLength;
break; break;
case 0x86: /* unsigned integer */ case 0x86: /* unsigned integer */
value = MmsValue_newUnsigned(elementLength * 8); value = MmsValue_newUnsigned(elementLength * 8);
memcpy(value->value.integer->octets, buffer + bufPos, elementLength); memcpy(value->value.integer->octets, buffer + bufPos, elementLength);
value->value.integer->size = elementLength; value->value.integer->size = elementLength;
break; break;
case 0x87: /* Float */ case 0x87: /* Float */
if (elementLength == 9) if (elementLength == 9)
value = MmsValue_newDouble(BerDecoder_decodeDouble(buffer, bufPos)); value = MmsValue_newDouble(BerDecoder_decodeDouble(buffer, bufPos));
@ -406,9 +439,11 @@ parseAllDataUnknownValue(GooseSubscriber self, uint8_t* buffer, int allDataLengt
value = MmsValue_newOctetString(elementLength, elementLength); value = MmsValue_newOctetString(elementLength, elementLength);
memcpy(value->value.octetString.buf, buffer + bufPos, elementLength); memcpy(value->value.octetString.buf, buffer + bufPos, elementLength);
break; break;
case 0x8a: /* visible string */ case 0x8a: /* visible string */
value = MmsValue_newVisibleStringFromByteArray(buffer + bufPos, elementLength); value = MmsValue_newVisibleStringFromByteArray(buffer + bufPos, elementLength);
break; break;
case 0x8c: /* binary time */ case 0x8c: /* binary time */
if (elementLength == 4) if (elementLength == 4)
value = MmsValue_newBinaryTime(true); value = MmsValue_newBinaryTime(true);
@ -419,16 +454,20 @@ parseAllDataUnknownValue(GooseSubscriber self, uint8_t* buffer, int allDataLengt
memcpy(value->value.binaryTime.buf, buffer + bufPos, elementLength); memcpy(value->value.binaryTime.buf, buffer + bufPos, elementLength);
break; break;
case 0x91: /* Utctime */ case 0x91: /* Utctime */
if (elementLength == 8) { if (elementLength == 8) {
value = MmsValue_newUtcTime(0); value = MmsValue_newUtcTime(0);
MmsValue_setUtcTimeByBuffer(value, buffer + bufPos); MmsValue_setUtcTimeByBuffer(value, buffer + bufPos);
} }
else else
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: UTCTime element is of wrong size!\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: UTCTime element is of wrong size!\n");
break; break;
default: default:
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: found unkown tag %02x\n", tag); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: found unkown tag %02x\n", tag);
goto exit_with_error; goto exit_with_error;
} }
@ -444,7 +483,7 @@ parseAllDataUnknownValue(GooseSubscriber self, uint8_t* buffer, int allDataLengt
return dataSetValues; return dataSetValues;
exit_with_error: exit_with_error:
if (dataSetValues != NULL) if (dataSetValues != NULL)
MmsValue_delete(dataSetValues); MmsValue_delete(dataSetValues);
@ -452,7 +491,6 @@ exit_with_error:
return NULL; return NULL;
} }
static int static int
parseGoosePayload(GooseReceiver self, uint8_t* buffer, int apduLength) parseGoosePayload(GooseReceiver self, uint8_t* buffer, int apduLength)
{ {
@ -474,7 +512,8 @@ parseGoosePayload(GooseReceiver self, uint8_t* buffer, int apduLength)
int gooseLength; int gooseLength;
bufPos = BerDecoder_decodeLength(buffer, &gooseLength, bufPos, apduLength); bufPos = BerDecoder_decodeLength(buffer, &gooseLength, bufPos, apduLength);
if (bufPos < 0) { if (bufPos < 0) {
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Malformed message: failed to decode BER length tag!\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Malformed message: failed to decode BER length tag!\n");
return 0; return 0;
} }
@ -486,7 +525,8 @@ parseGoosePayload(GooseReceiver self, uint8_t* buffer, int apduLength)
uint8_t tag = buffer[bufPos++]; uint8_t tag = buffer[bufPos++];
bufPos = BerDecoder_decodeLength(buffer, &elementLength, bufPos, apduLength); bufPos = BerDecoder_decodeLength(buffer, &elementLength, bufPos, apduLength);
if (bufPos < 0) { if (bufPos < 0) {
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Malformed message: failed to decode BER length tag!\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Malformed message: failed to decode BER length tag!\n");
return 0; return 0;
} }
@ -500,9 +540,11 @@ parseGoosePayload(GooseReceiver self, uint8_t* buffer, int apduLength)
if (bufPos == -1) if (bufPos == -1)
goto exit_with_fault; goto exit_with_fault;
switch(tag) { switch (tag)
{
case 0x80: /* gocbRef */ case 0x80: /* gocbRef */
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Found gocbRef\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Found gocbRef\n");
{ {
LinkedList element = LinkedList_getNext(self->subscriberList); LinkedList element = LinkedList_getNext(self->subscriberList);
@ -512,7 +554,8 @@ parseGoosePayload(GooseReceiver self, uint8_t* buffer, int apduLength)
if (subscriber->goCBRefLen == elementLength) { if (subscriber->goCBRefLen == elementLength) {
if (memcmp(subscriber->goCBRef, buffer + bufPos, elementLength) == 0) { if (memcmp(subscriber->goCBRef, buffer + bufPos, elementLength) == 0) {
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: gocbRef is matching!\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: gocbRef is matching!\n");
matchingSubscriber = subscriber; matchingSubscriber = subscriber;
break; break;
} }
@ -531,61 +574,73 @@ parseGoosePayload(GooseReceiver self, uint8_t* buffer, int apduLength)
timeAllowedToLive = BerDecoder_decodeUint32(buffer, elementLength, bufPos); timeAllowedToLive = BerDecoder_decodeUint32(buffer, elementLength, bufPos);
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Found timeAllowedToLive %u\n", timeAllowedToLive); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Found timeAllowedToLive %u\n", timeAllowedToLive);
break; break;
case 0x82: case 0x82:
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Found dataSet\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Found dataSet\n");
break; break;
case 0x83: case 0x83:
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Found goId\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Found goId\n");
break; break;
case 0x84: case 0x84:
timestampBufPos = buffer + bufPos; timestampBufPos = buffer + bufPos;
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Found timestamp\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Found timestamp\n");
break; break;
case 0x85: case 0x85:
stNum = BerDecoder_decodeUint32(buffer, elementLength, bufPos); stNum = BerDecoder_decodeUint32(buffer, elementLength, bufPos);
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Found stNum: %u\n", stNum); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Found stNum: %u\n", stNum);
break; break;
case 0x86: case 0x86:
sqNum = BerDecoder_decodeUint32(buffer, elementLength, bufPos); sqNum = BerDecoder_decodeUint32(buffer, elementLength, bufPos);
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Found sqNum: %u\n", sqNum); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Found sqNum: %u\n", sqNum);
break; break;
case 0x87: case 0x87:
simulation = BerDecoder_decodeBoolean(buffer, bufPos); simulation = BerDecoder_decodeBoolean(buffer, bufPos);
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Found simulation: %i\n", simulation); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Found simulation: %i\n", simulation);
break; break;
case 0x88: case 0x88:
confRev = BerDecoder_decodeUint32(buffer, elementLength, bufPos); confRev = BerDecoder_decodeUint32(buffer, elementLength, bufPos);
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Found confRev: %u\n", confRev); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Found confRev: %u\n", confRev);
break; break;
case 0x89: case 0x89:
ndsCom = BerDecoder_decodeBoolean(buffer, bufPos); ndsCom = BerDecoder_decodeBoolean(buffer, bufPos);
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Found ndsCom: %i\n", ndsCom); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Found ndsCom: %i\n", ndsCom);
break; break;
case 0x8a: case 0x8a:
numberOfDatSetEntries = BerDecoder_decodeUint32(buffer, elementLength, bufPos); numberOfDatSetEntries = BerDecoder_decodeUint32(buffer, elementLength, bufPos);
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Found number of entries: %u\n", numberOfDatSetEntries); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Found number of entries: %u\n", numberOfDatSetEntries);
break; break;
case 0xab: case 0xab:
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Found all data with length: %i\n", elementLength); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Found all data with length: %i\n", elementLength);
dataSetBufferAddress = buffer + bufPos; dataSetBufferAddress = buffer + bufPos;
dataSetBufferLength = elementLength; dataSetBufferLength = elementLength;
break; break;
default: default:
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Unknown tag %02x\n", tag); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Unknown tag %02x\n", tag);
break; break;
} }
@ -629,12 +684,12 @@ parseGoosePayload(GooseReceiver self, uint8_t* buffer, int apduLength)
return 0; return 0;
} }
exit_with_fault: exit_with_fault:
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Invalid goose payload\n"); if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Invalid goose payload\n");
return -1; return -1;
} }
static void static void
parseGooseMessage(GooseReceiver self, int numbytes) parseGooseMessage(GooseReceiver self, int numbytes)
{ {
@ -642,7 +697,8 @@ parseGooseMessage(GooseReceiver self, int numbytes)
bool subscriberFound = false; bool subscriberFound = false;
uint8_t* buffer = self->buffer; uint8_t* buffer = self->buffer;
if (numbytes < 22) return; if (numbytes < 22)
return;
/* skip ethernet addresses */ /* skip ethernet addresses */
bufPos = 12; bufPos = 12;
@ -688,7 +744,6 @@ parseGooseMessage(GooseReceiver self, int numbytes)
printf("GOOSE_SUBSCRIBER: APDU length: %i\n", apduLength); printf("GOOSE_SUBSCRIBER: APDU length: %i\n", apduLength);
} }
// check if there is an interested subscriber // check if there is an interested subscriber
LinkedList element = LinkedList_getNext(self->subscriberList); LinkedList element = LinkedList_getNext(self->subscriberList);
@ -711,7 +766,6 @@ parseGooseMessage(GooseReceiver self, int numbytes)
} }
} }
static void static void
gooseReceiverLoop(void* threadParameter) gooseReceiverLoop(void* threadParameter)
{ {
@ -736,7 +790,6 @@ gooseReceiverLoop(void* threadParameter)
self->stopped = true; self->stopped = true;
} }
// start GOOSE receiver in a separate thread // start GOOSE receiver in a separate thread
void void
GooseReceiver_start(GooseReceiver self) GooseReceiver_start(GooseReceiver self)

@ -221,10 +221,10 @@ ControlObjectClient_create(const char* objectReference, IedConnection connection
private_IedConnection_addControlClient(connection, self); private_IedConnection_addControlClient(connection, self);
free_varspec: free_varspec:
MmsVariableSpecification_destroy(ctlVarSpec); MmsVariableSpecification_destroy(ctlVarSpec);
exit_function: exit_function:
return self; return self;
} }
@ -320,11 +320,11 @@ createOriginValue(ControlObjectClient self)
goto exit_function; goto exit_function;
cleanup_on_error: cleanup_on_error:
MmsValue_delete(origin); MmsValue_delete(origin);
origin = NULL; origin = NULL;
exit_function: exit_function:
return origin; return origin;
} }
@ -452,7 +452,7 @@ ControlObjectClient_operate(ControlObjectClient self, MmsValue* ctlVal, uint64_t
success = true; success = true;
exit_function: exit_function:
return success; return success;
} }
@ -613,7 +613,7 @@ ControlObjectClient_select(ControlObjectClient self)
MmsValue_delete(value); MmsValue_delete(value);
exit_function: exit_function:
return selected; return selected;
} }
@ -712,7 +712,6 @@ ControlObjectClient_setInterlockCheck(ControlObjectClient self, bool value)
self->interlockCheck = value; self->interlockCheck = value;
} }
void void
ControlObjectClient_enableSynchroCheck(ControlObjectClient self) ControlObjectClient_enableSynchroCheck(ControlObjectClient self)
{ {

@ -43,7 +43,7 @@ checkAuthMechanismName(uint8_t* authMechanism, int authMechLen)
{ {
AcseAuthenticationMechanism authenticationMechanism = ACSE_AUTH_NONE; AcseAuthenticationMechanism authenticationMechanism = ACSE_AUTH_NONE;
if (authMechanism != NULL ) { if (authMechanism != NULL) {
if (authMechLen == 3) { if (authMechLen == 3) {
if (memcmp(auth_mech_password_oid, authMechanism, 3) == 0) { if (memcmp(auth_mech_password_oid, authMechanism, 3) == 0) {
@ -81,7 +81,7 @@ checkAuthentication(AcseConnection* self, uint8_t* authMechanism, int authMechLe
{ {
self->securityToken = NULL; self->securityToken = NULL;
if (self->authenticator != NULL ) { if (self->authenticator != NULL) {
AcseAuthenticationMechanism mechanism = checkAuthMechanismName(authMechanism, authMechLen); AcseAuthenticationMechanism mechanism = checkAuthMechanismName(authMechanism, authMechLen);
@ -111,11 +111,11 @@ checkAuthentication(AcseConnection* self, uint8_t* authMechanism, int authMechLe
return true; return true;
} }
static int static int
parseUserInformation(AcseConnection* self, uint8_t* buffer, int bufPos, int maxBufPos, bool* userInfoValid) parseUserInformation(AcseConnection* self, uint8_t* buffer, int bufPos, int maxBufPos, bool* userInfoValid)
{ {
if (DEBUG_ACSE) printf("ACSE: parseUserInformation %i %i\n", bufPos, maxBufPos); if (DEBUG_ACSE)
printf("ACSE: parseUserInformation %i %i\n", bufPos, maxBufPos);
bool hasindirectReference = false; bool hasindirectReference = false;
bool isDataValid = false; bool isDataValid = false;
@ -131,7 +131,8 @@ parseUserInformation(AcseConnection* self, uint8_t* buffer, int bufPos, int maxB
return -1; return -1;
} }
switch (tag) { switch (tag)
{
case 0x02: /* indirect-reference */ case 0x02: /* indirect-reference */
self->nextReference = BerDecoder_decodeUint32(buffer, len, bufPos); self->nextReference = BerDecoder_decodeUint32(buffer, len, bufPos);
@ -154,11 +155,12 @@ parseUserInformation(AcseConnection* self, uint8_t* buffer, int bufPos, int maxB
} }
} }
if (DEBUG_ACSE) { if (DEBUG_ACSE) {
if (!hasindirectReference) printf("ACSE: User data has no indirect reference!\n"); if (!hasindirectReference)
printf("ACSE: User data has no indirect reference!\n");
if (!isDataValid) printf("ACSE: No valid user data\n"); if (!isDataValid)
printf("ACSE: No valid user data\n");
} }
if (hasindirectReference && isDataValid) if (hasindirectReference && isDataValid)
@ -172,7 +174,8 @@ parseUserInformation(AcseConnection* self, uint8_t* buffer, int bufPos, int maxB
static AcseIndication static AcseIndication
parseAarePdu(AcseConnection* self, uint8_t* buffer, int bufPos, int maxBufPos) parseAarePdu(AcseConnection* self, uint8_t* buffer, int bufPos, int maxBufPos)
{ {
if (DEBUG_ACSE) printf("ACSE: parse AARE PDU\n"); if (DEBUG_ACSE)
printf("ACSE: parse AARE PDU\n");
bool userInfoValid = false; bool userInfoValid = false;
@ -186,7 +189,8 @@ parseAarePdu(AcseConnection* self, uint8_t* buffer, int bufPos, int maxBufPos)
if (bufPos < 0) if (bufPos < 0)
return ACSE_ERROR; return ACSE_ERROR;
switch (tag) { switch (tag)
{
case 0xa1: /* application context name */ case 0xa1: /* application context name */
bufPos += len; bufPos += len;
break; break;
@ -209,7 +213,8 @@ parseAarePdu(AcseConnection* self, uint8_t* buffer, int bufPos, int maxBufPos)
case 0xbe: /* user information */ case 0xbe: /* user information */
if (buffer[bufPos] != 0x28) { if (buffer[bufPos] != 0x28) {
if (DEBUG_ACSE) printf("ACSE: invalid user info\n"); if (DEBUG_ACSE)
printf("ACSE: invalid user info\n");
bufPos += len; bufPos += len;
} }
else { else {
@ -246,7 +251,8 @@ parseAarePdu(AcseConnection* self, uint8_t* buffer, int bufPos, int maxBufPos)
static AcseIndication static AcseIndication
parseAarqPdu(AcseConnection* self, uint8_t* buffer, int bufPos, int maxBufPos) parseAarqPdu(AcseConnection* self, uint8_t* buffer, int bufPos, int maxBufPos)
{ {
if (DEBUG_ACSE) printf("ACSE: parse AARQ PDU\n"); if (DEBUG_ACSE)
printf("ACSE: parse AARQ PDU\n");
uint8_t* authValue = NULL; uint8_t* authValue = NULL;
int authValueLen = 0; int authValueLen = 0;
@ -261,11 +267,13 @@ parseAarqPdu(AcseConnection* self, uint8_t* buffer, int bufPos, int maxBufPos)
bufPos = BerDecoder_decodeLength(buffer, &len, bufPos, maxBufPos); bufPos = BerDecoder_decodeLength(buffer, &len, bufPos, maxBufPos);
if (bufPos < 0) { if (bufPos < 0) {
if (DEBUG_ACSE) printf("ACSE: Invalid PDU!\n"); if (DEBUG_ACSE)
printf("ACSE: Invalid PDU!\n");
return ACSE_ASSOCIATE_FAILED; return ACSE_ASSOCIATE_FAILED;
} }
switch (tag) { switch (tag)
{
case 0xa1: /* application context name */ case 0xa1: /* application context name */
bufPos += len; bufPos += len;
break; break;
@ -281,7 +289,7 @@ parseAarqPdu(AcseConnection* self, uint8_t* buffer, int bufPos, int maxBufPos)
{ {
if (buffer[bufPos] == 0x06) { /* ap-title-form2 */ if (buffer[bufPos] == 0x06) { /* ap-title-form2 */
int innerLength = buffer[bufPos+1]; int innerLength = buffer[bufPos + 1];
if (innerLength == len - 2) if (innerLength == len - 2)
BerDecoder_decodeOID(buffer, bufPos + 2, innerLength, &(self->applicationReference.apTitle)); BerDecoder_decodeOID(buffer, bufPos + 2, innerLength, &(self->applicationReference.apTitle));
@ -294,10 +302,10 @@ parseAarqPdu(AcseConnection* self, uint8_t* buffer, int bufPos, int maxBufPos)
{ {
if (buffer[bufPos] == 0x02) { /* ae-qualifier-form2 */ if (buffer[bufPos] == 0x02) { /* ae-qualifier-form2 */
int innerLength = buffer[bufPos+1]; int innerLength = buffer[bufPos + 1];
if (innerLength == len - 2) if (innerLength == len - 2)
self->applicationReference.aeQualifier = BerDecoder_decodeInt32(buffer + 2, buffer[bufPos+1], bufPos); self->applicationReference.aeQualifier = BerDecoder_decodeInt32(buffer + 2, buffer[bufPos + 1], bufPos);
} }
} }
bufPos += len; bufPos += len;
@ -318,7 +326,8 @@ parseAarqPdu(AcseConnection* self, uint8_t* buffer, int bufPos, int maxBufPos)
bufPos = BerDecoder_decodeLength(buffer, &len, bufPos, maxBufPos); bufPos = BerDecoder_decodeLength(buffer, &len, bufPos, maxBufPos);
if (bufPos < 0) { if (bufPos < 0) {
if (DEBUG_ACSE) printf("ACSE: Invalid PDU!\n"); if (DEBUG_ACSE)
printf("ACSE: Invalid PDU!\n");
return ACSE_ASSOCIATE_FAILED; return ACSE_ASSOCIATE_FAILED;
} }
@ -329,7 +338,8 @@ parseAarqPdu(AcseConnection* self, uint8_t* buffer, int bufPos, int maxBufPos)
case 0xbe: /* user information */ case 0xbe: /* user information */
if (buffer[bufPos] != 0x28) { if (buffer[bufPos] != 0x28) {
if (DEBUG_ACSE) printf("ACSE: invalid user info\n"); if (DEBUG_ACSE)
printf("ACSE: invalid user info\n");
bufPos += len; bufPos += len;
} }
else { else {
@ -338,14 +348,16 @@ parseAarqPdu(AcseConnection* self, uint8_t* buffer, int bufPos, int maxBufPos)
bufPos = BerDecoder_decodeLength(buffer, &len, bufPos, maxBufPos); bufPos = BerDecoder_decodeLength(buffer, &len, bufPos, maxBufPos);
if (bufPos < 0) { if (bufPos < 0) {
if (DEBUG_ACSE) printf("ACSE: Invalid PDU!\n"); if (DEBUG_ACSE)
printf("ACSE: Invalid PDU!\n");
return ACSE_ASSOCIATE_FAILED; return ACSE_ASSOCIATE_FAILED;
} }
bufPos = parseUserInformation(self, buffer, bufPos, bufPos + len, &userInfoValid); bufPos = parseUserInformation(self, buffer, bufPos, bufPos + len, &userInfoValid);
if (bufPos < 0) { if (bufPos < 0) {
if (DEBUG_ACSE) printf("ACSE: Invalid PDU!\n"); if (DEBUG_ACSE)
printf("ACSE: Invalid PDU!\n");
return ACSE_ASSOCIATE_FAILED; return ACSE_ASSOCIATE_FAILED;
} }
} }
@ -391,7 +403,8 @@ AcseConnection_init(AcseConnection* self, AcseAuthenticator authenticator, void*
self->tlsSocket = tlsSocket; self->tlsSocket = tlsSocket;
#endif #endif
memset(&(self->applicationReference), 0, sizeof(self->applicationReference)); memset(&(self->applicationReference), 0,
sizeof(self->applicationReference));
} }
void void
@ -416,14 +429,16 @@ AcseConnection_parseMessage(AcseConnection* self, ByteBuffer* message)
bufPos = BerDecoder_decodeLength(buffer, &len, bufPos, messageSize); bufPos = BerDecoder_decodeLength(buffer, &len, bufPos, messageSize);
if (bufPos < 0) { if (bufPos < 0)
{
if (DEBUG_ACSE) if (DEBUG_ACSE)
printf("ACSE: AcseConnection_parseMessage: invalid ACSE message!\n"); printf("ACSE: AcseConnection_parseMessage: invalid ACSE message!\n");
return ACSE_ERROR; return ACSE_ERROR;
} }
switch (messageType) { switch (messageType)
{
case 0x60: case 0x60:
indication = parseAarqPdu(self, buffer, bufPos, messageSize); indication = parseAarqPdu(self, buffer, bufPos, messageSize);
break; break;
@ -440,7 +455,8 @@ AcseConnection_parseMessage(AcseConnection* self, ByteBuffer* message)
indication = ACSE_ABORT; indication = ACSE_ABORT;
break; break;
default: default:
if (DEBUG_ACSE) printf("ACSE: Unknown ACSE message\n"); if (DEBUG_ACSE)
printf("ACSE: Unknown ACSE message\n");
indication = ACSE_ERROR; indication = ACSE_ERROR;
break; break;
} }
@ -469,7 +485,8 @@ AcseConnection_createAssociateResponseMessage(AcseConnection* self,
int resultLength = 5; int resultLength = 5;
int resultDiagnosticLength = 5; int resultDiagnosticLength = 5;
int fixedContentLength = appContextLength + resultLength + resultDiagnosticLength; int fixedContentLength = appContextLength + resultLength
+ resultDiagnosticLength;
int variableContentLength = 0; int variableContentLength = 0;
@ -567,12 +584,13 @@ AcseConnection_createAssociateRequestMessage(AcseConnection* self,
int calledAEQualifierLength = 0; int calledAEQualifierLength = 0;
if (isoParameters->remoteApTitleLen > 0) { if (isoParameters->remoteApTitleLen > 0)
{
/* called AP title */ /* called AP title */
contentLength += (4 + isoParameters->remoteApTitleLen); contentLength += (4 + isoParameters->remoteApTitleLen);
calledAEQualifierLength = BerEncoder_UInt32determineEncodedSize(isoParameters->remoteAEQualifier); calledAEQualifierLength = BerEncoder_UInt32determineEncodedSize(
isoParameters->remoteAEQualifier);
/* called AE qualifier */ /* called AE qualifier */
contentLength += (4 + calledAEQualifierLength); contentLength += (4 + calledAEQualifierLength);
@ -580,18 +598,20 @@ AcseConnection_createAssociateRequestMessage(AcseConnection* self,
int callingAEQualifierLength = 0; int callingAEQualifierLength = 0;
if (isoParameters->localApTitleLen > 0) { if (isoParameters->localApTitleLen > 0)
{
/* calling AP title */ /* calling AP title */
contentLength += (4 + isoParameters->localApTitleLen); contentLength += (4 + isoParameters->localApTitleLen);
callingAEQualifierLength = BerEncoder_UInt32determineEncodedSize(isoParameters->localAEQualifier); callingAEQualifierLength = BerEncoder_UInt32determineEncodedSize(
isoParameters->localAEQualifier);
/* calling AE qualifier */ /* calling AE qualifier */
contentLength += (4 + callingAEQualifierLength); contentLength += (4 + callingAEQualifierLength);
} }
if (authParameter != NULL) { if (authParameter != NULL)
{
/* sender ACSE requirements */ /* sender ACSE requirements */
contentLength += 4; contentLength += 4;
@ -599,22 +619,26 @@ AcseConnection_createAssociateRequestMessage(AcseConnection* self,
contentLength += 5; contentLength += 5;
/* authentication value */ /* authentication value */
if (authParameter->mechanism == ACSE_AUTH_PASSWORD) { if (authParameter->mechanism == ACSE_AUTH_PASSWORD)
{
contentLength += 2; contentLength += 2;
//if (authParameter->value.password.passwordLength == 0) //if (authParameter->value.password.passwordLength == 0)
passwordLength = authParameter->value.password.passwordLength; passwordLength = authParameter->value.password.passwordLength;
authValueStringLength = BerEncoder_determineLengthSize(passwordLength); authValueStringLength = BerEncoder_determineLengthSize(
passwordLength);
contentLength += passwordLength + authValueStringLength; contentLength += passwordLength + authValueStringLength;
authValueLength = BerEncoder_determineLengthSize(passwordLength + authValueStringLength + 1); authValueLength = BerEncoder_determineLengthSize(
passwordLength + authValueStringLength + 1);
contentLength += authValueLength; contentLength += authValueLength;
} }
else { else
{
contentLength += 2; contentLength += 2;
} }
} }
@ -654,40 +678,55 @@ AcseConnection_createAssociateRequestMessage(AcseConnection* self,
memcpy(buffer + bufPos, appContextNameMms, 5); memcpy(buffer + bufPos, appContextNameMms, 5);
bufPos += 5; bufPos += 5;
if (isoParameters->remoteApTitleLen > 0) { if (isoParameters->remoteApTitleLen > 0)
{
/* called AP title */ /* called AP title */
bufPos = BerEncoder_encodeTL(0xa2, isoParameters->remoteApTitleLen + 2, buffer, bufPos); bufPos = BerEncoder_encodeTL(0xa2, isoParameters->remoteApTitleLen + 2,
bufPos = BerEncoder_encodeTL(0x06, isoParameters->remoteApTitleLen, buffer, bufPos); buffer, bufPos);
bufPos = BerEncoder_encodeTL(0x06, isoParameters->remoteApTitleLen,
buffer, bufPos);
memcpy(buffer + bufPos, isoParameters->remoteApTitle, isoParameters->remoteApTitleLen); memcpy(buffer + bufPos, isoParameters->remoteApTitle,
isoParameters->remoteApTitleLen);
bufPos += isoParameters->remoteApTitleLen; bufPos += isoParameters->remoteApTitleLen;
/* called AE qualifier */ /* called AE qualifier */
bufPos = BerEncoder_encodeTL(0xa3, calledAEQualifierLength + 2, buffer, bufPos); bufPos = BerEncoder_encodeTL(0xa3, calledAEQualifierLength + 2, buffer,
bufPos = BerEncoder_encodeTL(0x02, calledAEQualifierLength, buffer, bufPos); bufPos);
bufPos = BerEncoder_encodeUInt32(isoParameters->remoteAEQualifier, buffer, bufPos); bufPos = BerEncoder_encodeTL(0x02, calledAEQualifierLength, buffer,
bufPos);
bufPos = BerEncoder_encodeUInt32(isoParameters->remoteAEQualifier,
buffer, bufPos);
} }
if (isoParameters->localApTitleLen > 0) { if (isoParameters->localApTitleLen > 0)
{
/* calling AP title */ /* calling AP title */
bufPos = BerEncoder_encodeTL(0xa6, isoParameters->localApTitleLen + 2, buffer, bufPos); bufPos = BerEncoder_encodeTL(0xa6, isoParameters->localApTitleLen + 2,
bufPos = BerEncoder_encodeTL(0x06, isoParameters->localApTitleLen, buffer, bufPos); buffer, bufPos);
memcpy(buffer + bufPos, isoParameters->localApTitle, isoParameters->localApTitleLen); bufPos = BerEncoder_encodeTL(0x06, isoParameters->localApTitleLen,
buffer, bufPos);
memcpy(buffer + bufPos, isoParameters->localApTitle,
isoParameters->localApTitleLen);
bufPos += isoParameters->localApTitleLen; bufPos += isoParameters->localApTitleLen;
/* calling AE qualifier */ /* calling AE qualifier */
bufPos = BerEncoder_encodeTL(0xa7, callingAEQualifierLength + 2, buffer, bufPos); bufPos = BerEncoder_encodeTL(0xa7, callingAEQualifierLength + 2, buffer,
bufPos = BerEncoder_encodeTL(0x02, callingAEQualifierLength, buffer, bufPos); bufPos);
bufPos = BerEncoder_encodeUInt32(isoParameters->localAEQualifier, buffer, bufPos); bufPos = BerEncoder_encodeTL(0x02, callingAEQualifierLength, buffer,
bufPos);
bufPos = BerEncoder_encodeUInt32(isoParameters->localAEQualifier,
buffer, bufPos);
} }
if (authParameter != NULL) { if (authParameter != NULL)
{
/* sender requirements */ /* sender requirements */
bufPos = BerEncoder_encodeTL(0x8a, 2, buffer, bufPos); bufPos = BerEncoder_encodeTL(0x8a, 2, buffer, bufPos);
buffer[bufPos++] = 0x04; buffer[bufPos++] = 0x04;
if (authParameter->mechanism == ACSE_AUTH_PASSWORD) { if (authParameter->mechanism == ACSE_AUTH_PASSWORD)
{
buffer[bufPos++] = requirements_authentication[0]; buffer[bufPos++] = requirements_authentication[0];
bufPos = BerEncoder_encodeTL(0x8b, 3, buffer, bufPos); bufPos = BerEncoder_encodeTL(0x8b, 3, buffer, bufPos);
@ -695,12 +734,15 @@ AcseConnection_createAssociateRequestMessage(AcseConnection* self,
bufPos += 3; bufPos += 3;
/* authentication value */ /* authentication value */
bufPos = BerEncoder_encodeTL(0xac, authValueStringLength + passwordLength + 1, buffer, bufPos); bufPos = BerEncoder_encodeTL(0xac,
authValueStringLength + passwordLength + 1, buffer, bufPos);
bufPos = BerEncoder_encodeTL(0x80, passwordLength, buffer, bufPos); bufPos = BerEncoder_encodeTL(0x80, passwordLength, buffer, bufPos);
memcpy(buffer + bufPos, authParameter->value.password.octetString, passwordLength); memcpy(buffer + bufPos, authParameter->value.password.octetString,
passwordLength);
bufPos += passwordLength; bufPos += passwordLength;
} }
else { /* AUTH_NONE */ else
{ /* AUTH_NONE */
buffer[bufPos++] = 0; buffer[bufPos++] = 0;
} }
} }

@ -410,7 +410,7 @@ sendRequestAndWaitForResponse(MmsConnection self, uint32_t invokeId, ByteBuffer*
receivedMessage = NULL; receivedMessage = NULL;
} }
connection_lost: connection_lost:
removeFromOutstandingCalls(self, invokeId); removeFromOutstandingCalls(self, invokeId);
@ -471,7 +471,8 @@ convertServiceErrorToMmsError(MmsServiceError serviceError)
{ {
MmsError mmsError; MmsError mmsError;
switch (serviceError.errorClass) { switch (serviceError.errorClass)
{
case 0: /* class: vmd-state */ case 0: /* class: vmd-state */
mmsError = MMS_ERROR_VMDSTATE_OTHER; mmsError = MMS_ERROR_VMDSTATE_OTHER;
break; break;
@ -481,7 +482,8 @@ convertServiceErrorToMmsError(MmsServiceError serviceError)
break; break;
case 2: /* class: definition */ case 2: /* class: definition */
switch (serviceError.errorCode) { switch (serviceError.errorCode)
{
case 1: case 1:
mmsError = MMS_ERROR_DEFINITION_OBJECT_UNDEFINED; mmsError = MMS_ERROR_DEFINITION_OBJECT_UNDEFINED;
break; break;
@ -523,7 +525,8 @@ convertServiceErrorToMmsError(MmsServiceError serviceError)
break; break;
case 7: /* class: access */ case 7: /* class: access */
switch (serviceError.errorCode) { switch (serviceError.errorCode)
{
case 1: case 1:
mmsError = MMS_ERROR_ACCESS_OBJECT_ACCESS_UNSUPPORTED; mmsError = MMS_ERROR_ACCESS_OBJECT_ACCESS_UNSUPPORTED;
break; break;
@ -543,7 +546,8 @@ convertServiceErrorToMmsError(MmsServiceError serviceError)
break; break;
case 11: /* class: file */ case 11: /* class: file */
switch (serviceError.errorCode) { switch (serviceError.errorCode)
{
case 1: case 1:
mmsError = MMS_ERROR_FILE_FILENAME_AMBIGUOUS; mmsError = MMS_ERROR_FILE_FILENAME_AMBIGUOUS;
break; break;
@ -577,7 +581,6 @@ convertServiceErrorToMmsError(MmsServiceError serviceError)
} }
break; break;
default: default:
mmsError = MMS_ERROR_OTHER; mmsError = MMS_ERROR_OTHER;
} }
@ -598,7 +601,8 @@ parseServiceError(uint8_t* buffer, int bufPos, int maxLength, MmsServiceError* e
if (bufPos < 0) if (bufPos < 0)
return -1; return -1;
switch (tag) { switch (tag)
{
case 0xa0: /* errorClass */ case 0xa0: /* errorClass */
{ {
uint8_t errorClassTag = buffer[bufPos++]; uint8_t errorClassTag = buffer[bufPos++];
@ -656,7 +660,8 @@ mmsMsg_parseConfirmedErrorPDU(uint8_t* buffer, int bufPos, int maxBufPos, uint32
if (bufPos < 0) if (bufPos < 0)
goto exit_error; goto exit_error;
switch (tag) { switch (tag)
{
case 0x80: /* invoke Id */ case 0x80: /* invoke Id */
if (invokeId != NULL) if (invokeId != NULL)
*invokeId = BerDecoder_decodeUint32(buffer, length, bufPos); *invokeId = BerDecoder_decodeUint32(buffer, length, bufPos);
@ -678,7 +683,7 @@ mmsMsg_parseConfirmedErrorPDU(uint8_t* buffer, int bufPos, int maxBufPos, uint32
return bufPos; return bufPos;
exit_error: exit_error:
if (DEBUG_MMS_CLIENT) if (DEBUG_MMS_CLIENT)
printf("MMS_CLIENT: error parsing confirmed error PDU\n"); printf("MMS_CLIENT: error parsing confirmed error PDU\n");
@ -714,7 +719,6 @@ mmsMsg_parseRejectPDU(uint8_t* buffer, int bufPos, int maxBufPos, uint32_t* invo
if (bufPos < 0) if (bufPos < 0)
goto exit_error; goto exit_error;
if (tag == 0x80) { /* invoke id */ if (tag == 0x80) { /* invoke id */
if (invokeId != NULL) if (invokeId != NULL)
*invokeId = BerDecoder_decodeUint32(buffer, length, bufPos); *invokeId = BerDecoder_decodeUint32(buffer, length, bufPos);
@ -732,7 +736,7 @@ mmsMsg_parseRejectPDU(uint8_t* buffer, int bufPos, int maxBufPos, uint32_t* invo
return bufPos; return bufPos;
exit_error: exit_error:
if (DEBUG_MMS_CLIENT) if (DEBUG_MMS_CLIENT)
printf("MMS_CLIENT: error parsing reject PDU\n"); printf("MMS_CLIENT: error parsing reject PDU\n");
@ -836,7 +840,8 @@ mmsIsoCallback(IsoIndication indication, void* parameter, ByteBuffer* payload)
if (DEBUG_MMS_CLIENT) if (DEBUG_MMS_CLIENT)
printf("MMS_CLIENT: Confirmed error PDU!\n"); printf("MMS_CLIENT: Confirmed error PDU!\n");
uint32_t invokeId; uint32_t invokeId;
MmsServiceError serviceError = {0, 0}; MmsServiceError serviceError =
{ 0, 0 };
if (mmsMsg_parseConfirmedErrorPDU(payload->buffer, 0, payload->size, &invokeId, &serviceError) < 0) { if (mmsMsg_parseConfirmedErrorPDU(payload->buffer, 0, payload->size, &invokeId, &serviceError) < 0) {
if (DEBUG_MMS_CLIENT) if (DEBUG_MMS_CLIENT)
@ -972,7 +977,8 @@ mmsIsoCallback(IsoIndication indication, void* parameter, ByteBuffer* payload)
goto exit_with_error; goto exit_with_error;
if (extendedTag) { if (extendedTag) {
switch(nestedTag) { switch (nestedTag)
{
#if (MMS_FILE_SERVICE == 1) #if (MMS_FILE_SERVICE == 1)
case 0x48: /* file-open-request */ case 0x48: /* file-open-request */
@ -1032,7 +1038,8 @@ mmsIsoCallback(IsoIndication indication, void* parameter, ByteBuffer* payload)
} }
} }
else { else {
switch(nestedTag) { switch (nestedTag)
{
case 0x02: /* invoke Id */ case 0x02: /* invoke Id */
invokeId = BerDecoder_decodeUint32(buf, length, bufPos); invokeId = BerDecoder_decodeUint32(buf, length, bufPos);
if (DEBUG_MMS_CLIENT) if (DEBUG_MMS_CLIENT)
@ -1040,7 +1047,6 @@ mmsIsoCallback(IsoIndication indication, void* parameter, ByteBuffer* payload)
self->lastInvokeId = invokeId; self->lastInvokeId = invokeId;
break; break;
default: default:
// mmsServer_writeMmsRejectPdu(&invokeId, MMS_ERROR_REJECT_UNRECOGNIZED_SERVICE, response); // mmsServer_writeMmsRejectPdu(&invokeId, MMS_ERROR_REJECT_UNRECOGNIZED_SERVICE, response);
if (DEBUG_MMS_CLIENT) if (DEBUG_MMS_CLIENT)
@ -1057,7 +1063,6 @@ mmsIsoCallback(IsoIndication indication, void* parameter, ByteBuffer* payload)
bufPos += length; bufPos += length;
} }
} }
#endif /* (MMS_OBTAIN_FILE_SERVICE == 1) */ #endif /* (MMS_OBTAIN_FILE_SERVICE == 1) */
@ -1066,14 +1071,13 @@ mmsIsoCallback(IsoIndication indication, void* parameter, ByteBuffer* payload)
return; return;
exit_with_error: exit_with_error:
if (DEBUG_MMS_CLIENT) if (DEBUG_MMS_CLIENT)
printf("MMS_CLIENT: received malformed message from server!\n"); printf("MMS_CLIENT: received malformed message from server!\n");
IsoClientConnection_releaseReceiveBuffer(self->isoClient); IsoClientConnection_releaseReceiveBuffer(self->isoClient);
if (DEBUG_MMS_CLIENT) if (DEBUG_MMS_CLIENT)
printf("MMS_CLIENT: LEAVE mmsIsoCallback - NOT OK!\n"); printf("MMS_CLIENT: LEAVE mmsIsoCallback - NOT OK!\n");
return; return;
@ -1109,7 +1113,7 @@ MmsConnection_create()
/* Load default values for connection parameters */ /* Load default values for connection parameters */
TSelector tSelector = { 2, { 0, 1 } }; TSelector tSelector = { 2, { 0, 1 } };
SSelector sSelector = {2, { 0, 1 } }; SSelector sSelector = { 2, { 0, 1 } };
IsoConnectionParameters_setLocalAddresses(self->isoParameters, 1, sSelector, tSelector); IsoConnectionParameters_setLocalAddresses(self->isoParameters, 1, sSelector, tSelector);
IsoConnectionParameters_setLocalApTitle(self->isoParameters, "1.1.1.999", 12); IsoConnectionParameters_setLocalApTitle(self->isoParameters, "1.1.1.999", 12);
@ -1141,7 +1145,6 @@ MmsConnection_createSecure(TLSConfiguration tlsConfig)
return self; return self;
} }
void void
MmsConnection_destroy(MmsConnection self) MmsConnection_destroy(MmsConnection self)
{ {
@ -1214,7 +1217,6 @@ MmsConnection_setRawMessageHandler(MmsConnection self, MmsRawMessageHandler hand
#endif #endif
} }
void void
MmsConnection_setConnectionLostHandler(MmsConnection self, MmsConnectionLostHandler handler, void* handlerParameter) MmsConnection_setConnectionLostHandler(MmsConnection self, MmsConnectionLostHandler handler, void* handlerParameter)
{ {
@ -1407,7 +1409,7 @@ sendConcludeRequestAndWaitForResponse(MmsConnection self)
self->lastResponseError = MMS_ERROR_SERVICE_TIMEOUT; self->lastResponseError = MMS_ERROR_SERVICE_TIMEOUT;
} }
exit_function: exit_function:
return; return;
} }
@ -1439,7 +1441,7 @@ MmsConnection_conclude(MmsConnection self, MmsError* mmsError)
self->connectionLostHandler = NULL; self->connectionLostHandler = NULL;
exit_function: exit_function:
return; return;
} }
@ -1492,7 +1494,7 @@ mmsClient_getNameListSingleRequest(
releaseResponse(self); releaseResponse(self);
exit_function: exit_function:
return moreFollows; return moreFollows;
} }
@ -1584,7 +1586,7 @@ MmsConnection_readVariable(MmsConnection self, MmsError* mmsError,
releaseResponse(self); releaseResponse(self);
exit_function: exit_function:
return value; return value;
} }
@ -1614,7 +1616,7 @@ MmsConnection_readArrayElements(MmsConnection self, MmsError* mmsError,
releaseResponse(self); releaseResponse(self);
exit_function: exit_function:
return value; return value;
} }
@ -1642,7 +1644,7 @@ MmsConnection_readMultipleVariables(MmsConnection self, MmsError* mmsError,
releaseResponse(self); releaseResponse(self);
exit_function: exit_function:
return value; return value;
} }
@ -1672,7 +1674,7 @@ MmsConnection_readNamedVariableListValues(MmsConnection self, MmsError* mmsError
releaseResponse(self); releaseResponse(self);
exit_function: exit_function:
return value; return value;
} }
@ -1703,7 +1705,7 @@ MmsConnection_readNamedVariableListValuesAssociationSpecific(
releaseResponse(self); releaseResponse(self);
exit_function: exit_function:
return value; return value;
} }
@ -1733,7 +1735,7 @@ MmsConnection_readNamedVariableListDirectory(MmsConnection self, MmsError* mmsEr
releaseResponse(self); releaseResponse(self);
exit_function: exit_function:
return attributes; return attributes;
} }
@ -1763,7 +1765,7 @@ MmsConnection_readNamedVariableListDirectoryAssociationSpecific(MmsConnection se
releaseResponse(self); releaseResponse(self);
exit_function: exit_function:
return attributes; return attributes;
} }
@ -1791,7 +1793,7 @@ MmsConnection_defineNamedVariableList(MmsConnection self, MmsError* mmsError,
releaseResponse(self); releaseResponse(self);
exit_function: exit_function:
return; return;
} }
@ -1819,8 +1821,7 @@ MmsConnection_defineNamedVariableListAssociationSpecific(MmsConnection self,
releaseResponse(self); releaseResponse(self);
exit_function:
exit_function:
return; return;
} }
@ -1849,7 +1850,7 @@ MmsConnection_deleteNamedVariableList(MmsConnection self, MmsError* mmsError,
releaseResponse(self); releaseResponse(self);
exit_function: exit_function:
return isDeleted; return isDeleted;
} }
@ -1879,7 +1880,7 @@ MmsConnection_deleteAssociationSpecificNamedVariableList(MmsConnection self,
releaseResponse(self); releaseResponse(self);
exit_function: exit_function:
return isDeleted; return isDeleted;
} }
@ -1907,7 +1908,7 @@ MmsConnection_getVariableAccessAttributes(MmsConnection self, MmsError* mmsError
releaseResponse(self); releaseResponse(self);
exit_function: exit_function:
return typeSpec; return typeSpec;
} }
@ -1934,13 +1935,13 @@ MmsConnection_identify(MmsConnection self, MmsError* mmsError)
releaseResponse(self); releaseResponse(self);
exit_function: exit_function:
return identity; return identity;
} }
void void
MmsConnection_getServerStatus(MmsConnection self, MmsError* mmsError, int* vmdLogicalStatus, int* vmdPhysicalStatus, MmsConnection_getServerStatus(MmsConnection self, MmsError* mmsError, int* vmdLogicalStatus, int* vmdPhysicalStatus,
bool extendedDerivation) bool extendedDerivation)
{ {
ByteBuffer* payload = IsoClientConnection_allocateTransmitBuffer(self->isoClient); ByteBuffer* payload = IsoClientConnection_allocateTransmitBuffer(self->isoClient);
@ -1998,7 +1999,6 @@ MmsJournalEntry_destroy(MmsJournalEntry self)
} }
} }
const MmsValue* const MmsValue*
MmsJournalEntry_getEntryID(MmsJournalEntry self) MmsJournalEntry_getEntryID(MmsJournalEntry self)
{ {
@ -2158,7 +2158,6 @@ MmsConnection_fileRead(MmsConnection self, MmsError* mmsError, int32_t frsmId, M
return moreFollows; return moreFollows;
} }
bool bool
MmsConnection_getFileDirectory(MmsConnection self, MmsError* mmsError, const char* fileSpecification, const char* continueAfter, MmsConnection_getFileDirectory(MmsConnection self, MmsError* mmsError, const char* fileSpecification, const char* continueAfter,
MmsFileDirectoryHandler handler, void* handlerParameter) MmsFileDirectoryHandler handler, void* handlerParameter)
@ -2199,7 +2198,6 @@ MmsConnection_fileRename(MmsConnection self, MmsError* mmsError, const char* cur
releaseResponse(self); releaseResponse(self);
} }
void void
MmsConnection_obtainFile(MmsConnection self, MmsError* mmsError, const char* sourceFile, const char* destinationFile) MmsConnection_obtainFile(MmsConnection self, MmsError* mmsError, const char* sourceFile, const char* destinationFile)
{ {
@ -2359,13 +2357,13 @@ void
MmsVariableAccessSpecification_destroy(MmsVariableAccessSpecification* self) MmsVariableAccessSpecification_destroy(MmsVariableAccessSpecification* self)
{ {
if (self->domainId != NULL) if (self->domainId != NULL)
GLOBAL_FREEMEM((void*) self->domainId); GLOBAL_FREEMEM((void* ) self->domainId);
if (self->itemId != NULL) if (self->itemId != NULL)
GLOBAL_FREEMEM((void*) self->itemId); GLOBAL_FREEMEM((void* ) self->itemId);
if (self->componentName != NULL) if (self->componentName != NULL)
GLOBAL_FREEMEM((void*) self->componentName); GLOBAL_FREEMEM((void* ) self->componentName);
GLOBAL_FREEMEM(self); GLOBAL_FREEMEM(self);
} }

@ -31,11 +31,13 @@
#include "mms_client_internal.h" #include "mms_client_internal.h"
static MmsVariableSpecification* static MmsVariableSpecification*
createTypeSpecification(TypeSpecification_t* asnTypeSpec) { createTypeSpecification(TypeSpecification_t* asnTypeSpec)
{
MmsVariableSpecification* typeSpec = (MmsVariableSpecification*) MmsVariableSpecification* typeSpec = (MmsVariableSpecification*)
GLOBAL_CALLOC(1, sizeof(MmsVariableSpecification)); GLOBAL_CALLOC(1, sizeof(MmsVariableSpecification));
switch (asnTypeSpec->present) { switch (asnTypeSpec->present)
{
case TypeSpecification_PR_structure: case TypeSpecification_PR_structure:
{ {
typeSpec->type = MMS_STRUCTURE; typeSpec->type = MMS_STRUCTURE;

@ -153,7 +153,6 @@ mmsClient_parseDeleteNamedVariableListResponse(ByteBuffer* message, uint32_t* in
return retVal; return retVal;
} }
void void
mmsClient_createGetNamedVariableListAttributesRequest(uint32_t invokeId, ByteBuffer* writeBuffer, mmsClient_createGetNamedVariableListAttributesRequest(uint32_t invokeId, ByteBuffer* writeBuffer,
const char* domainId, const char* listNameId) const char* domainId, const char* listNameId)
@ -227,7 +226,6 @@ parseNamedVariableAttributes(GetNamedVariableListAttributesResponse_t* response,
char* domainId; char* domainId;
char* itemId; char* itemId;
if (response->listOfVariable.list.array[i]->variableSpecification.choice.name.present == ObjectName_PR_vmdspecific) { if (response->listOfVariable.list.array[i]->variableSpecification.choice.name.present == ObjectName_PR_vmdspecific) {
domainId = NULL; domainId = NULL;
@ -252,8 +250,7 @@ parseNamedVariableAttributes(GetNamedVariableListAttributesResponse_t* response,
} }
LinkedList /* <MmsVariableAccessSpecification*> */ LinkedList /* <MmsVariableAccessSpecification*> */
mmsClient_parseGetNamedVariableListAttributesResponse(ByteBuffer* message, uint32_t* invokeId, mmsClient_parseGetNamedVariableListAttributesResponse(ByteBuffer* message, uint32_t* invokeId, bool* /*OUT*/deletable)
bool* /*OUT*/ deletable)
{ {
MmsPdu_t* mmsPdu = 0; MmsPdu_t* mmsPdu = 0;
@ -262,7 +259,6 @@ mmsClient_parseGetNamedVariableListAttributesResponse(ByteBuffer* message, uint3
asn_dec_rval_t rval = ber_decode(NULL, &asn_DEF_MmsPdu, asn_dec_rval_t rval = ber_decode(NULL, &asn_DEF_MmsPdu,
(void**) &mmsPdu, ByteBuffer_getBuffer(message), ByteBuffer_getSize(message)); (void**) &mmsPdu, ByteBuffer_getBuffer(message), ByteBuffer_getSize(message));
if (rval.code == RC_OK) { if (rval.code == RC_OK) {
if (mmsPdu->present == MmsPdu_PR_confirmedResponsePdu) { if (mmsPdu->present == MmsPdu_PR_confirmedResponsePdu) {
@ -284,14 +280,13 @@ mmsClient_parseGetNamedVariableListAttributesResponse(ByteBuffer* message, uint3
return attributes; return attributes;
} }
void void
mmsClient_createDefineNamedVariableListRequest( mmsClient_createDefineNamedVariableListRequest(
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* writeBuffer, ByteBuffer* writeBuffer,
const char* domainId, const char* domainId,
const char* listNameId, const char* listNameId,
LinkedList /*<MmsVariableSpecification*>*/ listOfVariables, LinkedList /*<MmsVariableSpecification*>*/listOfVariables,
bool associationSpecific) bool associationSpecific)
{ {
MmsPdu_t* mmsPdu = mmsClient_createConfirmedRequestPdu(invokeId); MmsPdu_t* mmsPdu = mmsClient_createConfirmedRequestPdu(invokeId);
@ -392,7 +387,6 @@ mmsClient_createDefineNamedVariableListRequest(
componentAccess->list.array[0]->present = AlternateAccess__Member_PR_unnamed; componentAccess->list.array[0]->present = AlternateAccess__Member_PR_unnamed;
componentAccess->list.array[0]->choice.unnamed = (AlternateAccessSelection_t*) GLOBAL_CALLOC(1, sizeof(AlternateAccessSelection_t)); componentAccess->list.array[0]->choice.unnamed = (AlternateAccessSelection_t*) GLOBAL_CALLOC(1, sizeof(AlternateAccessSelection_t));
componentAccess->list.array[0]->choice.unnamed->present = AlternateAccessSelection_PR_selectAccess; componentAccess->list.array[0]->choice.unnamed->present = AlternateAccessSelection_PR_selectAccess;
componentAccess->list.array[0]->choice.unnamed->choice.selectAccess.present = componentAccess->list.array[0]->choice.unnamed->choice.selectAccess.present =
AlternateAccessSelection__selectAccess_PR_component; AlternateAccessSelection__selectAccess_PR_component;
@ -410,7 +404,6 @@ mmsClient_createDefineNamedVariableListRequest(
request->listOfVariable.list.array[i]->alternateAccess = alternateAccess; request->listOfVariable.list.array[i]->alternateAccess = alternateAccess;
} }
element = LinkedList_getNext(element); element = LinkedList_getNext(element);
i++; i++;
@ -433,7 +426,6 @@ mmsClient_parseDefineNamedVariableResponse(ByteBuffer* message, uint32_t* invoke
rval = ber_decode(NULL, &asn_DEF_MmsPdu, rval = ber_decode(NULL, &asn_DEF_MmsPdu,
(void**) &mmsPdu, ByteBuffer_getBuffer(message), ByteBuffer_getSize(message)); (void**) &mmsPdu, ByteBuffer_getBuffer(message), ByteBuffer_getSize(message));
if (rval.code == RC_OK) { if (rval.code == RC_OK) {
if (mmsPdu->present == MmsPdu_PR_confirmedResponsePdu) { if (mmsPdu->present == MmsPdu_PR_confirmedResponsePdu) {
if (invokeId != NULL) if (invokeId != NULL)

@ -49,7 +49,8 @@ mmsClient_parseListOfAccessResults(AccessResult_t** accessResultList, int listSi
AccessResult_PR presentType = accessResultList[i]->present; AccessResult_PR presentType = accessResultList[i]->present;
if (presentType == AccessResult_PR_failure) { if (presentType == AccessResult_PR_failure) {
if (DEBUG_MMS_CLIENT) printf("access error!\n"); if (DEBUG_MMS_CLIENT)
printf("access error!\n");
if (accessResultList[i]->choice.failure.size > 0) { if (accessResultList[i]->choice.failure.size > 0) {
int errorCode = (int) accessResultList[i]->choice.failure.buf[0]; int errorCode = (int) accessResultList[i]->choice.failure.buf[0];
@ -239,7 +240,6 @@ mmsClient_parseListOfAccessResults(AccessResult_t** accessResultList, int listSi
return valueList; return valueList;
} }
/* /*
* \param createArray if multiple variables should be read (e.g. if a data set is read) an array should * \param createArray if multiple variables should be read (e.g. if a data set is read) an array should
* be created that contains the access results. * be created that contains the access results.
@ -277,9 +277,8 @@ mmsClient_parseReadResponse(ByteBuffer* message, uint32_t* invokeId, bool create
return valueList; return valueList;
} }
static ReadRequest_t* static ReadRequest_t*
createReadRequest (MmsPdu_t* mmsPdu) createReadRequest(MmsPdu_t* mmsPdu)
{ {
mmsPdu->choice.confirmedRequestPdu.confirmedServiceRequest.present = mmsPdu->choice.confirmedRequestPdu.confirmedServiceRequest.present =
ConfirmedServiceRequest_PR_read; ConfirmedServiceRequest_PR_read;
@ -287,7 +286,6 @@ createReadRequest (MmsPdu_t* mmsPdu)
return &(mmsPdu->choice.confirmedRequestPdu.confirmedServiceRequest.choice.read); return &(mmsPdu->choice.confirmedRequestPdu.confirmedServiceRequest.choice.read);
} }
int int
mmsClient_createReadNamedVariableListRequest(uint32_t invokeId, const char* domainId, const char* itemId, mmsClient_createReadNamedVariableListRequest(uint32_t invokeId, const char* domainId, const char* itemId,
ByteBuffer* writeBuffer, bool specWithResult) ByteBuffer* writeBuffer, bool specWithResult)
@ -307,7 +305,6 @@ mmsClient_createReadNamedVariableListRequest(uint32_t invokeId, const char* doma
ObjectName_t* objectName = &(readRequest->variableAccessSpecification.choice.variableListName); ObjectName_t* objectName = &(readRequest->variableAccessSpecification.choice.variableListName);
if (domainId != NULL) { if (domainId != NULL) {
objectName->present = ObjectName_PR_domainspecific; objectName->present = ObjectName_PR_domainspecific;
@ -515,7 +512,8 @@ mmsClient_createReadRequestAlternateAccessIndex(uint32_t invokeId, const char* d
} }
static ListOfVariableSeq_t** static ListOfVariableSeq_t**
createListOfVariables(ReadRequest_t* readRequest, int valuesCount) { createListOfVariables(ReadRequest_t* readRequest, int valuesCount)
{
readRequest->variableAccessSpecification.present = VariableAccessSpecification_PR_listOfVariable; readRequest->variableAccessSpecification.present = VariableAccessSpecification_PR_listOfVariable;
readRequest->variableAccessSpecification.choice.listOfVariable.list.array = (ListOfVariableSeq_t**) readRequest->variableAccessSpecification.choice.listOfVariable.list.array = (ListOfVariableSeq_t**)
@ -566,7 +564,6 @@ mmsClient_createReadRequestMultipleValues(uint32_t invokeId, const char* domainI
readRequest->variableAccessSpecification.choice.listOfVariable.list.size = 0; readRequest->variableAccessSpecification.choice.listOfVariable.list.size = 0;
readRequest->variableAccessSpecification.choice.listOfVariable.list.array = NULL; readRequest->variableAccessSpecification.choice.listOfVariable.list.array = NULL;
asn_DEF_MmsPdu.free_struct(&asn_DEF_MmsPdu, mmsPdu, 0); asn_DEF_MmsPdu.free_struct(&asn_DEF_MmsPdu, mmsPdu, 0);
return rval.encoded; return rval.encoded;

@ -102,7 +102,8 @@ bool
MmsValue_equals(const MmsValue* self, const MmsValue* otherValue) MmsValue_equals(const MmsValue* self, const MmsValue* otherValue)
{ {
if (self->type == otherValue->type) { if (self->type == otherValue->type) {
switch (self->type) { switch (self->type)
{
case MMS_ARRAY: case MMS_ARRAY:
case MMS_STRUCTURE: case MMS_STRUCTURE:
if (self->value.structure.size == otherValue->value.structure.size) { if (self->value.structure.size == otherValue->value.structure.size) {
@ -174,8 +175,6 @@ MmsValue_equals(const MmsValue* self, const MmsValue* otherValue)
} }
break; break;
case MMS_DATA_ACCESS_ERROR: case MMS_DATA_ACCESS_ERROR:
if (self->value.dataAccessError == otherValue->value.dataAccessError) if (self->value.dataAccessError == otherValue->value.dataAccessError)
return true; return true;
@ -195,7 +194,8 @@ bool
MmsValue_equalTypes(const MmsValue* self, const MmsValue* otherValue) MmsValue_equalTypes(const MmsValue* self, const MmsValue* otherValue)
{ {
if (self->type == otherValue->type) { if (self->type == otherValue->type) {
switch (self->type) { switch (self->type)
{
case MMS_ARRAY: case MMS_ARRAY:
case MMS_STRUCTURE: case MMS_STRUCTURE:
if (self->value.structure.size == otherValue->value.structure.size) { if (self->value.structure.size == otherValue->value.structure.size) {
@ -226,7 +226,8 @@ bool
MmsValue_update(MmsValue* self, const MmsValue* update) MmsValue_update(MmsValue* self, const MmsValue* update)
{ {
if (self->type == update->type) { if (self->type == update->type) {
switch (self->type) { switch (self->type)
{
case MMS_STRUCTURE: case MMS_STRUCTURE:
case MMS_ARRAY: case MMS_ARRAY:
if (updateStructuredComponent(self, update) == false) if (updateStructuredComponent(self, update) == false)
@ -314,7 +315,8 @@ MmsValue_newDataAccessError(MmsDataAccessError accessError)
MmsValue* MmsValue*
MmsValue_newBitString(int bitSize) MmsValue_newBitString(int bitSize)
{ {
MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));; MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
;
if (self == NULL) if (self == NULL)
return NULL; return NULL;
@ -449,7 +451,8 @@ MmsValue_getBitStringBit(const MmsValue* self, int bitPos)
return false; return false;
} }
else return false; /* out of range bits are always zero */ else
return false; /* out of range bits are always zero */
} }
uint32_t uint32_t
@ -518,11 +521,11 @@ MmsValue_setBitStringFromIntegerBigEndian(MmsValue* self, uint32_t intValue)
} }
} }
MmsValue* MmsValue*
MmsValue_newFloat(float variable) MmsValue_newFloat(float variable)
{ {
MmsValue* self = (MmsValue*) GLOBAL_MALLOC(sizeof(MmsValue));; MmsValue* self = (MmsValue*) GLOBAL_MALLOC(sizeof(MmsValue));
;
if (self == NULL) if (self == NULL)
return NULL; return NULL;
@ -584,7 +587,8 @@ MmsValue_newDouble(double variable)
MmsValue* MmsValue*
MmsValue_newIntegerFromInt8(int8_t integer) MmsValue_newIntegerFromInt8(int8_t integer)
{ {
MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));; MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
;
self->type = MMS_INTEGER; self->type = MMS_INTEGER;
self->value.integer = BerInteger_createFromInt32((int32_t) integer); self->value.integer = BerInteger_createFromInt32((int32_t) integer);
@ -595,7 +599,8 @@ MmsValue_newIntegerFromInt8(int8_t integer)
MmsValue* MmsValue*
MmsValue_newIntegerFromInt16(int16_t integer) MmsValue_newIntegerFromInt16(int16_t integer)
{ {
MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));; MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
;
self->type = MMS_INTEGER; self->type = MMS_INTEGER;
self->value.integer = BerInteger_createFromInt32((int32_t) integer); self->value.integer = BerInteger_createFromInt32((int32_t) integer);
@ -653,7 +658,6 @@ MmsValue_setUint32(MmsValue* self, uint32_t integer)
} }
} }
void void
MmsValue_setUint16(MmsValue* self, uint16_t integer) MmsValue_setUint16(MmsValue* self, uint16_t integer)
{ {
@ -664,7 +668,6 @@ MmsValue_setUint16(MmsValue* self, uint16_t integer)
} }
} }
void void
MmsValue_setUint8(MmsValue* self, uint8_t integer) MmsValue_setUint8(MmsValue* self, uint8_t integer)
{ {
@ -676,7 +679,6 @@ MmsValue_setUint8(MmsValue* self, uint8_t integer)
} }
void void
MmsValue_setBoolean(MmsValue* self, bool boolValue) MmsValue_setBoolean(MmsValue* self, bool boolValue)
{ {
@ -689,7 +691,6 @@ MmsValue_getBoolean(const MmsValue* self)
return self->value.boolean; return self->value.boolean;
} }
MmsValue* MmsValue*
MmsValue_setUtcTime(MmsValue* self, uint32_t timeval) MmsValue_setUtcTime(MmsValue* self, uint32_t timeval)
{ {
@ -705,7 +706,6 @@ MmsValue_setUtcTime(MmsValue* self, uint32_t timeval)
return self; return self;
} }
MmsValue* MmsValue*
MmsValue_setUtcTimeMs(MmsValue* self, uint64_t timeval) MmsValue_setUtcTimeMs(MmsValue* self, uint64_t timeval)
{ {
@ -816,7 +816,6 @@ MmsValue_getUtcTimeInMsWithUs(const MmsValue* self, uint32_t* usec)
return msVal; return msVal;
} }
MmsValue* MmsValue*
MmsValue_newIntegerFromInt32(int32_t integer) MmsValue_newIntegerFromInt32(int32_t integer)
{ {
@ -834,7 +833,8 @@ MmsValue_newIntegerFromInt32(int32_t integer)
MmsValue* MmsValue*
MmsValue_newUnsignedFromUint32(uint32_t integer) MmsValue_newUnsignedFromUint32(uint32_t integer)
{ {
MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));; MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
;
if (self == NULL) if (self == NULL)
return NULL; return NULL;
@ -848,7 +848,8 @@ MmsValue_newUnsignedFromUint32(uint32_t integer)
MmsValue* MmsValue*
MmsValue_newIntegerFromInt64(int64_t integer) MmsValue_newIntegerFromInt64(int64_t integer)
{ {
MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));; MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
;
if (self == NULL) if (self == NULL)
return NULL; return NULL;
@ -938,8 +939,6 @@ MmsValue_toDouble(const MmsValue* self)
return 0.f; return 0.f;
} }
uint32_t uint32_t
MmsValue_toUnixTimestamp(const MmsValue* self) MmsValue_toUnixTimestamp(const MmsValue* self)
{ {
@ -966,7 +965,8 @@ MmsValue_getSizeInMemory(const MmsValue* self)
{ {
int memorySize = MemoryAllocator_getAlignedSize(sizeof(MmsValue)); int memorySize = MemoryAllocator_getAlignedSize(sizeof(MmsValue));
switch(self->type) { switch (self->type)
{
case MMS_ARRAY: case MMS_ARRAY:
case MMS_STRUCTURE: case MMS_STRUCTURE:
{ {
@ -1016,7 +1016,8 @@ MmsValue_cloneToBuffer(const MmsValue* self, uint8_t* destinationAddress)
memcpy(destinationAddress, self, sizeof(MmsValue)); memcpy(destinationAddress, self, sizeof(MmsValue));
destinationAddress += MemoryAllocator_getAlignedSize(sizeof(MmsValue)); destinationAddress += MemoryAllocator_getAlignedSize(sizeof(MmsValue));
switch (self->type) { switch (self->type)
{
case MMS_ARRAY: case MMS_ARRAY:
case MMS_STRUCTURE: case MMS_STRUCTURE:
{ {
@ -1025,7 +1026,7 @@ MmsValue_cloneToBuffer(const MmsValue* self, uint8_t* destinationAddress)
int i; int i;
for (i = 0; i < self->value.structure.size; i++) { for (i = 0; i < self->value.structure.size; i++) {
memcpy(&(newValue->value.structure.components[i]), &(destinationAddress), sizeof (MmsValue*)); memcpy(&(newValue->value.structure.components[i]), &(destinationAddress), sizeof(MmsValue*));
destinationAddress = MmsValue_cloneToBuffer(self->value.structure.components[i], destinationAddress); destinationAddress = MmsValue_cloneToBuffer(self->value.structure.components[i], destinationAddress);
} }
} }
@ -1094,7 +1095,8 @@ MmsValue_clone(const MmsValue* self)
newValue->type = self->type; newValue->type = self->type;
int size; int size;
switch(self->type) { switch (self->type)
{
case MMS_ARRAY: case MMS_ARRAY:
case MMS_STRUCTURE: case MMS_STRUCTURE:
@ -1167,7 +1169,7 @@ MmsValue_clone(const MmsValue* self)
break; break;
} }
exit_function: exit_function:
return newValue; return newValue;
} }
@ -1187,7 +1189,8 @@ MmsValue_deleteIfNotNull(MmsValue* self)
void void
MmsValue_delete(MmsValue* self) MmsValue_delete(MmsValue* self)
{ {
switch (self->type) { switch (self->type)
{
case MMS_INTEGER: case MMS_INTEGER:
case MMS_UNSIGNED: case MMS_UNSIGNED:
Asn1PrimitiveValue_destroy(self->value.integer); Asn1PrimitiveValue_destroy(self->value.integer);
@ -1232,7 +1235,8 @@ MmsValue_deleteConditional(MmsValue* self)
{ {
if (self->deleteValue == 1) { if (self->deleteValue == 1) {
switch (self->type) { switch (self->type)
{
case MMS_INTEGER: case MMS_INTEGER:
case MMS_UNSIGNED: case MMS_UNSIGNED:
Asn1PrimitiveValue_destroy(self->value.integer); Asn1PrimitiveValue_destroy(self->value.integer);
@ -1396,7 +1400,8 @@ MmsValue_newDefaultValue(const MmsVariableSpecification* typeSpec)
{ {
MmsValue* self = NULL; MmsValue* self = NULL;
switch (typeSpec->type) { switch (typeSpec->type)
{
case MMS_INTEGER: case MMS_INTEGER:
self = MmsValue_newInteger(typeSpec->typeSpec.integer); self = MmsValue_newInteger(typeSpec->typeSpec.integer);
break; break;
@ -1493,7 +1498,7 @@ MmsValue_newDefaultValue(const MmsVariableSpecification* typeSpec)
if (self != NULL) if (self != NULL)
self->deleteValue = 0; self->deleteValue = 0;
exit_function: exit_function:
return self; return self;
} }
@ -1522,7 +1527,7 @@ setVisibleStringValue(MmsValue* self, const char* string)
self->value.visibleString.buf[0] = 0; self->value.visibleString.buf[0] = 0;
} }
exit_function: exit_function:
return; return;
} }
@ -1555,7 +1560,7 @@ MmsValue_newString(const char* string, MmsType type)
setVisibleStringValue(self, string); setVisibleStringValue(self, string);
} }
exit_function: exit_function:
return self; return self;
} }
@ -1586,7 +1591,7 @@ MmsValue_newStringWithSize(int size, MmsType type)
self->value.visibleString.buf[0] = 0; self->value.visibleString.buf[0] = 0;
exit_function: exit_function:
return self; return self;
} }
@ -1608,7 +1613,6 @@ MmsValue_newMmsStringWithSize(int size)
return MmsValue_newStringWithSize(size, MMS_STRING); return MmsValue_newStringWithSize(size, MMS_STRING);
} }
MmsValue* MmsValue*
MmsValue_newBinaryTime(bool timeOfDay) MmsValue_newBinaryTime(bool timeOfDay)
{ {
@ -1687,7 +1691,6 @@ MmsValue_getBinaryTimeAsUtcMs(const MmsValue* self)
mmsTime = daysDiff * (86400000LL); mmsTime = daysDiff * (86400000LL);
timestamp = mmsTime + (441763200000LL); timestamp = mmsTime + (441763200000LL);
} }
@ -1738,7 +1741,7 @@ MmsValue_newStringFromByteArray(const uint8_t* byteArray, int size, MmsType type
self = NULL; self = NULL;
} }
exit_function: exit_function:
return self; return self;
} }
@ -1807,11 +1810,10 @@ MmsValue_newUtcTime(uint32_t timeval)
valueArray[3] = timeArray[3]; valueArray[3] = timeArray[3];
#endif #endif
exit_function: exit_function:
return self; return self;
} }
MmsValue* MmsValue*
MmsValue_newUtcTimeByMsTime(uint64_t timeval) MmsValue_newUtcTimeByMsTime(uint64_t timeval)
{ {
@ -1855,7 +1857,7 @@ MmsValue_createArray(MmsVariableSpecification* elementType, int size)
} }
} }
exit_function: exit_function:
return self; return self;
} }
@ -1882,7 +1884,7 @@ MmsValue_createEmptyArray(int size)
self->value.structure.components[i] = NULL; self->value.structure.components[i] = NULL;
} }
exit_function: exit_function:
return self; return self;
} }
@ -1967,7 +1969,8 @@ MmsValue_getSubElement(MmsValue* self, MmsVariableSpecification* varSpec, char*
char* char*
MmsValue_getTypeString(MmsValue* self) MmsValue_getTypeString(MmsValue* self)
{ {
switch (MmsValue_getType(self)) { switch (MmsValue_getType(self))
{
case MMS_ARRAY: case MMS_ARRAY:
return "array"; return "array";
case MMS_BCD: case MMS_BCD:
@ -2008,11 +2011,13 @@ MmsValue_getTypeString(MmsValue* self)
const char* const char*
MmsValue_printToBuffer(const MmsValue* self, char* buffer, int bufferSize) MmsValue_printToBuffer(const MmsValue* self, char* buffer, int bufferSize)
{ {
switch (MmsValue_getType(self)) { switch (MmsValue_getType(self))
{
case MMS_STRUCTURE: case MMS_STRUCTURE:
case MMS_ARRAY: case MMS_ARRAY:
{ {
if (bufferSize==0) break; if (bufferSize == 0)
break;
buffer[0] = '{'; buffer[0] = '{';
int bufPos = 1; int bufPos = 1;

@ -61,7 +61,6 @@ getDomainNames(MmsServerConnection connection)
return list; return list;
} }
#if (CONFIG_MMS_SUPPORT_VMD_SCOPE_NAMED_VARIABLES == 1) #if (CONFIG_MMS_SUPPORT_VMD_SCOPE_NAMED_VARIABLES == 1)
static LinkedList static LinkedList
getNameListVMDSpecific(MmsServerConnection connection) getNameListVMDSpecific(MmsServerConnection connection)
@ -80,7 +79,6 @@ getNameListVMDSpecific(MmsServerConnection connection)
} }
#endif /* (CONFIG_MMS_SUPPORT_VMD_SCOPE_NAMED_VARIABLES == 1) */ #endif /* (CONFIG_MMS_SUPPORT_VMD_SCOPE_NAMED_VARIABLES == 1) */
#if (CONFIG_MMS_SORT_NAME_LIST == 1) #if (CONFIG_MMS_SORT_NAME_LIST == 1)
static void static void
sortIndex(int* index, int size, MmsVariableSpecification** namedVariables) sortIndex(int* index, int size, MmsVariableSpecification** namedVariables)
@ -173,9 +171,6 @@ addSubNamedVaribleNamesToList(LinkedList nameList, char* prefix, MmsVariableSpec
#endif /* (CONFIG_MMS_SUPPORT_FLATTED_NAME_SPACE == 1) */ #endif /* (CONFIG_MMS_SUPPORT_FLATTED_NAME_SPACE == 1) */
static LinkedList static LinkedList
getJournalListDomainSpecific(MmsServerConnection connection, char* domainName) getJournalListDomainSpecific(MmsServerConnection connection, char* domainName)
{ {
@ -259,7 +254,6 @@ getNameListDomainSpecific(MmsServerConnection connection, char* domainName)
return nameList; return nameList;
} }
#if (MMS_DATA_SET_SERVICE == 1) #if (MMS_DATA_SET_SERVICE == 1)
static LinkedList static LinkedList
@ -459,7 +453,8 @@ mmsServer_handleGetNameListRequest(
return; return;
} }
switch (tag) { switch (tag)
{
case 0xa0: /* objectClass */ case 0xa0: /* objectClass */
bufPos++; bufPos++;
@ -477,7 +472,8 @@ mmsServer_handleGetNameListRequest(
return; return;
} }
switch (objectScopeTag) { switch (objectScopeTag)
{
case 0x80: /* vmd-specific */ case 0x80: /* vmd-specific */
objectScope = OBJECT_SCOPE_VMD; objectScope = OBJECT_SCOPE_VMD;
break; break;
@ -508,7 +504,6 @@ mmsServer_handleGetNameListRequest(
bufPos += length; bufPos += length;
} }
char continueAfterIdMemory[130]; char continueAfterIdMemory[130];
char* continueAfterId = NULL; char* continueAfterId = NULL;
@ -573,7 +568,8 @@ mmsServer_handleGetNameListRequest(
#endif /* (MMS_DATA_SET_SERVICE == 1) */ #endif /* (MMS_DATA_SET_SERVICE == 1) */
else { else {
if (DEBUG_MMS_SERVER) printf("MMS_SERVER: getNameList domain specific objectClass %i not supported!\n", objectClass); if (DEBUG_MMS_SERVER)
printf("MMS_SERVER: getNameList domain specific objectClass %i not supported!\n", objectClass);
mmsMsg_createServiceErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_ACCESS_UNSUPPORTED); mmsMsg_createServiceErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_ACCESS_UNSUPPORTED);
} }
@ -631,7 +627,8 @@ mmsServer_handleGetNameListRequest(
} }
else { else {
if (DEBUG_MMS_SERVER) printf("MMS_SERVER: getNameList VMD specific objectClass %i not supported!\n", objectClass); if (DEBUG_MMS_SERVER)
printf("MMS_SERVER: getNameList VMD specific objectClass %i not supported!\n", objectClass);
mmsMsg_createServiceErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_ACCESS_UNSUPPORTED); mmsMsg_createServiceErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_ACCESS_UNSUPPORTED);
} }
@ -659,11 +656,12 @@ mmsServer_handleGetNameListRequest(
#endif /* (MMS_DATA_SET_SERVICE == 1) */ #endif /* (MMS_DATA_SET_SERVICE == 1) */
else { else {
if (DEBUG_MMS_SERVER) printf("MMS_SERVER: getNameList(%i) not supported!\n", objectScope); if (DEBUG_MMS_SERVER)
printf("MMS_SERVER: getNameList(%i) not supported!\n", objectScope);
mmsMsg_createServiceErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_ACCESS_UNSUPPORTED); mmsMsg_createServiceErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_ACCESS_UNSUPPORTED);
} }
} }
#endif /* (MMS_GET_NAME_LIST == 1) */ #endif /* (MMS_GET_NAME_LIST == 1) */

@ -100,7 +100,8 @@ mmsMsg_createMmsRejectPdu(uint32_t* invokeId, int reason, ByteBuffer* response)
int rejectType = 0; int rejectType = 0;
int rejectReason = 0; int rejectReason = 0;
switch (reason) { switch (reason)
{
case MMS_ERROR_REJECT_UNRECOGNIZED_SERVICE: case MMS_ERROR_REJECT_UNRECOGNIZED_SERVICE:
rejectType = MMS_REJECT_CONFIRMED_REQUEST; rejectType = MMS_REJECT_CONFIRMED_REQUEST;
@ -166,7 +167,8 @@ handleConfirmedRequestPdu(
} }
if (extendedTag) { if (extendedTag) {
switch(tag) { switch (tag)
{
#if (MMS_OBTAIN_FILE_SERVICE == 1) #if (MMS_OBTAIN_FILE_SERVICE == 1)
case 0x2e: /* obtain-file */ case 0x2e: /* obtain-file */
@ -213,7 +215,8 @@ handleConfirmedRequestPdu(
} }
} }
else { else {
switch(tag) { switch (tag)
{
case 0x02: /* invoke Id */ case 0x02: /* invoke Id */
invokeId = BerDecoder_decodeUint32(buffer, length, bufPos); invokeId = BerDecoder_decodeUint32(buffer, length, bufPos);
if (DEBUG_MMS_SERVER) if (DEBUG_MMS_SERVER)
@ -260,7 +263,6 @@ handleConfirmedRequestPdu(
break; break;
#endif /* MMS_GET_VARIABLE_ACCESS_ATTRIBUTES == 1 */ #endif /* MMS_GET_VARIABLE_ACCESS_ATTRIBUTES == 1 */
#if (MMS_DYNAMIC_DATA_SETS == 1) #if (MMS_DYNAMIC_DATA_SETS == 1)
case 0xab: /* define-named-variable-list */ case 0xab: /* define-named-variable-list */
mmsServer_handleDefineNamedVariableListRequest(self, mmsServer_handleDefineNamedVariableListRequest(self,
@ -269,7 +271,6 @@ handleConfirmedRequestPdu(
break; break;
#endif /* (MMS_DYNAMIC_DATA_SETS == 1) */ #endif /* (MMS_DYNAMIC_DATA_SETS == 1) */
#if (MMS_GET_DATA_SET_ATTRIBUTES == 1) #if (MMS_GET_DATA_SET_ATTRIBUTES == 1)
case 0xac: /* get-named-variable-list-attributes-request */ case 0xac: /* get-named-variable-list-attributes-request */
mmsServer_handleGetNamedVariableListAttributesRequest(self, mmsServer_handleGetNamedVariableListAttributesRequest(self,
@ -334,7 +335,6 @@ handleConfirmedErrorPdu(
} }
} }
static MmsObtainFileTask static MmsObtainFileTask
getUploadTaskByInvokeId(MmsServer mmsServer, uint32_t invokeId) getUploadTaskByInvokeId(MmsServer mmsServer, uint32_t invokeId)
{ {
@ -387,7 +387,8 @@ handleConfirmedResponsePdu(
} }
if (extendedTag) { if (extendedTag) {
switch(tag) { switch (tag)
{
#if (MMS_FILE_SERVICE == 1) #if (MMS_FILE_SERVICE == 1)
case 0x48: /* file-open-response */ case 0x48: /* file-open-response */
@ -487,7 +488,8 @@ handleConfirmedResponsePdu(
} }
} }
else { else {
switch(tag) { switch (tag)
{
case 0x02: /* invoke Id */ case 0x02: /* invoke Id */
invokeId = BerDecoder_decodeUint32(buffer, length, bufPos); invokeId = BerDecoder_decodeUint32(buffer, length, bufPos);
if (DEBUG_MMS_SERVER) if (DEBUG_MMS_SERVER)
@ -528,7 +530,8 @@ MmsServerConnection_parseMessage(MmsServerConnection self, ByteBuffer* message,
if (DEBUG_MMS_SERVER) if (DEBUG_MMS_SERVER)
printf("MMS_SERVER: recvd MMS-PDU type: %02x size: %i\n", pduType, pduLength); printf("MMS_SERVER: recvd MMS-PDU type: %02x size: %i\n", pduType, pduLength);
switch (pduType) { switch (pduType)
{
case 0xa8: /* Initiate request PDU */ case 0xa8: /* Initiate request PDU */
mmsServer_handleInitiateRequest(self, buffer, bufPos, bufPos + pduLength, response); mmsServer_handleInitiateRequest(self, buffer, bufPos, bufPos + pduLength, response);
break; break;
@ -563,7 +566,7 @@ MmsServerConnection_parseMessage(MmsServerConnection self, ByteBuffer* message,
return; return;
parsing_error: parsing_error:
if (DEBUG_MMS_SERVER) if (DEBUG_MMS_SERVER)
printf("MMS_SERVER: error parsing message\n"); printf("MMS_SERVER: error parsing message\n");
@ -655,7 +658,6 @@ MmsServerConnection_getNamedVariableList(MmsServerConnection self, const char* v
} }
#endif /* (MMS_DYNAMIC_DATA_SETS == 1) */ #endif /* (MMS_DYNAMIC_DATA_SETS == 1) */
char* char*
MmsServerConnection_getClientAddress(MmsServerConnection self) MmsServerConnection_getClientAddress(MmsServerConnection self)
{ {
@ -691,7 +693,6 @@ MmsServerConnection_getNextRequestInvokeId(MmsServerConnection self)
} }
#endif /* (MMS_OBTAIN_FILE_SERVICE == 1) */ #endif /* (MMS_OBTAIN_FILE_SERVICE == 1) */
const char* const char*
MmsServerConnection_getFilesystemBasepath(MmsServerConnection self) MmsServerConnection_getFilesystemBasepath(MmsServerConnection self)
{ {

Loading…
Cancel
Save