mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-15 12:47:08 +08:00
patch #7702 "Include ability to increase the socket number with defined offset"
This commit is contained in:
@@ -1545,6 +1545,17 @@
|
||||
#define LWIP_POSIX_SOCKETS_IO_NAMES 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LWIP_SOCKET_OFFSET==n: Increases the file descriptor number created by LwIP with n.
|
||||
* This can be useful when there are multiple APIs which create file descriptors.
|
||||
* When they all start with a different offset and you won't make them overlap you can
|
||||
* re implement read/write/close/ioctl/fnctl to send the requested action to the right
|
||||
* library (sharing select will need more work though).
|
||||
*/
|
||||
#ifndef LWIP_SOCKET_OFFSET
|
||||
#define LWIP_SOCKET_OFFSET 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LWIP_TCP_KEEPALIVE==1: Enable TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT
|
||||
* options processing. Note that TCP_KEEPIDLE and TCP_KEEPINTVL have to be set
|
||||
|
||||
@@ -378,18 +378,26 @@ typedef struct ip_mreq {
|
||||
|
||||
/* FD_SET used for lwip_select */
|
||||
#ifndef FD_SET
|
||||
#undef FD_SETSIZE
|
||||
/* Make FD_SETSIZE match NUM_SOCKETS in socket.c */
|
||||
#define FD_SETSIZE MEMP_NUM_NETCONN
|
||||
#define FD_SET(n, p) ((p)->fd_bits[(n)/8] |= (1 << ((n) & 7)))
|
||||
#define FD_CLR(n, p) ((p)->fd_bits[(n)/8] &= ~(1 << ((n) & 7)))
|
||||
#define FD_ISSET(n,p) ((p)->fd_bits[(n)/8] & (1 << ((n) & 7)))
|
||||
#define FD_ZERO(p) memset((void*)(p),0,sizeof(*(p)))
|
||||
#undef FD_SETSIZE
|
||||
/* Make FD_SETSIZE match NUM_SOCKETS in socket.c */
|
||||
#define FD_SETSIZE MEMP_NUM_NETCONN
|
||||
#define FDSETSAFESET(n, p, code) do { \
|
||||
if(((p) != NULL) && ((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0)) { \
|
||||
code; }} while(0)
|
||||
#define FDSETSAFEGET(n, p, code) (((p) != NULL) && ((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0) ?\
|
||||
(code) : 0)
|
||||
#define FD_SET(n, p) FDSETSAFESET(n, p, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] |= (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
|
||||
#define FD_CLR(n, p) FDSETSAFESET(n, p, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] &= ~(1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
|
||||
#define FD_ISSET(n,p) FDSETSAFEGET(n, p, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] & (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
|
||||
#define FD_ZERO(p) memset((void*)(p), 0, sizeof(*(p)))
|
||||
|
||||
typedef struct fd_set {
|
||||
unsigned char fd_bits [(FD_SETSIZE+7)/8];
|
||||
} fd_set;
|
||||
typedef struct fd_set
|
||||
{
|
||||
unsigned char fd_bits [(FD_SETSIZE+7)/8];
|
||||
} fd_set;
|
||||
|
||||
#elif LWIP_SOCKET_OFFSET
|
||||
#error LWIP_SOCKET_OFFSET does not work with external FD_SET!
|
||||
#endif /* FD_SET */
|
||||
|
||||
/** LWIP_TIMEVAL_PRIVATE: if you want to use the struct timeval provided
|
||||
|
||||
Reference in New Issue
Block a user