瀏覽代碼

南瑞网关备份

xhj 3 月之前
父節點
當前提交
27ebb78271
共有 29 個文件被更改,包括 471 次插入1657 次删除
  1. 3 19
      library/include/boost/pool/detail/pool_construct.bat
  2. 1 12
      library/include/libiec61850/goose_receiver.h
  3. 1 2
      library/include/libiec61850/goose_subscriber.h
  4. 0 30
      library/include/libiec61850/hal_ethernet.h
  5. 4 39
      library/include/libiec61850/hal_socket.h
  6. 1 1
      library/include/libiec61850/hal_time.h
  7. 0 2
      library/include/libiec61850/iec61850_cdc.h
  8. 27 106
      library/include/libiec61850/iec61850_client.h
  9. 19 24
      library/include/libiec61850/iec61850_common.h
  10. 0 2
      library/include/libiec61850/iec61850_config_file_parser.h
  11. 3 97
      library/include/libiec61850/iec61850_dynamic_model.h
  12. 47 29
      library/include/libiec61850/iec61850_model.h
  13. 33 319
      library/include/libiec61850/iec61850_server.h
  14. 1 21
      library/include/libiec61850/iso_connection_parameters.h
  15. 8 43
      library/include/libiec61850/mms_client_connection.h
  16. 7 50
      library/include/libiec61850/mms_server.h
  17. 1 33
      library/include/libiec61850/mms_value.h
  18. 0 244
      library/include/libiec61850/r_session.h
  19. 0 73
      library/include/libiec61850/sntp_client.h
  20. 1 13
      library/include/libiec61850/sv_publisher.h
  21. 68 14
      library/include/libiec61850/sv_subscriber.h
  22. 0 262
      library/include/libiec61850/tls_ciphers.h
  23. 10 131
      library/include/libiec61850/tls_config.h
  24. 二進制
      library/lib/libiec61850.so
  25. 19 16
      modules/gateway-scheduler/src/main.cpp
  26. 141 23
      modules/gateway-scheduler/src/report/MyIec61850Server.cpp
  27. 41 41
      modules/gateway-scheduler/src/report/MyIec61850Server.h
  28. 8 7
      modules/gateway-scheduler/src/tcp_server/TcpServer.cpp
  29. 27 4
      modules/gateway-server/src/server/BasicServer.cpp

+ 3 - 19
library/include/boost/pool/detail/pool_construct.bat

@@ -1,7 +1,7 @@
 /*
  *  goose_publisher.h
  *
- *  Copyright 2013-2022 Michael Zillgith
+ *  Copyright 2013-2020 Michael Zillgith
  *
  *  This file is part of libIEC61850.
  *
@@ -25,7 +25,6 @@
 #define GOOSE_PUBLISHER_H_
 
 #include "iec61850_common.h"
-#include "r_session.h"
 #include "linked_list.h"
 #include "mms_value.h"
 
@@ -54,35 +53,20 @@ typedef struct sGoosePublisher* GoosePublisher;
  *
  * \param parameters GOOSE communication parameters
  * \param interfaceId name of the Ethernet interface to use (e.g. "eth0")
- * 
- * \return the new GoosePublisher instance
  */
 LIB61850_API GoosePublisher
 GoosePublisher_create(CommParameters* parameters, const char* interfaceID);
 
 /**
- * \brief Create a new GoosePublisher instance for Ethernet GOOSE
+ * \brief Create a new GoosePublisher instance
  *
  * \param parameters GOOSE communication parameters
  * \param interfaceId name of the Ethernet interface to use (e.g. "eth0")
  * \param useVlanTag enable or disable the usage of VLAN tags in GOOSE messages
- * 
- * \return the new GoosePublisher instance
  */
 LIB61850_API GoosePublisher
 GoosePublisher_createEx(CommParameters* parameters, const char* interfaceID, bool useVlanTag);
 
-/**
- * \brief Create a new GoosePublisher instance for R-GOOSE
- *
- * \param session R-session protocol instance to use
- * \param appId the appID value to use
- * 
- * \return the new GoosePublisher instance
- */
-LIB61850_API GoosePublisher
-GoosePublisher_createRemote(RSession session, uint16_t appId);
-
 /**
  * \brief Release all resources of the GoosePublisher instance
  *
@@ -186,7 +170,7 @@ GoosePublisher_setStNum(GoosePublisher self, uint32_t stNum);
  * NOTE: Only for testing! The sequence number is increase manually whenever \ref GoosePublisher_publish is called.
  *
  * \param self GoosePublisher instance
- * \param sqNum the sequence number of the next GOOSE message to send
+ * \param stNum the state number of the next GOOSE message to send
  */
 LIB61850_API void
 GoosePublisher_setSqNum(GoosePublisher self, uint32_t sqNum);

+ 1 - 12
library/include/libiec61850/goose_receiver.h

@@ -1,7 +1,7 @@
 /*
  *  goose_receiver.h
  *
- *  Copyright 2014-2022 Michael Zillgith
+ *  Copyright 2014-2019 Michael Zillgith
  *
  *  This file is part of libIEC61850.
  *
@@ -32,7 +32,6 @@ extern "C" {
 
 #include "hal_ethernet.h"
 #include "goose_subscriber.h"
-#include "r_session.h"
 
 /**
  * \addtogroup goose_api_group
@@ -65,16 +64,6 @@ GooseReceiver_create(void);
 LIB61850_API GooseReceiver
 GooseReceiver_createEx(uint8_t* buffer);
 
-/**
- * \brief Create a new R-GOOSE receiver instance.
- *
- * \param session the remote session protocol instance
- *
- * \return the newly created receiver instance
- */
-LIB61850_API GooseReceiver
-GooseReceiver_createRemote(RSession session);
-
 /**
  * \brief sets the interface for the GOOSE receiver
  *

+ 1 - 2
library/include/libiec61850/goose_subscriber.h

@@ -1,7 +1,7 @@
 /*
  *  goose_subscriber.h
  *
- *  Copyright 2013-2022 Michael Zillgith
+ *  Copyright 2013-2021 Michael Zillgith
  *
  *  This file is part of libIEC61850.
  *
@@ -47,7 +47,6 @@ typedef enum
     GOOSE_PARSE_ERROR_UNDERFLOW,
     GOOSE_PARSE_ERROR_TYPE_MISMATCH,
     GOOSE_PARSE_ERROR_LENGTH_MISMATCH,
-    GOOSE_PARSE_ERROR_INVALID_PADDING
 } GooseParseError;
 
 typedef struct sGooseSubscriber* GooseSubscriber;

+ 0 - 30
library/include/libiec61850/hal_ethernet.h

@@ -36,13 +36,6 @@ typedef struct sEthernetSocket* EthernetSocket;
 /** Opaque reference for a set of Ethernet socket handles */
 typedef struct sEthernetHandleSet* EthernetHandleSet;
 
-typedef enum {
-    ETHERNET_SOCKET_MODE_PROMISC, /**<< receive all Ethernet messages */
-    ETHERNET_SOCKET_MODE_ALL_MULTICAST, /**<< receive all multicast messages */
-    ETHERNET_SOCKET_MODE_MULTICAST, /**<< receive only specific multicast messages */
-    ETHERNET_SOCKET_MODE_HOST_ONLY /**<< receive only messages for the host */
-} EthernetSocketMode;
-
 /**
  * \brief Create a new connection handle set (EthernetHandleSet)
  *
@@ -124,29 +117,6 @@ Ethernet_destroySocket(EthernetSocket ethSocket);
 PAL_API void
 Ethernet_sendPacket(EthernetSocket ethSocket, uint8_t* buffer, int packetSize);
 
-/*
- * \brief set the receive mode of the Ethernet socket
- *
- * NOTE: When not implemented the the implementation has to be able to receive
- * all messages required by GOOSE and/or SV (usually multicast addresses).
- *
- * \param ethSocket the ethernet socket handle
- * \param mode the mode of the socket
- */
-PAL_API void
-Ethernet_setMode(EthernetSocket ethSocket, EthernetSocketMode mode);
-
-/**
- * \brief Add a multicast address to be received by the Ethernet socket
- *
- * Used when mode is ETHERNET_SOCKET_MODE_MULTICAST
- *
- * \param ethSocket the ethernet socket handle
- * \param multicastAddress the multicast Ethernet address (this has to be a byte buffer of at least 6 byte)
- */
-PAL_API void
-Ethernet_addMulticastAddress(EthernetSocket ethSocket, uint8_t* multicastAddress);
-
 /*
  * \brief set a protocol filter for the specified etherType
  *

+ 4 - 39
library/include/libiec61850/hal_socket.h

@@ -1,7 +1,7 @@
 /*
  *  socket_hal.h
  *
- *  Copyright 2013-2022 Michael Zillgith
+ *  Copyright 2013-2021 Michael Zillgith
  *
  *  This file is part of Platform Abstraction Layer (libpal)
  *  for libiec61850, libmms, and lib60870.
@@ -128,44 +128,9 @@ Handleset_destroy(HandleSet self);
 PAL_API ServerSocket
 TcpServerSocket_create(const char* address, int port);
 
-/**
- * \brief Create an IPv4 UDP socket instance
- *
- * \return new UDP socket instance
- */
 PAL_API UdpSocket
 UdpSocket_create(void);
 
-/**
- * \brief Create an IPv6 UDP socket instance
- *
- * \return new UDP socket instance
- */
-PAL_API UdpSocket
-UdpSocket_createIpV6(void);
-
-/**
- * \brief Add the socket to an IPv4 or IPv6 multicast group
- *
- * \param self UDP socket instance
- * \param multicastAddress IPv4 or IPv6 multicast address
- *
- * \return true on success, false otherwise
- */
-PAL_API bool
-UdpSocket_addGroupMembership(UdpSocket self, const char* multicastAddress);
-
-/**
- * \brief Sets the multicast TTL (number of hops) for this UDP socket
- *
- * \param self UDP socket instance
- * \param ttl number of hops for multicast messages. Default is 1 (not routable!)
- *
- * \return true on success, false otherwise
- */
-PAL_API bool
-UdpSocket_setMulticastTtl(UdpSocket self, int ttl);
-
 PAL_API bool
 UdpSocket_bind(UdpSocket self, const char* address, int port);
 
@@ -341,7 +306,7 @@ Socket_getLocalAddress(Socket self);
 /**
  * \brief Get the address of the peer application (IP address and port number)
  *
- * The peer address has to be returned as null terminated string
+ * The peer address has to be returned as
  *
  * Implementation of this function is MANDATORY (libiec61850)
  *
@@ -355,9 +320,9 @@ Socket_getPeerAddress(Socket self);
 /**
  * \brief Get the address of the peer application (IP address and port number)
  *
- * The peer address has to be returned as null terminated string
+ * The peer address has to be returned as
  *
- * Implementation of this function is MANDATORY (lib60870 and libiec61850)
+ * Implementation of this function is MANDATORY (lib60870)
  *
  * \param self the client, connection or server socket instance
  * \param peerAddressString a string to store the peer address (the string should have space

+ 1 - 1
library/include/libiec61850/hal_time.h

@@ -1,7 +1,7 @@
 /*
  *  time.c
  *
- *  Copyright 2013-2022 Michael Zillgith
+ *  Copyright 2013-2021 Michael Zillgith
  *
  *  This file is part of Platform Abstraction Layer (libpal)
  *  for libiec61850, libmms, and lib60870.

+ 0 - 2
library/include/libiec61850/iec61850_cdc.h

@@ -36,8 +36,6 @@ extern "C" {
 /**
  * @defgroup COMMON_DATA_CLASSES Helper functions to create common data classes (CDC) using the dynamic model API
  *
- * \brief Helper functions to create compliant common data classes (CDC) using the dynamic model API.
- *
  * Currently supports CDCs from IEC 61850-7-3:2010 (Edition 2)
  *
  * @{

+ 27 - 106
library/include/libiec61850/iec61850_client.h

@@ -1,7 +1,7 @@
 /*
  *  iec61850_client.h
  *
- *  Copyright 2013-2023 Michael Zillgith
+ *  Copyright 2013-2021 Michael Zillgith
  *
  *  This file is part of libIEC61850.
  *
@@ -162,9 +162,6 @@ typedef enum {
     /** Received an invalid response message from the server */
     IED_ERROR_MALFORMED_MESSAGE = 34,
 
-    /** Service was not executed because required resource is still in use */
-    IED_ERROR_OBJECT_CONSTRAINT_CONFLICT = 35,
-
     /** Service not implemented */
     IED_ERROR_SERVICE_NOT_IMPLEMENTED = 98,
 
@@ -172,14 +169,6 @@ typedef enum {
     IED_ERROR_UNKNOWN = 99
 } IedClientError;
 
-/**
- * \brief Convert error value to string
- *
- * \return string constant representing the error
- */
-LIB61850_API const char*
-IedClientError_toString(IedClientError err);
-
 /**************************************************
  * Connection creation and destruction
  **************************************************/
@@ -242,17 +231,6 @@ IedConnection_createWithTlsSupport(TLSConfiguration tlsConfig);
 LIB61850_API void
 IedConnection_destroy(IedConnection self);
 
-/**
-* \brief Set the local IP address and port to be used by the client
-*
-* NOTE: This function is optional. When not used the OS decides what IP address and TCP port to use.
-*
-* \param self IedConnection instance
-* \param localIpAddress the local IP address or hostname as C string
-* \param localPort the local TCP port to use. When < 1 the OS will chose the TCP port to use.
-*/
-LIB61850_API void
-IedConnection_setLocalAddress(IedConnection self, const char* localIpAddress, int localPort);
 
 /**
  * \brief set the connect timeout in ms
@@ -266,16 +244,6 @@ IedConnection_setLocalAddress(IedConnection self, const char* localIpAddress, in
 LIB61850_API void
 IedConnection_setConnectTimeout(IedConnection self, uint32_t timeoutInMs);
 
-/**
- * \brief Set the maximum number outstanding calls allowed for this connection
- *
- * \param self the connection object
- * \param calling the maximum outstanding calls allowed by the caller (client)
- * \param called the maximum outstanding calls allowed by the called endpoint (server)
- */
-LIB61850_API void
-IedConnection_setMaxOutstandingCalls(IedConnection self, int calling, int called);
-
 /**
  * \brief set the request timeout in ms
  *
@@ -795,9 +763,8 @@ ClientGooseControlBlock_setDstAddress_appid(ClientGooseControlBlock self, uint16
  ********************************************************/
 
 /**
- * \brief Read access to attributes of a GOOSE control block (GoCB) at the connected server.
- *
- * A GoCB contains the configuration values for a single GOOSE publisher.
+ * \brief Read access to attributes of a GOOSE control block (GoCB) at the connected server. A GoCB contains
+ * the configuration values for a single GOOSE publisher.
  *
  * The requested GoCB has to be specified by its object IEC 61850 ACSI object reference. E.g.
  *
@@ -825,42 +792,6 @@ ClientGooseControlBlock_setDstAddress_appid(ClientGooseControlBlock self, uint16
 LIB61850_API ClientGooseControlBlock
 IedConnection_getGoCBValues(IedConnection self, IedClientError* error, const char* goCBReference, ClientGooseControlBlock updateGoCB);
 
-typedef void
-(*IedConnection_GetGoCBValuesHandler) (uint32_t invokeId, void* parameter, IedClientError err, ClientGooseControlBlock goCB);
-
-/**
- * \brief Read access to attributes of a GOOSE control block (GoCB) at the connected server (async version)
- *
- * A GoCB contains the configuration values for a single GOOSE publisher.
- *
- * The requested GoCB has to be specified by its object IEC 61850 ACSI object reference. E.g.
- *
- * "simpleIOGernericIO/LLN0.gcbEvents"
- *
- * This function is used to perform the actual read service for the GoCB values.
- * To access the received values the functions of ClientGooseControlBlock have to be used.
- *
- * If called with a NULL argument for the updateGoCB parameter a new ClientGooseControlBlock instance is created
- * and populated with the values received by the server. It is up to the user to release this object by
- * calling the ClientGooseControlBlock_destroy function when the object is no longer needed. If called with a reference
- * to an existing ClientGooseControlBlock instance the values of the attributes will be updated and no new instance
- * will be created.
- *
- * Note: This function maps to a single MMS read request to retrieve the complete GoCB at once.
- *
- * \param connection the connection object
- * \param error the error code if an error occurs
- * \param goCBReference IEC 61850-7-2 ACSI object reference of the GOOSE control block
- * \param updateRcb a reference to an existing ClientGooseControlBlock instance or NULL
- * \param handler the user callback that is called when the service is completed or timed out
- * \param parameter user provided parameter that is passed to the callback handler
- *
- * \return the invoke ID of the request
- */
-LIB61850_API uint32_t
-IedConnection_getGoCBValuesAsync(IedConnection self, IedClientError* error, const char* goCBReference, ClientGooseControlBlock updateGoCB,
-    IedConnection_GetGoCBValuesHandler handler, void* parameter);
-
 /**
  * \brief Write access to attributes of a GOOSE control block (GoCB) at the connected server
  *
@@ -886,35 +817,6 @@ LIB61850_API void
 IedConnection_setGoCBValues(IedConnection self, IedClientError* error, ClientGooseControlBlock goCB,
         uint32_t parametersMask, bool singleRequest);
 
-/**
- * \brief Write access to attributes of a GOOSE control block (GoCB) at the connected server (async version)
- *
- * The GoCB and the values to be written are specified with the goCB parameter.
- *
- * The parametersMask parameter specifies which attributes of the remote GoCB have to be set by this request.
- * You can specify multiple attributes by ORing the defined bit values. If all attributes have to be written
- * GOCB_ELEMENT_ALL can be used.
- *
- * The singleRequest parameter specifies the mapping to the corresponding MMS write request. Standard compliant
- * servers should accept both variants. But some server accept only one variant. Then the value of this parameter
- * will be of relevance.
- *
- * \param connection the connection object
- * \param error the error code if an error occurs
- * \param goCB ClientGooseControlBlock instance that actually holds the parameter
- *            values to be written.
- * \param parametersMask specifies the parameters contained in the setGoCBValues request.
- * \param singleRequest specifies if the seGoCBValues services is mapped to a single MMS write request containing
- *        multiple variables or to multiple MMS write requests.
- * \param handler the user callback that is called when the service is completed or timed out
- * \param parameter user provided parameter that is passed to the callback handler
- *
- * \return the invoke ID of the request
- */
-LIB61850_API uint32_t
-IedConnection_setGoCBValuesAsync(IedConnection self, IedClientError* error, ClientGooseControlBlock goCB,
-    uint32_t parametersMask, bool singleRequest, IedConnection_GenericServiceHandler handler, void* parameter);
-
 /** @} */
 
 
