ua_services_discovery.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "ua_services.h"
  2. UA_Int32 Service_GetEndpoints(SL_Channel channel, const UA_GetEndpointsRequest* request, UA_GetEndpointsResponse *response) {
  3. #ifdef DEBUG
  4. UA_String_printx("endpointUrl=", &request->endpointUrl);
  5. #endif
  6. response->endpointsSize = 1;
  7. UA_Array_new((void**) &response->endpoints,response->endpointsSize,&UA_.types[UA_ENDPOINTDESCRIPTION]);
  8. //Security issues:
  9. //The policy should be 'http://opcfoundation.org/UA/SecurityPolicy#None'
  10. //FIXME String or ByteString
  11. UA_AsymmetricAlgorithmSecurityHeader *asymSettings;
  12. SL_Channel_getLocalAsymAlgSettings(channel, &asymSettings);
  13. UA_String_copy((UA_String *)&(asymSettings->securityPolicyUri), &response->endpoints[0].securityPolicyUri);
  14. //FIXME hard-coded code
  15. response->endpoints[0].securityMode = UA_MESSAGESECURITYMODE_NONE;
  16. UA_String_copycstring("http://opcfoundation.org/UA-Profile/Transport/uatcp-uasc-uabinary", &response->endpoints[0].transportProfileUri);
  17. response->endpoints[0].userIdentityTokensSize = 1;
  18. UA_Array_new((void**) &response->endpoints[0].userIdentityTokens, response->endpoints[0].userIdentityTokensSize,
  19. &UA_.types[UA_USERTOKENPOLICY]);
  20. UA_UserTokenPolicy *token = &response->endpoints[0].userIdentityTokens[0];
  21. UA_String_copycstring("my-anonymous-policy", &token->policyId); // defined per server
  22. token->tokenType = UA_USERTOKENTYPE_ANONYMOUS;
  23. token->issuerEndpointUrl = (UA_String) {-1, UA_NULL};
  24. token->issuedTokenType = (UA_String) {-1, UA_NULL};
  25. token->securityPolicyUri = (UA_String) {-1, UA_NULL};
  26. UA_String_copy(&request->endpointUrl,&response->endpoints[0].endpointUrl);
  27. UA_String_copycstring("http://open62541.info/product/release",&(response->endpoints[0].server.productUri));
  28. // FIXME: This information should be provided by the application, preferably in the address space
  29. UA_String_copycstring("http://open62541.info/applications/4711",&(response->endpoints[0].server.applicationUri));
  30. UA_LocalizedText_copycstring("The open62541 application",&(response->endpoints[0].server.applicationName));
  31. // FIXME: This should be a feature of the application and an enum
  32. response->endpoints[0].server.applicationType = UA_APPLICATIONTYPE_SERVER;
  33. // all the other strings are empty by initialization
  34. return UA_SUCCESS;
  35. }