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

          Line data    Source code
       1             : /*      $OpenBSD: in_var.h,v 1.40 2017/05/29 14:36:22 mpi Exp $ */
       2             : /*      $NetBSD: in_var.h,v 1.16 1996/02/13 23:42:15 christos Exp $     */
       3             : 
       4             : /*
       5             :  * Copyright (c) 1985, 1986, 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             :  *      @(#)in_var.h    8.1 (Berkeley) 6/10/93
      33             :  */
      34             : 
      35             : #ifndef _NETINET_IN_VAR_H_
      36             : #define _NETINET_IN_VAR_H_
      37             : 
      38             : #include <sys/queue.h>
      39             : 
      40             : #ifdef _KERNEL
      41             : /*
      42             :  * Interface address, Internet version.  One of these structures
      43             :  * is allocated for each interface with an Internet address.
      44             :  * The ifaddr structure contains the protocol-independent part
      45             :  * of the structure and is assumed to be first.
      46             :  */
      47             : struct in_ifaddr {
      48             :         struct  ifaddr ia_ifa;          /* protocol-independent info */
      49             : #define ia_ifp          ia_ifa.ifa_ifp
      50             : #define ia_flags        ia_ifa.ifa_flags
      51             :                                         /* ia_net{,mask} in host order */
      52             :         u_int32_t ia_net;               /* network number of interface */
      53             :         u_int32_t ia_netmask;           /* mask of net part */
      54             :         TAILQ_ENTRY(in_ifaddr) ia_list; /* list of internet addresses */
      55             :         struct  sockaddr_in ia_addr;    /* reserve space for interface name */
      56             :         struct  sockaddr_in ia_dstaddr; /* reserve space for broadcast addr */
      57             : #define ia_broadaddr    ia_dstaddr
      58             :         struct  sockaddr_in ia_sockmask; /* reserve space for general netmask */
      59             :         struct  in_multi *ia_allhosts;  /* multicast address record for
      60             :                                            the allhosts multicast group */
      61             : };
      62             : #endif
      63             : 
      64             : struct  in_aliasreq {
      65             :         char    ifra_name[IFNAMSIZ];            /* if name, e.g. "en0" */
      66             :         union {
      67             :                 struct  sockaddr_in ifrau_addr;
      68             :                 int     ifrau_align;
      69             :         } ifra_ifrau;
      70             : #ifndef ifra_addr
      71             : #define ifra_addr       ifra_ifrau.ifrau_addr
      72             : #endif
      73             :         struct  sockaddr_in ifra_dstaddr;
      74             : #define ifra_broadaddr  ifra_dstaddr
      75             :         struct  sockaddr_in ifra_mask;
      76             : };
      77             : 
      78             : 
      79             : #ifdef  _KERNEL
      80             : /*
      81             :  * Macro for finding the internet address structure (in_ifaddr) corresponding
      82             :  * to a given interface (ifnet structure).
      83             :  */
      84             : #define IFP_TO_IA(ifp, ia)                                              \
      85             :         /* struct ifnet *ifp; */                                        \
      86             :         /* struct in_ifaddr *ia; */                                     \
      87             : do {                                                                    \
      88             :         struct ifaddr *ifa;                                             \
      89             :         NET_ASSERT_LOCKED();                                            \
      90             :         TAILQ_FOREACH(ifa, &(ifp)->if_addrlist, ifa_list) {              \
      91             :                 if (ifa->ifa_addr->sa_family == AF_INET)          \
      92             :                         break;                                          \
      93             :         }                                                               \
      94             :         (ia) = ifatoia(ifa);                                            \
      95             : } while (/* CONSTCOND */ 0)
      96             : #endif
      97             : 
      98             : /*
      99             :  * Per-interface router version information.
     100             :  */
     101             : struct router_info {
     102             :         unsigned int    rti_ifidx;
     103             :         int             rti_type;       /* type of router on this interface */
     104             :         int             rti_age;        /* time since last v1 query */
     105             :         struct  router_info *rti_next;
     106             : };
     107             : 
     108             : #ifdef _KERNEL
     109             : /*
     110             :  * Internet multicast address structure.  There is one of these for each IP
     111             :  * multicast group to which this host belongs on a given network interface.
     112             :  */
     113             : struct in_multi {
     114             :         struct ifmaddr          inm_ifma;   /* Protocol-independent info */
     115             : #define inm_refcnt              inm_ifma.ifma_refcnt
     116             : #define inm_ifidx               inm_ifma.ifma_ifidx
     117             : 
     118             :         struct sockaddr_in      inm_sin;   /* IPv4 multicast address */
     119             : #define inm_addr                inm_sin.sin_addr
     120             : 
     121             :         u_int                   inm_state; /* state of membership */
     122             :         u_int                   inm_timer; /* IGMP membership report timer */
     123             : 
     124             :         struct router_info      *inm_rti;  /* router version info */
     125             : };
     126             : 
     127             : static __inline struct in_multi *
     128           0 : ifmatoinm(struct ifmaddr *ifma)
     129             : {
     130           0 :        return ((struct in_multi *)(ifma));
     131             : }
     132             : 
     133             : /*
     134             :  * Macro for looking up the in_multi record for a given IP multicast
     135             :  * address on a given interface.  If no matching record is found, "inm"
     136             :  * returns NULL.
     137             :  */
     138             : #define IN_LOOKUP_MULTI(addr, ifp, inm)                                 \
     139             :         /* struct in_addr addr; */                                      \
     140             :         /* struct ifnet *ifp; */                                        \
     141             :         /* struct in_multi *inm; */                                     \
     142             : do {                                                                    \
     143             :         struct ifmaddr *ifma;                                           \
     144             :                                                                         \
     145             :         (inm) = NULL;                                                   \
     146             :         NET_ASSERT_LOCKED();                                            \
     147             :         TAILQ_FOREACH(ifma, &(ifp)->if_maddrlist, ifma_list)             \
     148             :                 if (ifma->ifma_addr->sa_family == AF_INET &&              \
     149             :                     ifmatoinm(ifma)->inm_addr.s_addr == (addr).s_addr) {\
     150             :                         (inm) = ifmatoinm(ifma);                        \
     151             :                         break;                                          \
     152             :                 }                                                       \
     153             : } while (/* CONSTCOND */ 0)
     154             : 
     155             : int     in_ifinit(struct ifnet *,
     156             :             struct in_ifaddr *, struct sockaddr_in *, int);
     157             : struct  in_multi *in_addmulti(struct in_addr *, struct ifnet *);
     158             : void    in_delmulti(struct in_multi *);
     159             : int     in_hasmulti(struct in_addr *, struct ifnet *);
     160             : void    in_ifscrub(struct ifnet *, struct in_ifaddr *);
     161             : int     in_control(struct socket *, u_long, caddr_t, struct ifnet *);
     162             : int     in_ioctl(u_long, caddr_t, struct ifnet *, int);
     163             : void    in_prefixlen2mask(struct in_addr *, int);
     164             : #endif
     165             : 
     166             : #endif /* _NETINET_IN_VAR_H_ */

Generated by: LCOV version 1.13