|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
/*
|
|
|
|
|
* r_session.h
|
|
|
|
|
*
|
|
|
|
|
* Copyright 2013-2021 Michael Zillgith
|
|
|
|
|
* Copyright 2013-2022 Michael Zillgith
|
|
|
|
|
*
|
|
|
|
|
* This file is part of libIEC61850.
|
|
|
|
|
*
|
|
|
|
@ -21,8 +21,8 @@
|
|
|
|
|
* See COPYING file for the complete license text.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef LIBIEC61850_SRC_SAMPLED_VALUES_R_SESSION_H_
|
|
|
|
|
#define LIBIEC61850_SRC_SAMPLED_VALUES_R_SESSION_H_
|
|
|
|
|
#ifndef LIBIEC61850_R_SESSION_H_
|
|
|
|
|
#define LIBIEC61850_R_SESSION_H_
|
|
|
|
|
|
|
|
|
|
#include "libiec61850_common_api.h"
|
|
|
|
|
#include "hal_socket.h"
|
|
|
|
@ -91,10 +91,26 @@ RSession_create();
|
|
|
|
|
LIB61850_API void
|
|
|
|
|
RSession_setBufferSize(RSession self, uint16_t bufferSize);
|
|
|
|
|
|
|
|
|
|
/* Required only for version 1 of the protocol! */
|
|
|
|
|
/**
|
|
|
|
|
* \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);
|
|
|
|
|
|
|
|
|
@ -165,9 +181,23 @@ RSession_stopListening(RSession self);
|
|
|
|
|
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
|
|
|
|
@ -179,6 +209,10 @@ typedef void (*RSession_KeyEventHandler) (void* parameter, RSession rSession, RS
|
|
|
|
|
* \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);
|
|
|
|
@ -188,6 +222,8 @@ RSession_setKeyEventHandler(RSession self, RSession_KeyEventHandler handler, voi
|
|
|
|
|
*
|
|
|
|
|
* \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);
|
|
|
|
@ -204,4 +240,4 @@ RSession_destroy(RSession self);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif /* LIBIEC61850_SRC_SAMPLED_VALUES_R_SESSION_H_ */
|
|
|
|
|
#endif /* LIBIEC61850_R_SESSION_H_ */
|
|
|
|
|