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  * Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.
8  *
9  * This file is part of CycloneTCP Open.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24  *
25  * @author Oryx Embedded SARL (www.oryx-embedded.com)
26  * @version 1.9.0
27  **/
28 
29 #ifndef _MDNS_CLIENT_H
30 #define _MDNS_CLIENT_H
31 
32 //Dependencies
33 #include "core/net.h"
34 #include "core/socket.h"
35 #include "core/udp.h"
36 #include "dns/dns_cache.h"
37 #include "dns/dns_common.h"
38 
39 //mDNS client support
40 #ifndef MDNS_CLIENT_SUPPORT
41  #define MDNS_CLIENT_SUPPORT DISABLED
42 #elif (MDNS_CLIENT_SUPPORT != ENABLED && MDNS_CLIENT_SUPPORT != DISABLED)
43  #error MDNS_CLIENT_SUPPORT parameter is not valid
44 #endif
45 
46 //Maximum number of retransmissions of mDNS queries
47 #ifndef MDNS_CLIENT_MAX_RETRIES
48  #define MDNS_CLIENT_MAX_RETRIES 3
49 #elif (MDNS_CLIENT_MAX_RETRIES < 1)
50  #error MDNS_CLIENT_MAX_RETRIES parameter is not valid
51 #endif
52 
53 //Initial retransmission timeout
54 #ifndef MDNS_CLIENT_INIT_TIMEOUT
55  #define MDNS_CLIENT_INIT_TIMEOUT 1000
56 #elif (MDNS_CLIENT_INIT_TIMEOUT < 1000)
57  #error MDNS_CLIENT_INIT_TIMEOUT parameter is not valid
58 #endif
59 
60 //Maximum retransmission timeout
61 #ifndef MDNS_CLIENT_MAX_TIMEOUT
62  #define MDNS_CLIENT_MAX_TIMEOUT 1000
63 #elif (MDNS_CLIENT_MAX_TIMEOUT < 1000)
64  #error MDNS_CLIENT_MAX_TIMEOUT parameter is not valid
65 #endif
66 
67 //Maximum cache lifetime for mDNS entries
68 #ifndef MDNS_MAX_LIFETIME
69  #define MDNS_MAX_LIFETIME 60000
70 #elif (MDNS_MAX_LIFETIME < 1000)
71  #error MDNS_MAX_LIFETIME parameter is not valid
72 #endif
73 
74 //C++ guard
75 #ifdef __cplusplus
76  extern "C" {
77 #endif
78 
79 //mDNS related functions
81  const char_t *name, HostType type, IpAddr *ipAddr);
82 
84 
86  const MdnsMessage *message, size_t offset, const DnsResourceRecord *record);
87 
88 //C++ guard
89 #ifdef __cplusplus
90  }
91 #endif
92 
93 #endif
error_t mdnsClientSendQuery(DnsCacheEntry *entry)
Send a mDNS query message.
Definition: mdns_client.c:195
char char_t
Definition: compiler_port.h:41
TCP/IP stack core.
uint8_t message[]
Definition: chap.h:150
mDNS message
Definition: mdns_common.h:75
DNS cache management.
IP network address.
Definition: ip.h:57
char_t type
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:256
uint8_t ipAddr[4]
Definition: mib_common.h:185
DNS cache entry.
Definition: dns_cache.h:94
HostType
Host types.
Definition: socket.h:168
char_t name[]
error_t mdnsClientResolve(NetInterface *interface, const char_t *name, HostType type, IpAddr *ipAddr)
Resolve a host name using mDNS.
Definition: mdns_client.c:54
error_t
Error codes.
Definition: error.h:40
#define NetInterface
Definition: net.h:34
__start_packed struct @152 DnsResourceRecord
Resource record format.
Socket API.
Common DNS routines.
UDP (User Datagram Protocol)