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

          Line data    Source code
       1             : /*      $OpenBSD: ip6_var.h,v 1.83 2018/02/10 05:52:08 florian Exp $    */
       2             : /*      $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $        */
       3             : 
       4             : /*
       5             :  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
       6             :  * 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 project 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 PROJECT 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 PROJECT 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             :  * Copyright (c) 1982, 1986, 1993
      35             :  *      The Regents of the University of California.  All rights reserved.
      36             :  *
      37             :  * Redistribution and use in source and binary forms, with or without
      38             :  * modification, are permitted provided that the following conditions
      39             :  * are met:
      40             :  * 1. Redistributions of source code must retain the above copyright
      41             :  *    notice, this list of conditions and the following disclaimer.
      42             :  * 2. Redistributions in binary form must reproduce the above copyright
      43             :  *    notice, this list of conditions and the following disclaimer in the
      44             :  *    documentation and/or other materials provided with the distribution.
      45             :  * 3. Neither the name of the University nor the names of its contributors
      46             :  *    may be used to endorse or promote products derived from this software
      47             :  *    without specific prior written permission.
      48             :  *
      49             :  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
      50             :  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
      51             :  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
      52             :  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
      53             :  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
      54             :  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
      55             :  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
      56             :  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
      57             :  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
      58             :  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
      59             :  * SUCH DAMAGE.
      60             :  *
      61             :  *      @(#)ip_var.h    8.1 (Berkeley) 6/10/93
      62             :  */
      63             : 
      64             : #ifndef _NETINET6_IP6_VAR_H_
      65             : #define _NETINET6_IP6_VAR_H_
      66             : 
      67             : /*
      68             :  * IP6 reassembly queue structure.  Each fragment
      69             :  * being reassembled is attached to one of these structures.
      70             :  */
      71             : struct  ip6q {
      72             :         TAILQ_ENTRY(ip6q) ip6q_queue;
      73             :         LIST_HEAD(ip6asfrag_list, ip6asfrag) ip6q_asfrag;
      74             :         struct in6_addr ip6q_src, ip6q_dst;
      75             :         int             ip6q_unfrglen;  /* len of unfragmentable part */
      76             :         int             ip6q_nfrag;     /* # of fragments */
      77             :         u_int32_t       ip6q_ident;     /* fragment identification */
      78             :         u_int8_t        ip6q_nxt;       /* ip6f_nxt in first fragment */
      79             :         u_int8_t        ip6q_ttl;       /* time to live in slowtimo units */
      80             : };
      81             : 
      82             : struct  ip6asfrag {
      83             :         LIST_ENTRY(ip6asfrag) ip6af_list;
      84             :         struct mbuf     *ip6af_m;
      85             :         int             ip6af_offset;   /* offset in ip6af_m to next header */
      86             :         int             ip6af_frglen;   /* fragmentable part length */
      87             :         int             ip6af_off;      /* fragment offset */
      88             :         u_int32_t       ip6af_flow;     /* ip header flow id */
      89             :         u_int16_t       ip6af_mff;      /* more fragment bit in frag off */
      90             : };
      91             : 
      92             : struct  ip6_moptions {
      93             :         LIST_HEAD(, in6_multi_mship) im6o_memberships;
      94             :         unsigned short im6o_ifidx;      /* ifp index for outgoing multicasts */
      95             :         u_char  im6o_hlim;      /* hoplimit for outgoing multicasts */
      96             :         u_char  im6o_loop;      /* 1 >= hear sends if a member */
      97             : };
      98             : 
      99             : /*
     100             :  * Control options for outgoing packets
     101             :  */
     102             : 
     103             : /* Routing header related info */
     104             : struct  ip6po_rhinfo {
     105             :         struct  ip6_rthdr *ip6po_rhi_rthdr; /* Routing header */
     106             :         struct  route_in6 ip6po_rhi_route; /* Route to the 1st hop */
     107             : };
     108             : #define ip6po_rthdr     ip6po_rhinfo.ip6po_rhi_rthdr
     109             : #define ip6po_route     ip6po_rhinfo.ip6po_rhi_route
     110             : 
     111             : struct  ip6_pktopts {
     112             :         /* Hoplimit for outgoing packets */
     113             :         int     ip6po_hlim;
     114             : 
     115             :         /* Outgoing IF/address information */
     116             :         struct in6_pktinfo *ip6po_pktinfo;
     117             : 
     118             :         /* Hop-by-Hop options header */
     119             :         struct  ip6_hbh *ip6po_hbh;
     120             : 
     121             :         /* Destination options header (before a routing header) */
     122             :         struct  ip6_dest *ip6po_dest1;
     123             : 
     124             :         /* Routing header related info. */
     125             :         struct  ip6po_rhinfo ip6po_rhinfo;
     126             : 
     127             :         /* Destination options header (after a routing header) */
     128             :         struct  ip6_dest *ip6po_dest2;
     129             : 
     130             :         /* traffic class */
     131             :         int     ip6po_tclass;
     132             : 
     133             :         /* fragment vs PMTU discovery policy */
     134             :         int     ip6po_minmtu;
     135             : #define IP6PO_MINMTU_MCASTONLY  -1 /* default: send at min MTU for multicast */
     136             : #define IP6PO_MINMTU_DISABLE    0  /* always perform pmtu disc */
     137             : #define IP6PO_MINMTU_ALL        1  /* always send at min MTU */
     138             : 
     139             :         int     ip6po_flags;
     140             : #define IP6PO_DONTFRAG  0x04    /* disable fragmentation (IPV6_DONTFRAG) */
     141             : };
     142             : 
     143             : struct  ip6stat {
     144             :         u_int64_t ip6s_total;           /* total packets received */
     145             :         u_int64_t ip6s_tooshort;        /* packet too short */
     146             :         u_int64_t ip6s_toosmall;        /* not enough data */
     147             :         u_int64_t ip6s_fragments;       /* fragments received */
     148             :         u_int64_t ip6s_fragdropped;     /* frags dropped(dups, out of space) */
     149             :         u_int64_t ip6s_fragtimeout;     /* fragments timed out */
     150             :         u_int64_t ip6s_fragoverflow;    /* fragments that exceeded limit */
     151             :         u_int64_t ip6s_forward;         /* packets forwarded */
     152             :         u_int64_t ip6s_cantforward;     /* packets rcvd for unreachable dest */
     153             :         u_int64_t ip6s_redirectsent;    /* packets forwarded on same net */
     154             :         u_int64_t ip6s_delivered;       /* datagrams delivered to upper level*/
     155             :         u_int64_t ip6s_localout;        /* total ip packets generated here */
     156             :         u_int64_t ip6s_odropped;        /* lost packets due to nobufs, etc. */
     157             :         u_int64_t ip6s_reassembled;     /* total packets reassembled ok */
     158             :         u_int64_t ip6s_fragmented;      /* datagrams successfully fragmented */
     159             :         u_int64_t ip6s_ofragments;      /* output fragments created */
     160             :         u_int64_t ip6s_cantfrag;        /* don't fragment flag was set, etc. */
     161             :         u_int64_t ip6s_badoptions;      /* error in option processing */
     162             :         u_int64_t ip6s_noroute;         /* packets discarded due to no route */
     163             :         u_int64_t ip6s_badvers;         /* ip6 version != 6 */
     164             :         u_int64_t ip6s_rawout;          /* total raw ip packets generated */
     165             :         u_int64_t ip6s_badscope;        /* scope error */
     166             :         u_int64_t ip6s_notmember;       /* don't join this multicast group */
     167             :         u_int64_t ip6s_nxthist[256];    /* next header history */
     168             :         u_int64_t ip6s_m1;              /* one mbuf */
     169             :         u_int64_t ip6s_m2m[32];         /* two or more mbuf */
     170             :         u_int64_t ip6s_mext1;           /* one ext mbuf */
     171             :         u_int64_t ip6s_mext2m;          /* two or more ext mbuf */
     172             :         u_int64_t ip6s_nogif;           /* no match gif found */
     173             :         u_int64_t ip6s_toomanyhdr;      /* discarded due to too many headers */
     174             : 
     175             :         /*
     176             :          * statistics for improvement of the source address selection
     177             :          * algorithm:
     178             :          * XXX: hardcoded 16 = # of ip6 multicast scope types + 1
     179             :          */
     180             :         /* number of times that address selection fails */
     181             :         u_int64_t ip6s_sources_none;
     182             :         /* number of times that an address on the outgoing I/F is chosen */
     183             :         u_int64_t ip6s_sources_sameif[16];
     184             :         /* number of times that an address on a non-outgoing I/F is chosen */
     185             :         u_int64_t ip6s_sources_otherif[16];
     186             :         /*
     187             :          * number of times that an address that has the same scope
     188             :          * from the destination is chosen.
     189             :          */
     190             :         u_int64_t ip6s_sources_samescope[16];
     191             :         /*
     192             :          * number of times that an address that has a different scope
     193             :          * from the destination is chosen.
     194             :          */
     195             :         u_int64_t ip6s_sources_otherscope[16];
     196             :         /* number of times that an deprecated address is chosen */
     197             :         u_int64_t ip6s_sources_deprecated[16];
     198             : 
     199             :         u_int64_t ip6s_forward_cachehit;
     200             :         u_int64_t ip6s_forward_cachemiss;
     201             : };
     202             : 
     203             : #ifdef _KERNEL
     204             : 
     205             : #include <sys/percpu.h>
     206             : 
     207             : enum ip6stat_counters {
     208             :         ip6s_total,
     209             :         ip6s_tooshort,
     210             :         ip6s_toosmall,
     211             :         ip6s_fragments,
     212             :         ip6s_fragdropped,
     213             :         ip6s_fragtimeout,
     214             :         ip6s_fragoverflow,
     215             :         ip6s_forward,
     216             :         ip6s_cantforward,
     217             :         ip6s_redirectsent,
     218             :         ip6s_delivered,
     219             :         ip6s_localout,
     220             :         ip6s_odropped,
     221             :         ip6s_reassembled,
     222             :         ip6s_fragmented,
     223             :         ip6s_ofragments,
     224             :         ip6s_cantfrag,
     225             :         ip6s_badoptions,
     226             :         ip6s_noroute,
     227             :         ip6s_badvers,
     228             :         ip6s_rawout,
     229             :         ip6s_badscope,
     230             :         ip6s_notmember,
     231             :         ip6s_nxthist,
     232             :         ip6s_m1 = ip6s_nxthist + 256,
     233             :         ip6s_m2m,
     234             :         ip6s_mext1 = ip6s_m2m + 32,
     235             :         ip6s_mext2m,
     236             :         ip6s_nogif,
     237             :         ip6s_toomanyhdr,
     238             :         ip6s_sources_none,
     239             :         ip6s_sources_sameif,
     240             :         ip6s_sources_otherif = ip6s_sources_sameif + 16,
     241             :         ip6s_sources_samescope = ip6s_sources_otherif + 16,
     242             :         ip6s_sources_otherscope = ip6s_sources_samescope + 16,
     243             :         ip6s_sources_deprecated = ip6s_sources_otherscope + 16,
     244             :         ip6s_forward_cachehit = ip6s_sources_deprecated + 16,
     245             :         ip6s_forward_cachemiss,
     246             :         ip6s_ncounters,
     247             : };
     248             : 
     249             : extern struct cpumem *ip6counters;
     250             : 
     251             : static inline void
     252           0 : ip6stat_inc(enum ip6stat_counters c)
     253             : {
     254           0 :         counters_inc(ip6counters, c);
     255           0 : }
     256             : 
     257             : static inline void
     258           0 : ip6stat_add(enum ip6stat_counters c, uint64_t v)
     259             : {
     260           0 :         counters_add(ip6counters, c, v);
     261           0 : }
     262             : 
     263             : /* flags passed to ip6_output as last parameter */
     264             : #define IPV6_UNSPECSRC          0x01    /* allow :: as the source address */
     265             : #define IPV6_FORWARDING         0x02    /* most of IPv6 header exists */
     266             : #define IPV6_MINMTU             0x04    /* use minimum MTU (IPV6_USE_MIN_MTU) */
     267             : 
     268             : extern int ip6_mtudisc_timeout;         /* mtu discovery */
     269             : extern struct rttimer_queue *icmp6_mtudisc_timeout_q;
     270             : 
     271             : extern int      ip6_defhlim;            /* default hop limit */
     272             : extern int      ip6_defmcasthlim;       /* default multicast hop limit */
     273             : extern int      ip6_forwarding;         /* act as router? */
     274             : extern int      ip6_mforwarding;        /* act as multicast router? */
     275             : extern int      ip6_multipath;          /* use multipath routes */
     276             : extern int      ip6_sendredirect;       /* send ICMPv6 redirect? */
     277             : extern int      ip6_use_deprecated;     /* allow deprecated addr as source */
     278             : extern int      ip6_mcast_pmtu;         /* path MTU discovery for multicast */
     279             : extern int      ip6_neighborgcthresh; /* Threshold # of NDP entries for GC */
     280             : extern int      ip6_maxdynroutes; /* Max # of routes created via redirect */
     281             : 
     282             : extern struct socket *ip6_mrouter[RT_TABLEID_MAX]; /* multicast routing daemon */
     283             : extern int      ip6_sendredirects;      /* send IP redirects when forwarding? */
     284             : extern int      ip6_maxfragpackets; /* Maximum packets in reassembly queue */
     285             : extern int      ip6_maxfrags;   /* Maximum fragments in reassembly queue */
     286             : extern int      ip6_log_interval;
     287             : extern time_t   ip6_log_time;
     288             : extern int      ip6_hdrnestlimit; /* upper limit of # of extension headers */
     289             : extern int      ip6_dad_count;          /* DupAddrDetectionTransmits */
     290             : extern int      ip6_dad_pending;        /* number of currently running DADs */
     291             : 
     292             : extern int ip6_auto_flowlabel;
     293             : extern int ip6_auto_linklocal;
     294             : 
     295             : #define IP6_SOIIKEY_LEN 16
     296             : extern uint8_t  ip6_soiikey[IP6_SOIIKEY_LEN];
     297             : 
     298             : struct in6pcb;
     299             : struct inpcb;
     300             : 
     301             : int     icmp6_ctloutput(int, struct socket *, int, int, struct mbuf *);
     302             : 
     303             : void    ip6_init(void);
     304             : void    ip6intr(void);
     305             : int     ip6_input_if(struct mbuf **, int *, int, int, struct ifnet *);
     306             : void    ip6_freepcbopts(struct ip6_pktopts *);
     307             : void    ip6_freemoptions(struct ip6_moptions *);
     308             : int     ip6_unknown_opt(u_int8_t *, struct mbuf *, int);
     309             : int     ip6_get_prevhdr(struct mbuf *, int);
     310             : int     ip6_nexthdr(struct mbuf *, int, int, int *);
     311             : int     ip6_lasthdr(struct mbuf *, int, int, int *);
     312             : int     ip6_mforward(struct ip6_hdr *, struct ifnet *, struct mbuf *);
     313             : int     ip6_process_hopopts(struct mbuf *, u_int8_t *, int, u_int32_t *,
     314             :              u_int32_t *);
     315             : void    ip6_savecontrol(struct inpcb *, struct mbuf *, struct mbuf **);
     316             : int     ip6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
     317             : 
     318             : void    ip6_forward(struct mbuf *, struct rtentry *, int);
     319             : 
     320             : void    ip6_mloopback(struct ifnet *, struct mbuf *, struct sockaddr_in6 *);
     321             : int     ip6_output(struct mbuf *, struct ip6_pktopts *, struct route_in6 *, int,
     322             :             struct ip6_moptions *, struct inpcb *);
     323             : int     ip6_fragment(struct mbuf *, int, u_char, u_long);
     324             : int     ip6_ctloutput(int, struct socket *, int, int, struct mbuf *);
     325             : int     ip6_raw_ctloutput(int, struct socket *, int, int, struct mbuf *);
     326             : void    ip6_initpktopts(struct ip6_pktopts *);
     327             : int     ip6_setpktopts(struct mbuf *, struct ip6_pktopts *,
     328             :             struct ip6_pktopts *, int, int);
     329             : void    ip6_clearpktopts(struct ip6_pktopts *, int);
     330             : void    ip6_randomid_init(void);
     331             : u_int32_t ip6_randomid(void);
     332             : void    ip6_send(struct mbuf *);
     333             : 
     334             : int     route6_input(struct mbuf **, int *, int, int);
     335             : 
     336             : void    frag6_init(void);
     337             : int     frag6_input(struct mbuf **, int *, int, int);
     338             : int     frag6_deletefraghdr(struct mbuf *, int);
     339             : void    frag6_slowtimo(void);
     340             : 
     341             : void    rip6_init(void);
     342             : int     rip6_input(struct mbuf **, int *, int, int);
     343             : void    rip6_ctlinput(int, struct sockaddr *, u_int, void *);
     344             : int     rip6_ctloutput(int, struct socket *, int, int, struct mbuf *);
     345             : int     rip6_output(struct mbuf *, struct socket *, struct sockaddr *,
     346             :             struct mbuf *);
     347             : int     rip6_usrreq(struct socket *,
     348             :             int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *);
     349             : int     rip6_attach(struct socket *, int);
     350             : int     rip6_detach(struct socket *);
     351             : int     rip6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
     352             : 
     353             : int     dest6_input(struct mbuf **, int *, int, int);
     354             : int     none_input(struct mbuf **, int *, int);
     355             : 
     356             : int     in6_pcbselsrc(struct in6_addr **, struct sockaddr_in6 *,
     357             :             struct inpcb *, struct ip6_pktopts *);
     358             : int     in6_selectsrc(struct in6_addr **, struct sockaddr_in6 *,
     359             :             struct ip6_moptions *, unsigned int);
     360             : struct rtentry *in6_selectroute(struct sockaddr_in6 *, struct ip6_pktopts *,
     361             :             struct route_in6 *, unsigned int rtableid);
     362             : 
     363             : u_int32_t ip6_randomflowlabel(void);
     364             : 
     365             : #ifdef IPSEC
     366             : struct tdb;
     367             : struct tdb *
     368             :         ip6_output_ipsec_lookup(struct mbuf *, int *, struct inpcb *);
     369             : int     ip6_output_ipsec_send(struct tdb *, struct mbuf *, int, int);
     370             : #endif /* IPSEC */
     371             : 
     372             : #endif /* _KERNEL */
     373             : 
     374             : #endif /* !_NETINET6_IP6_VAR_H_ */

Generated by: LCOV version 1.13