From b0e8a6331b87cecc053d82352c5c9c7d79f9b20d Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Thu, 15 Oct 2015 17:07:00 +0200 Subject: [PATCH] - fixed some problems in server side file directory service --- src/goose/goose_publisher.c | 5 ---- src/goose/goose_receiver.c | 7 ----- src/iec61850/client/ied_connection.c | 3 ++ src/mms/iso_client/iso_client_connection.c | 28 +------------------ src/mms/iso_mms/client/mms_client_identify.c | 3 ++ .../iso_mms/server/mms_association_service.c | 3 ++ src/mms/iso_mms/server/mms_file_service.c | 8 ++++-- 7 files changed, 16 insertions(+), 41 deletions(-) diff --git a/src/goose/goose_publisher.c b/src/goose/goose_publisher.c index 47b85995..d5ebe97f 100644 --- a/src/goose/goose_publisher.c +++ b/src/goose/goose_publisher.c @@ -376,11 +376,6 @@ GoosePublisher_publish(GoosePublisher self, LinkedList dataSet) if (DEBUG_GOOSE_PUBLISHER) printf("GOOSE_PUBLISHER: send GOOSE message\n"); - struct timeval tv; - - gettimeofday(&tv,NULL/*&tz*/); - printf("GOOSE SEND: %ld %ld\n",tv.tv_sec, tv.tv_usec); - Ethernet_sendPacket(self->ethernetSocket, self->buffer, self->payloadStart + payloadLength); return 0; diff --git a/src/goose/goose_receiver.c b/src/goose/goose_receiver.c index 201fcf93..960073a3 100644 --- a/src/goose/goose_receiver.c +++ b/src/goose/goose_receiver.c @@ -612,13 +612,6 @@ exit_with_fault: static void parseGooseMessage(GooseReceiver self, int numbytes) { - struct timeval tv; - - gettimeofday(&tv,NULL/*&tz*/); - - printf("RCVD GOOSE: %ld %ld\n",tv.tv_sec, tv.tv_usec); - - int bufPos; bool subscriberFound = false; uint8_t* buffer = self->buffer; diff --git a/src/iec61850/client/ied_connection.c b/src/iec61850/client/ied_connection.c index c0749e4e..b13c3011 100644 --- a/src/iec61850/client/ied_connection.c +++ b/src/iec61850/client/ied_connection.c @@ -88,6 +88,9 @@ iedConnection_mapMmsErrorToIedError(MmsError mmsError) case MMS_ERROR_CONNECTION_REJECTED: return IED_ERROR_CONNECTION_REJECTED; + case MMS_ERROR_ACCESS_OBJECT_VALUE_INVALID: + return IED_ERROR_OBJECT_VALUE_INVALID; + default: return IED_ERROR_UNKNOWN; } diff --git a/src/mms/iso_client/iso_client_connection.c b/src/mms/iso_client/iso_client_connection.c index 7ff796fd..b68631b0 100644 --- a/src/mms/iso_client/iso_client_connection.c +++ b/src/mms/iso_client/iso_client_connection.c @@ -106,8 +106,6 @@ connectionHandlingThread(IsoClientConnection self) TpktState packetState; - printf("P1\n"); - while ((packetState = CotpConnection_readToTpktBuffer(self->cotpConnection)) == TPKT_WAITING) { Thread_sleep(1); @@ -118,9 +116,6 @@ connectionHandlingThread(IsoClientConnection self) } } - printf("P2\n"); - - if (packetState == TPKT_ERROR) break; @@ -151,44 +146,27 @@ connectionHandlingThread(IsoClientConnection self) break; } - printf("P3\n"); - - self->callback(ISO_IND_DATA, self->callbackParameter, &(self->presentation->nextPayload)); - printf("P4\n"); - - /* wait for user to release the buffer */ Semaphore_wait(self->receiveBufferMutex); - - printf("P5\n"); - CotpConnection_resetPayload(self->cotpConnection); } - printf("I1\n"); - - self->callback(ISO_IND_CLOSED, self->callbackParameter, NULL); - - printf("I2\n"); + self->callback(ISO_IND_CLOSED, self->callbackParameter, NULL);; self->state = STATE_IDLE; Socket_destroy(self->socket); - printf("I3\n"); - if (DEBUG_ISO_CLIENT) printf("ISO_CLIENT_CONNECTION: exit connection %p\n", self); /* release buffer to enable reuse of client connection */ Semaphore_post(self->receiveBufferMutex); - printf("I4\n"); - self->handlingThreadRunning = false; } @@ -449,16 +427,12 @@ IsoClientConnection_close(IsoClientConnection self) if (DEBUG_ISO_CLIENT) printf("ISO_CLIENT: IsoClientConnection_close\n"); - printf("B1\n"); - if (self->handlingThreadRunning) { self->stopHandlingThread = true; while (self->handlingThreadRunning) Thread_sleep(1); } - printf("B2\n"); - self->state = STATE_IDLE; } diff --git a/src/mms/iso_mms/client/mms_client_identify.c b/src/mms/iso_mms/client/mms_client_identify.c index f107797d..7d1b9466 100644 --- a/src/mms/iso_mms/client/mms_client_identify.c +++ b/src/mms/iso_mms/client/mms_client_identify.c @@ -98,6 +98,9 @@ mmsClient_parseIdentifyResponse(MmsConnection self) case 0x83: /* list of abstract syntaxes */ bufPos += length; break; + default: /* ignore unknown tags */ + bufPos += length; + break; } } diff --git a/src/mms/iso_mms/server/mms_association_service.c b/src/mms/iso_mms/server/mms_association_service.c index ceb3e615..6cce6be6 100644 --- a/src/mms/iso_mms/server/mms_association_service.c +++ b/src/mms/iso_mms/server/mms_association_service.c @@ -221,6 +221,9 @@ parseInitiateRequestPdu(MmsServerConnection self, uint8_t* buffer, int bufPos, i case 0xa4: /* mms-init-request-detail */ /* we ignore this */ break; + + default: + break; /* Ignore unknown tags */ } bufPos += length; diff --git a/src/mms/iso_mms/server/mms_file_service.c b/src/mms/iso_mms/server/mms_file_service.c index d0780fb3..74c60d56 100644 --- a/src/mms/iso_mms/server/mms_file_service.c +++ b/src/mms/iso_mms/server/mms_file_service.c @@ -450,8 +450,10 @@ addFileEntriesToResponse(uint8_t* buffer, int bufPos, int maxBufSize, char* dire while (fileName != NULL) { directoryName[directoryNameLength] = 0; - if (directoryNameLength > 0) - strcat(directoryName, "/"); + if (directoryNameLength > 0) { + if (directoryName[directoryNameLength - 1] != '/') + strcat(directoryName, "/"); + } strcat(directoryName, fileName); @@ -506,6 +508,8 @@ addFileEntriesToResponse(uint8_t* buffer, int bufPos, int maxBufSize, char* dire FileSystem_closeDirectory(directory); } + else + bufPos = -1; directoryName[directoryNameLength] = 0;