- COTP: fixed problem in server side src/dst reference handling
This commit is contained in:
parent
c093852fda
commit
877d4562e4
5 changed files with 21 additions and 22 deletions
|
@ -4,6 +4,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "string_utilities.h"
|
#include "string_utilities.h"
|
||||||
#include "mms_client_connection.h"
|
#include "mms_client_connection.h"
|
||||||
|
#include "conversions.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_help()
|
print_help()
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include "platform_endian.h"
|
#include "platform_endian.h"
|
||||||
|
|
||||||
#define LIBIEC61850_VERSION "1.0.0"
|
#define LIBIEC61850_VERSION "1.0.1"
|
||||||
|
|
||||||
#ifndef CONFIG_DEFAULT_MMS_VENDOR_NAME
|
#ifndef CONFIG_DEFAULT_MMS_VENDOR_NAME
|
||||||
#define CONFIG_DEFAULT_MMS_VENDOR_NAME "libiec61850.com"
|
#define CONFIG_DEFAULT_MMS_VENDOR_NAME "libiec61850.com"
|
||||||
|
|
|
@ -38,8 +38,8 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int state;
|
int state;
|
||||||
int srcRef;
|
int remoteRef;
|
||||||
int dstRef;
|
int localRef;
|
||||||
int protocolClass;
|
int protocolClass;
|
||||||
Socket socket;
|
Socket socket;
|
||||||
CotpOptions options;
|
CotpOptions options;
|
||||||
|
@ -97,9 +97,9 @@ ByteBuffer*
|
||||||
CotpConnection_getPayload(CotpConnection* self);
|
CotpConnection_getPayload(CotpConnection* self);
|
||||||
|
|
||||||
int
|
int
|
||||||
CotpConnection_getSrcRef(CotpConnection* self);
|
CotpConnection_getRemoteRef(CotpConnection* self);
|
||||||
|
|
||||||
int
|
int
|
||||||
CotpConnection_getDstRef(CotpConnection* self);
|
CotpConnection_getLocalRef(CotpConnection* self);
|
||||||
|
|
||||||
#endif /* COTP_H_ */
|
#endif /* COTP_H_ */
|
||||||
|
|
|
@ -123,10 +123,10 @@ writeStaticConnectResponseHeader(CotpConnection* self, int optionsLength)
|
||||||
|
|
||||||
buffer[4] = 6 + optionsLength;
|
buffer[4] = 6 + optionsLength;
|
||||||
buffer[5] = 0xd0;
|
buffer[5] = 0xd0;
|
||||||
buffer[6] = (uint8_t) (self->srcRef / 0x100);
|
buffer[6] = (uint8_t) (self->remoteRef / 0x100);
|
||||||
buffer[7] = (uint8_t) (self->srcRef & 0xff);
|
buffer[7] = (uint8_t) (self->remoteRef & 0xff);
|
||||||
buffer[8] = (uint8_t) (self->dstRef / 0x100);
|
buffer[8] = (uint8_t) (self->localRef / 0x100);
|
||||||
buffer[9] = (uint8_t) (self->dstRef & 0xff);
|
buffer[9] = (uint8_t) (self->localRef & 0xff);
|
||||||
buffer[10] = (uint8_t) (self->protocolClass);
|
buffer[10] = (uint8_t) (self->protocolClass);
|
||||||
|
|
||||||
self->writeBuffer->size = 11;
|
self->writeBuffer->size = 11;
|
||||||
|
@ -312,8 +312,8 @@ CotpConnection_sendConnectionRequestMessage(CotpConnection* self, IsoConnectionP
|
||||||
buffer[7] = 0x00;
|
buffer[7] = 0x00;
|
||||||
|
|
||||||
/* SRC REF */
|
/* SRC REF */
|
||||||
buffer[8] = 0x00;
|
buffer[8] = (uint8_t) (self->localRef / 0x100);
|
||||||
buffer[9] = 0x02; /* or 0x01 ? */
|
buffer[9] = (uint8_t) (self->localRef & 0xff);
|
||||||
|
|
||||||
/* Class */
|
/* Class */
|
||||||
buffer[10] = 0x00;
|
buffer[10] = 0x00;
|
||||||
|
@ -435,8 +435,8 @@ CotpConnection_init(CotpConnection* self, Socket socket,
|
||||||
{
|
{
|
||||||
self->state = 0;
|
self->state = 0;
|
||||||
self->socket = socket;
|
self->socket = socket;
|
||||||
self->srcRef = -1;
|
self->remoteRef = -1;
|
||||||
self->dstRef = -1;
|
self->localRef = 1;
|
||||||
self->protocolClass = -1;
|
self->protocolClass = -1;
|
||||||
self->options.tpduSize = 0;
|
self->options.tpduSize = 0;
|
||||||
|
|
||||||
|
@ -487,15 +487,15 @@ CotpConnection_getPayload(CotpConnection* self)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
CotpConnection_getSrcRef(CotpConnection* self)
|
CotpConnection_getRemoteRef(CotpConnection* self)
|
||||||
{
|
{
|
||||||
return self->srcRef;
|
return self->remoteRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
CotpConnection_getDstRef(CotpConnection* self)
|
CotpConnection_getLocalRef(CotpConnection* self)
|
||||||
{
|
{
|
||||||
return self->dstRef;
|
return self->localRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -515,8 +515,7 @@ parseConnectRequestTpdu(CotpConnection* self, uint8_t* buffer, uint8_t len)
|
||||||
if (len < 6)
|
if (len < 6)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
self->dstRef = getUint16(buffer);
|
self->remoteRef = getUint16(buffer + 2);
|
||||||
self->srcRef = getUint16(buffer + 2);
|
|
||||||
self->protocolClass = getUint8(buffer + 4);
|
self->protocolClass = getUint8(buffer + 4);
|
||||||
|
|
||||||
return parseOptions(self, buffer + 5, len - 6);
|
return parseOptions(self, buffer + 5, len - 6);
|
||||||
|
@ -528,8 +527,7 @@ parseConnectConfirmTpdu(CotpConnection* self, uint8_t* buffer, uint8_t len)
|
||||||
if (len < 6)
|
if (len < 6)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
self->srcRef = getUint16(buffer);
|
self->remoteRef = getUint16(buffer);
|
||||||
self->dstRef = getUint16(buffer + 2);
|
|
||||||
self->protocolClass = getUint8(buffer + 4);
|
self->protocolClass = getUint8(buffer + 4);
|
||||||
|
|
||||||
return parseOptions(self, buffer + 5, len - 6);
|
return parseOptions(self, buffer + 5, len - 6);
|
||||||
|
|
|
@ -134,7 +134,7 @@ createTypeSpecification (
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (DEBUG_MMS_SERVER)
|
if (DEBUG_MMS_SERVER)
|
||||||
printf("MMS-SERVER: Unsupported type %i!\n", namedVariable->type);
|
printf("MMS-SERVER: Unsupported type %i!\n", namedVariable->type);
|
||||||
return -1;
|
return -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue