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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//      include/netinet/in_pcb.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_pcb.h,v 1.19 1999/12/12 12:10:43 itojun Exp $      */
34
/*      $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $     */
35
 
36
/*
37
 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
38
 * 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. Neither the name of the project nor the names of its contributors
49
 *    may be used to endorse or promote products derived from this software
50
 *    without specific prior written permission.
51
 *
52
 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
53
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
55
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
56
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
57
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
58
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
59
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
60
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
61
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
62
 * SUCH DAMAGE.
63
 */
64
 
65
/*
66
 * Copyright (c) 1982, 1986, 1990, 1993
67
 *      The Regents of the University of California.  All rights reserved.
68
 *
69
 * Redistribution and use in source and binary forms, with or without
70
 * modification, are permitted provided that the following conditions
71
 * are met:
72
 * 1. Redistributions of source code must retain the above copyright
73
 *    notice, this list of conditions and the following disclaimer.
74
 * 2. Redistributions in binary form must reproduce the above copyright
75
 *    notice, this list of conditions and the following disclaimer in the
76
 *    documentation and/or other materials provided with the distribution.
77
 * 3. All advertising materials mentioning features or use of this software
78
 *    must display the following acknowledgement:
79
 *      This product includes software developed by the University of
80
 *      California, Berkeley and its contributors.
81
 * 4. Neither the name of the University nor the names of its contributors
82
 *    may be used to endorse or promote products derived from this software
83
 *    without specific prior written permission.
84
 *
85
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
86
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
87
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
88
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
89
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
90
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
91
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
92
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
93
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
94
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
95
 * SUCH DAMAGE.
96
 *
97
 *      @(#)in_pcb.h    8.1 (Berkeley) 6/10/93
98
 */
99
 
100
#ifndef _NETINET_IN_PCB_H_
101
#define _NETINET_IN_PCB_H_
102
 
103
#include <sys/queue.h>
104
#if 0   /*KAME IPSEC*/
105
#include <netinet6/ipsec.h>
106
#endif
107
#include <netinet6/ip6.h>
108
#include <netinet6/ip6_var.h>
109
#include <netinet6/icmp6.h>
110
#include <netinet/ip_ipsp.h>
111
 
112
union inpaddru {
113
        struct in6_addr iau_addr6;
114
        struct {
115
                uint8_t pad[12];
116
                struct in_addr inaddr;  /* easier transition */
117
        } iau_a4u;
118
};
119
 
120
/*
121
 * Common structure pcb for internet protocol implementation.
122
 * Here are stored pointers to local and foreign host table
123
 * entries, local and foreign socket numbers, and pointers
124
 * up (to a socket structure) and down (to a protocol-specific)
125
 * control block.
126
 */
127
struct inpcb {
128
        LIST_ENTRY(inpcb) inp_hash;
129
        CIRCLEQ_ENTRY(inpcb) inp_queue;
130
        struct    inpcbtable *inp_table;
131
        union     inpaddru inp_faddru;          /* Foreign address. */
132
        union     inpaddru inp_laddru;          /* Local address. */
133
#define inp_faddr       inp_faddru.iau_a4u.inaddr
134
#define inp_faddr6      inp_faddru.iau_addr6
135
#define inp_laddr       inp_laddru.iau_a4u.inaddr
136
#define inp_laddr6      inp_laddru.iau_addr6
137
        u_int16_t inp_fport;            /* foreign port */
138
        u_int16_t inp_lport;            /* local port */
139
        struct    socket *inp_socket;   /* back pointer to socket */
140
        caddr_t   inp_ppcb;             /* pointer to per-protocol pcb */
141
        union {                         /* Route (notice increased size). */
142
                struct route ru_route;
143
                struct route_in6 ru_route6;
144
        } inp_ru;
145
#define inp_route       inp_ru.ru_route
146
#define inp_route6      inp_ru.ru_route6
147
        int       inp_flags;            /* generic IP/datagram flags */
148
        union {                         /* Header prototype. */
149
                struct ip hu_ip;
150
                struct ip6_hdr hu_ipv6;
151
        } inp_hu;
152
#define inp_ip          inp_hu.hu_ip
153
#define inp_ipv6        inp_hu.hu_ipv6
154
        struct    mbuf *inp_options;    /* IP options */
155
        struct ip6_pktopts *inp_outputopts6; /* IP6 options for outgoing packets */
156
        int inp_hops;
157
        union {
158
                struct ip_moptions *mou_mo;    /* IPv4 multicast options */
159
                struct ip6_moptions *mou_mo6; /* IPv6 multicast options */
160
        } inp_mou;
161
#define inp_moptions inp_mou.mou_mo
162
#define inp_moptions6 inp_mou.mou_mo6
163
        u_char    inp_seclevel[3];      /* Only the first 3 are used for now */
164
#define SL_AUTH           0             /* Authentication level */
165
#define SL_ESP_TRANS      1             /* ESP transport level */
166
#define SL_ESP_NETWORK    2             /* ESP network (encapsulation) level */
167
        u_int8_t  inp_secrequire:4,     /* Condensed State from above */
168
                  inp_secresult:4;      /* Result from Key Management */
169
#define SR_FAILED         1             /* Negotiation failed permanently */
170
#define SR_SUCCESS        2             /* SA successfully established */
171
#define SR_WAIT           3             /* Waiting for SA */
172
        TAILQ_ENTRY(inpcb) inp_tdb_next;
173
        struct tdb     *inp_tdb;        /* If tdb_dst matches our dst, use */
174
        int     inp_fflowinfo;          /* Foreign flowlabel & priority */
175
        int     inp_csumoffset;
176
        struct  icmp6_filter *inp_icmp6filt;
177
#if 0 /*KAME IPSEC*/
178
        struct secpolicy *inp_sp;       /* security policy. It may not be
179
                                         * used according to policy selection.
180
                                         */
181
#endif
182
};
183
 
