|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights ! 7: * Reserved. This file contains Original Code and/or Modifications of ! 8: * Original Code as defined in and that are subject to the Apple Public ! 9: * Source License Version 1.1 (the "License"). You may not use this file ! 10: * except in compliance with the License. Please obtain a copy of the ! 11: * License at http://www.apple.com/publicsource and read it before using ! 12: * this file. ! 13: * ! 14: * The Original Code and all software distributed under the License are ! 15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 19: * License for the specific language governing rights and limitations ! 20: * under the License. ! 21: * ! 22: * @APPLE_LICENSE_HEADER_END@ ! 23: */ ! 24: ! 25: /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ ! 26: /* ! 27: * Copyright (c) 1985, 1986, 1993 ! 28: * The Regents of the University of California. All rights reserved. ! 29: * ! 30: * Redistribution and use in source and binary forms, with or without ! 31: * modification, are permitted provided that the following conditions ! 32: * are met: ! 33: * 1. Redistributions of source code must retain the above copyright ! 34: * notice, this list of conditions and the following disclaimer. ! 35: * 2. Redistributions in binary form must reproduce the above copyright ! 36: * notice, this list of conditions and the following disclaimer in the ! 37: * documentation and/or other materials provided with the distribution. ! 38: * 3. All advertising materials mentioning features or use of this software ! 39: * must display the following acknowledgement: ! 40: * This product includes software developed by the University of ! 41: * California, Berkeley and its contributors. ! 42: * 4. Neither the name of the University nor the names of its contributors ! 43: * may be used to endorse or promote products derived from this software ! 44: * without specific prior written permission. ! 45: * ! 46: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ! 47: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ! 48: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ! 49: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ! 50: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ! 51: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ! 52: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! 53: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ! 54: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ! 55: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ! 56: * SUCH DAMAGE. ! 57: * ! 58: * @(#)in_var.h 8.2 (Berkeley) 1/9/95 ! 59: */ ! 60: ! 61: /* ! 62: * Interface address, Internet version. One of these structures ! 63: * is allocated for each interface with an Internet address. ! 64: * The ifaddr structure contains the protocol-independent part ! 65: * of the structure and is assumed to be first. ! 66: */ ! 67: struct in_ifaddr { ! 68: struct ifaddr ia_ifa; /* protocol-independent info */ ! 69: #define ia_ifp ia_ifa.ifa_ifp ! 70: #define ia_flags ia_ifa.ifa_flags ! 71: /* ia_{,sub}net{,mask} in host order */ ! 72: u_long ia_net; /* network number of interface */ ! 73: u_long ia_netmask; /* mask of net part */ ! 74: u_long ia_subnet; /* subnet number, including net */ ! 75: u_long ia_subnetmask; /* mask of subnet part */ ! 76: struct in_addr ia_netbroadcast; /* to recognize net broadcasts */ ! 77: struct in_ifaddr *ia_next; /* next in list of internet addresses */ ! 78: struct sockaddr_in ia_addr; /* reserve space for interface name */ ! 79: struct sockaddr_in ia_dstaddr; /* reserve space for broadcast addr */ ! 80: #define ia_broadaddr ia_dstaddr ! 81: struct sockaddr_in ia_sockmask; /* reserve space for general netmask */ ! 82: struct in_multi *ia_multiaddrs; /* list of multicast addresses */ ! 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: }; ! 92: /* ! 93: * Given a pointer to an in_ifaddr (ifaddr), ! 94: * return a pointer to the addr as a sockaddr_in. ! 95: */ ! 96: #define IA_SIN(ia) (&(((struct in_ifaddr *)(ia))->ia_addr)) ! 97: ! 98: #define IN_LNAOF(in, ifa) \ ! 99: ((ntohl((in).s_addr) & ~((struct in_ifaddr *)(ifa)->ia_subnetmask)) ! 100: ! 101: ! 102: #ifdef _KERNEL ! 103: extern struct in_ifaddr *in_ifaddr; ! 104: extern struct ifqueue ipintrq; /* ip packet input queue */ ! 105: ! 106: ! 107: /* ! 108: * Macro for finding the interface (ifnet structure) corresponding to one ! 109: * of our IP addresses. ! 110: */ ! 111: #define INADDR_TO_IFP(addr, ifp) \ ! 112: /* struct in_addr addr; */ \ ! 113: /* struct ifnet *ifp; */ \ ! 114: { \ ! 115: register struct in_ifaddr *ia; \ ! 116: \ ! 117: for (ia = in_ifaddr; \ ! 118: ia != NULL && IA_SIN(ia)->sin_addr.s_addr != (addr).s_addr; \ ! 119: ia = ia->ia_next) \ ! 120: continue; \ ! 121: (ifp) = (ia == NULL) ? NULL : ia->ia_ifp; \ ! 122: } ! 123: ! 124: /* ! 125: * Macro for finding the internet address structure (in_ifaddr) corresponding ! 126: * to a given interface (ifnet structure). ! 127: */ ! 128: #define IFP_TO_IA(ifp, ia) \ ! 129: /* struct ifnet *ifp; */ \ ! 130: /* struct in_ifaddr *ia; */ \ ! 131: { \ ! 132: for ((ia) = in_ifaddr; \ ! 133: (ia) != NULL && (ia)->ia_ifp != (ifp); \ ! 134: (ia) = (ia)->ia_next) \ ! 135: continue; \ ! 136: } ! 137: #endif ! 138: ! 139: /* ! 140: * Internet multicast address structure. There is one of these for each IP ! 141: * multicast group to which this host belongs on a given network interface. ! 142: * They are kept in a linked list, rooted in the interface's in_ifaddr ! 143: * structure. ! 144: */ ! 145: struct in_multi { ! 146: struct in_addr inm_addr; /* IP multicast address */ ! 147: struct ifnet *inm_ifp; /* back pointer to ifnet */ ! 148: struct in_ifaddr *inm_ia; /* back pointer to in_ifaddr */ ! 149: u_int inm_refcount; /* no. membership claims by sockets */ ! 150: u_int inm_timer; /* IGMP membership report timer */ ! 151: struct in_multi *inm_next; /* ptr to next multicast address */ ! 152: }; ! 153: ! 154: #ifdef _KERNEL ! 155: /* ! 156: * Structure used by macros below to remember position when stepping through ! 157: * all of the in_multi records. ! 158: */ ! 159: struct in_multistep { ! 160: struct in_ifaddr *i_ia; ! 161: struct in_multi *i_inm; ! 162: }; ! 163: ! 164: /* ! 165: * Macro for looking up the in_multi record for a given IP multicast address ! 166: * on a given interface. If no matching record is found, "inm" returns NULL. ! 167: */ ! 168: #define IN_LOOKUP_MULTI(addr, ifp, inm) \ ! 169: /* struct in_addr addr; */ \ ! 170: /* struct ifnet *ifp; */ \ ! 171: /* struct in_multi *inm; */ \ ! 172: { \ ! 173: register struct in_ifaddr *ia; \ ! 174: \ ! 175: IFP_TO_IA((ifp), ia); \ ! 176: if (ia == NULL) \ ! 177: (inm) = NULL; \ ! 178: else \ ! 179: for ((inm) = ia->ia_multiaddrs; \ ! 180: (inm) != NULL && (inm)->inm_addr.s_addr != (addr).s_addr; \ ! 181: (inm) = inm->inm_next) \ ! 182: continue; \ ! 183: } ! 184: ! 185: /* ! 186: * Macro to step through all of the in_multi records, one at a time. ! 187: * The current position is remembered in "step", which the caller must ! 188: * provide. IN_FIRST_MULTI(), below, must be called to initialize "step" ! 189: * and get the first record. Both macros return a NULL "inm" when there ! 190: * are no remaining records. ! 191: */ ! 192: #define IN_NEXT_MULTI(step, inm) \ ! 193: /* struct in_multistep step; */ \ ! 194: /* struct in_multi *inm; */ \ ! 195: { \ ! 196: if (((inm) = (step).i_inm) != NULL) \ ! 197: (step).i_inm = (inm)->inm_next; \ ! 198: else \ ! 199: while ((step).i_ia != NULL) { \ ! 200: (inm) = (step).i_ia->ia_multiaddrs; \ ! 201: (step).i_ia = (step).i_ia->ia_next; \ ! 202: if ((inm) != NULL) { \ ! 203: (step).i_inm = (inm)->inm_next; \ ! 204: break; \ ! 205: } \ ! 206: } \ ! 207: } ! 208: ! 209: #define IN_FIRST_MULTI(step, inm) \ ! 210: /* struct in_multistep step; */ \ ! 211: /* struct in_multi *inm; */ \ ! 212: { \ ! 213: (step).i_ia = in_ifaddr; \ ! 214: (step).i_inm = NULL; \ ! 215: IN_NEXT_MULTI((step), (inm)); \ ! 216: } ! 217: ! 218: int in_ifinit __P((struct ifnet *, ! 219: struct in_ifaddr *, struct sockaddr_in *, int)); ! 220: struct in_multi *in_addmulti __P((struct in_addr *, struct ifnet *)); ! 221: int in_delmulti __P((struct in_multi *)); ! 222: void in_ifscrub __P((struct ifnet *, struct in_ifaddr *)); ! 223: int in_control __P((struct socket *, u_long, caddr_t, struct ifnet *)); ! 224: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.