|
|
|
@ -21,15 +21,15 @@
|
|
|
|
|
* See COPYING file for the complete license text.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "byte_buffer.h"
|
|
|
|
|
#include "libiec61850_platform_includes.h"
|
|
|
|
|
#include "stack_config.h"
|
|
|
|
|
#include "mms_common.h"
|
|
|
|
|
#include "mms_client_connection.h"
|
|
|
|
|
#include "byte_buffer.h"
|
|
|
|
|
#include "mms_common.h"
|
|
|
|
|
#include "stack_config.h"
|
|
|
|
|
|
|
|
|
|
#include "mms_client_internal.h"
|
|
|
|
|
#include "ber_encoder.h"
|
|
|
|
|
#include "ber_decode.h"
|
|
|
|
|
#include "ber_encoder.h"
|
|
|
|
|
#include "mms_client_internal.h"
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
mmsClient_createIdentifyRequest(uint32_t invokeId, ByteBuffer* request)
|
|
|
|
@ -50,21 +50,23 @@ mmsClient_createIdentifyRequest(uint32_t invokeId, ByteBuffer* request)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
mmsClient_parseIdentifyResponse(MmsConnection self, ByteBuffer* response, uint32_t respBufPos, uint32_t invokeId, MmsConnection_IdentifyHandler handler, void* parameter)
|
|
|
|
|
mmsClient_parseIdentifyResponse(MmsConnection self, ByteBuffer* response, uint32_t respBufPos, uint32_t invokeId,
|
|
|
|
|
MmsConnection_IdentifyHandler handler, void* parameter)
|
|
|
|
|
{
|
|
|
|
|
(void)self;
|
|
|
|
|
|
|
|
|
|
uint8_t* buffer = ByteBuffer_getBuffer(response);
|
|
|
|
|
int maxBufPos = ByteBuffer_getSize(response);
|
|
|
|
|
int length;
|
|
|
|
|
int bufPos = (int) respBufPos;
|
|
|
|
|
int bufPos = (int)respBufPos;
|
|
|
|
|
|
|
|
|
|
uint8_t tag = buffer[bufPos++];
|
|
|
|
|
if (tag != 0xa2)
|
|
|
|
|
goto exit_error;
|
|
|
|
|
|
|
|
|
|
bufPos = BerDecoder_decodeLength(buffer, &length, bufPos, maxBufPos);
|
|
|
|
|
if (bufPos < 0) goto exit_error;
|
|
|
|
|
if (bufPos < 0)
|
|
|
|
|
goto exit_error;
|
|
|
|
|
|
|
|
|
|
int endPos = bufPos + length;
|
|
|
|
|
|
|
|
|
@ -76,23 +78,29 @@ mmsClient_parseIdentifyResponse(MmsConnection self, ByteBuffer* response, uint32
|
|
|
|
|
char* modelName = NULL;
|
|
|
|
|
char* revision = NULL;
|
|
|
|
|
|
|
|
|
|
while (bufPos < endPos) {
|
|
|
|
|
while (bufPos < endPos)
|
|
|
|
|
{
|
|
|
|
|
tag = buffer[bufPos++];
|
|
|
|
|
|
|
|
|
|
bufPos = BerDecoder_decodeLength(buffer, &length, bufPos, maxBufPos);
|
|
|
|
|
if (bufPos < 0) goto exit_error;
|
|
|
|
|
if (bufPos < 0)
|
|
|
|
|
goto exit_error;
|
|
|
|
|
|
|
|
|
|
switch (tag) {
|
|
|
|
|
switch (tag)
|
|
|
|
|
{
|
|
|
|
|
case 0x80: /* vendorName */
|
|
|
|
|
vendorName = StringUtils_createStringFromBufferInBufferMax(vendorNameBuf, buffer + bufPos, length, sizeof(vendorNameBuf));
|
|
|
|
|
vendorName = StringUtils_createStringFromBufferInBufferMax(vendorNameBuf, buffer + bufPos, length,
|
|
|
|
|
sizeof(vendorNameBuf));
|
|
|
|
|
bufPos += length;
|
|
|
|
|
break;
|
|
|
|
|
case 0x81: /* modelName */
|
|
|
|
|
modelName = StringUtils_createStringFromBufferInBufferMax(modelNameBuf, buffer + bufPos, length, sizeof(modelNameBuf));
|
|
|
|
|
modelName = StringUtils_createStringFromBufferInBufferMax(modelNameBuf, buffer + bufPos, length,
|
|
|
|
|
sizeof(modelNameBuf));
|
|
|
|
|
bufPos += length;
|
|
|
|
|
break;
|
|
|
|
|
case 0x82: /* revision */
|
|
|
|
|
revision = StringUtils_createStringFromBufferInBufferMax(revisionBuf, buffer + bufPos, length, sizeof (revisionBuf));
|
|
|
|
|
revision = StringUtils_createStringFromBufferInBufferMax(revisionBuf, buffer + bufPos, length,
|
|
|
|
|
sizeof(revisionBuf));
|
|
|
|
|
bufPos += length;
|
|
|
|
|
break;
|
|
|
|
|
case 0x83: /* list of abstract syntaxes */
|
|
|
|
@ -101,8 +109,8 @@ mmsClient_parseIdentifyResponse(MmsConnection self, ByteBuffer* response, uint32
|
|
|
|
|
case 0x00: /* indefinite length end tag -> ignore */
|
|
|
|
|
break;
|
|
|
|
|
default: /* ignore unknown tags */
|
|
|
|
|
bufPos += length;
|
|
|
|
|
break;
|
|
|
|
|
bufPos += length;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -113,6 +121,3 @@ mmsClient_parseIdentifyResponse(MmsConnection self, ByteBuffer* response, uint32
|
|
|
|
|
exit_error:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|