ua_services_discovery.c 2.3 KB

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