mikroSDK Reference Manual
mdns_common.h
Go to the documentation of this file.
1
31#ifndef _MDNS_COMMON_H
32#define _MDNS_COMMON_H
33
34//Dependencies
35#include "core/net.h"
36#include "dns/dns_common.h"
37
38//Maximum size of mDNS messages
39#ifndef MDNS_MESSAGE_MAX_SIZE
40 #define MDNS_MESSAGE_MAX_SIZE 1024
41#elif (MDNS_MESSAGE_MAX_SIZE < 1)
42 #error MDNS_MESSAGE_MAX_SIZE parameter is not valid
43#endif
44
45//Default resource record TTL (cache lifetime)
46#ifndef MDNS_DEFAULT_RR_TTL
47 #define MDNS_DEFAULT_RR_TTL 120
48#elif (MDNS_DEFAULT_RR_TTL < 1)
49 #error MDNS_DEFAULT_RR_TTL parameter is not valid
50#endif
51
52//mDNS port number
53#define MDNS_PORT 5353
54//Default IP TTL value
55#define MDNS_DEFAULT_IP_TTL 255
56//Maximum RR TTL in legacy unicast responses
57#define MDNS_LEGACY_UNICAST_RR_TTL 10
58
59//QU flag
60#define MDNS_QCLASS_QU 0x8000
61//Cache Flush flag
62#define MDNS_RCLASS_CACHE_FLUSH 0x8000
63
64//mDNS IPv4 multicast group
65#define MDNS_IPV4_MULTICAST_ADDR IPV4_ADDR(224, 0, 0, 251)
66
67//C++ guard
68#ifdef __cplusplus
69extern "C" {
70#endif
71
72
77typedef struct
78{
79 NetBuffer *buffer;
80 size_t offset;
81 size_t length;
82 const IpPseudoHeader *pseudoHeader;
83 const UdpHeader *udpHeader;
84 DnsHeader *dnsHeader;
85 systime_t timestamp;
86 systime_t timeout;
87 uint_t sharedRecordCount;
89
90
91//mDNS IPv6 multicast group
92extern const Ipv6Addr MDNS_IPV6_MULTICAST_ADDR;
93
94//mDNS related functions
95error_t mdnsInit(NetInterface *interface);
96
97void mdnsProcessMessage(NetInterface *interface,
98 const IpPseudoHeader *pseudoHeader, const UdpHeader *udpHeader,
99 const NetBuffer *buffer, size_t offset, const NetRxAncillary *ancillary,
100 void *param);
101
102void mdnsProcessResponse(NetInterface *interface, MdnsMessage *response);
103
104bool_t mdnsCheckSourceAddr(NetInterface *interface,
105 const IpPseudoHeader *pseudoHeader);
106
107error_t mdnsCreateMessage(MdnsMessage *message, bool_t queryResponse);
108void mdnsDeleteMessage(MdnsMessage *message);
109
110error_t mdnsSendMessage(NetInterface *interface, const MdnsMessage *message,
111 const IpAddr *destIpAddr, uint_t destPort);
112
113size_t mdnsEncodeName(const char_t *instance, const char_t *service,
114 const char_t *domain, uint8_t *dest);
115
116int_t mdnsCompareName(const DnsHeader *message, size_t length, size_t pos,
117 const char_t *instance, const char_t *service, const char_t *domain, uint_t level);
118
119int_t mdnsCompareRecord(const MdnsMessage *message1,
120 const DnsResourceRecord *record1, const MdnsMessage *message2,
121 const DnsResourceRecord *record2);
122
123bool_t mdnsCheckDuplicateRecord(const MdnsMessage *message,
124 const char_t *instance, const char_t *service, const char_t *domain,
125 uint16_t rtype, const uint8_t *rdata, size_t rdlength);
126
127//C++ guard
128#ifdef __cplusplus
129}
130#endif
131
132#endif
Common DNS routines.
error_t
Error codes.
Definition error.h:43
TCP/IP stack core.
uint32_t systime_t
System time.
Definition os_port_none.h:90
IP network address.
Definition ip.h:72
IP pseudo header.
Definition ip.h:91
mDNS message
Definition mdns_common.h:78
Structure describing a buffer that spans multiple chunks.
Definition net_mem.h:89