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

Subversion Repositories openrisc_me

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//      include/netinet/in_var.h
4
//
5
//      
6
//
7
//==========================================================================
8
//####BSDCOPYRIGHTBEGIN####
9
//
10
// -------------------------------------------
11
//
12
// Portions of this software may have been derived from OpenBSD or other sources,
13
// and are covered by the appropriate copyright disclaimers included herein.
14
//
15
// -------------------------------------------
16
//
17
//####BSDCOPYRIGHTEND####
18
//==========================================================================
19
//#####DESCRIPTIONBEGIN####
20
//
21
// Author(s):    gthomas
22
// Contributors: gthomas
23
// Date:         2000-01-10
24
// Purpose:      
25
// Description:  
26
//              
27
//
28
//####DESCRIPTIONEND####
29
//
30
//==========================================================================
31
 
32
 
33
/*      $OpenBSD: in_var.h,v 1.3 1999/12/08 06:50:19 itojun Exp $       */
34
/*      $NetBSD: in_var.h,v 1.16 1996/02/13 23:42:15 christos Exp $     */
35
 
36
/*
37
 * Copyright (c) 1985, 1986, 1993
38
 *      The Regents of the University of California.  All rights reserved.
39
 *
40
 * Redistribution and use in source and binary forms, with or without
41
 * modification, are permitted provided that the following conditions
42
 * are met:
43
 * 1. Redistributions of source code must retain the above copyright
44
 *    notice, this list of conditions and the following disclaimer.
45
 * 2. Redistributions in binary form must reproduce the above copyright
46
 *    notice, this list of conditions and the following disclaimer in the
47
 *    documentation and/or other materials provided with the distribution.
48
 * 3. All advertising materials mentioning features or use of this software
49
 *    must display the following acknowledgement:
50
 *      This product includes software developed by the University of
51
 *      California, Berkeley and its contributors.
52
 * 4. Neither the name of the University nor the names of its contributors
53
 *    may be used to endorse or promote products derived from this software
54
 *    without specific prior written permission.
55
 *
56
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
57
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
59
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
60
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
61
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
62
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
64
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
65
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
66
 * SUCH DAMAGE.
67
 *
68
 *      @(#)in_var.h    8.1 (Berkeley) 6/10/93
69
 */
70
 
71
#ifndef _NETINET_IN_VAR_H_
72
#define _NETINET_IN_VAR_H_
73
 
74
#include <sys/queue.h>
75
 
76
/*
77
 * Interface address, Internet version.  One of these structures
78
 * is allocated for each interface with an Internet address.
79
 * The ifaddr structure contains the protocol-independent part
80
 * of the structure and is assumed to be first.
81
 */
82
struct in_ifaddr {
83
        struct  ifaddr ia_ifa;          /* protocol-independent info */
84
#define ia_ifp          ia_ifa.ifa_ifp
85
#define ia_flags        ia_ifa.ifa_flags
86
                                        /* ia_{,sub}net{,mask} in host order */
87
        u_int32_t ia_net;               /* network number of interface */
88
        u_int32_t ia_netmask;           /* mask of net part */
89
        u_int32_t ia_subnet;            /* subnet number, including net */
90
        u_int32_t ia_subnetmask;        /* mask of subnet part */
91
        struct  in_addr ia_netbroadcast; /* to recognize net broadcasts */
92
        TAILQ_ENTRY(in_ifaddr) ia_list; /* list of internet addresses */
93
        struct  sockaddr_in ia_addr;    /* reserve space for interface name */
94
        struct  sockaddr_in ia_dstaddr; /* reserve space for broadcast addr */
95
#define ia_broadaddr    ia_dstaddr
96
        struct  sockaddr_in ia_sockmask; /* reserve space for general netmask */
97
        LIST_HEAD(, in_multi) ia_multiaddrs; /* list of multicast addresses */
98
};
99
 
100
struct  in_aliasreq {
101
        char    ifra_name[IFNAMSIZ];            /* if name, e.g. "en0" */
102
        struct  sockaddr_in ifra_addr;
103
        struct  sockaddr_in ifra_dstaddr;
104
#define ifra_broadaddr  ifra_dstaddr
105
        struct  sockaddr_in ifra_mask;
106
};
107
/*
108
 * Given a pointer to an in_ifaddr (ifaddr),
109
 * return a pointer to the addr as a sockaddr_in.
110
 */
111
#define IA_SIN(ia) (&(((struct in_ifaddr *)(ia))->ia_addr))
112
 
113
 
114
#ifdef  _KERNEL
115
TAILQ_HEAD(in_ifaddrhead, in_ifaddr);
116
extern  struct  in_ifaddrhead in_ifaddr;
117
extern  struct  ifqueue ipintrq;                /* ip packet input queue */
118
extern  int     inetctlerrmap[];
119
void    in_socktrim __P((struct sockaddr_in *));
120
 
121
 
122
/*
123
 * Macro for finding the interface (ifnet structure) corresponding to one
124
 * of our IP addresses.
125
 */
126
#define INADDR_TO_IFP(addr, ifp) \
127
        /* struct in_addr addr; */ \
128
        /* struct ifnet *ifp; */ \
