ua_services_discovery.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include "ua_services.h"
  2. UA_Int32 Service_GetEndpoints(UA_Server *server,
  3. const UA_GetEndpointsRequest *request,
  4. UA_GetEndpointsResponse *response) {
  5. UA_GetEndpointsResponse_init(response);
  6. response->endpointsSize = 1;
  7. UA_Array_new((void **)&response->endpoints, response->endpointsSize, &UA_.types[UA_ENDPOINTDESCRIPTION]);
  8. // security policy
  9. response->endpoints[0].securityMode = UA_MESSAGESECURITYMODE_NONE;
  10. UA_String_copycstring("http://opcfoundation.org/UA/SecurityPolicy#None",
  11. &response->endpoints[0].securityPolicyUri);
  12. UA_String_copycstring("http://opcfoundation.org/UA-Profile/Transport/uatcp-uasc-uabinary",
  13. &response->endpoints[0].transportProfileUri);
  14. // usertoken policy
  15. response->endpoints[0].userIdentityTokensSize = 1;
  16. UA_Array_new((void **)&response->endpoints[0].userIdentityTokens,
  17. response->endpoints[0].userIdentityTokensSize, &UA_.types[UA_USERTOKENPOLICY]);
  18. UA_UserTokenPolicy *token = &response->endpoints[0].userIdentityTokens[0];
  19. UA_UserTokenPolicy_init(token);
  20. UA_String_copycstring("my-anonymous-policy", &token->policyId); // defined per server
  21. token->tokenType = UA_USERTOKENTYPE_ANONYMOUS;
  22. // server description
  23. UA_String_copy(&request->endpointUrl, &response->endpoints[0].endpointUrl);
  24. /* The standard says "the HostName specified in the Server Certificate is the
  25. same as the HostName contained in the endpointUrl provided in the
  26. EndpointDescription */
  27. UA_String_copy(&server->serverCertificate, &response->endpoints[0].serverCertificate);
  28. UA_String_copycstring("http://open62541.info/product/release", &(response->endpoints[0].server.productUri));
  29. // FIXME: This information should be provided by the application, preferably in the address space
  30. UA_String_copycstring("http://open62541.info/applications/4711",
  31. &(response->endpoints[0].server.applicationUri));
  32. UA_LocalizedText_copycstring("The open62541 application", &(response->endpoints[0].server.applicationName));
  33. // FIXME: This should be a feature of the application and an enum
  34. response->endpoints[0].server.applicationType = UA_APPLICATIONTYPE_SERVER;
  35. return UA_SUCCESS;
  36. }