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-2019 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 1.9.6
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 //C++ guard
77 #ifdef __cplusplus
78 extern "C" {
79 #endif
80 
81 //mDNS related functions
84 
86 
88  const MdnsMessage *message, size_t offset, const DnsResourceRecord *record);
89 
90 //C++ guard
91 #ifdef __cplusplus
92 }
93 #endif
94 
95 #endif
HostType
Host types.
Definition: socket.h:171
IP network address.
Definition: ip.h:71
char_t name[]
error_t mdnsClientSendQuery(DnsCacheEntry *entry)
Send a mDNS query message.
Definition: mdns_client.c:197
__start_packed struct @148 DnsResourceRecord
Resource record format.
char_t type
error_t
Error codes.
Definition: error.h:42
#define NetInterface
Definition: net.h:36
DNS cache entry.
Definition: dns_cache.h:96
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:258
mDNS message
Definition: mdns_common.h:77
char char_t
Definition: compiler_port.h:43
DNS cache management.
UDP (User Datagram Protocol)
uint8_t message[]
Definition: chap.h:152
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:56
TCP/IP stack core.
Common DNS routines.
uint8_t ipAddr[4]
Definition: mib_common.h:187