File: sockets.h

package info (click to toggle)
lwip 2.1.2%2Bdfsg1-8%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 7,416 kB
  • sloc: ansic: 89,600; perl: 81; sh: 28; makefile: 18
file content (140 lines) | stat: -rw-r--r-- 4,958 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
   Copyright (C) 2018 Free Software Foundation, Inc.
   Written by Joan Lledó.

   This file is part of the GNU Hurd.

   The GNU Hurd is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License as
   published by the Free Software Foundation; either version 2, or (at
   your option) any later version.

   The GNU Hurd is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>.  */

#ifndef HURD_LWIP_POSIX_SOCKET_H
#define HURD_LWIP_POSIX_SOCKET_H

#include <sys/socket.h>
#include <poll.h>
#include <errno.h>
#include LWIP_SOCKET_EXTERNAL_HEADER_INET_H

#ifdef __cplusplus
extern "C" {
#endif

#ifdef _HAVE_SA_LEN
#define HAVE_SA_LEN	_HAVE_SA_LEN
#else
#define HAVE_SA_LEN	0
#endif /* _HAVE_SA_LEN */

/* Address length safe read and write */
#if HAVE_SA_LEN
#define IP4ADDR_SOCKADDR_SET_LEN(sin) \
      (sin)->sin_len = sizeof(struct sockaddr_in)
#define IP6ADDR_SOCKADDR_SET_LEN(sin6) \
      (sin6)->sin6_len = sizeof(struct sockaddr_in6)
#define IPADDR_SOCKADDR_GET_LEN(addr) \
      (addr)->sa.sa_len
#else
#define IP4ADDR_SOCKADDR_SET_LEN(addr)
#define IP6ADDR_SOCKADDR_SET_LEN(addr)
#define IPADDR_SOCKADDR_GET_LEN(addr) \
      ((addr)->sa.sa_family == AF_INET ? sizeof(struct sockaddr_in) \
        : ((addr)->sa.sa_family == AF_INET6 ? sizeof(struct sockaddr_in6) : 0))
#endif /* HAVE_SA_LEN */

#define SIN_ZERO_LEN	sizeof (struct sockaddr) - \
                           __SOCKADDR_COMMON_SIZE - \
                           sizeof (in_port_t) - \
                           sizeof (struct in_addr)

#if !defined IOV_MAX
#define IOV_MAX 0xFFFF
#elif IOV_MAX > 0xFFFF
#error "IOV_MAX larger than supported by LwIP"
#endif /* IOV_MAX */

#define LWIP_SELECT_MAXNFDS (FD_SETSIZE + LWIP_SOCKET_OFFSET)

#if LWIP_UDP && LWIP_UDPLITE
/*
 * Options for level IPPROTO_UDPLITE
 */
#define UDPLITE_SEND_CSCOV 0x01 /* sender checksum coverage */
#define UDPLITE_RECV_CSCOV 0x02 /* minimal receiver checksum coverage */
#endif /* LWIP_UDP && LWIP_UDPLITE*/

void lwip_socket_thread_init(void); /* LWIP_NETCONN_SEM_PER_THREAD==1: initialize thread-local semaphore */
void lwip_socket_thread_cleanup(void); /* LWIP_NETCONN_SEM_PER_THREAD==1: destroy thread-local semaphore */

int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
int lwip_bind(int s, const struct sockaddr *name, socklen_t namelen);
int lwip_shutdown(int s, int how);
int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen);
int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen);
int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen);
int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen);
 int lwip_close(int s);
int lwip_connect(int s, const struct sockaddr *name, socklen_t namelen);
int lwip_listen(int s, int backlog);
ssize_t lwip_recv(int s, void *mem, size_t len, int flags);
ssize_t lwip_read(int s, void *mem, size_t len);
ssize_t lwip_readv(int s, const struct iovec *iov, int iovcnt);
ssize_t lwip_recvfrom(int s, void *mem, size_t len, int flags,
      struct sockaddr *from, socklen_t *fromlen);
ssize_t lwip_recvmsg(int s, struct msghdr *message, int flags);
ssize_t lwip_send(int s, const void *dataptr, size_t size, int flags);
ssize_t lwip_sendmsg(int s, const struct msghdr *message, int flags);
ssize_t lwip_sendto(int s, const void *dataptr, size_t size, int flags,
    const struct sockaddr *to, socklen_t tolen);
int lwip_socket(int domain, int type, int protocol);
ssize_t lwip_write(int s, const void *dataptr, size_t size);
ssize_t lwip_writev(int s, const struct iovec *iov, int iovcnt);
#if LWIP_SOCKET_SELECT
int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
                struct timeval *timeout);
#endif
#if LWIP_SOCKET_POLL
int lwip_poll(struct pollfd *fds, nfds_t nfds, int timeout);
#endif
int lwip_ioctl(int s, long cmd, void *argp);
int lwip_fcntl(int s, int cmd, int val);
const char *lwip_inet_ntop(int af, const void *src, char *dst, socklen_t size);
int lwip_inet_pton(int af, const char *src, void *dst);

/* Unsuported indetifiers */
#ifndef SO_NO_CHECK
#define SO_NO_CHECK         0xFF
#endif
#ifndef SO_BINDTODEVICE
#define SO_BINDTODEVICE     0xFE
#endif
#ifndef MSG_MORE
#define MSG_MORE            0x0
#endif
#ifndef TCP_KEEPALIVE
#define TCP_KEEPALIVE       0xFF
#endif
#ifndef TCP_KEEPIDLE
#define TCP_KEEPIDLE        0xFE
#endif
#ifndef TCP_KEEPINTVL
#define TCP_KEEPINTVL       0xFD
#endif
#ifndef TCP_KEEPCNT
#define TCP_KEEPCNT         0xFC
#endif

#ifdef __cplusplus
}
#endif

#endif /* HURD_LWIP_POSIX_SOCKET_H */