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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [ecos-2.0/] [packages/] [net/] [tcpip/] [v2_0/] [include/] [netinet/] [ip_var.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1254 phoenix
//==========================================================================
2
//
3
//      include/netinet/ip_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: ip_var.h,v 1.12 1999/12/08 06:50:20 itojun Exp $      */
34
/*      $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $     */
35
 
36
/*
37
 * Copyright (c) 1982, 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
 *      @(#)ip_var.h    8.1 (Berkeley) 6/10/93
69
 */
70
 
71
#ifndef _NETINET_IP_VAR_H_
72
#define _NETINET_IP_VAR_H_
73
 
74
#include <sys/queue.h>
75
 
76
/*
77
 * Overlay for ip header used by other protocols (tcp, udp).
78
 */
79
struct ipovly {
80
        u_int8_t  ih_x1[9];             /* (unused) */
81
        u_int8_t  ih_pr;                /* protocol */
82
        u_int16_t ih_len;               /* protocol length */
83
        struct    in_addr ih_src;       /* source internet address */
84
        struct    in_addr ih_dst;       /* destination internet address */
85
};
86
 
87
/*
88
 * Ip (reassembly or sequence) queue structures.
89
 *
90
 * XXX -- The following explains why the ipqe_m field is here, for TCP's use:
91
 * We want to avoid doing m_pullup on incoming packets but that
92
 * means avoiding dtom on the tcp reassembly code.  That in turn means
93
 * keeping an mbuf pointer in the reassembly queue (since we might
94
 * have a cluster).  As a quick hack, the source & destination
95
 * port numbers (which are no longer needed once we've located the
96
 * tcpcb) are overlayed with an mbuf pointer.
97
 */
98
LIST_HEAD(ipqehead, ipqent);
99
struct ipqent {
100
        LIST_ENTRY(ipqent) ipqe_q;
101
        union {
102
                struct ip       *_ip;
103
                struct tcphdr   *_tcp;
104
        } _ipqe_u1;
105
        union {
106
                u_int8_t        _mff;   /* for IP fragmentation */
107
                struct mbuf     *_m;    /* XXX for TCP; see above */
108
        } _ipqe_u2;
109
};
110
#define ipqe_ip         _ipqe_u1._ip
111
#define ipqe_tcp        _ipqe_u1._tcp
112
#define ipqe_mff        _ipqe_u2._mff
113
#define ipqe_m          _ipqe_u2._m
114
 
115
/*
116
 * Ip reassembly queue structure.  Each fragment
117
 * being reassembled is attached to one of these structures.
118
 * They are timed out after ipq_ttl drops to 0, and may also
119
 * be reclaimed if memory becomes tight.
120
 */
121
struct ipq {
122
        LIST_ENTRY(ipq) ipq_q;          /* to other reass headers */
123
        u_int8_t  ipq_ttl;              /* time for reass q to live */
124
        u_int8_t  ipq_p;                /* protocol of this fragment */
125
        u_int16_t ipq_id;               /* sequence id for reassembly */
126
        struct    ipqehead ipq_fragq;   /* to ip fragment queue */
127
        struct    in_addr ipq_src, ipq_dst;
128
};
129
 
130
/*
131
 * Structure stored in mbuf in inpcb.ip_options
132
 * and passed to ip_output when ip options are in use.
133
 * The actual length of the options (including ipopt_dst)
134
 * is in m_len.
135
 */
136
#define MAX_IPOPTLEN    40
137
 
138
struct ipoption {
139
        struct  in_addr ipopt_dst;      /* first-hop dst if source routed */
140
        int8_t  ipopt_list[MAX_IPOPTLEN];       /* options proper */
141
};
142
 
143
/*
144
 * Structure attached to inpcb.ip_moptions and
145
 * passed to ip_output when IP multicast options are in use.
146
 */
147
struct ip_moptions {
148
        struct    ifnet *imo_multicast_ifp; /* ifp for outgoing multicasts */
149
        u_int8_t  imo_multicast_ttl;    /* TTL for outgoing multicasts */
150
        u_int8_t  imo_multicast_loop;   /* 1 => hear sends if a member */
151
        u_int16_t imo_num_memberships;  /* no. memberships this socket */
152
        struct    in_multi *imo_membership[IP_MAX_MEMBERSHIPS];
153
};
154
 
155
struct  ipstat {
156
        u_long  ips_total;              /* total packets received */
157
        u_long  ips_badsum;             /* checksum bad */
158
        u_long  ips_tooshort;           /* packet too short */
159
        u_long  ips_toosmall;           /* not enough data */
160
        u_long  ips_badhlen;            /* ip header length < data size */
161
        u_long  ips_badlen;             /* ip length < ip header length */
162
        u_long  ips_fragments;          /* fragments received */
163
        u_long  ips_fragdropped;        /* frags dropped (dups, out of space) */
164
        u_long  ips_fragtimeout;        /* fragments timed out */
165
        u_long  ips_forward;            /* packets forwarded */
166
        u_long  ips_cantforward;        /* packets rcvd for unreachable dest */
167
        u_long  ips_redirectsent;       /* packets forwarded on same net */
168
        u_long  ips_noproto;            /* unknown or unsupported protocol */
169
        u_long  ips_delivered;          /* datagrams delivered to upper level*/
170
        u_long  ips_localout;           /* total ip packets generated here */
171
        u_long  ips_odropped;           /* lost packets due to nobufs, etc. */
172
        u_long  ips_reassembled;        /* total packets reassembled ok */
173
        u_long  ips_fragmented;         /* datagrams sucessfully fragmented */
174
        u_long  ips_ofragments;         /* output fragments created */
175
        u_long  ips_cantfrag;           /* don't fragment flag was set, etc. */
176
        u_long  ips_badoptions;         /* error in option processing */
177
        u_long  ips_noroute;            /* packets discarded due to no route */
178
        u_long  ips_badvers;            /* ip version != 4 */
179
        u_long  ips_rawout;             /* total raw ip packets generated */
180
        u_long  ips_badfrags;           /* malformed fragments (bad length) */
181
        u_long  ips_rcvmemdrop;         /* frags dropped for lack of memory */
182
        u_long  ips_toolong;            /* ip length > max ip packet size */
183
        u_long  ips_nogif;              /* no match gif found */
184
};
185
 
186
#ifdef _KERNEL
187
/* flags passed to ip_output as last parameter */
188
#define IP_FORWARDING           0x1             /* most of ip header exists */
189
#define IP_RAWOUTPUT            0x2             /* raw ip header exists */
190
#define IP_ROUTETOIF            SO_DONTROUTE    /* bypass routing tables */
191
#define IP_ALLOWBROADCAST       SO_BROADCAST    /* can send broadcast packets */
192
 
193
#ifdef IPSEC
194
#define IP_ENCAPSULATED         0x0800          /* encapsulated already */
195
#endif
196
 
197
extern struct     ipstat ipstat;
198
#ifndef RANDOM_IP_ID
199
extern u_short  ip_id;                          /* ip packet ctr, for ids */
200
#endif
201
LIST_HEAD(ipqhead, ipq) ipq;            /* ip reass. queue */
202
extern int ip_defttl;                   /* default IP ttl */
203
extern int ipforwarding;                /* IPforwarding state */
204
 
205
int      ip_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
206
int      ip_dooptions __P((struct mbuf *));
207
void     ip_drain __P((void));
208
void     ip_flush __P((void));
209
void     ip_forward __P((struct mbuf *, int));
210
void     ip_freef __P((struct ipq *));
211
void     ip_freemoptions __P((struct ip_moptions *));
212
int      ip_getmoptions __P((int, struct ip_moptions *, struct mbuf **));
213
void     ip_init __P((void));
214
int      ip_mforward __P((struct mbuf *, struct ifnet *));
215
int      ip_optcopy __P((struct ip *, struct ip *));
216
int      ip_output __P((struct mbuf *, ...));
217
int      ip_pcbopts __P((struct mbuf **, struct mbuf *));
218
struct ip *
219
         ip_reass __P((struct ipqent *, struct ipq *));
220
struct in_ifaddr *
221
         in_iawithaddr __P((struct in_addr, struct mbuf *));
222
struct in_ifaddr *
223
         ip_rtaddr __P((struct in_addr));
224
u_int16_t
225
         ip_randomid __P((void));
226
int      ip_setmoptions __P((int, struct ip_moptions **, struct mbuf *));
227
void     ip_slowtimo __P((void));
228
struct mbuf *
229
         ip_srcroute __P((void));
230
void     ip_stripoptions __P((struct mbuf *, struct mbuf *));
231
int      ip_sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
232
void     ipintr __P((void));
233
void     ipv4_input __P((struct mbuf *, ...));
234
int      rip_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
235
void     rip_init __P((void));
236
void     rip_input __P((struct mbuf *, ...));
237
int      rip_output __P((struct mbuf *, ...));
238
int      rip_usrreq __P((struct socket *,
239
            int, struct mbuf *, struct mbuf *, struct mbuf *));
240
#endif
241
 
242
#endif // _NETINET_IP_VAR_H_

powered by: WebSVN 2.1.0

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