in_proto.c revision 38482
129759Swollman/* 229759Swollman * Copyright (c) 1982, 1986, 1993 329759Swollman * The Regents of the University of California. All rights reserved. 429759Swollman * 529759Swollman * Redistribution and use in source and binary forms, with or without 629759Swollman * modification, are permitted provided that the following conditions 729759Swollman * are met: 829759Swollman * 1. Redistributions of source code must retain the above copyright 929759Swollman * notice, this list of conditions and the following disclaimer. 1029759Swollman * 2. Redistributions in binary form must reproduce the above copyright 1129759Swollman * notice, this list of conditions and the following disclaimer in the 1229759Swollman * documentation and/or other materials provided with the distribution. 1329759Swollman * 3. All advertising materials mentioning features or use of this software 1429759Swollman * must display the following acknowledgement: 1529759Swollman * This product includes software developed by the University of 1629759Swollman * California, Berkeley and its contributors. 1729759Swollman * 4. Neither the name of the University nor the names of its contributors 1829759Swollman * may be used to endorse or promote products derived from this software 1929759Swollman * without specific prior written permission. 2029759Swollman * 2129759Swollman * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2229759Swollman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2329759Swollman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2429759Swollman * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2529759Swollman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2629759Swollman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2729759Swollman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2829759Swollman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2929759Swollman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3029759Swollman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3129759Swollman * SUCH DAMAGE. 3229759Swollman * 3329759Swollman * @(#)in_proto.c 8.2 (Berkeley) 2/9/95 3429759Swollman * $Id: in_proto.c,v 1.46 1998/03/21 11:33:57 peter Exp $ 3529759Swollman */ 3629759Swollman 3729759Swollman#include "opt_ipdivert.h" 3829759Swollman#include "opt_ipx.h" 3929759Swollman 4029759Swollman#include <sys/param.h> 4129759Swollman#include <sys/kernel.h> 4229759Swollman#include <sys/socket.h> 4329759Swollman#include <sys/domain.h> 4429759Swollman#include <sys/protosw.h> 4529759Swollman#include <sys/sysctl.h> 4629759Swollman 4729759Swollman#include <net/if.h> 4829759Swollman#include <net/route.h> 4929759Swollman 5029759Swollman#include <netinet/in.h> 5129759Swollman#include <netinet/in_systm.h> 5229759Swollman#include <netinet/ip.h> 5329759Swollman#include <netinet/ip_var.h> 5429759Swollman#include <netinet/ip_icmp.h> 5529759Swollman#include <netinet/igmp_var.h> 5629759Swollman#include <netinet/tcp.h> 5729759Swollman#include <netinet/tcp_timer.h> 5829759Swollman#include <netinet/tcp_var.h> 5929759Swollman#include <netinet/udp.h> 6029759Swollman#include <netinet/udp_var.h> 6129759Swollman/* 6229759Swollman * TCP/IP protocol family: IP, ICMP, UDP, TCP. 6329759Swollman */ 6429759Swollman 6529759Swollman#ifdef IPXIP 6629759Swollman#include <netipx/ipx_ip.h> 6729759Swollman#endif 6829759Swollman 6929759Swollman#ifdef NSIP 7029759Swollman#include <netns/ns.h> 7129759Swollman#include <netns/ns_if.h> 7229759Swollman#endif 7329759Swollman 7429759Swollmanextern struct domain inetdomain; 7529759Swollmanstatic struct pr_usrreqs nousrreqs; 7629759Swollman 7729759Swollmanstruct protosw inetsw[] = { 7829759Swollman{ 0, &inetdomain, 0, 0, 7929759Swollman 0, 0, 0, 0, 8029759Swollman 0, 8129759Swollman ip_init, 0, ip_slowtimo, ip_drain, 8229759Swollman &nousrreqs 8329759Swollman}, 8429759Swollman{ SOCK_DGRAM, &inetdomain, IPPROTO_UDP, PR_ATOMIC|PR_ADDR, 8529759Swollman udp_input, 0, udp_ctlinput, ip_ctloutput, 8629759Swollman 0, 8729759Swollman udp_init, 0, 0, 0, 8829759Swollman &udp_usrreqs 8929759Swollman}, 9029759Swollman{ SOCK_STREAM, &inetdomain, IPPROTO_TCP, 9129759Swollman PR_CONNREQUIRED|PR_IMPLOPCL|PR_WANTRCVD, 9229759Swollman tcp_input, 0, tcp_ctlinput, tcp_ctloutput, 9329759Swollman 0, 9429759Swollman tcp_init, tcp_fasttimo, tcp_slowtimo, tcp_drain, 9529759Swollman &tcp_usrreqs 9629759Swollman}, 9729759Swollman{ SOCK_RAW, &inetdomain, IPPROTO_RAW, PR_ATOMIC|PR_ADDR, 9829759Swollman rip_input, 0, rip_ctlinput, rip_ctloutput, 9929759Swollman 0, 10029759Swollman 0, 0, 0, 0, 10129759Swollman &rip_usrreqs 10229759Swollman}, 10329759Swollman{ SOCK_RAW, &inetdomain, IPPROTO_ICMP, PR_ATOMIC|PR_ADDR, 10429759Swollman icmp_input, 0, 0, rip_ctloutput, 10529759Swollman 0, 10629759Swollman 0, 0, 0, 0, 10729759Swollman &rip_usrreqs 10829759Swollman}, 10929759Swollman{ SOCK_RAW, &inetdomain, IPPROTO_IGMP, PR_ATOMIC|PR_ADDR, 11029759Swollman igmp_input, 0, 0, rip_ctloutput, 11129759Swollman 0, 11229759Swollman igmp_init, igmp_fasttimo, igmp_slowtimo, 0, 11329759Swollman &rip_usrreqs 11429759Swollman}, 11529759Swollman{ SOCK_RAW, &inetdomain, IPPROTO_RSVP, PR_ATOMIC|PR_ADDR, 11629759Swollman rsvp_input, 0, 0, rip_ctloutput, 11729759Swollman 0, 11829759Swollman 0, 0, 0, 0, 11929759Swollman &rip_usrreqs 12029759Swollman}, 12129759Swollman{ SOCK_RAW, &inetdomain, IPPROTO_IPIP, PR_ATOMIC|PR_ADDR, 12229759Swollman ipip_input, 0, 0, rip_ctloutput, 12329759Swollman 0, 12429759Swollman 0, 0, 0, 0, 12529759Swollman &rip_usrreqs 12629759Swollman}, 12729759Swollman#ifdef IPDIVERT 12829759Swollman{ SOCK_RAW, &inetdomain, IPPROTO_DIVERT, PR_ATOMIC|PR_ADDR, 12929759Swollman div_input, 0, 0, ip_ctloutput, 13029759Swollman 0, 13129759Swollman div_init, 0, 0, 0, 13229759Swollman &div_usrreqs, 13329759Swollman}, 13429759Swollman#endif 13529759Swollman#ifdef TPIP 13629759Swollman{ SOCK_SEQPACKET,&inetdomain, IPPROTO_TP, PR_CONNREQUIRED|PR_WANTRCVD, 13729759Swollman tpip_input, 0, tpip_ctlinput, tp_ctloutput, 13829759Swollman tp_usrreq, 13929759Swollman tp_init, 0, tp_slowtimo, tp_drain, 14029759Swollman}, 14129759Swollman#endif 14229759Swollman/* EON (ISO CLNL over IP) */ 14329759Swollman#ifdef EON 14429759Swollman{ SOCK_RAW, &inetdomain, IPPROTO_EON, 0, 14529759Swollman eoninput, 0, eonctlinput, 0, 14629759Swollman 0, 14729759Swollman eonprotoinit, 0, 0, 0, 14829759Swollman}, 14929759Swollman#endif 15029759Swollman#ifdef IPXIP 15129759Swollman{ SOCK_RAW, &inetdomain, IPPROTO_IDP, PR_ATOMIC|PR_ADDR, 15229759Swollman ipxip_input, 0, ipxip_ctlinput, 0, 15329759Swollman 0, 15429759Swollman 0, 0, 0, 0, 15529759Swollman &rip_usrreqs 15629759Swollman}, 15729759Swollman#endif 15829759Swollman#ifdef NSIP 15929759Swollman{ SOCK_RAW, &inetdomain, IPPROTO_IDP, PR_ATOMIC|PR_ADDR, 16029759Swollman idpip_input, 0, nsip_ctlinput, 0, 16129759Swollman 0, 16229759Swollman 0, 0, 0, 0, 16329759Swollman &rip_usrreqs 16429759Swollman}, 16529759Swollman#endif 16629759Swollman /* raw wildcard */ 16729759Swollman{ SOCK_RAW, &inetdomain, 0, PR_ATOMIC|PR_ADDR, 16829759Swollman rip_input, 0, 0, rip_ctloutput, 16929759Swollman 0, 17029759Swollman rip_init, 0, 0, 0, 17129759Swollman &rip_usrreqs 17229759Swollman}, 17329759Swollman}; 17429759Swollman 17529759Swollmanextern int in_inithead __P((void **, int)); 17629759Swollman 17729759Swollmanstruct domain inetdomain = 17829759Swollman { AF_INET, "internet", 0, 0, 0, 17929759Swollman inetsw, &inetsw[sizeof(inetsw)/sizeof(inetsw[0])], 0, 18029759Swollman in_inithead, 32, sizeof(struct sockaddr_in) 18129759Swollman }; 18229759Swollman 18329759SwollmanDOMAIN_SET(inet); 18429759Swollman 18529759SwollmanSYSCTL_NODE(_net, PF_INET, inet, CTLFLAG_RW, 0, 18629759Swollman "Internet Family"); 18729759Swollman 18829759SwollmanSYSCTL_NODE(_net_inet, IPPROTO_IP, ip, CTLFLAG_RW, 0, "IP"); 18929759SwollmanSYSCTL_NODE(_net_inet, IPPROTO_ICMP, icmp, CTLFLAG_RW, 0, "ICMP"); 19029759SwollmanSYSCTL_NODE(_net_inet, IPPROTO_UDP, udp, CTLFLAG_RW, 0, "UDP"); 19129759SwollmanSYSCTL_NODE(_net_inet, IPPROTO_TCP, tcp, CTLFLAG_RW, 0, "TCP"); 19229759SwollmanSYSCTL_NODE(_net_inet, IPPROTO_IGMP, igmp, CTLFLAG_RW, 0, "IGMP"); 19329759SwollmanSYSCTL_NODE(_net_inet, IPPROTO_RAW, raw, CTLFLAG_RW, 0, "RAW"); 19429759Swollman#ifdef IPDIVERT 19529759SwollmanSYSCTL_NODE(_net_inet, IPPROTO_DIVERT, div, CTLFLAG_RW, 0, "DIVERT"); 19629759Swollman#endif 19729759Swollman 19829759Swollman