lwip62541.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 2018 (c) Jose Cabral, fortiss GmbH
  5. */
  6. #ifndef ARCH_COMMON_LWIP62541_H_
  7. #define ARCH_COMMON_LWIP62541_H_
  8. #define LWIP_TIMEVAL_PRIVATE 0
  9. #define LWIP_POSIX_SOCKETS_IO_NAMES 0
  10. #ifdef LWIP_COMPAT_SOCKETS
  11. #undef LWIP_COMPAT_SOCKETS
  12. #endif
  13. #define LWIP_COMPAT_SOCKETS 0
  14. #include <lwip/tcpip.h>
  15. #include <lwip/netdb.h>
  16. #include <lwip/init.h>
  17. #include <lwip/sockets.h>
  18. #define sockaddr_storage sockaddr
  19. #define OPTVAL_TYPE int
  20. #define UA_fd_set(fd, fds) FD_SET((unsigned int)fd, fds)
  21. #define UA_fd_isset(fd, fds) FD_ISSET((unsigned int)fd, fds)
  22. #define UA_IPV6 LWIP_IPV6
  23. #define UA_SOCKET int
  24. #define UA_INVALID_SOCKET -1
  25. #define UA_ERRNO errno
  26. #define UA_INTERRUPTED EINTR
  27. #define UA_AGAIN EAGAIN
  28. #define UA_EAGAIN EAGAIN
  29. #define UA_WOULDBLOCK EWOULDBLOCK
  30. #define UA_ERR_CONNECTION_PROGRESS EINPROGRESS
  31. #define UA_send lwip_send
  32. #define UA_recv lwip_recv
  33. #define UA_sendto lwip_sendto
  34. #define UA_recvfrom lwip_recvfrom
  35. #define UA_htonl lwip_htonl
  36. #define UA_ntohl lwip_ntohl
  37. #define UA_close lwip_close
  38. #define UA_select lwip_select
  39. #define UA_shutdown lwip_shutdown
  40. #define UA_socket lwip_socket
  41. #define UA_bind lwip_bind
  42. #define UA_listen lwip_listen
  43. #define UA_accept lwip_accept
  44. #define UA_connect lwip_connect
  45. #define UA_getsockopt lwip_getsockopt
  46. #define UA_setsockopt lwip_setsockopt
  47. #define UA_freeaddrinfo lwip_freeaddrinfo
  48. #define UA_gethostname gethostname_lwip
  49. #define UA_getaddrinfo lwip_getaddrinfo
  50. #if UA_IPV6
  51. # define UA_inet_pton(af, src, dst) \
  52. (((af) == AF_INET6) ? ip6addr_aton((src),(ip6_addr_t*)(dst)) \
  53. : (((af) == AF_INET) ? ip4addr_aton((src),(ip4_addr_t*)(dst)) : 0))
  54. #else
  55. # define UA_inet_pton(af, src, dst) \
  56. (((af) == AF_INET) ? ip4addr_aton((src),(ip4_addr_t*)(dst)) : 0)
  57. #endif
  58. #if UA_IPV6
  59. # define UA_if_nametoindex lwip_if_nametoindex
  60. # if LWIP_VERSION_IS_RELEASE //lwip_if_nametoindex is not yet released
  61. unsigned int lwip_if_nametoindex(const char *ifname);
  62. # endif
  63. #endif
  64. int gethostname_lwip(char* name, size_t len);
  65. #define UA_LOG_SOCKET_ERRNO_GAI_WRAP UA_LOG_SOCKET_ERRNO_WRAP
  66. #endif /* ARCH_COMMON_LWIP62541_H_ */