ua_services_discovery.c 2.2 KB

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