source: rtems/cpukit/libnetworking/sys/socket.h @ 4ba4f82

5
Last change on this file since 4ba4f82 was 4ba4f82, checked in by Christian Mauderer <Christian.Mauderer@…>, on 04/21/16 at 12:42:53

libnetworking: Hide SO_PRIVSTATE

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