source: rtems/cpukit/libnetworking/sys/socket.h @ 51cda9a

4.104.114.84.95
Last change on this file since 51cda9a was 51cda9a, checked in by Ralf Corsepius <ralf.corsepius@…>, on 03/18/07 at 13:31:48

Remove P().

  • Property mode set to 100644
File size: 13.1 KB
Line 
1/*
2 * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994
3 *      The Regents of the University of California.  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 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 *    may be used to endorse or promote products derived from this software
15 *    without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 *      @(#)socket.h    8.4 (Berkeley) 2/21/94
30 * $FreeBSD: src/sys/sys/socket.h,v 1.88 2005/04/13 00:01:46 mdodd Exp $
31 */
32
33/*
34 * $Id$
35 */
36
37#ifndef _SYS_SOCKET_H_
38#define _SYS_SOCKET_H_
39
40#include <sys/cdefs.h>
41#include <rtems/bsdnet/_types.h>
42
43/*
44 * Definitions related to sockets: types, address families, options.
45 */
46
47/*
48 * Data types.
49 */
50
51#ifndef _SA_FAMILY_T_DECLARED
52typedef __sa_family_t   sa_family_t;
53#define _SA_FAMILY_T_DECLARED
54#endif
55
56#ifndef _SOCKLEN_T_DECLARED
57typedef __socklen_t     socklen_t;
58#define _SOCKLEN_T_DECLARED
59#endif
60
61/*
62 * Types
63 */
64#define SOCK_STREAM     1               /* stream socket */
65#define SOCK_DGRAM      2               /* datagram socket */
66#define SOCK_RAW        3               /* raw-protocol interface */
67#if __BSD_VISIBLE
68#define SOCK_RDM        4               /* reliably-delivered message */
69#endif
70#define SOCK_SEQPACKET  5               /* sequenced packet stream */
71
72/*
73 * Option flags per-socket.
74 */
75#define SO_DEBUG        0x0001          /* turn on debugging info recording */
76#define SO_ACCEPTCONN   0x0002          /* socket has had listen() */
77#define SO_REUSEADDR    0x0004          /* allow local address reuse */
78#define SO_KEEPALIVE    0x0008          /* keep connections alive */
79#define SO_DONTROUTE    0x0010          /* just use interface addresses */
80#define SO_BROADCAST    0x0020          /* permit sending of broadcast msgs */
81#if __BSD_VISIBLE
82#define SO_USELOOPBACK  0x0040          /* bypass hardware when possible */
83#endif
84#define SO_LINGER       0x0080          /* linger on close if data present */
85#define SO_OOBINLINE    0x0100          /* leave received OOB data in line */
86#if __BSD_VISIBLE
87#define SO_REUSEPORT    0x0200          /* allow local address & port reuse */
88#define SO_TIMESTAMP    0x0400          /* timestamp received dgram traffic */
89#define SO_NOSIGPIPE    0x0800          /* no SIGPIPE from EPIPE */
90#define SO_ACCEPTFILTER 0x1000          /* there is an accept filter */
91#define SO_BINTIME      0x2000          /* timestamp received dgram traffic */
92#endif
93
94/*
95 * Additional options, not kept in so_options.
96 */
97#define SO_SNDBUF       0x1001          /* send buffer size */
98#define SO_RCVBUF       0x1002          /* receive buffer size */
99#define SO_SNDLOWAT     0x1003          /* send low-water mark */
100#define SO_RCVLOWAT     0x1004          /* receive low-water mark */
101#define SO_SNDTIMEO     0x1005          /* send timeout */
102#define SO_RCVTIMEO     0x1006          /* receive timeout */
103#define SO_ERROR        0x1007          /* get error status and clear */
104#define SO_TYPE         0x1008          /* get socket type */
105#define SO_PRIVSTATE    0x1009          /* get/deny privileged state */
106
107/*
108 * RTEMS addition: get and set wakeup functions.
109 */
110#define SO_SNDWAKEUP    0x1020          /* wakeup when ready to send */
111#define SO_RCVWAKEUP    0x1021          /* wakeup when ready to receive */
112
113/*
114 * Structure used for manipulating linger option.
115 */
116struct  linger {
117        int     l_onoff;                /* option on/off */
118        int     l_linger;               /* linger time */
119};
120
121/*
122 * RTEMS addition: structure used to get and set wakeup function.
123 */
124struct socket;
125struct  sockwakeup {
126        void    (*sw_pfn)(struct socket *, caddr_t);
127        caddr_t sw_arg;
128};
129
130/*
131 * Level number for (get/set)sockopt() to apply to socket itself.
132 */
133#define SOL_SOCKET      0xffff          /* options for socket level */
134
135/*
136 * Address families.
137 */
138#define AF_UNSPEC       0               /* unspecified */
139#if __BSD_VISIBLE
140#define AF_LOCAL        AF_UNIX         /* local to host (pipes, portals) */
141#endif
142#define AF_UNIX         1               /* standardized name for AF_LOCAL */
143#define AF_INET         2               /* internetwork: UDP, TCP, etc. */
144#if __BSD_VISIBLE
145#define AF_IMPLINK      3               /* arpanet imp addresses */
146#define AF_PUP          4               /* pup protocols: e.g. BSP */
147#define AF_CHAOS        5               /* mit CHAOS protocols */
148#define AF_NETBIOS      6               /* SMB protocols */
149#define AF_ISO          7               /* ISO protocols */
150#define AF_OSI          AF_ISO
151#define AF_ECMA         8               /* European computer manufacturers */
152#define AF_DATAKIT      9               /* datakit protocols */
153#define AF_CCITT        10              /* CCITT protocols, X.25 etc */
154#define AF_SNA          11              /* IBM SNA */
155#define AF_DECnet       12              /* DECnet */
156#define AF_DLI          13              /* DEC Direct data link interface */
157#define AF_LAT          14              /* LAT */
158#define AF_HYLINK       15              /* NSC Hyperchannel */
159#define AF_APPLETALK    16              /* Apple Talk */
160#define AF_ROUTE        17              /* Internal Routing Protocol */
161#define AF_LINK         18              /* Link layer interface */
162#define pseudo_AF_XTP   19              /* eXpress Transfer Protocol (no AF) */
163#define AF_COIP         20              /* connection-oriented IP, aka ST II */
164#define AF_CNT          21              /* Computer Network Technology */
165#define pseudo_AF_RTIP  22              /* Help Identify RTIP packets */
166#define AF_IPX          23              /* Novell Internet Protocol */
167#define AF_SIP          24              /* Simple Internet Protocol */
168#define pseudo_AF_PIP   25              /* Help Identify PIP packets */
169#define AF_ISDN         26              /* Integrated Services Digital Network*/
170#define AF_E164         AF_ISDN         /* CCITT E.164 recommendation */
171#define pseudo_AF_KEY   27              /* Internal key-management function */
172#endif
173#define AF_INET6        28              /* IPv6 */
174
175#define AF_MAX          29
176
177/*
178 * Structure used by kernel to store most
179 * addresses.
180 */
181struct sockaddr {
182        unsigned char   sa_len;                 /* total length */
183        sa_family_t     sa_family;              /* address family */
184        char    sa_data[14];            /* actually longer; address value */
185};
186
187/*
188 * Structure used by kernel to pass protocol
189 * information in raw sockets.
190 */
191struct sockproto {
192        unsigned short  sp_family;              /* address family */
193        unsigned short  sp_protocol;            /* protocol */
194};
195
196/*
197 * Protocol families, same as address families for now.
198 */
199#define PF_UNSPEC       AF_UNSPEC
200#define PF_LOCAL        AF_LOCAL
201#define PF_UNIX         PF_LOCAL        /* backward compatibility */
202#define PF_INET         AF_INET
203#define PF_IMPLINK      AF_IMPLINK
204#define PF_PUP          AF_PUP
205#define PF_CHAOS        AF_CHAOS
206#define PF_NETBIOS      AF_NETBIOS
207#define PF_ISO          AF_ISO
208#define PF_OSI          AF_ISO
209#define PF_ECMA         AF_ECMA
210#define PF_DATAKIT      AF_DATAKIT
211#define PF_CCITT        AF_CCITT
212#define PF_SNA          AF_SNA
213#define PF_DECnet       AF_DECnet
214#define PF_DLI          AF_DLI
215#define PF_LAT          AF_LAT
216#define PF_HYLINK       AF_HYLINK
217#define PF_APPLETALK    AF_APPLETALK
218#define PF_ROUTE        AF_ROUTE
219#define PF_LINK         AF_LINK
220#define PF_XTP          pseudo_AF_XTP   /* really just proto family, no AF */
221#define PF_COIP         AF_COIP
222#define PF_CNT          AF_CNT
223#define PF_SIP          AF_SIP
224#define PF_IPX          AF_IPX
225#define PF_RTIP         pseudo_AF_RTIP  /* same format as AF_INET */
226#define PF_PIP          pseudo_AF_PIP
227#define PF_ISDN         AF_ISDN
228#define PF_KEY          pseudo_AF_KEY
229#define PF_INET6        AF_INET6
230
231#define PF_MAX          AF_MAX
232
233/*
234 * Definitions for network related sysctl, CTL_NET.
235 *
236 * Second level is protocol family.
237 * Third level is protocol number.
238 *
239 * Further levels are defined by the individual families below.
240 */
241#define NET_MAXID       AF_MAX
242
243#define CTL_NET_NAMES { \
244        { 0, 0 }, \
245        { "unix", CTLTYPE_NODE }, \
246        { "inet", CTLTYPE_NODE }, \
247        { "implink", CTLTYPE_NODE }, \
248        { "pup", CTLTYPE_NODE }, \
249        { "chaos", CTLTYPE_NODE }, \
250        { "xerox_ns", CTLTYPE_NODE }, \
251        { "iso", CTLTYPE_NODE }, \
252        { "emca", CTLTYPE_NODE }, \
253        { "datakit", CTLTYPE_NODE }, \
254        { "ccitt", CTLTYPE_NODE }, \
255        { "ibm_sna", CTLTYPE_NODE }, \
256        { "decnet", CTLTYPE_NODE }, \
257        { "dec_dli", CTLTYPE_NODE }, \
258        { "lat", CTLTYPE_NODE }, \
259        { "hylink", CTLTYPE_NODE }, \
260        { "appletalk", CTLTYPE_NODE }, \
261        { "route", CTLTYPE_NODE }, \
262        { "link_layer", CTLTYPE_NODE }, \
263        { "xtp", CTLTYPE_NODE }, \
264        { "coip", CTLTYPE_NODE }, \
265        { "cnt", CTLTYPE_NODE }, \
266        { "rtip", CTLTYPE_NODE }, \
267        { "ipx", CTLTYPE_NODE }, \
268        { "sip", CTLTYPE_NODE }, \
269        { "pip", CTLTYPE_NODE }, \
270        { "isdn", CTLTYPE_NODE }, \
271        { "key", CTLTYPE_NODE }, \
272}
273
274/*
275 * PF_ROUTE - Routing table
276 *
277 * Three additional levels are defined:
278 *      Fourth: address family, 0 is wildcard
279 *      Fifth: type of info, defined below
280 *      Sixth: flag(s) to mask with for NET_RT_FLAGS
281 */
282#define NET_RT_DUMP     1               /* dump; may limit to a.f. */
283#define NET_RT_FLAGS    2               /* by flags, e.g. RESOLVING */
284#define NET_RT_IFLIST   3               /* survey interface list */
285#define NET_RT_MAXID    4
286
287#define CTL_NET_RT_NAMES { \
288        { 0, 0 }, \
289        { "dump", CTLTYPE_STRUCT }, \
290        { "flags", CTLTYPE_STRUCT }, \
291        { "iflist", CTLTYPE_STRUCT }, \
292}
293
294/*
295 * Maximum queue length specifiable by listen.
296 */
297#define SOMAXCONN       128
298
299/*
300 * Message header for recvmsg and sendmsg calls.
301 * Used value-result for recvmsg, value only for sendmsg.
302 */
303struct msghdr {
304        void            *msg_name;              /* optional address */
305        socklen_t       msg_namelen;            /* size of address */
306        struct  iovec *msg_iov;         /* scatter/gather array */
307        int     msg_iovlen;             /* # elements in msg_iov */
308        void            *msg_control;           /* ancillary data, see below */
309        socklen_t       msg_controllen;         /* ancillary data buffer len */
310        int     msg_flags;              /* flags on received message */
311};
312
313#define MSG_OOB         0x1             /* process out-of-band data */
314#define MSG_PEEK        0x2             /* peek at incoming message */
315#define MSG_DONTROUTE   0x4             /* send without using routing tables */
316#define MSG_EOR         0x8             /* data completes record */
317#define MSG_TRUNC       0x10            /* data discarded before delivery */
318#define MSG_CTRUNC      0x20            /* control data lost before delivery */
319#define MSG_WAITALL     0x40            /* wait for full request or error */
320#if __BSD_VISIBLE
321#define MSG_DONTWAIT    0x80            /* this message should be nonblocking */
322#define MSG_EOF         0x100           /* data completes connection */
323#define MSG_COMPAT      0x8000          /* used in sendit() */
324#endif
325
326/*
327 * Header for ancillary data objects in msg_control buffer.
328 * Used for additional information with/about a datagram
329 * not expressible by flags.  The format is a sequence
330 * of message elements headed by cmsghdr structures.
331 */
332struct cmsghdr {
333        socklen_t       cmsg_len;               /* data byte count, including hdr */
334        int     cmsg_level;             /* originating protocol */
335        int     cmsg_type;              /* protocol-specific type */
336/* followed by  u_char  cmsg_data[]; */
337};
338
339/* given pointer to struct cmsghdr, return pointer to data */
340#define CMSG_DATA(cmsg)         ((u_char *)((cmsg) + 1))
341
342/* given pointer to struct cmsghdr, return pointer to next cmsghdr */
343#define CMSG_NXTHDR(mhdr, cmsg) \
344        (((caddr_t)(cmsg) + (cmsg)->cmsg_len + sizeof(struct cmsghdr) > \
345            (mhdr)->msg_control + (mhdr)->msg_controllen) ? \
346            (struct cmsghdr *)NULL : \
347            (struct cmsghdr *)((caddr_t)(cmsg) + ALIGN((cmsg)->cmsg_len)))
348
349#define CMSG_FIRSTHDR(mhdr)     ((struct cmsghdr *)(mhdr)->msg_control)
350
351/* "Socket"-level control message types: */
352#define SCM_RIGHTS      0x01            /* access rights (array of int) */
353#define SCM_TIMESTAMP   0x02            /* timestamp (struct timeval) */
354
355/*
356 * 4.3 compat sockaddr, move to compat file later
357 */
358struct osockaddr {
359        unsigned short  sa_family;              /* address family */
360        char    sa_data[14];            /* up to 14 bytes of direct address */
361};
362
363/*
364 * 4.3-compat message header (move to compat file later).
365 */
366struct omsghdr {
367        char    *msg_name;              /* optional address */
368        int     msg_namelen;            /* size of address */
369        struct  iovec *msg_iov;         /* scatter/gather array */
370        int     msg_iovlen;             /* # elements in msg_iov */
371        char    *msg_accrights;         /* access rights sent/received */
372        int     msg_accrightslen;
373};
374
375/*
376 * howto arguments for shutdown(2), specified by Posix.1g.
377 */
378#define SHUT_RD         0               /* shut down the reading side */
379#define SHUT_WR         1               /* shut down the writing side */
380#define SHUT_RDWR       2               /* shut down both sides */
381
382#ifndef _KERNEL
383
384__BEGIN_DECLS
385int     accept(int, struct sockaddr * __restrict, socklen_t * __restrict);
386int     bind(int, const struct sockaddr *, socklen_t);
387int     connect(int, const struct sockaddr *, socklen_t);
388int     getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict);
389int     getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict);
390int     getsockopt(int, int, int, void * __restrict, socklen_t * __restrict);
391int     listen(int, int);
392ssize_t recv(int, void *, size_t, int);
393ssize_t recvfrom(int, void *, size_t, int, struct sockaddr * __restrict, socklen_t * __restrict);
394ssize_t recvmsg(int, struct msghdr *, int);
395ssize_t send(int, const void *, size_t, int);
396ssize_t sendto(int, const void *,
397            size_t, int, const struct sockaddr *, socklen_t);
398ssize_t sendmsg(int, const struct msghdr *, int);
399int     setsockopt(int, int, int, const void *, socklen_t);
400int     shutdown(int, int);
401int     socket(int, int, int);
402int     socketpair(int, int, int, int *);
403__END_DECLS
404
405#endif /* !_KERNEL */
406
407#endif /* !_SYS_SOCKET_H_ */
Note: See TracBrowser for help on using the repository browser.