OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [net/] [bsd_tcpip/] [v2_0/] [include/] [netinet/] [in_var.h] - Blame information for rev 307

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//      include/netinet/in_var.h
4
//
5
//==========================================================================
6
//####BSDCOPYRIGHTBEGIN####
7
//
8
// -------------------------------------------
9
//
10
// Portions of this software may have been derived from OpenBSD, 
11
// FreeBSD or other sources, and are covered by the appropriate
12
// copyright disclaimers included herein.
13
//
14
// Portions created by Red Hat are
15
// Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
16
//
17
// -------------------------------------------
18
//
19
//####BSDCOPYRIGHTEND####
20
//==========================================================================
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
 * $FreeBSD: src/sys/netinet/in_var.h,v 1.33.2.2 2001/07/17 10:50:01 ru Exp $
56
 */
57
 
58
#ifndef _NETINET_IN_VAR_H_
59
#define _NETINET_IN_VAR_H_
60
 
61
#include <sys/queue.h>
62
 
63
/*
64
 * Interface address, Internet version.  One of these structures
65
 * is allocated for each Internet address on an interface.
66
 * The ifaddr structure contains the protocol-independent part
67
 * of the structure and is assumed to be first.
68
 */
69
struct in_ifaddr {
70
        struct  ifaddr ia_ifa;          /* protocol-independent info */
71
#define ia_ifp          ia_ifa.ifa_ifp
72
#define ia_flags        ia_ifa.ifa_flags
73
                                        /* ia_{,sub}net{,mask} in host order */
74
        u_long  ia_net;                 /* network number of interface */
75
        u_long  ia_netmask;             /* mask of net part */
76
        u_long  ia_subnet;              /* subnet number, including net */
77
        u_long  ia_subnetmask;          /* mask of subnet part */
78
        struct  in_addr ia_netbroadcast; /* to recognize net broadcasts */
79
        TAILQ_ENTRY(in_ifaddr) ia_link; /* tailq macro glue */
80
        struct  sockaddr_in ia_addr;    /* reserve space for interface name */
81
        struct  sockaddr_in ia_dstaddr; /* reserve space for broadcast addr */
82
#define ia_broadaddr    ia_dstaddr
83
        struct  sockaddr_in ia_sockmask; /* reserve space for general netmask */
84
};
85
 