@@ -1238,6 +1140,15 @@ typedef int ReasonForInclusion;
 /** the reason for inclusion is unknown (e.g. report is not configured to include reason-for-inclusion) */
 #define IEC61850_REASON_UNKNOWN 32
 
+#define REASON_NOT_INCLUDED IEC61850_REASON_NOT_INCLUDED
+#define REASON_DATA_CHANGE IEC61850_REASON_DATA_CHANGE
+#define REASON_QUALITY_CHANGE IEC61850_REASON_QUALITY_CHANGE
+#define REASON_DATA_UPDATE IEC61850_REASON_DATA_UPDATE
+#define REASON_INTEGRITY IEC61850_REASON_INTEGRITY
+#define REASON_GI IEC61850_REASON_GI
+#define REASON_UNKNOWN IEC61850_REASON_UNKNOWN
+
+
 /* Element encoding mask values for ClientReportControlBlock */
 
 /** include the report ID into the setRCB request */
@@ -1334,11 +1245,9 @@ typedef void (*ReportCallbackFunction) (void* parameter, ClientReport report);
  * Otherwise the internal data structures storing the received data set values will not be updated
  * correctly.
  *
- * \note Replacing a report handler you only have to call this function. There is no separate call to
+ * When replacing a report handler you only have to call this function. There is no separate call to
  * IedConnection_uninstallReportHandler() required.
  *
- * \note Do not call this function inside of the ReportCallbackFunction. Doing so will cause a deadlock.
- *
  * \param self the connection object
  * \param rcbReference object reference of the report control block
  * \param rptId a string that identifies the report. If the rptId is not available then the
