source: mainline/uspace/srv/net/inetsrv/inet_std.h@ 1f97352

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 1f97352 was 313824a, checked in by Martin Decky <martin@…>, 12 years ago

all fragments of a packet need to have the same identifier (thx Antonin Steinhauser)

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*
2 * Copyright (c) 2012 Jiri Svoboda
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup inet
30 * @{
31 */
32/**
33 * @file IP header definitions
34 *
35 */
36
37#ifndef INET_STD_H_
38#define INET_STD_H_
39
40#include <sys/types.h>
41
42/** IPv4 Datagram header (fixed part) */
43typedef struct {
44 /** Version, Internet Header Length */
45 uint8_t ver_ihl;
46 /* Type of Service */
47 uint8_t tos;
48 /** Total Length */
49 uint16_t tot_len;
50 /** Identifier */
51 uint16_t id;
52 /** Flags, Fragment Offset */
53 uint16_t flags_foff;
54 /** Time to Live */
55 uint8_t ttl;
56 /** Protocol */
57 uint8_t proto;
58 /** Header Checksum */
59 uint16_t chksum;
60 /** Source Address */
61 uint32_t src_addr;
62 /** Destination Address */
63 uint32_t dest_addr;
64} ip_header_t;
65
66/** Bits in ip_header_t.ver_ihl */
67enum ver_ihl_bits {
68 /** Version, highest bit */
69 VI_VERSION_h = 7,
70 /** Version, lowest bit */
71 VI_VERSION_l = 4,
72 /** Internet Header Length, highest bit */
73 VI_IHL_h = 3,
74 /** Internet Header Length, lowest bit */
75 VI_IHL_l = 0
76};
77
78/** Bits in ip_header_t.flags_foff */
79enum flags_foff_bits {
80 /** Reserved, must be zero */
81 FF_FLAG_RSVD = 15,
82 /** Don't Fragment */
83 FF_FLAG_DF = 14,
84 /** More Fragments */
85 FF_FLAG_MF = 13,
86 /** Fragment Offset, highest bit */
87 FF_FRAGOFF_h = 12,
88 /** Fragment Offset, lowest bit */
89 FF_FRAGOFF_l = 0
90};
91
92/** Bits in ip6_frag_header_t.offsmf */
93enum flags_offsmt_bits {
94 /** More fragments */
95 OF_FLAG_M = 0,
96 /** Fragment offset, highest bit */
97 OF_FRAGOFF_h = 15,
98 /** Fragment offset, lowest bit */
99 OF_FRAGOFF_l = 3
100};
101
102/** IPv6 Datagram header (fixed part) */
103typedef struct {
104 /** Version, Traffic class first 4 bits */
105 uint8_t ver_tc;
106 /** Traffic class (the rest), Flow label */
107 uint8_t tc_fl[3];
108 /* Payload length */
109 uint16_t payload_len;
110 /** Next header */
111 uint8_t next;
112 /** Hop limit */
113 uint8_t hop_limit;
114 /** Source address */
115 uint8_t src_addr[16];
116 /** Destination address */
117 uint8_t dest_addr[16];
118} ip6_header_t;
119
120/** IPv6 Datagram Fragment extension header */
121typedef struct {
122 /** Next header */
123 uint8_t next;
124 /** Reserved */
125 uint8_t reserved;
126 /** Fragmentation offset, reserved and M flag */
127 uint16_t offsmf;
128 /** Identifier */
129 uint32_t id;
130} ip6_header_fragment_t;
131
132/** Fragment offset is expressed in units of 8 bytes */
133#define FRAG_OFFS_UNIT 8
134
135#endif
136
137/** @}
138 */
Note: See TracBrowser for help on using the repository browser.