mdns_client.h
Go to the documentation of this file.
1 /**
2  * @file mdns_client.h
3  * @brief mDNS client (Multicast DNS)
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.4
29  **/
30 
31 #ifndef _MDNS_CLIENT_H
32 #define _MDNS_CLIENT_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "core/socket.h"
37 #include "core/udp.h"
38 #include "dns/dns_cache.h"
39 #include "dns/dns_common.h"
40 
41 //mDNS client support
42 #ifndef MDNS_CLIENT_SUPPORT
43  #define MDNS_CLIENT_SUPPORT DISABLED
44 #elif (MDNS_CLIENT_SUPPORT != ENABLED && MDNS_CLIENT_SUPPORT != DISABLED)
45  #error MDNS_CLIENT_SUPPORT parameter is not valid
46 #endif
47 
48 //Maximum number of retransmissions of mDNS queries
49 #ifndef MDNS_CLIENT_MAX_RETRIES
50  #define MDNS_CLIENT_MAX_RETRIES 3
51 #elif (MDNS_CLIENT_MAX_RETRIES < 1)
52  #error MDNS_CLIENT_MAX_RETRIES parameter is not valid
53 #endif
54 
55 //Initial retransmission timeout
56 #ifndef MDNS_CLIENT_INIT_TIMEOUT
57  #define MDNS_CLIENT_INIT_TIMEOUT 1000
58 #elif (MDNS_CLIENT_INIT_TIMEOUT < 1000)
59  #error MDNS_CLIENT_INIT_TIMEOUT parameter is not valid
60 #endif
61 
62 //Maximum retransmission timeout
63 #ifndef MDNS_CLIENT_MAX_TIMEOUT
64  #define MDNS_CLIENT_MAX_TIMEOUT 1000
65 #elif (MDNS_CLIENT_MAX_TIMEOUT < 1000)
66  #error MDNS_CLIENT_MAX_TIMEOUT parameter is not valid
67 #endif
68 
69 //Maximum cache lifetime for mDNS entries
70 #ifndef MDNS_MAX_LIFETIME
71  #define MDNS_MAX_LIFETIME 60000
72 #elif (MDNS_MAX_LIFETIME < 1000)
73  #error MDNS_MAX_LIFETIME parameter is not valid
74 #endif
75 
76 //Additional record generation
77 #ifndef MDNS_ADDITIONAL_RECORDS_SUPPORT
78  #define MDNS_ADDITIONAL_RECORDS_SUPPORT ENABLED
79 #elif (MDNS_ADDITIONAL_RECORDS_SUPPORT != ENABLED && MDNS_ADDITIONAL_RECORDS_SUPPORT != DISABLED)
80  #error MDNS_ADDITIONAL_RECORDS_SUPPORT parameter is not valid
81 #endif
82 
83 //C++ guard
84 #ifdef __cplusplus
85 extern "C" {
86 #endif
87 
88 //mDNS related functions
91 
93 
95  const MdnsMessage *message, size_t offset, const DnsResourceRecord *record);
96 
97 //C++ guard
98 #ifdef __cplusplus
99 }
100 #endif
101 
102 #endif
HostType
Host types.
Definition: socket.h:215
IP network address.
Definition: ip.h:90
uint8_t message[]
Definition: chap.h:154
uint8_t type
Definition: coap_common.h:176
char_t name[]
error_t mdnsClientSendQuery(DnsCacheEntry *entry)
Send a mDNS query message.
Definition: mdns_client.c:196
error_t
Error codes.
Definition: error.h:43
#define NetInterface
Definition: net.h:36
DNS cache entry.
Definition: dns_cache.h:97
void mdnsClientParseAnRecord(NetInterface *interface, const MdnsMessage *message, size_t offset, const DnsResourceRecord *record)
Parse a resource record from the Answer Section.
Definition: mdns_client.c:257
mDNS message
Definition: mdns_common.h:78
char char_t
Definition: compiler_port.h:48
DNS cache management.
UDP (User Datagram Protocol)
Socket API.
error_t mdnsClientResolve(NetInterface *interface, const char_t *name, HostType type, IpAddr *ipAddr)
Resolve a host name using mDNS.
Definition: mdns_client.c:55
Ipv4Addr ipAddr
Definition: ipcp.h:105
TCP/IP stack core.
DnsResourceRecord
Definition: dns_common.h:224
Common DNS routines.