ua_config_default.h 4.5 KB

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