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.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.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.h,v 1.6 1999/12/08 06:50:19 itojun Exp $   */
34
/*      $NetBSD: ip.h,v 1.9 1995/05/15 01:22:44 cgd 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.h        8.1 (Berkeley) 6/10/93
69
 */
70
 
71
#ifndef _NETINET_IP_H_
72
#define _NETINET_IP_H_
73
 
74
#include <netinet/in_systm.h>
75
 
76
/*
77
 * Definitions for internet protocol version 4.
78
 * Per RFC 791, September 1981.
79
 */
80
#define IPVERSION       4
81
 
82
/*
83
 * Structure of an internet header, naked of options.
84
 */
85
struct ip {
86
#if BYTE_ORDER == LITTLE_ENDIAN
87
        u_int8_t  ip_hl:4,              /* header length */
88
                  ip_v:4;               /* version */
89
#endif
90
#if BYTE_ORDER == BIG_ENDIAN
91
        u_int8_t  ip_v:4,               /* version */
92
                  ip_hl:4;              /* header length */
93
#endif
94
        u_int8_t  ip_tos;               /* type of service */
95
        u_int16_t ip_len;               /* total length */
96
        u_int16_t ip_id;                /* identification */
97
        u_int16_t ip_off;               /* fragment offset field */
98
#define IP_RF 0x8000                    /* reserved fragment flag */
99
#define IP_DF 0x4000                    /* dont fragment flag */
100
#define IP_MF 0x2000                    /* more fragments flag */
101
#define IP_OFFMASK 0x1fff               /* mask for fragmenting bits */
102
        u_int8_t  ip_ttl;               /* time to live */
103
        u_int8_t  ip_p;                 /* protocol */
104
        u_int16_t ip_sum;               /* checksum */
105
        struct    in_addr ip_src, ip_dst; /* source and dest address */
106
} __attribute__ ((aligned(1), packed));
107
 
108
#define IP_MAXPACKET    65535           /* maximum packet size */
109
 
110
/*
111
 * Definitions for IP type of service (ip_tos)
112
 */
113
#define IPTOS_LOWDELAY          0x10
114
#define IPTOS_THROUGHPUT        0x08
115
#define IPTOS_RELIABILITY       0x04
116
/*      IPTOS_LOWCOST           0x02 XXX */
117
#if 1
118
/* ECN bits proposed by Sally Floyd */
119
#define IPTOS_CE                0x01    /* congestion experienced */
120
#define IPTOS_ECT               0x02    /* ECN-capable transport */
121
#endif
122
 
123
/*
124
 * Definitions for IP precedence (also in ip_tos) (hopefully unused)
125
 */
126
#define IPTOS_PREC_NETCONTROL           0xe0
127
#define IPTOS_PREC_INTERNETCONTROL      0xc0
128
#define IPTOS_PREC_CRITIC_ECP           0xa0
129
#define IPTOS_PREC_FLASHOVERRIDE        0x80
130
#define IPTOS_PREC_FLASH                0x60
131
#define IPTOS_PREC_IMMEDIATE            0x40
132
#define IPTOS_PREC_PRIORITY             0x20
133
#define IPTOS_PREC_ROUTINE              0x00
134
 
135
/*
136
 * Definitions for options.
137
 */
138
#define IPOPT_COPIED(o)         ((o)&0x80)
139
#define IPOPT_CLASS(o)          ((o)&0x60)
140
#define IPOPT_NUMBER(o)         ((o)&0x1f)
141
 
142
#define IPOPT_CONTROL           0x00
143
#define IPOPT_RESERVED1         0x20
144
#define IPOPT_DEBMEAS           0x40
145
#define IPOPT_RESERVED2         0x60
146
 
147
#define IPOPT_EOL               0                /* end of option list */
148
#define IPOPT_NOP               1               /* no operation */
149
 
150
#define IPOPT_RR                7               /* record packet route */
151
#define IPOPT_TS                68              /* timestamp */
152
#define IPOPT_SECURITY          130             /* provide s,c,h,tcc */
153
#define IPOPT_LSRR              131             /* loose source route */
154
#define IPOPT_SATID             136             /* satnet id */
155
#define IPOPT_SSRR              137             /* strict source route */
156
 
157
/*
158
 * Offsets to fields in options other than EOL and NOP.
159
 */
160
#define IPOPT_OPTVAL            0                /* option ID */
161
#define IPOPT_OLEN              1               /* option length */
162
#define IPOPT_OFFSET            2               /* offset within option */
163
#define IPOPT_MINOFF            4               /* min value of above */
164
 
165
/*
166
 * Time stamp option structure.
167
 */
168
struct  ip_timestamp {
169
        u_int8_t ipt_code;              /* IPOPT_TS */
170
        u_int8_t ipt_len;               /* size of structure (variable) */
171
        u_int8_t ipt_ptr;               /* index of current entry */
172
#if BYTE_ORDER == LITTLE_ENDIAN
173
        u_int8_t ipt_flg:4,             /* flags, see below */
174
                 ipt_oflw:4;            /* overflow counter */
175
#endif
176
#if BYTE_ORDER == BIG_ENDIAN
177
        u_int8_t ipt_oflw:4,            /* overflow counter */
178
                 ipt_flg:4;             /* flags, see below */
179
#endif
180
        union ipt_timestamp {
181
                 n_time ipt_time[1];
182
                 struct ipt_ta {
183
                        struct in_addr ipt_addr;
184
                        n_time ipt_time;
185
                 } ipt_ta[1];
186
        } ipt_timestamp;
187
} __attribute__ ((aligned(1), packed));
188
 
189
/* flag bits for ipt_flg */
190
#define IPOPT_TS_TSONLY         0                /* timestamps only */
191
#define IPOPT_TS_TSANDADDR      1               /* timestamps and addresses */
192
#define IPOPT_TS_PRESPEC        3               /* specified modules only */
193
 
194
/* bits for security (not byte swapped) */
195
#define IPOPT_SECUR_UNCLASS     0x0000
196
#define IPOPT_SECUR_CONFID      0xf135
197
#define IPOPT_SECUR_EFTO        0x789a
198
#define IPOPT_SECUR_MMMM        0xbc4d
199
#define IPOPT_SECUR_RESTR       0xaf13
200
#define IPOPT_SECUR_SECRET      0xd788
201
#define IPOPT_SECUR_TOPSECRET   0x6bc5
202
 
203
/*
204
 * Internet implementation parameters.
205
 */
206
#define MAXTTL          255             /* maximum time to live (seconds) */
207
#define IPDEFTTL        64              /* default ttl, from RFC 1340 */
208
#define IPFRAGTTL       60              /* time to live for frags, slowhz */
209
#define IPTTLDEC        1               /* subtracted when forwarding */
210
 
211
#define IP_MSS          576             /* default maximum segment size */
212
 
213
/*
214
 * This is the real IPv4 psuedo header, used for computing the TCP and UDP
215
 * checksums. For the Internet checksum, struct ipovly can be used instead.
216
 * For stronger checksums, the real thing must be used.
217
 */
218
struct ippseudo {
219
        struct    in_addr ippseudo_src; /* source internet address */
220
        struct    in_addr ippseudo_dst; /* destination internet address */
221
        u_int8_t  ippseudo_pad;         /* pad, must be zero */
222
        u_int8_t  ippseudo_p;           /* protocol */
223
        u_int16_t ippseudo_len;         /* protocol length */
224
} __attribute__ ((aligned(1), packed));
225
 
226
#endif // _NETINET_IP_H_

powered by: WebSVN 2.1.0

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