source: rtems/cpukit/libnetworking/netinet/in_var.h @ dac1edb

4.104.114.84.95
Last change on this file since dac1edb was dac1edb, checked in by Ralf Corsepius <ralf.corsepius@…>, on 12/02/04 at 18:42:53

2004-12-02 Ralf Corsepius <ralf.corsepius@…>

  • libnetworking/net/radix.c, libnetworking/net/radix.h, libnetworking/net/route.h, libnetworking/netinet/if_ether.h, libnetworking/netinet/in_var.h, libnetworking/netinet/tcp_timer.h, libnetworking/netinet/udp_usrreq.c, libnetworking/netinet/udp_var.h, libnetworking/sys/callout.h, libnetworking/sys/socketvar.h, libnetworking/sys/sysctl.h: Cosmetics from FreeBSD.
  • Property mode set to 100644
File size: 7.8 KB
Line 
1/*
2 * Copyright (c) 1985, 1986, 1993
3 *      The Regents of the University of California.  All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 *    may be used to endorse or promote products derived from this software
15 *    without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 *      @(#)in_var.h    8.2 (Berkeley) 1/9/95
30 * $FreeBSD: src/sys/netinet/in_var.h,v 1.52 2004/10/19 21:06:14 andre Exp $
31 */
32
33#ifndef _NETINET_IN_VAR_H_
34#define _NETINET_IN_VAR_H_
35
36#include <sys/queue.h>
37#if !defined(__rtems__)
38#include <sys/fnv_hash.h>
39#endif
40
41/*
42 * Interface address, Internet version.  One of these structures
43 * is allocated for each Internet address on an interface.
44 * The ifaddr structure contains the protocol-independent part
45 * of the structure and is assumed to be first.
46 */
47struct 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_{,sub}net{,mask} in host order */
52        u_long  ia_net;                 /* network number of interface */
53        u_long  ia_netmask;             /* mask of net part */
54        u_long  ia_subnet;              /* subnet number, including net */
55        u_long  ia_subnetmask;          /* mask of subnet part */
56        struct  in_addr ia_netbroadcast; /* to recognize net broadcasts */
57        struct  in_ifaddr *ia_next;     /* next in list of internet addresses */
58        struct  sockaddr_in ia_addr;    /* reserve space for interface name */
59        struct  sockaddr_in ia_dstaddr; /* reserve space for broadcast addr */
60#define ia_broadaddr    ia_dstaddr
61        struct  sockaddr_in ia_sockmask; /* reserve space for general netmask */
62        LIST_HEAD(in_multihead, in_multi) ia_multiaddrs;
63                                        /* list of multicast addresses */
64};
65
66struct  in_aliasreq {
67        char    ifra_name[IFNAMSIZ];            /* if name, e.g. "en0" */
68        struct  sockaddr_in ifra_addr;
69        struct  sockaddr_in ifra_broadaddr;
70#define ifra_dstaddr ifra_broadaddr
71        struct  sockaddr_in ifra_mask;
72};
73/*
74 * Given a pointer to an in_ifaddr (ifaddr),
75 * return a pointer to the addr as a sockaddr_in.
76 */
77#define IA_SIN(ia)    (&(((struct in_ifaddr *)(ia))->ia_addr))
78#define IA_DSTSIN(ia) (&(((struct in_ifaddr *)(ia))->ia_dstaddr))
79
80#define IN_LNAOF(in, ifa) \
81        ((ntohl((in).s_addr) & ~((struct in_ifaddr *)(ifa)->ia_subnetmask))
82
83
84#ifdef  _KERNEL
85extern  struct  in_ifaddr *in_ifaddr;
86extern  struct  ifqueue ipintrq;                /* ip packet input queue */
87extern  struct  in_addr zeroin_addr;
88extern  u_char  inetctlerrmap[];
89extern  int rtq_reallyold;      /* XXX */
90extern  int rtq_minreallyold;   /* XXX */
91extern  int rtq_toomany;        /* XXX */
92
93/*
94 * Macro for finding the interface (ifnet structure) corresponding to one
95 * of our IP addresses.
96 */
97#define INADDR_TO_IFP(addr, ifp) \
98        /* struct in_addr addr; */ \
99        /* struct ifnet *ifp; */ \
100{ \
101        register struct in_ifaddr *ia; \
102\
103        for (ia = in_ifaddr; \
104            ia != NULL && ((ia->ia_ifp->if_flags & IFF_POINTOPOINT)? \
105                IA_DSTSIN(ia):IA_SIN(ia))->sin_addr.s_addr != (addr).s_addr; \
106            ia = ia->ia_next) \
107                 continue; \
108        if (ia == NULL) \
109            for (ia = in_ifaddr; \
110                ia != NULL; \
111                ia = ia->ia_next) \
112                    if (ia->ia_ifp->if_flags & IFF_POINTOPOINT && \
113                        IA_SIN(ia)->sin_addr.s_addr == (addr).s_addr) \
114                            break; \
115        (ifp) = (ia == NULL) ? NULL : ia->ia_ifp; \
116}
117
118/*
119 * Macro for finding the internet address structure (in_ifaddr) corresponding
120 * to a given interface (ifnet structure).
121 */
122#define IFP_TO_IA(ifp, ia) \
123        /* struct ifnet *ifp; */ \
124        /* struct in_ifaddr *ia; */ \
125{ \
126        for ((ia) = in_ifaddr; \
127            (ia) != NULL && (ia)->ia_ifp != (ifp); \
128            (ia) = (ia)->ia_next) \
129                continue; \
130}
131#endif
132
133/*
134 * This information should be part of the ifnet structure but we don't wish
135 * to change that - as it might break a number of things
136 */
137
138struct router_info {
139        struct ifnet *rti_ifp;
140        int    rti_type; /* type of router which is querier on this interface */
141        int    rti_time; /* # of slow timeouts since last old query */
142        struct router_info *rti_next;
143};
144
145/*
146 * Internet multicast address structure.  There is one of these for each IP
147 * multicast group to which this host belongs on a given network interface.
148 * They are kept in a linked list, rooted in the interface's in_ifaddr
149 * structure.
150 */
151struct in_multi {
152        LIST_ENTRY(in_multi) inm_entry; /* list glue */
153        struct  in_addr inm_addr;       /* IP multicast address */
154        struct  ifnet *inm_ifp;         /* back pointer to ifnet */
155        struct  in_ifaddr *inm_ia;      /* back pointer to in_ifaddr */
156        u_int   inm_refcount;           /* no. membership claims by sockets */
157        u_int   inm_timer;              /* IGMP membership report timer */
158        u_int   inm_state;              /*  state of the membership */
159        struct  router_info *inm_rti;   /* router info*/
160};
161
162#ifdef _KERNEL
163
164#ifdef SYSCTL_DECL
165SYSCTL_DECL(_net_inet_ip);
166SYSCTL_DECL(_net_inet_raw);
167#endif
168
169/*
170 * Structure used by macros below to remember position when stepping through
171 * all of the in_multi records.
172 */
173struct in_multistep {
174        struct in_ifaddr *i_ia;
175        struct in_multi *i_inm;
176};
177
178/*
179 * Macro for looking up the in_multi record for a given IP multicast address
180 * on a given interface.  If no matching record is found, "inm" returns NULL.
181 */
182#define IN_LOOKUP_MULTI(addr, ifp, inm) \
183        /* struct in_addr addr; */ \
184        /* struct ifnet *ifp; */ \
185        /* struct in_multi *inm; */ \
186{ \
187        register struct in_ifaddr *ia; \
188\
189        IFP_TO_IA((ifp), ia); \
190        if (ia == NULL) \
191                (inm) = NULL; \
192        else \
193                for ((inm) = ia->ia_multiaddrs.lh_first; \
194                    (inm) != NULL && (inm)->inm_addr.s_addr != (addr).s_addr; \
195                     (inm) = inm->inm_entry.le_next) \
196                         continue; \
197}
198
199/*
200 * Macro to step through all of the in_multi records, one at a time.
201 * The current position is remembered in "step", which the caller must
202 * provide.  IN_FIRST_MULTI(), below, must be called to initialize "step"
203 * and get the first record.  Both macros return a NULL "inm" when there
204 * are no remaining records.
205 */
206#define IN_NEXT_MULTI(step, inm) \
207        /* struct in_multistep  step; */ \
208        /* struct in_multi *inm; */ \
209{ \
210        if (((inm) = (step).i_inm) != NULL) \
211                (step).i_inm = (inm)->inm_entry.le_next; \
212        else \
213                while ((step).i_ia != NULL) { \
214                        (inm) = (step).i_ia->ia_multiaddrs.lh_first; \
215                        (step).i_ia = (step).i_ia->ia_next; \
216                        if ((inm) != NULL) { \
217                                (step).i_inm = (inm)->inm_entry.le_next; \
218                                break; \
219                        } \
220                } \
221}
222
223#define IN_FIRST_MULTI(step, inm) \
224        /* struct in_multistep step; */ \
225        /* struct in_multi *inm; */ \
226{ \
227        (step).i_ia = in_ifaddr; \
228        (step).i_inm = NULL; \
229        IN_NEXT_MULTI((step), (inm)); \
230}
231
232struct  in_multi *in_addmulti __P((struct in_addr *, struct ifnet *));
233void    in_delmulti __P((struct in_multi *));
234int     in_control __P((struct socket *, u_long, caddr_t, struct ifnet *));
235void    in_rtqdrain __P((void));
236void    ip_input __P((struct mbuf *));
237
238#endif /* _KERNEL */
239
240#endif /* _NETINET_IN_VAR_H_ */
Note: See TracBrowser for help on using the repository browser.