source: mainline/uspace/srv/net/inetsrv/icmpv6_std.h

Last change on this file was 8d2dd7f2, checked in by Jakub Jermar <jakub@…>, 8 years ago

Reduce the number of files that include <sys/types.h>

  • Property mode set to 100644
File size: 3.5 KB
RevLine 
[1d24ad3]1/*
2 * Copyright (c) 2013 Antonin Steinhauser
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 ICMPv6 standard definitions
34 *
35 */
36
37#ifndef ICMPV6_STD_H_
38#define ICMPV6_STD_H_
39
[8d2dd7f2]40#include <stdint.h>
[1d24ad3]41
42#define IP_PROTO_ICMPV6 58
43
44/** Type of service used for ICMP */
45#define ICMPV6_TOS 0
46
47#define INET6_HOP_LIMIT_MAX 255
48
[a17356fd]49#define NDP_FLAG_ROUTER 0x80
50#define NDP_FLAG_OVERRIDE 0x40
51#define NDP_FLAG_SOLICITED 0x20
52
[1d24ad3]53/** ICMPv6 message type */
54enum icmpv6_type {
55 ICMPV6_ECHO_REQUEST = 128,
56 ICMPV6_ECHO_REPLY = 129,
57 ICMPV6_ROUTER_SOLICITATION = 133,
58 ICMPV6_ROUTER_ADVERTISEMENT = 134,
59 ICMPV6_NEIGHBOUR_SOLICITATION = 135,
60 ICMPV6_NEIGHBOUR_ADVERTISEMENT = 136
61};
62
63/** NDP options */
64enum ndp_option {
65 SOURCE_LINK_LAYER = 1,
66 TARGET_LINK_LAYER = 2,
67 PREFIX_INFORMATION = 3
68};
69
70/** ICMPv6 message header */
71typedef struct {
72 /** ICMPv6 message type */
73 uint8_t type;
74 /** Code (0) */
75 uint8_t code;
76 /** Internet checksum of the ICMP message */
77 uint16_t checksum;
78 union {
79 struct {
80 /** Indentifier */
81 uint16_t ident;
82 /** Sequence number */
83 uint16_t seq_no;
84 } echo;
85 struct {
86 /** Flags byte */
87 uint8_t flags;
88 /** Reserved bytes */
[a17356fd]89 uint8_t reserved[3];
[1d24ad3]90 } ndp;
91 } un;
92} icmpv6_message_t;
93
94/** ICMPv6 pseudoheader for checksum computation */
95typedef struct {
96 /** Source IPv6 address */
[a17356fd]97 uint8_t src_addr[16];
[1d24ad3]98 /** Target IPv6 address */
[a17356fd]99 uint8_t dest_addr[16];
[1d24ad3]100 /** ICMPv6 length */
101 uint32_t length;
102 /** Zeroes */
[a17356fd]103 uint8_t zeroes[3];
[1d24ad3]104 /** Next header */
105 uint8_t next;
[12df1f1]106} icmpv6_phdr_t;
[1d24ad3]107
108/** NDP neighbour body */
109typedef struct {
110 /** Target IPv6 address */
[a17356fd]111 uint8_t target_address[16];
[1d24ad3]112 /** Option code */
113 uint8_t option;
114 /** Option length */
115 uint8_t length;
116 /** MAC address */
[a17356fd]117 uint8_t mac[6];
[1d24ad3]118} ndp_message_t;
119
120/** NDP prefix information structure */
121typedef struct {
122 /** Option code - must be 3 = PREFIX_INFORMATION */
123 uint8_t option;
124 /** Option length - may be 4 */
125 uint8_t length;
126 /** Prefix length */
127 uint8_t prefixlen;
128 /** Flags */
129 uint8_t flags;
130 /** Valid lifetime */
131 uint32_t valid_lftm;
132 /** Preferred lifetime */
133 uint32_t pref_lftm;
134 /** Reserved */
135 uint32_t reserved;
136 /** Prefix */
[a17356fd]137 uint8_t prefix[16];
[1d24ad3]138} ndp_prefix_t;
139
140#endif
141
142/** @}
143 */
Note: See TracBrowser for help on using the repository browser.