ua_config_default.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. #include "ua_server.h"
  11. #include "ua_server_config.h"
  12. #include "ua_client.h"
  13. _UA_BEGIN_DECLS
  14. /**********************/
  15. /* Default Connection */
  16. /**********************/
  17. extern const UA_EXPORT UA_ConnectionConfig UA_ConnectionConfig_default;
  18. /*************************/
  19. /* Default Server Config */
  20. /*************************/
  21. /* Creates a new server config with one endpoint and custom buffer size.
  22. *
  23. * The config will set the tcp network layer to the given port and adds a single
  24. * endpoint with the security policy ``SecurityPolicy#None`` to the server. A
  25. * server certificate may be supplied but is optional.
  26. * Additionally you can define a custom buffer size for send and receive buffer.
  27. *
  28. * @param portNumber The port number for the tcp network layer
  29. * @param certificate Optional certificate for the server endpoint. Can be
  30. * ``NULL``.
  31. * @param sendBufferSize The size in bytes for the network send buffer
  32. * @param recvBufferSize The size in bytes for the network receive buffer
  33. *
  34. */
  35. UA_EXPORT UA_ServerConfig *
  36. UA_ServerConfig_new_customBuffer(UA_UInt16 portNumber, const UA_ByteString *certificate,
  37. UA_UInt32 sendBufferSize, UA_UInt32 recvBufferSize);
  38. /* Creates a new server config with one endpoint.
  39. *
  40. * The config will set the tcp network layer to the given port and adds a single
  41. * endpoint with the security policy ``SecurityPolicy#None`` to the server. A
  42. * server certificate may be supplied but is optional.
  43. *
  44. * @param portNumber The port number for the tcp network layer
  45. * @param certificate Optional certificate for the server endpoint. Can be
  46. * ``NULL``. */
  47. static UA_INLINE UA_ServerConfig *
  48. UA_ServerConfig_new_minimal(UA_UInt16 portNumber, const UA_ByteString *certificate) {
  49. return UA_ServerConfig_new_customBuffer(portNumber, certificate, 0 ,0);
  50. }
  51. #ifdef UA_ENABLE_ENCRYPTION
  52. UA_EXPORT UA_ServerConfig *
  53. UA_ServerConfig_new_basic128rsa15(UA_UInt16 portNumber,
  54. const UA_ByteString *certificate,
  55. const UA_ByteString *privateKey,
  56. const UA_ByteString *trustList,
  57. size_t trustListSize,
  58. const UA_ByteString *revocationList,
  59. size_t revocationListSize);
  60. UA_EXPORT UA_ServerConfig *
  61. UA_ServerConfig_new_basic256sha256(UA_UInt16 portNumber,
  62. const UA_ByteString *certificate,
  63. const UA_ByteString *privateKey,
  64. const UA_ByteString *trustList,
  65. size_t trustListSize,
  66. const UA_ByteString *revocationList,
  67. size_t revocationListSize);
  68. UA_EXPORT UA_ServerConfig *
  69. UA_ServerConfig_new_allSecurityPolicies(UA_UInt16 portNumber,
  70. const UA_ByteString *certificate,
  71. const UA_ByteString *privateKey,
  72. const UA_ByteString *trustList,
  73. size_t trustListSize,
  74. const UA_ByteString *revocationList,
  75. size_t revocationListSize);
  76. #endif
  77. /* Creates a server config on the default port 4840 with no server
  78. * certificate. */
  79. static UA_INLINE UA_ServerConfig *
  80. UA_ServerConfig_new_default(void) {
  81. return UA_ServerConfig_new_minimal(4840, NULL);
  82. }
  83. /* Set a custom hostname in server configuration
  84. *
  85. * @param config A valid server configuration
  86. * @param customHostname The custom hostname used by the server */
  87. UA_EXPORT void
  88. UA_ServerConfig_set_customHostname(UA_ServerConfig *config,
  89. const UA_String customHostname);
  90. /* Frees allocated memory in the server config */
  91. UA_EXPORT void
  92. UA_ServerConfig_delete(UA_ServerConfig *config);
  93. /*************************/
  94. /* Default Client Config */
  95. /*************************/
  96. UA_StatusCode UA_EXPORT
  97. UA_ClientConfig_setDefault(UA_ClientConfig *config);
  98. #ifdef UA_ENABLE_ENCRYPTION
  99. UA_StatusCode UA_EXPORT
  100. UA_ClientConfig_setDefaultEncryption(UA_ClientConfig *config,
  101. UA_ByteString localCertificate, UA_ByteString privateKey,
  102. const UA_ByteString *trustList, size_t trustListSize,
  103. const UA_ByteString *revocationList, size_t revocationListSize);
  104. #endif
  105. _UA_END_DECLS
  106. #endif /* UA_CONFIG_DEFAULT_H_ */