OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [ecos-2.0/] [packages/] [net/] [tcpip/] [v2_0/] [include/] [sys/] [socket.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1254 phoenix
//==========================================================================
2
//
3
//      include/sys/socket.h
4
//
5
//      
6
//
7
//==========================================================================
8
//####BSDCOPYRIGHTBEGIN####
9
//
10
// -------------------------------------------
11
//
12
// Portions of this software may have been derived from OpenBSD or other sources,
13
// and are covered by the appropriate copyright disclaimers included herein.
14
//
15
// -------------------------------------------
16
//
17
//####BSDCOPYRIGHTEND####
18
//==========================================================================
19
//#####DESCRIPTIONBEGIN####
20
//
21
// Author(s):    gthomas
22
// Contributors: gthomas
23
// Date:         2000-01-10
24
// Purpose:      
25
// Description:  
26
//              
27
//
28
//####DESCRIPTIONEND####
29
//
30
//==========================================================================
31
 
32
 
33
/*      $OpenBSD: socket.h,v 1.30 1999/12/08 06:50:24 itojun Exp $      */
34
/*      $NetBSD: socket.h,v 1.14 1996/02/09 18:25:36 christos Exp $     */
35
 
36
/*
37
 * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994
38
 *      The Regents of the University of California.  All rights reserved.
39
 *
40
 * Redistribution and use in source and binary forms, with or without
41
 * modification, are permitted provided that the following conditions
42
 * are met:
43
 * 1. Redistributions of source code must retain the above copyright
44
 *    notice, this list of conditions and the following disclaimer.
45
 * 2. Redistributions in binary form must reproduce the above copyright
46
 *    notice, this list of conditions and the following disclaimer in the
47
 *    documentation and/or other materials provided with the distribution.
48
 * 3. All advertising materials mentioning features or use of this software
49
 *    must display the following acknowledgement:
50
 *      This product includes software developed by the University of
51
 *      California, Berkeley and its contributors.
52
 * 4. Neither the name of the University nor the names of its contributors
53
 *    may be used to endorse or promote products derived from this software
54
 *    without specific prior written permission.
55
 *
56
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
57
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
59
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
60
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
61
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
62
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
64
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
65
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
66
 * SUCH DAMAGE.
67
 *
68
 *      @(#)socket.h    8.4 (Berkeley) 2/21/94
69
 */
70
 
71
#ifndef _SYS_SOCKET_H_
72
#define _SYS_SOCKET_H_
73
 
74
/*
75
 * Definitions related to sockets: types, address families, options.
76
 */
77
 
78
/*
79
 * Types
80
 */
81
#define SOCK_STREAM     1               /* stream socket */
82
#define SOCK_DGRAM      2               /* datagram socket */
83
#define SOCK_RAW        3               /* raw-protocol interface */
84
#define SOCK_RDM        4               /* reliably-delivered message */
85
#define SOCK_SEQPACKET  5               /* sequenced packet stream */
86
 
87
/*
88
 * Option flags per-socket.
89
 */
90
#define SO_DEBUG        0x0001          /* turn on debugging info recording */
91
#define SO_ACCEPTCONN   0x0002          /* socket has had listen() */
92
#define SO_REUSEADDR    0x0004          /* allow local address reuse */
93
#define SO_KEEPALIVE    0x0008          /* keep connections alive */
94
#define SO_DONTROUTE    0x0010          /* just use interface addresses */
95
#define SO_BROADCAST    0x0020          /* permit sending of broadcast msgs */
96
#define SO_USELOOPBACK  0x0040          /* bypass hardware when possible */
97
#define SO_LINGER       0x0080          /* linger on close if data present */
98
#define SO_OOBINLINE    0x0100          /* leave received OOB data in line */
99
#define SO_REUSEPORT    0x0200          /* allow local address & port reuse */
100
 
101
/*
102
 * Additional options, not kept in so_options.
103
 */
104
#define SO_SNDBUF       0x1001          /* send buffer size */
105
#define SO_RCVBUF       0x1002          /* receive buffer size */
106
#define SO_SNDLOWAT     0x1003          /* send low-water mark */
107
#define SO_RCVLOWAT     0x1004          /* receive low-water mark */
108
#define SO_SNDTIMEO     0x1005          /* send timeout */
109
#define SO_RCVTIMEO     0x1006          /* receive timeout */
110
#define SO_ERROR        0x1007          /* get error status and clear */
111
#define SO_TYPE         0x1008          /* get socket type */
112
#define SO_NETPROC      0x1020          /* multiplex; network processing */
113
 
114
/*
115
 * Structure used for manipulating linger option.
116
 */
117
struct  linger {
118
        int     l_onoff;                /* option on/off */
119
        int     l_linger;               /* linger time */
120
};
121
 
122
/*
123
 * Level number for (get/set)sockopt() to apply to socket itself.
124
 */
125
#define SOL_SOCKET      0xffff          /* options for socket level */
126
 
127
/*
128
 * Address families.
129
 */
130
#define AF_UNSPEC       0                /* unspecified */
131
#define AF_LOCAL        1               /* local to host (pipes, portals) */
132
#define AF_UNIX         AF_LOCAL        /* backward compatibility */
133
#define AF_INET         2               /* internetwork: UDP, TCP, etc. */
134
#define AF_IMPLINK      3               /* arpanet imp addresses */
135
#define AF_PUP          4               /* pup protocols: e.g. BSP */
136
#define AF_CHAOS        5               /* mit CHAOS protocols */
137
#define AF_NS           6               /* XEROX NS protocols */
138
#define AF_ISO          7               /* ISO protocols */
139
#define AF_OSI          AF_ISO
140
#define AF_ECMA         8               /* european computer manufacturers */
141
#define AF_DATAKIT      9               /* datakit protocols */
142
#define AF_CCITT        10              /* CCITT protocols, X.25 etc */
143
#define AF_SNA          11              /* IBM SNA */
144
#define AF_DECnet       12              /* DECnet */
145
#define AF_DLI          13              /* DEC Direct data link interface */
146
#define AF_LAT          14              /* LAT */
147
#define AF_HYLINK       15              /* NSC Hyperchannel */
148
#define AF_APPLETALK    16              /* Apple Talk */
149
#define AF_ROUTE        17              /* Internal Routing Protocol */
150
#define AF_LINK         18              /* Link layer interface */
151
#define pseudo_AF_XTP   19              /* eXpress Transfer Protocol (no AF) */
152
#define AF_COIP         20              /* connection-oriented IP, aka ST II */
153
#define AF_CNT          21              /* Computer Network Technology */
154
#define pseudo_AF_RTIP  22              /* Help Identify RTIP packets */
155
#define AF_IPX          23              /* Novell Internet Protocol */
156
#define AF_INET6        24              /* IPv6 */
157
#define pseudo_AF_PIP   25              /* Help Identify PIP packets */
158
#define AF_ISDN         26              /* Integrated Services Digital Network*/
159
#define AF_E164         AF_ISDN         /* CCITT E.164 recommendation */
160
#define AF_NATM         27              /* native ATM access */
161
#define AF_ENCAP        28
162
#define AF_SIP          29              /* Simple Internet Protocol */
163
#define AF_KEY          30
164
#define AF_MAX          31
165
 
166
/*
167
 * Structure used by kernel to store most
168
 * addresses.
169
 */
170
struct sockaddr {
171
        u_int8_t    sa_len;             /* total length */
172
        sa_family_t sa_family;          /* address family */
173
        char        sa_data[14];        /* actually longer; address value */
174
};
175
 
176
/*
177
 * Sockaddr type which can hold any sockaddr type available
178
 * in the system.
179
 *
180
 * Note: __ss_{len,family} is defined in RFC2553.  During RFC2553 discussion
181
 * the field name went back and forth between ss_len and __ss_len,
182
 * and RFC2553 specifies it to be __ss_len.  openbsd picked ss_len.
183
 * For maximum portability, userland programmer would need to
184
 * (1) make the code never touch ss_len portion (cast it into sockaddr and
185
 * touch sa_len), or (2) add "-Dss_len=__ss_len" into CFLAGS to unify all
186
 * occurences (including header file) to __ss_len.
187
 */
188
struct sockaddr_storage {
189
        u_int8_t    ss_len;             /* total length */
190
        sa_family_t ss_family;          /* address family */
191
        u_char      __ss_pad1[6];       /* align to quad */
192
        u_int64_t   __ss_pad2;          /* force alignment for stupid compilers */
193
        u_char      __ss_pad3[240];     /* pad to a total of 256 bytes */
194
};
195
 
196
/*
197
 * Structure used by kernel to pass protocol
198
 * information in raw sockets.
199
 */
200
struct sockproto {
201
        u_short sp_family;              /* address family */
202
        u_short sp_protocol;            /* protocol */
203
};
204
 
205
/*
206
 * Protocol families, same as address families for now.
207
 */
208
#define PF_UNSPEC       AF_UNSPEC
209
#define PF_LOCAL        AF_LOCAL
210
#define PF_UNIX         PF_LOCAL        /* backward compatibility */
211
#define PF_INET         AF_INET
212
#define PF_INET6        AF_INET6
213
#define PF_IMPLINK      AF_IMPLINK
214
#define PF_PUP          AF_PUP
215
#define PF_CHAOS        AF_CHAOS
216
#define PF_NS           AF_NS
217
#define PF_ISO          AF_ISO
218
#define PF_OSI          AF_ISO
219
#define PF_ECMA         AF_ECMA
220
#define PF_DATAKIT      AF_DATAKIT
221
#define PF_CCITT        AF_CCITT
222
#define PF_SNA          AF_SNA
223
#define PF_DECnet       AF_DECnet
224
#define PF_DLI          AF_DLI
225
#define PF_LAT          AF_LAT
226
#define PF_HYLINK       AF_HYLINK
227
#define PF_APPLETALK    AF_APPLETALK
228
#define PF_ROUTE        AF_ROUTE
229
#define PF_LINK         AF_LINK
230
#define PF_XTP          pseudo_AF_XTP   /* really just proto family, no AF */
231
#define PF_COIP         AF_COIP
232
#define PF_CNT          AF_CNT
233
#define PF_IPX          AF_IPX          /* same format as AF_NS */
234
#define PF_INET6        AF_INET6
235
#define PF_RTIP         pseudo_AF_FTIP  /* same format as AF_INET */
236
#define PF_PIP          pseudo_AF_PIP
237
#define PF_ISDN         AF_ISDN
238
#define PF_NATM         AF_NATM
239
#define PF_ENCAP        AF_ENCAP
240
#define PF_SIP          AF_SIP
241
#define PF_KEY          AF_KEY
242
#define PF_MAX          AF_MAX
243
 
244
/*
245
 * These are the valid values for the "how" field used by shutdown(2).
246
 */
247
#define SHUT_RD         0
248
#define SHUT_WR         1
249
#define SHUT_RDWR       2
250
 
251
/*
252
 * Socket credentials.
253
 */
254
struct sockcred {
255
        uid_t   sc_uid;                 /* real user id */
256
        uid_t   sc_euid;                /* effective user id */
257
        gid_t   sc_gid;                 /* real group id */
258
        gid_t   sc_egid;                /* effective group id */
259
        int     sc_ngroups;             /* number of supplemental groups */
260
        gid_t   sc_groups[1];           /* variable length */
261
};
262
 
263
/*
264
 * Compute size of a sockcred structure with groups.
265
 */
266
#define SOCKCREDSIZE(ngrps) \
267
        (sizeof(struct sockcred) + (sizeof(gid_t) * ((ngrps) - 1)))
268
 
269
/*
270
 * Definitions for network related sysctl, CTL_NET.
271
 *
272
 * Second level is protocol family.
273
 * Third level is protocol number.
274
 *
275
 * Further levels are defined by the individual families below.
276
 */
277
#define NET_MAXID       AF_MAX
278
 
279
#define CTL_NET_NAMES { \
280
        { 0, 0 }, \
281
        { "unix", CTLTYPE_NODE }, \
282
        { "inet", CTLTYPE_NODE }, \
283
        { "implink", CTLTYPE_NODE }, \
284
        { "pup", CTLTYPE_NODE }, \
285
        { "chaos", CTLTYPE_NODE }, \
286
        { "xerox_ns", CTLTYPE_NODE }, \
287
        { "iso", CTLTYPE_NODE }, \
288
        { "emca", CTLTYPE_NODE }, \
289
        { "datakit", CTLTYPE_NODE }, \
290
        { "ccitt", CTLTYPE_NODE }, \
291
        { "ibm_sna", CTLTYPE_NODE }, \
292
        { "decnet", CTLTYPE_NODE }, \
293
        { "dec_dli", CTLTYPE_NODE }, \
294
        { "lat", CTLTYPE_NODE }, \
295
        { "hylink", CTLTYPE_NODE }, \
296
        { "appletalk", CTLTYPE_NODE }, \
297
        { "route", CTLTYPE_NODE }, \
298
        { "link_layer", CTLTYPE_NODE }, \
299
        { "xtp", CTLTYPE_NODE }, \
300
        { "coip", CTLTYPE_NODE }, \
301
        { "cnt", CTLTYPE_NODE }, \
302
        { "rtip", CTLTYPE_NODE }, \
303
        { "ipx", CTLTYPE_NODE }, \
304
        { "inet6", CTLTYPE_NODE }, \
305
        { "pip", CTLTYPE_NODE }, \
306
        { "isdn", CTLTYPE_NODE }, \
307
        { "natm", CTLTYPE_NODE }, \
308
        { "encap", CTLTYPE_NODE }, \
309
        { "sip", CTLTYPE_NODE }, \
310
        { "key", CTLTYPE_NODE }, \
311
}
312
 
