Subversion Repositories HelenOS

Rev

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

Rev 4243 Rev 4578
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 net
29
/** @addtogroup socket
30
 *  @{
30
 *  @{
31
 */
31
 */
32
 
32
 
33
/** @file
33
/** @file
34
 *  Common socket constants.
34
 *  Socket application program interface (API).
-
 
35
 *  This is a part of the network application library.
35
 *  Based on the linux src/include/linux/socket.h header file.
36
 *  Based on the linux src/include/linux/socket.h header file and BSD socket interface.
36
 */
37
 */
37
 
38
 
38
#ifndef __NET_SOCKET_H__
39
#ifndef __NET_SOCKET_H__
39
#define __NET_SOCKET_H__
40
#define __NET_SOCKET_H__
40
 
41
 
-
 
42
#include <sys/types.h>
-
 
43
 
-
 
44
#include "in.h"
-
 
45
#include "inet.h"
-
 
46
 
41
/* Supported address families. */
47
/* Supported address families. */
42
/** Unspecified address family.
48
/** Unspecified address family.
43
 */
49
 */
44
#define AF_UNSPEC   0
50
#define AF_UNSPEC   0
45
 
51
 
46
/** Unix domain sockets address family.
52
/** Unix domain sockets address family.
47
 */
53
 */
48
#define AF_UNIXL    1
54
#define AF_UNIXL    1
49
 
55
 
50
/** POSIX name for AF_UNIX address family.
56
/** POSIX name for AF_UNIX address family.
51
 */
57
 */
52
#define AF_LOCAL    1
58
#define AF_LOCAL    1
53
 
59
 
54
/** Internet IP Protocol address family.
60
/** Internet IP Protocol address family.
55
 */
61
 */
56
#define AF_INET     2
62
#define AF_INET     2
57
 
63
 
58
/** Amateur Radio AX.25 address family.
64
/** Amateur Radio AX.25 address family.
59
 */
65
 */
60
#define AF_AX25     3
66
#define AF_AX25     3
61
 
67
 
62
/** Novell IPX address family.
68
/** Novell IPX address family.
63
 */
69
 */
64
#define AF_IPX      4
70
#define AF_IPX      4
65
 
71
 
66
/** AppleTalk DDP address family.
72
/** AppleTalk DDP address family.
67
 */
73
 */
68
#define AF_APPLETALK    5
74
#define AF_APPLETALK    5
69
 
75
 
70
/** Amateur Radio NET/ROM address family.
76
/** Amateur Radio NET/ROM address family.
71
 */
77
 */
72
#define AF_NETROM   6
78
#define AF_NETROM   6
73
 
79
 
74
/** Multiprotocol bridge address family.
80
/** Multiprotocol bridge address family.
75
 */
81
 */
76
#define AF_BRIDGE   7
82
#define AF_BRIDGE   7
77
 
83
 
78
/** ATM PVCs address family.
84
/** ATM PVCs address family.
79
 */
85
 */
80
#define AF_ATMPVC   8
86
#define AF_ATMPVC   8
81
 
87
 
82
/** Reserved for X.25 project address family.
88
/** Reserved for X.25 project address family.
83
 */
89
 */
84
#define AF_X25      9
90
#define AF_X25      9
85
 
91
 
86
/** IP version 6 address family.
92
/** IP version 6 address family.
87
 */
93
 */
88
#define AF_INET6    10
94
#define AF_INET6    10
89
 
95
 
90
/** Amateur Radio X.25 PLP address family.
96
/** Amateur Radio X.25 PLP address family.
91
 */
97
 */
92
#define AF_ROSE     11
98
#define AF_ROSE     11
93
 
99
 
94
/** Reserved for DECnet project address family.
100
/** Reserved for DECnet project address family.
95
 */
101
 */
96
#define AF_DECnet   12
102
#define AF_DECnet   12
97
 
103
 
98
/** Reserved for 802.2LLC project address family.
104
/** Reserved for 802.2LLC project address family.
99
 */
105
 */
