FreeBSD/Linux Kernel Cross Reference
sys/netipx/ipx.h
1 /*-
2 * Copyright (c) 1984, 1985, 1986, 1987, 1993
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 * Copyright (c) 1995, Mike Mitchell
30 *
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
33 * are met:
34 * 1. Redistributions of source code must retain the above copyright
35 * notice, this list of conditions and the following disclaimer.
36 * 2. Redistributions in binary form must reproduce the above copyright
37 * notice, this list of conditions and the following disclaimer in the
38 * documentation and/or other materials provided with the distribution.
39 * 3. All advertising materials mentioning features or use of this software
40 * must display the following acknowledgement:
41 * This product includes software developed by the University of
42 * California, Berkeley and its contributors.
43 * 4. Neither the name of the University nor the names of its contributors
44 * may be used to endorse or promote products derived from this software
45 * without specific prior written permission.
46 *
47 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
48 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
51 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
53 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57 * SUCH DAMAGE.
58 *
59 * @(#)ipx.h
60 *
61 * $FreeBSD$
62 */
63
64 #ifndef _NETIPX_IPX_H_
65 #define _NETIPX_IPX_H_
66
67 /*
68 * Constants and Structures
69 */
70
71 /*
72 * Protocols
73 */
74 #define IPXPROTO_UNKWN 0 /* Unknown */
75 #define IPXPROTO_RI 1 /* RIP Routing Information */
76 #define IPXPROTO_PXP 4 /* IPX Packet Exchange Protocol */
77 #define IPXPROTO_SPX 5 /* SPX Sequenced Packet */
78 #define IPXPROTO_NCP 17 /* NCP NetWare Core */
79 #define IPXPROTO_NETBIOS 20 /* Propagated Packet */
80 #define IPXPROTO_RAW 255 /* Placemarker*/
81 #define IPXPROTO_MAX 256 /* Placemarker*/
82
83 /*
84 * Port/Socket numbers: network standard functions
85 */
86
87 #define IPXPORT_RI 1 /* NS RIP Routing Information */
88 #define IPXPORT_ECHO 2 /* NS Echo */
89 #define IPXPORT_RE 3 /* NS Router Error */
90 #define IPXPORT_NCP 0x0451 /* NW NCP Core Protocol */
91 #define IPXPORT_SAP 0x0452 /* NW SAP Service Advertising */
92 #define IPXPORT_RIP 0x0453 /* NW RIP Routing Information */
93 #define IPXPORT_NETBIOS 0x0455 /* NW NetBIOS */
94 #define IPXPORT_DIAGS 0x0456 /* NW Diagnostics */
95 /*
96 * Ports < IPXPORT_RESERVED are reserved for privileged
97 */
98 #define IPXPORT_RESERVED 0x4000
99 /*
100 * Ports > IPXPORT_WELLKNOWN are reserved for privileged
101 * processes (e.g. root).
102 */
103 #define IPXPORT_WELLKNOWN 0x6000
104
105 /* flags passed to ipx_outputfl as last parameter */
106
107 #define IPX_FORWARDING 0x1 /* most of ipx header exists */
108 #define IPX_ROUTETOIF 0x10 /* same as SO_DONTROUTE */
109 #define IPX_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */
110
111 #define IPX_MAXHOPS 15
112
113 /* flags passed to get/set socket option */
114 #define SO_HEADERS_ON_INPUT 1
115 #define SO_HEADERS_ON_OUTPUT 2
116 #define SO_DEFAULT_HEADERS 3
117 #define SO_LAST_HEADER 4
118 #define SO_IPXIP_ROUTE 5 /* No longer implemented. */
119 #define SO_SEQNO 6
120 #define SO_ALL_PACKETS 7
121 #define SO_MTU 8
122 #define SO_IPXTUN_ROUTE 9
123 #define SO_IPX_CHECKSUM 10
124
125 /*
126 * IPX addressing
127 */
128 union ipx_host {
129 u_char c_host[6];
130 u_short s_host[3];
131 };
132
133 union ipx_net {
134 u_char c_net[4];
135 u_short s_net[2];
136 };
137
138 union ipx_net_u {
139 union ipx_net net_e;
140 u_long long_e;
141 };
142
143 struct ipx_addr {
144 union ipx_net x_net;
145 union ipx_host x_host;
146 u_short x_port;
147 };
148
149 /*
150 * Socket address
151 */
152 struct sockaddr_ipx {
153 u_char sipx_len;
154 u_char sipx_family;
155 struct ipx_addr sipx_addr;
156 char sipx_zero[2];
157 };
158 #define sipx_port sipx_addr.x_port
159
160 /*
161 * Definitions for IPX Internetwork Packet Exchange Protocol
162 */
163 struct ipx {
164 u_short ipx_sum; /* Checksum */
165 u_short ipx_len; /* Length, in bytes, including header */
166 u_char ipx_tc; /* Transport Control (i.e. hop count) */
167 u_char ipx_pt; /* Packet Type (i.e. level 2 protocol) */
168 struct ipx_addr ipx_dna; /* Destination Network Address */
169 struct ipx_addr ipx_sna; /* Source Network Address */
170 } __packed;
171
172 #define ipx_neteqnn(a,b) \
173 (((a).s_net[0] == (b).s_net[0]) && ((a).s_net[1] == (b).s_net[1]))
174 #define ipx_neteq(a,b) ipx_neteqnn((a).x_net, (b).x_net)
175 #define satoipx_addr(sa) (((struct sockaddr_ipx *)&(sa))->sipx_addr)
176 #define ipx_hosteqnh(s,t) ((s).s_host[0] == (t).s_host[0] && \
177 (s).s_host[1] == (t).s_host[1] && (s).s_host[2] == (t).s_host[2])
178 #define ipx_hosteq(s,t) (ipx_hosteqnh((s).x_host,(t).x_host))
179 #define ipx_nullnet(x) (((x).x_net.s_net[0]==0) && ((x).x_net.s_net[1]==0))
180 #define ipx_nullhost(x) (((x).x_host.s_host[0] == 0) && \
181 ((x).x_host.s_host[1] == 0) && ((x).x_host.s_host[2] == 0))
182 #define ipx_wildnet(x) (((x).x_net.s_net[0] == 0xffff) && \
183 ((x).x_net.s_net[1] == 0xffff))
184 #define ipx_wildhost(x) (((x).x_host.s_host[0] == 0xffff) && \
185 ((x).x_host.s_host[1] == 0xffff) && ((x).x_host.s_host[2] == 0xffff))
186
187 #include <sys/cdefs.h>
188
189 __BEGIN_DECLS
190 struct ipx_addr ipx_addr(const char *);
191 char *ipx_ntoa(struct ipx_addr);
192 __END_DECLS
193
194 #endif /* !_NETIPX_IPX_H_ */
Cache object: b69ded97db3ab065e00b35bfa7390a3a
|