server_config_default.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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
  16. UA_ConnectionConfig UA_ConnectionConfig_default;
  17. /*************************/
  18. /* Default Server Config */
  19. /*************************/
  20. /* Creates a new server config with one endpoint and custom buffer size.
  21. *
  22. * The config will set the tcp network layer to the given port and adds a single
  23. * endpoint with the security policy ``SecurityPolicy#None`` to the server. A
  24. * server certificate may be supplied but is optional.
  25. * Additionally you can define a custom buffer size for send and receive buffer.
  26. *
  27. * @param portNumber The port number for the tcp network layer
  28. * @param certificate Optional certificate for the server endpoint. Can be
  29. * ``NULL``.
  30. * @param sendBufferSize The size in bytes for the network send buffer
  31. * @param recvBufferSize The size in bytes for the network receive buffer
  32. *
  33. */
  34. UA_EXPORT UA_StatusCode
  35. UA_ServerConfig_setMinimalCustomBuffer(UA_ServerConfig *config,
  36. UA_UInt16 portNumber,
  37. const UA_ByteString *certificate,
  38. UA_UInt32 sendBufferSize,
  39. UA_UInt32 recvBufferSize);
  40. /* Creates a new server config with one endpoint.
  41. *
  42. * The config will set the tcp network layer to the given port and adds a single
  43. * endpoint with the security policy ``SecurityPolicy#None`` to the server. A
  44. * server certificate may be supplied but is optional. */
  45. static UA_INLINE UA_StatusCode
  46. UA_ServerConfig_setMinimal(UA_ServerConfig *config, UA_UInt16 portNumber,
  47. const UA_ByteString *certificate) {
  48. return UA_ServerConfig_setMinimalCustomBuffer(config, portNumber,
  49. certificate, 0, 0);
  50. }
  51. #ifdef UA_ENABLE_ENCRYPTION
  52. UA_EXPORT UA_StatusCode
  53. UA_ServerConfig_setDefaultWithSecurityPolicies(UA_ServerConfig *conf,
  54. 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. #endif
  62. /* Creates a server config on the default port 4840 with no server
  63. * certificate. */
  64. static UA_INLINE UA_StatusCode
  65. UA_ServerConfig_setDefault(UA_ServerConfig *config) {
  66. return UA_ServerConfig_setMinimal(config, 4840, NULL);
  67. }
  68. _UA_END_DECLS
  69. #endif /* UA_SERVER_CONFIG_DEFAULT_H_ */