129
{ \
130
        register struct in_ifaddr *ia; \
131
\
132
        for (ia = in_ifaddr.tqh_first; \
133
            ia != NULL && ia->ia_addr.sin_addr.s_addr != (addr).s_addr; \
134
            ia = ia->ia_list.tqe_next) \
135
                 continue; \
136
        (ifp) = (ia == NULL) ? NULL : ia->ia_ifp; \
137
}
138
 
139
/*
140
 * Macro for finding the internet address structure (in_ifaddr) corresponding
141
 * to a given interface (ifnet structure).
142
 */
143
#define IFP_TO_IA(ifp, ia) \
144
        /* struct ifnet *ifp; */ \
145
        /* struct in_ifaddr *ia; */ \
146
{ \
147
        for ((ia) = in_ifaddr.tqh_first; \
148
            (ia) != NULL && (ia)->ia_ifp != (ifp); \
149
            (ia) = (ia)->ia_list.tqe_next) \
150
                continue; \
151
}
152
#endif
153
 
154
/*
155
 * Per-interface router version information.
156
 */
157
struct router_info {
158
        struct  ifnet *rti_ifp;
159
        int     rti_type;       /* type of router on this interface */
160
        int     rti_age;        /* time since last v1 query */
161
        struct  router_info *rti_next;
162
};
163
 
164
/*
165
 * Internet multicast address structure.  There is one of these for each IP
166
 * multicast group to which this host belongs on a given network interface.
167
 * They are kept in a linked list, rooted in the interface's in_ifaddr
168
 * structure.
169
 */
170
struct in_multi {
171
        struct  in_addr inm_addr;       /* IP multicast address */
172
        struct  ifnet *inm_ifp;         /* back pointer to ifnet */
173
        struct  in_ifaddr *inm_ia;      /* back pointer to in_ifaddr */
174
        u_int   inm_refcount;           /* no. membership claims by sockets */
175
        u_int   inm_timer;              /* IGMP membership report timer */
176
        LIST_ENTRY(in_multi) inm_list;  /* list of multicast addresses */
177
        u_int   inm_state;              /* state of membership */
178
        struct  router_info *inm_rti;   /* router version info */
179
};
180
 
181
#ifdef _KERNEL
182
/*
183
 * Structure used by macros below to remember position when stepping through
184
 * all of the in_multi records.
185
 */
186
struct in_multistep {
187
        struct in_ifaddr *i_ia;
188
        struct in_multi *i_inm;
189
};
190
 
191
/*
192
 * Macro for looking up the in_multi record for a given IP multicast address
193
 * on a given interface.  If no matching record is found, "inm" returns NULL.
194
 */
195
#define IN_LOOKUP_MULTI(addr, ifp, inm) \
196
        /* struct in_addr addr; */ \
197
        /* struct ifnet *ifp; */ \
198
        /* struct in_multi *inm; */ \
199
{ \
200
        register struct in_ifaddr *ia; \
201
\
202
        IFP_TO_IA((ifp), ia); \
203
        if (ia == NULL) \
204
                (inm) = NULL; \
205
        else \
206
                for ((inm) = ia->ia_multiaddrs.lh_first; \
207
                    (inm) != NULL && (inm)->inm_addr.s_addr != (addr).s_addr; \
208
                     (inm) = inm->inm_list.le_next) \
209
                         continue; \
210
}
211
 
212
/*
213
 * Macro to step through all of the in_multi records, one at a time.
214
 * The current position is remembered in "step", which the caller must
215
 * provide.  IN_FIRST_MULTI(), below, must be called to initialize "step"
216
 * and get the first record.  Both macros return a NULL "inm" when there
217
 * are no remaining records.
218
 */
219
#define IN_NEXT_MULTI(step, inm) \
220
        /* struct in_multistep  step; */ \
221
        /* struct in_multi *inm; */ \
222
{ \
223
        if (((inm) = (step).i_inm) != NULL) \
224
                (step).i_inm = (inm)->inm_list.le_next; \
225
        else \
226
                while ((step).i_ia != NULL) { \
227
                        (inm) = (step).i_ia->ia_multiaddrs.lh_first; \
228
                        (step).i_ia = (step).i_ia->ia_list.tqe_next; \
229
                        if ((inm) != NULL) { \
230
                                (step).i_inm = (inm)->inm_list.le_next; \
231
                                break; \
232
                        } \
233
                } \
234
}
235
 
236
#define IN_FIRST_MULTI(step, inm) \
237
        /* struct in_multistep step; */ \
238
        /* struct in_multi *inm; */ \
239
{ \
240
        (step).i_ia = in_ifaddr.tqh_first; \
241
        (step).i_inm = NULL; \
242
        IN_NEXT_MULTI((step), (inm)); \
243
}
244
 
245
int     in_ifinit __P((struct ifnet *,
246
            struct in_ifaddr *, struct sockaddr_in *, int));
247
struct  in_multi *in_addmulti __P((struct in_addr *, struct ifnet *));
248
void    in_delmulti __P((struct in_multi *));
249
void    in_ifscrub __P((struct ifnet *, struct in_ifaddr *));
250
int     in_control __P((struct socket *, u_long, caddr_t, struct ifnet *));
251
#endif
252
 
253
 
254
/* INET6 stuff */
255
#include <netinet6/in6_var.h>
256
 
257
#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.