313
/*
314
 * PF_ROUTE - Routing table
315
 *
316
 * Three additional levels are defined:
317
 *      Fourth: address family, 0 is wildcard
318
 *      Fifth: type of info, defined below
319
 *      Sixth: flag(s) to mask with for NET_RT_FLAGS
320
 */
321
#define NET_RT_DUMP     1               /* dump; may limit to a.f. */
322
#define NET_RT_FLAGS    2               /* by flags, e.g. RESOLVING */
323
#define NET_RT_IFLIST   3               /* survey interface list */
324
#define NET_RT_MAXID    4
325
 
326
#define CTL_NET_RT_NAMES { \
327
        { 0, 0 }, \
328
        { "dump", CTLTYPE_STRUCT }, \
329
        { "flags", CTLTYPE_STRUCT }, \
330
        { "iflist", CTLTYPE_STRUCT }, \
331
}
332
 
333
/*
334
 * Maximum queue length specifiable by listen(2).
335
 */
336
#define SOMAXCONN       128
337
 
338
/*
339
 * Message header for recvmsg and sendmsg calls.
340
 * Used value-result for recvmsg, value only for sendmsg.
341
 */
342
struct msghdr {
343
        caddr_t         msg_name;       /* optional address */
344
        socklen_t       msg_namelen;    /* size of address */
345
        struct          iovec *msg_iov; /* scatter/gather array */
346
        u_int           msg_iovlen;     /* # elements in msg_iov */
347
        caddr_t         msg_control;    /* ancillary data, see below */
348
        socklen_t       msg_controllen; /* ancillary data buffer len */
349
        int             msg_flags;      /* flags on received message */
350
};
351
 
