- some code reformating

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

@ -45,7 +45,8 @@
#define ETH_P_GOOSE 0x88b8
struct sGooseReceiver {
struct sGooseReceiver
{
bool running;
bool stopped;
char* interfaceId;
@ -57,7 +58,6 @@ struct sGooseReceiver {
#endif
};
GooseReceiver
GooseReceiver_create()
{
@ -89,7 +89,6 @@ GooseReceiver_removeSubscriber(GooseReceiver self, GooseSubscriber subscriber)
LinkedList_remove(self->subscriberList, (void*) subscriber);
}
void
GooseReceiver_setInterfaceId(GooseReceiver self, const char* interfaceId)
{
@ -122,7 +121,8 @@ parseAllData(uint8_t* buffer, int allDataLength, MmsValue* dataSetValues)
uint8_t tag = buffer[bufPos++];
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;
}
@ -130,41 +130,51 @@ parseAllData(uint8_t* buffer, int allDataLength, MmsValue* dataSetValues)
bufPos = BerDecoder_decodeLength(buffer, &elementLength, bufPos, allDataLength);
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;
}
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;
}
switch (tag) {
switch (tag)
{
case 0x80: /* reserved for access result */
printf("GOOSE_SUBSCRIBER: found reserved value (tag 0x80)!\n");
break;
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 (!parseAllData(buffer + bufPos, elementLength, value))
return -1;
}
break;
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 (!parseAllData(buffer + bufPos, elementLength, value))
return -1;
}
break;
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) {
MmsValue_setBoolean(value, BerDecoder_decodeBoolean(buffer, bufPos));
}
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;
@ -181,6 +191,7 @@ parseAllData(uint8_t* buffer, int allDataLength, MmsValue* dataSetValues)
printf("bit-string is of wrong size");
}
break;
case 0x85: /* integer */
if (MmsValue_getType(value) == MMS_INTEGER) {
if (elementLength <= value->value.integer->maxSize) {
@ -189,6 +200,7 @@ parseAllData(uint8_t* buffer, int allDataLength, MmsValue* dataSetValues)
}
}
break;
case 0x86: /* unsigned integer */
if (MmsValue_getType(value) == MMS_UNSIGNED) {
if (elementLength <= value->value.integer->maxSize) {
@ -197,6 +209,7 @@ parseAllData(uint8_t* buffer, int allDataLength, MmsValue* dataSetValues)
}
}
break;
case 0x87: /* Float */
if (MmsValue_getType(value) == MMS_FLOAT) {
if (elementLength == 9) {
@ -216,6 +229,7 @@ parseAllData(uint8_t* buffer, int allDataLength, MmsValue* dataSetValues)
}
}
break;
case 0x8a: /* visible string */
if (MmsValue_getType(value) == MMS_VISIBLE_STRING) {
@ -235,6 +249,7 @@ parseAllData(uint8_t* buffer, int allDataLength, MmsValue* dataSetValues)
}
break;
case 0x8c: /* binary time */
if (MmsValue_getType(value) == MMS_BINARY_TIME) {
if ((elementLength == 4) || (elementLength == 6)) {
@ -242,17 +257,21 @@ parseAllData(uint8_t* buffer, int allDataLength, MmsValue* dataSetValues)
}
}
break;
case 0x91: /* Utctime */
if (elementLength == 8) {
if (MmsValue_getType(value) == MMS_UTC_TIME) {
MmsValue_setUtcTimeByBuffer(value, buffer + bufPos);
}
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
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;
default:
if (DEBUG_GOOSE_SUBSCRIBER)
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);
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;
}
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;
}
switch (tag) {
switch (tag)
{
case 0x80: /* reserved for access result */
break;
case 0xa1: /* array */
@ -340,20 +362,24 @@ parseAllDataUnknownValue(GooseSubscriber self, uint8_t* buffer, int allDataLengt
bufPos = BerDecoder_decodeLength(buffer, &elementLength, bufPos, allDataLength);
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;
}
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;
}
MmsValue* value = NULL;
switch (tag) {
switch (tag)
{
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);
@ -361,8 +387,10 @@ parseAllDataUnknownValue(GooseSubscriber self, uint8_t* buffer, int allDataLengt
goto exit_with_error;
break;
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);
@ -370,8 +398,10 @@ parseAllDataUnknownValue(GooseSubscriber self, uint8_t* buffer, int allDataLengt
goto exit_with_error;
break;
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));
break;
@ -385,16 +415,19 @@ parseAllDataUnknownValue(GooseSubscriber self, uint8_t* buffer, int allDataLengt
}
break;
case 0x85: /* integer */
value = MmsValue_newInteger(elementLength * 8);
memcpy(value->value.integer->octets, buffer + bufPos, elementLength);
value->value.integer->size = elementLength;
break;
case 0x86: /* unsigned integer */
value = MmsValue_newUnsigned(elementLength * 8);
memcpy(value->value.integer->octets, buffer + bufPos, elementLength);
value->value.integer->size = elementLength;
break;
case 0x87: /* Float */
if (elementLength == 9)
value = MmsValue_newDouble(BerDecoder_decodeDouble(buffer, bufPos));
@ -406,9 +439,11 @@ parseAllDataUnknownValue(GooseSubscriber self, uint8_t* buffer, int allDataLengt
value = MmsValue_newOctetString(elementLength, elementLength);
memcpy(value->value.octetString.buf, buffer + bufPos, elementLength);
break;
case 0x8a: /* visible string */
value = MmsValue_newVisibleStringFromByteArray(buffer + bufPos, elementLength);
break;
case 0x8c: /* binary time */
if (elementLength == 4)
value = MmsValue_newBinaryTime(true);
@ -419,16 +454,20 @@ parseAllDataUnknownValue(GooseSubscriber self, uint8_t* buffer, int allDataLengt
memcpy(value->value.binaryTime.buf, buffer + bufPos, elementLength);
break;
case 0x91: /* Utctime */
if (elementLength == 8) {
value = MmsValue_newUtcTime(0);
MmsValue_setUtcTimeByBuffer(value, buffer + bufPos);
}
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;
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;
}
@ -452,7 +491,6 @@ exit_with_error:
return NULL;
}
static int
parseGoosePayload(GooseReceiver self, uint8_t* buffer, int apduLength)
{
@ -474,7 +512,8 @@ parseGoosePayload(GooseReceiver self, uint8_t* buffer, int apduLength)
int gooseLength;
bufPos = BerDecoder_decodeLength(buffer, &gooseLength, bufPos, apduLength);
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;
}
@ -486,7 +525,8 @@ parseGoosePayload(GooseReceiver self, uint8_t* buffer, int apduLength)
uint8_t tag = buffer[bufPos++];
bufPos = BerDecoder_decodeLength(buffer, &elementLength, bufPos, apduLength);
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;
}
@ -500,9 +540,11 @@ parseGoosePayload(GooseReceiver self, uint8_t* buffer, int apduLength)
if (bufPos == -1)
goto exit_with_fault;
switch(tag) {
switch (tag)
{
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);
@ -512,7 +554,8 @@ parseGoosePayload(GooseReceiver self, uint8_t* buffer, int apduLength)
if (subscriber->goCBRefLen == elementLength) {
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;
break;
}
@ -531,61 +574,73 @@ parseGoosePayload(GooseReceiver self, uint8_t* buffer, int apduLength)
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;
case 0x82:
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Found dataSet\n");
if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Found dataSet\n");
break;
case 0x83:
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Found goId\n");
if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Found goId\n");
break;
case 0x84:
timestampBufPos = buffer + bufPos;
if (DEBUG_GOOSE_SUBSCRIBER) printf("GOOSE_SUBSCRIBER: Found timestamp\n");
if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Found timestamp\n");
break;
case 0x85:
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;
case 0x86:
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;
case 0x87:
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;
case 0x88:
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;
case 0x89:
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;
case 0x8a:
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;
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;
dataSetBufferLength = elementLength;
break;
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;
}
@ -630,11 +685,11 @@ parseGoosePayload(GooseReceiver self, uint8_t* buffer, int apduLength)
}
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;
}
static void
parseGooseMessage(GooseReceiver self, int numbytes)
{
@ -642,7 +697,8 @@ parseGooseMessage(GooseReceiver self, int numbytes)
bool subscriberFound = false;
uint8_t* buffer = self->buffer;
if (numbytes < 22) return;
if (numbytes < 22)
return;
/* skip ethernet addresses */
bufPos = 12;
@ -688,7 +744,6 @@ parseGooseMessage(GooseReceiver self, int numbytes)
printf("GOOSE_SUBSCRIBER: APDU length: %i\n", apduLength);
}
// check if there is an interested subscriber
LinkedList element = LinkedList_getNext(self->subscriberList);
@ -711,7 +766,6 @@ parseGooseMessage(GooseReceiver self, int numbytes)
}
}
static void
gooseReceiverLoop(void* threadParameter)
{
@ -736,7 +790,6 @@ gooseReceiverLoop(void* threadParameter)
self->stopped = true;
}
// start GOOSE receiver in a separate thread
void
GooseReceiver_start(GooseReceiver self)

