Correct BSD License clause numbering from 1-2-4 to 1-2-3.
[dragonfly.git] / sys / netproto / ipx / ipx_proto.c
1 /*
2  * Copyright (c) 1995, Mike Mitchell
3  * Copyright (c) 1984, 1985, 1986, 1987, 1993
4  *      The Regents of the University of California.  All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. Neither the name of the University nor the names of its contributors
15  *    may be used to endorse or promote products derived from this software
16  *    without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  *      @(#)ipx_proto.c
31  *
32  * $FreeBSD: src/sys/netipx/ipx_proto.c,v 1.15 1999/08/28 00:49:41 peter Exp $
33  */
34
35 #include "opt_ipx.h"
36
37 #include <sys/param.h>
38 #include <sys/socket.h>
39 #include <sys/protosw.h>
40 #include <sys/domain.h>
41 #include <sys/kernel.h>
42 #include <sys/queue.h>
43 #include <sys/sysctl.h>
44 #include <sys/globaldata.h>
45 #include <sys/thread.h>
46
47 #include <net/radix.h>
48
49 #include "ipx.h"
50 #include "ipx_var.h"
51 #include "spx.h"
52
53 static  struct domain ipxdomain;
54 static  struct pr_usrreqs nousrreqs;
55
56 /*
57  * IPX protocol family: IPX, ERR, PXP, SPX, ROUTE.
58  */
59
60 static struct protosw ipxsw[] = {
61     {
62         .pr_type = 0,
63         .pr_domain = &ipxdomain,
64         .pr_protocol = 0,
65         .pr_flags = 0,
66
67         .pr_init = ipx_init,
68         .pr_usrreqs = &nousrreqs
69     },
70     {
71         .pr_type = SOCK_DGRAM,
72         .pr_domain = &ipxdomain,
73         .pr_protocol = 0,
74         .pr_flags = PR_ATOMIC|PR_ADDR,
75
76         .pr_input = NULL,
77         .pr_output = NULL,
78         .pr_ctlinput = ipx_ctlinput,
79         .pr_ctloutput = ipx_ctloutput,
80
81         .pr_ctlport = cpu0_ctlport,
82         .pr_usrreqs = &ipx_usrreqs
83     },
84     {
85         .pr_type = SOCK_STREAM,
86         .pr_domain = &ipxdomain,
87         .pr_protocol = IPXPROTO_SPX,
88         .pr_flags = PR_CONNREQUIRED|PR_WANTRCVD,
89
90         .pr_input = NULL,
91         .pr_output = NULL,
92         .pr_ctlinput = spx_ctlinput,
93         .pr_ctloutput = spx_ctloutput,
94         .pr_ctlport = cpu0_ctlport,
95
96         .pr_init = spx_init,
97         .pr_fasttimo = spx_fasttimo,
98         .pr_slowtimo = spx_slowtimo,
99         .pr_drain = NULL,
100         .pr_usrreqs = &spx_usrreqs
101     },
102     {
103         .pr_type = SOCK_SEQPACKET,
104         .pr_domain = &ipxdomain,
105         .pr_protocol = IPXPROTO_SPX,
106         .pr_flags = PR_CONNREQUIRED|PR_WANTRCVD|PR_ATOMIC,
107
108         .pr_input = NULL,
109         .pr_output = NULL,
110         .pr_ctlinput = spx_ctlinput,
111         .pr_ctloutput = spx_ctloutput,
112
113         .pr_ctlport = cpu0_ctlport,
114         .pr_usrreqs = &spx_usrreq_sps
115     },
116     {
117         .pr_type = SOCK_RAW,
118         .pr_domain = &ipxdomain,
119         .pr_protocol = IPXPROTO_RAW,
120         .pr_flags = PR_ATOMIC|PR_ADDR,
121
122         .pr_input = NULL,
123         .pr_output = NULL,
124         .pr_ctlinput = NULL,
125         .pr_ctloutput = ipx_ctloutput,
126
127         .pr_usrreqs = &ripx_usrreqs
128     },
129 #ifdef IPTUNNEL
130 #if 0
131     {
132         .pr_type = SOCK_RAW,
133         .pr_domain = &ipxdomain,
134         .pr_protocol = IPPROTO_IPX,
135         .pr_flags = PR_ATOMIC|PR_ADDR,
136
137         .pr_input = iptun_input,
138         .pr_output = rip_output,
139         .pr_ctlinput = iptun_ctlinput,
140         .pr_ctloutput = 0,
141
142         .pr_ctlport = cpu0_ctlport,
143         .pr_usrreqs = &rip_usrreqs
144     },
145 #endif
146 #endif
147 };
148
149 static int
150 ipx_inithead(void **head, int off)
151 {
152         return rn_inithead(head, rn_cpumaskhead(mycpuid), off);
153 }
154
155 static struct   domain ipxdomain =
156     { AF_IPX, "network systems", 0, 0, 0, 
157       ipxsw, &ipxsw[NELEM(ipxsw)], SLIST_ENTRY_INITIALIZER,
158       ipx_inithead, 16, sizeof(struct sockaddr_ipx)};
159
160 DOMAIN_SET(ipx);
161 SYSCTL_NODE(_net,       PF_IPX,         ipx,    CTLFLAG_RW, 0,
162         "IPX/SPX");
163
164 SYSCTL_NODE(_net_ipx,   IPXPROTO_RAW,   ipx,    CTLFLAG_RW, 0, "IPX");
165 SYSCTL_NODE(_net_ipx,   IPXPROTO_SPX,   spx,    CTLFLAG_RW, 0, "SPX");