352
#define MSG_OOB         0x1             /* process out-of-band data */
353
#define MSG_PEEK        0x2             /* peek at incoming message */
354
#define MSG_DONTROUTE   0x4             /* send without using routing tables */
355
#define MSG_EOR         0x8             /* data completes record */
356
#define MSG_TRUNC       0x10            /* data discarded before delivery */
357
#define MSG_CTRUNC      0x20            /* control data lost before delivery */
358
#define MSG_WAITALL     0x40            /* wait for full request or error */
359
#define MSG_DONTWAIT    0x80            /* this message should be nonblocking */
360
#define MSG_BCAST       0x100           /* this message rec'd as broadcast */
361
#define MSG_MCAST       0x200           /* this message rec'd as multicast */
362
 
363
/*
364
 * Header for ancillary data objects in msg_control buffer.
365
 * Used for additional information with/about a datagram
366
 * not expressible by flags.  The format is a sequence
367
 * of message elements headed by cmsghdr structures.
368
 */
369
struct cmsghdr {
370
        socklen_t       cmsg_len;       /* data byte count, including hdr */
371
        int             cmsg_level;     /* originating protocol */
372
        int             cmsg_type;      /* protocol-specific type */
373
/* followed by  u_char  cmsg_data[]; */
374
};
375
 
