Subversion Repositories HelenOS

Rev

Rev 4578 | Rev 4712 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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