100
#define AF_NETBEUI  13
106
#define AF_NETBEUI  13
101
 
107
 
102
/** Security callback pseudo AF address family.
108
/** Security callback pseudo AF address family.
103
 */
109
 */
104
#define AF_SECURITY 14
110
#define AF_SECURITY 14
105
 
111
 
106
/** PF_KEY key management API address family.
112
/** PF_KEY key management API address family.
107
 */
113
 */
108
#define AF_KEY      15
114
#define AF_KEY      15
109
 
115
 
110
/** Alias to emulate 4.4BSD address family.
116
/** Alias to emulate 4.4BSD address family.
111
 */
117
 */
112
#define AF_NETLINK  16
118
#define AF_NETLINK  16
113
 
119
 
114
/** Packet family address family.
120
/** Packet family address family.
115
 */
121
 */
116
#define AF_PACKET   17
122
#define AF_PACKET   17
117
 
123
 
118
/** Ash address family.
124
/** Ash address family.
119
 */
125
 */
120
#define AF_ASH      18
126
#define AF_ASH      18
121
 
127
 
122
/** Acorn Econet address family.
128
/** Acorn Econet address family.
123
 */
129
 */
124
#define AF_ECONET   19
130
#define AF_ECONET   19
125
 
131
 
126
/** ATM SVCs address family.
132
/** ATM SVCs address family.
127
 */
133
 */
128
#define AF_ATMSVC   20
134
#define AF_ATMSVC   20
129
 
135
 
130
/** Linux SNA Project (nutters!) address family.
136
/** Linux SNA Project (nutters!) address family.
131
 */
137
 */
132
#define AF_SNA      22
138
#define AF_SNA      22
133
 
139
 
134
/** IRDA sockets address family.
140
/** IRDA sockets address family.
135
 */
141
 */
136
#define AF_IRDA     23
142
#define AF_IRDA     23
137
 
143
 
138
/** PPPoX sockets address family.
144
/** PPPoX sockets address family.
139
 */
145
 */
140
#define AF_PPPOX    24
146
#define AF_PPPOX    24
141
 
147
 
142
/** Wanpipe API Sockets address family.
148
/** Wanpipe API Sockets address family.
143
 */
149
 */
144
#define AF_WANPIPE  25
150
#define AF_WANPIPE  25
145
 
151
 
146
/** Linux LLC address family.
152
/** Linux LLC address family.
147
 */
153
 */
148
#define AF_LLC      26
154
#define AF_LLC      26
149
 
155
 
150
/** Controller Area Network address family.
156
/** Controller Area Network address family.
151
 */
157
 */
152
#define AF_CAN      29
158
#define AF_CAN      29
153
 
159
 
154
/** TIPC sockets address family.
160
/** TIPC sockets address family.
155
 */
161
 */
156
#define AF_TIPC     30
162
#define AF_TIPC     30
157
 
163
 
158
/** Bluetooth sockets address family.
164
/** Bluetooth sockets address family.
159
 */
165
 */
160
#define AF_BLUETOOTH    31
166
#define AF_BLUETOOTH    31
161
 
167
 
162
/** IUCV sockets address family.
168
/** IUCV sockets address family.
163
 */
169
 */
164
#define AF_IUCV     32
170
#define AF_IUCV     32
165
 
171
 
166
/** RxRPC sockets address family.
172
/** RxRPC sockets address family.
167
 */
173
 */
168
#define AF_RXRPC    33
174
#define AF_RXRPC    33
169
 
175
 
170
/** Maximum address family.
176
/** Maximum address family.
171
 */
177
 */
172
#define AF_MAX      34
178
#define AF_MAX      34
173
 
179
 
