ReactOS 0.4.16-dev-297-gc569aee
sockets_priv.h
Go to the documentation of this file.
1
6/*
7 * Copyright (c) 2017 Joel Cunningham, Garmin International, Inc. <joel.cunningham@garmin.com>
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without modification,
11 * are permitted provided that the following conditions are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * 3. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
22 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
24 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
26 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
30 * OF SUCH DAMAGE.
31 *
32 * This file is part of the lwIP TCP/IP stack.
33 *
34 * Author: Joel Cunningham <joel.cunningham@me.com>
35 *
36 */
37#ifndef LWIP_HDR_SOCKETS_PRIV_H
38#define LWIP_HDR_SOCKETS_PRIV_H
39
40#include "lwip/opt.h"
41
42#if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */
43
44#include "lwip/err.h"
45#include "lwip/sockets.h"
46#include "lwip/sys.h"
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
52#define NUM_SOCKETS MEMP_NUM_NETCONN
53
57#ifndef SELWAIT_T
58#define SELWAIT_T u8_t
59#endif
60
61union lwip_sock_lastdata {
62 struct netbuf *netbuf;
63 struct pbuf *pbuf;
64};
65
67struct lwip_sock {
69 struct netconn *conn;
71 union lwip_sock_lastdata lastdata;
72#if LWIP_SOCKET_SELECT || LWIP_SOCKET_POLL
75 s16_t rcvevent;
78 u16_t sendevent;
80 u16_t errevent;
82 SELWAIT_T select_waiting;
83#endif /* LWIP_SOCKET_SELECT || LWIP_SOCKET_POLL */
84#if LWIP_NETCONN_FULLDUPLEX
85 /* counter of how many threads are using a struct lwip_sock (not the 'int') */
86 u8_t fd_used;
87 /* status of pending close/delete actions */
88 u8_t fd_free_pending;
89#define LWIP_SOCK_FD_FREE_TCP 1
90#define LWIP_SOCK_FD_FREE_FREE 2
91#endif
92};
93
94#ifndef set_errno
95#define set_errno(err) do { if (err) { errno = (err); } } while(0)
96#endif
97
98#if !LWIP_TCPIP_CORE_LOCKING
100#define LWIP_SETGETSOCKOPT_MAXOPTLEN LWIP_MAX(16, sizeof(struct ifreq))
101
104struct lwip_setgetsockopt_data {
106 int s;
108 int level;
110 int optname;
113#if LWIP_MPU_COMPATIBLE
114 u8_t optval[LWIP_SETGETSOCKOPT_MAXOPTLEN];
115#else
116 union {
117 void *p;
118 const void *pc;
119 } optval;
120#endif
122 socklen_t optlen;
124 int err;
126 void* completed_sem;
127};
128#endif /* !LWIP_TCPIP_CORE_LOCKING */
129
130#ifdef __cplusplus
131}
132#endif
133
134struct lwip_sock* lwip_socket_dbg_get_socket(int fd);
135
136#if LWIP_SOCKET_SELECT || LWIP_SOCKET_POLL
137
138#if LWIP_NETCONN_SEM_PER_THREAD
139#define SELECT_SEM_T sys_sem_t*
140#define SELECT_SEM_PTR(sem) (sem)
141#else /* LWIP_NETCONN_SEM_PER_THREAD */
142#define SELECT_SEM_T sys_sem_t
143#define SELECT_SEM_PTR(sem) (&(sem))
144#endif /* LWIP_NETCONN_SEM_PER_THREAD */
145
147struct lwip_select_cb {
149 struct lwip_select_cb *next;
151 struct lwip_select_cb *prev;
152#if LWIP_SOCKET_SELECT
154 fd_set *readset;
156 fd_set *writeset;
158 fd_set *exceptset;
159#endif /* LWIP_SOCKET_SELECT */
160#if LWIP_SOCKET_POLL
162 struct pollfd *poll_fds;
164 nfds_t poll_nfds;
165#endif /* LWIP_SOCKET_POLL */
167 int sem_signalled;
169 SELECT_SEM_T sem;
170};
171#endif /* LWIP_SOCKET_SELECT || LWIP_SOCKET_POLL */
172
173#endif /* LWIP_SOCKET */
174
175#endif /* LWIP_HDR_SOCKETS_PRIV_H */
GLint level
Definition: gl.h:1546
GLdouble s
Definition: gl.h:2039
GLfloat GLfloat p
Definition: glext.h:8902
uint8_t u8_t
Definition: arch.h:125
uint16_t u16_t
Definition: arch.h:127
int16_t s16_t
Definition: arch.h:128
int socklen_t
Definition: tcp.c:35
static HANDLE sem
Definition: sync.c:674
static unsigned __int64 next
Definition: rand_nt.c:6
#define err(...)
static int fd
Definition: io.c:51
Definition: winsock.h:66
Definition: types.h:144
Definition: pbuf.h:186
Definition: linux.h:1867