Subversion Repositories HelenOS

Rev

Rev 4603 | Rev 4712 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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