174
/* Protocol families, same as address families. */
180
/* Protocol families, same as address families. */
175
/*
181
 
176
#define PF_UNSPEC   AF_UNSPEC
182
#define PF_UNSPEC   AF_UNSPEC
177
#define PF_UNIX     AF_UNIX
183
#define PF_UNIX     AF_UNIX
178
#define PF_LOCAL    AF_LOCAL
184
#define PF_LOCAL    AF_LOCAL
179
#define PF_INET     AF_INET
185
#define PF_INET     AF_INET
180
#define PF_AX25     AF_AX25
186
#define PF_AX25     AF_AX25
181
#define PF_IPX      AF_IPX
187
#define PF_IPX      AF_IPX
182
#define PF_APPLETALK    AF_APPLETALK
188
#define PF_APPLETALK    AF_APPLETALK
183
#define PF_NETROM   AF_NETROM
189
#define PF_NETROM   AF_NETROM
184
#define PF_BRIDGE   AF_BRIDGE
190
#define PF_BRIDGE   AF_BRIDGE
185
#define PF_ATMPVC   AF_ATMPVC
191
#define PF_ATMPVC   AF_ATMPVC
186
#define PF_X25      AF_X25
192
#define PF_X25      AF_X25
187
#define PF_INET6    AF_INET6
193
#define PF_INET6    AF_INET6
188
#define PF_ROSE     AF_ROSE
194
#define PF_ROSE     AF_ROSE
189
#define PF_DECnet   AF_DECnet
195
#define PF_DECnet   AF_DECnet
190
#define PF_NETBEUI  AF_NETBEUI
196
#define PF_NETBEUI  AF_NETBEUI
191
#define PF_SECURITY AF_SECURITY
197
#define PF_SECURITY AF_SECURITY
192
#define PF_KEY      AF_KEY
198
#define PF_KEY      AF_KEY
193
#define PF_NETLINK  AF_NETLINK
199
#define PF_NETLINK  AF_NETLINK
194
#define PF_ROUTE    AF_ROUTE
200
#define PF_ROUTE    AF_ROUTE
195
#define PF_PACKET   AF_PACKET
201
#define PF_PACKET   AF_PACKET
196
#define PF_ASH      AF_ASH
202
#define PF_ASH      AF_ASH
197
#define PF_ECONET   AF_ECONET
203
#define PF_ECONET   AF_ECONET
198
#define PF_ATMSVC   AF_ATMSVC
204
#define PF_ATMSVC   AF_ATMSVC
199
#define PF_SNA      AF_SNA
205
#define PF_SNA      AF_SNA
200
#define PF_IRDA     AF_IRDA
206
#define PF_IRDA     AF_IRDA
201
#define PF_PPPOX    AF_PPPOX
207
#define PF_PPPOX    AF_PPPOX
202
#define PF_WANPIPE  AF_WANPIPE
208
#define PF_WANPIPE  AF_WANPIPE
203
#define PF_LLC      AF_LLC
209
#define PF_LLC      AF_LLC
204
#define PF_CAN      AF_CAN
210
#define PF_CAN      AF_CAN
205
#define PF_TIPC     AF_TIPC
211
#define PF_TIPC     AF_TIPC
206
#define PF_BLUETOOTH    AF_BLUETOOTH
212
#define PF_BLUETOOTH    AF_BLUETOOTH
207
#define PF_IUCV     AF_IUCV
213
#define PF_IUCV     AF_IUCV
208
#define PF_RXRPC    AF_RXRPC
214
#define PF_RXRPC    AF_RXRPC
209
#define PF_MAX      AF_MAX
215
#define PF_MAX      AF_MAX
210
*/
216
 