86
struct  in_aliasreq {
87
        char    ifra_name[IFNAMSIZ];            /* if name, e.g. "en0" */
88
        struct  sockaddr_in ifra_addr;
89
        struct  sockaddr_in ifra_broadaddr;
90
#define ifra_dstaddr ifra_broadaddr
91
        struct  sockaddr_in ifra_mask;
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  int /*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
        struct in_ifaddr *ia; \
119
\
120
        TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) \
121
                if (IA_SIN(ia)->sin_addr.s_addr == (addr).s_addr) \
122
                        break; \
123
        (ifp) = (ia == NULL) ? NULL : ia->ia_ifp; \
124
}
125
 
126
/*
127
 * Macro for finding the internet address structure (in_ifaddr) corresponding
128
 * to a given interface (ifnet structure).
129
 */
130
#define IFP_TO_IA(ifp, ia) \
131
        /* struct ifnet *ifp; */ \
132
        /* struct in_ifaddr *ia; */ \
133
{ \
134
        for ((ia) = TAILQ_FIRST(&in_ifaddrhead); \
135
            (ia) != NULL && (ia)->ia_ifp != (ifp); \
136
            (ia) = TAILQ_NEXT((ia), ia_link)) \
137
                continue; \
138
}
139
#endif
140
 
141
/*
142
 * This information should be part of the ifnet structure but we don't wish
143
 * to change that - as it might break a number of things
144
 */
145
 
146
struct router_info {
147
        struct ifnet *rti_ifp;
148
        int    rti_type; /* type of router which is querier on this interface */
149
        int    rti_time; /* # of slow timeouts since last old query */
150
        struct router_info *rti_next;
151
};
152
 
153
/*
154
 * Internet multicast address structure.  There is one of these for each IP
155
 * multicast group to which this host belongs on a given network interface.
156
 * For every entry on the interface's if_multiaddrs list which represents
157
 * an IP multicast group, there is one of these structures.  They are also
158
 * kept on a system-wide list to make it easier to keep our legacy IGMP code
159
 * compatible with the rest of the world (see IN_FIRST_MULTI et al, below).
160
 */
161
struct in_multi {
162
        LIST_ENTRY(in_multi) inm_link;  /* queue macro glue */
163
        struct  in_addr inm_addr;       /* IP multicast address, convenience */
164
        struct  ifnet *inm_ifp;         /* back pointer to ifnet */
165
        struct  ifmultiaddr *inm_ifma;  /* back pointer to ifmultiaddr */
166
        u_int   inm_timer;              /* IGMP membership report timer */
167
        u_int   inm_state;              /*  state of the membership */
168
        struct  router_info *inm_rti;   /* router info*/
169
};
170
 
171
#ifdef _KERNEL
172
 
173
extern LIST_HEAD(in_multihead, in_multi) in_multihead;
174
 
175
/*
176
 * Structure used by macros below to remember position when stepping through
177
 * all of the in_multi records.
178
 */
179
struct in_multistep {
180
        struct in_multi *i_inm;
181
};
182
 
183
/*
184
 * Macro for looking up the in_multi record for a given IP multicast address
185
 * on a given interface.  If no matching record is found, "inm" is set null.
186
 */
187
#define IN_LOOKUP_MULTI(addr, ifp, inm) \
188
        /* struct in_addr addr; */ \
189
        /* struct ifnet *ifp; */ \
190
        /* struct in_multi *inm; */ \
191
do { \
192
        struct ifmultiaddr *ifma; \
193
\
194
        LIST_FOREACH(ifma, &((ifp)->if_multiaddrs), ifma_link) { \
195
                if (ifma->ifma_addr->sa_family == AF_INET \
196
                    && ((struct sockaddr_in *)ifma->ifma_addr)->sin_addr.s_addr == \
197
                    (addr).s_addr) \
198
                        break; \
199
        } \
200
        (inm) = ifma ? ifma->ifma_protospec : 0; \
201
} while(0)
202
 
203
/*
204
 * Macro to step through all of the in_multi records, one at a time.
205
 * The current position is remembered in "step", which the caller must
206
 * provide.  IN_FIRST_MULTI(), below, must be called to initialize "step"
207
 * and get the first record.  Both macros return a NULL "inm" when there
208
 * are no remaining records.
209
 */
210
#define IN_NEXT_MULTI(step, inm) \
211
        /* struct in_multistep  step; */ \
212
        /* struct in_multi *inm; */ \
213
do { \
214
        if (((inm) = (step).i_inm) != NULL) \
215
                (step).i_inm = LIST_NEXT((step).i_inm, inm_link); \
216
} while(0)
217
 
218
#define IN_FIRST_MULTI(step, inm) \
219
        /* struct in_multistep step; */ \
220
        /* struct in_multi *inm; */ \
221
do { \
222
        (step).i_inm = LIST_FIRST(&in_multihead); \
223
        IN_NEXT_MULTI((step), (inm)); \
224
} while(0)
225
 
226
struct  route;
227
struct  in_multi *in_addmulti __P((struct in_addr *, struct ifnet *));
228
void    in_delmulti __P((struct in_multi *));
229
int     in_control __P((struct socket *, u_long, caddr_t, struct ifnet *,
230
                        struct proc *));
231
void    in_rtqdrain __P((void));
232
void    ip_input __P((struct mbuf *));
233
int     in_ifadown __P((struct ifaddr *ifa, int));
234
void    in_ifscrub __P((struct ifnet *, struct in_ifaddr *));
235
int     ipflow_fastforward __P((struct mbuf *));
236
void    ipflow_create __P((const struct route *, struct mbuf *));
237
void    ipflow_slowtimo __P((void));
238
 
239
#endif /* _KERNEL */
240
 
241
/* INET6 stuff */
242
#include <netinet6/in6_var.h>
243
 
244
#endif /* _NETINET_IN_VAR_H_ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.