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