ua_config_default.h 4.5 KB

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