The OPC server uses the SNMP protocol to perform data exchange with SNMP devices. All information can be integrated in OPC-compatible systems, such as the WinCC HMI system. This enables process and network diagnostics to be combined in the HMI system. Current versions and software updates are always available in the Industry Mall. Siemens South Africa set out to see what could be learnt about the DNA of Alexandra township & ended up inspiring a new business opportunity. When corn is turned into clothing With assistance from Siemens, Cathay Industrial Biotech Ltd. Is building a digital factory to turn renewable biomass into polyamide.

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

51 commits
Select commit Hold shift + click to select a range

Opc Scout V10 Download

Filter file types
Failed to load files and symbols.

feature: access control plugin; give session handle to method callbacks

  • Loading branch information...
@@ -176,6 +176,7 @@ set(exported_headers ${PROJECT_BINARY_DIR}/src_generated/ua_config.h
${PROJECT_SOURCE_DIR}/include/ua_client.h
${PROJECT_SOURCE_DIR}/include/ua_client_highlevel.h
${PROJECT_SOURCE_DIR}/plugins/ua_network_tcp.h
${PROJECT_SOURCE_DIR}/plugins/ua_accesscontrol_default.h
${PROJECT_SOURCE_DIR}/plugins/ua_log_stdout.h
${PROJECT_SOURCE_DIR}/plugins/ua_config_standard.h)
set(internal_headers ${PROJECT_SOURCE_DIR}/deps/queue.h
@@ -233,6 +234,7 @@ set(lib_sources ${PROJECT_SOURCE_DIR}/src/ua_types.c
${PROJECT_SOURCE_DIR}/src/client/ua_client_highlevel_subscriptions.c
# plugins and dependencies
${PROJECT_SOURCE_DIR}/plugins/ua_network_tcp.c
${PROJECT_SOURCE_DIR}/plugins/ua_accesscontrol_default.c
${PROJECT_SOURCE_DIR}/plugins/ua_clock.c
${PROJECT_SOURCE_DIR}/plugins/ua_log_stdout.c
${PROJECT_SOURCE_DIR}/plugins/ua_config_standard.c

Siemens Opc Scout V10 Firefox Updates Download

@@ -77,7 +77,8 @@ readTimeData(void *handle, const UA_NodeId nodeId, UA_Boolean sourceTimeStamp,
/* Method Node Example */
#ifdef UA_ENABLE_METHODCALLS
static UA_StatusCode
helloWorld(void *methodHandle, const UA_NodeId objectId,
helloWorld(void *methodHandle, const UA_NodeId *objectId,
const UA_NodeId *sessionId, void *sessionHandle,
size_t inputSize, const UA_Variant *input,
size_t outputSize, UA_Variant *output) {
/* input is a scalar string (checked by the server) */
@@ -94,16 +95,18 @@ helloWorld(void *methodHandle, const UA_NodeId objectId,
}

static UA_StatusCode
noargMethod (void *methodHandle, const UA_NodeId objectId,
size_t inputSize, const UA_Variant *input,
size_t outputSize, UA_Variant *output) {
noargMethod(void *methodHandle, const UA_NodeId *objectId,
const UA_NodeId *sessionId, void *sessionHandle,
size_t inputSize, const UA_Variant *input,
size_t outputSize, UA_Variant *output) {
return UA_STATUSCODE_GOOD;
}

static UA_StatusCode
outargMethod (void *methodHandle, const UA_NodeId objectId,
size_t inputSize, const UA_Variant *input,
size_t outputSize, UA_Variant *output) {
outargMethod(void *methodHandle, const UA_NodeId *objectId,
const UA_NodeId *sessionId, void *sessionHandle,
size_t inputSize, const UA_Variant *input,
size_t outputSize, UA_Variant *output) {
UA_Int32 out = 42;
UA_Variant_setScalarCopy(output, &out, &UA_TYPES[UA_TYPES_INT32]);
return UA_STATUSCODE_GOOD;
@@ -20,7 +20,8 @@ UA_Logger logger = UA_Log_Stdout;

/* Example 1 */
static UA_StatusCode
helloWorldMethod(void *handle, const UA_NodeId objectId,
helloWorldMethod(void *handle, const UA_NodeId *objectId,
const UA_NodeId *sessionId, void *sessionHandle,
size_t inputSize, const UA_Variant *input,
size_t outputSize, UA_Variant *output) {
UA_String *inputStr = (UA_String*)input->data;
@@ -38,7 +39,8 @@ helloWorldMethod(void *handle, const UA_NodeId objectId,

/* Example 2 */
static UA_StatusCode
IncInt32ArrayValuesMethod(void *handle, const UA_NodeId objectId,
IncInt32ArrayValuesMethod(void *handle, const UA_NodeId *objectId,
const UA_NodeId *sessionId, void *sessionHandle,
size_t inputSize, const UA_Variant *input,
size_t outputSize, UA_Variant *output) {
UA_Variant_setArrayCopy(output, input->data, 5, &UA_TYPES[UA_TYPES_INT32]);
@@ -50,7 +52,8 @@ IncInt32ArrayValuesMethod(void *handle, const UA_NodeId objectId,

/* Example 3 */
static UA_StatusCode
fooBarMethod(void *handle, const UA_NodeId objectId,
fooBarMethod(void *handle, const UA_NodeId *objectId,
const UA_NodeId *sessionId, void *sessionHandle,
size_t inputSize, const UA_Variant *input,
size_t outputSize, UA_Variant *output) {
/* the same as helloWorld, but returns foobar */

Opc Scout V10 Port No

@@ -80,6 +80,45 @@ struct UA_ServerNetworkLayer {
void (*deleteMembers)(UA_ServerNetworkLayer *nl);
};

/**
* Access Control
* --------------
* The access control callback is used to authenticate sessions and grant access
* rights accordingly. */
typedefstruct {
UA_Boolean enableAnonymousLogin;
UA_Boolean enableUsernamePasswordLogin;

/* Authenticate a session */
UA_StatusCode (*activateSession)(const UA_NodeId *sessionId,
const UA_ExtensionObject *userIdentityToken,
void **sessionHandle);

/* Deauthenticate a session and cleanup */
void (*closeSession)(const UA_NodeId *sessionId, void *sessionHandle);

/* Access control for all nodes*/
UA_UInt32 (*getUserRightsMask)(const UA_NodeId *sessionId, void *sessionHandle, const UA_NodeId *nodeId);

/* Additional access control for variable nodes */
UA_Byte (*getUserAccessLevel)(const UA_NodeId *sessionId, void *sessionHandle, const UA_NodeId *nodeId);

/* Additional access control for method nodes */
UA_Boolean (*getUserExecutable)(const UA_NodeId *sessionId, void *sessionHandle, const UA_NodeId *nodeId);

/* Allow adding a node */
UA_Boolean (*allowAddNode)(const UA_NodeId *sessionId, void *sessionHandle, const UA_AddNodesItem *item);

/* Allow adding a reference */
UA_Boolean (*allowAddReference)(const UA_NodeId *sessionId, void *sessionHandle, const UA_AddReferencesItem *item);

/* Allow deleting a node */
UA_Boolean (*allowDeleteNode)(const UA_NodeId *sessionId, void *sessionHandle, const UA_DeleteNodesItem *item);

/* Allow deleting a reference */
UA_Boolean (*allowDeleteReference)(const UA_NodeId *sessionId, void *sessionHandle, const UA_DeleteReferencesItem *item);
} UA_AccessControl;

/**
* Server Configuration
* --------------------
@@ -112,11 +151,8 @@ typedef struct {
size_t networkLayersSize;
UA_ServerNetworkLayer *networkLayers;

/* Login */
UA_Boolean enableAnonymousLogin;
UA_Boolean enableUsernamePasswordLogin;
size_t usernamePasswordLoginsSize;
UA_UsernamePasswordLogin* usernamePasswordLogins;
/* Access Control */
UA_AccessControl accessControl;

/* Limits for SecureChannels */
UA_UInt16 maxSecureChannels;
@@ -686,7 +722,8 @@ UA_Server_setObjectTypeNode_lifecycleManagement(UA_Server *server,
* Method Callbacks
* ~~~~~~~~~~~~~~~~ */
typedef UA_StatusCode
(*UA_MethodCallback)(void *methodHandle, const UA_NodeId objectId,
(*UA_MethodCallback)(void *methodHandle, const UA_NodeId *objectId,
const UA_NodeId *sessionId, void *sessionHandle,
size_t inputSize, const UA_Variant *input,
size_t outputSize, UA_Variant *output);

Siemens Opc Scout V10 Firefox Updates
@@ -0,0 +1,108 @@
/* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
* See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */

#include'ua_accesscontrol_default.h'

/* We allow login anonymous and with the following username / password. The
* access rights are maximally permissive in this example plugin. */

#defineANONYMOUS_POLICY'open62541-anonymous-policy'
#defineUSERNAME_POLICY'open62541-username-policy'

#defineUA_STRING_STATIC(s) {sizeof(s)-1, (UA_Byte*)s}
const UA_String ap = UA_STRING_STATIC(ANONYMOUS_POLICY);
const UA_String up = UA_STRING_STATIC(USERNAME_POLICY);

UA_StatusCode
activateSession_default(const UA_NodeId *sessionId, const UA_ExtensionObject *userIdentityToken,
void **sessionHandle) {
/* Could the token be decoded? */
if(userIdentityToken->encoding < UA_EXTENSIONOBJECT_DECODED)
return UA_STATUSCODE_BADIDENTITYTOKENINVALID;

/* anonymous login */
if(enableAnonymousLogin &&
userIdentityToken->content.decoded.type &UA_TYPES[UA_TYPES_ANONYMOUSIDENTITYTOKEN]) {
const UA_AnonymousIdentityToken *token = userIdentityToken->content.decoded.data;

/* Compatibility notice: Siemens OPC Scout v10 provides an empty
* policyId. This is not compliant. For compatibility we will assume
* that empty policyId ANONYMOUS_POLICY */
if(token->policyId.data && !UA_String_equal(&token->policyId, &ap))
return UA_STATUSCODE_BADIDENTITYTOKENINVALID;

*sessionHandle = NULL;
return UA_STATUSCODE_GOOD;
}

/* username and password */
if(enableUsernamePasswordLogin &&
userIdentityToken->content.decoded.type &UA_TYPES[UA_TYPES_USERNAMEIDENTITYTOKEN]) {
const UA_UserNameIdentityToken *token = userIdentityToken->content.decoded.data;
if(!UA_String_equal(&token->policyId, &up))
return UA_STATUSCODE_BADIDENTITYTOKENINVALID;

/* empty username and password */
if(token->userName.length0 && token->password.length0)
return UA_STATUSCODE_BADIDENTITYTOKENINVALID;

/* trying to match pw/username */
UA_Boolean match = false;
for(size_t i = 0; i < usernamePasswordsSize; i++) {
const UA_String *user = &usernamePasswords[i].username;
const UA_String *pw = &usernamePasswords[i].password;
if(UA_String_equal(&token->userName, user) && UA_String_equal(&token->password, pw)) {
match = true;
break;
}
}
if(!match)
return UA_STATUSCODE_BADUSERACCESSDENIED;

*sessionHandle = NULL;
return UA_STATUSCODE_GOOD;
}

/* Unsupported token type */
return UA_STATUSCODE_BADIDENTITYTOKENINVALID;
}

void
closeSession_default(const UA_NodeId *sessionId, void *sessionHandle) {
/* no handle to clean up */
}

UA_UInt32
getUserRightsMask_default(const UA_NodeId *sessionId, void *sessionHandle, const UA_NodeId *nodeId) {
return0xFFFFFFFF;
}

UA_Byte
getUserAccessLevel_default(const UA_NodeId *sessionId, void *sessionHandle, const UA_NodeId *nodeId) {
return0xFF;
}

UA_Boolean
getUserExecutable_default(const UA_NodeId *sessionId, void *sessionHandle, const UA_NodeId *nodeId) {
returntrue;
}

UA_Boolean
allowAddNode_default(const UA_NodeId *sessionId, void *sessionHandle, const UA_AddNodesItem *item) {
returntrue;
}

UA_Boolean
allowAddReference_default(const UA_NodeId *sessionId, void *sessionHandle, const UA_AddReferencesItem *item) {
returntrue;
}

UA_Boolean
allowDeleteNode_default(const UA_NodeId *sessionId, void *sessionHandle, const UA_DeleteNodesItem *item) {
returntrue;
}

UA_Boolean
allowDeleteReference_default(const UA_NodeId *sessionId, void *sessionHandle, const UA_DeleteReferencesItem *item) {
returntrue;
}
@@ -0,0 +1,49 @@
/* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
* See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */

#ifndef UA_ACCESSCONTROL_DEFAULT_H_
#defineUA_ACCESSCONTROL_DEFAULT_H_

#include'ua_server.h'

#ifdef __cplusplus
extern'C' {
#endif

externconst UA_Boolean enableAnonymousLogin;
externconst UA_Boolean enableUsernamePasswordLogin;
externconstsize_t usernamePasswordsSize;
externconst UA_UsernamePasswordLogin *usernamePasswords;

UA_EXPORT UA_StatusCode
activateSession_default(const UA_NodeId *sessionId, const UA_ExtensionObject *userIdentityToken, void **sessionHandle);

UA_EXPORT void
closeSession_default(const UA_NodeId *sessionId, void *sessionHandle);

UA_EXPORT UA_UInt32
getUserRightsMask_default(const UA_NodeId *sessionId, void *sessionHandle, const UA_NodeId *nodeId);

UA_EXPORT UA_Byte
getUserAccessLevel_default(const UA_NodeId *sessionId, void *sessionHandle, const UA_NodeId *nodeId);

UA_EXPORT UA_Boolean
getUserExecutable_default(const UA_NodeId *sessionId, void *sessionHandle, const UA_NodeId *nodeId);

UA_EXPORT UA_Boolean
allowAddNode_default(const UA_NodeId *sessionId, void *sessionHandle, const UA_AddNodesItem *item);

UA_EXPORT UA_Boolean
allowAddReference_default(const UA_NodeId *sessionId, void *sessionHandle, const UA_AddReferencesItem *item);

UA_EXPORT UA_Boolean
allowDeleteNode_default(const UA_NodeId *sessionId, void *sessionHandle, const UA_DeleteNodesItem *item);

UA_EXPORT UA_Boolean
allowDeleteReference_default(const UA_NodeId *sessionId, void *sessionHandle, const UA_DeleteReferencesItem *item);

#ifdef __cplusplus
}
#endif

#endif /* UA_ACCESSCONTROL_DEFAULT_H_ */
@@ -4,6 +4,7 @@
#include'ua_config_standard.h'
#include'ua_log_stdout.h'
#include'ua_network_tcp.h'
#include'ua_accesscontrol_default.h'

/*******************************/
/* Default Connection Settings */
@@ -30,7 +31,13 @@ const UA_EXPORT UA_ConnectionConfig UA_ConnectionConfig_standard = {
#defineUA_STRING_STATIC(s) {sizeof(s)-1, (UA_Byte*)s}
#defineUA_STRING_STATIC_NULL {0, NULL}

UA_UsernamePasswordLogin usernamePasswords[2] = {
/* Access Control */
#defineENABLEANONYMOUSLOGINtrue
#defineENABLEUSERNAMEPASSWORDLOGINtrue
const UA_Boolean enableAnonymousLogin = ENABLEANONYMOUSLOGIN;
const UA_Boolean enableUsernamePasswordLogin = ENABLEUSERNAMEPASSWORDLOGIN;
constsize_t usernamePasswordsSize = 2;
const UA_UsernamePasswordLogin *usernamePasswords = (UA_UsernamePasswordLogin[2]){
{ UA_STRING_STATIC('user1'), UA_STRING_STATIC('password') },
{ UA_STRING_STATIC('user2'), UA_STRING_STATIC('password1') } };

@@ -62,11 +69,20 @@ const UA_EXPORT UA_ServerConfig UA_ServerConfig_standard = {
.networkLayersSize = 0,
.networkLayers = NULL,

/* Login */
.enableAnonymousLogin = true,
.enableUsernamePasswordLogin = true,
.usernamePasswordLogins = usernamePasswords,
.usernamePasswordLoginsSize = 2,
/* Access Control */
.accessControl = (UA_AccessControl) {
.enableAnonymousLogin = ENABLEANONYMOUSLOGIN,
.enableUsernamePasswordLogin = ENABLEUSERNAMEPASSWORDLOGIN,
.activateSession = activateSession_default,
.closeSession = closeSession_default,
.getUserRightsMask = getUserRightsMask_default,
.getUserAccessLevel = getUserAccessLevel_default,
.getUserExecutable = getUserExecutable_default,
.allowAddNode = allowAddNode_default,
.allowAddReference = allowAddReference_default,
.allowDeleteNode = allowDeleteNode_default,
.allowDeleteReference = allowDeleteReference_default
},

/* Limits for SecureChannels */
.maxSecureChannels = 40,
@@ -419,8 +419,10 @@ createVariableTypeNode(UA_Server *server, char* name, UA_UInt32 variabletypeid,

#if defined(UA_ENABLE_METHODCALLS) && defined(UA_ENABLE_SUBSCRIPTIONS)
static UA_StatusCode
GetMonitoredItems(void *handle, const UA_NodeId objectId, size_t inputSize,
const UA_Variant *input, size_t outputSize, UA_Variant *output) {
GetMonitoredItems(void *handle, const UA_NodeId *objectId,
const UA_NodeId *sessionId, void *sessionHandle,
size_t inputSize, const UA_Variant *input,
size_t outputSize, UA_Variant *output) {
UA_UInt32 subscriptionId = *((UA_UInt32*)(input[0].data));
UA_Session* session = methodCallSession;
UA_Subscription* subscription = UA_Session_getSubscriptionByID(session, subscriptionId);
@@ -488,21 +490,21 @@ UA_Server * UA_Server_new(const UA_ServerConfig config) {
UA_STRING_ALLOC('http://opcfoundation.org/UA-Profile/Transport/uatcp-uasc-uabinary');

size_t policies = 0;
if(server->config.enableAnonymousLogin)
if(server->config.accessControl.enableAnonymousLogin)
policies++;
if(server->config.enableUsernamePasswordLogin)
if(server->config.accessControl.enableUsernamePasswordLogin)
policies++;
endpoint->userIdentityTokensSize = policies;
endpoint->userIdentityTokens = UA_Array_new(policies, &UA_TYPES[UA_TYPES_USERTOKENPOLICY]);

size_t currentIndex = 0;
if(server->config.enableAnonymousLogin) {
if(server->config.accessControl.enableAnonymousLogin) {
UA_UserTokenPolicy_init(&endpoint->userIdentityTokens[currentIndex]);
endpoint->userIdentityTokens[currentIndex].tokenType = UA_USERTOKENTYPE_ANONYMOUS;
endpoint->userIdentityTokens[currentIndex].policyId = UA_STRING_ALLOC(ANONYMOUS_POLICY);
currentIndex++;
}
if(server->config.enableUsernamePasswordLogin) {
if(server->config.accessControl.enableUsernamePasswordLogin) {
UA_UserTokenPolicy_init(&endpoint->userIdentityTokens[currentIndex]);
endpoint->userIdentityTokens[currentIndex].tokenType = UA_USERTOKENTYPE_USERNAME;
endpoint->userIdentityTokens[currentIndex].policyId = UA_STRING_ALLOC(USERNAME_POLICY);

Siemens Opc Scout V10 Firefox Updates Update

ProTip! Use n and p to navigate between commits in a pull request.

Siemens Opc Server

Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.