211
/* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */
217
/* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */
212
/*#define SOL_IP        0
218
#define SOL_IP      0
213
#define SOL_ICMP    1
219
#define SOL_ICMP    1
214
#define SOL_TCP     6
220
#define SOL_TCP     6
215
#define SOL_UDP     17
221
#define SOL_UDP     17
216
#define SOL_IPV6    41
222
#define SOL_IPV6    41
217
#define SOL_ICMPV6  58
223
#define SOL_ICMPV6  58
218
#define SOL_SCTP    132
224
#define SOL_SCTP    132
219
#define SOL_UDPLITE 136     *//* UDP-Lite (RFC 3828) */
225
#define SOL_UDPLITE 136     /* UDP-Lite (RFC 3828) */
220
/*#define SOL_RAW       255
226
#define SOL_RAW     255
221
#define SOL_IPX     256
227
#define SOL_IPX     256
222
#define SOL_AX25    257
228
#define SOL_AX25    257
223
#define SOL_ATALK   258
229
#define SOL_ATALK   258
224
#define SOL_NETROM  259
230
#define SOL_NETROM  259
225
#define SOL_ROSE    260
231
#define SOL_ROSE    260
226
#define SOL_DECNET  261
232
#define SOL_DECNET  261
227
#define SOL_X25     262
233
#define SOL_X25     262
228
#define SOL_PACKET  263
234
#define SOL_PACKET  263
229
#define SOL_ATM     264 *//* ATM layer (cell level) */
235
#define SOL_ATM     264 /* ATM layer (cell level) */
230
/*#define SOL_AAL       265 *//* ATM Adaption Layer (packet level) */
236
#define SOL_AAL     265 /* ATM Adaption Layer (packet level) */
231
/*#define SOL_IRDA        266
237
#define SOL_IRDA        266
232
#define SOL_NETBEUI 267
238
#define SOL_NETBEUI 267
233
#define SOL_LLC     268
239
#define SOL_LLC     268
234
#define SOL_DCCP    269
240
#define SOL_DCCP    269
235
#define SOL_NETLINK 270
241
#define SOL_NETLINK 270
236
#define SOL_TIPC    271
242
#define SOL_TIPC    271
237
#define SOL_RXRPC   272
243
#define SOL_RXRPC   272
238
#define SOL_PPPOL2TP    273
244
#define SOL_PPPOL2TP    273
239
#define SOL_BLUETOOTH   274
245
#define SOL_BLUETOOTH   274
240
*/
246
 
241
//
247
//
242
/* * IPX options.
248
/* * IPX options.
243
 */
249
 */
244
//#define IPX_TYPE  1
250
//#define IPX_TYPE  1
245
 
251
 
-
 
252
/** Socket type type definition.
-
 
253
 */
-
 
254
typedef enum sock_type{
-
 
255
    /** Stream (connection oriented) socket.
-
 
256
     */
-
 
257
    SOCK_STREAM = 1,
-
 
258
    /** Datagram (connectionless oriented) socket.
-
 
259
     */
-
 
260
    SOCK_DGRAM  = 2,
-
 
261
    /** Raw socket.
-
 
262
     */
-
 
263
    SOCK_RAW    = 3
-
 
264
} sock_type_t;
-
 
265
 
-
 
266
typedef int32_t socklen_t;
-
 
267
 
-
 
268
int socket( int domain, int type, int protocol );
-
 
269
int bind( int socket_id, const struct sockaddr * my_addr, socklen_t addrlen );
-
 
270
int listen( int socket_id, int backlog );
-
 
271
int accept( int socket_id, struct sockaddr * cliaddr, socklen_t * addrlen );
-
 
272
int connect( int socket_id, const struct sockaddr * serv_addr, socklen_t addrlen );
-
 
273
 
-
 
274
int closesocket( int socket_id );
-
 
275
 
-
 
276
int send( int socket_id, void * data, size_t datalength, int flags );
-
 
277
int sendto( int socket_id, const void * data, size_t datalength, int flags, const struct sockaddr * toaddr, socklen_t addrlen );
-
 
278
 
-
 
279
int recv( int socket_id, void * data, size_t datalength, int flags );
-
 
280
int recvfrom( int socket_id, void * data, size_t datalength, int flags, struct sockaddr * fromaddr, socklen_t * addrlen );
-
 
281
 
-
 
282
int getsockopt( int socket_id, int level, int optname, void * value, size_t * optlen );
-
 
283
int setsockopt( int socket_id, int level, int optname, const void * value, size_t optlen );
-
 
284
 
246
#endif
285
#endif
247
 
286
 
248
/** @}
287
/** @}
249
 */
288
 */
250
 
289