open62541 1.3.12
Open source implementation of OPC UA
Loading...
Searching...
No Matches
ua_session.h
Go to the documentation of this file.
1/** This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 *
5 * Copyright 2018 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
6 * Copyright 2019 (c) HMS Industrial Networks AB (Author: Jonas Green)
7 */
8
9#ifndef UA_SESSION_H_
10#define UA_SESSION_H_
11
12#include <open62541/util.h>
13
14#include "ua_securechannel.h"
15
17
18#define UA_MAXCONTINUATIONPOINTS 5
19
22
23/** Returns the next entry in the linked list */
26
27struct UA_Subscription;
29
30#ifdef UA_ENABLE_SUBSCRIPTIONS
36#endif
37
38typedef struct {
43 void *sessionHandle; /* pointer assigned in userland-callback */
47 UA_Double timeout; /* in ms */
50
53
54 size_t paramsSize;
56
57 /* Localization information */
60
61#ifdef UA_ENABLE_SUBSCRIPTIONS
62 /* The queue is ordered according to the priority byte (higher bytes come
63 * first). When a late subscription finally publishes, then it is pushed to
64 * the back within the sub-set of subscriptions that has the same priority
65 * (round-robin scheduling). */
67 TAILQ_HEAD(, UA_Subscription) subscriptions;
68
71
72 size_t totalRetransmissionQueueSize; /* Retransmissions of all subscriptions */
73#endif
74
75#ifdef UA_ENABLE_DIAGNOSTICS
76 UA_SessionSecurityDiagnosticsDataType securityDiagnostics;
77 UA_SessionDiagnosticsDataType diagnostics;
78#endif
80
81
82
84void UA_Session_clear(UA_Session *session, UA_Server *server);
88
89/** If any activity on a session happens, the timeout is extended */
91
92
93
94#ifdef UA_ENABLE_SUBSCRIPTIONS
95
96void
98
99/** If releasePublishResponses is true and the last subscription is removed, all
100 * outstanding PublishResponse are sent with a StatusCode. But we don't do that
101 * if a Subscription is only detached for modification. */
102void
104 UA_Subscription *sub, UA_Boolean releasePublishResponses);
105
108 UA_UInt32 subscriptionId);
109
110
111void
114 UA_Boolean head);
115
118
119#endif
120
121
122
123#define UA_LOG_SESSION_INTERNAL(LOGGER, LEVEL, SESSION, MSG, ...) \
124 do { \
125 int nameLen = (SESSION) ? (int)(SESSION)->sessionName.length : 0; \
126 const char *nameStr = (SESSION) ? \
127 (const char*)(SESSION)->sessionName.data : NULL; \
128 UA_UInt32 chanId = ((SESSION) && (SESSION)->header.channel) ? \
129 (SESSION)->header.channel->securityToken.channelId : 0; \
130 UA_LOG_##LEVEL(LOGGER, UA_LOGCATEGORY_SESSION, \
131 "SecureChannel %" PRIu32 " | Session \"%.*s\" | " MSG "%.0s", \
132 chanId, nameLen, nameStr, __VA_ARGS__); \
133 } while(0)
134
135#if UA_LOGLEVEL <= 100
136# define UA_LOG_TRACE_SESSION(LOGGER, SESSION, ...) \
137 UA_MACRO_EXPAND(UA_LOG_SESSION_INTERNAL(LOGGER, TRACE, SESSION, __VA_ARGS__, ""))
138#else
139# define UA_LOG_TRACE_SESSION(LOGGER, SESSION, ...)
140#endif
141
142#if UA_LOGLEVEL <= 200
143# define UA_LOG_DEBUG_SESSION(LOGGER, SESSION, ...) \
144 UA_MACRO_EXPAND(UA_LOG_SESSION_INTERNAL(LOGGER, DEBUG, SESSION, __VA_ARGS__, ""))
145#else
146# define UA_LOG_DEBUG_SESSION(LOGGER, SESSION, ...)
147#endif
148
149#if UA_LOGLEVEL <= 300
150# define UA_LOG_INFO_SESSION(LOGGER, SESSION, ...) \
151 UA_MACRO_EXPAND(UA_LOG_SESSION_INTERNAL(LOGGER, INFO, SESSION, __VA_ARGS__, ""))
152#else
153# define UA_LOG_INFO_SESSION(LOGGER, SESSION, ...)
154#endif
155
156#if UA_LOGLEVEL <= 400
157# define UA_LOG_WARNING_SESSION(LOGGER, SESSION, ...) \
158 UA_MACRO_EXPAND(UA_LOG_SESSION_INTERNAL(LOGGER, WARNING, SESSION, __VA_ARGS__, ""))
159#else
160# define UA_LOG_WARNING_SESSION(LOGGER, SESSION, ...)
161#endif
162
163#if UA_LOGLEVEL <= 500
164# define UA_LOG_ERROR_SESSION(LOGGER, SESSION, ...) \
165 UA_MACRO_EXPAND(UA_LOG_SESSION_INTERNAL(LOGGER, ERROR, SESSION, __VA_ARGS__, ""))
166#else
167# define UA_LOG_ERROR_SESSION(LOGGER, SESSION, ...)
168#endif
169
170#if UA_LOGLEVEL <= 600
171# define UA_LOG_FATAL_SESSION(LOGGER, SESSION, ...) \
172 UA_MACRO_EXPAND(UA_LOG_SESSION_INTERNAL(LOGGER, FATAL, SESSION, __VA_ARGS__, ""))
173#else
174# define UA_LOG_FATAL_SESSION(LOGGER, SESSION, ...)
175#endif
176
178
179#endif /* UA_SESSION_H_ */
#define _UA_BEGIN_DECLS
#undef UA_DEBUG_DUMP_PKGS
Definition config.h:89
#define _UA_END_DECLS
Definition config.h:96
UA_PublishResponse response
Definition ua_session.h:34
SIMPLEQ_ENTRY(UA_PublishResponseEntry) listEntry
Thread-local variables to force failure modes during testing.
UA_NodeId sessionId
Definition ua_session.h:44
UA_UInt32 maxResponseMessageSize
Definition ua_session.h:46
UA_KeyValuePair * params
Definition ua_session.h:55
UA_DateTime validTill
Definition ua_session.h:48
UA_Double timeout
Definition ua_session.h:47
size_t responseQueueSize
Definition ua_session.h:69
SIMPLEQ_HEAD(, UA_PublishResponseEntry) responseQueue
UA_SessionHeader header
Definition ua_session.h:39
size_t totalRetransmissionQueueSize
Definition ua_session.h:72
UA_ByteString serverNonce
Definition ua_session.h:49
UA_String sessionName
Definition ua_session.h:41
ContinuationPoint * continuationPoints
Definition ua_session.h:52
UA_String * localeIds
Definition ua_session.h:59
size_t paramsSize
Definition ua_session.h:54
TAILQ_HEAD(, UA_Subscription) subscriptions
UA_ApplicationDescription clientDescription
Definition ua_session.h:40
size_t subscriptionsSize
Definition ua_session.h:66
UA_UInt32 maxRequestMessageSize
Definition ua_session.h:45
void * sessionHandle
Definition ua_session.h:43
UA_UInt16 availableContinuationPoints
Definition ua_session.h:51
UA_Boolean activated
Definition ua_session.h:42
size_t localeIdsSize
Definition ua_session.h:58
Subscriptions are managed in a server-wide linked list.
_UA_BEGIN_DECLS typedef bool UA_Boolean
This Source Code Form is subject to the terms of the Mozilla Public License, v.
Definition types.h:26
uint16_t UA_UInt16
Definition types.h:46
uint32_t UA_UInt32
Definition types.h:56
int64_t UA_DateTime
Definition types.h:144
uint32_t UA_StatusCode
Definition types.h:77
double UA_Double
Definition types.h:74
void UA_Session_queuePublishReq(UA_Session *session, UA_PublishResponseEntry *entry, UA_Boolean head)
void UA_Session_attachSubscription(UA_Session *session, UA_Subscription *sub)
void UA_Session_attachToSecureChannel(UA_Session *session, UA_SecureChannel *channel)
void UA_Session_updateLifetime(UA_Session *session)
If any activity on a session happens, the timeout is extended.
UA_PublishResponseEntry * UA_Session_dequeuePublishReq(UA_Session *session)
ContinuationPoint * ContinuationPoint_clear(ContinuationPoint *cp)
Returns the next entry in the linked list.
UA_StatusCode UA_Session_generateNonce(UA_Session *session)
void UA_Session_clear(UA_Session *session, UA_Server *server)
void UA_Session_detachFromSecureChannel(UA_Session *session)
void UA_Session_detachSubscription(UA_Server *server, UA_Session *session, UA_Subscription *sub, UA_Boolean releasePublishResponses)
If releasePublishResponses is true and the last subscription is removed, all outstanding PublishRespo...
void UA_Session_init(UA_Session *session)
struct ContinuationPoint ContinuationPoint
Definition ua_session.h:21
struct UA_PublishResponseEntry UA_PublishResponseEntry
UA_Subscription * UA_Session_getSubscriptionById(UA_Session *session, UA_UInt32 subscriptionId)