The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/netinet/in_proto.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1982, 1986, 1993
    3  *      The Regents of the University of California.  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  * 4. Neither the name of the University nor the names of its contributors
   14  *    may be used to endorse or promote products derived from this software
   15  *    without specific prior written permission.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  *
   29  *      @(#)in_proto.c  8.2 (Berkeley) 2/9/95
   30  */
   31 
   32 #include <sys/cdefs.h>
   33 __FBSDID("$FreeBSD: releng/11.1/sys/netinet/in_proto.c 315514 2017-03-18 22:04:20Z ae $");
   34 
   35 #include "opt_mrouting.h"
   36 #include "opt_ipsec.h"
   37 #include "opt_inet.h"
   38 #include "opt_inet6.h"
   39 #include "opt_sctp.h"
   40 #include "opt_mpath.h"
   41 
   42 #include <sys/param.h>
   43 #include <sys/systm.h>
   44 #include <sys/kernel.h>
   45 #include <sys/malloc.h>
   46 #include <sys/socket.h>
   47 #include <sys/domain.h>
   48 #include <sys/proc.h>
   49 #include <sys/protosw.h>
   50 #include <sys/queue.h>
   51 #include <sys/sysctl.h>
   52 
   53 /*
   54  * While this file provides the domain and protocol switch tables for IPv4, it
   55  * also provides the sysctl node declarations for net.inet.* often shared with
   56  * IPv6 for common features or by upper layer protocols.  In case of no IPv4
   57  * support compile out everything but these sysctl nodes.
   58  */
   59 #ifdef INET
   60 #include <net/if.h>
   61 #include <net/if_var.h>
   62 #include <net/route.h>
   63 #ifdef RADIX_MPATH
   64 #include <net/radix_mpath.h>
   65 #endif
   66 #include <net/vnet.h>
   67 #endif /* INET */
   68 
   69 #if defined(INET) || defined(INET6)
   70 #include <netinet/in.h>
   71 #endif
   72 
   73 #ifdef INET
   74 #include <netinet/in_systm.h>
   75 #include <netinet/in_var.h>
   76 #include <netinet/ip.h>
   77 #include <netinet/ip_var.h>
   78 #include <netinet/ip_icmp.h>
   79 #include <netinet/igmp_var.h>
   80 #include <netinet/tcp.h>
   81 #include <netinet/tcp_timer.h>
   82 #include <netinet/tcp_var.h>
   83 #include <netinet/udp.h>
   84 #include <netinet/udp_var.h>
   85 #include <netinet/ip_encap.h>
   86 
   87 /*
   88  * TCP/IP protocol family: IP, ICMP, UDP, TCP.
   89  */
   90 
   91 static struct pr_usrreqs nousrreqs;
   92 
   93 #ifdef SCTP
   94 #include <netinet/in_pcb.h>
   95 #include <netinet/sctp_pcb.h>
   96 #include <netinet/sctp.h>
   97 #include <netinet/sctp_var.h>
   98 #endif /* SCTP */
   99 
  100 FEATURE(inet, "Internet Protocol version 4");
  101 
  102 extern  struct domain inetdomain;
  103 
  104 /* Spacer for loadable protocols. */
  105 #define IPPROTOSPACER                           \
  106 {                                               \
  107         .pr_domain =            &inetdomain,    \
  108         .pr_protocol =          PROTO_SPACER,   \
  109         .pr_usrreqs =           &nousrreqs      \
  110 }
  111 
  112 struct protosw inetsw[] = {
  113 {
  114         .pr_type =              0,
  115         .pr_domain =            &inetdomain,
  116         .pr_protocol =          IPPROTO_IP,
  117         .pr_init =              ip_init,
  118         .pr_slowtimo =          ip_slowtimo,
  119         .pr_drain =             ip_drain,
  120         .pr_usrreqs =           &nousrreqs
  121 },
  122 {
  123         .pr_type =              SOCK_DGRAM,
  124         .pr_domain =            &inetdomain,
  125         .pr_protocol =          IPPROTO_UDP,
  126         .pr_flags =             PR_ATOMIC|PR_ADDR,
  127         .pr_input =             udp_input,
  128         .pr_ctlinput =          udp_ctlinput,
  129         .pr_ctloutput =         udp_ctloutput,
  130         .pr_init =              udp_init,
  131         .pr_usrreqs =           &udp_usrreqs
  132 },
  133 {
  134         .pr_type =              SOCK_STREAM,
  135         .pr_domain =            &inetdomain,
  136         .pr_protocol =          IPPROTO_TCP,
  137         .pr_flags =             PR_CONNREQUIRED|PR_IMPLOPCL|PR_WANTRCVD,
  138         .pr_input =             tcp_input,
  139         .pr_ctlinput =          tcp_ctlinput,
  140         .pr_ctloutput =         tcp_ctloutput,
  141         .pr_init =              tcp_init,
  142         .pr_slowtimo =          tcp_slowtimo,
  143         .pr_drain =             tcp_drain,
  144         .pr_usrreqs =           &tcp_usrreqs
  145 },
  146 #ifdef SCTP
  147 { 
  148         .pr_type =              SOCK_SEQPACKET,
  149         .pr_domain =            &inetdomain,
  150         .pr_protocol =          IPPROTO_SCTP,
  151         .pr_flags =             PR_WANTRCVD|PR_LASTHDR,
  152         .pr_input =             sctp_input,
  153         .pr_ctlinput =          sctp_ctlinput,
  154         .pr_ctloutput =         sctp_ctloutput,
  155         .pr_init =              sctp_init,
  156         .pr_drain =             sctp_drain,
  157         .pr_usrreqs =           &sctp_usrreqs
  158 },
  159 { 
  160         .pr_type =              SOCK_STREAM,
  161         .pr_domain =            &inetdomain,
  162         .pr_protocol =          IPPROTO_SCTP,
  163         .pr_flags =             PR_CONNREQUIRED|PR_WANTRCVD|PR_LASTHDR,
  164         .pr_input =             sctp_input,
  165         .pr_ctlinput =          sctp_ctlinput,
  166         .pr_ctloutput =         sctp_ctloutput,
  167         .pr_drain =             sctp_drain,
  168         .pr_usrreqs =           &sctp_usrreqs
  169 },
  170 #endif /* SCTP */
  171 {
  172         .pr_type =              SOCK_DGRAM,
  173         .pr_domain =            &inetdomain,
  174         .pr_protocol =          IPPROTO_UDPLITE,
  175         .pr_flags =             PR_ATOMIC|PR_ADDR,
  176         .pr_input =             udp_input,
  177         .pr_ctlinput =          udplite_ctlinput,
  178         .pr_ctloutput =         udp_ctloutput,
  179         .pr_init =              udplite_init,
  180         .pr_usrreqs =           &udp_usrreqs
  181 },
  182 {
  183         .pr_type =              SOCK_RAW,
  184         .pr_domain =            &inetdomain,
  185         .pr_protocol =          IPPROTO_RAW,
  186         .pr_flags =             PR_ATOMIC|PR_ADDR,
  187         .pr_input =             rip_input,
  188         .pr_ctlinput =          rip_ctlinput,
  189         .pr_ctloutput =         rip_ctloutput,
  190         .pr_usrreqs =           &rip_usrreqs
  191 },
  192 {
  193         .pr_type =              SOCK_RAW,
  194         .pr_domain =            &inetdomain,
  195         .pr_protocol =          IPPROTO_ICMP,
  196         .pr_flags =             PR_ATOMIC|PR_ADDR|PR_LASTHDR,
  197         .pr_input =             icmp_input,
  198         .pr_ctloutput =         rip_ctloutput,
  199         .pr_usrreqs =           &rip_usrreqs
  200 },
  201 {
  202         .pr_type =              SOCK_RAW,
  203         .pr_domain =            &inetdomain,
  204         .pr_protocol =          IPPROTO_IGMP,
  205         .pr_flags =             PR_ATOMIC|PR_ADDR|PR_LASTHDR,
  206         .pr_input =             igmp_input,
  207         .pr_ctloutput =         rip_ctloutput,
  208         .pr_fasttimo =          igmp_fasttimo,
  209         .pr_slowtimo =          igmp_slowtimo,
  210         .pr_usrreqs =           &rip_usrreqs
  211 },
  212 {
  213         .pr_type =              SOCK_RAW,
  214         .pr_domain =            &inetdomain,
  215         .pr_protocol =          IPPROTO_RSVP,
  216         .pr_flags =             PR_ATOMIC|PR_ADDR|PR_LASTHDR,
  217         .pr_input =             rsvp_input,
  218         .pr_ctloutput =         rip_ctloutput,
  219         .pr_usrreqs =           &rip_usrreqs
  220 },
  221 {
  222         .pr_type =              SOCK_RAW,
  223         .pr_domain =            &inetdomain,
  224         .pr_protocol =          IPPROTO_IPV4,
  225         .pr_flags =             PR_ATOMIC|PR_ADDR|PR_LASTHDR,
  226         .pr_input =             encap4_input,
  227         .pr_ctloutput =         rip_ctloutput,
  228         .pr_init =              encap_init,
  229         .pr_usrreqs =           &rip_usrreqs
  230 },
  231 {
  232         .pr_type =              SOCK_RAW,
  233         .pr_domain =            &inetdomain,
  234         .pr_protocol =          IPPROTO_MOBILE,
  235         .pr_flags =             PR_ATOMIC|PR_ADDR|PR_LASTHDR,
  236         .pr_input =             encap4_input,
  237         .pr_ctloutput =         rip_ctloutput,
  238         .pr_init =              encap_init,
  239         .pr_usrreqs =           &rip_usrreqs
  240 },
  241 {
  242         .pr_type =              SOCK_RAW,
  243         .pr_domain =            &inetdomain,
  244         .pr_protocol =          IPPROTO_ETHERIP,
  245         .pr_flags =             PR_ATOMIC|PR_ADDR|PR_LASTHDR,
  246         .pr_input =             encap4_input,
  247         .pr_ctloutput =         rip_ctloutput,
  248         .pr_init =              encap_init,
  249         .pr_usrreqs =           &rip_usrreqs
  250 },
  251 {
  252         .pr_type =              SOCK_RAW,
  253         .pr_domain =            &inetdomain,
  254         .pr_protocol =          IPPROTO_GRE,
  255         .pr_flags =             PR_ATOMIC|PR_ADDR|PR_LASTHDR,
  256         .pr_input =             encap4_input,
  257         .pr_ctloutput =         rip_ctloutput,
  258         .pr_init =              encap_init,
  259         .pr_usrreqs =           &rip_usrreqs
  260 },
  261 # ifdef INET6
  262 {
  263         .pr_type =              SOCK_RAW,
  264         .pr_domain =            &inetdomain,
  265         .pr_protocol =          IPPROTO_IPV6,
  266         .pr_flags =             PR_ATOMIC|PR_ADDR|PR_LASTHDR,
  267         .pr_input =             encap4_input,
  268         .pr_ctloutput =         rip_ctloutput,
  269         .pr_init =              encap_init,
  270         .pr_usrreqs =           &rip_usrreqs
  271 },
  272 #endif
  273 {
  274         .pr_type =              SOCK_RAW,
  275         .pr_domain =            &inetdomain,
  276         .pr_protocol =          IPPROTO_PIM,
  277         .pr_flags =             PR_ATOMIC|PR_ADDR|PR_LASTHDR,
  278         .pr_input =             encap4_input,
  279         .pr_ctloutput =         rip_ctloutput,
  280         .pr_usrreqs =           &rip_usrreqs
  281 },
  282 /* Spacer n-times for loadable protocols. */
  283 IPPROTOSPACER,
  284 IPPROTOSPACER,
  285 IPPROTOSPACER,
  286 IPPROTOSPACER,
  287 IPPROTOSPACER,
  288 IPPROTOSPACER,
  289 IPPROTOSPACER,
  290 IPPROTOSPACER,
  291 /* raw wildcard */
  292 {
  293         .pr_type =              SOCK_RAW,
  294         .pr_domain =            &inetdomain,
  295         .pr_flags =             PR_ATOMIC|PR_ADDR,
  296         .pr_input =             rip_input,
  297         .pr_ctloutput =         rip_ctloutput,
  298         .pr_init =              rip_init,
  299         .pr_usrreqs =           &rip_usrreqs
  300 },
  301 };
  302 
  303 extern int in_inithead(void **, int);
  304 extern int in_detachhead(void **, int);
  305 
  306 struct domain inetdomain = {
  307         .dom_family =           AF_INET,
  308         .dom_name =             "internet",
  309         .dom_protosw =          inetsw,
  310         .dom_protoswNPROTOSW =  &inetsw[nitems(inetsw)],
  311 #ifdef RADIX_MPATH
  312         .dom_rtattach =         rn4_mpath_inithead,
  313 #else
  314         .dom_rtattach =         in_inithead,
  315 #endif
  316 #ifdef VIMAGE
  317         .dom_rtdetach =         in_detachhead,
  318 #endif
  319         .dom_ifattach =         in_domifattach,
  320         .dom_ifdetach =         in_domifdetach
  321 };
  322 
  323 VNET_DOMAIN_SET(inet);
  324 #endif /* INET */
  325 
  326 SYSCTL_NODE(_net,      PF_INET,         inet,   CTLFLAG_RW, 0,
  327         "Internet Family");
  328 
  329 SYSCTL_NODE(_net_inet, IPPROTO_IP,      ip,     CTLFLAG_RW, 0,  "IP");
  330 SYSCTL_NODE(_net_inet, IPPROTO_ICMP,    icmp,   CTLFLAG_RW, 0,  "ICMP");
  331 SYSCTL_NODE(_net_inet, IPPROTO_UDP,     udp,    CTLFLAG_RW, 0,  "UDP");
  332 SYSCTL_NODE(_net_inet, IPPROTO_TCP,     tcp,    CTLFLAG_RW, 0,  "TCP");
  333 #ifdef SCTP
  334 SYSCTL_NODE(_net_inet, IPPROTO_SCTP,    sctp,   CTLFLAG_RW, 0,  "SCTP");
  335 #endif
  336 SYSCTL_NODE(_net_inet, IPPROTO_IGMP,    igmp,   CTLFLAG_RW, 0,  "IGMP");
  337 #if defined(IPSEC) || defined(IPSEC_SUPPORT)
  338 /* XXX no protocol # to use, pick something "reserved" */
  339 SYSCTL_NODE(_net_inet, 253,             ipsec,  CTLFLAG_RW, 0,  "IPSEC");
  340 SYSCTL_NODE(_net_inet, IPPROTO_AH,      ah,     CTLFLAG_RW, 0,  "AH");
  341 SYSCTL_NODE(_net_inet, IPPROTO_ESP,     esp,    CTLFLAG_RW, 0,  "ESP");
  342 SYSCTL_NODE(_net_inet, IPPROTO_IPCOMP,  ipcomp, CTLFLAG_RW, 0,  "IPCOMP");
  343 SYSCTL_NODE(_net_inet, IPPROTO_IPIP,    ipip,   CTLFLAG_RW, 0,  "IPIP");
  344 #endif /* IPSEC */
  345 SYSCTL_NODE(_net_inet, IPPROTO_RAW,     raw,    CTLFLAG_RW, 0,  "RAW");
  346 SYSCTL_NODE(_net_inet, OID_AUTO,        accf,   CTLFLAG_RW, 0,
  347     "Accept filters");

Cache object: 3e11466a013524c7c001b8c4f1806408


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.