#include "lwip/ip_addr.h"
#include "lwip/inet.h"
+#include "lwip/inet6.h"
#ifdef __cplusplus
extern "C" {
#endif
+/* If your port already typedef's sa_family_t, define SA_FAMILY_T_DEFINED
+ to prevent this code from redefining it. */
+#if !defined(sa_family_t) && !defined(SA_FAMILY_T_DEFINED)
+typedef u8_t sa_family_t;
+#endif
+/* If your port already typedef's in_port_t, define IN_PORT_T_DEFINED
+ to prevent this code from redefining it. */
+#if !defined(in_port_t) && !defined(IN_PORT_T_DEFINED)
+typedef u16_t in_port_t;
+#endif
+
/* members are in network byte order */
struct sockaddr_in {
- u8_t sin_len;
- u8_t sin_family;
- u16_t sin_port;
- struct in_addr sin_addr;
- char sin_zero[8];
+ u8_t sin_len;
+ sa_family_t sin_family;
+ in_port_t sin_port;
+ struct in_addr sin_addr;
+#define SIN_ZERO_LEN 8
+ char sin_zero[SIN_ZERO_LEN];
+};
+
+#if LWIP_IPV6
+struct sockaddr_in6 {
+ u8_t sin6_len; /* length of this structure */
+ sa_family_t sin6_family; /* AF_INET6 */
+ in_port_t sin6_port; /* Transport layer port # */
+ u32_t sin6_flowinfo; /* IPv6 flow information */
+ struct in6_addr sin6_addr; /* IPv6 address */
};
+#endif /* LWIP_IPV6 */
struct sockaddr {
- u8_t sa_len;
- u8_t sa_family;
- char sa_data[14];
+ u8_t sa_len;
+ sa_family_t sa_family;
+#if LWIP_IPV6
+ char sa_data[22];
+#else /* LWIP_IPV6 */
+ char sa_data[14];
+#endif /* LWIP_IPV6 */
+};
+
+struct sockaddr_storage {
+ u8_t s2_len;
+ sa_family_t ss_family;
+ char s2_data1[2];
+ u32_t s2_data2[3];
+#if LWIP_IPV6
+ u32_t s2_data3[2];
+#endif /* LWIP_IPV6 */
};
-#ifndef socklen_t
-# define socklen_t u32_t
+/* If your port already typedef's socklen_t, define SOCKLEN_T_DEFINED
+ to prevent this code from redefining it. */
+#if !defined(socklen_t) && !defined(SOCKLEN_T_DEFINED)
+typedef u32_t socklen_t;
#endif
/* Socket protocol types (TCP/UDP/RAW) */
#define SOCK_RAW 3
/*
- * Option flags per-socket. These must match the SOF_ flags in ip.h!
+ * Option flags per-socket. These must match the SOF_ flags in ip.h (checked in init.c)
*/
#define SO_DEBUG 0x0001 /* Unimplemented: turn on debugging info recording */
#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
-#define SO_REUSEADDR 0x0004 /* Unimplemented: allow local address reuse */
+#define SO_REUSEADDR 0x0004 /* Allow local address reuse */
#define SO_KEEPALIVE 0x0008 /* keep connections alive */
#define SO_DONTROUTE 0x0010 /* Unimplemented: just use interface addresses */
#define SO_BROADCAST 0x0020 /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */
#define AF_UNSPEC 0
#define AF_INET 2
+#if LWIP_IPV6
+#define AF_INET6 10
+#else /* LWIP_IPV6 */
+#define AF_INET6 AF_UNSPEC
+#endif /* LWIP_IPV6 */
#define PF_INET AF_INET
+#define PF_INET6 AF_INET6
#define PF_UNSPEC AF_UNSPEC
#define IPPROTO_IP 0
#define IPPROTO_TCP 6
#define IPPROTO_UDP 17
+#if LWIP_IPV6
+#define IPPROTO_IPV6 41
+#endif /* LWIP_IPV6 */
#define IPPROTO_UDPLITE 136
/* Flags we can use with send and recv. */
#define TCP_KEEPCNT 0x05 /* set pcb->keep_cnt - Use number of probes sent for get/setsockopt */
#endif /* LWIP_TCP */
+#if LWIP_IPV6
+/*
+ * Options for level IPPROTO_IPV6
+ */
+#define IPV6_V6ONLY 27 /* RFC3493: boolean control to restrict AF_INET6 sockets to IPv6 communications only. */
+#endif /* LWIP_IPV6 */
+
#if LWIP_UDP && LWIP_UDPLITE
/*
* Options for level IPPROTO_UDPLITE
#define SIOCATMARK _IOR('s', 7, unsigned long) /* at oob mark? */
#endif
-/* Socket flags: */
+/* commands for fnctl */
+#ifndef F_GETFL
+#define F_GETFL 3
+#endif
+#ifndef F_SETFL
+#define F_SETFL 4
+#endif
+
+/* File status flags and file access modes for fnctl,
+ these are bits in an int. */
#ifndef O_NONBLOCK
-#define O_NONBLOCK 04000U
+#define O_NONBLOCK 1 /* nonblocking I/O */
+#endif
+#ifndef O_NDELAY
+#define O_NDELAY 1 /* same as O_NONBLOCK, for compatibility */
+#endif
+
+#ifndef SHUT_RD
+ #define SHUT_RD 0
+ #define SHUT_WR 1
+ #define SHUT_RDWR 2
#endif
/* FD_SET used for lwip_select */
int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
struct timeval *timeout);
int lwip_ioctl(int s, long cmd, void *argp);
+int lwip_fcntl(int s, int cmd, int val);
#if LWIP_COMPAT_SOCKETS
#define accept(a,b,c) lwip_accept(a,b,c)
#define read(a,b,c) lwip_read(a,b,c)
#define write(a,b,c) lwip_write(a,b,c)
#define close(s) lwip_close(s)
+#define fcntl(a,b,c) lwip_fcntl(a,b,c)
#endif /* LWIP_POSIX_SOCKETS_IO_NAMES */
#endif /* LWIP_COMPAT_SOCKETS */