ua_stack_channel.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * ua_stack_channel.h
  3. *
  4. * Created on: 09.05.2014
  5. * Author: root
  6. */
  7. #ifndef UA_STACK_CHANNEL_H_
  8. #define UA_STACK_CHANNEL_H_
  9. #include <stdio.h>
  10. #include <memory.h> // memcpy
  11. #include "opcua.h"
  12. #include "ua_transport_connection.h"
  13. typedef enum ChannelState {
  14. UA_SL_CHANNEL_CLOSING,
  15. UA_SL_CHANNEL_CLOSED,
  16. UA_SL_CHANNEL_OPENING,
  17. UA_SL_CHANNEL_OPEN
  18. }SL_channelState;
  19. //hide object behind typedef
  20. typedef struct SL_Channel1 *SL_secureChannel;
  21. typedef UA_Int32 (*SL_ChannelSecurityTokenProvider)(SL_secureChannel ,UA_Int32 , SecurityTokenRequestType, UA_ChannelSecurityToken*);
  22. typedef UA_Int32 (*SL_ChannelIdProvider)(UA_UInt32*);
  23. UA_Int32 SL_Channel_new(SL_secureChannel *channel,
  24. SL_ChannelIdProvider channelIdProvider,
  25. SL_ChannelSecurityTokenProvider tokenProvider,
  26. UA_ByteString *receiverCertificateThumbprint,
  27. UA_ByteString *securityPolicyUri,
  28. UA_ByteString *senderCertificate,
  29. UA_MessageSecurityMode securityMode);
  30. UA_Int32 SL_Channel_init(SL_secureChannel channel,
  31. UA_ByteString *receiverCertificateThumbprint,
  32. UA_ByteString *securityPolicyUri,
  33. UA_ByteString *senderCertificate, UA_MessageSecurityMode securityMode);
  34. UA_Int32 SL_Channel_initByRequest(SL_secureChannel channel, UA_TL_Connection1 connection, const UA_ByteString* msg,
  35. UA_Int32* pos);
  36. UA_Int32 SL_Channel_initMembers(SL_secureChannel channel,
  37. UA_TL_Connection1 *connection,
  38. UA_UInt32 connectionId,
  39. UA_UInt32 sequenceNumber,
  40. UA_UInt32 requestId,
  41. UA_MessageSecurityMode securityMode,
  42. UA_ByteString *remoteNonce,
  43. UA_ByteString *localNonce,
  44. UA_ByteString *receiverCertificateThumbprint,
  45. UA_ByteString *securityPolicyUri,
  46. UA_ByteString *senderCertificate);
  47. UA_Int32 SL_Channel_delete(SL_secureChannel channel);
  48. UA_Int32 SL_Channel_deleteMembers(SL_secureChannel channel);
  49. UA_Int32 SL_Channel_renewToken(SL_secureChannel channel, UA_UInt32 tokenId, UA_DateTime revisedLifetime, UA_DateTime createdAt);
  50. UA_Int32 SL_Channel_processOpenRequest(SL_secureChannel channel,
  51. const UA_OpenSecureChannelRequest* request, UA_OpenSecureChannelResponse* response);
  52. UA_Int32 SL_Channel_processCloseRequest(SL_secureChannel channel,
  53. const UA_CloseSecureChannelRequest* request);
  54. UA_Int32 SL_Channel_registerTokenProvider(SL_secureChannel channel,SL_ChannelSecurityTokenProvider provider);
  55. UA_Int32 SL_Channel_registerChannelIdProvider(SL_ChannelIdProvider provider);
  56. UA_Int32 SL_Channel_checkSequenceNumber(SL_secureChannel channel, UA_UInt32 sequenceNumber);
  57. _Bool SL_Channel_equal(void* channel1, void* channel2);
  58. //getters
  59. UA_Int32 SL_Channel_getChannelId(SL_secureChannel channel, UA_UInt32 *channelId);
  60. UA_Int32 SL_Channel_getTokenId(SL_secureChannel channel, UA_UInt32 *tokenlId);
  61. UA_Int32 SL_Channel_getSequenceNumber(SL_secureChannel channel, UA_UInt32 *sequenceNumber);
  62. UA_Int32 SL_Channel_getRequestId(SL_secureChannel channel, UA_UInt32 *requestId);
  63. UA_Int32 SL_Channel_getConnectionId(SL_secureChannel channel, UA_UInt32 *connectionId);
  64. UA_Int32 SL_Channel_getConnection(SL_secureChannel channel, UA_TL_Connection1 *connection);
  65. UA_Int32 SL_Channel_getState(SL_secureChannel channel, SL_channelState *channelState);
  66. UA_Int32 SL_Channel_getLocalAsymAlgSettings(SL_secureChannel channel, UA_AsymmetricAlgorithmSecurityHeader **asymAlgSettings);
  67. UA_Int32 SL_Channel_getRemainingLifetime(SL_secureChannel channel, UA_Int32 *lifetime);
  68. UA_Int32 SL_Channel_getRevisedLifetime(SL_secureChannel channel, UA_UInt32 *revisedLifetime);
  69. //setters
  70. UA_Int32 SL_Channel_setId(SL_secureChannel channel, UA_UInt32 id);
  71. /*
  72. typedef struct SL_ChannelManager {
  73. UA_UInt32 maxChannelCount;
  74. UA_Int32 lastChannelId;
  75. UA_UInt32 currentChannelCount;
  76. UA_DateTime maxChannelLifeTime;
  77. UA_indexedList_List channels;
  78. UA_MessageSecurityMode securityMode;
  79. UA_String *endpointUrl;
  80. }SL_ChannelManager;
  81. UA_Int32 SL_ChannelManager_init(SL_ChannelManager *channelManager, UA_UInt32 maxChannelCount, UA_Int32 startChannelId);
  82. UA_Int32 SL_ChannelManager_addChannel(SL_secureChannel channel);
  83. UA_Int32 SL_ChannelManager_renewChannelToken(UA_Int32 channelId, UA_DateTime requestedLifeTime);
  84. UA_Int32 SL_ChannelManager_bindChannel(UA_Int32 channelId, UA_TL_Connection1 connection);
  85. UA_Int32 SL_ChannelManager_removeChannel(UA_Int32 channelId);
  86. UA_Int32 SL_ChannelManager_getChannel(UA_Int32 channelId, SL_secureChannel *channel);
  87. UA_Int32 SL_ChannelManager_updateChannels();
  88. */
  89. #endif /* UA_STACK_CHANNEL_H_ */