source: mainline/uspace/lib/net/include/icmp_header.h@ 849ed54

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

Networking work:
Split the networking stack into end-user library (libsocket) and two helper libraries (libnet and libnetif).
Don't use over-the-hand compiling and linking, but rather separation of conserns.
There might be still some issues and the non-modular networking architecture is currently broken, but this will be fixed soon.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 * Copyright (c) 2009 Lukas Mejdrech
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 icmp
30 * @{
31 */
32
33/** @file
34 * ICMP header definition.
35 * Based on the RFC~792.
36 */
37
38#ifndef __NET_ICMP_HEADER_H__
39#define __NET_ICMP_HEADER_H__
40
41#include <sys/types.h>
42
43#include <in.h>
44#include <icmp_codes.h>
45
46/** ICMP header size in bytes.
47 */
48#define ICMP_HEADER_SIZE sizeof(icmp_header_t)
49
50/** Type definition of the echo specific data.
51 * @see icmp_echo
52 */
53typedef struct icmp_echo icmp_echo_t;
54
55/** Type definition of the echo specific data pointer.
56 * @see icmp_echo
57 */
58typedef icmp_echo_t * icmp_echo_ref;
59
60/** Echo specific data.
61 */
62struct icmp_echo{
63 /** Message idintifier.
64 */
65 icmp_param_t identifier;
66 /** Message sequence number.
67 */
68 icmp_param_t sequence_number;
69} __attribute__ ((packed));
70
71/** Type definition of the internet control message header.
72 * @see icmp_header
73 */
74typedef struct icmp_header icmp_header_t;
75
76/** Type definition of the internet control message header pointer.
77 * @see icmp_header
78 */
79typedef icmp_header_t * icmp_header_ref;
80
81/** Internet control message header.
82 */
83struct icmp_header{
84 /** The type of the message.
85 */
86 uint8_t type;
87 /** The error code for the datagram reported by the ICMP message.
88 * The interpretation is dependent on the message type.
89 */
90 uint8_t code;
91 /** The checksum is the 16-bit ones's complement of the one's complement sum of the ICMP message starting with the ICMP Type.
92 * For computing the checksum, the checksum field should be zero.
93 * If the checksum does not match the contents, the datagram is discarded.
94 */
95 uint16_t checksum;
96 /** Message specific data.
97 */
98 union{
99 /** Echo specific data.
100 */
101 icmp_echo_t echo;
102 /** Proposed gateway value.
103 */
104 in_addr_t gateway;
105 /** Fragmentation needed specific data.
106 */
107 struct{
108 /** Reserved field.
109 * Must be zero.
110 */
111 icmp_param_t reserved;
112 /** Proposed MTU.
113 */
114 icmp_param_t mtu;
115 } frag;
116 /** Parameter problem specific data.
117 */
118 struct{
119 /** Problem pointer.
120 */
121 icmp_param_t pointer;
122 /** Reserved field.
123 * Must be zero.
124 */
125 icmp_param_t reserved;
126 } param;
127 } un;
128} __attribute__ ((packed));
129
130#endif
131
132/** @}
133 */
Note: See TracBrowser for help on using the repository browser.