- fixed bug in server side file directory service with nested directory structure
- mms_utility: added read file directory feature
This commit is contained in:
parent
50115191cc
commit
ecf64277a8
2 changed files with 35 additions and 12 deletions
|
@ -8,7 +8,8 @@
|
|||
static void
|
||||
print_help()
|
||||
{
|
||||
printf("MMS utility (libiec61850 v0.5) options:\n");
|
||||
|
||||
printf("MMS utility (libiec61850 " LIBIEC61850_VERSION ") options:\n");
|
||||
printf("-h <hostname> specify hostname\n");
|
||||
printf("-p <port> specify port\n");
|
||||
printf("-l <max_pdu_size> specify maximum PDU size\n");
|
||||
|
@ -16,7 +17,18 @@ print_help()
|
|||
printf("-i show server identity\n");
|
||||
printf("-t <domain_name> show domain directory\n");
|
||||
printf("-r <variable_name> read domain variable\n");
|
||||
printf("-a <domain_name> specify domain for read or write command");
|
||||
printf("-a <domain_name> specify domain for read or write command\n");
|
||||
printf("-f show file list\n");
|
||||
}
|
||||
|
||||
static void
|
||||
mmsFileDirectoryHandler (void* parameter, char* filename, uint32_t size, uint64_t lastModified)
|
||||
{
|
||||
char* lastName = (char*) parameter;
|
||||
|
||||
strcpy (lastName, filename);
|
||||
|
||||
printf("%s\n", filename);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
@ -33,11 +45,12 @@ int main(int argc, char** argv) {
|
|||
int identifyDevice = 0;
|
||||
int readWriteHasDomain = 0;
|
||||
int readVariable = 0;
|
||||
int showFileList = 0;
|
||||
|
||||
|
||||
int c;
|
||||
|
||||
while ((c = getopt(argc, argv, "idh:p:l:t:a:r:")) != -1)
|
||||
while ((c = getopt(argc, argv, "ifdh:p:l:t:a:r:")) != -1)
|
||||
switch (c) {
|
||||
case 'h':
|
||||
hostname = copyString(optarg);
|
||||
|
@ -66,6 +79,9 @@ int main(int argc, char** argv) {
|
|||
readVariable = 1;
|
||||
variableName = copyString(optarg);
|
||||
break;
|
||||
case 'f':
|
||||
showFileList = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
print_help();
|
||||
|
@ -150,6 +166,16 @@ int main(int argc, char** argv) {
|
|||
printf("Reading VMD scope variable not yet supported!\n");
|
||||
}
|
||||
|
||||
if (showFileList) {
|
||||
char lastName[300];
|
||||
lastName[0] = 0;
|
||||
|
||||
char* continueAfter = NULL;
|
||||
|
||||
while (MmsConnection_getFileDirectory(con, &error, "", continueAfter, mmsFileDirectoryHandler, lastName)) {
|
||||
continueAfter = lastName;
|
||||
}
|
||||
}
|
||||
|
||||
exit:
|
||||
MmsConnection_destroy(con);
|
||||
|
|
|
@ -437,7 +437,7 @@ encodeFileSpecification(uint8_t tag, char* fileSpecification, uint8_t* buffer, i
|
|||
}
|
||||
|
||||
static int
|
||||
addFileEntriesToResponse(uint8_t* buffer, int bufPos, int maxBufSize, char* directoryName, char* continueAfterFileName, bool* moreFollows)
|
||||
addFileEntriesToResponse(uint8_t* buffer, int bufPos, int maxBufSize, char* directoryName, char** continueAfterFileName, bool* moreFollows)
|
||||
{
|
||||
int directoryNameLength = strlen(directoryName);
|
||||
|
||||
|
@ -464,9 +464,10 @@ addFileEntriesToResponse(uint8_t* buffer, int bufPos, int maxBufSize, char* dire
|
|||
break;
|
||||
}
|
||||
else {
|
||||
if (continueAfterFileName != NULL) {
|
||||
if (strcmp(continueAfterFileName, directoryName) == 0)
|
||||
continueAfterFileName = NULL;
|
||||
if (*continueAfterFileName != NULL) {
|
||||
if (strcmp(*continueAfterFileName, directoryName) == 0) {
|
||||
*continueAfterFileName = NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
uint64_t msTime;
|
||||
|
@ -533,9 +534,7 @@ createFileDirectoryResponse(uint32_t invokeId, ByteBuffer* response, int maxPduS
|
|||
continueAfterFileName = NULL;
|
||||
}
|
||||
|
||||
printf("createFileDirectoryResponse: maxSize:%i\n", maxSize);
|
||||
|
||||
tempCurPos = addFileEntriesToResponse(buffer, tempCurPos, maxSize, directoryName, continueAfterFileName, &moreFollows);
|
||||
tempCurPos = addFileEntriesToResponse(buffer, tempCurPos, maxSize, directoryName, &continueAfterFileName, &moreFollows);
|
||||
|
||||
if (tempCurPos < 0) {
|
||||
|
||||
|
@ -586,8 +585,6 @@ createFileDirectoryResponse(uint32_t invokeId, ByteBuffer* response, int maxPduS
|
|||
bufPos = BerEncoder_encodeBoolean(0x81, moreFollows, buffer, bufPos);
|
||||
|
||||
response->size = bufPos;
|
||||
|
||||
printf("createFileDirectoryResponse: maxSize:%i response->isze:%i\n", maxSize, response->size);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Reference in a new issue