1df8bae1dSRodney W. Grimes /* 2df8bae1dSRodney W. Grimes * Copyright (c) 1982, 1986, 1993 3df8bae1dSRodney W. Grimes * The Regents of the University of California. All rights reserved. 4df8bae1dSRodney W. Grimes * 5df8bae1dSRodney W. Grimes * Redistribution and use in source and binary forms, with or without 6df8bae1dSRodney W. Grimes * modification, are permitted provided that the following conditions 7df8bae1dSRodney W. Grimes * are met: 8df8bae1dSRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 9df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer. 10df8bae1dSRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 11df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 12df8bae1dSRodney W. Grimes * documentation and/or other materials provided with the distribution. 13df8bae1dSRodney W. Grimes * 3. All advertising materials mentioning features or use of this software 14df8bae1dSRodney W. Grimes * must display the following acknowledgement: 15df8bae1dSRodney W. Grimes * This product includes software developed by the University of 16df8bae1dSRodney W. Grimes * California, Berkeley and its contributors. 17df8bae1dSRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 18df8bae1dSRodney W. Grimes * may be used to endorse or promote products derived from this software 19df8bae1dSRodney W. Grimes * without specific prior written permission. 20df8bae1dSRodney W. Grimes * 21df8bae1dSRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22df8bae1dSRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23df8bae1dSRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24df8bae1dSRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25df8bae1dSRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26df8bae1dSRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27df8bae1dSRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28df8bae1dSRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29df8bae1dSRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30df8bae1dSRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31df8bae1dSRodney W. Grimes * SUCH DAMAGE. 32df8bae1dSRodney W. Grimes * 33425f123eSGarrett Wollman * @(#)in_proto.c 8.2 (Berkeley) 2/9/95 34dcc3cb75SPoul-Henning Kamp * $Id: in_proto.c,v 1.21 1995/11/14 20:34:05 phk Exp $ 35df8bae1dSRodney W. Grimes */ 36df8bae1dSRodney W. Grimes 37df8bae1dSRodney W. Grimes #include <sys/param.h> 38748e0b0aSGarrett Wollman #include <sys/kernel.h> 39df8bae1dSRodney W. Grimes #include <sys/socket.h> 40dcc3cb75SPoul-Henning Kamp #include <sys/socketvar.h> 41df8bae1dSRodney W. Grimes #include <sys/domain.h> 42df8bae1dSRodney W. Grimes #include <sys/mbuf.h> 43dcc3cb75SPoul-Henning Kamp #include <sys/protosw.h> 4415bd2b43SDavid Greenman #include <sys/queue.h> 4598163b98SPoul-Henning Kamp #include <sys/sysctl.h> 46df8bae1dSRodney W. Grimes 47df8bae1dSRodney W. Grimes #include <net/if.h> 48df8bae1dSRodney W. Grimes #include <net/radix.h> 49df8bae1dSRodney W. Grimes #include <net/route.h> 50df8bae1dSRodney W. Grimes 51df8bae1dSRodney W. Grimes #include <netinet/in.h> 52df8bae1dSRodney W. Grimes #include <netinet/in_systm.h> 53df8bae1dSRodney W. Grimes #include <netinet/ip.h> 54df8bae1dSRodney W. Grimes #include <netinet/ip_var.h> 55df8bae1dSRodney W. Grimes #include <netinet/ip_icmp.h> 56df8bae1dSRodney W. Grimes #include <netinet/in_pcb.h> 57df8bae1dSRodney W. Grimes #include <netinet/igmp_var.h> 58df8bae1dSRodney W. Grimes #include <netinet/tcp.h> 59df8bae1dSRodney W. Grimes #include <netinet/tcp_fsm.h> 60df8bae1dSRodney W. Grimes #include <netinet/tcp_seq.h> 61df8bae1dSRodney W. Grimes #include <netinet/tcp_timer.h> 62df8bae1dSRodney W. Grimes #include <netinet/tcp_var.h> 63df8bae1dSRodney W. Grimes #include <netinet/tcpip.h> 64610ee2f9SDavid Greenman #ifdef TCPDEBUG 65df8bae1dSRodney W. Grimes #include <netinet/tcp_debug.h> 66610ee2f9SDavid Greenman #endif 67df8bae1dSRodney W. Grimes #include <netinet/udp.h> 68df8bae1dSRodney W. Grimes #include <netinet/udp_var.h> 69df8bae1dSRodney W. Grimes /* 70df8bae1dSRodney W. Grimes * TCP/IP protocol family: IP, ICMP, UDP, TCP. 71df8bae1dSRodney W. Grimes */ 72df8bae1dSRodney W. Grimes 73cc6a66f2SJulian Elischer #ifdef IPXIP 74cc6a66f2SJulian Elischer void ipxip_input(), ipxip_ctlinput(); 75cc6a66f2SJulian Elischer #endif 76cc6a66f2SJulian Elischer 77df8bae1dSRodney W. Grimes #ifdef NSIP 78df8bae1dSRodney W. Grimes void idpip_input(), nsip_ctlinput(); 79df8bae1dSRodney W. Grimes #endif 80df8bae1dSRodney W. Grimes 81df8bae1dSRodney W. Grimes #ifdef TPIP 82425f123eSGarrett Wollman void tpip_input(), tpip_ctlinput(), tp_init(), tp_slowtimo(), tp_drain(); 83425f123eSGarrett Wollman int tp_ctloutput(), tp_usrreq(); 84df8bae1dSRodney W. Grimes #endif 85df8bae1dSRodney W. Grimes 86df8bae1dSRodney W. Grimes #ifdef EON 87df8bae1dSRodney W. Grimes void eoninput(), eonctlinput(), eonprotoinit(); 88df8bae1dSRodney W. Grimes #endif /* EON */ 89df8bae1dSRodney W. Grimes 901c5de19aSGarrett Wollman void rsvp_input(struct mbuf *, int); 911c5de19aSGarrett Wollman void ipip_input(struct mbuf *, int); 92f0068c4aSGarrett Wollman 93df8bae1dSRodney W. Grimes extern struct domain inetdomain; 94df8bae1dSRodney W. Grimes 95df8bae1dSRodney W. Grimes struct protosw inetsw[] = { 96df8bae1dSRodney W. Grimes { 0, &inetdomain, 0, 0, 97df8bae1dSRodney W. Grimes 0, ip_output, 0, 0, 98df8bae1dSRodney W. Grimes 0, 990312fbe9SPoul-Henning Kamp ip_init, 0, ip_slowtimo, ip_drain 100df8bae1dSRodney W. Grimes }, 101df8bae1dSRodney W. Grimes { SOCK_DGRAM, &inetdomain, IPPROTO_UDP, PR_ATOMIC|PR_ADDR, 102df8bae1dSRodney W. Grimes udp_input, 0, udp_ctlinput, ip_ctloutput, 103df8bae1dSRodney W. Grimes udp_usrreq, 1040312fbe9SPoul-Henning Kamp udp_init 105df8bae1dSRodney W. Grimes }, 106999f1343SGarrett Wollman { SOCK_STREAM, &inetdomain, IPPROTO_TCP, 107999f1343SGarrett Wollman PR_CONNREQUIRED|PR_IMPLOPCL|PR_WANTRCVD, 108df8bae1dSRodney W. Grimes tcp_input, 0, tcp_ctlinput, tcp_ctloutput, 109df8bae1dSRodney W. Grimes tcp_usrreq, 1100312fbe9SPoul-Henning Kamp tcp_init, tcp_fasttimo, tcp_slowtimo, tcp_drain 111df8bae1dSRodney W. Grimes }, 112df8bae1dSRodney W. Grimes { SOCK_RAW, &inetdomain, IPPROTO_RAW, PR_ATOMIC|PR_ADDR, 113df8bae1dSRodney W. Grimes rip_input, rip_output, 0, rip_ctloutput, 114df8bae1dSRodney W. Grimes rip_usrreq, 115df8bae1dSRodney W. Grimes 0, 0, 0, 0, 116df8bae1dSRodney W. Grimes }, 117df8bae1dSRodney W. Grimes { SOCK_RAW, &inetdomain, IPPROTO_ICMP, PR_ATOMIC|PR_ADDR, 118df8bae1dSRodney W. Grimes icmp_input, rip_output, 0, rip_ctloutput, 1190312fbe9SPoul-Henning Kamp rip_usrreq 120df8bae1dSRodney W. Grimes }, 121df8bae1dSRodney W. Grimes { SOCK_RAW, &inetdomain, IPPROTO_IGMP, PR_ATOMIC|PR_ADDR, 122df8bae1dSRodney W. Grimes igmp_input, rip_output, 0, rip_ctloutput, 123df8bae1dSRodney W. Grimes rip_usrreq, 1240312fbe9SPoul-Henning Kamp igmp_init, igmp_fasttimo, igmp_slowtimo 125df8bae1dSRodney W. Grimes }, 126f0068c4aSGarrett Wollman { SOCK_RAW, &inetdomain, IPPROTO_RSVP, PR_ATOMIC|PR_ADDR, 1271c5de19aSGarrett Wollman rsvp_input, rip_output, 0, rip_ctloutput, 128f0068c4aSGarrett Wollman rip_usrreq, 129f0068c4aSGarrett Wollman 0, 0, 0, 0, 130f0068c4aSGarrett Wollman }, 131fba14c2eSGarrett Wollman { SOCK_RAW, &inetdomain, IPPROTO_IPIP, PR_ATOMIC|PR_ADDR, 1321c5de19aSGarrett Wollman ipip_input, rip_output, 0, rip_ctloutput, 133f0068c4aSGarrett Wollman rip_usrreq, 134f0068c4aSGarrett Wollman 0, 0, 0, 0, 135f0068c4aSGarrett Wollman }, 136df8bae1dSRodney W. Grimes #ifdef TPIP 137df8bae1dSRodney W. Grimes { SOCK_SEQPACKET,&inetdomain, IPPROTO_TP, PR_CONNREQUIRED|PR_WANTRCVD, 138df8bae1dSRodney W. Grimes tpip_input, 0, tpip_ctlinput, tp_ctloutput, 139df8bae1dSRodney W. Grimes tp_usrreq, 140df8bae1dSRodney W. Grimes tp_init, 0, tp_slowtimo, tp_drain, 141df8bae1dSRodney W. Grimes }, 142df8bae1dSRodney W. Grimes #endif 143df8bae1dSRodney W. Grimes /* EON (ISO CLNL over IP) */ 144df8bae1dSRodney W. Grimes #ifdef EON 145df8bae1dSRodney W. Grimes { SOCK_RAW, &inetdomain, IPPROTO_EON, 0, 146df8bae1dSRodney W. Grimes eoninput, 0, eonctlinput, 0, 147df8bae1dSRodney W. Grimes 0, 148df8bae1dSRodney W. Grimes eonprotoinit, 0, 0, 0, 149df8bae1dSRodney W. Grimes }, 150df8bae1dSRodney W. Grimes #endif 151cc6a66f2SJulian Elischer #ifdef IPXIP 152cc6a66f2SJulian Elischer { SOCK_RAW, &inetdomain, IPPROTO_IDP, PR_ATOMIC|PR_ADDR, 153cc6a66f2SJulian Elischer ipxip_input, rip_output, ipxip_ctlinput, 0, 154cc6a66f2SJulian Elischer rip_usrreq, 155cc6a66f2SJulian Elischer 0, 0, 0, 0, 156cc6a66f2SJulian Elischer }, 157cc6a66f2SJulian Elischer #endif 158df8bae1dSRodney W. Grimes #ifdef NSIP 159df8bae1dSRodney W. Grimes { SOCK_RAW, &inetdomain, IPPROTO_IDP, PR_ATOMIC|PR_ADDR, 160df8bae1dSRodney W. Grimes idpip_input, rip_output, nsip_ctlinput, 0, 161df8bae1dSRodney W. Grimes rip_usrreq, 162df8bae1dSRodney W. Grimes 0, 0, 0, 0, 163df8bae1dSRodney W. Grimes }, 164df8bae1dSRodney W. Grimes #endif 165df8bae1dSRodney W. Grimes /* raw wildcard */ 166df8bae1dSRodney W. Grimes { SOCK_RAW, &inetdomain, 0, PR_ATOMIC|PR_ADDR, 167df8bae1dSRodney W. Grimes rip_input, rip_output, 0, rip_ctloutput, 168df8bae1dSRodney W. Grimes rip_usrreq, 169df8bae1dSRodney W. Grimes rip_init, 0, 0, 0, 170df8bae1dSRodney W. Grimes }, 171df8bae1dSRodney W. Grimes }; 172df8bae1dSRodney W. Grimes 1735c2dae8eSGarrett Wollman extern int in_inithead(void **, int); 1745c2dae8eSGarrett Wollman 175df8bae1dSRodney W. Grimes struct domain inetdomain = 176df8bae1dSRodney W. Grimes { AF_INET, "internet", 0, 0, 0, 177df8bae1dSRodney W. Grimes inetsw, &inetsw[sizeof(inetsw)/sizeof(inetsw[0])], 0, 1785c2dae8eSGarrett Wollman in_inithead, 32, sizeof(struct sockaddr_in) 1795c2dae8eSGarrett Wollman }; 180df8bae1dSRodney W. Grimes 181748e0b0aSGarrett Wollman DOMAIN_SET(inet); 182748e0b0aSGarrett Wollman 18398163b98SPoul-Henning Kamp SYSCTL_NODE(_net,PF_INET, inet,CTLFLAG_RW,0, "InterNet Protocols"); 18498163b98SPoul-Henning Kamp 18598163b98SPoul-Henning Kamp SYSCTL_NODE(_net_inet,IPPROTO_IP, ip, CTLFLAG_RW,0, "IP"); 18698163b98SPoul-Henning Kamp SYSCTL_NODE(_net_inet,IPPROTO_ICMP,icmp,CTLFLAG_RW,0, "ICMP"); 18798163b98SPoul-Henning Kamp SYSCTL_NODE(_net_inet,IPPROTO_UDP, udp, CTLFLAG_RW,0, "UDP"); 18898163b98SPoul-Henning Kamp SYSCTL_NODE(_net_inet,IPPROTO_TCP, tcp, CTLFLAG_RW,0, "TCP"); 18998163b98SPoul-Henning Kamp SYSCTL_NODE(_net_inet,IPPROTO_IGMP,igmp,CTLFLAG_RW,0, "IGMP"); 19098163b98SPoul-Henning Kamp 191df8bae1dSRodney W. Grimes #include "imp.h" 192df8bae1dSRodney W. Grimes #if NIMP > 0 193df8bae1dSRodney W. Grimes extern struct domain impdomain; 194df8bae1dSRodney W. Grimes int rimp_output(), hostslowtimo(); 195df8bae1dSRodney W. Grimes 196df8bae1dSRodney W. Grimes struct protosw impsw[] = { 197df8bae1dSRodney W. Grimes { SOCK_RAW, &impdomain, 0, PR_ATOMIC|PR_ADDR, 198df8bae1dSRodney W. Grimes 0, rimp_output, 0, 0, 199df8bae1dSRodney W. Grimes rip_usrreq, 200df8bae1dSRodney W. Grimes 0, 0, hostslowtimo, 0, 201df8bae1dSRodney W. Grimes }, 202df8bae1dSRodney W. Grimes }; 203df8bae1dSRodney W. Grimes 204df8bae1dSRodney W. Grimes struct domain impdomain = 205df8bae1dSRodney W. Grimes { AF_IMPLINK, "imp", 0, 0, 0, 206df8bae1dSRodney W. Grimes impsw, &impsw[sizeof (impsw)/sizeof(impsw[0])] }; 207748e0b0aSGarrett Wollman 208748e0b0aSGarrett Wollman DOMAIN_SET(imp); 209748e0b0aSGarrett Wollman 210df8bae1dSRodney W. Grimes #endif 211df8bae1dSRodney W. Grimes 21226f9a767SRodney W. Grimes #if 0 213df8bae1dSRodney W. Grimes #include "hy.h" 214df8bae1dSRodney W. Grimes #if NHY > 0 215df8bae1dSRodney W. Grimes /* 216df8bae1dSRodney W. Grimes * HYPERchannel protocol family: raw interface. 217df8bae1dSRodney W. Grimes */ 218df8bae1dSRodney W. Grimes int rhy_output(); 219df8bae1dSRodney W. Grimes extern struct domain hydomain; 220df8bae1dSRodney W. Grimes 221df8bae1dSRodney W. Grimes struct protosw hysw[] = { 222df8bae1dSRodney W. Grimes { SOCK_RAW, &hydomain, 0, PR_ATOMIC|PR_ADDR, 223df8bae1dSRodney W. Grimes 0, rhy_output, 0, 0, 224df8bae1dSRodney W. Grimes rip_usrreq, 225df8bae1dSRodney W. Grimes 0, 0, 0, 0, 226df8bae1dSRodney W. Grimes }, 227df8bae1dSRodney W. Grimes }; 228df8bae1dSRodney W. Grimes 229df8bae1dSRodney W. Grimes struct domain hydomain = 230df8bae1dSRodney W. Grimes { AF_HYLINK, "hy", 0, 0, 0, hysw, &hysw[sizeof (hysw)/sizeof(hysw[0])] }; 231748e0b0aSGarrett Wollman 232748e0b0aSGarrett Wollman DOMAIN_SET(hy); 233df8bae1dSRodney W. Grimes #endif 23426f9a767SRodney W. Grimes #endif 235