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-2023 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.2.4
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_ICMPV6 58
101 
102 //Ethernet protocol identifiers
103 #define ETH_P_ALL 0x0000
104 #define ETH_P_IP 0x0800
105 #define ETH_P_ARP 0x0806
106 #define ETH_P_IPV6 0x86DD
107 
108 //Option levels
109 #define SOL_SOCKET 0xFFFF
110 
111 //Common addresses
112 #define INADDR_ANY 0x00000000
113 #define INADDR_LOOPBACK 0x7F000001
114 #define INADDR_BROADCAST 0xFFFFFFFF
115 
116 //Flags used by I/O functions
117 #define MSG_PEEK 0x02
118 #define MSG_DONTROUTE 0x04
119 #define MSG_WAITALL 0x08
120 #define MSG_DONTWAIT 0x01
121 
122 //Flags used by shutdown function
123 #define SD_RECEIVE 0
124 #define SD_SEND 1
125 #define SD_BOTH 2
126 
127 //Flags used by shutdown function (alias)
128 #define SHUT_RD SD_RECEIVE
129 #define SHUT_WR SD_SEND
130 #define SHUT_RDWR SD_BOTH
131 
132 //Socket level options
133 #define SO_REUSEADDR 0x0004
134 #define SO_KEEPALIVE 0x0008
135 #define SO_DONTROUTE 0x0010
136 #define SO_BROADCAST 0x0020
137 #define SO_LINGER 0x0080
138 #define SO_SNDBUF 0x1001
139 #define SO_RCVBUF 0x1002
140 #define SO_SNDTIMEO 0x1005
141 #define SO_RCVTIMEO 0x1006
142 #define SO_ERROR 0x1007
143 #define SO_TYPE 0x1008
144 #define SO_MAX_MSG_SIZE 0x2003
145 #define SO_BINDTODEVICE 0x3000
146 
147 //IP level options
148 #define IP_TOS 1
149 #define IP_TTL 2
150 #define IP_PKTINFO 8
151 #define IP_MULTICAST_TTL 33
152 
153 //TCP level options
154 #define TCP_NODELAY 0x0001
155 #define TCP_MAXSEG 0x0002
156 #define TCP_KEEPIDLE 0x0004
157 #define TCP_KEEPINTVL 0x0005
158 #define TCP_KEEPCNT 0x0006
159 
160 //IP TOS option
161 #define IPTOS_LOWDELAY 0x10
162 #define IPTOS_THROUGHPUT 0x08
163 #define IPTOS_RELIABILITY 0x04
164 
165 //IOCTL commands
166 #define FIONBIO 126
167 #define FIONREAD 127
168 #define FIONWRITE 121
169 #define FIONSPACE 120
170 
171 //FCNTL commands
172 #define F_GETFL 3
173 #define F_SETFL 4
174 
175 //FCNTL flags
176 #define O_NONBLOCK 0x0004
177 
178 //Flags used by getaddrinfo
179 #define AI_PASSIVE 0x01
180 #define AI_CANONNAME 0x02
181 #define AI_NUMERICHOST 0x04
182 #define AI_NUMERICSERV 0x08
183 #define AI_ALL 0x10
184 #define AI_ADDRCONFIG 0x20
185 #define AI_V4MAPPED 0x40
186 
187 //Flags used by getnameinfo
188 #define NI_NOFQDN 0x01
189 #define NI_NUMERICHOST 0x02
190 #define NI_NAMEREQD 0x04
191 #define NI_NUMERICSERV 0x08
192 #define NI_DGRAM 0x10
193 
194 //Return values
195 #define SOCKET_SUCCESS 0
196 #define SOCKET_ERROR (-1)
197 
198 //Return values used by getaddrinfo and getnameinfo
199 #define EAI_ADDRFAMILY 1
200 #define EAI_AGAIN 2
201 #define EAI_BADFLAGS 3
202 #define EAI_FAIL 4
203 #define EAI_FAMILY 5
204 #define EAI_MEMORY 6
205 #define EAI_NODATA 7
206 #define EAI_NONAME 8
207 #define EAI_SERVICE 9
208 #define EAI_SOCKTYPE 10
209 #define EAI_SYSTEM 11
210 #define EAI_OVERFLOW 12
211 
212 //Error codes
213 #define EINTR 4
214 #define EAGAIN 11
215 #define EWOULDBLOCK 11
216 #define EFAULT 14
217 #define EINVAL 22
218 #define EINPROGRESS 36
219 #define ETIMEDOUT 60
220 #define ENAMETOOLONG 63
221 #define ENOPROTOOPT 92
222 #define ECONNRESET 104
223 #define EISCONN 106
224 #define ENOTCONN 107
225 #define ESHUTDOWN 108
226 #define ECONNREFUSED 111
227 
228 //Error codes used by gethostbyname_r
229 #define NETDB_SUCCESS 0
230 #define HOST_NOT_FOUND 1
231 #define TRY_AGAIN 2
232 #define NO_RECOVERY 3
233 #define NO_ADDRESS 4
234 
235 //Return codes
236 #define INADDR_NONE ((in_addr_t) (-1))
237 
238 //Maximum length for string representation of IPv4 address
239 #define INET_ADDRSTRLEN 16
240 
241 //Maximum length for string representation of IPv6 address
242 #define INET6_ADDRSTRLEN 40
243 
244 //C++ guard
245 #ifdef __cplusplus
246 extern "C" {
247 #endif
248 
249 
250 /**
251  * @brief Length type
252  **/
253 
254 typedef int_t socklen_t;
255 
256 
257 /**
258  * @brief IPv4 address
259  **/
260 
261 typedef uint32_t in_addr_t;
262 
263 
264 /**
265  * @brief Socket address
266  **/
267 
268 typedef struct sockaddr
269 {
270  uint16_t sa_family;
271  uint8_t sa_data[14];
273 
274 
275 /**
276  * @brief Structure that represents an IPv4 address
277  **/
278 
279 typedef struct in_addr
280 {
283 
284 
285 /**
286  * @brief IPv4 address information
287  **/
288 
289 typedef struct sockaddr_in
290 {
291  uint16_t sin_family;
292  uint16_t sin_port;
293  struct in_addr sin_addr;
294  uint8_t sin_zero[8];
296 
297 
298 /**
299  * @brief Structure that represents an IPv6 address
300  **/
301 
302 typedef struct in6_addr
303 {
304  uint8_t s6_addr[16];
306 
307 
308 /**
309  * @brief IPv6 address information
310  **/
311 
312 typedef struct sockaddr_in6
313 {
314  uint16_t sin6_family;
315  uint16_t sin6_port;
316  struct in6_addr sin6_addr;
318 
319 
320 /**
321  * @brief Scatter/gather array
322  **/
323 
324 struct iovec
325 {
326  void *iov_base;
327  size_t iov_len;
328 };
329 
330 
331 /**
332  * @brief Message header
333  **/
334 
335 struct msghdr
336 {
337  void *msg_name;
339  struct iovec *msg_iov;
341  void *msg_control;
344 };
345 
346 
347 /**
348  * @brief Ancillary data header
349  **/
350 
351 struct cmsghdr
352 {
353  size_t cmsg_len;
356 };
357 
358 
359 /**
360  * @brief Packet information
361  **/
362 
364 {
366  struct in_addr ipi_addr;
367 };
368 
369 
370 /**
371  * @brief Set of sockets
372  **/
373 
374 typedef struct fd_set
375 {
379 
380 
381 /**
382  * @brief Information about a given host
383  **/
384 
385 typedef struct hostent
386 {
387  uint16_t h_addrtype;
388  uint16_t h_length;
389  uint8_t h_addr[16];
391 
392 
393 /**
394  * @brief Information about address of a service provider
395  **/
396 
397 typedef struct addrinfo
398 {
404  struct sockaddr *ai_addr;
406  struct addrinfo *ai_next;
408 
409 
410 #ifndef _TIMEVAL_DEFINED
411 
412 /**
413  * @brief Timeout structure
414  **/
415 
416 typedef struct timeval
417 {
418  int32_t tv_sec;
419  int32_t tv_usec;
421 
422 #endif
423 
424 
425 //Forward declaration of functions
426 struct cmsghdr *socketCmsgFirstHdr(struct msghdr *msg);
427 struct cmsghdr *socketCmsgNextHdr(struct msghdr *msg, struct cmsghdr *cmsg);
428 
429 //Macros for manipulating ancillary data object information
430 #define CMSG_DATA(cmsg) ((uint8_t *) (cmsg) + sizeof(struct cmsghdr))
431 #define CMSG_ALIGN(len) (((len) + sizeof(int_t) - 1) & ~(sizeof(int_t) - 1))
432 #define CMSG_SPACE(len) (sizeof(struct cmsghdr) + CMSG_ALIGN(len))
433 #define CMSG_LEN(len) (sizeof(struct cmsghdr) + (len))
434 #define CMSG_FIRSTHDR(msg) socketCmsgFirstHdr(msg)
435 #define CMSG_NXTHDR(msg, cmsg) socketCmsgNextHdr(msg, cmsg)
436 
437 //Forward declaration of functions
438 void socketFdZero(fd_set *fds);
439 void socketFdSet(fd_set *fds, int_t s);
440 void socketFdClr(fd_set *fds, int_t s);
442 
443 //Macros for manipulating and checking descriptor sets
444 #define FD_ZERO(fds) socketFdZero(fds)
445 #define FD_SET(s, fds) socketFdSet(fds, s)
446 #define FD_CLR(s, fds) socketFdClr(fds, s)
447 #define FD_ISSET(s, fds) socketFdIsSet(fds, s)
448 
449 //BSD socket related constants
450 extern const struct in6_addr in6addr_any;
451 extern const struct in6_addr in6addr_loopback;
452 
453 //BSD socket related functions
455 int_t bind(int_t s, const struct sockaddr *addr, socklen_t addrlen);
456 int_t connect(int_t s, const struct sockaddr *addr, socklen_t addrlen);
457 int_t listen(int_t s, int_t backlog);
458 int_t accept(int_t s, struct sockaddr *addr, socklen_t *addrlen);
459 int_t send(int_t s, const void *data, size_t length, int_t flags);
460 
461 int_t sendto(int_t s, const void *data, size_t length, int_t flags,
462  const struct sockaddr *addr, socklen_t addrlen);
463 
464 int_t recv(int_t s, void *data, size_t size, int_t flags);
465 
466 int_t recvfrom(int_t s, void *data, size_t size, int_t flags,
467  struct sockaddr *addr, socklen_t *addrlen);
468 
469 int_t recvmsg(int_t s, struct msghdr *msg, int_t flags);
470 
471 int_t getsockname(int_t s, struct sockaddr *addr, socklen_t *addrlen);
472 int_t getpeername(int_t s, struct sockaddr *addr, socklen_t *addrlen);
473 
474 int_t setsockopt(int_t s, int_t level, int_t optname, const void *optval,
475  socklen_t optlen);
476 
477 int_t getsockopt(int_t s, int_t level, int_t optname, void *optval,
478  socklen_t *optlen);
479 
480 int_t ioctlsocket(int_t s, uint32_t cmd, void *arg);
481 int_t fcntl(int_t s, int_t cmd, void *arg);
482 
483 int_t shutdown(int_t s, int_t how);
485 
486 int_t select(int_t nfds, fd_set *readfds, fd_set *writefds,
487  fd_set *exceptfds, const struct timeval *timeout);
488 
489 int_t gethostname(char_t *name, size_t len);
490 struct hostent *gethostbyname(const char_t *name);
491 
492 struct hostent *gethostbyname_r(const char_t *name, struct hostent *result,
493  char_t *buf, size_t buflen, int_t *h_errnop);
494 
495 int_t getaddrinfo(const char_t *node, const char_t *service,
496  const struct addrinfo *hints, struct addrinfo **res);
497 
498 void freeaddrinfo(struct addrinfo *res);
499 
500 int_t getnameinfo(const struct sockaddr *addr, socklen_t addrlen,
501  char_t *host, size_t hostlen, char_t *serv, size_t servlen, int flags);
502 
503 in_addr_t inet_addr(const char_t *cp);
504 
505 int_t inet_aton(const char_t *cp, struct in_addr *inp);
506 const char_t *inet_ntoa(struct in_addr in);
507 const char_t *inet_ntoa_r(struct in_addr in, char_t *buf, socklen_t buflen);
508 
509 int_t inet_pton(int_t af, const char_t *src, void *dst);
510 const char_t *inet_ntop(int_t af, const void *src, char_t *dst, socklen_t size);
511 
512 //C++ guard
513 #ifdef __cplusplus
514 }
515 #endif
516 
517 #endif
518 #endif
int_t listen(int_t s, int_t backlog)
Place a socket in the listening state.
Definition: bsd_socket.c:316
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:63
uint8_t length
Definition: coap_common.h:193
struct sockaddr * ai_addr
Definition: bsd_socket.h:404
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:2327
struct addrinfo * PADDRINFO
int_t socklen_t
Length type.
Definition: bsd_socket.h:254
Ancillary data header.
Definition: bsd_socket.h:352
int_t fcntl(int_t s, int_t cmd, void *arg)
Perform specific operation.
Definition: bsd_socket.c:1860
uint32_t in_addr_t
IPv4 address.
Definition: bsd_socket.h:261
uint8_t sin_zero[8]
Definition: bsd_socket.h:294
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:2253
struct in6_addr IN6_ADDR
Structure that represents an IPv6 address.
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:451
uint8_t data[]
Definition: ethernet.h:220
struct in_addr IN_ADDR
Structure that represents an IPv4 address.
signed int int_t
Definition: compiler_port.h:49
void * iov_base
Definition: bsd_socket.h:326
uint16_t sin_family
Definition: bsd_socket.h:291
size_t iov_len
Definition: bsd_socket.h:327
int_t closesocket(int_t s)
The closesocket function closes an existing socket.
Definition: bsd_socket.c:1971
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:2776
const struct in6_addr in6addr_any
Definition: bsd_socket.c:47
Set of sockets.
Definition: bsd_socket.h:375
struct timeval * PTIMEVAL
socklen_t msg_namelen
Definition: bsd_socket.h:338
struct in6_addr sin6_addr
Definition: bsd_socket.h:316
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:2876
void * msg_control
Definition: bsd_socket.h:341
struct sockaddr_in6 SOCKADDR_IN6
IPv6 address information.
struct cmsghdr * socketCmsgFirstHdr(struct msghdr *msg)
Get first ancillary data header.
int_t ioctlsocket(int_t s, uint32_t cmd, void *arg)
Control the I/O mode of a socket.
Definition: bsd_socket.c:1760
char_t name[]
int_t ai_flags
Definition: bsd_socket.h:399
const uint8_t res[]
IPv4 address information.
Definition: bsd_socket.h:290
int_t cmsg_level
Definition: bsd_socket.h:354
void socketFdClr(fd_set *fds, int_t s)
Remove a descriptor from an existing set.
void * msg_name
Definition: bsd_socket.h:337
uint8_t h_addr[16]
Definition: bsd_socket.h:389
uint8_t level
Definition: tls.h:1800
void socketFdSet(fd_set *fds, int_t s)
Add a descriptor to an existing set.
Structure that represents an IPv6 address.
Definition: bsd_socket.h:303
int_t getsockname(int_t s, struct sockaddr *addr, socklen_t *addrlen)
Retrieves the local name for a socket.
Definition: bsd_socket.c:916
uint16_t sa_family
Definition: bsd_socket.h:270
struct timeval TIMEVAL
Timeout structure.
int32_t tv_sec
Definition: bsd_socket.h:418
int ipi_ifindex
Definition: bsd_socket.h:365
int_t fd_count
Definition: bsd_socket.h:376
struct in_addr * PIN_ADDR
struct cmsghdr * socketCmsgNextHdr(struct msghdr *msg, struct cmsghdr *cmsg)
Get next ancillary data header.
Socket address.
Definition: bsd_socket.h:269
char_t type
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:666
int_t ai_protocol
Definition: bsd_socket.h:402
IPv6 address information.
Definition: bsd_socket.h:313
uint8_t protocol
Structure that represents an IPv4 address.
Definition: bsd_socket.h:280
uint16_t h_length
Definition: bsd_socket.h:388
void socketFdZero(fd_set *fds)
Initializes a descriptor set.
struct sockaddr_in SOCKADDR_IN
IPv4 address information.
uint8_t sa_data[14]
Definition: bsd_socket.h:271
struct sockaddr_in * PSOCKADDR_IN
struct hostent HOSTENT
Information about a given host.
int_t msg_iovlen
Definition: bsd_socket.h:340
int_t bind(int_t s, const struct sockaddr *addr, socklen_t addrlen)
Associate a local address with a socket.
Definition: bsd_socket.c:105
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:2690
Message header.
Definition: bsd_socket.h:336
struct hostent * PHOSTENT
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:2013
int_t fd_array[FD_SETSIZE]
Definition: bsd_socket.h:377
const struct in6_addr in6addr_loopback
Definition: bsd_socket.c:50
uint16_t sin6_family
Definition: bsd_socket.h:314
int32_t tv_usec
Definition: bsd_socket.h:419
socklen_t ai_addrlen
Definition: bsd_socket.h:403
struct addrinfo ADDRINFO
Information about address of a service provider.
int_t gethostname(char_t *name, size_t len)
Get system host name.
Definition: bsd_socket.c:2189
struct sockaddr * PSOCKADDR
in_addr_t s_addr
Definition: bsd_socket.h:281
uint8_t flags
Definition: tcp.h:349
int_t connect(int_t s, const struct sockaddr *addr, socklen_t addrlen)
Establish a connection to a specified socket.
Definition: bsd_socket.c:200
int_t recvmsg(int_t s, struct msghdr *msg, int_t flags)
Receive a message.
Definition: bsd_socket.c:766
char char_t
Definition: compiler_port.h:48
struct in6_addr * PIN6_ADDR
struct in_addr ipi_addr
Definition: bsd_socket.h:366
Information about a given host.
Definition: bsd_socket.h:386
Scatter/gather array.
Definition: bsd_socket.h:325
int_t socketFdIsSet(fd_set *fds, int_t s)
Check whether a descriptor is set.
size_t cmsg_len
Definition: bsd_socket.h:353
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:2594
const char_t * inet_ntoa(struct in_addr in)
Convert a binary IPv4 address to dot-decimal notation.
Definition: bsd_socket.c:2759
struct sockaddr SOCKADDR
Socket address.
void freeaddrinfo(struct addrinfo *res)
Free socket address structures.
Definition: bsd_socket.c:2565
Timeout structure.
Definition: bsd_socket.h:417
uint16_t sin_port
Definition: bsd_socket.h:292
int_t accept(int_t s, struct sockaddr *addr, socklen_t *addrlen)
Permit an incoming connection attempt on a socket.
Definition: bsd_socket.c:354
uint16_t sin6_port
Definition: bsd_socket.h:315
struct in_addr sin_addr
Definition: bsd_socket.h:293
#define FD_SET(s, fds)
Definition: bsd_socket.h:445
int_t ai_socktype
Definition: bsd_socket.h:401
uint8_t s
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:2804
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:1106
struct iovec * msg_iov
Definition: bsd_socket.h:339
Ipv4Addr addr
Definition: nbns_common.h:121
int_t cmsg_type
Definition: bsd_socket.h:355
int_t inet_aton(const char_t *cp, struct in_addr *inp)
Convert a dot-decimal string into binary form.
Definition: bsd_socket.c:2724
struct hostent * gethostbyname(const char_t *name)
Host name resolution.
Definition: bsd_socket.c:2230
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:510
int_t ai_family
Definition: bsd_socket.h:400
size_t msg_controllen
Definition: bsd_socket.h:342
int_t recv(int_t s, void *data, size_t size, int_t flags)
Receive data from a connected socket.
Definition: bsd_socket.c:618
#define FD_SETSIZE
Definition: bsd_socket.h:43
RTOS abstraction layer.
struct fd_set * PFD_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:1426
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:1010
struct sockaddr_in6 * PSOCKADDR_IN6
Information about address of a service provider.
Definition: bsd_socket.h:398
int_t msg_flags
Definition: bsd_socket.h:343
uint8_t s6_addr[16]
Definition: bsd_socket.h:304
struct fd_set fd_set
Set of sockets.
int_t shutdown(int_t s, int_t how)
The shutdown function disables sends or receives on a socket.
Definition: bsd_socket.c:1935
uint16_t h_addrtype
Definition: bsd_socket.h:387
struct addrinfo * ai_next
Definition: bsd_socket.h:406
Packet information.
Definition: bsd_socket.h:364
char_t * ai_canonname
Definition: bsd_socket.h:405