open62541 1.3.12
Open source implementation of OPC UA
Loading...
Searching...
No Matches
ua_lwip.h
Go to the documentation of this file.
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
7#ifndef ARCH_COMMON_LWIP62541_H_
8#define ARCH_COMMON_LWIP62541_H_
9
10/*
11 * Needed flags to be set before including this file. Normally done in lwipopts.h
12 * #define LWIP_COMPAT_SOCKETS 0 // Don't do name define-transformation in networking function names.
13 * #define LWIP_SOCKET 1 // Enable Socket API (normally already set)
14 * #define LWIP_DNS 1 // enable the lwip_getaddrinfo function, struct addrinfo and more.
15 * #define SO_REUSE 1 // Allows to set the socket as reusable
16 * #define LWIP_TIMEVAL_PRIVATE 0 // This is optional. Set this flag if you get a compilation error about redefinition of struct timeval
17 *
18 * Why not define these here? This stack is used as middleware so other code might use this header file with other flags (specially LWIP_COMPAT_SOCKETS)
19 */
20#include <lwip/tcpip.h>
21#include <lwip/netdb.h>
22#include <lwip/init.h>
23#include <lwip/sockets.h>
24
25#define OPTVAL_TYPE int
26
27#define UA_fd_set(fd, fds) FD_SET((unsigned int)fd, fds)
28#define UA_fd_isset(fd, fds) FD_ISSET((unsigned int)fd, fds)
29
30#define UA_IPV6 LWIP_IPV6
31#define UA_SOCKET int
32#define UA_INVALID_SOCKET -1
33#define UA_ERRNO errno
34#define UA_INTERRUPTED EINTR
35#define UA_AGAIN EAGAIN
36#define UA_EAGAIN EAGAIN
37#define UA_WOULDBLOCK EWOULDBLOCK
38#define UA_ERR_CONNECTION_PROGRESS EINPROGRESS
39
40#define UA_POLLIN POLLIN
41#define UA_POLLOUT POLLOUT
42
43#define UA_poll lwip_poll
44#define UA_send lwip_send
45#define UA_recv lwip_recv
46#define UA_sendto lwip_sendto
47#define UA_recvfrom lwip_recvfrom
48#define UA_htonl lwip_htonl
49#define UA_ntohl lwip_ntohl
50#define UA_close lwip_close
51#define UA_select lwip_select
52#define UA_shutdown lwip_shutdown
53#define UA_socket lwip_socket
54#define UA_bind lwip_bind
55#define UA_listen lwip_listen
56#define UA_accept lwip_accept
57#define UA_connect lwip_connect
58#define UA_getsockopt lwip_getsockopt
59#define UA_setsockopt lwip_setsockopt
60#define UA_freeaddrinfo lwip_freeaddrinfo
61#ifndef UA_gethostname
62#define UA_gethostname gethostname_lwip
63#else
64extern int UA_gethostname(char* name, size_t len);
65#endif
66#ifndef UA_getsockname
67#define UA_getsockname lwip_getsockname
68#else
69extern int UA_getsockname((int s, struct sockaddr *name, socklen_t *namelen);
70#endif
71#ifndef UA_getaddrinfo
72#define UA_getaddrinfo lwip_getaddrinfo
73#else
74extern int UA_getaddrinfo(const char *nodename, const char *servname,
75 const struct addrinfo *hints, struct addrinfo **res);
76#endif
77
78#if UA_IPV6
79# define UA_inet_pton(af, src, dst) \
80 (((af) == AF_INET6) ? ip6addr_aton((src),(ip6_addr_t*)(dst)) \
81 : (((af) == AF_INET) ? ip4addr_aton((src),(ip4_addr_t*)(dst)) : 0))
82#else
83# define UA_inet_pton(af, src, dst) \
84 (((af) == AF_INET) ? ip4addr_aton((src),(ip4_addr_t*)(dst)) : 0)
85#endif
86
87#if UA_IPV6
88# define UA_if_nametoindex lwip_if_nametoindex
89
90# if LWIP_VERSION_IS_RELEASE //lwip_if_nametoindex is not yet released
91unsigned int lwip_if_nametoindex(const char *ifname);
92# endif
93#endif
94
95int gethostname_lwip(char* name, size_t len);
96
97#define UA_LOG_SOCKET_ERRNO_GAI_WRAP UA_LOG_SOCKET_ERRNO_WRAP
98
99#endif /* ARCH_COMMON_LWIP62541_H_ */
#define UA_gethostname
Definition ua_lwip.h:62
#define UA_getsockname
Definition ua_lwip.h:67
#define UA_getaddrinfo
Definition ua_lwip.h:72
int gethostname_lwip(char *name, size_t len)