1 /*
2  * Copyright (C) 2002 USAGI/WIDE Project.
3  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. 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  * 3. Neither the name of the project nor the names of its contributors
15  *    may be used to endorse or promote products derived from this software
16  *    without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  */
30 
31 #ifndef ICMP6_NODEINFO_H
32 #define ICMP6_NODEINFO_H
33 
34 struct icmp6_nodeinfo {
35 	struct icmp6_hdr	icmp6_ni_hdr;
36 	uint8_t			icmp6_ni_nonce[8];
37 	/* could be followed by reply data */
38 };
39 
40 #define ni_type		icmp6_ni_hdr.icmp6_type
41 #define ni_code		icmp6_ni_hdr.icmp6_code
42 #define ni_cksum	icmp6_ni_hdr.icmp6_cksum
43 #define ni_qtype	icmp6_ni_hdr.icmp6_data16[0]
44 #define ni_flags	icmp6_ni_hdr.icmp6_data16[1]
45 #define ni_nonce	icmp6_ni_nonce
46 
47 /* ICMP6 types */
48 #define ICMP6_NI_QUERY			139
49 #define ICMP6_NI_REPLY			140
50 
51 /* ICMP6 codes for NI Query */
52 #define ICMP6_NI_SUBJ_IPV6		0	/* Query Subject is an ipv6 address */
53 #define ICMP6_NI_SUBJ_FQDN		1	/* Query Subject is a Domain name */
54 #define ICMP6_NI_SUBJ_IPV4		2	/* Query Subject is an ipv4 address */
55 
56 /* ICMP6 codes for NI Reply */
57 #define ICMP6_NI_SUCCESS		0	/* NI successful reply */
58 #define ICMP6_NI_REFUSED		1	/* NI request is refused */
59 #define ICMP6_NI_UNKNOWN		2	/* unknown Qtype */
60 
61 /* NI Codes */
62 #define NI_QTYPE_NOOP			0	/* NOOP  */
63 #define NI_QTYPE_SUPTYPES		1	/* Supported Qtypes */
64 #define NI_QTYPE_DNSNAME		2	/* DNS Name */
65 #define NI_QTYPE_NODEADDR		3	/* Node Addresses */
66 #define NI_QTYPE_IPV4ADDR		4	/* IPv4 Addresses */
67 
68 /* NI Flags */
69 #if WORDS_BIGENDIAN
70 #define NI_SUPTYPE_FLAG_COMPRESS	0x1
71 #define NI_FQDN_FLAG_VALIDTTL		0x1
72 #else
73 #define NI_SUPTYPE_FLAG_COMPRESS	0x0100
74 #define NI_FQDN_FLAG_VALIDTTL		0x0100
75 #endif
76 
77 #if WORDS_BIGENDIAN
78 #define NI_NODEADDR_FLAG_TRUNCATE	0x1
79 #define NI_NODEADDR_FLAG_ALL		0x2
80 #define NI_NODEADDR_FLAG_COMPAT		0x4
81 #define NI_NODEADDR_FLAG_LINKLOCAL	0x8
82 #define NI_NODEADDR_FLAG_SITELOCAL	0x10
83 #define NI_NODEADDR_FLAG_GLOBAL		0x20
84 #else
85 #define NI_NODEADDR_FLAG_TRUNCATE	0x0100
86 #define NI_NODEADDR_FLAG_ALL		0x0200
87 #define NI_NODEADDR_FLAG_COMPAT		0x0400
88 #define NI_NODEADDR_FLAG_LINKLOCAL	0x0800
89 #define NI_NODEADDR_FLAG_SITELOCAL	0x1000
90 #define NI_NODEADDR_FLAG_GLOBAL		0x2000
91 #endif
92 
93 #define NI_IPV4ADDR_FLAG_TRUNCATE	NI_NODEADDR_FLAG_TRUNCATE
94 #define NI_IPV4ADDR_FLAG_ALL		NI_NODEADDR_FLAG_ALL
95 
96 #endif
97 
98