1 /* $OpenBSD: linux_socket.h,v 1.7 2002/11/27 07:30:36 ish Exp $ */
2 /* $NetBSD: linux_socket.h,v 1.3 1995/05/28 10:16:34 mycroft Exp $ */
3
4 /*
5 * Copyright (c) 1995 Frank van der Linden
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed for the NetBSD Project
19 * by Frank van der Linden
20 * 4. The name of the author may not be used to endorse or promote products
21 * derived from this software without specific prior written permission
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #ifndef _LINUX_SOCKET_H
36 #define _LINUX_SOCKET_H
37
38 /*
39 * Various Linux socket defines. Everything that is not re-defined here
40 * is the same as in OpenBSD.
41 *
42 * COMPAT_43 is assumed, and the osockaddr struct is used (it is what
43 * Linux uses)
44 */
45
46 /*
47 * Address families. There are fewer of them, and they're numbered
48 * a bit different
49 */
50
51 #define LINUX_AF_UNSPEC 0
52 #define LINUX_AF_UNIX 1
53 #define LINUX_AF_INET 2
54 #define LINUX_AF_AX25 3
55 #define LINUX_AF_IPX 4
56 #define LINUX_AF_APPLETALK 5
57 #define LINUX_AF_INET6 10
58 #define LINUX_AF_MAX 32
59
60 /*
61 * Option levels for [gs]etsockopt(2). Only SOL_SOCKET is different,
62 * the rest matches IPPROTO_XXX
63 */
64
65 #define LINUX_SOL_SOCKET 1
66 #define LINUX_SOL_IP 0
67 #define LINUX_SOL_IPX 256
68 #define LINUX_SOL_AX25 257
69 #define LINUX_SOL_TCP 6
70 #define LINUX_SOL_UDP 17
71
72 /*
73 * Options for [gs]etsockopt(2), socket level. For Linux, they
74 * are not masks, but just increasing numbers.
75 */
76
77 #define LINUX_SO_DEBUG 1
78 #define LINUX_SO_REUSEADDR 2
79 #define LINUX_SO_TYPE 3
80 #define LINUX_SO_ERROR 4
81 #define LINUX_SO_DONTROUTE 5
82 #define LINUX_SO_BROADCAST 6
83 #define LINUX_SO_SNDBUF 7
84 #define LINUX_SO_RCVBUF 8
85 #define LINUX_SO_KEEPALIVE 9
86 #define LINUX_SO_OOBINLINE 10
87 #define LINUX_SO_NO_CHECK 11
88 #define LINUX_SO_PRIORITY 12
89 #define LINUX_SO_LINGER 13
90
91 /*
92 * Options vor [gs]etsockopt(2), IP level.
93 */
94
95 #define LINUX_IP_TOS 1
96 #define LINUX_IP_TTL 2
97 #define LINUX_IP_HDRINCL 3
98 #define LINUX_IP_MULTICAST_IF 32
99 #define LINUX_IP_MULTICAST_TTL 33
100 #define LINUX_IP_MULTICAST_LOOP 34
101 #define LINUX_IP_ADD_MEMBERSHIP 35
102 #define LINUX_IP_DROP_MEMBERSHIP 36
103
104 /*
105 * Options vor [gs]etsockopt(2), TCP level.
106 */
107
108 #define LINUX_TCP_NODELAY 1
109 #define LINUX_TCP_MAXSEG 2
110
111 struct linux_sockaddr {
112 unsigned short sa_family;
113 char sa_data[14];
114 };
115
116 struct linux_ifmap {
117 unsigned long mem_start;
118 unsigned long mem_end;
119 unsigned short base_addr;
120 unsigned char irq;
121 unsigned char dma;
122 unsigned char port;
123 };
124
125 struct linux_ifreq {
126 #define LINUX_IFHWADDRLEN 6
127 #define LINUX_IFNAMSIZ 16
128 union {
129 char ifrn_name[LINUX_IFNAMSIZ]; /* if name, e.g. "en0" */
130 } ifr_ifrn;
131
132 union {
133 struct linux_sockaddr ifru_addr;
134 struct linux_sockaddr ifru_dstaddr;
135 struct linux_sockaddr ifru_broadaddr;
136 struct linux_sockaddr ifru_netmask;
137 struct linux_sockaddr ifru_hwaddr;
138 short ifru_flags;
139 int ifru_metric;
140 int ifru_mtu;
141 struct linux_ifmap ifru_map;
142 char ifru_slave[LINUX_IFNAMSIZ];
143 caddr_t ifru_data;
144 } ifr_ifru;
145 };
146
147 #define ifr_name ifr_ifrn.ifrn_name /* interface name */
148 #define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
149
150 #endif /* _LINUX_SOCKET_H */