Rev 4701 | Rev 4720 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4701 | Rev 4712 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2009 Lukas Mejdrech |
2 | * Copyright (c) 2009 Lukas Mejdrech |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @addtogroup socket |
29 | /** @addtogroup socket |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | 32 | ||
33 | /** @file |
33 | /** @file |
34 | * Socket application program interface (API). |
34 | * Socket application program interface (API). |
35 | * This is a part of the network application library. |
35 | * This is a part of the network application library. |
36 | * Based on the linux src/include/linux/socket.h header file and BSD socket interface. |
36 | * Based on the linux src/include/linux/socket.h header file and BSD socket interface. |
37 | */ |
37 | */ |
38 | 38 | ||
39 | #ifndef __NET_SOCKET_H__ |
39 | #ifndef __NET_SOCKET_H__ |
40 | #define __NET_SOCKET_H__ |
40 | #define __NET_SOCKET_H__ |
41 | 41 | ||
42 | #include <sys/types.h> |
- | |
43 | - | ||
44 | #include "byteorder.h" |
42 | #include "byteorder.h" |
45 | #include "in.h" |
43 | #include "in.h" |
46 | #include "inet.h" |
44 | #include "inet.h" |
47 | 45 | ||
48 | /** @name Address families definitions |
- | |
49 | */ |
- | |
50 | /*@{*/ |
- | |
51 | /** Unspecified address family. |
- | |
52 | */ |
- | |
53 | #define AF_UNSPEC 0 |
- | |
54 | - | ||
55 | /** Unix domain sockets address family. |
- | |
56 | */ |
- | |
57 | #define AF_UNIXL 1 |
- | |
58 | - | ||
59 | /** POSIX name for AF_UNIX address family. |
- | |
60 | */ |
- | |
61 | #define AF_LOCAL 1 |
- | |
62 | - | ||
63 | /** Internet IP Protocol address family. |
- | |
64 | */ |
- | |
65 | #define AF_INET 2 |
- | |
66 | - | ||
67 | /** Amateur Radio AX.25 address family. |
- | |
68 | */ |
- | |
69 | #define AF_AX25 3 |
- | |
70 | - | ||
71 | /** Novell IPX address family. |
- | |
72 | */ |
- | |
73 | #define AF_IPX 4 |
- | |
74 | - | ||
75 | /** AppleTalk DDP address family. |
- | |
76 | */ |
- | |
77 | #define AF_APPLETALK 5 |
- | |
78 | - | ||
79 | /** Amateur Radio NET/ROM address family. |
- | |
80 | */ |
- | |
81 | #define AF_NETROM 6 |
- | |
82 | - | ||
83 | /** Multiprotocol bridge address family. |
- | |
84 | */ |
- | |
85 | #define AF_BRIDGE 7 |
- | |
86 | - | ||
87 | /** ATM PVCs address family. |
- | |
88 | */ |
- | |
89 | #define AF_ATMPVC 8 |
- | |
90 | - | ||
91 | /** Reserved for X.25 project address family. |
- | |
92 | */ |
- | |
93 | #define AF_X25 9 |
- | |
94 | - | ||
95 | /** IP version 6 address family. |
- | |
96 | */ |
- | |
97 | #define AF_INET6 10 |
- | |
98 | - | ||
99 | /** Amateur Radio X.25 PLP address family. |
- | |
100 | */ |
- | |
101 | #define AF_ROSE 11 |
- | |
102 | - | ||
103 | /** Reserved for DECnet project address family. |
- | |
104 | */ |
- | |
105 | #define AF_DECnet 12 |
- | |
106 | - | ||
107 | /** Reserved for 802.2LLC project address family. |
- | |
108 | */ |
- | |
109 | #define AF_NETBEUI 13 |
- | |
110 | - | ||
111 | /** Security callback pseudo AF address family. |
- | |
112 | */ |
- | |
113 | #define AF_SECURITY 14 |
- | |
114 | - | ||
115 | /** PF_KEY key management API address family. |
- | |
116 | */ |
- | |
117 | #define AF_KEY 15 |
- | |
118 | - | ||
119 | /** Alias to emulate 4.4BSD address family. |
- | |
120 | */ |
- | |
121 | #define AF_NETLINK 16 |
- | |
122 | - | ||
123 | /** Packet family address family. |
- | |
124 | */ |
- | |
125 | #define AF_PACKET 17 |
- | |
126 | - | ||
127 | /** Ash address family. |
- | |
128 | */ |
- | |
129 | #define AF_ASH 18 |
- | |
130 | - | ||
131 | /** Acorn Econet address family. |
- | |
132 | */ |
- | |
133 | #define AF_ECONET 19 |
- | |
134 | - | ||
135 | /** ATM SVCs address family. |
- | |
136 | */ |
- | |
137 | #define AF_ATMSVC 20 |
- | |
138 | - | ||
139 | /** Linux SNA Project (nutters!) address family. |
- | |
140 | */ |
- | |
141 | #define AF_SNA 22 |
- | |
142 | - | ||
143 | /** IRDA sockets address family. |
- | |
144 | */ |
- | |
145 | #define AF_IRDA 23 |
- | |
146 | - | ||
147 | /** PPPoX sockets address family. |
- | |
148 | */ |
- | |
149 | #define AF_PPPOX 24 |
- | |
150 | - | ||
151 | /** Wanpipe API Sockets address family. |
- | |
152 | */ |
- | |
153 | #define AF_WANPIPE 25 |
- | |
154 | - | ||
155 | /** Linux LLC address family. |
- | |
156 | */ |
- | |
157 | #define AF_LLC 26 |
- | |
158 | - | ||
159 | /** Controller Area Network address family. |
- | |
160 | */ |
- | |
161 | #define AF_CAN 29 |
- | |
162 | - | ||
163 | /** TIPC sockets address family. |
- | |
164 | */ |
- | |
165 | #define AF_TIPC 30 |
- | |
166 | - | ||
167 | /** Bluetooth sockets address family. |
- | |
168 | */ |
- | |
169 | #define AF_BLUETOOTH 31 |
- | |
170 | - | ||
171 | /** IUCV sockets address family. |
- | |
172 | */ |
- | |
173 | #define AF_IUCV 32 |
- | |
174 | - | ||
175 | /** RxRPC sockets address family. |
- | |
176 | */ |
- | |
177 | #define AF_RXRPC 33 |
- | |
178 | - | ||
179 | /** Maximum address family. |
- | |
180 | */ |
- | |
181 | #define AF_MAX 34 |
- | |
182 | /*@}*/ |
- | |
183 | - | ||
184 | /** @name Protocol families definitions |
- | |
185 | * Same as address families. |
- | |
186 | */ |
- | |
187 | /*@{*/ |
- | |
188 | /** Unspecified protocol family. |
- | |
189 | */ |
- | |
190 | #define PF_UNSPEC AF_UNSPEC |
- | |
191 | - | ||
192 | /** Unix domain sockets protocol family. |
- | |
193 | */ |
- | |
194 | #define PF_UNIXL AF_UNIXL |
- | |
195 | - | ||
196 | /** POSIX name for AF_UNIX protocol family. |
- | |
197 | */ |
- | |
198 | #define PF_LOCAL AF_LOCAL |
- | |
199 | - | ||
200 | /** Internet IP Protocol protocol family. |
- | |
201 | */ |
- | |
202 | #define PF_INET AF_INET |
- | |
203 | - | ||
204 | /** Amateur Radio AX.25 protocol family. |
- | |
205 | */ |
- | |
206 | #define PF_AX25 AF_AX25 |
- | |
207 | - | ||
208 | /** Novell IPX protocol family. |
- | |
209 | */ |
- | |
210 | #define PF_IPX AF_IPX |
- | |
211 | - | ||
212 | /** AppleTalk DDP protocol family. |
- | |
213 | */ |
- | |
214 | #define PF_APPLETALK AF_APPLETALK |
- | |
215 | - | ||
216 | /** Amateur Radio NET/ROM protocol family. |
- | |
217 | */ |
- | |
218 | #define PF_NETROM AF_NETROM |
- | |
219 | - | ||
220 | /** Multiprotocol bridge protocol family. |
- | |
221 | */ |
- | |
222 | #define PF_BRIDGE AF_BRIDGE |
- | |
223 | - | ||
224 | /** ATM PVCs protocol family. |
- | |
225 | */ |
- | |
226 | #define PF_ATMPVC AF_ATMPVC |
- | |
227 | - | ||
228 | /** Reserved for X.25 project protocol family. |
- | |
229 | */ |
- | |
230 | #define PF_X25 AF_X25 |
- | |
231 | - | ||
232 | /** IP version 6 protocol family. |
- | |
233 | */ |
- | |
234 | #define PF_INET6 AF_INET6 |
- | |
235 | - | ||
236 | /** Amateur Radio X.25 PLP protocol family. |
- | |
237 | */ |
- | |
238 | #define PF_ROSE AF_ROSE |
- | |
239 | - | ||
240 | /** Reserved for DECnet project protocol family. |
- | |
241 | */ |
- | |
242 | #define PF_DECnet AF_DECnet |
- | |
243 | - | ||
244 | /** Reserved for 802.2LLC project protocol family. |
- | |
245 | */ |
- | |
246 | #define PF_NETBEUI AF_NETBEUI |
- | |
247 | - | ||
248 | /** Security callback pseudo AF protocol family. |
- | |
249 | */ |
- | |
250 | #define PF_SECURITY AF_SECURITY |
- | |
251 | - | ||
252 | /** PF_KEY key management API protocol family. |
- | |
253 | */ |
- | |
254 | #define PF_KEY AF_KEY |
- | |
255 | - | ||
256 | /** Alias to emulate 4.4BSD protocol family. |
- | |
257 | */ |
- | |
258 | #define PF_NETLINK AF_NETLINK |
- | |
259 | - | ||
260 | /** Packet family protocol family. |
- | |
261 | */ |
- | |
262 | #define PF_PACKET AF_PACKET |
- | |
263 | - | ||
264 | /** Ash protocol family. |
- | |
265 | */ |
- | |
266 | #define PF_ASH AF_ASH |
- | |
267 | - | ||
268 | /** Acorn Econet protocol family. |
- | |
269 | */ |
- | |
270 | #define PF_ECONET AF_ECONET |
- | |
271 | - | ||
272 | /** ATM SVCs protocol family. |
- | |
273 | */ |
- | |
274 | #define PF_ATMSVC AF_ATMSVC |
- | |
275 | - | ||
276 | /** Linux SNA Project (nutters!) protocol family. |
- | |
277 | */ |
- | |
278 | #define PF_SNA AF_SNA |
- | |
279 | - | ||
280 | /** IRDA sockets protocol family. |
- | |
281 | */ |
- | |
282 | #define PF_IRDA AF_IRDA |
- | |
283 | - | ||
284 | /** PPPoX sockets protocol family. |
- | |
285 | */ |
- | |
286 | #define PF_PPPOX AF_PPPOX |
- | |
287 | - | ||
288 | /** Wanpipe API Sockets protocol family. |
- | |
289 | */ |
- | |
290 | #define PF_WANPIPE AF_WANPIPE |
- | |
291 | - | ||
292 | /** Linux LLC protocol family. |
- | |
293 | */ |
- | |
294 | #define PF_LLC AF_LLC |
- | |
295 | - | ||
296 | /** Controller Area Network protocol family. |
- | |
297 | */ |
- | |
298 | #define PF_CAN AF_CAN |
- | |
299 | - | ||
300 | /** TIPC sockets protocol family. |
- | |
301 | */ |
- | |
302 | #define PF_TIPC AF_TIPC |
- | |
303 | - | ||
304 | /** Bluetooth sockets protocol family. |
- | |
305 | */ |
- | |
306 | #define PF_BLUETOOTH AF_BLUETOOTH |
- | |
307 | - | ||
308 | /** IUCV sockets protocol family. |
- | |
309 | */ |
- | |
310 | #define PF_IUCV AF_IUCV |
- | |
311 | - | ||
312 | /** RxRPC sockets protocol family. |
- | |
313 | */ |
- | |
314 | #define PF_RXRPC AF_RXRPC |
- | |
315 | - | ||
316 | /** Maximum protocol family. |
- | |
317 | */ |
- | |
318 | #define PF_MAX AF_MAX |
- | |
319 | /*@}*/ |
- | |
320 | - | ||
321 | /** @name Socket option levels definitions |
- | |
322 | * Thanks to BSD these must match IPPROTO_xxx |
- | |
323 | */ |
- | |
324 | /*@{*/ |
- | |
325 | - | ||
326 | /** IP socket option level. |
- | |
327 | */ |
- | |
328 | #define SOL_IP 0 |
- | |
329 | - | ||
330 | /** ICMP socket option level. |
- | |
331 | */ |
- | |
332 | #define SOL_ICMP 1 |
- | |
333 | - | ||
334 | /** TCP socket option level. |
- | |
335 | */ |
- | |
336 | #define SOL_TCP 6 |
- | |
337 | - | ||
338 | /** UDP socket option level. |
- | |
339 | */ |
- | |
340 | #define SOL_UDP 17 |
- | |
341 | - | ||
342 | /** IPV socket option level. |
- | |
343 | */ |
- | |
344 | #define SOL_IPV6 41 |
- | |
345 | - | ||
346 | /** ICMPV socket option level. |
- | |
347 | */ |
- | |
348 | #define SOL_ICMPV6 58 |
- | |
349 | - | ||
350 | /** SCTP socket option level. |
- | |
351 | */ |
- | |
352 | #define SOL_SCTP 132 |
- | |
353 | - | ||
354 | /** UDP-Lite (RFC 3828) socket option level. |
- | |
355 | */ |
- | |
356 | #define SOL_UDPLITE 136 |
- | |
357 | - | ||
358 | /** RAW socket option level. |
- | |
359 | */ |
- | |
360 | #define SOL_RAW 255 |
- | |
361 | - | ||
362 | /** IPX socket option level. |
- | |
363 | */ |
- | |
364 | #define SOL_IPX 256 |
- | |
365 | - | ||
366 | /** AX socket option level. |
- | |
367 | */ |
- | |
368 | #define SOL_AX25 257 |
- | |
369 | - | ||
370 | /** ATALK socket option level. |
- | |
371 | */ |
- | |
372 | #define SOL_ATALK 258 |
- | |
373 | - | ||
374 | /** NETROM socket option level. |
- | |
375 | */ |
- | |
376 | #define SOL_NETROM 259 |
- | |
377 | - | ||
378 | /** ROSE socket option level. |
- | |
379 | */ |
- | |
380 | #define SOL_ROSE 260 |
- | |
381 | - | ||
382 | /** DECNET socket option level. |
- | |
383 | */ |
- | |
384 | #define SOL_DECNET 261 |
- | |
385 | - | ||
386 | /** X25 socket option level. |
- | |
387 | */ |
- | |
388 | #define SOL_X25 262 |
- | |
389 | - | ||
390 | /** PACKET socket option level. |
- | |
391 | */ |
- | |
392 | #define SOL_PACKET 263 |
- | |
393 | - | ||
394 | /** ATM layer (cell level) socket option level. |
- | |
395 | */ |
- | |
396 | #define SOL_ATM 264 |
- | |
397 | - | ||
398 | /** ATM Adaption Layer (packet level) socket option level. |
- | |
399 | */ |
- | |
400 | #define SOL_AAL 265 |
- | |
401 | - | ||
402 | /** IRDA socket option level. |
- | |
403 | */ |
- | |
404 | #define SOL_IRDA 266 |
- | |
405 | - | ||
406 | /** NETBEUI socket option level. |
- | |
407 | */ |
- | |
408 | #define SOL_NETBEUI 267 |
- | |
409 | - | ||
410 | /** LLC socket option level. |
- | |
411 | */ |
- | |
412 | #define SOL_LLC 268 |
- | |
413 | - | ||
414 | /** DCCP socket option level. |
- | |
415 | */ |
- | |
416 | #define SOL_DCCP 269 |
- | |
417 | - | ||
418 | /** NETLINK socket option level. |
- | |
419 | */ |
- | |
420 | #define SOL_NETLINK 270 |
- | |
421 | - | ||
422 | /** TIPC socket option level. |
- | |
423 | */ |
- | |
424 | #define SOL_TIPC 271 |
- | |
425 | - | ||
426 | /** RXRPC socket option level. |
- | |
427 | */ |
- | |
428 | #define SOL_RXRPC 272 |
- | |
429 | - | ||
430 | /** PPPOL socket option level. |
- | |
431 | */ |
- | |
432 | #define SOL_PPPOL2TP 273 |
- | |
433 | - | ||
434 | /** BLUETOOTH socket option level. |
- | |
435 | */ |
- | |
436 | #define SOL_BLUETOOTH 274 |
- | |
437 | - | ||
438 | /*@}*/ |
- | |
439 | - | ||
440 | // |
- | |
441 | /* * IPX options. |
- | |
442 | */ |
- | |
443 | //#define IPX_TYPE 1 |
- | |
444 | - | ||
445 | /** Socket types. |
46 | #include "socket_codes.h" |
446 | */ |
- | |
447 | typedef enum sock_type{ |
- | |
448 | /** Stream (connection oriented) socket. |
- | |
449 | */ |
- | |
450 | SOCK_STREAM = 1, |
- | |
451 | /** Datagram (connectionless oriented) socket. |
- | |
452 | */ |
- | |
453 | SOCK_DGRAM = 2, |
- | |
454 | /** Raw socket. |
- | |
455 | */ |
- | |
456 | SOCK_RAW = 3 |
- | |
457 | } sock_type_t; |
- | |
458 | - | ||
459 | /** Type definition of the socket length. |
- | |
460 | */ |
- | |
461 | typedef int32_t socklen_t; |
- | |
462 | 47 | ||
463 | /** @name Socket application programming interface |
48 | /** @name Socket application programming interface |
464 | */ |
49 | */ |
465 | /*@{*/ |
50 | /*@{*/ |
466 | 51 | ||
467 | /** Creates a new socket. |
52 | /** Creates a new socket. |
468 | * @param domain The socket protocol family. Input parameter. |
53 | * @param domain The socket protocol family. Input parameter. |
469 | * @param type Socket type. Input parameter. |
54 | * @param type Socket type. Input parameter. |
470 | * @param protocol Socket protocol. Input parameter. |
55 | * @param protocol Socket protocol. Input parameter. |
471 | * @returns The socket identifier on success. |
56 | * @returns The socket identifier on success. |
472 | * @returns EPFNOTSUPPORT if the protocol family is not supported. |
57 | * @returns EPFNOTSUPPORT if the protocol family is not supported. |
473 | * @returns ESOCKNOTSUPPORT if the socket type is not supported. |
58 | * @returns ESOCKNOTSUPPORT if the socket type is not supported. |
474 | * @returns EPROTONOSUPPORT if the protocol is not supported. |
59 | * @returns EPROTONOSUPPORT if the protocol is not supported. |
475 | * @returns ENOMEM if there is not enough memory left. |
60 | * @returns ENOMEM if there is not enough memory left. |
476 | * @returns Other error codes as defined for the NET_SOCKET message. |
61 | * @returns Other error codes as defined for the NET_SOCKET message. |
477 | */ |
62 | */ |
478 | int socket( int domain, int type, int protocol ); |
63 | int socket( int domain, int type, int protocol ); |
479 | 64 | ||
480 | /** Binds the socket to a port address. |
65 | /** Binds the socket to a port address. |
481 | * @param socket_id Socket identifier. Input parameter. |
66 | * @param socket_id Socket identifier. Input parameter. |
482 | * @param my_addr The port address. Input parameter. |
67 | * @param my_addr The port address. Input parameter. |
483 | * @param addrlen The address length. Input parameter. |
68 | * @param addrlen The address length. Input parameter. |
484 | * @returns EOK on success. |
69 | * @returns EOK on success. |
485 | * @returns ENOTSOCK if the socket is not found. |
70 | * @returns ENOTSOCK if the socket is not found. |
486 | * @returns EBADMEM if the my_addr parameter is NULL. |
71 | * @returns EBADMEM if the my_addr parameter is NULL. |
487 | * @returns NO_DATA if the addlen parameter is zero (0). |
72 | * @returns NO_DATA if the addlen parameter is zero (0). |
488 | * @returns Other error codes as defined for the NET_SOCKET_BIND message. |
73 | * @returns Other error codes as defined for the NET_SOCKET_BIND message. |
489 | */ |
74 | */ |
490 | int bind( int socket_id, const struct sockaddr * my_addr, socklen_t addrlen ); |
75 | int bind( int socket_id, const struct sockaddr * my_addr, socklen_t addrlen ); |
491 | 76 | ||
492 | /** Sets the number of connections waiting to be accepted. |
77 | /** Sets the number of connections waiting to be accepted. |
493 | * @param socket_id Socket identifier. Input parameter. |
78 | * @param socket_id Socket identifier. Input parameter. |
494 | * @param backlog The maximum number of waiting sockets to be accepted. Input parameter. |
79 | * @param backlog The maximum number of waiting sockets to be accepted. Input parameter. |
495 | * @returns EOK on success. |
80 | * @returns EOK on success. |
496 | * @returns EINVAL if the backlog parameter is not positive (<=0). |
81 | * @returns EINVAL if the backlog parameter is not positive (<=0). |
497 | * @returns ENOTSOCK if the socket is not found. |
82 | * @returns ENOTSOCK if the socket is not found. |
498 | * @returns Other error codes as defined for the NET_SOCKET_LISTEN message. |
83 | * @returns Other error codes as defined for the NET_SOCKET_LISTEN message. |
499 | */ |
84 | */ |
500 | int listen( int socket_id, int backlog ); |
85 | int listen( int socket_id, int backlog ); |
501 | 86 | ||
502 | /** Accepts waiting socket. |
87 | /** Accepts waiting socket. |
503 | * Blocks until such a socket exists. |
88 | * Blocks until such a socket exists. |
504 | * @param socket_id Socket identifier. Input parameter. |
89 | * @param socket_id Socket identifier. Input parameter. |
505 | * @param cliaddr The remote client address. Output parameter. |
90 | * @param cliaddr The remote client address. Output parameter. |
506 | * @param addrlen The address length. Input parameter. |
91 | * @param addrlen The address length. Input parameter. |
507 | * @returns EOK on success. |
92 | * @returns EOK on success. |
508 | * @returns EBADMEM if the cliaddr or addrlen parameter is NULL. |
93 | * @returns EBADMEM if the cliaddr or addrlen parameter is NULL. |
509 | * @returns EINVAL if the backlog parameter is not positive (<=0). |
94 | * @returns EINVAL if the backlog parameter is not positive (<=0). |
510 | * @returns ENOTSOCK if the socket is not found. |
95 | * @returns ENOTSOCK if the socket is not found. |
511 | * @returns Other error codes as defined for the NET_SOCKET_ACCEPT message. |
96 | * @returns Other error codes as defined for the NET_SOCKET_ACCEPT message. |
512 | */ |
97 | */ |
513 | int accept( int socket_id, struct sockaddr * cliaddr, socklen_t * addrlen ); |
98 | int accept( int socket_id, struct sockaddr * cliaddr, socklen_t * addrlen ); |
514 | 99 | ||
515 | /** Connects socket to the remote server. |
100 | /** Connects socket to the remote server. |
516 | * @param socket_id Socket identifier. Input parameter. |
101 | * @param socket_id Socket identifier. Input parameter. |
517 | * @param serv_addr The remote server address. Input parameter. |
102 | * @param serv_addr The remote server address. Input parameter. |
518 | * @param addrlen The address length. Input parameter. |
103 | * @param addrlen The address length. Input parameter. |
519 | * @returns EOK on success. |
104 | * @returns EOK on success. |
520 | * @returns EBADMEM if the serv_addr parameter is NULL. |
105 | * @returns EBADMEM if the serv_addr parameter is NULL. |
521 | * @returns NO_DATA if the addlen parameter is zero (0). |
106 | * @returns NO_DATA if the addlen parameter is zero (0). |
522 | * @returns ENOTSOCK if the socket is not found. |
107 | * @returns ENOTSOCK if the socket is not found. |
523 | * @returns Other error codes as defined for the NET_SOCKET_CONNECT message. |
108 | * @returns Other error codes as defined for the NET_SOCKET_CONNECT message. |
524 | */ |
109 | */ |
525 | int connect( int socket_id, const struct sockaddr * serv_addr, socklen_t addrlen ); |
110 | int connect( int socket_id, const struct sockaddr * serv_addr, socklen_t addrlen ); |
526 | 111 | ||
527 | /** Closes the socket. |
112 | /** Closes the socket. |
528 | * @param socket_id Socket identifier. Input parameter. |
113 | * @param socket_id Socket identifier. Input parameter. |
529 | * @returns EOK on success. |
114 | * @returns EOK on success. |
530 | * @returns ENOTSOCK if the socket is not found. |
115 | * @returns ENOTSOCK if the socket is not found. |
531 | * @returns Other error codes as defined for the NET_SOCKET_CLOSE message. |
116 | * @returns Other error codes as defined for the NET_SOCKET_CLOSE message. |
532 | */ |
117 | */ |
533 | int closesocket( int socket_id ); |
118 | int closesocket( int socket_id ); |
534 | 119 | ||
535 | /** Sends data via the socket. |
120 | /** Sends data via the socket. |
536 | * @param socket_id Socket identifier. Input parameter. |
121 | * @param socket_id Socket identifier. Input parameter. |
537 | * @param data The data to be sent. Input parameter. |
122 | * @param data The data to be sent. Input parameter. |
538 | * @param datalength The data length. Input parameter. |
123 | * @param datalength The data length. Input parameter. |
539 | * @param flags Various send flags. Input parameter. |
124 | * @param flags Various send flags. Input parameter. |
540 | * @returns EOK on success. |
125 | * @returns EOK on success. |
541 | * @returns ENOTSOCK if the socket is not found. |
126 | * @returns ENOTSOCK if the socket is not found. |
542 | * @returns EBADMEM if the data parameter is NULL. |
127 | * @returns EBADMEM if the data parameter is NULL. |
543 | * @returns NO_DATA if the datalength parameter is zero (0). |
128 | * @returns NO_DATA if the datalength parameter is zero (0). |
544 | * @returns Other error codes as defined for the NET_SOCKET_SEND message. |
129 | * @returns Other error codes as defined for the NET_SOCKET_SEND message. |
545 | */ |
130 | */ |
546 | int send( int socket_id, void * data, size_t datalength, int flags ); |
131 | int send( int socket_id, void * data, size_t datalength, int flags ); |
547 | 132 | ||
548 | /** Sends data via the socket to the remote address. |
133 | /** Sends data via the socket to the remote address. |
549 | * Binds the socket to a free port if not already connected/bound. |
134 | * Binds the socket to a free port if not already connected/bound. |
550 | * @param socket_id Socket identifier. Input parameter. |
135 | * @param socket_id Socket identifier. Input parameter. |
551 | * @param data The data to be sent. Input parameter. |
136 | * @param data The data to be sent. Input parameter. |
552 | * @param datalength The data length. Input parameter. |
137 | * @param datalength The data length. Input parameter. |
553 | * @param flags Various send flags. Input parameter. |
138 | * @param flags Various send flags. Input parameter. |
554 | * @param toaddr The destination address. Input parameter. |
139 | * @param toaddr The destination address. Input parameter. |
555 | * @param addrlen The address length. Input parameter. |
140 | * @param addrlen The address length. Input parameter. |
556 | * @returns EOK on success. |
141 | * @returns EOK on success. |
557 | * @returns ENOTSOCK if the socket is not found. |
142 | * @returns ENOTSOCK if the socket is not found. |
558 | * @returns EBADMEM if the data or toaddr parameter is NULL. |
143 | * @returns EBADMEM if the data or toaddr parameter is NULL. |
559 | * @returns NO_DATA if the datalength or the addrlen parameter is zero (0). |
144 | * @returns NO_DATA if the datalength or the addrlen parameter is zero (0). |
560 | * @returns Other error codes as defined for the NET_SOCKET_SENDTO message. |
145 | * @returns Other error codes as defined for the NET_SOCKET_SENDTO message. |
561 | */ |
146 | */ |
562 | int sendto( int socket_id, const void * data, size_t datalength, int flags, const struct sockaddr * toaddr, socklen_t addrlen ); |
147 | int sendto( int socket_id, const void * data, size_t datalength, int flags, const struct sockaddr * toaddr, socklen_t addrlen ); |
563 | 148 | ||
564 | /** Receives data via the socket. |
149 | /** Receives data via the socket. |
565 | * @param socket_id Socket identifier. Input parameter. |
150 | * @param socket_id Socket identifier. Input parameter. |
566 | * @param data The data buffer to be filled. Output parameter. |
151 | * @param data The data buffer to be filled. Output parameter. |
567 | * @param datalength The data length. Input parameter. |
152 | * @param datalength The data length. Input parameter. |
568 | * @param flags Various receive flags. Input parameter. |
153 | * @param flags Various receive flags. Input parameter. |
569 | * @returns EOK on success. |
154 | * @returns EOK on success. |
570 | * @returns ENOTSOCK if the socket is not found. |
155 | * @returns ENOTSOCK if the socket is not found. |
571 | * @returns EBADMEM if the data parameter is NULL. |
156 | * @returns EBADMEM if the data parameter is NULL. |
572 | * @returns NO_DATA if the datalength parameter is zero (0). |
157 | * @returns NO_DATA if the datalength parameter is zero (0). |
573 | * @returns Other error codes as defined for the NET_SOCKET_RECV message. |
158 | * @returns Other error codes as defined for the NET_SOCKET_RECV message. |
574 | */ |
159 | */ |
575 | int recv( int socket_id, void * data, size_t datalength, int flags ); |
160 | int recv( int socket_id, void * data, size_t datalength, int flags ); |
576 | 161 | ||
577 | /** Receives data via the socket. |
162 | /** Receives data via the socket. |
578 | * @param socket_id Socket identifier. Input parameter. |
163 | * @param socket_id Socket identifier. Input parameter. |
579 | * @param data The data buffer to be filled. Output parameter. |
164 | * @param data The data buffer to be filled. Output parameter. |
580 | * @param datalength The data length. Input parameter. |
165 | * @param datalength The data length. Input parameter. |
581 | * @param flags Various receive flags. Input parameter. |
166 | * @param flags Various receive flags. Input parameter. |
582 | * @param fromaddr The source address. Output parameter. |
167 | * @param fromaddr The source address. Output parameter. |
583 | * @param addrlen The address length. The maximum address length is read. The actual address length is set. Input/output parameter. |
168 | * @param addrlen The address length. The maximum address length is read. The actual address length is set. Input/output parameter. |
584 | * @returns EOK on success. |
169 | * @returns EOK on success. |
585 | * @returns ENOTSOCK if the socket is not found. |
170 | * @returns ENOTSOCK if the socket is not found. |
586 | * @returns EBADMEM if the data or fromaddr parameter is NULL. |
171 | * @returns EBADMEM if the data or fromaddr parameter is NULL. |
587 | * @returns NO_DATA if the datalength or addrlen parameter is zero (0). |
172 | * @returns NO_DATA if the datalength or addrlen parameter is zero (0). |
588 | * @returns Other error codes as defined for the NET_SOCKET_RECVFROM message. |
173 | * @returns Other error codes as defined for the NET_SOCKET_RECVFROM message. |
589 | */ |
174 | */ |
590 | int recvfrom( int socket_id, void * data, size_t datalength, int flags, struct sockaddr * fromaddr, socklen_t * addrlen ); |
175 | int recvfrom( int socket_id, void * data, size_t datalength, int flags, struct sockaddr * fromaddr, socklen_t * addrlen ); |
591 | 176 | ||
592 | /** Gets socket option. |
177 | /** Gets socket option. |
593 | * @param socket_id Socket identifier. Input parameter. |
178 | * @param socket_id Socket identifier. Input parameter. |
594 | * @param level The socket options level. Input parameter. |
179 | * @param level The socket options level. Input parameter. |
595 | * @param optname The socket option to be get. Input parameter. |
180 | * @param optname The socket option to be get. Input parameter. |
596 | * @param value The value buffer to be filled. Output parameter. |
181 | * @param value The value buffer to be filled. Output parameter. |
597 | * @param optlen The value buffer length. The maximum length is read. The actual length is set. Input/output parameter. |
182 | * @param optlen The value buffer length. The maximum length is read. The actual length is set. Input/output parameter. |
598 | * @returns EOK on success. |
183 | * @returns EOK on success. |
599 | * @returns ENOTSOCK if the socket is not found. |
184 | * @returns ENOTSOCK if the socket is not found. |
600 | * @returns EBADMEM if the value or optlen parameter is NULL. |
185 | * @returns EBADMEM if the value or optlen parameter is NULL. |
601 | * @returns NO_DATA if the optlen parameter is zero (0). |
186 | * @returns NO_DATA if the optlen parameter is zero (0). |
602 | * @returns Other error codes as defined for the NET_SOCKET_GETSOCKOPT message. |
187 | * @returns Other error codes as defined for the NET_SOCKET_GETSOCKOPT message. |
603 | */ |
188 | */ |
604 | int getsockopt( int socket_id, int level, int optname, void * value, size_t * optlen ); |
189 | int getsockopt( int socket_id, int level, int optname, void * value, size_t * optlen ); |
605 | 190 | ||
606 | /** Sets socket option. |
191 | /** Sets socket option. |
607 | * @param socket_id Socket identifier. Input parameter. |
192 | * @param socket_id Socket identifier. Input parameter. |
608 | * @param level The socket options level. Input parameter. |
193 | * @param level The socket options level. Input parameter. |
609 | * @param optname The socket option to be set. Input parameter. |
194 | * @param optname The socket option to be set. Input parameter. |
610 | * @param value The value to be set. Input parameter. |
195 | * @param value The value to be set. Input parameter. |
611 | * @param optlen The value length. Input parameter. |
196 | * @param optlen The value length. Input parameter. |
612 | * @returns EOK on success. |
197 | * @returns EOK on success. |
613 | * @returns ENOTSOCK if the socket is not found. |
198 | * @returns ENOTSOCK if the socket is not found. |
614 | * @returns EBADMEM if the value parameter is NULL. |
199 | * @returns EBADMEM if the value parameter is NULL. |
615 | * @returns NO_DATA if the optlen parameter is zero (0). |
200 | * @returns NO_DATA if the optlen parameter is zero (0). |
616 | * @returns Other error codes as defined for the NET_SOCKET_SETSOCKOPT message. |
201 | * @returns Other error codes as defined for the NET_SOCKET_SETSOCKOPT message. |
617 | */ |
202 | */ |
618 | int setsockopt( int socket_id, int level, int optname, const void * value, size_t optlen ); |
203 | int setsockopt( int socket_id, int level, int optname, const void * value, size_t optlen ); |
619 | 204 | ||
620 | /*@}*/ |
205 | /*@}*/ |
621 | 206 | ||
622 | #endif |
207 | #endif |
623 | 208 | ||
624 | /** @} |
209 | /** @} |
625 | */ |
210 | */ |
626 | 211 |