184
struct inpcbtable {
185
        CIRCLEQ_HEAD(, inpcb) inpt_queue;
186
        LIST_HEAD(inpcbhead, inpcb) *inpt_hashtbl;
187
        u_long    inpt_hash;
188
        u_int16_t inpt_lastport;
189
};
190
 
191
/* flags in inp_flags: */
192
#define INP_RECVOPTS    0x001   /* receive incoming IP options */
193
#define INP_RECVRETOPTS 0x002   /* receive IP options for reply */
194
#define INP_RECVDSTADDR 0x004   /* receive IP dst address */
195
 
196
#define INP_RXDSTOPTS   INP_RECVOPTS
197
#define INP_RXHOPOPTS   INP_RECVRETOPTS
198
#define INP_RXINFO      INP_RECVDSTADDR
199
#define INP_RXSRCRT     0x010
200
#define INP_HOPLIMIT    0x020
201
 
202
#define INP_CONTROLOPTS (INP_RECVOPTS|INP_RECVRETOPTS|INP_RECVDSTADDR| \
203
            INP_RXSRCRT|INP_HOPLIMIT)
204
 
205
#define INP_HDRINCL     0x008   /* user supplies entire IP header */
206
#define INP_HIGHPORT    0x010   /* user wants "high" port binding */
207
#define INP_LOWPORT     0x020   /* user wants "low" port binding */
208
 
209
/*
210
 * These flags' values should be determined by either the transport
211
 * protocol at PRU_BIND, PRU_LISTEN, PRU_CONNECT, etc, or by in_pcb*().
212
 */
213
#define INP_IPV6        0x100   /* sotopf(inp->inp_socket) == PF_INET6 */
214
#define INP_IPV6_UNDEC  0x200   /* PCB is PF_INET6, but listens for V4/V6 */
215
#define INP_IPV6_MAPPED 0x400   /* PF_INET6 PCB which is connected to
216
                                 * an IPv4 host, or is bound to
217
                                 * an IPv4 address (specified with
218
                                 * the mapped form of v6 addresses) */
219
#define INP_IPV6_MCAST  0x800   /* Set if inp_moptions points to ipv6 ones */
220
 
221
#if 1   /*KAME*/
222
/* flags in in6p_flags */
223
#define IN6P_RECVOPTS   INP_RECVOPTS    /* receive incoming IP6 options */
224
#define IN6P_RECVRETOPTS INP_RECVRETOPTS /* receive IP6 options for reply */
225
#define IN6P_RECVDSTADDR INP_RECVDSTADDR /* receive IP6 dst address */
226
#define IN6P_HIGHPORT   INP_HIGHPORT    /* user wants "high" port binding */
227
#define IN6P_LOWPORT    INP_LOWPORT     /* user wants "low" port binding */
228
#define IN6P_ANONPORT   0x40            /* port chosen for user */
229
#define IN6P_FAITH      0x80            /* accept FAITH'ed connections */
230
#define IN6P_PKTINFO    0x010000
231
#define IN6P_HOPLIMIT   0x020000
232
#define IN6P_NEXTHOP    0x040000
233
#define IN6P_HOPOPTS    0x080000
234
#define IN6P_DSTOPTS    0x100000
235
#define IN6P_RTHDR      0x200000
236
#define IN6P_CONTROLOPTS        (0x3f0000 | IN6P_RECVOPTS | IN6P_RECVRETOPTS | IN6P_RECVDSTADDR)
237
#endif
238
 
