1 /*!\file netinet/in_var.h
2 * IP interface address.
6 * Copyright (c) 1985, 1986, 1993
7 * The Regents of the University of California. All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the University of
20 * California, Berkeley and its contributors.
21 * 4. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * @(#)in_var.h 8.2 (Berkeley) 1/9/95
38 * $Id: in_var.h,v 1.17 1996/03/14 16:59:19 fenner Exp $
41 #ifndef __NETINET_IN_VAR_H
42 #define __NETINET_IN_VAR_H
44 #include <sys/queue.h>
47 * Interface address, Internet version. One of these structures
48 * is allocated for each interface with an Internet address.
49 * The ifaddr structure contains the protocol-independent part
50 * of the structure and is assumed to be first.
53 struct ifaddr ia_ifa; /* protocol-independent info */
54 #define ia_ifp ia_ifa.ifa_ifp
55 #define ia_flags ia_ifa.ifa_flags
56 /* ia_{,sub}net{,mask} in host order */
57 u_long ia_net; /* network number of interface */
58 u_long ia_netmask; /* mask of net part */
59 u_long ia_subnet; /* subnet number, including net */
60 u_long ia_subnetmask; /* mask of subnet part */
61 struct in_addr ia_netbroadcast; /* to recognize net broadcasts */
62 struct in_ifaddr *ia_next; /* next in list of internet addresses */
63 struct sockaddr_in ia_addr; /* reserve space for interface name */
64 struct sockaddr_in ia_dstaddr; /* reserve space for broadcast addr */
65 #define ia_broadaddr ia_dstaddr
66 struct sockaddr_in ia_sockmask; /* reserve space for general netmask */
67 LIST_HEAD(in_multihead, in_multi) ia_multiaddrs;
68 /* list of multicast addresses */
72 char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */
73 struct sockaddr_in ifra_addr;
74 struct sockaddr_in ifra_broadaddr;
75 #define ifra_dstaddr ifra_broadaddr
76 struct sockaddr_in ifra_mask;
79 * Given a pointer to an in_ifaddr (ifaddr),
80 * return a pointer to the addr as a sockaddr_in.
82 #define IA_SIN(ia) (&(((struct in_ifaddr *)(ia))->ia_addr))
83 #define IA_DSTSIN(ia) (&(((struct in_ifaddr *)(ia))->ia_dstaddr))
85 #define IN_LNAOF(in, ifa) \
86 ((ntohl((in).s_addr) & ~((struct in_ifaddr *)(ifa)->ia_subnetmask))
90 * This information should be part of the ifnet structure but we don't wish
91 * to change that - as it might break a number of things
95 struct ifnet *rti_ifp;
96 int rti_type; /* type of router which is querier on this interface */
97 int rti_time; /* # of slow timeouts since last old query */
98 struct router_info *rti_next;
102 * Internet multicast address structure. There is one of these for each IP
103 * multicast group to which this host belongs on a given network interface.
104 * They are kept in a linked list, rooted in the interface's in_ifaddr
108 LIST_ENTRY(in_multi) inm_entry; /* list glue */
109 struct in_addr inm_addr; /* IP multicast address */
110 struct ifnet *inm_ifp; /* back pointer to ifnet */
111 struct in_ifaddr *inm_ia; /* back pointer to in_ifaddr */
112 u_int inm_refcount; /* no. membership claims by sockets */
113 u_int inm_timer; /* IGMP membership report timer */
114 u_int inm_state; /* state of the membership */
115 struct router_info *inm_rti; /* router info*/