#include "ua_util.h" #include "ua_session.h" #include "ua_statuscodes.h" UA_Session anonymousSession = { .clientDescription = {.applicationUri = {-1, UA_NULL}, .productUri = {-1, UA_NULL}, .applicationName = {.locale = {-1, UA_NULL}, .text = {-1, UA_NULL}}, .applicationType = UA_APPLICATIONTYPE_CLIENT, .gatewayServerUri = {-1, UA_NULL}, .discoveryProfileUri = {-1, UA_NULL}, .discoveryUrlsSize = -1, .discoveryUrls = UA_NULL}, .sessionName = {sizeof("Anonymous Session")-1, (UA_Byte*)"Anonymous Session"}, .authenticationToken = {.namespaceIndex = 0, .identifierType = UA_NODEIDTYPE_NUMERIC, .identifier.numeric = 0}, .sessionId = {.namespaceIndex = 0, .identifierType = UA_NODEIDTYPE_NUMERIC, .identifier.numeric = 0}, .maxRequestMessageSize = UA_UINT32_MAX, .maxResponseMessageSize = UA_UINT32_MAX, .timeout = UA_INT64_MAX, .validTill = UA_INT64_MAX, .channel = UA_NULL, .continuationPoints = {UA_NULL}}; UA_Session adminSession = { .clientDescription = {.applicationUri = {-1, UA_NULL}, .productUri = {-1, UA_NULL}, .applicationName = {.locale = {-1, UA_NULL}, .text = {-1, UA_NULL}}, .applicationType = UA_APPLICATIONTYPE_CLIENT, .gatewayServerUri = {-1, UA_NULL}, .discoveryProfileUri = {-1, UA_NULL}, .discoveryUrlsSize = -1, .discoveryUrls = UA_NULL}, .sessionName = {sizeof("Administrator Session")-1, (UA_Byte*)"Administrator Session"}, .authenticationToken = {.namespaceIndex = 0, .identifierType = UA_NODEIDTYPE_NUMERIC, .identifier.numeric = 1}, .sessionId = {.namespaceIndex = 0, .identifierType = UA_NODEIDTYPE_NUMERIC, .identifier.numeric = 1}, .maxRequestMessageSize = UA_UINT32_MAX, .maxResponseMessageSize = UA_UINT32_MAX, .timeout = UA_INT64_MAX, .validTill = UA_INT64_MAX, .channel = UA_NULL, .continuationPoints = {UA_NULL}}; void UA_Session_init(UA_Session *session) { UA_ApplicationDescription_init(&session->clientDescription); session->activated = UA_FALSE; UA_NodeId_init(&session->authenticationToken); UA_NodeId_init(&session->sessionId); UA_String_init(&session->sessionName); session->maxRequestMessageSize = 0; session->maxResponseMessageSize = 0; session->timeout = 0; UA_DateTime_init(&session->validTill); session->channel = UA_NULL; session->availableContinuationPoints = MAXCONTINUATIONPOINTS; LIST_INIT(&session->continuationPoints); } void UA_Session_deleteMembersCleanup(UA_Session *session) { UA_ApplicationDescription_deleteMembers(&session->clientDescription); UA_NodeId_deleteMembers(&session->authenticationToken); UA_NodeId_deleteMembers(&session->sessionId); UA_String_deleteMembers(&session->sessionName); struct ContinuationPointEntry *cp; while((cp = LIST_FIRST(&session->continuationPoints))) { UA_ByteString_deleteMembers(&cp->identifier); UA_BrowseDescription_deleteMembers(&cp->browseDescription); LIST_REMOVE(cp, pointers); UA_free(cp); } if(session->channel) UA_SecureChannel_detachSession(session->channel, session); } void UA_Session_updateLifetime(UA_Session *session) { session->validTill = UA_DateTime_now() + session->timeout * 10000; //timeout in ms }