239
#define INPLOOKUP_WILDCARD      1
240
#define INPLOOKUP_SETLOCAL      2
241
#define INPLOOKUP_IPV6          4
242
 
243
#define sotoinpcb(so)   ((struct inpcb *)(so)->so_pcb)
244
 
245
/* macros for handling bitmap of ports not to allocate dynamically */
246
#define DP_MAPBITS      (sizeof(u_int32_t) * NBBY)
247
#define DP_MAPSIZE      (howmany(IPPORT_RESERVED/2, DP_MAPBITS))
248
#define DP_SET(m, p)    ((m)[((p) - IPPORT_RESERVED/2) / DP_MAPBITS] |= (1 << ((p) % DP_MAPBITS)))
249
#define DP_CLR(m, p)    ((m)[((p) - IPPORT_RESERVED/2) / DP_MAPBITS] &= ~(1 << ((p) % DP_MAPBITS)))
250
#define DP_ISSET(m, p)  ((m)[((p) - IPPORT_RESERVED/2) / DP_MAPBITS] & (1 << ((p) % DP_MAPBITS)))
251
 
252
/* default values for baddynamicports [see ip_init()] */
253
#define DEFBADDYNAMICPORTS_TCP  { 749, 750, 751, 760, 761, 871, 0 }
254
#define DEFBADDYNAMICPORTS_UDP  { 750, 751, 0 }
255
 
256
struct baddynamicports {
257
        u_int32_t tcp[DP_MAPSIZE];
258
        u_int32_t udp[DP_MAPSIZE];
259
};
260
 
261
#ifdef _KERNEL
262
 
263
#define sotopf(so)  (so->so_proto->pr_domain->dom_family)
264
 
265
void     in_losing __P((struct inpcb *));
266
int      in_pcballoc __P((struct socket *, void *));
267
int      in_pcbbind __P((void *, struct mbuf *));
268
int      in_pcbconnect __P((void *, struct mbuf *));
269
void     in_pcbdetach __P((void *));
270
void     in_pcbdisconnect __P((void *));
271
struct inpcb *
272
         in_pcbhashlookup __P((struct inpcbtable *, struct in_addr,
273
                               u_int, struct in_addr, u_int));
274
#ifdef INET6
275
struct inpcb *
276
         in6_pcbhashlookup __P((struct inpcbtable *, struct in6_addr *,
277
                               u_int, struct in6_addr *, u_int));
278
int      in6_pcbbind __P((struct inpcb *, struct mbuf *));
279
int      in6_pcbconnect __P((struct inpcb *, struct mbuf *));
280
int      in6_setsockaddr __P((struct inpcb *, struct mbuf *));
281
int      in6_setpeeraddr __P((struct inpcb *, struct mbuf *));
282
#endif /* INET6 */
283
void     in_pcbinit __P((struct inpcbtable *, int));
284
struct inpcb *
285
         in_pcblookup __P((struct inpcbtable *, void *, u_int, void *,
286
            u_int, int));
287
void     in_pcbnotify __P((struct inpcbtable *, struct sockaddr *,
288
            u_int, struct in_addr, u_int, int, void (*)(struct inpcb *, int)));
289
void     in_pcbnotifyall __P((struct inpcbtable *, struct sockaddr *,
290
            int, void (*)(struct inpcb *, int)));
291
void     in_pcbrehash __P((struct inpcb *));
292
void     in_rtchange __P((struct inpcb *, int));
293
void     in_setpeeraddr __P((struct inpcb *, struct mbuf *));
294
void     in_setsockaddr __P((struct inpcb *, struct mbuf *));
295
int      in_baddynamic __P((u_int16_t, u_int16_t));
296
extern struct sockaddr_in *in_selectsrc __P((struct sockaddr_in *,
297
        struct route *, int, struct ip_moptions *, int *));
298
 
299
/* INET6 stuff */
300
int     in6_pcbnotify __P((struct inpcbtable *, struct sockaddr *,
301
                           u_int, struct in6_addr *, u_int, int,
302
                           void (*)(struct inpcb *, int)));
303
struct  in6_addr *in6_selectsrc __P((struct sockaddr_in6 *,
304
                                     struct ip6_pktopts *,
305
                                     struct ip6_moptions *,
306
                                     struct route_in6 *,
307
                                     struct in6_addr *, int *));
308
int     in6_selecthlim __P((struct inpcb *, struct ifnet *));
309
#endif
310
 
311
#endif // _NETINET_IN_PCB_H_

powered by: WebSVN 2.1.0

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