@@ -1353,8 +1262,6 @@ IedConnection_installReportHandler(IedConnection self, const char* rcbReference,
 /**
  * \brief uninstall a report handler function for the specified report control block (RCB)
  *
- * \note Do not call this function inside of the ReportCallbackFunction. Doing so will cause a deadlock.
- *
  * \param self the connection object
  * \param rcbReference object reference of the report control block
  */
@@ -2549,6 +2456,20 @@ IedConnection_getServerDirectory(IedConnection self, IedClientError* error, bool
 LIB61850_API LinkedList /*<char*>*/
 IedConnection_getLogicalDeviceDirectory(IedConnection self, IedClientError* error, const char* logicalDeviceName);
 
+typedef enum {
+    ACSI_CLASS_DATA_OBJECT,
+    ACSI_CLASS_DATA_SET,
+    ACSI_CLASS_BRCB,
+    ACSI_CLASS_URCB,
+    ACSI_CLASS_LCB,
+    ACSI_CLASS_LOG,
+    ACSI_CLASS_SGCB,
+    ACSI_CLASS_GoCB,
+    ACSI_CLASS_GsCB,
+    ACSI_CLASS_MSVCB,
+    ACSI_CLASS_USVCB
+} ACSIClass;
+
 /**
  * \brief returns a list of all MMS variables that are children of the given logical node
  *

+ 19 - 24
library/include/libiec61850/iec61850_common.h

@@ -55,21 +55,6 @@ typedef struct {
     uint8_t dstAddress[6];
 } PhyComAddress;
 
-/** IEC 61850 ACSI classes */
-typedef enum {
-    ACSI_CLASS_DATA_OBJECT,
-    ACSI_CLASS_DATA_SET,
-    ACSI_CLASS_BRCB,
-    ACSI_CLASS_URCB,
-    ACSI_CLASS_LCB,
-    ACSI_CLASS_LOG,
-    ACSI_CLASS_SGCB,
-    ACSI_CLASS_GoCB,
-    ACSI_CLASS_GsCB,
-    ACSI_CLASS_MSVCB,
-    ACSI_CLASS_USVCB
-} ACSIClass;
-
 /**
  * \brief Control model (represented by "ctlModel" attribute)
  */
@@ -256,6 +241,25 @@ typedef enum {
  * @{
  */
 
+#if (CONFIG_PROVIDE_OLD_FC_DEFINES == 1)
+#define ST IEC61850_FC_ST
+#define MX IEC61850_FC_MX
+#define SP IEC61850_FC_SP
+#define SV IEC61850_FC_SV
+#define CF IEC61850_FC_CF
+#define DC IEC61850_FC_DC
+#define SG IEC61850_FC_SG
+#define SE IEC61850_FC_SE
+#define SR IEC61850_FC_SR
+#define OR IEC61850_FC_OR
+#define BL IEC61850_FC_BL
+#define EX IEC61850_FC_EX
+#define CO IEC61850_FC_CO
+#define ALL IEC61850_FC_ALL
+#define NONE IEC61850_FC_NONE
+#endif /* (CONFIG_PROVIDE_OLD_FC_DEFINES == 1) */
+
+
 /** FCs (Functional constraints) according to IEC 61850-7-2 */
 typedef enum eFunctionalConstraint {
     /** Status information */
@@ -460,15 +464,6 @@ Timestamp_setClockNotSynchronized(Timestamp* self, bool value);
 LIB61850_API int
 Timestamp_getSubsecondPrecision(Timestamp* self);
 
-LIB61850_API void
-Timestamp_setFractionOfSecondPart(Timestamp* self, uint32_t fractionOfSecond);
-
-LIB61850_API uint32_t
-Timestamp_getFractionOfSecondPart(Timestamp* self);
-
-LIB61850_API float
-Timestamp_getFractionOfSecond(Timestamp* self);
-
 /**
  * \brief Set the subsecond precision value of the time stamp
  *

+ 0 - 2
library/include/libiec61850/iec61850_config_file_parser.h

@@ -37,8 +37,6 @@ extern "C" {
 /**
  * @defgroup CONFIG_FILE_PARSER Create data models by configuration files
  *
- * \brief Functions to create data models from simple text configuration files create with the configuration file tool.
- *
  * @{
  */
 

+ 3 - 97
library/include/libiec61850/iec61850_dynamic_model.h

@@ -39,8 +39,6 @@ extern "C" {
 /**
  * @defgroup DYNAMIC_MODEL General dynamic model creation functions
  *
- * \brief Functions to dynamically create IEC 61850 data models without using SCL or configuration files
- *
  * @{
  */
 
@@ -84,7 +82,7 @@ LIB61850_API void
 IedModel_destroy(IedModel* model);
 
 /**
- * \brief Create a new logical device and add it to the IED model
+ * \brief Create a new logical device model and add it to the IED model
  *
  * \param name the name of the new logical device
  * \param parent the parent IED model
@@ -94,17 +92,6 @@ IedModel_destroy(IedModel* model);
 LIB61850_API LogicalDevice*
 LogicalDevice_create(const char* name, IedModel* parent);
 
-/**
- * \brief Create a new logical device and add it to the IED model
- *
- * \param name the name of the new logical device
- * \param parent the parent IED model
- * \param ldName when not NULL functional naming is used for this LD (ldName <= 64 chars)
- *
- * \return the newly created LogicalDevice instance
- */
-LIB61850_API LogicalDevice*
-LogicalDevice_createEx(const char* inst, IedModel* parent, const char* ldName);
 
 /**
  * \brief Create a new logical mode  and add it to a logical device
@@ -118,12 +105,9 @@ LIB61850_API LogicalNode*
 LogicalNode_create(const char* name, LogicalDevice* parent);
 
 /**
- * \brief create a new data object or array data object and add it to a parent model node
+ * \brief create a new data object and add it to a parent model node
  *
  * The parent model node has to be of type DataObject or LogicalNode.
- * 
- * NOTE: When the data object is an array the array elements will also be created by this function.
- * This will result in child DataObject instances for each array element.
  *
  * \param name the name of the data object (e.h. "Mod", "Health" ...)
  * \param parent the parent model node
@@ -259,96 +243,27 @@ ReportControlBlock_isBuffered(ReportControlBlock* self);
 LIB61850_API LogicalNode*
 ReportControlBlock_getParent(ReportControlBlock* self);
 
-/**
- * \brief Get the name of the currently set report ID
- *
- * \param self the RCB instance
- *
- * \return a null terminated string containing the current data set name (the string has to be released by the caller!)
- */
 LIB61850_API char*
 ReportControlBlock_getRptID(ReportControlBlock* self);
 
-/**
- * \brief Check if RCB instance is enabled
- *
- * \param self the RCB instance
- *
- * \return true when the RCB instance is enabled, false otherwise
- */
-LIB61850_API bool
+LIB61850_API int
 ReportControlBlock_getRptEna(ReportControlBlock* self);
 
-/**
- * \brief Get the name of the currenlty set data set
- *
- * \param self the RCB instance
- *
- * \return a null terminated string containing the current data set name (the string has to be released by the caller!)
- */
 LIB61850_API char*
 ReportControlBlock_getDataSet(ReportControlBlock* self);
 
-/**
- * \brief Get the confRev value
- *
- * \param self the RCB instance
- *
- * \return confRev value
- */
 LIB61850_API uint32_t
 ReportControlBlock_getConfRev(ReportControlBlock* self);
 
-/**
- * \brief Get the currently set OptFlds value
- *
- * The OptField (option field) value is a bit field with the following fields:
- * - RPT_OPT_SEQ_NUM
- * - RPT_OPT_TIME_STAMP
- * - RPT_OPT_REASON_FOR_INCLUSION
- * - RPT_OPT_DATA_SET
- * - RPT_OPT_DATA_REFERENCE
- * - RPT_OPT_BUFFER_OVERFLOW
- * - RPT_OPT_ENTRY_ID
- * - RPT_OPT_CONF_REV
- *
- * \param self the RCB instance
- *
- * \return OptFlds options value
- */
 LIB61850_API uint32_t
 ReportControlBlock_getOptFlds(ReportControlBlock* self);
 
-/**
- * \brief Get the BufTm value (buffer time)
- *
- * The buffer time is the maximum value between an event and
- * the actual report generation.
- *
- * \param self the RCB instance
- *
- * \return bufTm value
- */
 LIB61850_API uint32_t
 ReportControlBlock_getBufTm(ReportControlBlock* self);
 
 LIB61850_API uint16_t
 ReportControlBlock_getSqNum(ReportControlBlock* self);
 
-/**
- * \brief Get the currently set trigger options
- *
- * The trigger option value is a bit field with the following fields:
- * - TRG_OPT_DATA_CHANGED
- * - TRG_OPT_QUALITY_CHANGED
- * - TRG_OPT_DATA_UPDATE
- * - TRG_OPT_INTEGRITY
- * - TRG_OPT_GI
- *
- * \param self the RCB instance
- *
- * \return trigger options value
- */
 LIB61850_API uint32_t
 ReportControlBlock_getTrgOps(ReportControlBlock* self);
 
@@ -370,9 +285,6 @@ ReportControlBlock_getTimeofEntry(ReportControlBlock* self);
 LIB61850_API int16_t
 ReportControlBlock_getResvTms(ReportControlBlock* self);
 
-LIB61850_API bool
-ReportControlBlock_getResv(ReportControlBlock* self);
-
 LIB61850_API MmsValue*
 ReportControlBlock_getOwner(ReportControlBlock* self);
 
@@ -397,12 +309,6 @@ LIB61850_API LogControlBlock*
 LogControlBlock_create(const char* name, LogicalNode* parent, const char* dataSetName, const char* logRef, uint8_t trgOps,
         uint32_t intgPd, bool logEna, bool reasonCode);
 
-LIB61850_API const char*
-LogControlBlock_getName(LogControlBlock* self);
-
-LIB61850_API LogicalNode*
-LogControlBlock_getParent(LogControlBlock* self);
-
 /**
  * \brief create a log (used by the IEC 61850 log service)
  *

+ 47 - 29
library/include/libiec61850/iec61850_model.h

@@ -1,7 +1,7 @@
 /*
  *  model.h
  *
- *  Copyright 2013-2024 Michael Zillgith
+ *  Copyright 2013-2016 Michael Zillgith
  *
  *  This file is part of libIEC61850.
  *
@@ -37,8 +37,6 @@ extern "C" {
 /**
  * @defgroup DATA_MODEL General data model definitions, access and iteration functions
  *
- * \brief Functions and structures to access and iterate the IEC 61850 data model
- *
  * @{
  */
 
@@ -123,6 +121,44 @@ typedef enum {
 	IEC61850_CURRENCY = 30,
 	IEC61850_OPTFLDS = 31, /* bit-string(10) */
 	IEC61850_TRGOPS = 32 /* bit-string(6) */
+
+
+#if (CONFIG_IEC61850_USE_COMPAT_TYPE_DECLARATIONS == 1)
+	,
+    BOOLEAN = 0,/* int */
+    INT8 = 1,   /* int8_t */
+    INT16 = 2,  /* int16_t */
+    INT32 = 3,  /* int32_t */
+    INT64 = 4,  /* int64_t */
+    INT128 = 5, /* no native mapping! */
+    INT8U = 6,  /* uint8_t */
+    INT16U = 7, /* uint16_t */
+    INT24U = 8, /* uint32_t */
+    INT32U = 9, /* uint32_t */
+    FLOAT32 = 10, /* float */
+    FLOAT64 = 11, /* double */
+    ENUMERATED = 12,
+    OCTET_STRING_64 = 13,
+    OCTET_STRING_6 = 14,
+    OCTET_STRING_8 = 15,
+    VISIBLE_STRING_32 = 16,
+    VISIBLE_STRING_64 = 17,
+    VISIBLE_STRING_65 = 18,
+    VISIBLE_STRING_129 = 19,
+    VISIBLE_STRING_255 = 20,
+    UNICODE_STRING_255 = 21,
+    TIMESTAMP = 22,
+    QUALITY = 23,
+    CHECK = 24,
+    CODEDENUM = 25,
+    GENERIC_BITSTRING = 26,
+    CONSTRUCTED = 27,
+    ENTRY_TIME = 28,
+    PHYCOMADDR = 29,
+    CURRENCY = 30
+    OPTFLDS = 31,
+    TRGOPS = 32
+#endif
 } DataAttributeType;
 
 typedef enum {
@@ -147,11 +183,10 @@ struct sIedModel {
 
 struct sLogicalDevice {
     ModelNodeType modelType;
-    char* name; /* LD instance */
+    char* name;
     ModelNode* parent;
     ModelNode* sibling;
     ModelNode* firstChild;
-    char* ldName; /* ldName (when using functional naming) */
 };
 
 struct sModelNode {
@@ -177,8 +212,7 @@ struct sDataObject {
     ModelNode* sibling;
     ModelNode* firstChild;
 
-    int elementCount; /* value > 0 if this is an array */
-    int arrayIndex; /* value > -1 when this is an array element */
+    int elementCount; /* > 0 if this is an array */
 };
 
 struct sDataAttribute {
@@ -188,8 +222,7 @@ struct sDataAttribute {
     ModelNode* sibling;
     ModelNode* firstChild;
 
-    int elementCount; /* value > 0 if this is an array */
-    int arrayIndex; /* value > -1 when this is an array element */
+    int elementCount; /* > 0 if this is an array */
 
     FunctionalConstraint fc;
     DataAttributeType type;
@@ -198,11 +231,11 @@ struct sDataAttribute {
 
     MmsValue* mmsValue;
 
-    uint32_t sAddr; /* TODO remove in version 2.0 */
+    uint32_t sAddr;
 };
 
 typedef struct sDataSetEntry {
-    char* logicalDeviceName; /* logical device instance name */
+    char* logicalDeviceName;
     bool isLDNameDynamicallyAllocated;
     char* variableName;
     int index;
@@ -212,7 +245,7 @@ typedef struct sDataSetEntry {
 } DataSetEntry;
 
 struct sDataSet {
-    char* logicalDeviceName; /* logical device instance name */
+    char* logicalDeviceName;
     char* name; /* eg. MMXU1$dataset1 */
     int elementCount;
     DataSetEntry* fcdas;
@@ -333,22 +366,11 @@ ModelNode_getChildCount(ModelNode* self);
  * \param self the model node instance
  * \param name the name of the child model node
  *
- * \return the model node instance or NULL if model node does not exist.
+ * \return  the model node instance or NULL if model node does not exist.
  */
 LIB61850_API ModelNode*
 ModelNode_getChild(ModelNode* self, const char* name);
 
-/**
- * \brief return the child node of an array or other structure
- *
- * \param self the model node instance
- * \param idx the index (e.g. array index) starting with 0
- *
- * \return the model node instance or NULL if model node with given index does not exist.
- */
-LIB61850_API ModelNode*
-ModelNode_getChildWithIdx(ModelNode* self, int idx);
-
 /**
  * \brief return a child model node with a given functional constraint
  *
@@ -448,8 +470,6 @@ IedModel_setIedName(IedModel* self, const char* iedName);
  * This function uses the full logical device name as part of the object reference
  * as it happens to appear on the wire. E.g. if IED name in SCL file would be "IED1"
  * and the logical device "WD1" the resulting LD name would be "IED1WD".
- * When using functional naming in the LD (with ldName attribute) then the logical
- * device name is identical with the ldName attribute.
  *
  * \param self the IedModel instance that holds the model node
  * \param objectReference the IEC 61850 object reference
@@ -466,9 +486,7 @@ IedModel_getSVControlBlock(IedModel* self, LogicalNode* parentLN, const char* sv
  * \brief Lookup a model node by its short (normalized) reference
  *
  * This version uses the object reference that does not contain the
- * IED name or functional name as part of the logical device name.
- * Instead the LD part consists of the LD instance name ("inst" attribute).
- * This function is useful for
+ * IED name as part of the logical device name. This function is useful for
  * devices where the IED name can be configured.
  *
  * \param self the IedModel instance that holds the model node

+ 33 - 319
library/include/libiec61850/iec61850_server.h

@@ -3,7 +3,7 @@
  *
  *  IEC 61850 server API for libiec61850.
  *
- *  Copyright 2013-2024 Michael Zillgith
+ *  Copyright 2013-2022 Michael Zillgith
  *
  *  This file is part of libIEC61850.
  *
@@ -32,11 +32,6 @@ extern "C" {
 #endif
 
 /** \defgroup server_api_group IEC 61850/MMS server API
- *
- * \brief IEC 61850/MMS server API for libiec61850.
- *
- * This API can be used to create, configure, and run IEC 61850/MMS server instances.
- *
  *  @{
  */
 
@@ -47,22 +42,6 @@ extern "C" {
 #include "iso_connection_parameters.h"
 #include "iec61850_config_file_parser.h"
 
-/**
- * @defgroup IEC61850_SERVER_CONFIG Server configuration related functions
- *
- * \brief Functions to handle server independent configuration settings to define
- *        services, features, and other behavior of IEC 61850 server instances.
- *
- * @{
- */
-
-#define IEC61850_REPORTSETTINGS_RPT_ID 1
-#define IEC61850_REPORTSETTINGS_BUF_TIME 2
-#define IEC61850_REPORTSETTINGS_DATSET 4
-#define IEC61850_REPORTSETTINGS_TRG_OPS 8
-#define IEC61850_REPORTSETTINGS_OPT_FIELDS 16
-#define IEC61850_REPORTSETTINGS_INTG_PD 32
-
 /**
  * \brief Configuration object to configure IEC 61850 stack features
  */
@@ -117,12 +96,6 @@ struct sIedServerConfig
 
     /** RCB has owner attribute (default: true) */
     bool enableOwnerForRCB;
-
-    /** integrity report start times will by synchronized with straight numbers (default: false) */
-    bool syncIntegrityReportTimes;
-
-    /** for each configurable ReportSetting there is a separate flag (default: Dyn = enable write for all) */
-    uint8_t reportSettingsWritable;
 };
 
 /**
@@ -206,30 +179,6 @@ IedServerConfig_setMaxMmsConnections(IedServerConfig self, int maxConnections);
 LIB61850_API int
 IedServerConfig_getMaxMmsConnections(IedServerConfig self);
 
-/**
- * \brief Enable synchronized integrity report times
- *
- * NOTE: When this flag is enabled the integrity report generation times are
- * aligned with the UTC epoch. Then the unix time stamps are straight multiples of the
- * integrity interval.
- *
- * \param enable when true synchronized integrity report times are enabled
- */
-LIB61850_API void
-IedServerConfig_setSyncIntegrityReportTimes(IedServerConfig self, bool enable);
-
-/**
- * \brief Check if synchronized integrity report times are enabled
- *
- * NOTE: When this flag is enabled the integrity report generation times are
- * aligned with the UTC epoch. Then the unix time stamps are straight multiples of the
- * integrity interval.
- *
- * \return true, when enabled, false otherwise
- */
-LIB61850_API bool
-IedServerConfig_getSyncIntegrityReportTimes(IedServerConfig self);
-
 /**
  * \brief Set the basepath of the file services
  *
@@ -413,45 +362,21 @@ LIB61850_API bool
 IedServerConfig_isLogServiceEnabled(IedServerConfig self);
 
 /**
- * \brief Make a configurable report setting writeable or read-only
- *
- * \note Can be used to implement some of Services\ReportSettings options
- *
- * \param[in] setting one of IEC61850_REPORTSETTINGS_RPT_ID, _BUF_TIME, _DATSET, _TRG_OPS, _OPT_FIELDS, _INTG_PD
- * \param[in] isDyn true, when setting is writable ("Dyn") or false, when read-only
+ * An opaque handle for an IED server instance
  */
-LIB61850_API void
-IedServerConfig_setReportSetting(IedServerConfig self, uint8_t setting, bool isDyn);
+typedef struct sIedServer* IedServer;
 
 /**
- * \brief Check if a configurable report setting is writable or read-only
- *
- * \param[in] setting one of IEC61850_REPORTSETTINGS_RPT_ID, _BUF_TIME, _DATSET, _TRG_OPS, _OPT_FIELDS, _INTG_PD
- *
- * \return  true, when setting is writable ("Dyn") or false, when read-only
+ * An opaque handle for a client connection
  */
-LIB61850_API bool
-IedServerConfig_getReportSetting(IedServerConfig self, uint8_t setting);
-
-/**@}*/
+typedef struct sClientConnection* ClientConnection;
 
 /**
  * @defgroup IEC61850_SERVER_GENERAL General server setup and management functions
  *
- * \brief Functions to create, configure, and manage an IEC 61850 server instance.
- *
  * @{
  */
 
-/**
- * An opaque handle for an IED server instance
- */
-typedef struct sIedServer* IedServer;
-
-/**
- * An opaque handle for a client connection
- */
-typedef struct sClientConnection* ClientConnection;
 
 /**
  * \brief Create a new IedServer instance
@@ -540,18 +465,6 @@ IedServer_setServerIdentity(IedServer self, const char* vendor, const char* mode
 LIB61850_API void
 IedServer_setFilestoreBasepath(IedServer self, const char* basepath);
 
-/**
- * \brief Assign a \ref LogStorage instance to a log reference
- *
- * \note configuration option CONFIG_IEC61850_LOG_SERVICE is required
- *
- * \param self the IedServer instance
- * \param logRef the log reference to assign the log storage to
- * \param logStorage the log storage instance to assign
- */
-LIB61850_API void
-IedServer_setLogStorage(IedServer self, const char* logRef, LogStorage logStorage);
-
 /**
  * \brief Start handling client connections
  *
@@ -680,7 +593,7 @@ IedServer_getMmsServer(IedServer self);
  * then configured GOOSE control blocks keep inactive until a MMS client enables
  * them by writing to the GOOSE control block.
  *
- * \note This function has no effect when CONFIG_INCLUDE_GOOSE_SUPPORT is not set.
+ * Note: This function has no effect when CONFIG_INCLUDE_GOOSE_SUPPORT is not set.
  *
  * \param self the instance of IedServer to operate on.
  */
@@ -693,7 +606,7 @@ IedServer_enableGoosePublishing(IedServer self);
  * This will set the GoEna attribute of all configured GOOSE control blocks
  * to false. This will stop GOOSE transmission.
  *
- * \note This function has no effect when CONFIG_INCLUDE_GOOSE_SUPPORT is not set.
+ * Note: This function has no effect when CONFIG_INCLUDE_GOOSE_SUPPORT is not set.
  *
  * \param self the instance of IedServer to operate on.
  */
@@ -704,11 +617,10 @@ IedServer_disableGoosePublishing(IedServer self);
  * \brief Set the Ethernet interface to be used by GOOSE publishing
  *
  * This function can be used to set the GOOSE interface ID. If not used or set to NULL the
- * default interface ID from stack_config.h is used.
- *
- * \note the interface ID is operating system specific!
+ * default interface ID from stack_config.h is used. Note the interface ID is operating system
+ * specific!
  *
- * \note This function has no effect when CONFIG_INCLUDE_GOOSE_SUPPORT is not set.
+ * Note: This function has no effect when CONFIG_INCLUDE_GOOSE_SUPPORT is not set.
  *
  * \param self the instance of IedServer to operate on.
  * \param interfaceId the ID of the ethernet interface to be used for GOOSE publishing
@@ -722,7 +634,7 @@ IedServer_setGooseInterfaceId(IedServer self, const char* interfaceId);
  * This function can be used to set the GOOSE interface ID forG all CBs (parameter ln = NULL) or for
  * a specific GCB specified by the logical node instance and the GCB name.
  *
- * \note This function has no effect when CONFIG_INCLUDE_GOOSE_SUPPORT is not set.
+ * Note: This function has no effect when CONFIG_INCLUDE_GOOSE_SUPPORT is not set.
  *
  * \param self the instance of IedServer to operate on.
  * \param ln the logical node that contains the GCB or NULL to set the ethernet interface ID for all GCBs
@@ -738,7 +650,7 @@ IedServer_setGooseInterfaceIdEx(IedServer self, LogicalNode* ln, const char* gcb
  * This function can be used to enable/disable VLAN tagging for all GCBs (parameter ln = NULL) or for
  * a specific GCB specified by the logical node instance and the GCB name.
  *
- * \note This function has no effect when CONFIG_INCLUDE_GOOSE_SUPPORT is not set.
+ * Note: This function has no effect when CONFIG_INCLUDE_GOOSE_SUPPORT is not set.
  *
  * \param self the instance of IedServer to operate on
  * \param ln the logical node that contains the GCB or NULL to enable/disable VLAN tagging for all GCBs
@@ -748,28 +660,11 @@ IedServer_setGooseInterfaceIdEx(IedServer self, LogicalNode* ln, const char* gcb
 LIB61850_API void
 IedServer_useGooseVlanTag(IedServer self, LogicalNode* ln, const char* gcbName, bool useVlanTag);
 
-/**
- * \brief Set the time quality for all timestamps internally generated by this IedServer instance
- * 
- * You can call this function during the initialization of the server or whenever a time quality
- * flag has to be updated (on clock failure or change of time synchronization state).
- *
- * \param self the instance of IedServer to operate on.
- * \param leapSecondKnown set/unset leap seconds known flag
- * \param clockFailure set/unset clock failure flag
- * \param clockNotSynchronized set/unset clock not synchronized flag
- * \param subsecondPrecision set the subsecond precision (number of significant bits of the fractionOfSecond part of the time stamp)
- */
-LIB61850_API void
-IedServer_setTimeQuality(IedServer self, bool leapSecondKnown, bool clockFailure, bool clockNotSynchronized, int subsecondPrecision);
-
 /**@}*/
 
 /**
  * @defgroup IEC61850_SERVER_CONNECTION_HANDLING Connection handling and client authentication
  *
- * \brief Functions and callbacks to control client access and connection handling.
- *
  * @{
  */
 
@@ -788,10 +683,12 @@ IedServer_setTimeQuality(IedServer self, bool leapSecondKnown, bool clockFailure
 LIB61850_API void
 IedServer_setAuthenticator(IedServer self, AcseAuthenticator authenticator, void* authenticatorParameter);
 
+
+
 /**
  * \brief get the peer address of this connection as string
  *
- * \note the returned string is only valid as long as the client connection exists. It is save to use
+ * Note: the returned string is only valid as long as the client connection exists. It is save to use
  * the string inside of the connection indication callback function.
  *
  * \param self the ClientConnection instance
@@ -803,7 +700,7 @@ ClientConnection_getPeerAddress(ClientConnection self);
 /**
  * \brief get the local address of this connection as string
  *
- * \note the returned string is only valid as long as the client connection exists. It is save to use
+ * Note: the returned string is only valid as long as the client connection exists. It is save to use
  * the string inside of the connection indication callback function.
  *
  * \param self the ClientConnection instance
@@ -846,27 +743,16 @@ typedef void (*IedConnectionIndicationHandler) (IedServer self, ClientConnection
 LIB61850_API void
 IedServer_setConnectionIndicationHandler(IedServer self, IedConnectionIndicationHandler handler, void* parameter);
 
-/**
- * \brief Ignore all requests from clients (for testing purposes)
- *
- * NOTE: This function will block all client requests on MMS layer
- * 
- * \param self the instance of IedServer to configure.
- * \param enable when true all requests from clients will be ignored
- */
-void
-IedServer_ignoreClientRequests(IedServer self, bool enable);
 
 /**@}*/
 
 /**
  * @defgroup IEC61850_SERVER_DATA_MODEL_ACCESS Data model access and data update
  *
- * \brief Functions to access and update the data model of an IEC 61850 server instance.
- *
  * @{
  */
 
+
 /**
  * \brief Lock the data model for data update.
  *
@@ -1025,8 +911,9 @@ IedServer_getBitStringAttributeValue(IedServer self, const DataAttribute* dataAt
 LIB61850_API const char*
 IedServer_getStringAttributeValue(IedServer self, const DataAttribute* dataAttribute);
 
+
 /**
- * \brief Get the MmsValue object related to a functional constrained data object (FCD)
+ * \brief Get the MmsValue object related to a FunctionalConstrainedData object
  *
  * Get the MmsValue from the server cache that is associated with the Functional Constrained Data (FCD)
  * object that is specified by the DataObject and the given Function Constraint (FC).
@@ -1231,11 +1118,13 @@ IedServer_updateQuality(IedServer self, DataAttribute* dataAttribute, Quality qu
 
 /**@}*/
 
+
+LIB61850_API void
+IedServer_setLogStorage(IedServer self, const char* logRef, LogStorage logStorage);
+
 /**
  * @defgroup IEC61850_SERVER_SETTING_GROUPS Server side setting group handling
  *
- * \brief Functions and callbacks to handle setting groups on the server side.
- *
  * @{
  */
 
@@ -1354,8 +1243,6 @@ IedServer_setEditSettingGroupConfirmationHandler(IedServer self, SettingGroupCon
 /**
  * @defgroup IEC61850_SERVER_CONTROL Server side control model handling
  *
- * \brief Functions and callbacks to handle control model related operations on the server side
- *
  * @{
  */
 
@@ -1431,26 +1318,6 @@ ControlAction_getOrIdent(ControlAction self, int* orIdentSize);
 LIB61850_API int
 ControlAction_getCtlNum(ControlAction self);
 
-/**
- * \brief Gets the synchroCheck bit provided by the client
- *
- * \param self the control action instance
- *
- * \return the synchroCheck bit
- */
-LIB61850_API bool
-ControlAction_getSynchroCheck(ControlAction self);
-
-/**
- * \brief Gets the interlockCheck bit provided by the client
- *
- * \param self the control action instance
- *
- * \return the interlockCheck bit
- */
-LIB61850_API bool
-ControlAction_getInterlockCheck(ControlAction self);
-
 /**
  * \brief Check if the control callback is called by a select or operate command
  *
@@ -1482,7 +1349,7 @@ LIB61850_API DataObject*
 ControlAction_getControlObject(ControlAction self);
 
 /**
- * \brief Gets the time of the control (attribute "operTm"), if it's a timeActivatedControl, returns 0, if it's not.
+ * \brief Gets the time of the control, if it's a timeActivatedControl, returns 0, if it's not.
  *
  * \param self the control action instance
  *
@@ -1491,20 +1358,10 @@ ControlAction_getControlObject(ControlAction self);
 LIB61850_API uint64_t
 ControlAction_getControlTime(ControlAction self);
 
-/**
- * \brief Gets the time (attribute "T") of the last received control action (Oper or Select)
- *
- * \param self the control action instance
- *
- * \return the time of the last received control action
- */
-LIB61850_API Timestamp*
-ControlAction_getT(ControlAction self);
-
 /**
  * \brief Control model callback to perform the static tests (optional).
  *
- * \note Signature changed in version 1.4!
+ * NOTE: Signature changed in version 1.4!
  *
  * User provided callback function for the control model. It will be invoked after
  * a control operation has been invoked by the client. This callback function is
@@ -1526,14 +1383,13 @@ typedef CheckHandlerResult (*ControlPerformCheckHandler) (ControlAction action,
 /**
  * \brief Control model callback to perform the dynamic tests (optional).
  *
- * \note  Signature changed in version 1.4!
+ * NOTE: Signature changed in version 1.4!
  *
  * User provided callback function for the control model. It will be invoked after
  * a control operation has been invoked by the client. This callback function is
  * intended to perform the dynamic tests. It should check if the synchronization conditions
  * are met if the synchroCheck parameter is set to true.
- *
- * \note Since version 0.7.9 this function is intended to return immediately. If the operation
+ * NOTE: Since version 0.7.9 this function is intended to return immediately. If the operation
  * cannot be performed immediately the function SHOULD return CONTROL_RESULT_WAITING and the
  * handler will be invoked again later.
  *
@@ -1551,13 +1407,12 @@ typedef ControlHandlerResult (*ControlWaitForExecutionHandler) (ControlAction ac
 /**
  * \brief Control model callback to actually perform the control operation.
  *
- * \note Signature changed in version 1.4!
+ * NOTE: Signature changed in version 1.4!
  *
  * User provided callback function for the control model. It will be invoked when
  * a control operation happens (Oper). Here the user should perform the control operation
  * (e.g. by setting an digital output or switching a relay).
- *
- * \note  Since version 0.7.9 this function is intended to return immediately. If the operation
+ * NOTE: Since version 0.7.9 this function is intended to return immediately. If the operation
  * cannot be performed immediately the function SHOULD return CONTROL_RESULT_WAITING and the
  * handler will be invoked again later.
  *
@@ -1586,7 +1441,7 @@ typedef enum {
 /**
  * \brief Control model callback that is called when the select state of a control changes
  *
- * \note New in version 1.5
+ * New in version 1.5
  *
  * \param action the control action parameter that provides access to additional context information
  * \param parameter the parameter that was specified when setting the control handler
@@ -1668,7 +1523,7 @@ IedServer_setSelectStateChangedHandler(IedServer self, DataObject* node, Control
  * \brief Update the control model for the specified controllable data object with the given value and
  *        update "ctlModel" attribute value.
  *
- * \note The corresponding control structures for the control model have to be present in the data model!
+ * NOTE: The corresponding control structures for the control model have to be present in the data model!
  *
  * \param self the instance of IedServer to operate on.
  * \param ctlObject the controllable data object handle
@@ -1682,8 +1537,6 @@ IedServer_updateCtlModel(IedServer self, DataObject* ctlObject, ControlModel val
 /**
  * @defgroup IEC61850_SERVER_RCB Server side report control block (RCB) handling
  *
- * \brief Functions and callbacks to handle report control blocks (RCBs) on the server side
- *
  * @{
  */
 
@@ -1695,9 +1548,7 @@ typedef enum {
     RCB_EVENT_ENABLE,        /* << RCB enabled */
     RCB_EVENT_DISABLE,       /* << RCB disabled */
     RCB_EVENT_GI,            /* << GI report triggered */
-    RCB_EVENT_PURGEBUF,      /* << Purge buffer procedure executed */
-    RCB_EVENT_OVERFLOW,      /* << Report buffer overflow */
-    RCB_EVENT_REPORT_CREATED /* << A new report was created and inserted into the buffer */
+    RCB_EVENT_PURGEBUF       /* << Purge buffer procedure executed */
 } IedServer_RCBEventType;
 
 /**
@@ -1727,8 +1578,6 @@ IedServer_setRCBEventHandler(IedServer self, IedServer_RCBEventHandler handler,
 /**
  * @defgroup IEC61850_SERVER_SVCB Server side sampled values control block (SVCB) handling
  *
- * \brief Functions and callbacks to handle sampled values control blocks on the server side
- *
  * @{
  */
 
@@ -1763,8 +1612,6 @@ IedServer_setSVCBHandler(IedServer self, SVControlBlock* svcb, SVCBEventHandler
 /**
  * @defgroup IEC61850_SERVER_GOCB Server side GOOSE control block (GoCB) handling
  *
- * \brief Functions and callbacks to handle GOOSE control blocks (GoCBs) on the server side
- *
  * @{
  */
 
@@ -1820,12 +1667,6 @@ MmsGooseControlBlock_getNdsCom(MmsGooseControlBlock self);
 /**
  * @defgroup IEC61850_SERVER_EXTERNAL_ACCESS Handle external access to data model and access control
  *
- * \brief Functions and callbacks to handle and restrict external access to the data model and services
- *
- * This module provides functions and callbacks to restrict external access to the data model and services of the IEC 61850 server.
- * They can be used to implement access control mechanisms like role based access control (RBAC) and to restrict access to specific
- * data objects and data attributes.
- *
  * @{
  */
 
@@ -1867,7 +1708,7 @@ typedef MmsDataAccessError
  * or denied. If a WriteAccessHandler is set for a specific data attribute - the
  * default write access policy will not be performed for that data attribute.
  *
- * \note If the data attribute has sub data attributes, the WriteAccessHandler is not
+ * NOTE: If the data attribute has sub data attributes, the WriteAccessHandler is not
  * set for the sub data attributes and will not be called when the sub data attribute is
  * written directly!
  *
@@ -1904,19 +1745,6 @@ LIB61850_API void
 IedServer_handleWriteAccessForComplexAttribute(IedServer self, DataAttribute* dataAttribute,
         WriteAccessHandler handler, void* parameter);
 
-/**
- * \brief Install a WriteAccessHandler for all data attributes of a data object with a specific FC
- *
- * \param self the instance of IedServer to operate on.
- * \param dataObject the data object to monitor
- * \param fc the functional constraint to monitor
- * \param handler the callback function that is invoked if a client tries to write to
- *       the monitored data attribute.
- * \param parameter a user provided parameter that is passed to the WriteAccessHandler when called.
-*/
-LIB61850_API void
-IedServer_handleWriteAccessForDataObject(IedServer self, DataObject* dataObject, FunctionalConstraint fc, WriteAccessHandler handler, void* parameter);
-
 typedef enum {
     ACCESS_POLICY_ALLOW,
     ACCESS_POLICY_DENY
@@ -1964,120 +1792,6 @@ typedef MmsDataAccessError
 LIB61850_API void
 IedServer_setReadAccessHandler(IedServer self, ReadAccessHandler handler, void* parameter);
 
-typedef enum {
-    DATASET_CREATE,
-    DATASET_DELETE,
-    DATASET_READ,
-    DATASET_WRITE,
-    DATASET_GET_DIRECTORY
-} IedServer_DataSetOperation;
-
-/**
- * \brief Callback that is called when the client is calling a dataset operation (create, delete, read, write, list directory)
- * 
- * \note This callback is called before the IedServer_RCBEventHandler and only in case of operations (RCB_EVENT_GET_PARAMETER, RCB_EVENT_SET_PARAMETER, RCB_EVENT_ENABLE
- * 
- * \param parameter user provided parameter
- * \param connection client connection that is involved
- * \param operation one of the following operation types: DATASET_CREATE, DATASET_DELETE, DATASET_READ, DATASET_WRITE, DATASET_GET_DIRECTORY
- * 
- * \return true to allow operation, false to deny operation
- */
-typedef bool
-(*IedServer_DataSetAccessHandler) (void* parameter, ClientConnection connection, IedServer_DataSetOperation operation, const char* datasetRef);
-
-/**
- * \brief Set a handler to control access to a dataset (create, delete, read, write, list directory)
- * 
- * \param handler the callback handler to be used
- * \param parameter a user provided parameter that is passed to the handler.
- */
-LIB61850_API void
-IedServer_setDataSetAccessHandler(IedServer self, IedServer_DataSetAccessHandler handler, void* parameter);
-
-typedef enum {
-    DIRECTORY_CAT_LD_LIST,
-    DIRECTORY_CAT_DATA_LIST,
-    DIRECTORY_CAT_DATASET_LIST,
-    DIRECTORY_CAT_LOG_LIST
-} IedServer_DirectoryCategory;
-
-typedef bool
-(*IedServer_DirectoryAccessHandler) (void* parameter, ClientConnection connection, IedServer_DirectoryCategory category, LogicalDevice* logicalDevice);
-
-LIB61850_API void
-IedServer_setDirectoryAccessHandler(IedServer self, IedServer_DirectoryAccessHandler handler, void* parameter);
-
-/**
- * \brief Callback that is called when a client is invoking a list objects service
- *
- * This callback can be used to control the list object access to specific objects and is called for each object that are subject to a client request.
- *
- * \param parameter user provided parameter
- * \param connection client connection that is involved
- * \param acsiClass the ACSI class of the object
- * \param ld the logical device of the object
- * \param ln the logical node of the object
- * \param objectName the name of the object (e.g. data object name, data set name, log name, RCB name, ...)
- * \param subObjectName the name of a sub element of an object or NULL
- * \param fc the functional constraint of the object of IEC61850_FC_NONE when the object has no FC.
- *
- * \return true to include the object in the service response, otherwise false
- */
-typedef bool
-(*IedServer_ListObjectsAccessHandler)(void* parameter, ClientConnection connection, ACSIClass acsiClass, LogicalDevice* ld, LogicalNode* ln, const char* objectName, const char* subObjectName, FunctionalConstraint fc);
-
-/**
- * \brief Set a handler to control which objects are return by the list objects services
- *
- * \param handler the callback handler to be used
- * \param parameter a user provided parameter that is passed to the handler.
- */
-LIB61850_API void
-IedServer_setListObjectsAccessHandler(IedServer self, IedServer_ListObjectsAccessHandler handler, void* parameter);
-
-typedef enum {
-    IEC61850_CB_ACCESS_TYPE_READ,
-    IEC61850_CB_ACCESS_TYPE_WRITE
-} IedServer_ControlBlockAccessType;
-
-/**
- * \brief Callback that is called when a client is invoking a read or write service to a control block or log
- *
- * This callback can be used to control the read and write access to control blocks and logs (SGCB, LCBs, URCBs, BRCBs, GoCBs, SVCBs, logs)
- *
- * \param parameter user provided parameter
- * \param connection client connection that is involved
- * \param acsiClass the ACSI class of the object
- * \param ld the logical device of the object
- * \param ln the logical node of the object
- * \param objectName the name of the object (e.g. data object name, data set name, log name, RCB name, ...)
- * \param subObjectName the name of a sub element of an object or NULL
- * \param accessType access type (read=IEC61850_CB_ACCESS_TYPE_READ or write=IEC61850_CB_ACCESS_TYPE_WRITE)
- *
- * \return true to include the object in the service response, otherwise false
- */
-typedef bool
-(*IedServer_ControlBlockAccessHandler)(void* parameter, ClientConnection connection, ACSIClass acsiClass, LogicalDevice* ld, LogicalNode* ln, const char* objectName, const char* subObjectName, IedServer_ControlBlockAccessType accessType);
-
-/**
- * \brief Set a handler to control read and write access to control blocks and logs
- *
- * \param handler the callback handler to be used
- * \param parameter a user provided parameter that is passed to the handler.
- */
-LIB61850_API void
-IedServer_setControlBlockAccessHandler(IedServer self, IedServer_ControlBlockAccessHandler handler, void* parameter);
-
-/**
- * \brief Temporarily ignore read requests (for testing purposes)
- *
- * \param self the instance of IedServer to operate on.
- * \param ignore true to ignore read requests, false to handle read requests.
-*/
-LIB61850_API void
-IedServer_ignoreReadAccess(IedServer self, bool ignore);
-
 /**@}*/
 
 /**@}*/

+ 1 - 21
library/include/libiec61850/iso_connection_parameters.h

@@ -1,7 +1,7 @@
 /*
  *  iso_connection_parameters.h
  *
- *  Copyright 2013-2023 Michael Zillgith
+ *  Copyright 2013-2018 Michael Zillgith
  *
  *  This file is part of libIEC61850.
  *
@@ -24,10 +24,6 @@
 #ifndef ISO_CONNECTION_PARAMETERS_H_
 #define ISO_CONNECTION_PARAMETERS_H_
 
-#ifndef CONFIG_MMS_SUPPORT_TLS
-#define CONFIG_MMS_SUPPORT_TLS 0
-#endif
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -149,9 +145,6 @@ struct sIsoConnectionParameters
     const char* hostname;
     int tcpPort;
 
-    const char* localIpAddress;
-    int localTcpPort;
-
     uint8_t remoteApTitle[10];
     int remoteApTitleLen;
     int remoteAEQualifier;
@@ -222,19 +215,6 @@ IsoConnectionParameters_setAcseAuthenticationParameter(IsoConnectionParameters s
 LIB61850_API void
 IsoConnectionParameters_setTcpParameters(IsoConnectionParameters self, const char* hostname, int tcpPort);
 
-/**
-* \brief Set Local TCP parameters (FOR LIBRARY INTERNAL USE)
-*
-* NOTE: This function used internally by the MMS Client library. When using the MMS or IEC 61850 API
-* there should be no reason for the user to call this function
-*
-* \param self the IsoConnectionParameters instance
-* \param localIpAddress the hostname of local IP address of the server
-* \param localTcpPort the local TCP port number of the server
-*/
-LIB61850_API void
-IsoConnectionParameters_setLocalTcpParameters(IsoConnectionParameters self, const char* localIpAddress, int localTcpPort);
-
 /**
  * \brief set the remote AP-Title and AE-Qualifier
  *

+ 8 - 43
library/include/libiec61850/mms_client_connection.h

@@ -160,16 +160,6 @@ MmsConnection_setFilestoreBasepath(MmsConnection self, const char* basepath);
 LIB61850_API void
 MmsConnection_setRequestTimeout(MmsConnection self, uint32_t timeoutInMs);
 
-/**
- * \brief Set the maximum number outstanding calls allowed for this connection
- *
- * \param self MmsConnection instance to operate on
- * \param calling the maximum outstanding calls allowed by the caller (client)
- * \param called the maximum outstanding calls allowed by the called endpoint (server)
- */
-LIB61850_API void
-MmsConnnection_setMaxOutstandingCalls(MmsConnection self, int calling, int called);
-
 /**
  * \brief Get the request timeout in ms for this connection
  *
@@ -281,8 +271,6 @@ MmsConnection_destroy(MmsConnection self);
 LIB61850_API bool
 MmsConnection_connect(MmsConnection self, MmsError* mmsError, const char* serverName, int serverPort);
 
-
-
 LIB61850_API void
 MmsConnection_connectAsync(MmsConnection self, MmsError* mmsError, const char* serverName, int serverPort);
 
@@ -297,10 +285,6 @@ MmsConnection_connectAsync(MmsConnection self, MmsError* mmsError, const char* s
 LIB61850_API bool
 MmsConnection_tick(MmsConnection self);
 
-/* NOTE: This function is for test purposes! */
-LIB61850_API void
-MmsConnection_sendRawData(MmsConnection self, MmsError* mmsError, uint8_t* buffer, int bufSize);
-
 /**
  * \brief Close the connection - not recommended
  *
@@ -660,23 +644,6 @@ MmsConnection_writeVariableAsync(MmsConnection self, uint32_t* usedInvokeId, Mms
         MmsConnection_WriteVariableHandler handler, void* parameter);
 
 
-/**
- * \brief Write a single variable to the server (using component alternate access)
- *
- * \param self MmsConnection instance to operate on
- * \param mmsError user provided variable to store error code
- * \param domainId the domain name of the variable to be written
- * \param itemId name of the variable to be written
- * \param componentId the name of the variable component
- * \param value value of the variable to be written
- *
- * \return when successful, the data access error value returned by the server
- */
-LIB61850_API MmsDataAccessError
-MmsConnection_writeVariableComponent(MmsConnection self, MmsError* mmsError,
-        const char* domainId, const char* itemId,
-        const char* componentId, MmsValue* value);
-
 /**
  * \brief Write a single array element with a component to an array type variable
  *
@@ -701,11 +668,6 @@ MmsConnection_writeSingleArrayElementWithComponentAsync(MmsConnection self, uint
         uint32_t arrayIndex, const char* componentId, MmsValue* value,
         MmsConnection_WriteVariableHandler handler, void* parameter);
 
-LIB61850_API void
-MmsConnection_writeVariableComponentAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError,
-        const char* domainId, const char* itemId, const char* componentId, MmsValue* value,
-        MmsConnection_WriteVariableHandler handler, void* parameter);
-
 /**
  * \brief Write a single array element or a sub array to an array type variable
  *
@@ -1070,11 +1032,6 @@ LIB61850_API void
 MmsConnection_identifyAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError,
         MmsConnection_IdentifyHandler handler, void* parameter);
 
-/**
- * \brief Destroy (free) an MmsServerIdentity object
- *
- * \param self the object to destroy
- */
 LIB61850_API void
 MmsServerIdentity_destroy(MmsServerIdentity* self);
 
@@ -1324,6 +1281,14 @@ LIB61850_API void
 MmsConnection_readJournalStartAfterAsync(MmsConnection self, uint32_t* usedInvokeId, MmsError* mmsError, const char* domainId, const char* itemId,
         MmsValue* timeSpecification, MmsValue* entrySpecification, MmsConnection_ReadJournalHandler handler, void* parameter);
 
+/**
+ * \brief Destroy (free) an MmsServerIdentity object
+ *
+ * \param self the object to destroy
+ */
+LIB61850_API void
+MmsServerIdentity_destroy(MmsServerIdentity* self);
+
 /**@}*/
 
 #ifdef __cplusplus

+ 7 - 50
library/include/libiec61850/mms_server.h

@@ -1,7 +1,7 @@
 /*
  *  mms_server.h
  *
- *  Copyright 2013-2023 Michael Zillgith
+ *  Copyright 2013-2018 Michael Zillgith
  *
  *  This file is part of libIEC61850.
  *
@@ -57,70 +57,30 @@ MmsServer_setLocalIpAddress(MmsServer self, const char* localIpAddress);
 LIB61850_INTERNAL bool
 MmsServer_isRunning(MmsServer self);
 
-typedef enum {
-    MMS_VARLIST_CREATE,
-    MMS_VARLIST_DELETE,
-    MMS_VARLIST_READ,
-    MMS_VARLIST_WRITE,
-    MMS_VARLIST_GET_DIRECTORY
-} MmsVariableListAccessType;
-
 /**
- * \brief callback handler that is called for each named variable list access
+ * \brief callback handler that is called whenever a named variable list changes
  *
  * \param parameter a user provided parameter
- * \param accessType the kind of access (create, delete, read, write, get directory)
+ * \param create if true the the request if a request to create a new variable list, false is a delete request
  * \param listType the type (scope) of the named variable list (either domain, association or VMD specific)
  * \param domain the MMS domain the list is belonging to (is NULL for association or VMD specific lists!)
  * \param listName the name
- * \param connection client connection that is accessing the named variable list
+ * \param connection client connection that requests the creation of deletion of the variable list
  *
  * \return MMS_ERROR_NONE if the request is accepted, otherwise the MmsError value that has to be sent back to the client
  */
-typedef MmsError (*MmsNamedVariableListAccessHandler)(void* parameter, MmsVariableListAccessType accessType, MmsVariableListType listType, MmsDomain* domain,
+typedef MmsError (*MmsNamedVariableListChangedHandler)(void* parameter, bool create, MmsVariableListType listType, MmsDomain* domain,
         char* listName, MmsServerConnection connection);
 
 /**
- * \brief Install callback handler that is called when a named variable list is accessed by a client
+ * \brief Install callback handler that is called when a named variable list changes (is created or deleted)
  *
  * \param self the MmsServer instance to operate on
  * \param handler the callback handler function
  * \param parameter user provided parameter that is passed to the callback handler
  */
 LIB61850_INTERNAL void
-MmsServer_installVariableListAccessHandler(MmsServer self, MmsNamedVariableListAccessHandler handler, void* parameter);
-
-/**
- * \brief callback handler that is called for each received read journal request
- * 
- * \param parameter a user provided parameter
- * \param domain the MMS domain the journal is belonging to
- * \param logName the name of the journal
- * \param connection client connection that is accessing the journal
- */
-typedef bool (*MmsReadJournalHandler)(void* parameter, MmsDomain* domain, const char* logName, MmsServerConnection connection);
-
-/**
- * \brief Install callback handler that is called when a journal is accessed by a client
- *
- * \param self the MmsServer instance to operate on
- * \param handler the callback handler function
- * \param parameter user provided parameter that is passed to the callback handler
- */
-LIB61850_INTERNAL void
-MmsServer_installReadJournalHandler(MmsServer self, MmsReadJournalHandler handler, void* parameter);
-
-typedef enum {
-    MMS_GETNAMELIST_DOMAINS,
-    MMS_GETNAMELIST_JOURNALS,
-    MMS_GETNAMELIST_DATASETS,
-    MMS_GETNAMELIST_DATA
-} MmsGetNameListType;
-
-typedef bool (*MmsGetNameListHandler)(void* parameter, MmsGetNameListType nameListType, MmsDomain* domain, MmsServerConnection connection);
-
-LIB61850_INTERNAL void
-MmsServer_installGetNameListHandler(MmsServer self, MmsGetNameListHandler handler, void* parameter);
+MmsServer_installVariableListChangedHandler(MmsServer self, MmsNamedVariableListChangedHandler handler, void* parameter);
 
 /**
  * \brief ObtainFile service callback handler
@@ -410,9 +370,6 @@ MmsServerConnection_getLocalAddress(MmsServerConnection self);
 LIB61850_INTERNAL void*
 MmsServerConnection_getSecurityToken(MmsServerConnection self);
 
-LIB61850_INTERNAL void
-MmsServer_ignoreClientRequests(MmsServer self, bool enable);;
-
 /**@}*/
 
 #ifdef __cplusplus

+ 1 - 33
library/include/libiec61850/mms_value.h

@@ -498,30 +498,12 @@ MmsValue_getUtcTimeInMsWithUs(const MmsValue* self, uint32_t* usec);
  * bit 0-4 = subsecond time accuracy (number of significant bits of subsecond time)
  *
  * \param self MmsValue instance to operate on. Has to be of a type MMS_UTCTIME.
+ *
  * \param timeQuality the byte representing the time quality
  */
 LIB61850_API void
 MmsValue_setUtcTimeQuality(MmsValue* self, uint8_t timeQuality);
 
-/**
- * \brief Update an MmsValue object of type MMS_UTCTIME with a millisecond time.
- * 
- * Meaning of the bits in the timeQuality byte:
- *
- * bit 7 = leapSecondsKnown
- * bit 6 = clockFailure
- * bit 5 = clockNotSynchronized
- * bit 0-4 = subsecond time accuracy (number of significant bits of subsecond time)
- *
- * \param self MmsValue instance to operate on. Has to be of a type MMS_UTCTIME.
- * \param timeval the new value in milliseconds since epoch (1970/01/01 00:00 UTC)
- * \param timeQuality the byte representing the time quality
- * 
- * \return the updated MmsValue instance
- */
-LIB61850_API MmsValue*
-MmsValue_setUtcTimeMsEx(MmsValue* self, uint64_t timeval, uint8_t timeQuality);
-
 /**
  * \brief get the TimeQuality byte of the UtcTime
  *
@@ -1018,20 +1000,6 @@ MmsValue_printToBuffer(const MmsValue* self, char* buffer, int bufferSize);
 LIB61850_API MmsValue*
 MmsValue_decodeMmsData(uint8_t* buffer, int bufPos, int bufferLength, int* endBufPos);
 
-/**
- * \brief create a new MmsValue instance from a BER encoded MMS Data element (deserialize) with a defined maximum recursion depth
- *
- * \param buffer the buffer to read from
- * \param bufPos the start position of the mms value data in the buffer
- * \param bufferLength the length of the buffer
- * \param endBufPos the position in the buffer after the read MMS data element (NULL if not required)
- * \param maxDepth the maximum recursion depth
- *
- * \return the MmsValue instance created from the buffer
- */
-LIB61850_API MmsValue*
-MmsValue_decodeMmsDataMaxRecursion(uint8_t* buffer, int bufPos, int bufferLength, int* endBufPos, int maxDepth);
-
 /**
  * \brief Serialize the MmsValue instance as BER encoded MMS Data element
  *

+ 0 - 244
library/include/libiec61850/r_session.h

@@ -1,244 +0,0 @@
-/*
- *  r_session.h
- *
- *  Copyright 2013-2022 Michael Zillgith
- *
- *  This file is part of libIEC61850.
- *
- *  libIEC61850 is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  libIEC61850 is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with libIEC61850.  If not, see <http://www.gnu.org/licenses/>.
- *
- *  See COPYING file for the complete license text.
- */
-
-#ifndef LIBIEC61850_R_SESSION_H_
-#define LIBIEC61850_R_SESSION_H_
-
-#include "libiec61850_common_api.h"
-#include "hal_socket.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct sRSession* RSession;
-
-typedef enum {
-    R_SESSION_SEC_ALGO_NONE = 0,
-    R_SESSION_SEC_ALGO_AES_128_GCM = 1,
-    R_SESSION_SEC_ALGO_AES_256_GCM = 2
-} RSecurityAlgorithm;
-
-typedef enum {
-    R_SESSION_SIG_ALGO_NONE = 0,
-    R_SESSION_SIG_ALGO_HMAC_SHA256_80 = 1,
-    R_SESSION_SIG_ALGO_HMAC_SHA256_128 = 2,
-    R_SESSION_SIG_ALGO_HMAC_SHA256_256 = 3,
-    R_SESSION_SIG_ALGO_AES_GMAC_64 = 4,
-    R_SESSION_SIG_ALGO_AES_GMAC_128 = 5,
-    R_SESSION_SIG_ALGO_HMAC_SHA3_80 = 6,
-    R_SESSION_SIG_ALGO_HMAC_SHA3_128 = 7,
-    R_SESSION_SIG_ALGO_HMAC_SHA3_256 = 8
-} RSignatureAlgorithm;
-
-typedef enum {
-    R_SESSION_ERROR_OK = 0,
-    R_SESSION_ERROR_INVALID_KEY = 1,
-    R_SESSION_ERROR_KEY_QUEUE_FULL = 2,
-    R_SESSION_ERROR_NO_SOCKET = 3,
-    R_SESSION_ERROR_OUT_OF_MEMORY = 4,
-    R_SESSION_ERROR_FAILED_TO_SEND = 5,
-    R_SESSION_ERROR_FAILED_TO_RECEIVE = 6,
-    R_SESSION_ERROR_INVALID_MESSAGE = 7,
-    R_SESSION_ERROR_SET_FAILED = 8
-} RSessionError;
-
-typedef struct sRSessionPayloadElement* RSessionPayloadElement;
-
-struct sRSessionPayloadElement
-{
-    bool simulation;
-    uint16_t appId;
-    uint8_t payloadType;
-    uint8_t* payload;
-    int payloadSize;
-    RSessionPayloadElement nextElement; /* NULL when no more elements follow */
-};
-
-/**
- * \brief Create a new RSession instance to provide R-GOOSE/R-SMV support for GOOSE/SMV publisher/subscriber
- *
- * \return new RSession instance
- */
-LIB61850_API RSession
-RSession_create(void);
-
-/**
- * \brief Set the maximum buffer size for session messages (range: 128 - 65535)
- *
- * \param self the RSession instance
- * \param bufferSize the size of the buffer for RSession UDP messages (range: 128 - 65535)
- */
-LIB61850_API void
-RSession_setBufferSize(RSession self, uint16_t bufferSize);
-
-/**
- * \brief Set the security algorithms for the session instance
- * 
- * \note only for version 1 of the protocol!
- * 
- * \param secAlgo encryption algorithm to be used for the session instance
- * \param sigAlgo signature algorithm to be used for the session instance
- * 
- * \return returns R_SESSION_ERROR_OK
- */
-LIB61850_API RSessionError
-RSession_setSecurity(RSession self, RSecurityAlgorithm secAlgo, RSignatureAlgorithm sigAlgo);
-
-/**
- * \brief Bind the RSession instance to a specific local IP address and UDP port
- * 
- * \param self the RSession instance
- * \param localAddress the local IP address to use
- * \param localPort the local UDP port to use (default is 102)
-*/
-LIB61850_API RSessionError
-RSession_setLocalAddress(RSession self, const char* localAddress, int localPort);
-
-/**
- * \brief Add this instance to an IPv4/IPv6 multicast group
- *
- * \param self the RSession instance
- * \param multicastAddress IPv4 or IPv6 multicast address
- *
- * \return R_SESSION_ERROR_OK on success, R_SESSION_ERROR_SET_FAILED otherwise
- */
-LIB61850_API RSessionError
-RSession_addMulticastGroup(RSession self, const char* multicastAddress);
-
-/**
- * \brief Sets the multicast TTL (number of hops) for this RSession instance
- *
- * \param self the RSession instance
- * \param ttl number of hops for multicast messages. Default is 1 (not routable!)
- *
- * \return R_SESSION_ERROR_OK on success, error code otherwise
- */
-LIB61850_API RSessionError
-RSession_setMulticastTtl(RSession self, int ttl);
-
-/**
- * \brief Set the destionation address and port for publishers
- *
- * \param self the RSession instance
- * \param remoteAddress remote IP address
- * \param remotePort remote UDP port
- *
- * \return R_SESSION_ERROR_OK on success, error code otherwise
- */
-LIB61850_API RSessionError
-RSession_setRemoteAddress(RSession self, const char* remoteAddress, int remotePort);
-
-/**
- * \brief Start sending and receiving messages (bind to a local UDP port/interface)
- *
- * \param self the RSession instance
- *
- * \return R_SESSION_ERROR_OK on success, error code otherwise
- */
-LIB61850_API RSessionError
-RSession_start(RSession self);
-
-/**
- * \brief Stop sending and receiving messages.
- *
- * \param self the RSession instance
- *
- * \return R_SESSION_ERROR_OK on success, error code otherwise
- */
-LIB61850_API RSessionError
-RSession_stop(RSession self);
-
-/**
- * \brief Manually add a key to the RSession instance
- *
- * \param self the RSession instance
- * \param keyId the key ID is unique for the security association
- * \param key the key data
- * \param keyLength the length of the key in bytes
- * \param secAlgo the applicable security (encryption) algorithm
- * \param sigAlgo the applicable signature algorithm
- */
-LIB61850_API RSessionError
-RSession_addKey(RSession self, uint32_t keyId, uint8_t* key, int keyLength, RSecurityAlgorithm secAlgo, RSignatureAlgorithm sigAlgo);
-
-/**
- * \brief Remove key from the list of accepted keys
- * 
- * \param self the RSession instance
- * \param keyId the key ID is unique for the security association
- */
-LIB61850_API RSessionError
-RSession_removeKey(RSession self, uint32_t keyId);
-
-/**
- * \brief Remove all keys from the list of accepted keys
- * 
- * \param self the RSession instance 
- */
-void
-RSession_removeAllKeys(RSession self);
-
-typedef enum
-{
-    RSESSION_KEY_EVENT__NEED_KEY = 1
-} RSessionKeyEvent;
-
-typedef void (*RSession_KeyEventHandler) (void* parameter, RSession rSession, RSessionKeyEvent event, uint32_t keyID);
-
-/**
- * \brief Set a callback handler to receive key events from the RSession instance
- *
- * e.g. when the RSession instance has no valid key for the received messages or to publish messages.
- * 
- * \param self the RSession instance
- * \param handler the callback that is called when a new event happens
- * \param parameter user provided parameter that is passed to the user callback
- */
-LIB61850_API void
-RSession_setKeyEventHandler(RSession self, RSession_KeyEventHandler handler, void* parameter);
-
-/**
- * \brief Set the active key for the sender/publisher
- *
- * \param self the RSession instance
- * \param keyId the key ID of the new active key (has to be added with \ref RSession_addKey before).
- * 
- * \return R_SESSION_ERROR_INVALID_KEY when no valid key with the given keyId is avialable, R_SESSION_ERROR_OK otherwise
- */
-LIB61850_API RSessionError
-RSession_setActiveKey(RSession self, uint32_t keyId);
-
-/**
- * \brief Destroy the RSession instance and free all resource
- *
- * \param self the RSession instance
- */
-LIB61850_API void
-RSession_destroy(RSession self);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LIBIEC61850_R_SESSION_H_ */

+ 0 - 73
library/include/libiec61850/sntp_client.h

@@ -1,73 +0,0 @@
-/*
- *  Copyright 2013-2022 Michael Zillgith
- *
- *  This file is part of libIEC61850.
- *
- *  libIEC61850 is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  libIEC61850 is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with libIEC61850.  If not, see <http://www.gnu.org/licenses/>.
- *
- *  See COPYING file for the complete license text.
- */
-
-#ifndef LIBIEC61850_SRC_COMMON_INC_SNTP_CLIENT_H_
-#define LIBIEC61850_SRC_COMMON_INC_SNTP_CLIENT_H_
-
-#include "libiec61850_common_api.h"
-#include "hal_socket.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct sSNTPClient* SNTPClient;
-
-typedef void (*SNTPClient_UserCallback)(void* parameter, bool isSynced);
-
-LIB61850_API SNTPClient
-SNTPClient_create();
-
-LIB61850_API void
-SNTPClient_setLocalAddress(SNTPClient self, const char* localAddress);
-
-LIB61850_API void
-SNTPClient_setLocalPort(SNTPClient self, int udpPort);
-
-LIB61850_API HandleSet
-SNTPClient_getHandleSet(SNTPClient self);
-
-LIB61850_API void
-SNTPClient_addServer(SNTPClient self, const char* serverAddr, int serverPort);
-
-LIB61850_API void
-SNTPClient_setPollInterval(SNTPClient self, uint32_t intervalInSeconds);
-
-LIB61850_API void
-SNTPClient_setUserCallback(SNTPClient self, SNTPClient_UserCallback callback, void* parameter);
-
-LIB61850_API bool
-SNTPClient_isSynchronized(SNTPClient self);
-
-LIB61850_API void
-SNTPClient_start(SNTPClient self);
-
-LIB61850_API void
-SNTPClient_stop(SNTPClient self);
-
-LIB61850_API void
-SNTPClient_destroy(SNTPClient self);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LIBIEC61850_SRC_COMMON_INC_SNTP_CLIENT_H_ */

+ 1 - 13
library/include/libiec61850/sv_publisher.h

@@ -1,7 +1,7 @@
 /*
  *  sv_publisher.h
  *
- *  Copyright 2016-2022 Michael Zillgith
+ *  Copyright 2016-2018 Michael Zillgith
  *
  *  This file is part of libIEC61850.
  *
@@ -26,7 +26,6 @@
 #define LIBIEC61850_SRC_SAMPLED_VALUES_SV_PUBLISHER_H_
 
 #include "iec61850_common.h"
-#include "r_session.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -91,17 +90,6 @@ SVPublisher_create(CommParameters* parameters, const char* interfaceId);
 LIB61850_API SVPublisher
 SVPublisher_createEx(CommParameters* parameters, const char* interfaceId, bool useVlanTag);
 
-/**
- * \brief Create a new SVPublisher instance for R-SMV
- *
- * \param session R-session protocol instance to use
- * \param appId the appID value to use
- * 
- * \return the new SVPublisher instance
- */
-LIB61850_API SVPublisher
-SVPublisher_createRemote(RSession session, uint16_t appId);
-
 /**
  * \brief Create an Application Service Data Unit (ASDU) and add it to an existing Sampled Values publisher.
  *

+ 68 - 14
library/include/libiec61850/sv_subscriber.h

@@ -1,7 +1,7 @@
 /*
  *  sv_subscriber.h
  *
- *  Copyright 2015-2022 Michael Zillgith
+ *  Copyright 2015-2018 Michael Zillgith
  *
  *  This file is part of libIEC61850.
  *
@@ -26,7 +26,6 @@
 
 #include "libiec61850_common_api.h"
 #include "iec61850_common.h"
-#include "r_session.h"
 #include "hal_ethernet.h"
 
 #ifdef __cplusplus
@@ -133,16 +132,6 @@ typedef struct sSVReceiver* SVReceiver;
 LIB61850_API SVReceiver
 SVReceiver_create(void);
 
-/**
- * \brief Create a new R-SV receiver instance.
- *
- * \param session the remote session protocol instance
- *
- * \return the newly created receiver instance
- */
-LIB61850_API SVReceiver
-SVReceiver_createRemote(RSession session);
-
 /**
  * \brief Disable check for destination address of the received SV messages
  *
@@ -239,7 +228,7 @@ SVReceiver_destroy(SVReceiver self);
  * Functions for non-threaded operation
  ***************************************/
 
-LIB61850_API bool
+LIB61850_API EthernetSocket
 SVReceiver_startThreadless(SVReceiver self);
 
 LIB61850_API void
@@ -560,7 +549,72 @@ SVSubscriber_ASDU_getDataSize(SVSubscriber_ASDU self);
 uint8_t
 SVSubscriber_ASDU_getSmpSynch(SVSubscriber_ASDU self);
 
-/** @}*/
+#ifndef DEPRECATED
+#if defined(__GNUC__) || defined(__clang__)
+  #define DEPRECATED __attribute__((deprecated))
+#else
+  #define DEPRECATED
+#endif
+#endif
+
+/**
+ * \addtogroup sv_subscriber_deprecated_api_group Deprecated API
+ * \ingroup sv_subscriber_api_group IEC 61850 Sampled Values (SV) publisher API
+ * \deprecated
+ * @{
+ */
+
+typedef struct sSVSubscriberASDU* SVClientASDU;
+
+LIB61850_API DEPRECATED uint16_t
+SVClientASDU_getSmpCnt(SVSubscriber_ASDU self);
+
+LIB61850_API DEPRECATED const char*
+SVClientASDU_getSvId(SVSubscriber_ASDU self);
+
+LIB61850_API DEPRECATED uint32_t
+SVClientASDU_getConfRev(SVSubscriber_ASDU self);
+
+LIB61850_API DEPRECATED bool
+SVClientASDU_hasRefrTm(SVSubscriber_ASDU self);
+
+LIB61850_API DEPRECATED uint64_t
+SVClientASDU_getRefrTmAsMs(SVSubscriber_ASDU self);
+
+LIB61850_API DEPRECATED int8_t
+SVClientASDU_getINT8(SVSubscriber_ASDU self, int index);
+
+LIB61850_API DEPRECATED int16_t
+SVClientASDU_getINT16(SVSubscriber_ASDU self, int index);
+
+LIB61850_API DEPRECATED int32_t
+SVClientASDU_getINT32(SVSubscriber_ASDU self, int index);
+
+LIB61850_API DEPRECATED int64_t
+SVClientASDU_getINT64(SVSubscriber_ASDU self, int index);
+
+LIB61850_API DEPRECATED uint8_t
+SVClientASDU_getINT8U(SVSubscriber_ASDU self, int index);
+
+LIB61850_API DEPRECATED uint16_t
+SVClientASDU_getINT16U(SVSubscriber_ASDU self, int index);
+
+LIB61850_API DEPRECATED uint32_t
+SVClientASDU_getINT32U(SVSubscriber_ASDU self, int index);
+
+LIB61850_API DEPRECATED uint64_t
+SVClientASDU_getINT64U(SVSubscriber_ASDU self, int index);
+
+LIB61850_API DEPRECATED float
+SVClientASDU_getFLOAT32(SVSubscriber_ASDU self, int index);
+
+LIB61850_API DEPRECATED double
+SVClientASDU_getFLOAT64(SVSubscriber_ASDU self, int index);
+
+LIB61850_API DEPRECATED int
+SVClientASDU_getDataSize(SVSubscriber_ASDU self);
+
+/**@} @}*/
 
 #ifdef __cplusplus
 }

+ 0 - 262
library/include/libiec61850/tls_ciphers.h

@@ -1,262 +0,0 @@
-#ifndef IANA_TLS_CIPHER_SUITES_H_
-#define IANA_TLS_CIPHER_SUITES_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define TLS_NULL_WITH_NULL_NULL 0x0000
-#define TLS_RSA_WITH_NULL_MD5 0x0001
-#define TLS_RSA_WITH_NULL_SHA 0x0002
-#define TLS_RSA_EXPORT_WITH_RC4_40_MD5 0x0003
-#define TLS_RSA_WITH_RC4_128_MD5 0x0004
-#define TLS_RSA_WITH_RC4_128_SHA 0x0005
-#define TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 0x0006
-#define TLS_RSA_WITH_IDEA_CBC_SHA 0x0007
-#define TLS_RSA_EXPORT_WITH_DES40_CBC_SHA 0x0008
-#define TLS_RSA_WITH_DES_CBC_SHA 0x0009
-#define TLS_RSA_WITH_3DES_EDE_CBC_SHA 0x000A
-#define TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA 0x000B
-#define TLS_DH_DSS_WITH_DES_CBC_SHA 0x000C
-#define TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA 0x000D
-#define TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA 0x000E
-#define TLS_DH_RSA_WITH_DES_CBC_SHA 0x000F
-#define TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA 0x0010
-#define TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA 0x0011
-#define TLS_DHE_DSS_WITH_DES_CBC_SHA 0x0012
-#define TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA 0x0013
-#define TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA 0x0014
-#define TLS_DHE_RSA_WITH_DES_CBC_SHA 0x0015
-#define TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA 0x0016
-#define TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 0x0017
-#define TLS_DH_anon_WITH_RC4_128_MD5 0x0018
-#define TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA 0x0019
-#define TLS_DH_anon_WITH_DES_CBC_SHA 0x001A
-#define TLS_DH_anon_WITH_3DES_EDE_CBC_SHA 0x001B
-#define TLS_RSA_WITH_AES_128_CBC_SHA 0x002F
-#define TLS_DH_DSS_WITH_AES_128_CBC_SHA 0x0030
-#define TLS_DH_RSA_WITH_AES_128_CBC_SHA 0x0031
-#define TLS_DHE_DSS_WITH_AES_128_CBC_SHA 0x0032
-#define TLS_DHE_RSA_WITH_AES_128_CBC_SHA 0x0033
-#define TLS_DH_anon_WITH_AES_128_CBC_SHA 0x0034
-#define TLS_RSA_WITH_AES_256_CBC_SHA 0x0035
-#define TLS_DH_DSS_WITH_AES_256_CBC_SHA 0x0036
-#define TLS_DH_RSA_WITH_AES_256_CBC_SHA 0x0037
-#define TLS_DHE_DSS_WITH_AES_256_CBC_SHA 0x0038
-#define TLS_DHE_RSA_WITH_AES_256_CBC_SHA 0x0039
-#define TLS_DH_anon_WITH_AES_256_CBC_SHA 0x003A
-#define TLS_RSA_WITH_NULL_SHA256 0x003B
-#define TLS_RSA_WITH_AES_128_CBC_SHA256 0x003C
-#define TLS_RSA_WITH_AES_256_CBC_SHA256 0x003D
-#define TLS_DH_DSS_WITH_AES_128_CBC_SHA256 0x003E
-#define TLS_DH_RSA_WITH_AES_128_CBC_SHA256 0x003F
-#define TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 0x0040
-#define TLS_RSA_WITH_CAMELLIA_128_CBC_SHA 0x0041
-#define TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA 0x0042
-#define TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA 0x0043
-#define TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA 0x0044
-#define TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA 0x0045
-#define TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA 0x0046
-#define TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 0x0067
-#define TLS_DH_DSS_WITH_AES_256_CBC_SHA256 0x0068
-#define TLS_DH_RSA_WITH_AES_256_CBC_SHA256 0x0069
-#define TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 0x006A
-#define TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 0x006B
-#define TLS_DH_anon_WITH_AES_128_CBC_SHA256 0x006C
-#define TLS_DH_anon_WITH_AES_256_CBC_SHA256 0x006D
-#define TLS_RSA_WITH_CAMELLIA_256_CBC_SHA 0x0084
-#define TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA 0x0085
-#define TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA 0x0086
-#define TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA 0x0087
-#define TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA 0x0088
-#define TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA 0x0089
-#define TLS_RSA_WITH_SEED_CBC_SHA 0x0096
-#define TLS_DH_DSS_WITH_SEED_CBC_SHA 0x0097
-#define TLS_DH_RSA_WITH_SEED_CBC_SHA 0x0098
-#define TLS_DHE_DSS_WITH_SEED_CBC_SHA 0x0099
-#define TLS_DHE_RSA_WITH_SEED_CBC_SHA 0x009A
-#define TLS_DH_anon_WITH_SEED_CBC_SHA 0x009B
-#define TLS_RSA_WITH_AES_128_GCM_SHA256 0x009C
-#define TLS_RSA_WITH_AES_256_GCM_SHA384 0x009D
-#define TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 0x009E
-#define TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 0x009F
-#define TLS_DH_RSA_WITH_AES_128_GCM_SHA256 0x00A0
-#define TLS_DH_RSA_WITH_AES_256_GCM_SHA384 0x00A1
-#define TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 0x00A2
-#define TLS_DHE_DSS_WITH_AES_256_GCM_SHA384 0x00A3
-#define TLS_DH_DSS_WITH_AES_128_GCM_SHA256 0x00A4
-#define TLS_DH_DSS_WITH_AES_256_GCM_SHA384 0x00A5
-#define TLS_DH_anon_WITH_AES_128_GCM_SHA256 0x00A6
-#define TLS_DH_anon_WITH_AES_256_GCM_SHA384 0x00A7
-#define TLS_PSK_WITH_AES_128_CBC_SHA 0x008C
-#define TLS_PSK_WITH_AES_256_CBC_SHA 0x008D
-#define TLS_DHE_PSK_WITH_AES_128_CBC_SHA 0x008E
-#define TLS_DHE_PSK_WITH_AES_256_CBC_SHA 0x008F
-#define TLS_RSA_PSK_WITH_AES_128_CBC_SHA 0x0090
-#define TLS_RSA_PSK_WITH_AES_256_CBC_SHA 0x0091
-#define TLS_PSK_WITH_AES_128_CBC_SHA256 0x00AE
-#define TLS_PSK_WITH_AES_256_CBC_SHA384 0x00AF
-#define TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 0x00B0
-#define TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 0x00B1
-#define TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 0x00B2
-#define TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 0x00B3
-#define TLS_PSK_WITH_NULL_SHA 0x002C
-#define TLS_DHE_PSK_WITH_NULL_SHA 0x002D
-#define TLS_RSA_PSK_WITH_NULL_SHA 0x002E
-#define TLS_PSK_WITH_NULL_SHA256 0x00B4
-#define TLS_PSK_WITH_NULL_SHA384 0x00B5
-#define TLS_DHE_PSK_WITH_NULL_SHA256 0x00B6
-#define TLS_DHE_PSK_WITH_NULL_SHA384 0x00B7
-#define TLS_RSA_PSK_WITH_NULL_SHA256 0x00B8
-#define TLS_RSA_PSK_WITH_NULL_SHA384 0x00B9
-#define TLS_ECDH_ECDSA_WITH_NULL_SHA 0xC001
-#define TLS_ECDH_ECDSA_WITH_RC4_128_SHA 0xC002
-#define TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA 0xC003
-#define TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA 0xC004
-#define TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA 0xC005
-#define TLS_ECDHE_ECDSA_WITH_NULL_SHA 0xC006
-#define TLS_ECDHE_ECDSA_WITH_RC4_128_SHA 0xC007
-#define TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA 0xC008
-#define TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA 0xC009
-#define TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA 0xC00A
-#define TLS_ECDH_RSA_WITH_NULL_SHA 0xC00B
-#define TLS_ECDH_RSA_WITH_RC4_128_SHA 0xC00C
-#define TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA 0xC00D
-#define TLS_ECDH_RSA_WITH_AES_128_CBC_SHA 0xC00E
-#define TLS_ECDH_RSA_WITH_AES_256_CBC_SHA 0xC00F
-#define TLS_ECDHE_RSA_WITH_NULL_SHA 0xC010
-#define TLS_ECDHE_RSA_WITH_RC4_128_SHA 0xC011
-#define TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA 0xC012
-#define TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA 0xC013
-#define TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA 0xC014
-#define TLS_ECDH_anon_WITH_NULL_SHA 0xC015
-#define TLS_ECDH_anon_WITH_RC4_128_SHA 0xC016
-#define TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA 0xC017
-#define TLS_ECDH_anon_WITH_AES_128_CBC_SHA 0xC018
-#define TLS_ECDH_anon_WITH_AES_256_CBC_SHA 0xC019
-#define TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 0xC023
-#define TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 0xC024
-#define TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 0xC025
-#define TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 0xC026
-#define TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 0xC027
-#define TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 0xC028
-#define TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 0xC029
-#define TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 0xC02A
-#define TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 0xC02B
-#define TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 0xC02C
-#define TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 0xC02D
-#define TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 0xC02E
-#define TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 0xC02F
-#define TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 0xC030
-#define TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 0xC031
-#define TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 0xC032
-#define TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA 0xC035
-#define TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA 0xC036
-#define TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 0xC037
-#define TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 0xC038
-#define TLS_ECDHE_PSK_WITH_NULL_SHA 0xC039
-#define TLS_ECDHE_PSK_WITH_NULL_SHA256 0xC03A
-#define TLS_ECDHE_PSK_WITH_NULL_SHA384 0xC03B
-#define TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 0xC072
-#define TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 0xC073
-#define TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 0xC074
-#define TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 0xC075
-#define TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 0xC076
-#define TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 0xC077
-#define TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 0xC078
-#define TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 0xC079
-#define TLS_RSA_WITH_ARIA_128_CBC_SHA256 0xC03C
-#define TLS_RSA_WITH_ARIA_256_CBC_SHA384 0xC03D
-#define TLS_DH_DSS_WITH_ARIA_128_CBC_SHA256 0xC03E
-#define TLS_DH_DSS_WITH_ARIA_256_CBC_SHA384 0xC03F
-#define TLS_DH_RSA_WITH_ARIA_128_CBC_SHA256 0xC040
-#define TLS_DH_RSA_WITH_ARIA_256_CBC_SHA384 0xC041
-#define TLS_DHE_DSS_WITH_ARIA_128_CBC_SHA256 0xC042
-#define TLS_DHE_DSS_WITH_ARIA_256_CBC_SHA384 0xC043
-#define TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256 0xC044
-#define TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384 0xC045
-#define TLS_DH_anon_WITH_ARIA_128_CBC_SHA256 0xC046
-#define TLS_DH_anon_WITH_ARIA_256_CBC_SHA384 0xC047
-#define TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256 0xC048
-#define TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384 0xC049
-#define TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256 0xC04A
-#define TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384 0xC04B
-#define TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256 0xC04C
-#define TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384 0xC04D
-#define TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256 0xC04E
-#define TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384 0xC04F
-#define TLS_RSA_WITH_ARIA_128_GCM_SHA256 0xC050
-#define TLS_RSA_WITH_ARIA_256_GCM_SHA384 0xC051
-#define TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256 0xC052
-#define TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384 0xC053
-#define TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256 0xC054
-#define TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384 0xC055
-#define TLS_DHE_DSS_WITH_ARIA_128_GCM_SHA256 0xC056
-#define TLS_DHE_DSS_WITH_ARIA_256_GCM_SHA384 0xC057
-#define TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256 0xC058
-#define TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384 0xC059
-#define TLS_DH_anon_WITH_ARIA_128_GCM_SHA256 0xC05A
-#define TLS_DH_anon_WITH_ARIA_256_GCM_SHA384 0xC05B
-#define TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 0xC05C
-#define TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 0xC05D
-#define TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 0xC05E
-#define TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 0xC05F
-#define TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 0xC060
-#define TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 0xC061
-#define TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256 0xC062
-#define TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384 0xC063
-#define TLS_PSK_WITH_ARIA_128_CBC_SHA256 0xC064
-#define TLS_PSK_WITH_ARIA_256_CBC_SHA384 0xC065
-#define TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256 0xC066
-#define TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384 0xC067
-#define TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256 0xC068
-#define TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384 0xC069
-#define TLS_PSK_WITH_ARIA_128_GCM_SHA256 0xC06A
-#define TLS_PSK_WITH_ARIA_256_GCM_SHA384 0xC06B
-#define TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256 0xC06C
-#define TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384 0xC06D
-#define TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256 0xC06E
-#define TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384 0xC06F
-#define TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256 0xC070
-#define TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384 0xC071
-#define TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 0xC076
-#define TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 0xC077
-#define TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 0xC078
-#define TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 0xC079
-#define TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 0xC07A
-#define TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 0xC07B
-#define TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 0xC07C
-#define TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 0xC07D
-#define TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 0xC07E
-#define TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 0xC07F
-#define TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 0xC080
-#define TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 0xC081
-#define TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 0xC082
-#define TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 0xC083
-#define TLS_ECDHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 0xC084
-#define TLS_ECDHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 0xC085
-#define TLS_RSA_WITH_AES_128_CCM 0xC09C
-#define TLS_RSA_WITH_AES_256_CCM 0xC09D
-#define TLS_DHE_RSA_WITH_AES_128_CCM 0xC09E
-#define TLS_DHE_RSA_WITH_AES_256_CCM 0xC09F
-#define TLS_RSA_WITH_AES_128_CCM_8 0xC0A0
-#define TLS_RSA_WITH_AES_256_CCM_8 0xC0A1
-#define TLS_DHE_RSA_WITH_AES_128_CCM_8 0xC0A2
-#define TLS_DHE_RSA_WITH_AES_256_CCM_8 0xC0A3
-#define TLS_PSK_WITH_AES_128_CCM 0xC0A4
-#define TLS_PSK_WITH_AES_256_CCM 0xC0A5
-#define TLS_DHE_PSK_WITH_AES_128_CCM 0xC0A6
-#define TLS_DHE_PSK_WITH_AES_256_CCM 0xC0A7
-#define TLS_PSK_WITH_AES_128_CCM_8 0xC0A8
-#define TLS_PSK_WITH_AES_256_CCM_8 0xC0A9
-#define TLS_PSK_DHE_WITH_AES_128_CCM_8 0xC0AA
-#define TLS_PSK_DHE_WITH_AES_256_CCM_8 0xC0AB
-#define TLS_ECDHE_ECDSA_WITH_AES_128_CCM 0xC0AC
-
-// ... add more cipher suite codes here ...
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* IANA_TLS_CIPHER_SUITES_H_ */

+ 10 - 131
library/include/libiec61850/tls_config.h

@@ -3,7 +3,7 @@
  *
  * TLS Configuration API for protocol stacks using TCP/IP
  *
- * Copyright 2017-2024 Michael Zillgith
+ * Copyright 2017-2021 Michael Zillgith
  *
  * Abstraction layer for configuration of different TLS implementations
  *
@@ -17,7 +17,6 @@ extern "C" {
 #endif
 
 #include "hal_base.h"
-#include "tls_ciphers.h"
 
 /**
  * \file tls_config.h
@@ -51,112 +50,6 @@ TLSConfiguration_create(void);
 PAL_API void
 TLSConfiguration_setClientMode(TLSConfiguration self);
 
-typedef enum {
-   TLS_VERSION_NOT_SELECTED = 0,
-   TLS_VERSION_SSL_3_0 = 3,
-   TLS_VERSION_TLS_1_0 = 4,
-   TLS_VERSION_TLS_1_1 = 5,
-   TLS_VERSION_TLS_1_2 = 6,
-   TLS_VERSION_TLS_1_3 = 7
-} TLSConfigVersion;
-
-/**
- * \brief Convert TLS version number to string
- * 
- * \param version TLS version number
- * 
- * \return the TLS version as null terminated string 
- */
-PAL_API const char*
-TLSConfigVersion_toString(TLSConfigVersion version);
-
-typedef enum {
-    TLS_SEC_EVT_INFO = 0,
-    TLS_SEC_EVT_WARNING = 1,
-    TLS_SEC_EVT_INCIDENT = 2
-} TLSEventLevel;
-
-#define TLS_EVENT_CODE_ALM_ALGO_NOT_SUPPORTED 1
-#define TLS_EVENT_CODE_ALM_UNSECURE_COMMUNICATION 2
-#define TLS_EVENT_CODE_ALM_CERT_UNAVAILABLE 3
-#define TLS_EVENT_CODE_ALM_BAD_CERT 4
-#define TLS_EVENT_CODE_ALM_CERT_SIZE_EXCEEDED 5
-#define TLS_EVENT_CODE_ALM_CERT_VALIDATION_FAILED 6
-#define TLS_EVENT_CODE_ALM_CERT_REQUIRED 7
-#define TLS_EVENT_CODE_ALM_HANDSHAKE_FAILED_UNKNOWN_REASON 8
-#define TLS_EVENT_CODE_WRN_INSECURE_TLS_VERSION 9
-#define TLS_EVENT_CODE_INF_SESSION_RENEGOTIATION 10
-#define TLS_EVENT_CODE_ALM_CERT_EXPIRED 11
-#define TLS_EVENT_CODE_ALM_CERT_REVOKED 12
-#define TLS_EVENT_CODE_ALM_CERT_NOT_CONFIGURED 13
-#define TLS_EVENT_CODE_ALM_CERT_NOT_TRUSTED 14
-#define TLS_EVENT_CODE_ALM_NO_CIPHER 15
-#define TLS_EVENT_CODE_INF_SESSION_ESTABLISHED 16
-
-typedef struct sTLSConnection* TLSConnection;
-
-/**
- * \brief Get the peer address of the TLS connection
- * 
- * \param self the TLS connection instance
- * \param peerAddrBuf user provided buffer that can hold at least 60 characters, or NULL to allow the function to allocate the memory for the buffer
- * 
- * \returns peer address:port as null terminated string 
- */
-PAL_API char*
-TLSConnection_getPeerAddress(TLSConnection self, char* peerAddrBuf);
-
-/**
- * \brief Get the TLS certificate used by the peer
- * 
- * \param self the TLS connection instance
- * \param certSize[OUT] the certificate size in bytes
- * 
- * \return address of the certificate buffer 
- */
-PAL_API uint8_t*
-TLSConnection_getPeerCertificate(TLSConnection self, int* certSize);
-
-/**
- * \brief Get the TLS version used by the connection
- * 
- * \param self the TLS connection instance
- * 
- * \return TLS version
- */
-PAL_API TLSConfigVersion
-TLSConnection_getTLSVersion(TLSConnection self);
-
-typedef void (*TLSConfiguration_EventHandler)(void* parameter, TLSEventLevel eventLevel, int eventCode, const char* message, TLSConnection con);
-
-/**
- * \brief Set the security event handler
- * 
- * \param handler the security event callback handler
- * \param parameter user provided parameter to be passed to the callback handler
- */
-PAL_API void
-TLSConfiguration_setEventHandler(TLSConfiguration self, TLSConfiguration_EventHandler handler, void* parameter);
-
-/**
- * \brief enable or disable TLS session resumption (default: enabled)
- * 
- * NOTE: Depending on the used TLS version this is implemented by
- * session IDs or by session tickets.
- * 
- * \param enable true to enable session resumption, false otherwise
- */
-PAL_API void
-TLSConfiguration_enableSessionResumption(TLSConfiguration self, bool enable);
-
-/**
- * \brief Set the maximum life time of a cached TLS session for session resumption in seconds
- *
- * \param intervalInSeconds the maximum lifetime of a cached TLS session
- */
-PAL_API void
-TLSConfiguration_setSessionResumptionInterval(TLSConfiguration self, int intervalInSeconds);
-
 /**
  * \brief Enables the validation of the certificate trust chain (enabled by default)
  *
@@ -268,6 +161,15 @@ TLSConfiguration_addCACertificateFromFile(TLSConfiguration self, const char* fil
 PAL_API void
 TLSConfiguration_setRenegotiationTime(TLSConfiguration self, int timeInMs);
 
+typedef enum {
+   TLS_VERSION_NOT_SELECTED = 0,
+   TLS_VERSION_SSL_3_0 = 3,
+   TLS_VERSION_TLS_1_0 = 4,
+   TLS_VERSION_TLS_1_1 = 5,
+   TLS_VERSION_TLS_1_2 = 6,
+   TLS_VERSION_TLS_1_3 = 7
+} TLSConfigVersion;
+
 /**
  * \brief Set minimal allowed TLS version to use
  */
@@ -299,29 +201,6 @@ TLSConfiguration_addCRL(TLSConfiguration self, uint8_t* crl, int crlLen);
 PAL_API bool
 TLSConfiguration_addCRLFromFile(TLSConfiguration self, const char* filename);
 
-/**
- * \brief Removes any CRL (certificate revocation list) currently in use
- */
-PAL_API void
-TLSConfiguration_resetCRL(TLSConfiguration self);
-
-/**
- * \brief Add an allowed ciphersuite to the list of allowed ciphersuites
- *
- * \param self the TLS configuration instance
- * \param ciphersuite the ciphersuite to add (IANA cipher suite ID)
- */
-PAL_API void
-TLSConfiguration_addCipherSuite(TLSConfiguration self, int ciphersuite);
-
-/**
- * \brief Clear the list of allowed ciphersuites
- *
- * \param self the TLS configuration instance
- */
-PAL_API void
-TLSConfiguration_clearCipherSuiteList(TLSConfiguration self);
-
 /**
  * Release all resource allocated by the TLSConfiguration instance
  *

二進制
library/lib/libiec61850.so


+ 19 - 16
modules/gateway-scheduler/src/main.cpp

@@ -17,26 +17,29 @@ int main(int argc, char* argv[]) {
   MESSAGE_PRINT(" scheduler starting");
   try {
 
-    int tcpPort = 102;
+    int port = 512;
+    // if(argc == 2){
+    //   port = std::stoi(argv[1]);
+    // }
+    TcpServer server(port);
+    server.start_server();
 
-    if (argc > 1) {
-        tcpPort = atoi(argv[1]);
-    }
 
-    MyIec61850::MyIec61850Server server("/root/config.json");
 
-    server.start();
-    server.run();
-    server.stop();
 
-    /*
-    int port = 512;
-    if(argc == 2){
-      port = std::stoi(argv[1]);
-    }
-    TcpServer server(port);
-    server.start_server();
-    */
+//    int tcpPort = 102;
+//
+//    if (argc > 2) {
+//      tcpPort = std::stoi(argv[1]);
+//    }
+//
+//    MyIec61850::MyIec61850Server iec61850Server(tcpPort, "/root/config.json");
+//
+//    iec61850Server.start();
+//    iec61850Server.run();
+//    iec61850Server.stop();
+
+
 /*
     auto report = new TaskReportService();
     report->start();

+ 141 - 23
modules/gateway-scheduler/src/report/MyIec61850Server.cpp

@@ -1,7 +1,7 @@
 #include "MyIec61850Server.h"
 #include <signal.h>
 #include <stdio.h>
-
+#include <hiredis/hiredis.h>
 static int running = 0;
 
 void sigint_handler(int signalId) {
@@ -11,9 +11,9 @@ void sigint_handler(int signalId) {
 
 using namespace MyIec61850;
 
-MyIec61850Server::MyIec61850Server(const std::string& configFilePath) {
+MyIec61850Server::MyIec61850Server(int port_in, const std::string& configFilePath) {
   setupDataModelFromConfig(configFilePath);
-  port = 102;
+  port = port_in;  //默认应该是102
 }
 
 
@@ -57,6 +57,7 @@ void MyIec61850Server::setupDataModelFromConfig(const std::string& configFilePat
             DataObject* ttmp1_tmpsv = CDC_SAV_create(temperatureDataObject.c_str(), (ModelNode*) ttmp1, 0, false);
             DataAttribute* temperatureValue = (DataAttribute*) ModelNode_getChild((ModelNode*) ttmp1_tmpsv, "instMag.f");
             DataAttribute* temperatureTimestamp = (DataAttribute*) ModelNode_getChild((ModelNode*) ttmp1_tmpsv, "t");
+            std::cout << "temperatureValue ptr: " << temperatureValue << std::endl;
 
             // 创建湿度传感器逻辑节点
             std::string humidityName = device["humidity"]["name"];
@@ -66,6 +67,7 @@ void MyIec61850Server::setupDataModelFromConfig(const std::string& configFilePat
             DataAttribute* humidityValue = (DataAttribute*) ModelNode_getChild((ModelNode*) hhum1_humsv, "instMag.f");
             DataAttribute* humidityTimestamp = (DataAttribute*) ModelNode_getChild((ModelNode*) hhum1_humsv, "t");
 
+            tmphumDeviceAttributesMap[deviceId] = TempHumDeviceAttributes{temperatureValue, temperatureTimestamp, humidityValue, humidityTimestamp};
             // 创建数据集用于报告 - 温湿度传感器
             DataSet* dataSet_sensors = DataSet_create("sensorData", lln0);
             DataSetEntry_create(dataSet_sensors, (temperatureName + "$MX$" + temperatureDataObject + "$instMag$f").c_str(), -1, NULL);
@@ -74,13 +76,44 @@ void MyIec61850Server::setupDataModelFromConfig(const std::string& configFilePat
             // 创建报告控制块 - 温湿度传感器
             uint8_t rptOptions_sensors = RPT_OPT_SEQ_NUM | RPT_OPT_TIME_STAMP | RPT_OPT_REASON_FOR_INCLUSION;
             ReportControlBlock_create("sensorReport", lln0, "sensorReport", false, NULL, 1, TRG_OPT_DATA_CHANGED, rptOptions_sensors, 50, 0);
-        } else if (deviceType == "smoke_detector") {
+        }
+      else if (deviceType == "smoke_detector") {
             // 创建烟雾报警器逻辑节点
             std::string smokeStatusName = device["status"]["name"];
             std::string smokeStatusDataObject = device["status"]["dataObject"];
             LogicalNode* ssmg1 = LogicalNode_create(smokeStatusName.c_str(), lDevice);
-            DataObject* ssmg1_smokeStatus = CDC_BSC_create(smokeStatusDataObject.c_str(), (ModelNode*) ssmg1, 0, 0, false);
-            DataAttribute* smokeStatus = (DataAttribute*) ModelNode_getChild((ModelNode*) ssmg1_smokeStatus, "stVal");
+            DataObject* ssmg1_smokeStatus = CDC_BSC_create(smokeStatusDataObject.c_str(), (ModelNode*) ssmg1, 0, 0, true);
+            if (!ssmg1_smokeStatus) {
+              std::cerr << "Failed to create BSC data object for smoke detector: " << deviceId << std::endl;
+              return;
+            }
+            DataAttribute* smokeTimestamp = (DataAttribute*) ModelNode_getChild((ModelNode*) ssmg1_smokeStatus, "t");
+
+            // // 如果 stVal 没有被正确创建,手动添加
+            DataAttribute* smokeStatus = (DataAttribute*) ModelNode_getChild((ModelNode*)ssmg1_smokeStatus, "stVal");
+            if (!smokeStatus) {
+              // 手动创建 stVal 数据属性
+              MmsValue* initialValue = MmsValue_newBoolean(false); // false 表示非告警
+              smokeStatus = (DataAttribute*) DataAttribute_create(
+                "stVal",                   // 名称
+                (ModelNode*)ssmg1_smokeStatus, // 父节点
+                IEC61850_BOOLEAN,          // 数据属性类型
+                IEC61850_FC_ST,            // 功能约束
+                0,                         // 触发选项(如果不需要触发,设为0)
+                0,                         // 数组元素数量(对于布尔值,设为0)
+                0                          // sAddr(通常设为0)
+              );
+              MmsValue_delete(initialValue);
+              if (!smokeStatus) {
+                std::cerr << "Failed to manually add 'stVal' DataAttribute." << std::endl;
+                return;
+              }
+              std::cout << "Manually added 'stVal' DataAttribute." << std::endl;
+            } else {
+              std::cout << "Successfully got 'stVal' DataAttribute: " << smokeStatus << std::endl;
+            }
+
+            smokeDeviceAttributesMap[deviceId] = smokeDeviceAttributes{smokeStatus, smokeTimestamp};
 
             // 创建数据集用于报告 - 烟雾报警器
             DataSet* dataSet_smoke = DataSet_create("smokeData", lln0);
@@ -95,7 +128,34 @@ void MyIec61850Server::setupDataModelFromConfig(const std::string& configFilePat
           std::string floodStatusDataObject = device["status"]["dataObject"];
           LogicalNode* ffls1 = LogicalNode_create(floodStatusName.c_str(), lDevice);
           DataObject* ffls1_floodStatus = CDC_BSC_create(floodStatusDataObject.c_str(), (ModelNode*) ffls1, 0, 0, false);
-          DataAttribute* floodStatus = (DataAttribute*) ModelNode_getChild((ModelNode*) ffls1_floodStatus, "stVal");
+
+          // // 如果 stVal 没有被正确创建,手动添加
+          DataAttribute* floodStatus = (DataAttribute*) ModelNode_getChild((ModelNode*)ffls1_floodStatus, "stVal");
+          if (!floodStatus) {
+            // 手动创建 stVal 数据属性
+            MmsValue* initialValue = MmsValue_newBoolean(false); // false 表示非告警
+            floodStatus = (DataAttribute*) DataAttribute_create(
+              "stVal",                   // 名称
+              (ModelNode*)ffls1_floodStatus, // 父节点
+              IEC61850_BOOLEAN,          // 数据属性类型
+              IEC61850_FC_ST,            // 功能约束
+              0,                         // 触发选项(如果不需要触发,设为0)
+              0,                         // 数组元素数量(对于布尔值,设为0)
+              0                          // sAddr(通常设为0)
+            );
+            MmsValue_delete(initialValue);
+            if (!floodStatus) {
+              std::cerr << "Failed to manually add 'stVal' DataAttribute." << std::endl;
+              return;
+            }
+            std::cout << "Manually added 'stVal' DataAttribute." << std::endl;
+          } else {
+            std::cout << "Successfully got 'stVal' DataAttribute: " << floodStatus << std::endl;
+          }
+
+          DataAttribute* floodTimestamp = (DataAttribute*) ModelNode_getChild((ModelNode*) ffls1_floodStatus, "t");
+
+          floodDeviceAttributesMap[deviceId] = FloodDeviceAttributes{floodStatus, floodTimestamp};
 
           // 创建数据集用于报告 - 水浸传感器
           DataSet* dataSet_flood = DataSet_create("floodData", lln0);
@@ -132,6 +192,7 @@ void MyIec61850Server::start() {
 
     /* MMS server will be instructed to start listening to client connections. */
     IedServer_start(iedServer, port);
+  std::cout << "61850 server listening on port :" << port << std::endl;
 
     if (!IedServer_isRunning(iedServer)) { // 使用 IedServer_isRunning 检查服务器状态
         printf("Starting server failed! Exit.\n");
@@ -154,30 +215,87 @@ void MyIec61850Server::run() {
     running = 1;
     signal(SIGINT, sigint_handler);
 
-    float temperature = 25.0f; // Initial temperature value
-    float humidity = 50.0f;    // Initial humidity value
-
     printf("Server is running and updating sensor values periodically.\n");
 
     while (running) {
-        IedServer_lockDataModel(iedServer);
-        printf("Updating sensor values: Temperature=%.2f, Humidity=%.2f\n", temperature, humidity);
 
-        /* Update temperature and humidity values */
-        // IedServer_updateUTCTimeAttributeValue(iedServer, temperatureTimestamp, Hal_getTimeInMs());
-        // IedServer_updateFloatAttributeValue(iedServer, temperatureValue, temperature);
-        //
-        // IedServer_updateUTCTimeAttributeValue(iedServer, humidityTimestamp, Hal_getTimeInMs());
-        // IedServer_updateFloatAttributeValue(iedServer, humidityValue, humidity);
 
-        IedServer_unlockDataModel(iedServer);
+      redisContext* rediscon = redisConnect("127.0.0.1", 6379);
+      if (rediscon == nullptr || rediscon->err) {
+        if (rediscon) {
+          std::cerr << "Connection error: " << rediscon->errstr << std::endl;
+          redisFree(rediscon);
+        } else {
+          std::cerr << "Connection error: can't allocate redis context" << std::endl;
+        }
+        return;
+      }
+
+      redisReply* reply = (redisReply*)redisCommand(rediscon, "KEYS *");
+      if (reply == nullptr) {
+        std::cerr << "Error: " << rediscon->errstr << std::endl;
+        redisFree(rediscon);
+        return;
+      }
+      if (reply->type == REDIS_REPLY_ARRAY) {
+        for (size_t i = 0; i < reply->elements; ++i) {
+          std::string key = reply->element[i]->str;
+          if(key.find("device_") != std::string::npos){
+            redisReply* valueReply = (redisReply*)redisCommand(rediscon, "GET %s", key.c_str());
+            if (valueReply && valueReply->type == REDIS_REPLY_STRING) {
+
+              nlohmann::json value = nlohmann::json::parse(valueReply->str);
+               std::string deviceName = value["device_name"];
+              if (deviceName.find("温湿度") != std::string::npos) { //温湿度传感器
+                if (tmphumDeviceAttributesMap.find(deviceName) != tmphumDeviceAttributesMap.end()) {
+
+                  IedServer_lockDataModel(iedServer);
+                  IedServer_updateUTCTimeAttributeValue(iedServer, tmphumDeviceAttributesMap[deviceName].temperatureTimestamp, Hal_getTimeInMs());
+                  IedServer_updateFloatAttributeValue(iedServer, tmphumDeviceAttributesMap[deviceName].temperatureValue, value["data"][0]["value"]);
+
+                  IedServer_updateUTCTimeAttributeValue(iedServer, tmphumDeviceAttributesMap[deviceName].humidityTimestamp, Hal_getTimeInMs());
+                  IedServer_updateFloatAttributeValue(iedServer, tmphumDeviceAttributesMap[deviceName].humidityValue, value["data"][1]["value"]);
+                  IedServer_unlockDataModel(iedServer);
+
+
+                }else {
+                  std::cout << "No tmphum device name!" << deviceName << std::endl;
+                }
+              }else if(deviceName.find("烟感") != std::string::npos) {
+                IedServer_lockDataModel(iedServer);
+                if (smokeDeviceAttributesMap.find(deviceName) != smokeDeviceAttributesMap.end()) {
+                  IedServer_updateUTCTimeAttributeValue(iedServer, smokeDeviceAttributesMap[deviceName].smokeTimestamp, Hal_getTimeInMs());
+                  MmsValue* newStatusValue = MmsValue_newBoolean(value["data"][0]["value"].get<int>());
+                  IedServer_updateAttributeValue(iedServer, smokeDeviceAttributesMap[deviceName].smokeStatus, newStatusValue);
+                } else {
+                  std::cout << "No flood device name!" << deviceName << std::endl;
+                }
+                IedServer_unlockDataModel(iedServer);
+
+              }else if(deviceName.find("水浸") != std::string::npos) {
+                IedServer_lockDataModel(iedServer);
+                if (floodDeviceAttributesMap.find(deviceName) != floodDeviceAttributesMap.end()) {
+                  IedServer_updateUTCTimeAttributeValue(iedServer, floodDeviceAttributesMap[deviceName].floodTimestamp, Hal_getTimeInMs());
+                  bool val = value["data"][0]["value"].get<int>();
+                  MmsValue* newfloodStatusValue = MmsValue_newBoolean(val);
+                  IedServer_updateAttributeValue(iedServer, floodDeviceAttributesMap[deviceName].floodStatus, newfloodStatusValue);
+                } else {
+                  std::cout << "No smoke device name !" << deviceName << std::endl;
+                }
+                IedServer_unlockDataModel(iedServer);
+              }
+
+            }
+          }
+        }
+      }
+      freeReplyObject(reply);
+      redisFree(rediscon);
 
-        /* Simulate periodic updates */
-        temperature += 0.1f;
-        humidity += 0.1f;
 
-        Thread_sleep(1000); // Sleep for 1 second
+        Thread_sleep(3000); // Sleep for 1 second
     }
 
+
     printf("Server stopped.\n");
 }

+ 41 - 41
modules/gateway-scheduler/src/report/MyIec61850Server.h

@@ -10,50 +10,47 @@
 #include <iostream>
 #include <nlohmann/json.hpp> // 假设你使用 nlohmann/json 库来解析 JSON
 namespace MyIec61850 {
-//
-// class MyIec61850Server {
-// public:
-//     MyIec61850Server(int port = 102);
-//     ~MyIec61850Server();
-//
-//     void start();
-//     void stop();
-//     void run();
-//
-// private:
-//     void setupDataModel(); // 声明 setupDataModel 方法
-//
-//     int port;
-//     sIedServer* iedServer; // 确保使用 sIedServer* 类型
-//     IedModel* model;
-//
-//     LogicalDevice* lDevice1;
-//     LogicalDevice* lDevice2;
-//
-//     LogicalNode* lln0_sensors;
-//     LogicalNode* lln0_smoke;
-//
-//     LogicalNode* ttmp1;
-//     LogicalNode* hhum1;
-//
-//     LogicalNode* ssmg1;
-//
-//     DataAttribute* temperatureValue;
-//     DataAttribute* temperatureTimestamp;
-//     DataAttribute* humidityValue;
-//     DataAttribute* humidityTimestamp;
-//     DataAttribute* smokeStatus;
-//
-//     DataSet* dataSet_sensors;
-//     DataSet* dataSet_smoke;
-//
-//     DataSet* dataSet;
-// };
+
   using json = nlohmann::json;
 
+struct TempHumDeviceAttributes {
+  DataAttribute* temperatureValue;
+  DataAttribute* temperatureTimestamp;
+  DataAttribute* humidityValue;
+  DataAttribute* humidityTimestamp;
+  TempHumDeviceAttributes()
+      : temperatureValue(nullptr), temperatureTimestamp(nullptr),
+        humidityValue(nullptr), humidityTimestamp(nullptr) {}
+  // 构造函数,接受四个指针作为参数
+  TempHumDeviceAttributes(DataAttribute* tv, DataAttribute* tt, DataAttribute* hv, DataAttribute* ht)
+      : temperatureValue(tv), temperatureTimestamp(tt),
+        humidityValue(hv), humidityTimestamp(ht) {}
+};
+
+struct FloodDeviceAttributes {
+  DataAttribute* floodStatus;
+  DataAttribute* floodTimestamp;
+
+  FloodDeviceAttributes()
+      : floodStatus(nullptr), floodTimestamp(nullptr) {}
+  // 构造函数,接受四个指针作为参数
+  FloodDeviceAttributes(DataAttribute* fv, DataAttribute* tt)
+      : floodStatus(fv), floodTimestamp(tt) {}
+};
+struct smokeDeviceAttributes {
+  DataAttribute* smokeStatus;
+  DataAttribute* smokeTimestamp;
+
+  smokeDeviceAttributes()
+      : smokeStatus(nullptr), smokeTimestamp(nullptr) {}
+  // 构造函数,接受四个指针作为参数
+  smokeDeviceAttributes(DataAttribute* sv, DataAttribute* tt)
+      : smokeStatus(sv), smokeTimestamp(tt) {}
+};
+
 class MyIec61850Server {
-  public:
-    MyIec61850Server(const std::string& configFilePath);
+ public:
+  MyIec61850Server(int port, const std::string& configFilePath);
     ~MyIec61850Server();
     void setupDataModelFromConfig(const std::string& configFilePath);
     void start();
@@ -64,6 +61,9 @@ class MyIec61850Server {
     IedModel* model;
     int port;
     sIedServer* iedServer; // 确保使用 sIedServer* 类型
+    std::unordered_map<std::string, TempHumDeviceAttributes> tmphumDeviceAttributesMap;
+    std::unordered_map<std::string, FloodDeviceAttributes> floodDeviceAttributesMap;
+    std::unordered_map<std::string, smokeDeviceAttributes> smokeDeviceAttributesMap;
 };
 
 } // namespace MyIec61850

+ 8 - 7
modules/gateway-scheduler/src/tcp_server/TcpServer.cpp

@@ -138,7 +138,8 @@ void TcpServer::start_server() {
             threads.emplace_back(&TcpServer::handle_client, this, new_socket);
         }
     });
-    accept_thread.join();  // 让接受线程独立运行
+//    accept_thread.detach();  // 让接受线程独立运行
+    accept_thread.join();
 }
 
 
@@ -356,12 +357,12 @@ void TcpServer::handle_client(int client_socket) {
         sqlite3_finalize(stmt);
 
         // 查询数据
-        const char *sql_select_data = "SELECT * FROM history_data;";
-        rc = sqlite3_exec(db, sql_select_data, sql_callback, 0, &zErrMsg);
-        if (rc != SQLITE_OK) {
-            fprintf(stderr, "SQL error: %s\n", zErrMsg);
-            sqlite3_free(zErrMsg);
-        }
+        // const char *sql_select_data = "SELECT * FROM history_data;";
+        // rc = sqlite3_exec(db, sql_select_data, sql_callback, 0, &zErrMsg);
+        // if (rc != SQLITE_OK) {
+        //     fprintf(stderr, "SQL error: %s\n", zErrMsg);
+        //     sqlite3_free(zErrMsg);
+        // }
 
         // 关闭数据库连接
         sqlite3_close(db);

+ 27 - 4
modules/gateway-server/src/server/BasicServer.cpp

@@ -22,6 +22,8 @@
 #include "gateway-basic/src/utils/StringUtils.h"
 #include "microhttpd.h"
 
+#include "gateway-server/src/large_screen_display/devices_info.h"
+
 using namespace server::basic;
 
 namespace server {
@@ -80,10 +82,31 @@ MHD_Result BasicServer::requestHandler(void* cls, struct MHD_Connection* connect
     Json json = error;
     response = json.dump();
   } else {
-    BasicRoute route = generate_route(url, method);
-    route.request = (BasicRequest*)*req_cls;
-    BasicRouter router;
-    response = router.router(route);
+    std::string url_string(url);
+    std::cout << "url " << url << std::endl;
+
+    if (url_string.rfind("/api/largeScreenDisplay/", 0) == 0) { // 确保从字符串的开始处匹配
+      if (url_string.find("/video") != std::string::npos) {
+        std::cout << "largeScreenDisplay video" << std::endl;
+      } else if (url_string.find("/history_data") != std::string::npos) {
+        std::cout << "largeScreenDisplay history_data" << std::endl;
+        auto devices_history = createDeviceHistoryData();
+        Json response_json = deviceHistoryToJson(devices_history);
+        std::cout << response_json.dump(4) << std::endl;
+        response = response_json.dump();
+      } else if (url_string.find("/devices_info") != std::string::npos) {
+        std::cout << "largeScreenDisplay devices_info" << std::endl;
+        auto devices = createDeviceInfo();
+        Json response_json = deviceInfoToJson(devices);
+        // std::cout << response_json.dump() << std::endl;
+        response = response_json.dump();
+      }
+    }else {
+      BasicRoute route = generate_route(url, method);
+      route.request = (BasicRequest*)*req_cls;
+      BasicRouter router;
+      response = router.router(route);
+    }
   }
   struct MHD_Response* http_response =
       MHD_create_response_from_buffer(response.length(), (void*)response.c_str(), MHD_RESPMEM_MUST_COPY);