376
/* given pointer to struct cmsghdr, return pointer to data */
377
#define CMSG_DATA(cmsg)         ((u_char *)((cmsg) + 1))
378
 
379
/* given pointer to struct cmsghdr, return pointer to next cmsghdr */
380
#define CMSG_NXTHDR(mhdr, cmsg) \
381
        (((caddr_t)(cmsg) + (cmsg)->cmsg_len + sizeof(struct cmsghdr) > \
382
            (mhdr)->msg_control + (mhdr)->msg_controllen) ? \
383
            (struct cmsghdr *)NULL : \
384
            (struct cmsghdr *)((caddr_t)(cmsg) + CMSG_ALIGN((cmsg)->cmsg_len)))
385
 
386
#define CMSG_FIRSTHDR(mhdr)     ((struct cmsghdr *)(mhdr)->msg_control)
387
 
388
/* Round len up to next alignment boundary */
389
#define CMSG_ALIGN(len) (((len)+sizeof(long)-1) & ~(sizeof(long)-1))
390
 
391
/* Length of the contents of a control message of length len */
392
#define CMSG_LEN(len)   (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
393
 
394
/* Length of the space taken up by a padded control message of length len */
395
#define CMSG_SPACE(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(len))
396
 
397
/* "Socket"-level control message types: */
398
#define SCM_RIGHTS      0x01            /* access rights (array of int) */
399
#define SCM_CREDS       0x02            /* credientials (struct sockcred) */
400
 
