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/netinet6/in6_var.h

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 /*      $OpenBSD: in6_var.h,v 1.78 2022/11/23 07:57:39 kn Exp $ */
    2 /*      $KAME: in6_var.h,v 1.55 2001/02/16 12:49:45 itojun 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) 1985, 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  *      @(#)in_var.h    8.1 (Berkeley) 6/10/93
   62  */
   63 
   64 #ifndef _NETINET6_IN6_VAR_H_
   65 #define _NETINET6_IN6_VAR_H_
   66 
   67 /*
   68  * Interface address, Internet version.  One of these structures
   69  * is allocated for each interface with an Internet address.
   70  * The ifaddr structure contains the protocol-independent part
   71  * of the structure and is assumed to be first.
   72  */
   73 
   74 /*
   75  * pltime/vltime are just for future reference (required to implements 2
   76  * hour rule for hosts).  they should never be modified by nd6_timeout or
   77  * anywhere else.
   78  *      userland -> kernel: accept pltime/vltime
   79  *      kernel -> userland: throw up everything
   80  *      in kernel: modify preferred/expire only
   81  */
   82 struct in6_addrlifetime {
   83         time_t ia6t_expire;     /* valid lifetime expiration time */
   84         time_t ia6t_preferred;  /* preferred lifetime expiration time */
   85         u_int32_t ia6t_vltime;  /* valid lifetime */
   86         u_int32_t ia6t_pltime;  /* prefix lifetime */
   87 };
   88 
   89 #ifdef _KERNEL
   90 struct  in6_ifaddr {
   91         struct  ifaddr ia_ifa;          /* protocol-independent info */
   92 #define ia_ifp          ia_ifa.ifa_ifp
   93 #define ia_flags        ia_ifa.ifa_flags
   94 
   95         struct  sockaddr_in6 ia_addr;   /* interface address */
   96         struct  sockaddr_in6 ia_dstaddr; /* space for destination addr */
   97         struct  sockaddr_in6 ia_prefixmask; /* prefix mask */
   98         TAILQ_ENTRY(in6_ifaddr) ia_list;        /* list of IP6 addresses */
   99         int     ia6_flags;
  100 
  101         struct in6_addrlifetime ia6_lifetime;
  102         time_t  ia6_updatetime;
  103 
  104         /* multicast addresses joined from the kernel */
  105         LIST_HEAD(, in6_multi_mship) ia6_memberships;
  106 };
  107 #endif /* _KERNEL */
  108 
  109 /*
  110  * IPv6 interface statistics, as defined in RFC2465 Ipv6IfStatsEntry (p12).
  111  */
  112 struct in6_ifstat {
  113         u_int64_t ifs6_in_receive;      /* # of total input datagram */
  114         u_int64_t ifs6_in_hdrerr;       /* # of datagrams with invalid hdr */
  115         u_int64_t ifs6_in_toobig;       /* # of datagrams exceeded MTU */
  116         u_int64_t ifs6_in_noroute;      /* # of datagrams with no route */
  117         u_int64_t ifs6_in_addrerr;      /* # of datagrams with invalid dst */
  118         u_int64_t ifs6_in_protounknown; /* # of datagrams with unknown proto */
  119                                         /* NOTE: increment on final dst if */
  120         u_int64_t ifs6_in_truncated;    /* # of truncated datagrams */
  121         u_int64_t ifs6_in_discard;      /* # of discarded datagrams */
  122                                         /* NOTE: fragment timeout is not here */
  123         u_int64_t ifs6_in_deliver;      /* # of datagrams delivered to ULP */
  124                                         /* NOTE: increment on final dst if */
  125         u_int64_t ifs6_out_forward;     /* # of datagrams forwarded */
  126                                         /* NOTE: increment on outgoing if */
  127         u_int64_t ifs6_out_request;     /* # of outgoing datagrams from ULP */
  128                                         /* NOTE: does not include forwards */
  129         u_int64_t ifs6_out_discard;     /* # of discarded datagrams */
  130         u_int64_t ifs6_out_fragok;      /* # of datagrams fragmented */
  131         u_int64_t ifs6_out_fragfail;    /* # of datagrams failed on fragment */
  132         u_int64_t ifs6_out_fragcreat;   /* # of fragment datagrams */
  133                                         /* NOTE: this is # after fragment */
  134         u_int64_t ifs6_reass_reqd;      /* # of incoming fragmented packets */
  135                                         /* NOTE: increment on final dst if */
  136         u_int64_t ifs6_reass_ok;        /* # of reassembled packets */
  137                                         /* NOTE: this is # after reass */
  138                                         /* NOTE: increment on final dst if */
  139         u_int64_t ifs6_reass_fail;      /* # of reass failures */
  140                                         /* NOTE: may not be packet count */
  141                                         /* NOTE: increment on final dst if */
  142         u_int64_t ifs6_in_mcast;        /* # of inbound multicast datagrams */
  143         u_int64_t ifs6_out_mcast;       /* # of outbound multicast datagrams */
  144 };
  145 
  146 /*
  147  * ICMPv6 interface statistics, as defined in RFC2466 Ipv6IfIcmpEntry.
  148  * XXX: I'm not sure if this file is the right place for this structure...
  149  */
  150 struct icmp6_ifstat {
  151         /*
  152          * Input statistics
  153          */
  154         /* ipv6IfIcmpInMsgs, total # of input messages */
  155         u_int64_t ifs6_in_msg;
  156         /* ipv6IfIcmpInErrors, # of input error messages */
  157         u_int64_t ifs6_in_error;
  158         /* ipv6IfIcmpInDestUnreachs, # of input dest unreach errors */
  159         u_int64_t ifs6_in_dstunreach;
  160         /* ipv6IfIcmpInAdminProhibs, # of input administratively prohibited errs */
  161         u_int64_t ifs6_in_adminprohib;
  162         /* ipv6IfIcmpInTimeExcds, # of input time exceeded errors */
  163         u_int64_t ifs6_in_timeexceed;
  164         /* ipv6IfIcmpInParmProblems, # of input parameter problem errors */
  165         u_int64_t ifs6_in_paramprob;
  166         /* ipv6IfIcmpInPktTooBigs, # of input packet too big errors */
  167         u_int64_t ifs6_in_pkttoobig;
  168         /* ipv6IfIcmpInEchos, # of input echo requests */
  169         u_int64_t ifs6_in_echo;
  170         /* ipv6IfIcmpInEchoReplies, # of input echo replies */
  171         u_int64_t ifs6_in_echoreply;
  172         /* ipv6IfIcmpInRouterSolicits, # of input router solicitations */
  173         u_int64_t ifs6_in_routersolicit;
  174         /* ipv6IfIcmpInRouterAdvertisements, # of input router advertisements */
  175         u_int64_t ifs6_in_routeradvert;
  176         /* ipv6IfIcmpInNeighborSolicits, # of input neighbor solicitations */
  177         u_int64_t ifs6_in_neighborsolicit;
  178         /* ipv6IfIcmpInNeighborAdvertisements, # of input neighbor advertisements */
  179         u_int64_t ifs6_in_neighboradvert;
  180         /* ipv6IfIcmpInRedirects, # of input redirects */
  181         u_int64_t ifs6_in_redirect;
  182         /* ipv6IfIcmpInGroupMembQueries, # of input MLD queries */
  183         u_int64_t ifs6_in_mldquery;
  184         /* ipv6IfIcmpInGroupMembResponses, # of input MLD reports */
  185         u_int64_t ifs6_in_mldreport;
  186         /* ipv6IfIcmpInGroupMembReductions, # of input MLD done */
  187         u_int64_t ifs6_in_mlddone;
  188 
  189         /*
  190          * Output statistics. We should solve unresolved routing problem...
  191          */
  192         /* ipv6IfIcmpOutMsgs, total # of output messages */
  193         u_int64_t ifs6_out_msg;
  194         /* ipv6IfIcmpOutErrors, # of output error messages */
  195         u_int64_t ifs6_out_error;
  196         /* ipv6IfIcmpOutDestUnreachs, # of output dest unreach errors */
  197         u_int64_t ifs6_out_dstunreach;
  198         /* ipv6IfIcmpOutAdminProhibs, # of output administratively prohibited errs */
  199         u_int64_t ifs6_out_adminprohib;
  200         /* ipv6IfIcmpOutTimeExcds, # of output time exceeded errors */
  201         u_int64_t ifs6_out_timeexceed;
  202         /* ipv6IfIcmpOutParmProblems, # of output parameter problem errors */
  203         u_int64_t ifs6_out_paramprob;
  204         /* ipv6IfIcmpOutPktTooBigs, # of output packet too big errors */
  205         u_int64_t ifs6_out_pkttoobig;
  206         /* ipv6IfIcmpOutEchos, # of output echo requests */
  207         u_int64_t ifs6_out_echo;
  208         /* ipv6IfIcmpOutEchoReplies, # of output echo replies */
  209         u_int64_t ifs6_out_echoreply;
  210         /* ipv6IfIcmpOutRouterSolicits, # of output router solicitations */
  211         u_int64_t ifs6_out_routersolicit;
  212         /* ipv6IfIcmpOutRouterAdvertisements, # of output router advertisements */
  213         u_int64_t ifs6_out_routeradvert;
  214         /* ipv6IfIcmpOutNeighborSolicits, # of output neighbor solicitations */
  215         u_int64_t ifs6_out_neighborsolicit;
  216         /* ipv6IfIcmpOutNeighborAdvertisements, # of output neighbor advertisements */
  217         u_int64_t ifs6_out_neighboradvert;
  218         /* ipv6IfIcmpOutRedirects, # of output redirects */
  219         u_int64_t ifs6_out_redirect;
  220         /* ipv6IfIcmpOutGroupMembQueries, # of output MLD queries */
  221         u_int64_t ifs6_out_mldquery;
  222         /* ipv6IfIcmpOutGroupMembResponses, # of output MLD reports */
  223         u_int64_t ifs6_out_mldreport;
  224         /* ipv6IfIcmpOutGroupMembReductions, # of output MLD done */
  225         u_int64_t ifs6_out_mlddone;
  226 };
  227 
  228 struct  in6_ifreq {
  229         char    ifr_name[IFNAMSIZ];
  230         union {
  231                 struct  sockaddr_in6 ifru_addr;
  232                 struct  sockaddr_in6 ifru_dstaddr;
  233                 short   ifru_flags;
  234                 int     ifru_flags6;
  235                 int     ifru_metric;
  236                 caddr_t ifru_data;
  237                 struct in6_addrlifetime ifru_lifetime;
  238                 struct in6_ifstat ifru_stat;
  239                 struct icmp6_ifstat ifru_icmp6stat;
  240         } ifr_ifru;
  241 };
  242 
  243 struct  in6_aliasreq {
  244         char    ifra_name[IFNAMSIZ];
  245         union {
  246                 struct  sockaddr_in6 ifrau_addr;
  247                 int     ifrau_align;
  248          } ifra_ifrau;
  249 #ifndef ifra_addr
  250 #define ifra_addr       ifra_ifrau.ifrau_addr
  251 #endif
  252         struct  sockaddr_in6 ifra_dstaddr;
  253         struct  sockaddr_in6 ifra_prefixmask;
  254         int     ifra_flags;
  255         struct in6_addrlifetime ifra_lifetime;
  256 };
  257 
  258 /*
  259  * Given a pointer to an in6_ifaddr (ifaddr),
  260  * return a pointer to the addr as a sockaddr_in6
  261  */
  262 #define IA6_IN6(ia)     (&((ia)->ia_addr.sin6_addr))
  263 #define IA6_DSTIN6(ia)  (&((ia)->ia_dstaddr.sin6_addr))
  264 #define IA6_MASKIN6(ia) (&((ia)->ia_prefixmask.sin6_addr))
  265 #define IA6_SIN6(ia)    (&((ia)->ia_addr))
  266 #define IA6_DSTSIN6(ia) (&((ia)->ia_dstaddr))
  267 #define IFA_IN6(x)      (&((struct sockaddr_in6 *)((x)->ifa_addr))->sin6_addr)
  268 #define IFA_DSTIN6(x)   (&((struct sockaddr_in6 *)((x)->ifa_dstaddr))->sin6_addr)
  269 
  270 #define SIOCDIFADDR_IN6          _IOW('i', 25, struct in6_ifreq)
  271 #define SIOCAIFADDR_IN6          _IOW('i', 26, struct in6_aliasreq)
  272 
  273 #define SIOCGIFDSTADDR_IN6      _IOWR('i', 34, struct in6_ifreq)
  274 #define SIOCGIFNETMASK_IN6      _IOWR('i', 37, struct in6_ifreq)
  275 
  276 #define SIOCGIFAFLAG_IN6        _IOWR('i', 73, struct in6_ifreq)
  277 
  278 #define SIOCGIFINFO_IN6         _IOWR('i', 108, struct in6_ndireq)
  279 #define SIOCGNBRINFO_IN6        _IOWR('i', 78, struct in6_nbrinfo)
  280 
  281 #define SIOCGIFALIFETIME_IN6    _IOWR('i', 81, struct in6_ifreq)
  282 
  283 #define SIOCGETSGCNT_IN6        _IOWR('u', 106, struct sioc_sg_req6)
  284 #define SIOCGETMIFCNT_IN6       _IOWR('u', 107, struct sioc_mif_req6)
  285 
  286 #define IN6_IFF_ANYCAST         0x01    /* anycast address */
  287 #define IN6_IFF_TENTATIVE       0x02    /* tentative address */
  288 #define IN6_IFF_DUPLICATED      0x04    /* DAD detected duplicate */
  289 #define IN6_IFF_DETACHED        0x08    /* may be detached from the link */
  290 #define IN6_IFF_DEPRECATED      0x10    /* deprecated address */
  291 #define IN6_IFF_AUTOCONF        0x40    /* autoconfigurable address. */
  292 #define IN6_IFF_TEMPORARY       0x80    /* RFC 4941 temporary address */
  293 
  294 #ifdef _KERNEL
  295 #define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m)      (       \
  296         (((d)->s6_addr32[0] ^ (a)->s6_addr32[0]) & (m)->s6_addr32[0]) == 0 && \
  297         (((d)->s6_addr32[1] ^ (a)->s6_addr32[1]) & (m)->s6_addr32[1]) == 0 && \
  298         (((d)->s6_addr32[2] ^ (a)->s6_addr32[2]) & (m)->s6_addr32[2]) == 0 && \
  299         (((d)->s6_addr32[3] ^ (a)->s6_addr32[3]) & (m)->s6_addr32[3]) == 0 )
  300 
  301 #define IN6_ARE_SCOPE_CMP(a,b) ((a)-(b))
  302 #define IN6_ARE_SCOPE_EQUAL(a,b) ((a)==(b))
  303 
  304 /*
  305  * Multi-cast membership entry.  One for each group/ifp that a PCB
  306  * belongs to.
  307  */
  308 struct in6_multi_mship {
  309         struct  in6_multi *i6mm_maddr;  /* Multicast address pointer */
  310         LIST_ENTRY(in6_multi_mship) i6mm_chain;  /* multicast options chain */
  311 };
  312 
  313 struct in6_multi {
  314         struct ifmaddr          in6m_ifma;   /* Protocol-independent info */
  315 #define in6m_refcnt             in6m_ifma.ifma_refcnt
  316 #define in6m_ifidx              in6m_ifma.ifma_ifidx
  317 
  318         struct sockaddr_in6     in6m_sin;   /* IPv6 multicast address */
  319 #define in6m_addr               in6m_sin.sin6_addr
  320 
  321         u_int                   in6m_state; /* state of membership */
  322         u_int                   in6m_timer; /* MLD6 membership report timer */
  323 };
  324 
  325 static __inline struct in6_multi *
  326 ifmatoin6m(struct ifmaddr *ifma)
  327 {
  328        return ((struct in6_multi *)(ifma));
  329 }
  330 
  331 /*
  332  * Macros for looking up the in6_multi record for a given IP6 multicast
  333  * address on a given interface. If no matching record is found, "in6m"
  334  * returns NULL.
  335  */
  336 #define IN6_LOOKUP_MULTI(addr, ifp, in6m)                               \
  337         /* struct in6_addr addr; */                                     \
  338         /* struct ifnet *ifp; */                                        \
  339         /* struct in6_multi *in6m; */                                   \
  340 do {                                                                    \
  341         struct ifmaddr *ifma;                                           \
  342                                                                         \
  343         (in6m) = NULL;                                                  \
  344         TAILQ_FOREACH(ifma, &(ifp)->if_maddrlist, ifma_list)            \
  345                 if (ifma->ifma_addr->sa_family == AF_INET6 &&           \
  346                     IN6_ARE_ADDR_EQUAL(&ifmatoin6m(ifma)->in6m_addr,    \
  347                                        &(addr))) {                      \
  348                         (in6m) = ifmatoin6m(ifma);                      \
  349                         break;                                          \
  350                 }                                                       \
  351 } while (/* CONSTCOND */ 0)
  352 
  353 struct  in6_multi *in6_addmulti(struct in6_addr *, struct ifnet *, int *);
  354 void    in6_delmulti(struct in6_multi *);
  355 int     in6_hasmulti(struct in6_addr *, struct ifnet *);
  356 struct in6_multi_mship *in6_joingroup(struct ifnet *, struct in6_addr *, int *);
  357 void    in6_leavegroup(struct in6_multi_mship *);
  358 int     in6_control(struct socket *, u_long, caddr_t, struct ifnet *);
  359 int     in6_ioctl(u_long, caddr_t, struct ifnet *, int);
  360 int     in6_update_ifa(struct ifnet *, struct in6_aliasreq *,
  361         struct in6_ifaddr *);
  362 void    in6_purgeaddr(struct ifaddr *);
  363 int     in6if_do_dad(struct ifnet *);
  364 void    *in6_domifattach(struct ifnet *);
  365 void    in6_domifdetach(struct ifnet *, void *);
  366 struct in6_ifaddr *in6ifa_ifpforlinklocal(struct ifnet *, int);
  367 struct in6_ifaddr *in6ifa_ifpwithaddr(struct ifnet *, struct in6_addr *);
  368 int     in6_addr2scopeid(unsigned int, struct in6_addr *);
  369 int     in6_matchlen(struct in6_addr *, struct in6_addr *);
  370 void    in6_prefixlen2mask(struct in6_addr *, int);
  371 void    in6_purgeprefix(struct ifnet *);
  372 #endif /* _KERNEL */
  373 
  374 #endif /* _NETINET6_IN6_VAR_H_ */

Cache object: 325313ad1f75e40184b1c5569ed6e60c


[ 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.