ipx_proto.c revision 273736
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_proto.c
60 */
61
62#include <sys/cdefs.h>
63__FBSDID("$FreeBSD: stable/10/sys/netipx/ipx_proto.c 273736 2014-10-27 14:38:00Z hselasky $");
64
65#include "opt_ipx.h"
66
67#include <sys/param.h>
68#include <sys/systm.h>
69#include <sys/socket.h>
70#include <sys/protosw.h>
71#include <sys/domain.h>
72#include <sys/kernel.h>
73#include <sys/queue.h>
74#include <sys/sysctl.h>
75
76#include <net/radix.h>
77
78#include <netipx/ipx.h>
79#include <netipx/ipx_var.h>
80#include <netipx/spx.h>
81
82static	struct pr_usrreqs nousrreqs;
83
84/*
85 * IPX protocol family: IPX, ERR, PXP, SPX, ROUTE.
86 */
87
88static	struct domain ipxdomain;
89
90static struct protosw ipxsw[] = {
91{
92	.pr_domain =		&ipxdomain,
93	.pr_init =		ipx_init,
94	.pr_usrreqs =		&nousrreqs
95},
96{
97	.pr_type =		SOCK_DGRAM,
98	.pr_domain =		&ipxdomain,
99	.pr_flags =		PR_ATOMIC|PR_ADDR,
100	.pr_ctlinput =		ipx_ctlinput,
101	.pr_ctloutput =		ipx_ctloutput,
102	.pr_usrreqs =		&ipx_usrreqs
103},
104{
105	.pr_type =		SOCK_STREAM,
106	.pr_domain =		&ipxdomain,
107	.pr_protocol =		IPXPROTO_SPX,
108	.pr_flags =		PR_CONNREQUIRED|PR_WANTRCVD,
109	.pr_ctlinput =		spx_ctlinput,
110	.pr_ctloutput =		spx_ctloutput,
111	.pr_init =		spx_init,
112	.pr_fasttimo =		spx_fasttimo,
113	.pr_slowtimo =		spx_slowtimo,
114	.pr_usrreqs =		&spx_usrreqs
115},
116{
117	.pr_type =		SOCK_SEQPACKET,
118	.pr_domain =		&ipxdomain,
119	.pr_protocol =		IPXPROTO_SPX,
120	.pr_flags =		PR_CONNREQUIRED|PR_WANTRCVD|PR_ATOMIC,
121	.pr_ctlinput =		spx_ctlinput,
122	.pr_ctloutput =		spx_ctloutput,
123	.pr_usrreqs =		&spx_usrreq_sps
124},
125{
126	.pr_type =		SOCK_RAW,
127	.pr_domain =		&ipxdomain,
128	.pr_protocol =		IPXPROTO_RAW,
129	.pr_flags =		PR_ATOMIC|PR_ADDR,
130	.pr_ctloutput =		ipx_ctloutput,
131	.pr_usrreqs =		&ripx_usrreqs
132},
133};
134
135extern int ipx_inithead(void **, int);
136
137static struct	domain ipxdomain = {
138	.dom_family =		AF_IPX,
139	.dom_name =		"network systems",
140	.dom_protosw =		ipxsw,
141	.dom_protoswNPROTOSW =	&ipxsw[sizeof(ipxsw)/sizeof(ipxsw[0])],
142	.dom_rtattach =		ipx_inithead,
143	.dom_rtoffset =		16,
144	.dom_maxrtkey =		sizeof(struct sockaddr_ipx)
145};
146
147
148/* shim to adapt arguments */
149int
150ipx_inithead(void **head, int offset)
151{
152	return rn_inithead(head, offset);
153}
154
155DOMAIN_SET(ipx);
156SYSCTL_NODE(_net,	PF_IPX,		ipx,	CTLFLAG_RW, 0,
157	"IPX/SPX");
158
159SYSCTL_NODE(_net_ipx,	IPXPROTO_RAW,	ipx,	CTLFLAG_RW, 0, "IPX");
160static SYSCTL_NODE(_net_ipx, IPXPROTO_SPX, spx,	CTLFLAG_RW, 0, "SPX");
161