1139823Simp/*-
211819Sjulian * Copyright (c) 1984, 1985, 1986, 1987, 1993
311819Sjulian *	The Regents of the University of California.  All rights reserved.
411819Sjulian *
511819Sjulian * Redistribution and use in source and binary forms, with or without
611819Sjulian * modification, are permitted provided that the following conditions
711819Sjulian * are met:
811819Sjulian * 1. Redistributions of source code must retain the above copyright
911819Sjulian *    notice, this list of conditions and the following disclaimer.
1011819Sjulian * 2. Redistributions in binary form must reproduce the above copyright
1111819Sjulian *    notice, this list of conditions and the following disclaimer in the
1211819Sjulian *    documentation and/or other materials provided with the distribution.
13165899Srwatson * 4. Neither the name of the University nor the names of its contributors
14165899Srwatson *    may be used to endorse or promote products derived from this software
15165899Srwatson *    without specific prior written permission.
16165899Srwatson *
17165899Srwatson * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18165899Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19165899Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20165899Srwatson * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21165899Srwatson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22165899Srwatson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23165899Srwatson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24165899Srwatson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25165899Srwatson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26165899Srwatson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27165899Srwatson * SUCH DAMAGE.
28165899Srwatson *
29165899Srwatson * Copyright (c) 1995, Mike Mitchell
30165899Srwatson *
31165899Srwatson * Redistribution and use in source and binary forms, with or without
32165899Srwatson * modification, are permitted provided that the following conditions
33165899Srwatson * are met:
34165899Srwatson * 1. Redistributions of source code must retain the above copyright
35165899Srwatson *    notice, this list of conditions and the following disclaimer.
36165899Srwatson * 2. Redistributions in binary form must reproduce the above copyright
37165899Srwatson *    notice, this list of conditions and the following disclaimer in the
38165899Srwatson *    documentation and/or other materials provided with the distribution.
3911819Sjulian * 3. All advertising materials mentioning features or use of this software
4011819Sjulian *    must display the following acknowledgement:
4111819Sjulian *	This product includes software developed by the University of
4211819Sjulian *	California, Berkeley and its contributors.
4311819Sjulian * 4. Neither the name of the University nor the names of its contributors
4411819Sjulian *    may be used to endorse or promote products derived from this software
4511819Sjulian *    without specific prior written permission.
4611819Sjulian *
4711819Sjulian * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
4811819Sjulian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4911819Sjulian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5011819Sjulian * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
5111819Sjulian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5211819Sjulian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5311819Sjulian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5411819Sjulian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5511819Sjulian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5611819Sjulian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5711819Sjulian * SUCH DAMAGE.
5811819Sjulian *
5912057Sjulian *	@(#)ipx.h
6012057Sjulian *
6150477Speter * $FreeBSD$
6211819Sjulian */
6311819Sjulian
6411819Sjulian#ifndef _NETIPX_IPX_H_
6512470Sbde#define	_NETIPX_IPX_H_
6611819Sjulian
6711819Sjulian/*
6811819Sjulian * Constants and Structures
6911819Sjulian */
7011819Sjulian
7111819Sjulian/*
7211819Sjulian * Protocols
7311819Sjulian */
7425652Sjhay#define IPXPROTO_UNKWN		0	/* Unknown */
7525652Sjhay#define IPXPROTO_RI		1	/* RIP Routing Information */
7625652Sjhay#define IPXPROTO_PXP		4	/* IPX Packet Exchange Protocol */
7725652Sjhay#define IPXPROTO_SPX		5	/* SPX Sequenced Packet */
7825652Sjhay#define IPXPROTO_NCP		17	/* NCP NetWare Core */
7925652Sjhay#define IPXPROTO_NETBIOS	20	/* Propagated Packet */
8025652Sjhay#define IPXPROTO_RAW		255	/* Placemarker*/
8125652Sjhay#define IPXPROTO_MAX		256	/* Placemarker*/
8211819Sjulian
8311819Sjulian/*
8411819Sjulian * Port/Socket numbers: network standard functions
8511819Sjulian */
8611819Sjulian
8725652Sjhay#define IPXPORT_RI		1	/* NS RIP Routing Information */
8825652Sjhay#define IPXPORT_ECHO		2	/* NS Echo */
8925652Sjhay#define IPXPORT_RE		3	/* NS Router Error */
9025652Sjhay#define IPXPORT_NCP		0x0451	/* NW NCP Core Protocol */
9125652Sjhay#define IPXPORT_SAP		0x0452	/* NW SAP Service Advertising */
9225652Sjhay#define IPXPORT_RIP		0x0453	/* NW RIP Routing Information */
9325652Sjhay#define IPXPORT_NETBIOS		0x0455	/* NW NetBIOS */
9425652Sjhay#define IPXPORT_DIAGS		0x0456	/* NW Diagnostics */
9525652Sjhay/*
9626965Sjhay * Ports < IPXPORT_RESERVED are reserved for privileged
9725652Sjhay */
9825652Sjhay#define IPXPORT_RESERVED	0x4000
9925652Sjhay/*
10026965Sjhay * Ports > IPXPORT_WELLKNOWN are reserved for privileged
10125652Sjhay * processes (e.g. root).
10225652Sjhay */
10325652Sjhay#define IPXPORT_WELLKNOWN	0x6000
10411819Sjulian
10511819Sjulian/* flags passed to ipx_outputfl as last parameter */
10611819Sjulian
10711819Sjulian#define	IPX_FORWARDING		0x1	/* most of ipx header exists */
10811819Sjulian#define	IPX_ROUTETOIF		0x10	/* same as SO_DONTROUTE */
10911819Sjulian#define	IPX_ALLOWBROADCAST	SO_BROADCAST	/* can send broadcast packets */
11011819Sjulian
11111819Sjulian#define IPX_MAXHOPS		15
11211819Sjulian
11311819Sjulian/* flags passed to get/set socket option */
11411819Sjulian#define	SO_HEADERS_ON_INPUT	1
11511819Sjulian#define	SO_HEADERS_ON_OUTPUT	2
11611819Sjulian#define	SO_DEFAULT_HEADERS	3
11711819Sjulian#define	SO_LAST_HEADER		4
118170664Srwatson#define	SO_IPXIP_ROUTE		5	/* No longer implemented. */
11911819Sjulian#define SO_SEQNO		6
12011819Sjulian#define	SO_ALL_PACKETS		7
12111819Sjulian#define SO_MTU			8
12211819Sjulian#define SO_IPXTUN_ROUTE		9
12350519Sjhay#define SO_IPX_CHECKSUM		10
12411819Sjulian
12511819Sjulian/*
12611819Sjulian * IPX addressing
12711819Sjulian */
12811819Sjulianunion ipx_host {
12911819Sjulian	u_char	c_host[6];
13011819Sjulian	u_short	s_host[3];
13111819Sjulian};
13211819Sjulian
13311819Sjulianunion ipx_net {
13411819Sjulian	u_char	c_net[4];
13511819Sjulian	u_short	s_net[2];
13611819Sjulian};
13711819Sjulian
13811819Sjulianunion ipx_net_u {
13911819Sjulian	union	ipx_net	net_e;
14011819Sjulian	u_long		long_e;
14111819Sjulian};
14211819Sjulian
14311819Sjulianstruct ipx_addr {
14411819Sjulian	union ipx_net	x_net;
14511819Sjulian	union ipx_host	x_host;
14611819Sjulian	u_short		x_port;
14711819Sjulian};
14811819Sjulian
14911819Sjulian/*
15011819Sjulian * Socket address
15111819Sjulian */
15211819Sjulianstruct sockaddr_ipx {
15311819Sjulian	u_char		sipx_len;
15411819Sjulian	u_char		sipx_family;
15511819Sjulian	struct ipx_addr	sipx_addr;
15611819Sjulian	char		sipx_zero[2];
15711819Sjulian};
15811819Sjulian#define sipx_port sipx_addr.x_port
15911819Sjulian
16011819Sjulian/*
16125652Sjhay * Definitions for IPX Internetwork Packet Exchange Protocol
16211819Sjulian */
16311819Sjulianstruct ipx {
16411819Sjulian	u_short	ipx_sum;	/* Checksum */
16511819Sjulian	u_short	ipx_len;	/* Length, in bytes, including header */
16613765Smpp	u_char	ipx_tc;		/* Transport Control (i.e. hop count) */
16711819Sjulian	u_char	ipx_pt;		/* Packet Type (i.e. level 2 protocol) */
16811819Sjulian	struct ipx_addr	ipx_dna;	/* Destination Network Address */
16911819Sjulian	struct ipx_addr	ipx_sna;	/* Source Network Address */
170139562Srwatson} __packed;
17111819Sjulian
17211819Sjulian#define ipx_neteqnn(a,b) \
17325652Sjhay	(((a).s_net[0] == (b).s_net[0]) && ((a).s_net[1] == (b).s_net[1]))
17411819Sjulian#define ipx_neteq(a,b) ipx_neteqnn((a).x_net, (b).x_net)
17511819Sjulian#define satoipx_addr(sa) (((struct sockaddr_ipx *)&(sa))->sipx_addr)
17611819Sjulian#define ipx_hosteqnh(s,t) ((s).s_host[0] == (t).s_host[0] && \
17711819Sjulian	(s).s_host[1] == (t).s_host[1] && (s).s_host[2] == (t).s_host[2])
17811819Sjulian#define ipx_hosteq(s,t) (ipx_hosteqnh((s).x_host,(t).x_host))
17911819Sjulian#define ipx_nullnet(x) (((x).x_net.s_net[0]==0) && ((x).x_net.s_net[1]==0))
18025652Sjhay#define ipx_nullhost(x) (((x).x_host.s_host[0] == 0) && \
18125652Sjhay	((x).x_host.s_host[1] == 0) && ((x).x_host.s_host[2] == 0))
18225652Sjhay#define ipx_wildnet(x) (((x).x_net.s_net[0] == 0xffff) && \
18325652Sjhay	((x).x_net.s_net[1] == 0xffff))
18425652Sjhay#define ipx_wildhost(x) (((x).x_host.s_host[0] == 0xffff) && \
18525652Sjhay	((x).x_host.s_host[1] == 0xffff) && ((x).x_host.s_host[2] == 0xffff))
18611819Sjulian
18711819Sjulian#include <sys/cdefs.h>
18811819Sjulian
18911819Sjulian__BEGIN_DECLS
190169463Srwatsonstruct ipx_addr	 ipx_addr(const char *);
191169463Srwatsonchar		*ipx_ntoa(struct ipx_addr);
19211819Sjulian__END_DECLS
19311819Sjulian
19426965Sjhay#endif /* !_NETIPX_IPX_H_ */
195