1 /* $NetBSD: iso_proto.c,v 1.21 2006/10/10 21:49:15 dogcow Exp $ */
2
3 /*-
4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * @(#)iso_proto.c 8.2 (Berkeley) 2/9/95
32 */
33
34 /***********************************************************
35 Copyright IBM Corporation 1987
36
37 All Rights Reserved
38
39 Permission to use, copy, modify, and distribute this software and its
40 documentation for any purpose and without fee is hereby granted,
41 provided that the above copyright notice appear in all copies and that
42 both that copyright notice and this permission notice appear in
43 supporting documentation, and that the name of IBM not be
44 used in advertising or publicity pertaining to distribution of the
45 software without specific, written prior permission.
46
47 IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
48 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
49 IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
50 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
51 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
52 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
53 SOFTWARE.
54
55 ******************************************************************/
56
57 /*
58 * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
59 */
60 /*
61 * iso_proto.c : protocol switch tables in the ISO domain
62 *
63 * ISO protocol family includes TP, CLTP, CLNP, 8208
64 * TP and CLNP are implemented here.
65 */
66
67 #include <sys/cdefs.h>
68 __KERNEL_RCSID(0, "$NetBSD: iso_proto.c,v 1.21 2006/10/10 21:49:15 dogcow Exp $");
69
70
71 #include <sys/param.h>
72 #include <sys/socket.h>
73 #include <sys/protosw.h>
74 #include <sys/domain.h>
75 #include <sys/mbuf.h>
76
77 #include <net/radix.h>
78
79 #include <netiso/iso.h>
80
81 #include <netiso/clnp.h>
82 #include <netiso/tp_param.h>
83 #include <netiso/tp_var.h>
84 #include <netiso/esis.h>
85 #include <netiso/idrp_var.h>
86 #include <netiso/iso_pcb.h>
87 #include <netiso/cltp_var.h>
88
89 const int isoctlerrmap[PRC_NCMDS] = {
90 0, 0, 0, 0,
91 0, EMSGSIZE, EHOSTDOWN, EHOSTUNREACH,
92 EHOSTUNREACH, EHOSTUNREACH, ECONNREFUSED, ECONNREFUSED,
93 EMSGSIZE, EHOSTUNREACH, 0, 0,
94 0, 0, 0, 0,
95 ENOPROTOOPT
96 };
97
98 DOMAIN_DEFINE(isodomain); /* forward declare and add to link set */
99
100 const struct protosw isosw[] = {
101 /*
102 * We need a datagram entry through which net mgmt programs can get
103 * to the iso_control procedure (iso ioctls). Thus, a minimal
104 * SOCK_DGRAM interface is provided here.
105 * THIS ONE MUST BE FIRST: Kludge city : socket() says if(!proto) call
106 * pffindtype, which gets the first entry that matches the type.
107 * sigh.
108 */
109 {SOCK_DGRAM, &isodomain, ISOPROTO_CLTP, PR_ATOMIC | PR_ADDR,
110 0, cltp_output, 0, 0,
111 cltp_usrreq,
112 cltp_init, 0, 0, 0
113 },
114
115 /*
116 * A datagram interface for clnp cannot co-exist with TP/CLNP
117 * because CLNP has no way to discriminate incoming TP packets from
118 * packets coming in for any other higher layer protocol.
119 * Old way: set it up so that pffindproto(... dgm, clnp) fails.
120 * New way: let pffindproto work (for x.25, thank you) but create
121 * a clnp_usrreq() that returns error on PRU_ATTACH.
122 */
123 {SOCK_DGRAM, &isodomain, ISOPROTO_CLNP, 0,
124 0, clnp_output, 0, 0,
125 clnp_usrreq,
126 clnp_init, 0, clnp_slowtimo, clnp_drain,
127 },
128
129 /* raw clnp */
130 {SOCK_RAW, &isodomain, ISOPROTO_RAW, PR_ATOMIC | PR_ADDR,
131 rclnp_input, rclnp_output, 0, rclnp_ctloutput,
132 clnp_usrreq,
133 0, 0, 0, 0
134 },
135
136 /* ES-IS protocol */
137 {SOCK_DGRAM, &isodomain, ISOPROTO_ESIS, PR_ATOMIC | PR_ADDR,
138 esis_input, 0, esis_ctlinput, 0,
139 esis_usrreq,
140 esis_init, 0, 0, 0
141 },
142
143 /* ISOPROTO_INTRAISIS */
144 {SOCK_DGRAM, &isodomain, ISOPROTO_INTRAISIS, PR_ATOMIC | PR_ADDR,
145 isis_input, 0, 0, 0,
146 esis_usrreq,
147 0, 0, 0, 0
148 },
149
150 /* ISOPROTO_IDRP */
151 {SOCK_DGRAM, &isodomain, ISOPROTO_IDRP, PR_ATOMIC | PR_ADDR,
152 idrp_input, 0, 0, 0,
153 idrp_usrreq,
154 idrp_init, 0, 0, 0
155 },
156
157 /* ISOPROTO_TP */
158 {SOCK_SEQPACKET, &isodomain, ISOPROTO_TP, PR_CONNREQUIRED | PR_WANTRCVD | PR_LISTEN | PR_ABRTACPTDIS,
159 tpclnp_input, 0, tpclnp_ctlinput, tp_ctloutput,
160 tp_usrreq,
161 tp_init, tp_fasttimo, tp_slowtimo, tp_drain,
162 },
163
164 #ifdef TPCONS
165 /* ISOPROTO_TP */
166 {SOCK_SEQPACKET, &isodomain, ISOPROTO_TP0, PR_CONNREQUIRED | PR_WANTRCVD | PR_LISTEN | PR_ABRTACPTDIS,
167 tpcons_input, 0, 0, tp_ctloutput,
168 tp_usrreq,
169 cons_init, 0, 0, 0,
170 },
171 #endif
172 };
173
174 extern struct ifqueue clnlintrq;
175
176 struct domain isodomain = {
177 PF_ISO, /* family */
178 "iso-domain", /* name */
179 0, /* initialize routine */
180 0, /* externalize access rights */
181 0, /* dispose of internalized rights */
182 isosw, /* protosw */
183 &isosw[sizeof(isosw) / sizeof(isosw[0])], /* NPROTOSW */
184 rn_inithead, /* rtattach */
185 48, /* rtoffset */
186 sizeof(struct sockaddr_iso), /* maxkeylen */
187 0,
188 0,
189 { &clnlintrq, NULL }, /* ifqueues */
190 { NULL },
191 MOWNER_INIT("",""),
192 };
Cache object: 24d54522baf3e9595be71ca64b01165b
|