1 /* $NetBSD: in_var.h,v 1.1 1999/12/11 22:24:08 veego Exp $ */
3 /* @(#)in_var.h 1.3 88/08/19 SMI; from UCB 7.1 6/5/86 */
6 * Copyright (c) 1985, 1986 Regents of the University of California.
7 * All rights reserved. The Berkeley software License Agreement
8 * specifies the terms and conditions for redistribution.
12 * Interface address, Internet version. One of these structures
13 * is allocated for each interface with an Internet address.
14 * The ifaddr structure contains the protocol-independent part
15 * of the structure and is assumed to be first.
18 #ifndef _netinet_in_var_h
19 #define _netinet_in_var_h
22 struct ifaddr ia_ifa
; /* protocol-independent info */
23 #define ia_addr ia_ifa.ifa_addr
24 #define ia_broadaddr ia_ifa.ifa_broadaddr
25 #define ia_dstaddr ia_ifa.ifa_dstaddr
26 #define ia_ifp ia_ifa.ifa_ifp
27 u_long ia_net
; /* network number of interface */
28 u_long ia_netmask
; /* mask of net part */
29 u_long ia_subnet
; /* subnet number, including net */
30 u_long ia_subnetmask
; /* mask of net + subnet */
31 struct in_addr ia_netbroadcast
; /* broadcast addr for (logical) net */
33 struct in_ifaddr
*ia_next
; /* next in list of internet addresses */
34 struct in_multi
*ia_multiaddrs
;/* list of multicast addresses */
37 * Given a pointer to an in_ifaddr (ifaddr),
38 * return a pointer to the addr as a sockadd_in.
40 #define IA_SIN(ia) ((struct sockaddr_in *)(&((struct in_ifaddr *)ia)->ia_addr))
44 #define IFA_ROUTE 0x01 /* routing entry installed */
47 struct in_ifaddr
*in_ifaddr
;
48 struct in_ifaddr
*in_iaonnetof();
49 struct ifqueue ipintrq
; /* ip packet input queue */
54 * Macro for finding the interface (ifnet structure) corresponding to one
55 * of our IP addresses.
57 #define INADDR_TO_IFP(addr, ifp) \
58 /* struct in_addr addr; */ \
59 /* struct ifnet *ifp; */ \
61 register struct in_ifaddr *ia; \
63 for (ia = in_ifaddr; \
64 ia != NULL && IA_SIN(ia)->sin_addr.s_addr != (addr).s_addr; \
66 (ifp) = (ia == NULL) ? NULL : ia->ia_ifp; \
70 * Macro for finding the internet address structure (in_ifaddr) corresponding
71 * to a given interface (ifnet structure).
73 #define IFP_TO_IA(ifp, ia) \
74 /* struct ifnet *ifp; */ \
75 /* struct in_ifaddr *ia; */ \
77 for ((ia) = in_ifaddr; \
78 (ia) != NULL && (ia)->ia_ifp != (ifp); \
79 (ia) = (ia)->ia_next); \
84 * Per-interface router version information is kept in this list.
85 * This information should be part of the ifnet structure but we don't wish
86 * to change that - as it might break a number of things
91 int type
; /* type of router which is querier on this interface */
92 int time
; /* # of slow timeouts since last old query */
93 struct router_info
*next
;
97 * Internet multicast address structure. There is one of these for each IP
98 * multicast group to which this host belongs on a given network interface.
99 * They are kept in a linked list, rooted in the interface's in_ifaddr
104 struct in_addr inm_addr
; /* IP multicast address */
105 struct ifnet
*inm_ifp
; /* back pointer to ifnet */
106 struct in_ifaddr
*inm_ia
; /* back pointer to in_ifaddr */
107 u_int inm_refcount
;/* no. membership claims by sockets */
108 u_int inm_timer
; /* IGMP membership report timer */
109 struct in_multi
*inm_next
; /* ptr to next multicast address */
110 u_int inm_state
; /* state of the membership */
111 struct router_info
*inm_rti
; /* router info*/
116 * Structure used by macros below to remember position when stepping through
117 * all of the in_multi records.
119 struct in_multistep
{
120 struct in_ifaddr
*i_ia
;
121 struct in_multi
*i_inm
;
125 * Macro for looking up the in_multi record for a given IP multicast address
126 * on a given interface. If no matching record is found, "inm" returns NULL.
128 #define IN_LOOKUP_MULTI(addr, ifp, inm) \
129 /* struct in_addr addr; */ \
130 /* struct ifnet *ifp; */ \
131 /* struct in_multi *inm; */ \
133 register struct in_ifaddr *ia; \
135 IFP_TO_IA((ifp), ia); \
139 for ((inm) = ia->ia_multiaddrs; \
140 (inm) != NULL && (inm)->inm_addr.s_addr != (addr).s_addr; \
141 (inm) = inm->inm_next); \
145 * Macro to step through all of the in_multi records, one at a time.
146 * The current position is remembered in "step", which the caller must
147 * provide. IN_FIRST_MULTI(), below, must be called to initialize "step"
148 * and get the first record. Both macros return a NULL "inm" when there
149 * are no remaining records.
151 #define IN_NEXT_MULTI(step, inm) \
152 /* struct in_multistep step; */ \
153 /* struct in_multi *inm; */ \
155 if (((inm) = (step).i_inm) != NULL) { \
156 (step).i_inm = (inm)->inm_next; \
158 else while ((step).i_ia != NULL) { \
159 (inm) = (step).i_ia->ia_multiaddrs; \
160 (step).i_ia = (step).i_ia->ia_next; \
161 if ((inm) != NULL) { \
162 (step).i_inm = (inm)->inm_next; \
168 #define IN_FIRST_MULTI(step, inm) \
169 /* struct in_multistep step; */ \
170 /* struct in_multi *inm; */ \
172 (step).i_ia = in_ifaddr; \
173 (step).i_inm = NULL; \
174 IN_NEXT_MULTI((step), (inm)); \
177 struct in_multi
*in_addmulti();
179 #endif /*!_netinet_in_var_h*/