Annotation of XNU/bsd/netinet/in_var.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * The contents of this file constitute Original Code as defined in and
        !             7:  * are subject to the Apple Public Source License Version 1.1 (the
        !             8:  * "License").  You may not use this file except in compliance with the
        !             9:  * License.  Please obtain a copy of the License at
        !            10:  * http://www.apple.com/publicsource and read it before using this file.
        !            11:  * 
        !            12:  * This Original Code and all software distributed under the License are
        !            13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            17:  * License for the specific language governing rights and limitations
        !            18:  * under the License.
        !            19:  * 
        !            20:  * @APPLE_LICENSE_HEADER_END@
        !            21:  */
        !            22: /*
        !            23:  * Copyright (c) 1985, 1986, 1993
        !            24:  *     The Regents of the University of California.  All rights reserved.
        !            25:  *
        !            26:  * Redistribution and use in source and binary forms, with or without
        !            27:  * modification, are permitted provided that the following conditions
        !            28:  * are met:
        !            29:  * 1. Redistributions of source code must retain the above copyright
        !            30:  *    notice, this list of conditions and the following disclaimer.
        !            31:  * 2. Redistributions in binary form must reproduce the above copyright
        !            32:  *    notice, this list of conditions and the following disclaimer in the
        !            33:  *    documentation and/or other materials provided with the distribution.
        !            34:  * 3. All advertising materials mentioning features or use of this software
        !            35:  *    must display the following acknowledgement:
        !            36:  *     This product includes software developed by the University of
        !            37:  *     California, Berkeley and its contributors.
        !            38:  * 4. Neither the name of the University nor the names of its contributors
        !            39:  *    may be used to endorse or promote products derived from this software
        !            40:  *    without specific prior written permission.
        !            41:  *
        !            42:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
        !            43:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            44:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            45:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
        !            46:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            47:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            48:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            49:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            50:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            51:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            52:  * SUCH DAMAGE.
        !            53:  *
        !            54:  *     @(#)in_var.h    8.2 (Berkeley) 1/9/95
        !            55:  */
        !            56: 
        !            57: #ifndef _NETINET_IN_VAR_H_
        !            58: #define _NETINET_IN_VAR_H_
        !            59: 
        !            60: #include <sys/queue.h>
        !            61: 
        !            62: /*
        !            63:  * Interface address, Internet version.  One of these structures
        !            64:  * is allocated for each Internet address on an interface.
        !            65:  * The ifaddr structure contains the protocol-independent part
        !            66:  * of the structure and is assumed to be first.
        !            67:  */
        !            68: struct in_ifaddr {
        !            69:        struct  ifaddr ia_ifa;          /* protocol-independent info */
        !            70: #define        ia_ifp          ia_ifa.ifa_ifp
        !            71: #define ia_flags       ia_ifa.ifa_flags
        !            72:                                        /* ia_{,sub}net{,mask} in host order */
        !            73:        u_long  ia_net;                 /* network number of interface */
        !            74:        u_long  ia_netmask;             /* mask of net part */
        !            75:        u_long  ia_subnet;              /* subnet number, including net */
        !            76:        u_long  ia_subnetmask;          /* mask of subnet part */
        !            77:        struct  in_addr ia_netbroadcast; /* to recognize net broadcasts */
        !            78:        TAILQ_ENTRY(in_ifaddr) ia_link; /* tailq macro glue */
        !            79:        struct  sockaddr_in ia_addr;    /* reserve space for interface name */
        !            80:        struct  sockaddr_in ia_dstaddr; /* reserve space for broadcast addr */
        !            81: #define        ia_broadaddr    ia_dstaddr
        !            82:        struct  sockaddr_in ia_sockmask; /* reserve space for general netmask */
        !            83: };
        !            84: 
        !            85: struct in_aliasreq {
        !            86:        char    ifra_name[IFNAMSIZ];            /* if name, e.g. "en0" */
        !            87:        struct  sockaddr_in ifra_addr;
        !            88:        struct  sockaddr_in ifra_broadaddr;
        !            89: #define ifra_dstaddr ifra_broadaddr
        !            90:        struct  sockaddr_in ifra_mask;
        !            91:         u_long              dlt;
        !            92: };
        !            93: /*
        !            94:  * Given a pointer to an in_ifaddr (ifaddr),
        !            95:  * return a pointer to the addr as a sockaddr_in.
        !            96:  */
        !            97: #define IA_SIN(ia)    (&(((struct in_ifaddr *)(ia))->ia_addr))
        !            98: #define IA_DSTSIN(ia) (&(((struct in_ifaddr *)(ia))->ia_dstaddr))
        !            99: 
        !           100: #define IN_LNAOF(in, ifa) \
        !           101:        ((ntohl((in).s_addr) & ~((struct in_ifaddr *)(ifa)->ia_subnetmask))
        !           102: 
        !           103: 
        !           104: #ifdef KERNEL
        !           105: extern TAILQ_HEAD(in_ifaddrhead, in_ifaddr) in_ifaddrhead;
        !           106: extern struct  ifqueue ipintrq;                /* ip packet input queue */
        !           107: extern struct  in_addr zeroin_addr;
        !           108: extern u_char  inetctlerrmap[];
        !           109: 
        !           110: /*
        !           111:  * Macro for finding the interface (ifnet structure) corresponding to one
        !           112:  * of our IP addresses.
        !           113:  */
        !           114: #define INADDR_TO_IFP(addr, ifp) \
        !           115:        /* struct in_addr addr; */ \
        !           116:        /* struct ifnet *ifp; */ \
        !           117: { \
        !           118:        register struct in_ifaddr *ia; \
        !           119: \
        !           120:        for (ia = in_ifaddrhead.tqh_first; \
        !           121:            ia != NULL && ((ia->ia_ifp->if_flags & IFF_POINTOPOINT)? \
        !           122:                IA_DSTSIN(ia):IA_SIN(ia))->sin_addr.s_addr != (addr).s_addr; \
        !           123:            ia = ia->ia_link.tqe_next) \
        !           124:                 continue; \
        !           125:        if (ia == NULL) \
        !           126:            for (ia = in_ifaddrhead.tqh_first; \
        !           127:                ia != NULL; \
        !           128:                ia = ia->ia_link.tqe_next) \
        !           129:                    if (ia->ia_ifp->if_flags & IFF_POINTOPOINT && \
        !           130:                        IA_SIN(ia)->sin_addr.s_addr == (addr).s_addr) \
        !           131:                            break; \
        !           132:        (ifp) = (ia == NULL) ? NULL : ia->ia_ifp; \
        !           133: }
        !           134: 
        !           135: /*
        !           136:  * Macro for finding the internet address structure (in_ifaddr) corresponding
        !           137:  * to a given interface (ifnet structure).
        !           138:  */
        !           139: #define IFP_TO_IA(ifp, ia) \
        !           140:        /* struct ifnet *ifp; */ \
        !           141:        /* struct in_ifaddr *ia; */ \
        !           142: { \
        !           143:        for ((ia) = in_ifaddrhead.tqh_first; \
        !           144:            (ia) != NULL && (ia)->ia_ifp != (ifp); \
        !           145:            (ia) = (ia)->ia_link.tqe_next) \
        !           146:                continue; \
        !           147: }
        !           148: #endif
        !           149: 
        !           150: /*
        !           151:  * This information should be part of the ifnet structure but we don't wish
        !           152:  * to change that - as it might break a number of things
        !           153:  */
        !           154: 
        !           155: struct router_info {
        !           156:        struct ifnet *rti_ifp;
        !           157:        int    rti_type; /* type of router which is querier on this interface */
        !           158:        int    rti_time; /* # of slow timeouts since last old query */
        !           159:        struct router_info *rti_next;
        !           160: };
        !           161: 
        !           162: /*
        !           163:  * Internet multicast address structure.  There is one of these for each IP
        !           164:  * multicast group to which this host belongs on a given network interface.
        !           165:  * For every entry on the interface's if_multiaddrs list which represents
        !           166:  * an IP multicast group, there is one of these structures.  They are also
        !           167:  * kept on a system-wide list to make it easier to keep our legacy IGMP code
        !           168:  * compatible with the rest of the world (see IN_FIRST_MULTI et al, below).
        !           169:  */
        !           170: struct in_multi {
        !           171:        LIST_ENTRY(in_multi) inm_link;  /* queue macro glue */
        !           172:        struct  in_addr inm_addr;       /* IP multicast address, convenience */
        !           173:        struct  ifnet *inm_ifp;         /* back pointer to ifnet */
        !           174:        struct  ifmultiaddr *inm_ifma;  /* back pointer to ifmultiaddr */
        !           175:        u_int   inm_timer;              /* IGMP membership report timer */
        !           176:        u_int   inm_state;              /*  state of the membership */
        !           177:        struct  router_info *inm_rti;   /* router info*/
        !           178: };
        !           179: 
        !           180: #ifdef KERNEL
        !           181: 
        !           182: #ifdef SYSCTL_DECL
        !           183: SYSCTL_DECL(_net_inet_ip);
        !           184: SYSCTL_DECL(_net_inet_raw);
        !           185: #endif
        !           186: 
        !           187: extern LIST_HEAD(in_multihead, in_multi) in_multihead;
        !           188: 
        !           189: /*
        !           190:  * Structure used by macros below to remember position when stepping through
        !           191:  * all of the in_multi records.
        !           192:  */
        !           193: struct in_multistep {
        !           194:        struct in_multi *i_inm;
        !           195: };
        !           196: 
        !           197: /*
        !           198:  * Macro for looking up the in_multi record for a given IP multicast address
        !           199:  * on a given interface.  If no matching record is found, "inm" is set null.
        !           200:  */
        !           201: #define IN_LOOKUP_MULTI(addr, ifp, inm) \
        !           202:        /* struct in_addr addr; */ \
        !           203:        /* struct ifnet *ifp; */ \
        !           204:        /* struct in_multi *inm; */ \
        !           205: do { \
        !           206:        register struct ifmultiaddr *ifma; \
        !           207: \
        !           208:        for (ifma = (ifp)->if_multiaddrs.lh_first; ifma; \
        !           209:             ifma = ifma->ifma_link.le_next) { \
        !           210:                if (ifma->ifma_addr->sa_family == AF_INET \
        !           211:                    && ((struct sockaddr_in *)ifma->ifma_addr)->sin_addr.s_addr == \
        !           212:                    (addr).s_addr) \
        !           213:                        break; \
        !           214:        } \
        !           215:        (inm) = ifma ? ifma->ifma_protospec : 0; \
        !           216: } while(0)
        !           217: 
        !           218: /*
        !           219:  * Macro to step through all of the in_multi records, one at a time.
        !           220:  * The current position is remembered in "step", which the caller must
        !           221:  * provide.  IN_FIRST_MULTI(), below, must be called to initialize "step"
        !           222:  * and get the first record.  Both macros return a NULL "inm" when there
        !           223:  * are no remaining records.
        !           224:  */
        !           225: #define IN_NEXT_MULTI(step, inm) \
        !           226:        /* struct in_multistep  step; */ \
        !           227:        /* struct in_multi *inm; */ \
        !           228: do { \
        !           229:        if (((inm) = (step).i_inm) != NULL) \
        !           230:                (step).i_inm = (step).i_inm->inm_link.le_next; \
        !           231: } while(0)
        !           232: 
        !           233: #define IN_FIRST_MULTI(step, inm) \
        !           234:        /* struct in_multistep step; */ \
        !           235:        /* struct in_multi *inm; */ \
        !           236: do { \
        !           237:        (step).i_inm = in_multihead.lh_first; \
        !           238:        IN_NEXT_MULTI((step), (inm)); \
        !           239: } while(0)
        !           240: 
        !           241: struct route;
        !           242: struct in_multi *in_addmulti __P((struct in_addr *, struct ifnet *));
        !           243: void   in_delmulti __P((struct in_multi *));
        !           244: int    in_control __P((struct socket *, u_long, caddr_t, struct ifnet *,
        !           245:                        struct proc *));
        !           246: void   in_rtqdrain __P((void));
        !           247: void   ip_input __P((struct mbuf *));
        !           248: int    in_ifadown __P((struct ifaddr *ifa));
        !           249: void   in_ifscrub __P((struct ifnet *, struct in_ifaddr *));
        !           250: int    ipflow_fastforward __P((struct mbuf *));
        !           251: void   ipflow_create __P((const struct route *, struct mbuf *));
        !           252: void   ipflow_slowtimo __P((void));
        !           253: 
        !           254: #endif /* KERNEL */
        !           255: 
        !           256: #endif /* _NETINET_IN_VAR_H_ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.