401
/*
402
 * 4.3 compat sockaddr, move to compat file later
403
 */
404
struct osockaddr {
405
        u_short sa_family;              /* address family */
406
        char    sa_data[14];            /* up to 14 bytes of direct address */
407
};
408
 
409
/*
410
 * 4.3-compat message header (move to compat file later).
411
 */
412
struct omsghdr {
413
        caddr_t msg_name;               /* optional address */
414
        int     msg_namelen;            /* size of address */
415
        struct  iovec *msg_iov;         /* scatter/gather array */
416
        int     msg_iovlen;             /* # elements in msg_iov */
417
        caddr_t msg_accrights;          /* access rights sent/received */
418
        int     msg_accrightslen;
419
};
420
 
421
#define SA_LEN(x) ((x)->sa_len)
422
 
423
#ifndef _KERNEL
424
 
425
#include <sys/cdefs.h>
426
 
427
__BEGIN_DECLS
428
int     accept __P((int, struct sockaddr *, socklen_t *));
429
int     bind __P((int, const struct sockaddr *, socklen_t));
430
int     connect __P((int, const struct sockaddr *, socklen_t));
431
int     getpeername __P((int, struct sockaddr *, socklen_t *));
432
int     getsockname __P((int, struct sockaddr *, socklen_t *));
433
int     getsockopt __P((int, int, int, void *, socklen_t *));
434
int     listen __P((int, int));
435
ssize_t recv __P((int, void *, size_t, int));
436
ssize_t recvfrom __P((int, void *, size_t, int, struct sockaddr *, socklen_t *));
437
ssize_t recvmsg __P((int, struct msghdr *, int));
438
ssize_t send __P((int, const void *, size_t, int));
439
ssize_t sendto __P((int, const void *,
440
            size_t, int, const struct sockaddr *, socklen_t));
441
ssize_t sendmsg __P((int, const struct msghdr *, int));
442
int     setsockopt __P((int, int, int, const void *, socklen_t));
443
int     shutdown __P((int, int));
444
int     socket __P((int, int, int));
445
int     socketpair __P((int, int, int, int *));
446
__END_DECLS
447
#else
448
# if defined(COMPAT_43) || defined(COMPAT_SUNOS) || defined(COMPAT_LINUX) || \
449
     defined(COMPAT_HPUX) || defined(COMPAT_FREEBSD)
450
#  define COMPAT_OLDSOCK
451
#  define MSG_COMPAT    0x8000
452
# endif
453
 
454
void    pfctlinput __P((int, struct sockaddr *));
455
#endif /* !_KERNEL */
456
 
457
#endif /* !_SYS_SOCKET_H_ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.