server_config_default.h 4.3 KB

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