llmnr_common.h
Go to the documentation of this file.
1 /**
2  * @file llmnr_common.h
3  * @brief Definitions common to LLMNR client and responder
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.0
29  **/
30 
31 #ifndef _LLMNR_COMMON_H
32 #define _LLMNR_COMMON_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "dns/dns_common.h"
37 
38 //Maximum size of LLMNR messages
39 #ifndef LLMNR_MESSAGE_MAX_SIZE
40  #define LLMNR_MESSAGE_MAX_SIZE 512
41 #elif (LLMNR_MESSAGE_MAX_SIZE < 1)
42  #error LLMNR_MESSAGE_MAX_SIZE parameter is not valid
43 #endif
44 
45 //Default resource record TTL (cache lifetime)
46 #ifndef LLMNR_DEFAULT_RESOURCE_RECORD_TTL
47  #define LLMNR_DEFAULT_RESOURCE_RECORD_TTL 30
48 #elif (LLMNR_DEFAULT_RESOURCE_RECORD_TTL < 1)
49  #error LLMNR_DEFAULT_RESOURCE_RECORD_TTL parameter is not valid
50 #endif
51 
52 //LLMNR port number
53 #define LLMNR_PORT 5355
54 //Default IP TTL value for LLMNR queries
55 #define LLMNR_DEFAULT_QUERY_IP_TTL 1
56 //Default IP TTL value for LLMNR responses
57 #define LLMNR_DEFAULT_RESPONSE_IP_TTL 255
58 
59 //LLMNR IPv4 multicast group
60 #define LLMNR_IPV4_MULTICAST_ADDR IPV4_ADDR(224, 0, 0, 252)
61 
62 //C++ guard
63 #ifdef __cplusplus
64 extern "C" {
65 #endif
66 
67 
68 //CC-RX, CodeWarrior or Win32 compiler?
69 #if defined(__CCRX__)
70  #pragma pack
71 #elif defined(__CWCC__) || defined(_WIN32)
72  #pragma pack(push, 1)
73 #endif
74 
75 
76 /**
77  * @brief LLMNR message header
78  **/
79 
81 {
82  uint16_t id; //0-1
83 #if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
84  uint8_t qr : 1; //2
85  uint8_t opcode : 4;
86  uint8_t c : 1;
87  uint8_t tc : 1;
88  uint8_t t : 1;
89  uint8_t z : 4; //3
90  uint8_t rcode : 4;
91 #else
92  uint8_t t : 1; //2
93  uint8_t tc : 1;
94  uint8_t c : 1;
95  uint8_t opcode : 4;
96  uint8_t qr : 1;
97  uint8_t rcode : 4; //3
98  uint8_t z : 4;
99 #endif
100  uint16_t qdcount; //4-5
101  uint16_t ancount; //6-7
102  uint16_t nscount; //8-9
103  uint16_t arcount; //10-11
104  uint8_t questions[]; //12
106 
107 
108 //CC-RX, CodeWarrior or Win32 compiler?
109 #if defined(__CCRX__)
110  #pragma unpack
111 #elif defined(__CWCC__) || defined(_WIN32)
112  #pragma pack(pop)
113 #endif
114 
115 //LLMNR IPv6 multicast group
117 
118 //C++ guard
119 #ifdef __cplusplus
120 }
121 #endif
122 
123 #endif
Common DNS routines.
Ipv6Addr
Definition: ipv6.h:251
uint16_t qdcount
Definition: llmnr_common.h:100
uint8_t questions[]
Definition: llmnr_common.h:104
uint16_t ancount
Definition: llmnr_common.h:101
uint8_t t
Definition: llmnr_common.h:92
uint8_t c
Definition: llmnr_common.h:94
uint8_t qr
Definition: llmnr_common.h:96
uint8_t opcode
Definition: llmnr_common.h:95
uint8_t tc
Definition: llmnr_common.h:93
uint16_t arcount
Definition: llmnr_common.h:103
LlmnrHeader
Definition: llmnr_common.h:105
const Ipv6Addr LLMNR_IPV6_MULTICAST_ADDR
Definition: llmnr_common.c:45
uint16_t nscount
Definition: llmnr_common.h:102
uint8_t z
Definition: llmnr_common.h:98
typedef __packed_struct
LLMNR message header.
Definition: llmnr_common.h:81
uint8_t rcode
Definition: llmnr_common.h:97
TCP/IP stack core.