opt.h, sockets.h: add new configuration options (LWIP_POSIX_SOCKETS_IO_NAMES, ETHARP_TRUST_IP_MAC, review SO_REUSE).

Also include directly tcp.h in sockets.h to improve application independancy from ip stack (avoid to include directly in application the "unknown" tcp.h if you need options like TCP_NODELAY and TCP_KEEPALIVE in application.
This commit is contained in:
fbernon 2007-03-05 14:43:11 +00:00
parent 7b54ddd828
commit ddf0982d0f
3 changed files with 59 additions and 29 deletions

View File

@ -42,6 +42,9 @@ HISTORY
++ Bug fixes:
2007-03-05 Frédéric Bernon
* opt.h, sockets.h: add new configuration options (LWIP_POSIX_SOCKETS_IO_NAMES, ETHARP_TRUST_IP_MAC, review SO_REUSE)
2007-03-04 Frédéric Bernon
* api_msg.c: Remove some compiler warnings : parameter "pcb" was never referenced.

View File

@ -187,6 +187,19 @@ a lot of data that needs to be copied, this should be set high. */
#define ARP_QUEUEING 1
#endif
/* If enabled, incoming IP packets cause the ARP table to be updated
* with the source MAC and IP addresses supplied in the packet. You may
* want to disable this if you do not trust LAN peers to have the
* correct addresses, or as a limited approach to attempt to handle
* spoofing. If disabled, lwIP will need to make a new ARP request if
* the peer is not already in the ARP table, adding a little latency.
*/
#ifndef ETHARP_TRUST_IP_MAC
#define ETHARP_TRUST_IP_MAC 1
#endif
/* This option is deprecated */
#ifdef ETHARP_QUEUE_FIRST
#error ETHARP_QUEUE_FIRST option is deprecated. Remove it from your lwipopts.h.
@ -316,15 +329,16 @@ a lot of data that needs to be copied, this should be set high. */
#define TCP_WND 2048
#endif
/* Maximum number of retransmissions of data segments. */
#ifndef TCP_MAXRTX
#define TCP_MAXRTX 12
#endif
/* Maximum number of retransmissions of SYN segments. */
#ifndef TCP_SYNMAXRTX
#define TCP_SYNMAXRTX 6
#endif
/* Controls if TCP should queue segments that arrive out of
order. Define to 0 if your device is low on memory. */
#ifndef TCP_QUEUE_OOSEQ
@ -347,11 +361,6 @@ a lot of data that needs to be copied, this should be set high. */
#define TCP_SND_QUEUELEN 4 * TCP_SND_BUF/TCP_MSS
#endif
/* Maximum number of retransmissions of data segments. */
/* Maximum number of retransmissions of SYN segments. */
/* TCP writable space (bytes). This must be less than or equal
to TCP_SND_BUF. It is the amount of space which must be
available in the tcp snd_buf for select to return writable */
@ -372,11 +381,6 @@ a lot of data that needs to be copied, this should be set high. */
#define LWIP_CALLBACK_API 0
#endif
#ifndef LWIP_COMPAT_SOCKETS
#define LWIP_COMPAT_SOCKETS 1
#endif
#ifndef TCPIP_THREAD_PRIO
#define TCPIP_THREAD_PRIO 1
#endif
@ -395,8 +399,23 @@ a lot of data that needs to be copied, this should be set high. */
/* ---------- Socket Options ---------- */
/* Enable BSD-style sockets functions names */
#ifndef LWIP_COMPAT_SOCKETS
#define LWIP_COMPAT_SOCKETS 1
#endif
/* Enable POSIX-style sockets functions names
Disable it if you use a POSIX operating system using same names (read, write & close) */
#ifndef LWIP_POSIX_SOCKETS_IO_NAMES
#define LWIP_POSIX_SOCKETS_IO_NAMES 1
#endif
/* Enable SO_REUSEADDR and SO_REUSEPORT options */
#ifdef SO_REUSE
#ifndef SO_REUSE
#define SO_REUSE 0
#endif
#if SO_REUSE
/* I removed the lot since this was an ugly hack. It broke the raw-API.
It also came with many ugly goto's, Christiaan Simons. */
#error "SO_REUSE currently unavailable, this was a hack"

View File

@ -34,6 +34,8 @@
#ifndef __LWIP_SOCKETS_H__
#define __LWIP_SOCKETS_H__
#include "lwip/ip_addr.h"
#include "opt.h"
#include "tcp.h"
struct sockaddr_in {
u8_t sin_len;
@ -61,30 +63,30 @@ struct sockaddr {
/*
* Option flags per-socket.
*/
#define SO_DEBUG 0x0001 /* turn on debugging info recording */
#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
#define SO_REUSEADDR 0x0004 /* allow local address reuse */
#define SO_KEEPALIVE 0x0008 /* keep connections alive */
#define SO_DONTROUTE 0x0010 /* just use interface addresses */
#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
#define SO_LINGER 0x0080 /* linger on close if data present */
#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
#define SO_REUSEPORT 0x0200 /* allow local address & port reuse */
#define SO_DEBUG 0x0001 /* turn on debugging info recording */
#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
#define SO_REUSEADDR 0x0004 /* allow local address reuse */
#define SO_KEEPALIVE 0x0008 /* keep connections alive */
#define SO_DONTROUTE 0x0010 /* just use interface addresses */
#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
#define SO_LINGER 0x0080 /* linger on close if data present */
#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
#define SO_REUSEPORT 0x0200 /* allow local address & port reuse */
#define SO_DONTLINGER (int)(~SO_LINGER)
/*
* Additional options, not kept in so_options.
*/
#define SO_SNDBUF 0x1001 /* send buffer size */
#define SO_RCVBUF 0x1002 /* receive buffer size */
#define SO_SNDBUF 0x1001 /* send buffer size */
#define SO_RCVBUF 0x1002 /* receive buffer size */
#define SO_SNDLOWAT 0x1003 /* send low-water mark */
#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
#define SO_SNDTIMEO 0x1005 /* send timeout */
#define SO_RCVTIMEO 0x1006 /* receive timeout */
#define SO_ERROR 0x1007 /* get error status and clear */
#define SO_TYPE 0x1008 /* get socket type */
#define SO_ERROR 0x1007 /* get error status and clear */
#define SO_TYPE 0x1008 /* get socket type */
@ -223,6 +225,7 @@ struct linger {
#endif
void lwip_socket_init(void);
int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
int lwip_bind(int s, struct sockaddr *name, socklen_t namelen);
int lwip_shutdown(int s, int how);
@ -250,7 +253,7 @@ int lwip_ioctl(int s, long cmd, void *argp);
#define accept(a,b,c) lwip_accept(a,b,c)
#define bind(a,b,c) lwip_bind(a,b,c)
#define shutdown(a,b) lwip_shutdown(a,b)
#define close(s) lwip_close(s)
#define closesocket(s) lwip_close(s)
#define connect(a,b,c) lwip_connect(a,b,c)
#define getsockname(a,b,c) lwip_getsockname(a,b,c)
#define getpeername(a,b,c) lwip_getpeername(a,b,c)
@ -258,14 +261,19 @@ int lwip_ioctl(int s, long cmd, void *argp);
#define getsockopt(a,b,c,d,e) lwip_getsockopt(a,b,c,d,e)
#define listen(a,b) lwip_listen(a,b)
#define recv(a,b,c,d) lwip_recv(a,b,c,d)
#define read(a,b,c) lwip_read(a,b,c)
#define recvfrom(a,b,c,d,e,f) lwip_recvfrom(a,b,c,d,e,f)
#define send(a,b,c,d) lwip_send(a,b,c,d)
#define sendto(a,b,c,d,e,f) lwip_sendto(a,b,c,d,e,f)
#define socket(a,b,c) lwip_socket(a,b,c)
#define write(a,b,c) lwip_write(a,b,c)
#define select(a,b,c,d,e) lwip_select(a,b,c,d,e)
#define ioctlsocket(a,b,c) lwip_ioctl(a,b,c)
#if LWIP_POSIX_SOCKETS_IO_NAMES
#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)
#endif /* LWIP_POSIX_SOCKETS_IO_NAMES */
#endif /* LWIP_COMPAT_SOCKETS */
#endif /* __LWIP_SOCKETS_H__ */