LCOV - code coverage report
Current view: top level - netinet - in.h (source / functions) Hit Total Coverage
Test: 6.4 Lines: 0 6 0.0 %
Date: 2018-10-19 03:25:38 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*      $OpenBSD: in.h,v 1.132 2018/09/11 21:04:03 bluhm Exp $  */
       2             : /*      $NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $ */
       3             : 
       4             : /*
       5             :  * Copyright (c) 1982, 1986, 1990, 1993
       6             :  *      The Regents of the University of California.  All rights reserved.
       7             :  *
       8             :  * Redistribution and use in source and binary forms, with or without
       9             :  * modification, are permitted provided that the following conditions
      10             :  * are met:
      11             :  * 1. Redistributions of source code must retain the above copyright
      12             :  *    notice, this list of conditions and the following disclaimer.
      13             :  * 2. Redistributions in binary form must reproduce the above copyright
      14             :  *    notice, this list of conditions and the following disclaimer in the
      15             :  *    documentation and/or other materials provided with the distribution.
      16             :  * 3. Neither the name of the University nor the names of its contributors
      17             :  *    may be used to endorse or promote products derived from this software
      18             :  *    without specific prior written permission.
      19             :  *
      20             :  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
      21             :  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
      22             :  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
      23             :  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
      24             :  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
      25             :  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
      26             :  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
      27             :  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
      28             :  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
      29             :  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
      30             :  * SUCH DAMAGE.
      31             :  */
      32             : 
      33             : /*
      34             :  * Constants and structures defined by the internet system,
      35             :  * Per RFC 790, September 1981, and numerous additions.
      36             :  */
      37             : 
      38             : #ifndef _NETINET_IN_H_
      39             : #define _NETINET_IN_H_
      40             : 
      41             : #include <sys/cdefs.h>
      42             : 
      43             : #ifndef _KERNEL
      44             : #include <sys/types.h>
      45             : 
      46             : /* <sys/_endian.h> is pulled in by <sys/types.h> */
      47             : #ifndef htons
      48             : #define htons(x)        __htobe16(x)
      49             : #define htonl(x)        __htobe32(x)
      50             : #define ntohs(x)        __htobe16(x)
      51             : #define ntohl(x)        __htobe32(x)
      52             : #endif
      53             : 
      54             : #endif /* _KERNEL */
      55             : 
      56             : #ifndef _SA_FAMILY_T_DEFINED_
      57             : #define _SA_FAMILY_T_DEFINED_
      58             : typedef __sa_family_t   sa_family_t;    /* sockaddr address family type */
      59             : #endif /* _SA_FAMILY_T_DEFINED_ */
      60             : 
      61             : #ifndef _IN_TYPES_DEFINED_
      62             : #define _IN_TYPES_DEFINED_
      63             : typedef __in_addr_t     in_addr_t;      /* base type for internet address */
      64             : typedef __in_port_t     in_port_t;      /* IP port type */
      65             : #endif
      66             : 
      67             : /*
      68             :  * Protocols
      69             :  */
      70             : #define IPPROTO_IP              0               /* dummy for IP */
      71             : #define IPPROTO_HOPOPTS         IPPROTO_IP      /* Hop-by-hop option header */
      72             : #define IPPROTO_ICMP            1               /* control message protocol */
      73             : #define IPPROTO_IGMP            2               /* group mgmt protocol */
      74             : #define IPPROTO_GGP             3               /* gateway^2 (deprecated) */
      75             : #define IPPROTO_IPIP            4               /* IP inside IP */
      76             : #define IPPROTO_IPV4            IPPROTO_IPIP    /* IP inside IP */
      77             : #define IPPROTO_TCP             6               /* tcp */
      78             : #define IPPROTO_EGP             8               /* exterior gateway protocol */
      79             : #define IPPROTO_PUP             12              /* pup */
      80             : #define IPPROTO_UDP             17              /* user datagram protocol */
      81             : #define IPPROTO_IDP             22              /* xns idp */
      82             : #define IPPROTO_TP              29              /* tp-4 w/ class negotiation */
      83             : #define IPPROTO_IPV6            41              /* IPv6 in IPv6 */
      84             : #define IPPROTO_ROUTING         43              /* Routing header */
      85             : #define IPPROTO_FRAGMENT        44              /* Fragmentation/reassembly header */
      86             : #define IPPROTO_RSVP            46              /* resource reservation */
      87             : #define IPPROTO_GRE             47              /* GRE encap, RFCs 1701/1702 */
      88             : #define IPPROTO_ESP             50              /* Encap. Security Payload */
      89             : #define IPPROTO_AH              51              /* Authentication header */
      90             : #define IPPROTO_MOBILE          55              /* IP Mobility, RFC 2004 */
      91             : #define IPPROTO_ICMPV6          58              /* ICMP for IPv6 */
      92             : #define IPPROTO_NONE            59              /* No next header */
      93             : #define IPPROTO_DSTOPTS         60              /* Destination options header */
      94             : #define IPPROTO_EON             80              /* ISO cnlp */
      95             : #define IPPROTO_ETHERIP         97              /* Ethernet in IPv4 */
      96             : #define IPPROTO_ENCAP           98              /* encapsulation header */
      97             : #define IPPROTO_PIM             103             /* Protocol indep. multicast */
      98             : #define IPPROTO_IPCOMP          108             /* IP Payload Comp. Protocol */
      99             : #define IPPROTO_CARP            112             /* CARP */
     100             : #define IPPROTO_MPLS            137             /* unicast MPLS packet */
     101             : #define IPPROTO_PFSYNC          240             /* PFSYNC */
     102             : #define IPPROTO_RAW             255             /* raw IP packet */
     103             : 
     104             : #define IPPROTO_MAX             256
     105             : 
     106             : /* Only used internally, so it can be outside the range of valid IP protocols */
     107             : #define IPPROTO_DIVERT          258             /* Divert sockets */
     108             : 
     109             : /*
     110             :  * From FreeBSD:
     111             :  *
     112             :  * Local port number conventions:
     113             :  *
     114             :  * When a user does a bind(2) or connect(2) with a port number of zero,
     115             :  * a non-conflicting local port address is chosen.
     116             :  * The default range is IPPORT_RESERVED through
     117             :  * IPPORT_USERRESERVED, although that is settable by sysctl.
     118             :  *
     119             :  * A user may set the IPPROTO_IP option IP_PORTRANGE to change this
     120             :  * default assignment range.
     121             :  *
     122             :  * The value IP_PORTRANGE_DEFAULT causes the default behavior.
     123             :  *
     124             :  * The value IP_PORTRANGE_HIGH changes the range of candidate port numbers
     125             :  * into the "high" range.  These are reserved for client outbound connections
     126             :  * which do not want to be filtered by any firewalls.
     127             :  *
     128             :  * The value IP_PORTRANGE_LOW changes the range to the "low" are
     129             :  * that is (by convention) restricted to privileged processes.  This
     130             :  * convention is based on "vouchsafe" principles only.  It is only secure
     131             :  * if you trust the remote host to restrict these ports.
     132             :  *
     133             :  * The default range of ports and the high range can be changed by
     134             :  * sysctl(3).  (net.inet.ip.port{hi}{first,last})
     135             :  *
     136             :  * Changing those values has bad security implications if you are
     137             :  * using a a stateless firewall that is allowing packets outside of that
     138             :  * range in order to allow transparent outgoing connections.
     139             :  *
     140             :  * Such a firewall configuration will generally depend on the use of these
     141             :  * default values.  If you change them, you may find your Security
     142             :  * Administrator looking for you with a heavy object.
     143             :  */
     144             : 
     145             : /*
     146             :  * Ports < IPPORT_RESERVED are reserved for
     147             :  * privileged processes (e.g. root).
     148             :  * Ports > IPPORT_USERRESERVED are reserved
     149             :  * for servers, not necessarily privileged.
     150             :  */
     151             : #define IPPORT_RESERVED         1024
     152             : #define IPPORT_USERRESERVED     49151
     153             : 
     154             : /*
     155             :  * Default local port range to use by setting IP_PORTRANGE_HIGH
     156             :  */
     157             : #define IPPORT_HIFIRSTAUTO      49152
     158             : #define IPPORT_HILASTAUTO       65535
     159             : 
     160             : #ifndef _IN_ADDR_DECLARED
     161             : #define _IN_ADDR_DECLARED
     162             : /*
     163             :  * IP Version 4 Internet address (a structure for historical reasons)
     164             :  */
     165             : struct in_addr {
     166             :         in_addr_t s_addr;
     167             : };
     168             : #endif /* _IN_ADDR_DECLARED */
     169             : 
     170             : /* last return value of *_input(), meaning "all job for this pkt is done".  */
     171             : #define IPPROTO_DONE            257
     172             : 
     173             : /*
     174             :  * Definitions of bits in internet address integers.
     175             :  * On subnets, the decomposition of addresses to host and net parts
     176             :  * is done according to subnet mask, not the masks here.
     177             :  *
     178             :  * By byte-swapping the constants, we avoid ever having to byte-swap IP
     179             :  * addresses inside the kernel.  Unfortunately, user-level programs rely
     180             :  * on these macros not doing byte-swapping.
     181             :  */
     182             : #ifdef _KERNEL
     183             : #define __IPADDR(x)     ((u_int32_t) htonl((u_int32_t)(x)))
     184             : #else
     185             : #define __IPADDR(x)     ((u_int32_t)(x))
     186             : #endif /* _KERNEL */
     187             : 
     188             : #define IN_CLASSA(i)            (((u_int32_t)(i) & __IPADDR(0x80000000)) == \
     189             :                                  __IPADDR(0x00000000))
     190             : #define IN_CLASSA_NET           __IPADDR(0xff000000)
     191             : #define IN_CLASSA_NSHIFT        24
     192             : #define IN_CLASSA_HOST          __IPADDR(0x00ffffff)
     193             : #define IN_CLASSA_MAX           128
     194             : 
     195             : #define IN_CLASSB(i)            (((u_int32_t)(i) & __IPADDR(0xc0000000)) == \
     196             :                                  __IPADDR(0x80000000))
     197             : #define IN_CLASSB_NET           __IPADDR(0xffff0000)
     198             : #define IN_CLASSB_NSHIFT        16
     199             : #define IN_CLASSB_HOST          __IPADDR(0x0000ffff)
     200             : #define IN_CLASSB_MAX           65536
     201             : 
     202             : #define IN_CLASSC(i)            (((u_int32_t)(i) & __IPADDR(0xe0000000)) == \
     203             :                                  __IPADDR(0xc0000000))
     204             : #define IN_CLASSC_NET           __IPADDR(0xffffff00)
     205             : #define IN_CLASSC_NSHIFT        8
     206             : #define IN_CLASSC_HOST          __IPADDR(0x000000ff)
     207             : 
     208             : #define IN_CLASSD(i)            (((u_int32_t)(i) & __IPADDR(0xf0000000)) == \
     209             :                                  __IPADDR(0xe0000000))
     210             : /* These ones aren't really net and host fields, but routing needn't know. */
     211             : #define IN_CLASSD_NET           __IPADDR(0xf0000000)
     212             : #define IN_CLASSD_NSHIFT        28
     213             : #define IN_CLASSD_HOST          __IPADDR(0x0fffffff)
     214             : #define IN_MULTICAST(i)         IN_CLASSD(i)
     215             : 
     216             : #define IN_RFC3021_NET          __IPADDR(0xfffffffe)
     217             : #define IN_RFC3021_NSHIFT       31
     218             : #define IN_RFC3021_HOST         __IPADDR(0x00000001)
     219             : #define IN_RFC3021_SUBNET(n)    (((u_int32_t)(n) & IN_RFC3021_NET) == \
     220             :                                  IN_RFC3021_NET)
     221             : 
     222             : #define IN_EXPERIMENTAL(i)      (((u_int32_t)(i) & __IPADDR(0xf0000000)) == \
     223             :                                  __IPADDR(0xf0000000))
     224             : #define IN_BADCLASS(i)          (((u_int32_t)(i) & __IPADDR(0xf0000000)) == \
     225             :                                  __IPADDR(0xf0000000))
     226             : 
     227             : #define IN_LOCAL_GROUP(i)       (((u_int32_t)(i) & __IPADDR(0xffffff00)) == \
     228             :                                  __IPADDR(0xe0000000))
     229             : 
     230             : #ifdef _KERNEL
     231             : #define IN_CLASSFULBROADCAST(i, b) \
     232             :                                 ((IN_CLASSC(b) && (b | IN_CLASSC_HOST) == i) || \
     233             :                                  (IN_CLASSB(b) && (b | IN_CLASSB_HOST) == i) || \
     234             :                                  (IN_CLASSA(b) && (b | IN_CLASSA_HOST) == i))
     235             : #endif  /* _KERNEL */
     236             : 
     237             : #define INADDR_ANY              __IPADDR(0x00000000)
     238             : #define INADDR_LOOPBACK         __IPADDR(0x7f000001)
     239             : #define INADDR_BROADCAST        __IPADDR(0xffffffff)    /* must be masked */
     240             : #ifndef _KERNEL
     241             : #define INADDR_NONE             __IPADDR(0xffffffff)    /* -1 return */
     242             : #endif /* _KERNEL */
     243             : 
     244             : #define INADDR_UNSPEC_GROUP     __IPADDR(0xe0000000)    /* 224.0.0.0 */
     245             : #define INADDR_ALLHOSTS_GROUP   __IPADDR(0xe0000001)    /* 224.0.0.1 */
     246             : #define INADDR_ALLROUTERS_GROUP __IPADDR(0xe0000002)    /* 224.0.0.2 */
     247             : #define INADDR_CARP_GROUP       __IPADDR(0xe0000012)    /* 224.0.0.18 */
     248             : #define INADDR_PFSYNC_GROUP     __IPADDR(0xe00000f0)    /* 224.0.0.240 */
     249             : #define INADDR_MAX_LOCAL_GROUP  __IPADDR(0xe00000ff)    /* 224.0.0.255 */
     250             : 
     251             : #define IN_LOOPBACKNET          127                     /* official! */
     252             : 
     253             : /*
     254             :  * IP Version 4 socket address.
     255             :  */
     256             : struct sockaddr_in {
     257             :         u_int8_t    sin_len;
     258             :         sa_family_t sin_family;
     259             :         in_port_t   sin_port;
     260             :         struct      in_addr sin_addr;
     261             :         int8_t      sin_zero[8];
     262             : };
     263             : 
     264             : /*
     265             :  * Structure used to describe IP options.
     266             :  * Used to store options internally, to pass them to a process,
     267             :  * or to restore options retrieved earlier.
     268             :  * The ip_dst is used for the first-hop gateway when using a source route
     269             :  * (this gets put into the header proper).
     270             :  */
     271             : struct ip_opts {
     272             :         struct in_addr  ip_dst;         /* first hop, 0 w/o src rt */
     273             : #if defined(__cplusplus)
     274             :         int8_t          Ip_opts[40];    /* cannot have same name as class */
     275             : #else
     276             :         int8_t          ip_opts[40];    /* actually variable in size */
     277             : #endif /* defined(__cplusplus) */
     278             : };
     279             : 
     280             : /*
     281             :  * Options for use with [gs]etsockopt at the IP level.
     282             :  * First word of comment is data type; bool is stored in int.
     283             :  */
     284             : #define IP_OPTIONS              1    /* buf/ip_opts; set/get IP options */
     285             : #define IP_HDRINCL              2    /* int; header is included with data */
     286             : #define IP_TOS                  3    /* int; IP type of service and preced. */
     287             : #define IP_TTL                  4    /* int; IP time to live */
     288             : #define IP_RECVOPTS             5    /* bool; receive all IP opts w/dgram */
     289             : #define IP_RECVRETOPTS          6    /* bool; receive IP opts for response */
     290             : #define IP_RECVDSTADDR          7    /* bool; receive IP dst addr w/dgram */
     291             : #define IP_RETOPTS              8    /* ip_opts; set/get IP options */
     292             : #define IP_MULTICAST_IF         9    /* in_addr; set/get IP multicast i/f  */
     293             : #define IP_MULTICAST_TTL        10   /* u_char; set/get IP multicast ttl */
     294             : #define IP_MULTICAST_LOOP       11   /* u_char; set/get IP multicast loopback */
     295             : #define IP_ADD_MEMBERSHIP       12   /* ip_mreq; add an IP group membership */
     296             : #define IP_DROP_MEMBERSHIP      13   /* ip_mreq; drop an IP group membership */
     297             : #define IP_PORTRANGE            19   /* int; range to choose for unspec port */
     298             : #define IP_AUTH_LEVEL           20   /* int; authentication used */
     299             : #define IP_ESP_TRANS_LEVEL      21   /* int; transport encryption */
     300             : #define IP_ESP_NETWORK_LEVEL    22   /* int; full-packet encryption */
     301             : #define IP_IPSEC_LOCAL_ID       23   /* buf; IPsec local ID */
     302             : #define IP_IPSEC_REMOTE_ID      24   /* buf; IPsec remote ID */
     303             : #define IP_IPSEC_LOCAL_CRED     25   /* buf; was: IPsec local credentials */
     304             : #define IP_IPSEC_REMOTE_CRED    26   /* buf; was: IPsec remote credentials */
     305             : #define IP_IPSEC_LOCAL_AUTH     27   /* buf; was: IPsec local auth material */
     306             : #define IP_IPSEC_REMOTE_AUTH    28   /* buf; was: IPsec remote auth material */
     307             : #define IP_IPCOMP_LEVEL         29   /* int; compression used */
     308             : #define IP_RECVIF               30   /* bool; receive reception if w/dgram */
     309             : #define IP_RECVTTL              31   /* bool; receive IP TTL w/dgram */
     310             : #define IP_MINTTL               32   /* minimum TTL for packet or drop */
     311             : #define IP_RECVDSTPORT          33   /* bool; receive IP dst port w/dgram */
     312             : #define IP_PIPEX                34   /* bool; using PIPEX */
     313             : #define IP_RECVRTABLE           35   /* bool; receive rdomain w/dgram */
     314             : #define IP_IPSECFLOWINFO        36   /* bool; IPsec flow info for dgram */
     315             : #define IP_IPDEFTTL             37   /* int; IP TTL system default */
     316             : #define IP_SENDSRCADDR          IP_RECVDSTADDR  /* struct in_addr; */
     317             :                                                 /* source address to use */
     318             : 
     319             : #define IP_RTABLE               0x1021  /* int; routing table, see SO_RTABLE */
     320             : 
     321             : #if __BSD_VISIBLE
     322             : /*
     323             :  * Security levels - IPsec, not IPSO
     324             :  */
     325             : 
     326             : #define IPSEC_LEVEL_BYPASS      0x00    /* Bypass policy altogether */
     327             : #define IPSEC_LEVEL_NONE        0x00    /* Send clear, accept any */
     328             : #define IPSEC_LEVEL_AVAIL       0x01    /* Send secure if SA available */
     329             : #define IPSEC_LEVEL_USE         0x02    /* Send secure, accept any */
     330             : #define IPSEC_LEVEL_REQUIRE     0x03    /* Require secure inbound, also use */
     331             : #define IPSEC_LEVEL_UNIQUE      0x04    /* Use outbound SA that is unique */
     332             : #define IPSEC_LEVEL_DEFAULT     IPSEC_LEVEL_AVAIL
     333             : 
     334             : #define IPSEC_AUTH_LEVEL_DEFAULT IPSEC_LEVEL_DEFAULT
     335             : #define IPSEC_ESP_TRANS_LEVEL_DEFAULT IPSEC_LEVEL_DEFAULT
     336             : #define IPSEC_ESP_NETWORK_LEVEL_DEFAULT IPSEC_LEVEL_DEFAULT
     337             : #define IPSEC_IPCOMP_LEVEL_DEFAULT IPSEC_LEVEL_DEFAULT
     338             : 
     339             : #endif /* __BSD_VISIBLE */
     340             : 
     341             : /*
     342             :  * Defaults and limits for options
     343             :  */
     344             : #define IP_DEFAULT_MULTICAST_TTL  1     /* normally limit m'casts to 1 hop  */
     345             : #define IP_DEFAULT_MULTICAST_LOOP 1     /* normally hear sends if a member  */
     346             : /*
     347             :  * The imo_membership vector for each socket starts at IP_MIN_MEMBERSHIPS
     348             :  * and is dynamically allocated at run-time, bounded by IP_MAX_MEMBERSHIPS,
     349             :  * and is reallocated when needed, sized according to a power-of-two increment.
     350             :  */
     351             : #define IP_MIN_MEMBERSHIPS      15
     352             : #define IP_MAX_MEMBERSHIPS      4095
     353             : 
     354             : /*
     355             :  * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
     356             :  */
     357             : struct ip_mreq {
     358             :         struct  in_addr imr_multiaddr;  /* IP multicast address of group */
     359             :         struct  in_addr imr_interface;  /* local IP address of interface */
     360             : };
     361             : 
     362             : /*
     363             :  * Argument for IP_PORTRANGE:
     364             :  * - which range to search when port is unspecified at bind() or connect()
     365             :  */
     366             : #define IP_PORTRANGE_DEFAULT    0       /* default range */
     367             : #define IP_PORTRANGE_HIGH       1       /* "high" - request firewall bypass */
     368             : #define IP_PORTRANGE_LOW        2       /* "low" - vouchsafe security */
     369             : 
     370             : /*
     371             :  * Buffer lengths for strings containing printable IP addresses
     372             :  */
     373             : #ifndef INET_ADDRSTRLEN
     374             : #define INET_ADDRSTRLEN         16
     375             : #endif /* INET_ADDRSTRLEN */
     376             : 
     377             : 
     378             : #if __BSD_VISIBLE
     379             : /*
     380             :  * Definitions for inet sysctl operations.
     381             :  *
     382             :  * Third level is protocol number.
     383             :  * Fourth level is desired variable within that protocol.
     384             :  */
     385             : #define IPPROTO_MAXID   (IPPROTO_DIVERT + 1)    /* don't list to IPPROTO_MAX */
     386             : 
     387             : #define CTL_IPPROTO_NAMES { \
     388             :         { "ip", CTLTYPE_NODE }, \
     389             :         { "icmp", CTLTYPE_NODE }, \
     390             :         { "igmp", CTLTYPE_NODE }, \
     391             :         { "ggp", CTLTYPE_NODE }, \
     392             :         { "ipip", CTLTYPE_NODE }, \
     393             :         { 0, 0 }, \
     394             :         { "tcp", CTLTYPE_NODE }, \
     395             :         { 0, 0 }, \
     396             :         { "egp", CTLTYPE_NODE }, \
     397             :         { 0, 0 }, \
     398             :         { 0, 0 }, \
     399             :         { 0, 0 }, \
     400             :         { "pup", CTLTYPE_NODE }, \
     401             :         { 0, 0 }, \
     402             :         { 0, 0 }, \
     403             :         { 0, 0 }, \
     404             :         { 0, 0 }, \
     405             :         { "udp", CTLTYPE_NODE }, \
     406             :         { 0, 0 }, \
     407             :         { 0, 0 }, \
     408             :         { 0, 0 }, \
     409             :         { 0, 0 }, \
     410             :         { 0, 0 }, \
     411             :         { 0, 0 }, \
     412             :         { 0, 0 }, \
     413             :         { 0, 0 }, \
     414             :         { 0, 0 }, \
     415             :         { 0, 0 }, \
     416             :         { 0, 0 }, \
     417             :         { 0, 0 }, \
     418             :         { 0, 0 }, \
     419             :         { 0, 0 }, \
     420             :         { 0, 0 }, \
     421             :         { 0, 0 }, \
     422             :         { 0, 0 }, \
     423             :         { 0, 0 }, \
     424             :         { 0, 0 }, \
     425             :         { 0, 0 }, \
     426             :         { 0, 0 }, \
     427             :         { 0, 0 }, \
     428             :         { 0, 0 }, \
     429             :         { 0, 0 }, \
     430             :         { 0, 0 }, \
     431             :         { 0, 0 }, \
     432             :         { 0, 0 }, \
     433             :         { 0, 0 }, \
     434             :         { 0, 0 }, \
     435             :         { "gre", CTLTYPE_NODE }, \
     436             :         { 0, 0 }, \
     437             :         { 0, 0 }, \
     438             :         { "esp", CTLTYPE_NODE }, \
     439             :         { "ah", CTLTYPE_NODE }, \
     440             :         { 0, 0 }, \
     441             :         { 0, 0 }, \
     442             :         { 0, 0 }, \
     443             :         { "mobileip", CTLTYPE_NODE }, \
     444             :         { 0, 0 }, \
     445             :         { 0, 0 }, \
     446             :         { 0, 0 }, \
     447             :         { 0, 0 }, \
     448             :         { 0, 0 }, \
     449             :         { 0, 0 }, \
     450             :         { 0, 0 }, \
     451             :         { 0, 0 }, \
     452             :         { 0, 0 }, \
     453             :         { 0, 0 }, \
     454             :         { 0, 0 }, \
     455             :         { 0, 0 }, \
     456             :         { 0, 0 }, \
     457             :         { 0, 0 }, \
     458             :         { 0, 0 }, \
     459             :         { 0, 0 }, \
     460             :         { 0, 0 }, \
     461             :         { 0, 0 }, \
     462             :         { 0, 0 }, \
     463             :         { 0, 0 }, \
     464             :         { 0, 0 }, \
     465             :         { 0, 0 }, \
     466             :         { 0, 0 }, \
     467             :         { 0, 0 }, \
     468             :         { 0, 0 }, \
     469             :         { 0, 0 }, \
     470             :         { 0, 0 }, \
     471             :         { 0, 0 }, \
     472             :         { 0, 0 }, \
     473             :         { 0, 0 }, \
     474             :         { 0, 0 }, \
     475             :         { 0, 0 }, \
     476             :         { 0, 0 }, \
     477             :         { 0, 0 }, \
     478             :         { 0, 0 }, \
     479             :         { 0, 0 }, \
     480             :         { 0, 0 }, \
     481             :         { 0, 0 }, \
     482             :         { 0, 0 }, \
     483             :         { 0, 0 }, \
     484             :         { 0, 0 }, \
     485             :         { "etherip", CTLTYPE_NODE }, \
     486             :         { 0, 0 }, \
     487             :         { 0, 0 }, \
     488             :         { 0, 0 }, \
     489             :         { 0, 0 }, \
     490             :         { 0, 0 }, \
     491             :         { 0, 0 }, \
     492             :         { 0, 0 }, \
     493             :         { 0, 0 }, \
     494             :         { 0, 0 }, \
     495             :         { 0, 0 }, \
     496             :         { "ipcomp", CTLTYPE_NODE }, \
     497             :         { 0, 0 }, \
     498             :         { 0, 0 }, \
     499             :         { 0, 0 }, \
     500             :         { "carp", CTLTYPE_NODE }, \
     501             :         { 0, 0 }, \
     502             :         { 0, 0 }, \
     503             :         { 0, 0 }, \
     504             :         { 0, 0 }, \
     505             :         { 0, 0 }, \
     506             :         { 0, 0 }, \
     507             :         { 0, 0 }, \
     508             :         { 0, 0 }, \
     509             :         { 0, 0 }, \
     510             :         { 0, 0 }, \
     511             :         { 0, 0 }, \
     512             :         { 0, 0 }, \
     513             :         { 0, 0 }, \
     514             :         { 0, 0 }, \
     515             :         { 0, 0 }, \
     516             :         { 0, 0 }, \
     517             :         { 0, 0 }, \
     518             :         { 0, 0 }, \
     519             :         { 0, 0 }, \
     520             :         { 0, 0 }, \
     521             :         { 0, 0 }, \
     522             :         { 0, 0 }, \
     523             :         { 0, 0 }, \
     524             :         { 0, 0 }, \
     525             :         { 0, 0 }, \
     526             :         { 0, 0 }, \
     527             :         { 0, 0 }, \
     528             :         { 0, 0 }, \
     529             :         { 0, 0 }, \
     530             :         { 0, 0 }, \
     531             :         { 0, 0 }, \
     532             :         { 0, 0 }, \
     533             :         { 0, 0 }, \
     534             :         { 0, 0 }, \
     535             :         { 0, 0 }, \
     536             :         { 0, 0 }, \
     537             :         { 0, 0 }, \
     538             :         { 0, 0 }, \
     539             :         { 0, 0 }, \
     540             :         { 0, 0 }, \
     541             :         { 0, 0 }, \
     542             :         { 0, 0 }, \
     543             :         { 0, 0 }, \
     544             :         { 0, 0 }, \
     545             :         { 0, 0 }, \
     546             :         { 0, 0 }, \
     547             :         { 0, 0 }, \
     548             :         { 0, 0 }, \
     549             :         { 0, 0 }, \
     550             :         { 0, 0 }, \
     551             :         { 0, 0 }, \
     552             :         { 0, 0 }, \
     553             :         { 0, 0 }, \
     554             :         { 0, 0 }, \
     555             :         { 0, 0 }, \
     556             :         { 0, 0 }, \
     557             :         { 0, 0 }, \
     558             :         { 0, 0 }, \
     559             :         { 0, 0 }, \
     560             :         { 0, 0 }, \
     561             :         { 0, 0 }, \
     562             :         { 0, 0 }, \
     563             :         { 0, 0 }, \
     564             :         { 0, 0 }, \
     565             :         { 0, 0 }, \
     566             :         { 0, 0 }, \
     567             :         { 0, 0 }, \
     568             :         { 0, 0 }, \
     569             :         { 0, 0 }, \
     570             :         { 0, 0 }, \
     571             :         { 0, 0 }, \
     572             :         { 0, 0 }, \
     573             :         { 0, 0 }, \
     574             :         { 0, 0 }, \
     575             :         { 0, 0 }, \
     576             :         { 0, 0 }, \
     577             :         { 0, 0 }, \
     578             :         { 0, 0 }, \
     579             :         { 0, 0 }, \
     580             :         { 0, 0 }, \
     581             :         { 0, 0 }, \
     582             :         { 0, 0 }, \
     583             :         { 0, 0 }, \
     584             :         { 0, 0 }, \
     585             :         { 0, 0 }, \
     586             :         { 0, 0 }, \
     587             :         { 0, 0 }, \
     588             :         { 0, 0 }, \
     589             :         { 0, 0 }, \
     590             :         { 0, 0 }, \
     591             :         { 0, 0 }, \
     592             :         { 0, 0 }, \
     593             :         { 0, 0 }, \
     594             :         { 0, 0 }, \
     595             :         { 0, 0 }, \
     596             :         { 0, 0 }, \
     597             :         { 0, 0 }, \
     598             :         { 0, 0 }, \
     599             :         { 0, 0 }, \
     600             :         { 0, 0 }, \
     601             :         { 0, 0 }, \
     602             :         { 0, 0 }, \
     603             :         { 0, 0 }, \
     604             :         { 0, 0 }, \
     605             :         { 0, 0 }, \
     606             :         { 0, 0 }, \
     607             :         { 0, 0 }, \
     608             :         { 0, 0 }, \
     609             :         { 0, 0 }, \
     610             :         { 0, 0 }, \
     611             :         { 0, 0 }, \
     612             :         { 0, 0 }, \
     613             :         { 0, 0 }, \
     614             :         { 0, 0 }, \
     615             :         { 0, 0 }, \
     616             :         { 0, 0 }, \
     617             :         { 0, 0 }, \
     618             :         { 0, 0 }, \
     619             :         { 0, 0 }, \
     620             :         { 0, 0 }, \
     621             :         { 0, 0 }, \
     622             :         { 0, 0 }, \
     623             :         { 0, 0 }, \
     624             :         { 0, 0 }, \
     625             :         { 0, 0 }, \
     626             :         { 0, 0 }, \
     627             :         { 0, 0 }, \
     628             :         { "pfsync", CTLTYPE_NODE }, \
     629             :         { 0, 0 }, \
     630             :         { 0, 0 }, \
     631             :         { 0, 0 }, \
     632             :         { 0, 0 }, \
     633             :         { 0, 0 }, \
     634             :         { 0, 0 }, \
     635             :         { 0, 0 }, \
     636             :         { 0, 0 }, \
     637             :         { 0, 0 }, \
     638             :         { 0, 0 }, \
     639             :         { 0, 0 }, \
     640             :         { 0, 0 }, \
     641             :         { 0, 0 }, \
     642             :         { 0, 0 }, \
     643             :         { 0, 0 }, \
     644             :         { 0, 0 }, \
     645             :         { 0, 0 }, \
     646             :         { "divert", CTLTYPE_NODE }, \
     647             : }
     648             : 
     649             : /*
     650             :  * Names for IP sysctl objects
     651             :  */
     652             : #define IPCTL_FORWARDING        1       /* act as router */
     653             : #define IPCTL_SENDREDIRECTS     2       /* may send redirects when forwarding */
     654             : #define IPCTL_DEFTTL            3       /* default TTL */
     655             : #define IPCTL_SOURCEROUTE       5       /* may perform source routes */
     656             : #define IPCTL_DIRECTEDBCAST     6       /* default broadcast behavior */
     657             : #define IPCTL_IPPORT_FIRSTAUTO  7
     658             : #define IPCTL_IPPORT_LASTAUTO   8
     659             : #define IPCTL_IPPORT_HIFIRSTAUTO 9
     660             : #define IPCTL_IPPORT_HILASTAUTO 10
     661             : #define IPCTL_IPPORT_MAXQUEUE   11
     662             : #define IPCTL_ENCDEBUG          12
     663             : #define IPCTL_IPSEC_STATS       13
     664             : #define IPCTL_IPSEC_EXPIRE_ACQUIRE 14   /* How long to wait for key mgmt. */
     665             : #define IPCTL_IPSEC_EMBRYONIC_SA_TIMEOUT        15 /* new SA lifetime */
     666             : #define IPCTL_IPSEC_REQUIRE_PFS 16
     667             : #define IPCTL_IPSEC_SOFT_ALLOCATIONS            17
     668             : #define IPCTL_IPSEC_ALLOCATIONS 18
     669             : #define IPCTL_IPSEC_SOFT_BYTES  19
     670             : #define IPCTL_IPSEC_BYTES       20
     671             : #define IPCTL_IPSEC_TIMEOUT     21
     672             : #define IPCTL_IPSEC_SOFT_TIMEOUT 22
     673             : #define IPCTL_IPSEC_SOFT_FIRSTUSE 23
     674             : #define IPCTL_IPSEC_FIRSTUSE    24
     675             : #define IPCTL_IPSEC_ENC_ALGORITHM 25
     676             : #define IPCTL_IPSEC_AUTH_ALGORITHM 26
     677             : #define IPCTL_MTUDISC           27      /* allow path MTU discovery */
     678             : #define IPCTL_MTUDISCTIMEOUT    28      /* allow path MTU discovery */
     679             : #define IPCTL_IPSEC_IPCOMP_ALGORITHM    29
     680             : #define IPCTL_IFQUEUE           30
     681             : #define IPCTL_MFORWARDING       31
     682             : #define IPCTL_MULTIPATH         32
     683             : #define IPCTL_STATS             33      /* IP statistics */
     684             : #define IPCTL_MRTPROTO          34      /* type of multicast */
     685             : #define IPCTL_MRTSTATS          35
     686             : #define IPCTL_ARPQUEUED         36
     687             : #define IPCTL_MRTMFC            37
     688             : #define IPCTL_MRTVIF            38
     689             : #define IPCTL_ARPTIMEOUT        39
     690             : #define IPCTL_ARPDOWN           40
     691             : #define IPCTL_MAXID             41
     692             : 
     693             : #define IPCTL_NAMES { \
     694             :         { 0, 0 }, \
     695             :         { "forwarding", CTLTYPE_INT }, \
     696             :         { "redirect", CTLTYPE_INT }, \
     697             :         { "ttl", CTLTYPE_INT }, \
     698             :         /* { "mtu", CTLTYPE_INT }, */ { 0, 0 }, \
     699             :         { "sourceroute", CTLTYPE_INT }, \
     700             :         { "directed-broadcast", CTLTYPE_INT }, \
     701             :         { "portfirst", CTLTYPE_INT }, \
     702             :         { "portlast", CTLTYPE_INT }, \
     703             :         { "porthifirst", CTLTYPE_INT }, \
     704             :         { "porthilast", CTLTYPE_INT }, \
     705             :         { "maxqueue", CTLTYPE_INT }, \
     706             :         { "encdebug", CTLTYPE_INT }, \
     707             :         { 0, 0 /* ipsecstat */ }, \
     708             :         { "ipsec-expire-acquire", CTLTYPE_INT }, \
     709             :         { "ipsec-invalid-life", CTLTYPE_INT }, \
     710             :         { "ipsec-pfs", CTLTYPE_INT }, \
     711             :         { "ipsec-soft-allocs", CTLTYPE_INT }, \
     712             :         { "ipsec-allocs", CTLTYPE_INT }, \
     713             :         { "ipsec-soft-bytes", CTLTYPE_INT }, \
     714             :         { "ipsec-bytes", CTLTYPE_INT }, \
     715             :         { "ipsec-timeout", CTLTYPE_INT }, \
     716             :         { "ipsec-soft-timeout", CTLTYPE_INT }, \
     717             :         { "ipsec-soft-firstuse", CTLTYPE_INT }, \
     718             :         { "ipsec-firstuse", CTLTYPE_INT }, \
     719             :         { "ipsec-enc-alg", CTLTYPE_STRING }, \
     720             :         { "ipsec-auth-alg", CTLTYPE_STRING }, \
     721             :         { "mtudisc", CTLTYPE_INT }, \
     722             :         { "mtudisctimeout", CTLTYPE_INT }, \
     723             :         { "ipsec-comp-alg", CTLTYPE_STRING }, \
     724             :         { "ifq", CTLTYPE_NODE }, \
     725             :         { "mforwarding", CTLTYPE_INT }, \
     726             :         { "multipath", CTLTYPE_INT }, \
     727             :         { "stats", CTLTYPE_STRUCT }, \
     728             :         { "mrtproto", CTLTYPE_INT }, \
     729             :         { "mrtstats", CTLTYPE_STRUCT }, \
     730             :         { "arpqueued", CTLTYPE_INT }, \
     731             :         { "mrtmfc", CTLTYPE_STRUCT }, \
     732             :         { "mrtvif", CTLTYPE_STRUCT }, \
     733             :         { "arptimeout", CTLTYPE_INT }, \
     734             :         { "arpdown", CTLTYPE_INT }, \
     735             : }
     736             : #define IPCTL_VARS { \
     737             :         NULL, \
     738             :         &ipforwarding, \
     739             :         &ipsendredirects, \
     740             :         &ip_defttl, \
     741             :         NULL, \
     742             :         NULL, \
     743             :         &ip_directedbcast, \
     744             :         &ipport_firstauto, \
     745             :         &ipport_lastauto, \
     746             :         &ipport_hifirstauto, \
     747             :         &ipport_hilastauto, \
     748             :         &ip_maxqueue, \
     749             :         NULL /* encdebug */, \
     750             :         NULL /* ipsecstat */, \
     751             :         NULL /* ipsec_expire_acquire */, \
     752             :         NULL /* ipsec_keep_invalid */, \
     753             :         NULL /* ipsec_require_pfs */, \
     754             :         NULL /* ipsec_soft_allocations */, \
     755             :         NULL /* ipsec_exp_allocations */, \
     756             :         NULL /* ipsec_soft_bytes */, \
     757             :         NULL /* ipsec_exp_bytes */, \
     758             :         NULL /* ipsec_exp_timeout */, \
     759             :         NULL /* ipsec_soft_timeout */, \
     760             :         NULL /* ipsec_soft_first_use */, \
     761             :         NULL /* ipsec_exp_first_use */, \
     762             :         NULL, \
     763             :         NULL, \
     764             :         NULL, \
     765             :         NULL, \
     766             :         NULL, \
     767             :         NULL, \
     768             :         &ipmforwarding, \
     769             :         &ipmultipath, \
     770             :         NULL, \
     771             :         NULL, \
     772             :         NULL, \
     773             :         &la_hold_total, \
     774             :         NULL, \
     775             :         NULL, \
     776             :         &arpt_keep, \
     777             :         &arpt_down, \
     778             : }
     779             : 
     780             : #endif /* __BSD_VISIBLE */
     781             : 
     782             : /* INET6 stuff */
     783             : #define __KAME_NETINET_IN_H_INCLUDED_
     784             : #include <netinet6/in6.h>
     785             : #undef __KAME_NETINET_IN_H_INCLUDED_
     786             : 
     787             : #ifndef _KERNEL
     788             : #if __BSD_VISIBLE
     789             : __BEGIN_DECLS
     790             : int        bindresvport(int, struct sockaddr_in *);
     791             : struct sockaddr;
     792             : int        bindresvport_sa(int, struct sockaddr *);
     793             : __END_DECLS
     794             : #endif /* __BSD_VISIBLE */
     795             : #endif /* !_KERNEL */
     796             : 
     797             : #ifdef _KERNEL
     798             : extern const u_char inetctlerrmap[];
     799             : extern const struct in_addr zeroin_addr;
     800             : 
     801             : struct mbuf;
     802             : struct sockaddr;
     803             : struct sockaddr_in;
     804             : struct ifaddr;
     805             : struct in_ifaddr;
     806             : 
     807             : void       ipv4_input(struct ifnet *, struct mbuf *);
     808             : 
     809             : int        in_broadcast(struct in_addr, u_int);
     810             : int        in_canforward(struct in_addr);
     811             : int        in_cksum(struct mbuf *, int);
     812             : int        in4_cksum(struct mbuf *, u_int8_t, int, int);
     813             : void       in_proto_cksum_out(struct mbuf *, struct ifnet *);
     814             : void       in_ifdetach(struct ifnet *);
     815             : int        in_mask2len(struct in_addr *);
     816             : void       in_len2mask(struct in_addr *, int);
     817             : int        in_nam2sin(const struct mbuf *, struct sockaddr_in **);
     818             : 
     819             : char      *inet_ntoa(struct in_addr);
     820             : int        inet_nat64(int, const void *, void *, const void *, u_int8_t);
     821             : int        inet_nat46(int, const void *, void *, const void *, u_int8_t);
     822             : 
     823             : const char *inet_ntop(int, const void *, char *, socklen_t);
     824             : const char *sockaddr_ntop(struct sockaddr *, char *, size_t);
     825             : 
     826             : #define in_hosteq(s,t)  ((s).s_addr == (t).s_addr)
     827             : #define in_nullhost(x)  ((x).s_addr == INADDR_ANY)
     828             : 
     829             : /*
     830             :  * Convert between address family specific and general structs.
     831             :  * Inline functions check the source type and are stricter than
     832             :  * casts or defines.
     833             :  */
     834             : 
     835             : static inline struct sockaddr_in *
     836           0 : satosin(struct sockaddr *sa)
     837             : {
     838           0 :         return ((struct sockaddr_in *)(sa));
     839             : }
     840             : 
     841             : static inline struct sockaddr *
     842           0 : sintosa(struct sockaddr_in *sin)
     843             : {
     844           0 :         return ((struct sockaddr *)(sin));
     845             : }
     846             : 
     847             : static inline struct in_ifaddr *
     848           0 : ifatoia(struct ifaddr *ifa)
     849             : {
     850           0 :         return ((struct in_ifaddr *)(ifa));
     851             : }
     852             : #endif /* _KERNEL */
     853             : #endif /* _NETINET_IN_H_ */

Generated by: LCOV version 1.13