@ -712,7 +712,6 @@ ControlObjectClient_setInterlockCheck(ControlObjectClient self, bool value)
self->interlockCheck = value;
}
void
ControlObjectClient_enableSynchroCheck(ControlObjectClient self)
{

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

@ -471,7 +471,8 @@ convertServiceErrorToMmsError(MmsServiceError serviceError)
{
MmsError mmsError;
switch (serviceError.errorClass) {
switch (serviceError.errorClass)
{
case 0: /* class: vmd-state */
mmsError = MMS_ERROR_VMDSTATE_OTHER;
break;
@ -481,7 +482,8 @@ convertServiceErrorToMmsError(MmsServiceError serviceError)
break;
case 2: /* class: definition */
switch (serviceError.errorCode) {
switch (serviceError.errorCode)
{
case 1:
mmsError = MMS_ERROR_DEFINITION_OBJECT_UNDEFINED;
break;
@ -523,7 +525,8 @@ convertServiceErrorToMmsError(MmsServiceError serviceError)
break;
case 7: /* class: access */
switch (serviceError.errorCode) {
switch (serviceError.errorCode)
{
case 1:
mmsError = MMS_ERROR_ACCESS_OBJECT_ACCESS_UNSUPPORTED;
break;
@ -543,7 +546,8 @@ convertServiceErrorToMmsError(MmsServiceError serviceError)
break;
case 11: /* class: file */
switch (serviceError.errorCode) {
switch (serviceError.errorCode)
{
case 1:
mmsError = MMS_ERROR_FILE_FILENAME_AMBIGUOUS;
break;
@ -577,7 +581,6 @@ convertServiceErrorToMmsError(MmsServiceError serviceError)
}
break;
default:
mmsError = MMS_ERROR_OTHER;
}
@ -598,7 +601,8 @@ parseServiceError(uint8_t* buffer, int bufPos, int maxLength, MmsServiceError* e
if (bufPos < 0)
return -1;
switch (tag) {
switch (tag)
{
case 0xa0: /* errorClass */
{
uint8_t errorClassTag = buffer[bufPos++];
@ -656,7 +660,8 @@ mmsMsg_parseConfirmedErrorPDU(uint8_t* buffer, int bufPos, int maxBufPos, uint32
if (bufPos < 0)
goto exit_error;
switch (tag) {
switch (tag)
{
case 0x80: /* invoke Id */
if (invokeId != NULL)
*invokeId = BerDecoder_decodeUint32(buffer, length, bufPos);
@ -714,7 +719,6 @@ mmsMsg_parseRejectPDU(uint8_t* buffer, int bufPos, int maxBufPos, uint32_t* invo
if (bufPos < 0)
goto exit_error;
if (tag == 0x80) { /* invoke id */
if (invokeId != NULL)
*invokeId = BerDecoder_decodeUint32(buffer, length, bufPos);
@ -836,7 +840,8 @@ mmsIsoCallback(IsoIndication indication, void* parameter, ByteBuffer* payload)
if (DEBUG_MMS_CLIENT)
printf("MMS_CLIENT: Confirmed error PDU!\n");
uint32_t invokeId;
MmsServiceError serviceError = {0, 0};
MmsServiceError serviceError =
{ 0, 0 };
if (mmsMsg_parseConfirmedErrorPDU(payload->buffer, 0, payload->size, &invokeId, &serviceError) < 0) {
if (DEBUG_MMS_CLIENT)
@ -972,7 +977,8 @@ mmsIsoCallback(IsoIndication indication, void* parameter, ByteBuffer* payload)
goto exit_with_error;
if (extendedTag) {
switch(nestedTag) {
switch (nestedTag)
{
#if (MMS_FILE_SERVICE == 1)
case 0x48: /* file-open-request */
@ -1032,7 +1038,8 @@ mmsIsoCallback(IsoIndication indication, void* parameter, ByteBuffer* payload)
}
}
else {
switch(nestedTag) {
switch (nestedTag)
{
case 0x02: /* invoke Id */
invokeId = BerDecoder_decodeUint32(buf, length, bufPos);
if (DEBUG_MMS_CLIENT)
@ -1040,7 +1047,6 @@ mmsIsoCallback(IsoIndication indication, void* parameter, ByteBuffer* payload)
self->lastInvokeId = invokeId;
break;
default:
// mmsServer_writeMmsRejectPdu(&invokeId, MMS_ERROR_REJECT_UNRECOGNIZED_SERVICE, response);
if (DEBUG_MMS_CLIENT)
@ -1057,7 +1063,6 @@ mmsIsoCallback(IsoIndication indication, void* parameter, ByteBuffer* payload)
bufPos += length;
}
}
#endif /* (MMS_OBTAIN_FILE_SERVICE == 1) */
@ -1073,7 +1078,6 @@ exit_with_error:
IsoClientConnection_releaseReceiveBuffer(self->isoClient);
if (DEBUG_MMS_CLIENT)
printf("MMS_CLIENT: LEAVE mmsIsoCallback - NOT OK!\n");
return;
@ -1141,7 +1145,6 @@ MmsConnection_createSecure(TLSConfiguration tlsConfig)
return self;
}
void
MmsConnection_destroy(MmsConnection self)
{
@ -1214,7 +1217,6 @@ MmsConnection_setRawMessageHandler(MmsConnection self, MmsRawMessageHandler hand
#endif
}
void
MmsConnection_setConnectionLostHandler(MmsConnection self, MmsConnectionLostHandler handler, void* handlerParameter)
{
@ -1819,7 +1821,6 @@ MmsConnection_defineNamedVariableListAssociationSpecific(MmsConnection self,
releaseResponse(self);
exit_function:
return;
}
@ -1998,7 +1999,6 @@ MmsJournalEntry_destroy(MmsJournalEntry self)
}
}
const MmsValue*
MmsJournalEntry_getEntryID(MmsJournalEntry self)
{
@ -2158,7 +2158,6 @@ MmsConnection_fileRead(MmsConnection self, MmsError* mmsError, int32_t frsmId, M
return moreFollows;
}
bool
MmsConnection_getFileDirectory(MmsConnection self, MmsError* mmsError, const char* fileSpecification, const char* continueAfter,
MmsFileDirectoryHandler handler, void* handlerParameter)
@ -2199,7 +2198,6 @@ MmsConnection_fileRename(MmsConnection self, MmsError* mmsError, const char* cur
releaseResponse(self);
}
void
MmsConnection_obtainFile(MmsConnection self, MmsError* mmsError, const char* sourceFile, const char* destinationFile)
{

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

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

@ -49,7 +49,8 @@ mmsClient_parseListOfAccessResults(AccessResult_t** accessResultList, int listSi
AccessResult_PR presentType = accessResultList[i]->present;
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) {
int errorCode = (int) accessResultList[i]->choice.failure.buf[0];
@ -239,7 +240,6 @@ mmsClient_parseListOfAccessResults(AccessResult_t** accessResultList, int listSi
return valueList;
}
/*
* \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.
@ -277,7 +277,6 @@ mmsClient_parseReadResponse(ByteBuffer* message, uint32_t* invokeId, bool create
return valueList;
}
static ReadRequest_t*
createReadRequest(MmsPdu_t* mmsPdu)
{
@ -287,7 +286,6 @@ createReadRequest (MmsPdu_t* mmsPdu)
return &(mmsPdu->choice.confirmedRequestPdu.confirmedServiceRequest.choice.read);
}
int
mmsClient_createReadNamedVariableListRequest(uint32_t invokeId, const char* domainId, const char* itemId,
ByteBuffer* writeBuffer, bool specWithResult)
@ -307,7 +305,6 @@ mmsClient_createReadNamedVariableListRequest(uint32_t invokeId, const char* doma
ObjectName_t* objectName = &(readRequest->variableAccessSpecification.choice.variableListName);
if (domainId != NULL) {
objectName->present = ObjectName_PR_domainspecific;
@ -515,7 +512,8 @@ mmsClient_createReadRequestAlternateAccessIndex(uint32_t invokeId, const char* d
}
static ListOfVariableSeq_t**
createListOfVariables(ReadRequest_t* readRequest, int valuesCount) {
createListOfVariables(ReadRequest_t* readRequest, int valuesCount)
{
readRequest->variableAccessSpecification.present = VariableAccessSpecification_PR_listOfVariable;
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.array = NULL;
asn_DEF_MmsPdu.free_struct(&asn_DEF_MmsPdu, mmsPdu, 0);
return rval.encoded;

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

@ -61,7 +61,6 @@ getDomainNames(MmsServerConnection connection)
return list;
}
#if (CONFIG_MMS_SUPPORT_VMD_SCOPE_NAMED_VARIABLES == 1)
static LinkedList
getNameListVMDSpecific(MmsServerConnection connection)
@ -80,7 +79,6 @@ getNameListVMDSpecific(MmsServerConnection connection)
}
#endif /* (CONFIG_MMS_SUPPORT_VMD_SCOPE_NAMED_VARIABLES == 1) */
#if (CONFIG_MMS_SORT_NAME_LIST == 1)
static void
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) */
static LinkedList
getJournalListDomainSpecific(MmsServerConnection connection, char* domainName)
{
@ -259,7 +254,6 @@ getNameListDomainSpecific(MmsServerConnection connection, char* domainName)
return nameList;
}
#if (MMS_DATA_SET_SERVICE == 1)
static LinkedList
@ -459,7 +453,8 @@ mmsServer_handleGetNameListRequest(
return;
}
switch (tag) {
switch (tag)
{
case 0xa0: /* objectClass */
bufPos++;
@ -477,7 +472,8 @@ mmsServer_handleGetNameListRequest(
return;
}
switch (objectScopeTag) {
switch (objectScopeTag)
{
case 0x80: /* vmd-specific */
objectScope = OBJECT_SCOPE_VMD;
break;
@ -508,7 +504,6 @@ mmsServer_handleGetNameListRequest(
bufPos += length;
}
char continueAfterIdMemory[130];
char* continueAfterId = NULL;
@ -573,7 +568,8 @@ mmsServer_handleGetNameListRequest(
#endif /* (MMS_DATA_SET_SERVICE == 1) */
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);
}
@ -631,7 +627,8 @@ mmsServer_handleGetNameListRequest(
}
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);
}
@ -659,11 +656,12 @@ mmsServer_handleGetNameListRequest(
#endif /* (MMS_DATA_SET_SERVICE == 1) */
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);
}
}
#endif /* (MMS_GET_NAME_LIST == 1) */

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

Loading…
Cancel
Save