bsd_socket.h
Go to the documentation of this file.
1 /**
2  * @file bsd_socket.h
3  * @brief BSD socket API
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.0
29  **/
30 
31 #ifndef _BSD_SOCKET_H
32 #define _BSD_SOCKET_H
33 
34 //BSD socket support
35 #ifndef BSD_SOCKET_SUPPORT
36  #define BSD_SOCKET_SUPPORT ENABLED
37 #elif (BSD_SOCKET_SUPPORT != ENABLED && BSD_SOCKET_SUPPORT != DISABLED)
38  #error BSD_SOCKET_SUPPORT parameter is not valid
39 #endif
40 
41 //Maximum number of file descriptors a fd_set object can hold
42 #ifndef FD_SETSIZE
43  #define FD_SETSIZE 8
44 #elif (FD_SETSIZE < 1)
45  #error FD_SETSIZE parameter is not valid
46 #endif
47 
48 //Set errno variable
49 #ifndef BSD_SOCKET_SET_ERRNO
50  #define BSD_SOCKET_SET_ERRNO(e)
51 #endif
52 
53 //Keil RTX port?
54 #if defined(USE_RTX) && !defined(RTX_CUSTOM_HEADER)
55 
56 //No support for BSD sockets
57 #undef BSD_SOCKET_SUPPORT
58 #define BSD_SOCKET_SUPPORT DISABLED
59 
60 //Windows port?
61 #elif defined(_WIN32) && !defined(_DONT_USE_WINSOCK)
62 
63 //Undefine conflicting definitions
64 #undef htons
65 #undef htonl
66 #undef ntohs
67 #undef ntohl
68 
69 //Dependencies
70 #include <winsock2.h>
71 
72 #elif (BSD_SOCKET_SUPPORT == ENABLED)
73 
74 //Dependencies
75 #include "os_port.h"
76 
77 //Address families
78 #define AF_UNSPEC 0
79 #define AF_INET 2
80 #define AF_INET6 10
81 #define AF_PACKET 17
82 
83 //Protocol families
84 #define PF_UNSPEC AF_UNSPEC
85 #define PF_INET AF_INET
86 #define PF_INET6 AF_INET6
87 #define PF_PACKET AF_PACKET
88 
89 //Socket types
90 #define SOCK_STREAM 1
91 #define SOCK_DGRAM 2
92 #define SOCK_RAW 3
93 
94 //IP protocol identifiers
95 #define IPPROTO_IP 0
96 #define IPPROTO_ICMP 1
97 #define IPPROTO_IGMP 2
98 #define IPPROTO_TCP 6
99 #define IPPROTO_UDP 17
100 #define IPPROTO_IPV6 41
101 #define IPPROTO_ESP 50
102 #define IPPROTO_AH 51
103 #define IPPROTO_ICMPV6 58
104 
105 //Ethernet protocol identifiers
106 #define ETH_P_ALL 0x0000
107 #define ETH_P_IP 0x0800
108 #define ETH_P_ARP 0x0806
109 #define ETH_P_IPV6 0x86DD
110 
111 //Option levels
112 #define SOL_SOCKET 0xFFFF
113 
114 //Common addresses
115 #define INADDR_ANY 0x00000000
116 #define INADDR_LOOPBACK 0x7F000001
117 #define INADDR_BROADCAST 0xFFFFFFFF
118 
119 //Flags used by I/O functions
120 #define MSG_PEEK 0x0002
121 #define MSG_DONTROUTE 0x0004
122 #define MSG_CTRUNC 0x0008
123 #define MSG_DONTWAIT 0x0040
124 #define MSG_WAITALL 0x0100
125 
126 //Flags used by shutdown function
127 #define SD_RECEIVE 0
128 #define SD_SEND 1
129 #define SD_BOTH 2
130 
131 //Flags used by shutdown function (alias)
132 #define SHUT_RD SD_RECEIVE
133 #define SHUT_WR SD_SEND
134 #define SHUT_RDWR SD_BOTH
135 
136 //Socket level options
137 #define SO_REUSEADDR 0x0004
138 #define SO_KEEPALIVE 0x0008
139 #define SO_DONTROUTE 0x0010
140 #define SO_BROADCAST 0x0020
141 #define SO_LINGER 0x0080
142 #define SO_SNDBUF 0x1001
143 #define SO_RCVBUF 0x1002
144 #define SO_SNDTIMEO 0x1005
145 #define SO_RCVTIMEO 0x1006
146 #define SO_ERROR 0x1007
147 #define SO_TYPE 0x1008
148 #define SO_MAX_MSG_SIZE 0x2003
149 #define SO_BINDTODEVICE 0x3000
150 
151 //IP level options
152 #define IP_TOS 1
153 #define IP_TTL 2
154 #define IP_ROUTER_ALERT 5
155 #define IP_PKTINFO 8
156 #define IP_RECVTTL 12
157 #define IP_RECVTOS 13
158 #define IP_MULTICAST_IF 32
159 #define IP_MULTICAST_TTL 33
160 #define IP_MULTICAST_LOOP 34
161 #define IP_ADD_MEMBERSHIP 35
162 #define IP_DROP_MEMBERSHIP 36
163 #define IP_DONTFRAG 67
164 
165 //IPv6 level options
166 #define IPV6_UNICAST_HOPS 16
167 #define IPV6_MULTICAST_IF 17
168 #define IPV6_MULTICAST_HOPS 18
169 #define IPV6_MULTICAST_LOOP 19
170 #define IPV6_ADD_MEMBERSHIP 20
171 #define IPV6_DROP_MEMBERSHIP 21
172 #define IPV6_V6ONLY 26
173 #define IPV6_PKTINFO 50
174 #define IPV6_RECVHOPLIMIT 51
175 #define IPV6_HOPLIMIT 52
176 #define IPV6_DONTFRAG 62
177 #define IPV6_RECVTCLASS 66
178 #define IPV6_TCLASS 67
179 
180 //TCP level options
181 #define TCP_NODELAY 0x0001
182 #define TCP_MAXSEG 0x0002
183 #define TCP_KEEPIDLE 0x0004
184 #define TCP_KEEPINTVL 0x0005
185 #define TCP_KEEPCNT 0x0006
186 
187 //IP TOS option
188 #define IPTOS_LOWDELAY 0x10
189 #define IPTOS_THROUGHPUT 0x08
190 #define IPTOS_RELIABILITY 0x04
191 
192 //IOCTL commands
193 #define FIONBIO 126
194 #define FIONREAD 127
195 #define FIONWRITE 121
196 #define FIONSPACE 120
197 
198 //FCNTL commands
199 #define F_GETFL 3
200 #define F_SETFL 4
201 
202 //FCNTL flags
203 #define O_NONBLOCK 0x0004
204 
205 //Flags used by getaddrinfo
206 #define AI_PASSIVE 0x01
207 #define AI_CANONNAME 0x02
208 #define AI_NUMERICHOST 0x04
209 #define AI_NUMERICSERV 0x08
210 #define AI_ALL 0x10
211 #define AI_ADDRCONFIG 0x20
212 #define AI_V4MAPPED 0x40
213 
214 //Flags used by getnameinfo
215 #define NI_NOFQDN 0x01
216 #define NI_NUMERICHOST 0x02
217 #define NI_NAMEREQD 0x04
218 #define NI_NUMERICSERV 0x08
219 #define NI_DGRAM 0x10
220 
221 //Return values
222 #define SOCKET_SUCCESS 0
223 #define SOCKET_ERROR (-1)
224 
225 //Return values used by getaddrinfo and getnameinfo
226 #define EAI_ADDRFAMILY 1
227 #define EAI_AGAIN 2
228 #define EAI_BADFLAGS 3
229 #define EAI_FAIL 4
230 #define EAI_FAMILY 5
231 #define EAI_MEMORY 6
232 #define EAI_NODATA 7
233 #define EAI_NONAME 8
234 #define EAI_SERVICE 9
235 #define EAI_SOCKTYPE 10
236 #define EAI_SYSTEM 11
237 #define EAI_OVERFLOW 12
238 
239 //Error codes
240 #define EINTR 4
241 #define EAGAIN 11
242 #define EWOULDBLOCK 11
243 #define EFAULT 14
244 #define EINVAL 22
245 #define EINPROGRESS 36
246 #define ETIMEDOUT 60
247 #define ENAMETOOLONG 63
248 #define EMSGSIZE 90
249 #define ENOPROTOOPT 92
250 #define ECONNRESET 104
251 #define EISCONN 106
252 #define ENOTCONN 107
253 #define ESHUTDOWN 108
254 #define ECONNREFUSED 111
255 
256 //Error codes used by gethostbyname_r
257 #define NETDB_SUCCESS 0
258 #define HOST_NOT_FOUND 1
259 #define TRY_AGAIN 2
260 #define NO_RECOVERY 3
261 #define NO_ADDRESS 4
262 
263 //Return codes
264 #define INADDR_NONE ((in_addr_t) (-1))
265 
266 //Maximum length for string representation of IPv4 address
267 #define INET_ADDRSTRLEN 16
268 
269 //Maximum length for string representation of IPv6 address
270 #define INET6_ADDRSTRLEN 40
271 
272 //C++ guard
273 #ifdef __cplusplus
274 extern "C" {
275 #endif
276 
277 
278 /**
279  * @brief Length type
280  **/
281 
282 typedef int_t socklen_t;
283 
284 
285 /**
286  * @brief IPv4 address
287  **/
288 
289 typedef uint32_t in_addr_t;
290 
291 
292 /**
293  * @brief Socket address
294  **/
295 
296 typedef struct sockaddr
297 {
298  uint16_t sa_family;
299  uint8_t sa_data[14];
301 
302 
303 /**
304  * @brief Socket address storage
305  **/
306 
307 typedef struct sockaddr_storage
308 {
309  uint16_t ss_family;
310  uint8_t ss_pad[26];
312 
313 
314 /**
315  * @brief Structure that represents an IPv4 address
316  **/
317 
318 typedef struct in_addr
319 {
322 
323 
324 /**
325  * @brief IPv4 address information
326  **/
327 
328 typedef struct sockaddr_in
329 {
330  uint16_t sin_family;
331  uint16_t sin_port;
332  struct in_addr sin_addr;
333  uint8_t sin_zero[8];
335 
336 
337 /**
338  * @brief Structure that represents an IPv6 address
339  **/
340 
341 typedef struct in6_addr
342 {
343  uint8_t s6_addr[16];
345 
346 
347 /**
348  * @brief IPv6 address information
349  **/
350 
351 typedef struct sockaddr_in6
352 {
353  uint16_t sin6_family;
354  uint16_t sin6_port;
355  uint32_t sin6_flowinfo;
356  struct in6_addr sin6_addr;
357  uint32_t sin6_scope_id;
359 
360 
361 /**
362  * @brief Multicast group information for IPv4 addresses
363  **/
364 
365 typedef struct ip_mreq
366 {
367  struct in_addr imr_multiaddr;
368  struct in_addr imr_interface;
370 
371 
372 /**
373  * @brief Multicast group information for IPv6 addresses
374  **/
375 
376 typedef struct ipv6_mreq
377 {
378  struct in6_addr ipv6mr_multiaddr;
381 
382 
383 /**
384  * @brief Linger structure
385  **/
386 
387 typedef struct linger
388 {
392 
393 
394 /**
395  * @brief Scatter/gather array
396  **/
397 
398 struct iovec
399 {
400  void *iov_base;
401  size_t iov_len;
402 };
403 
404 
405 /**
406  * @brief Message header
407  **/
408 
409 typedef struct msghdr
410 {
411  void *msg_name;
413  struct iovec *msg_iov;
415  void *msg_control;
419 
420 
421 /**
422  * @brief Ancillary data header
423  **/
424 
425 typedef struct cmsghdr
426 {
427  size_t cmsg_len;
431 
432 
433 /**
434  * @brief IPv4 packet information
435  **/
436 
437 typedef struct in_pktinfo
438 {
440  struct in_addr ipi_addr;
442 
443 
444 /**
445  * @brief IPv6 packet information
446  **/
447 
448 typedef struct in6_pktinfo
449 {
451  struct in6_addr ipi6_addr;
453 
454 
455 /**
456  * @brief Set of sockets
457  **/
458 
459 typedef struct fd_set
460 {
464 
465 
466 /**
467  * @brief Information about a given host
468  **/
469 
470 typedef struct hostent
471 {
472  uint16_t h_addrtype;
473  uint16_t h_length;
474  uint8_t h_addr[16];
476 
477 
478 /**
479  * @brief Information about address of a service provider
480  **/
481 
482 typedef struct addrinfo
483 {
489  struct sockaddr *ai_addr;
491  struct addrinfo *ai_next;
493 
494 
495 #ifndef _TIMEVAL_DEFINED
496 
497 /**
498  * @brief Timeout structure
499  **/
500 
501 typedef struct timeval
502 {
503  int32_t tv_sec;
504  int32_t tv_usec;
506 
507 #endif
508 
509 
510 //Forward declaration of functions
511 struct cmsghdr *socketCmsgFirstHdr(struct msghdr *msg);
512 struct cmsghdr *socketCmsgNextHdr(struct msghdr *msg, struct cmsghdr *cmsg);
513 
514 //Macros for manipulating ancillary data object information
515 #define CMSG_DATA(cmsg) ((uint8_t *) (cmsg) + sizeof(struct cmsghdr))
516 #define CMSG_ALIGN(len) (((len) + sizeof(int_t) - 1) & ~(sizeof(int_t) - 1))
517 #define CMSG_SPACE(len) (sizeof(struct cmsghdr) + CMSG_ALIGN(len))
518 #define CMSG_LEN(len) (sizeof(struct cmsghdr) + (len))
519 #define CMSG_FIRSTHDR(msg) socketCmsgFirstHdr(msg)
520 #define CMSG_NXTHDR(msg, cmsg) socketCmsgNextHdr(msg, cmsg)
521 
522 //Forward declaration of functions
523 void socketFdZero(fd_set *fds);
524 void socketFdSet(fd_set *fds, int_t s);
525 void socketFdClr(fd_set *fds, int_t s);
527 
528 //Macros for manipulating and checking descriptor sets
529 #define FD_ZERO(fds) socketFdZero(fds)
530 #define FD_SET(s, fds) socketFdSet(fds, s)
531 #define FD_CLR(s, fds) socketFdClr(fds, s)
532 #define FD_ISSET(s, fds) socketFdIsSet(fds, s)
533 
534 //BSD socket related constants
535 extern const struct in6_addr in6addr_any;
536 extern const struct in6_addr in6addr_loopback;
537 
538 //BSD socket related functions
540 int_t bind(int_t s, const struct sockaddr *addr, socklen_t addrlen);
541 int_t connect(int_t s, const struct sockaddr *addr, socklen_t addrlen);
542 int_t listen(int_t s, int_t backlog);
543 int_t accept(int_t s, struct sockaddr *addr, socklen_t *addrlen);
544 int_t send(int_t s, const void *data, size_t length, int_t flags);
545 
546 int_t sendto(int_t s, const void *data, size_t length, int_t flags,
547  const struct sockaddr *addr, socklen_t addrlen);
548 
549 int_t sendmsg(int_t s, struct msghdr *msg, int_t flags);
550 
551 int_t recv(int_t s, void *data, size_t size, int_t flags);
552 
553 int_t recvfrom(int_t s, void *data, size_t size, int_t flags,
554  struct sockaddr *addr, socklen_t *addrlen);
555 
556 int_t recvmsg(int_t s, struct msghdr *msg, int_t flags);
557 
558 int_t getsockname(int_t s, struct sockaddr *addr, socklen_t *addrlen);
559 int_t getpeername(int_t s, struct sockaddr *addr, socklen_t *addrlen);
560 
561 int_t setsockopt(int_t s, int_t level, int_t optname, const void *optval,
562  socklen_t optlen);
563 
564 int_t getsockopt(int_t s, int_t level, int_t optname, void *optval,
565  socklen_t *optlen);
566 
567 int_t ioctlsocket(int_t s, uint32_t cmd, void *arg);
568 int_t fcntl(int_t s, int_t cmd, int_t arg);
569 
570 int_t shutdown(int_t s, int_t how);
572 
573 int_t select(int_t nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
574  const struct timeval *timeout);
575 
576 int_t gethostname(char_t *name, size_t len);
577 struct hostent *gethostbyname(const char_t *name);
578 
579 struct hostent *gethostbyname_r(const char_t *name, struct hostent *result,
580  char_t *buf, size_t buflen, int_t *h_errnop);
581 
582 int_t getaddrinfo(const char_t *node, const char_t *service,
583  const struct addrinfo *hints, struct addrinfo **res);
584 
585 void freeaddrinfo(struct addrinfo *res);
586 
587 int_t getnameinfo(const struct sockaddr *addr, socklen_t addrlen,
588  char_t *host, size_t hostlen, char_t *serv, size_t servlen, int flags);
589 
590 in_addr_t inet_addr(const char_t *cp);
591 
592 int_t inet_aton(const char_t *cp, struct in_addr *inp);
593 const char_t *inet_ntoa(struct in_addr in);
594 const char_t *inet_ntoa_r(struct in_addr in, char_t *buf, socklen_t buflen);
595 
596 int_t inet_pton(int_t af, const char_t *src, void *dst);
597 const char_t *inet_ntop(int_t af, const void *src, char_t *dst, socklen_t size);
598 
599 //C++ guard
600 #ifdef __cplusplus
601 }
602 #endif
603 
604 #endif
605 #endif
int_t socklen_t
Length type.
Definition: bsd_socket.h:282
struct cmsghdr CMSGHDR
Ancillary data header.
struct hostent HOSTENT
Information about a given host.
struct in_pktinfo * PIN_PKTINFO
in_addr_t inet_addr(const char_t *cp)
Convert a dot-decimal string into binary data in network byte order.
Definition: bsd_socket.c:3108
struct in6_addr IN6_ADDR
Structure that represents an IPv6 address.
struct linger LINGER
Linger structure.
int_t sendmsg(int_t s, struct msghdr *msg, int_t flags)
Send a message.
Definition: bsd_socket.c:661
void socketFdClr(fd_set *fds, int_t s)
Remove a descriptor from an existing set.
struct sockaddr_storage * PSOCKADDR_STORAGE
struct in6_addr * PIN6_ADDR
int_t fcntl(int_t s, int_t cmd, int_t arg)
Perform specific operation.
Definition: bsd_socket.c:2287
int_t recvmsg(int_t s, struct msghdr *msg, int_t flags)
Receive a message.
Definition: bsd_socket.c:1115
struct sockaddr_in SOCKADDR_IN
IPv4 address information.
int_t getpeername(int_t s, struct sockaddr *addr, socklen_t *addrlen)
Retrieves the address of the peer to which a socket is connected.
Definition: bsd_socket.c:1572
int_t listen(int_t s, int_t backlog)
Place a socket in the listening state.
Definition: bsd_socket.c:322
struct fd_set * PFD_SET
const char_t * inet_ntop(int_t af, const void *src, char_t *dst, socklen_t size)
Convert an IPv4 or IPv6 address from binary to text.
Definition: bsd_socket.c:3294
struct in_addr IN_ADDR
Structure that represents an IPv4 address.
struct in6_pktinfo * PIN6_PKTINFO
int_t gethostname(char_t *name, size_t len)
Get system host name.
Definition: bsd_socket.c:2605
int_t ioctlsocket(int_t s, uint32_t cmd, void *arg)
Control the I/O mode of a socket.
Definition: bsd_socket.c:2187
void socketFdSet(fd_set *fds, int_t s)
Add a descriptor to an existing set.
int_t socket(int_t family, int_t type, int_t protocol)
Create a socket that is bound to a specific transport service provider.
Definition: bsd_socket.c:65
int_t send(int_t s, const void *data, size_t length, int_t flags)
Send data to a connected socket.
Definition: bsd_socket.c:459
int_t getaddrinfo(const char_t *node, const char_t *service, const struct addrinfo *hints, struct addrinfo **res)
Convert host and service names to socket address.
Definition: bsd_socket.c:2743
struct msghdr MSGHDR
Message header.
struct sockaddr_in6 SOCKADDR_IN6
IPv6 address information.
void freeaddrinfo(struct addrinfo *res)
Free socket address structures.
Definition: bsd_socket.c:2983
int_t recvfrom(int_t s, void *data, size_t size, int_t flags, struct sockaddr *addr, socklen_t *addrlen)
Receive a datagram.
Definition: bsd_socket.c:989
const struct in6_addr in6addr_loopback
Definition: bsd_socket.c:52
struct timeval TIMEVAL
Timeout structure.
const char_t * inet_ntoa(struct in_addr in)
Convert a binary IPv4 address to dot-decimal notation.
Definition: bsd_socket.c:3177
struct cmsghdr * PCMSGHDR
struct sockaddr_in * PSOCKADDR_IN
int_t getsockname(int_t s, struct sockaddr *addr, socklen_t *addrlen)
Retrieves the local name for a socket.
Definition: bsd_socket.c:1476
int_t getnameinfo(const struct sockaddr *addr, socklen_t addrlen, char_t *host, size_t hostlen, char_t *serv, size_t servlen, int flags)
Convert a socket address to a corresponding host and service.
Definition: bsd_socket.c:3012
int_t connect(int_t s, const struct sockaddr *addr, socklen_t addrlen)
Establish a connection to a specified socket.
Definition: bsd_socket.c:204
struct ipv6_mreq IPV6_MREQ
Multicast group information for IPv6 addresses.
struct cmsghdr * socketCmsgFirstHdr(struct msghdr *msg)
Get first ancillary data header.
int_t sendto(int_t s, const void *data, size_t length, int_t flags, const struct sockaddr *addr, socklen_t addrlen)
Send a datagram to a specific destination.
Definition: bsd_socket.c:535
struct ip_mreq IP_MREQ
Multicast group information for IPv4 addresses.
int_t bind(int_t s, const struct sockaddr *addr, socklen_t addrlen)
Associate a local address with a socket.
Definition: bsd_socket.c:107
int_t accept(int_t s, struct sockaddr *addr, socklen_t *addrlen)
Permit an incoming connection attempt on a socket.
Definition: bsd_socket.c:360
#define FD_SETSIZE
Definition: bsd_socket.h:43
struct sockaddr_in6 * PSOCKADDR_IN6
struct ipv6_mreq * PIPV6_MREQ
int_t inet_pton(int_t af, const char_t *src, void *dst)
Convert an IPv4 or IPv6 address from text to binary form.
Definition: bsd_socket.c:3222
struct hostent * gethostbyname(const char_t *name)
Host name resolution.
Definition: bsd_socket.c:2646
struct hostent * PHOSTENT
uint32_t in_addr_t
IPv4 address.
Definition: bsd_socket.h:289
int_t recv(int_t s, void *data, size_t size, int_t flags)
Receive data from a connected socket.
Definition: bsd_socket.c:917
#define FD_SET(s, fds)
Definition: bsd_socket.h:530
struct sockaddr_storage SOCKADDR_STORAGE
Socket address storage.
struct in6_pktinfo IN6_PKTINFO
IPv6 packet information.
struct sockaddr * PSOCKADDR
struct fd_set fd_set
Set of sockets.
int_t closesocket(int_t s)
The closesocket function closes an existing socket.
Definition: bsd_socket.c:2381
int_t socketFdIsSet(fd_set *fds, int_t s)
Check whether a descriptor is set.
int_t inet_aton(const char_t *cp, struct in_addr *inp)
Convert a dot-decimal string into binary form.
Definition: bsd_socket.c:3142
int_t shutdown(int_t s, int_t how)
The shutdown function disables sends or receives on a socket.
Definition: bsd_socket.c:2345
int_t setsockopt(int_t s, int_t level, int_t optname, const void *optval, socklen_t optlen)
The setsockopt function sets a socket option.
Definition: bsd_socket.c:1672
struct addrinfo ADDRINFO
Information about address of a service provider.
struct hostent * gethostbyname_r(const char_t *name, struct hostent *result, char_t *buf, size_t buflen, int_t *h_errnop)
Host name resolution (reentrant version)
Definition: bsd_socket.c:2669
struct linger * PLINGER
struct timeval * PTIMEVAL
struct sockaddr SOCKADDR
Socket address.
struct in_pktinfo IN_PKTINFO
IPv4 packet information.
struct addrinfo * PADDRINFO
int_t select(int_t nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timeval *timeout)
Determine the status of one or more sockets.
Definition: bsd_socket.c:2423
struct msghdr * PMSGHDR
void socketFdZero(fd_set *fds)
Initializes a descriptor set.
int_t getsockopt(int_t s, int_t level, int_t optname, void *optval, socklen_t *optlen)
The getsockopt function retrieves a socket option.
Definition: bsd_socket.c:1939
const char_t * inet_ntoa_r(struct in_addr in, char_t *buf, socklen_t buflen)
Convert a binary IPv4 address to dot-decimal notation (reentrant version)
Definition: bsd_socket.c:3194
struct cmsghdr * socketCmsgNextHdr(struct msghdr *msg, struct cmsghdr *cmsg)
Get next ancillary data header.
const struct in6_addr in6addr_any
Definition: bsd_socket.c:49
struct in_addr * PIN_ADDR
struct ip_mreq * PIP_MREQ
uint8_t type
Definition: coap_common.h:176
signed int int_t
Definition: compiler_port.h:49
char char_t
Definition: compiler_port.h:48
uint8_t data[]
Definition: ethernet.h:222
uint8_t protocol
Definition: ipv4.h:296
Ipv4Addr addr
Definition: nbns_common.h:123
uint8_t s
Definition: ndp.h:345
RTOS abstraction layer.
const uint8_t res[]
char_t name[]
Information about address of a service provider.
Definition: bsd_socket.h:483
int_t ai_family
Definition: bsd_socket.h:485
struct sockaddr * ai_addr
Definition: bsd_socket.h:489
socklen_t ai_addrlen
Definition: bsd_socket.h:488
int_t ai_flags
Definition: bsd_socket.h:484
int_t ai_protocol
Definition: bsd_socket.h:487
int_t ai_socktype
Definition: bsd_socket.h:486
char_t * ai_canonname
Definition: bsd_socket.h:490
struct addrinfo * ai_next
Definition: bsd_socket.h:491
Ancillary data header.
Definition: bsd_socket.h:426
int_t cmsg_level
Definition: bsd_socket.h:428
size_t cmsg_len
Definition: bsd_socket.h:427
int_t cmsg_type
Definition: bsd_socket.h:429
Set of sockets.
Definition: bsd_socket.h:460
int_t fd_count
Definition: bsd_socket.h:461
int_t fd_array[FD_SETSIZE]
Definition: bsd_socket.h:462
Information about a given host.
Definition: bsd_socket.h:471
uint16_t h_length
Definition: bsd_socket.h:473
uint16_t h_addrtype
Definition: bsd_socket.h:472
uint8_t h_addr[16]
Definition: bsd_socket.h:474
Structure that represents an IPv6 address.
Definition: bsd_socket.h:342
uint8_t s6_addr[16]
Definition: bsd_socket.h:343
IPv6 packet information.
Definition: bsd_socket.h:449
int ipi6_ifindex
Definition: bsd_socket.h:450
struct in6_addr ipi6_addr
Definition: bsd_socket.h:451
Structure that represents an IPv4 address.
Definition: bsd_socket.h:319
in_addr_t s_addr
Definition: bsd_socket.h:320
IPv4 packet information.
Definition: bsd_socket.h:438
struct in_addr ipi_addr
Definition: bsd_socket.h:440
int ipi_ifindex
Definition: bsd_socket.h:439
Scatter/gather array.
Definition: bsd_socket.h:399
void * iov_base
Definition: bsd_socket.h:400
size_t iov_len
Definition: bsd_socket.h:401
Multicast group information for IPv4 addresses.
Definition: bsd_socket.h:366
struct in_addr imr_interface
Definition: bsd_socket.h:368
struct in_addr imr_multiaddr
Definition: bsd_socket.h:367
Multicast group information for IPv6 addresses.
Definition: bsd_socket.h:377
struct in6_addr ipv6mr_multiaddr
Definition: bsd_socket.h:378
int_t ipv6mr_interface
Definition: bsd_socket.h:379
Linger structure.
Definition: bsd_socket.h:388
int_t l_onoff
Definition: bsd_socket.h:389
int_t l_linger
Definition: bsd_socket.h:390
Message header.
Definition: bsd_socket.h:410
size_t msg_controllen
Definition: bsd_socket.h:416
void * msg_name
Definition: bsd_socket.h:411
int_t msg_flags
Definition: bsd_socket.h:417
socklen_t msg_namelen
Definition: bsd_socket.h:412
int_t msg_iovlen
Definition: bsd_socket.h:414
struct iovec * msg_iov
Definition: bsd_socket.h:413
void * msg_control
Definition: bsd_socket.h:415
IPv6 address information.
Definition: bsd_socket.h:352
uint32_t sin6_flowinfo
Definition: bsd_socket.h:355
uint16_t sin6_port
Definition: bsd_socket.h:354
uint16_t sin6_family
Definition: bsd_socket.h:353
uint32_t sin6_scope_id
Definition: bsd_socket.h:357
struct in6_addr sin6_addr
Definition: bsd_socket.h:356
IPv4 address information.
Definition: bsd_socket.h:329
uint16_t sin_port
Definition: bsd_socket.h:331
struct in_addr sin_addr
Definition: bsd_socket.h:332
uint16_t sin_family
Definition: bsd_socket.h:330
uint8_t sin_zero[8]
Definition: bsd_socket.h:333
Socket address storage.
Definition: bsd_socket.h:308
uint16_t ss_family
Definition: bsd_socket.h:309
uint8_t ss_pad[26]
Definition: bsd_socket.h:310
Socket address.
Definition: bsd_socket.h:297
uint16_t sa_family
Definition: bsd_socket.h:298
uint8_t sa_data[14]
Definition: bsd_socket.h:299
Timeout structure.
Definition: bsd_socket.h:502
int32_t tv_sec
Definition: bsd_socket.h:503
int32_t tv_usec
Definition: bsd_socket.h:504
uint8_t length
Definition: tcp.h:368
uint8_t flags
Definition: tcp.h:351