ua_config_default.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  2. * See http://creativecommons.org/publicdomain/zero/1.0/ for more information.
  3. *
  4. * Copyright 2017 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
  5. * Copyright 2017 (c) Stefan Profanter, fortiss GmbH
  6. * Copyright 2018 (c) Mark Giraud, Fraunhofer IOSB
  7. */
  8. #ifndef UA_CONFIG_DEFAULT_H_
  9. #define UA_CONFIG_DEFAULT_H_
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. #include "ua_server.h"
  14. #include "ua_server_config.h"
  15. #include "ua_client.h"
  16. /**********************/
  17. /* Default Connection */
  18. /**********************/
  19. extern const UA_EXPORT UA_ConnectionConfig UA_ConnectionConfig_default;
  20. /*************************/
  21. /* Default Server Config */
  22. /*************************/
  23. /* Creates a new server config with one endpoint.
  24. *
  25. * The config will set the tcp network layer to the given port and adds a single
  26. * endpoint with the security policy ``SecurityPolicy#None`` to the server. A
  27. * server certificate may be supplied but is optional.
  28. *
  29. * @param portNumber The port number for the tcp network layer
  30. * @param certificate Optional certificate for the server endpoint. Can be
  31. * ``NULL``. */
  32. UA_EXPORT UA_ServerConfig *
  33. UA_ServerConfig_new_minimal(UA_UInt16 portNumber, const UA_ByteString *certificate);
  34. #ifdef UA_ENABLE_ENCRYPTION
  35. UA_EXPORT UA_ServerConfig *
  36. UA_ServerConfig_new_basic128rsa15(UA_UInt16 portNumber,
  37. const UA_ByteString *certificate,
  38. const UA_ByteString *privateKey,
  39. const UA_ByteString *trustList,
  40. size_t trustListSize,
  41. const UA_ByteString *revocationList,
  42. size_t revocationListSize);
  43. UA_EXPORT UA_ServerConfig *
  44. UA_ServerConfig_new_basic256sha256(UA_UInt16 portNumber,
  45. const UA_ByteString *certificate,
  46. const UA_ByteString *privateKey,
  47. const UA_ByteString *trustList,
  48. size_t trustListSize,
  49. const UA_ByteString *revocationList,
  50. size_t revocationListSize);
  51. UA_EXPORT UA_ServerConfig *
  52. UA_ServerConfig_new_allSecurityPolicies(UA_UInt16 portNumber,
  53. const UA_ByteString *certificate,
  54. const UA_ByteString *privateKey,
  55. const UA_ByteString *trustList,
  56. size_t trustListSize,
  57. const UA_ByteString *revocationList,
  58. size_t revocationListSize);
  59. #endif
  60. /* Creates a server config on the default port 4840 with no server
  61. * certificate. */
  62. static UA_INLINE UA_ServerConfig *
  63. UA_ServerConfig_new_default(void) {
  64. return UA_ServerConfig_new_minimal(4840, NULL);
  65. }
  66. /* Set a custom hostname in server configuration
  67. *
  68. * @param config A valid server configuration
  69. * @param customHostname The custom hostname used by the server */
  70. UA_EXPORT void
  71. UA_ServerConfig_set_customHostname(UA_ServerConfig *config,
  72. const UA_String customHostname);
  73. /* Frees allocated memory in the server config */
  74. UA_EXPORT void
  75. UA_ServerConfig_delete(UA_ServerConfig *config);
  76. /*************************/
  77. /* Default Client Config */
  78. /*************************/
  79. extern const UA_EXPORT UA_ClientConfig UA_ClientConfig_default;
  80. #ifdef __cplusplus
  81. }
  82. #endif
  83. #endif /* UA_CONFIG_DEFAULT_H_ */