- MMS client/server: extended BER encoder to support MMS PDU sizes with more than 64k

This commit is contained in:
Michael Zillgith 2017-08-15 08:15:33 +02:00
parent 8d2b8b087e
commit b1641b82ff
5 changed files with 34 additions and 6 deletions

View File

@ -28,7 +28,7 @@
#define DEBUG_HAL_ETHERNET 0
/* Maximum MMS PDU SIZE - default is 65000 */
#define CONFIG_MMS_MAXIMUM_PDU_SIZE 65000
#define CONFIG_MMS_MAXIMUM_PDU_SIZE 120000
/*
* Enable single threaded mode

View File

@ -23,6 +23,7 @@ print_help()
printf("-g <filename> get file attributes\n");
printf("-x <filename> delete file\n");
printf("-j <domainName/journalName> read journal\n");
printf("-v <variable list_name> read domain variable list\n");
printf("-m print raw MMS messages\n");
}
@ -117,10 +118,11 @@ int main(int argc, char** argv) {
int readJournal = 0;
int printRawMmsMessages = 0;
int deleteFile = 0;
int readVariableList = 0;
int c;
while ((c = getopt(argc, argv, "mifdh:p:l:t:a:r:g:j:x:")) != -1)
while ((c = getopt(argc, argv, "mifdh:p:l:t:a:r:g:j:x:v:")) != -1)
switch (c) {
case 'm':
printRawMmsMessages = 1;
@ -153,6 +155,10 @@ int main(int argc, char** argv) {
readVariable = 1;
variableName = StringUtils_copyString(optarg);
break;
case 'v':
readVariableList = 1;
variableName = StringUtils_copyString(optarg);
break;
case 'f':
showFileList = 1;
break;
@ -342,6 +348,21 @@ int main(int argc, char** argv) {
printf("Reading VMD scope variable not yet supported!\n");
}
if (readVariableList) {
if (readWriteHasDomain) {
MmsValue* variables = MmsConnection_readNamedVariableListValues(con, &error, domainName, variableName, true);
if (error != MMS_ERROR_NONE) {
printf("Reading variable failed: (ERROR %i)\n", error);
}
else {
printf("Read SUCCESS\n");
}
}
else
printf("Reading VMD scope variable list not yet supported!\n");
}
if (showFileList) {
char lastName[300];
lastName[0] = 0;

View File

@ -34,12 +34,19 @@ BerEncoder_encodeLength(uint32_t length, uint8_t* buffer, int bufPos)
buffer[bufPos++] = 0x81;
buffer[bufPos++] = (uint8_t) length;
}
else {
else if (length < 65535) {
buffer[bufPos++] = 0x82;
buffer[bufPos++] = length / 256;
buffer[bufPos++] = length % 256;
}
else {
buffer[bufPos++] = 0x83;
buffer[bufPos++] = length / 0x10000;
buffer[bufPos++] = (length & 0xffff) / 0x100;
buffer[bufPos++] = length % 256;
}
return bufPos;
}
@ -362,8 +369,10 @@ BerEncoder_determineLengthSize(uint32_t length)
return 1;
if (length < 256)
return 2;
else
if (length < 65536)
return 3;
else
return 4;
}
int

View File

@ -252,8 +252,6 @@ handleConfirmedErrorPdu(
uint32_t invokeId;
MmsServiceError serviceError;
if (mmsMsg_parseConfirmedErrorPDU(buffer, bufPos, maxBufPos, &invokeId, &serviceError)) {
if (DEBUG_MMS_SERVER)