Webserver+3d print

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mdns_common.h Source File

mdns_common.h

Go to the documentation of this file.
00001 /**
00002  * @file mdns_common.h
00003  * @brief Functions common to mDNS client and mDNS responder
00004  *
00005  * @section License
00006  *
00007  * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.
00008  *
00009  * This file is part of CycloneTCP Open.
00010  *
00011  * This program is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU General Public License
00013  * as published by the Free Software Foundation; either version 2
00014  * of the License, or (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software Foundation,
00023  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00024  *
00025  * @author Oryx Embedded SARL (www.oryx-embedded.com)
00026  * @version 1.7.6
00027  **/
00028 
00029 #ifndef _MDNS_COMMON_H
00030 #define _MDNS_COMMON_H
00031 
00032 //Dependencies
00033 #include "core/net.h"
00034 #include "dns/dns_common.h"
00035 
00036 //Maximum size of DNS messages
00037 #ifndef MDNS_MESSAGE_MAX_SIZE
00038    #define MDNS_MESSAGE_MAX_SIZE 1024
00039 #elif (MDNS_MESSAGE_MAX_SIZE < 1)
00040    #error MDNS_MESSAGE_MAX_SIZE parameter is not valid
00041 #endif
00042 
00043 //Default resource record TTL (cache lifetime)
00044 #ifndef MDNS_DEFAULT_RR_TTL
00045    #define MDNS_DEFAULT_RR_TTL 120
00046 #elif (MDNS_DEFAULT_RR_TTL < 1)
00047    #error MDNS_DEFAULT_RR_TTL parameter is not valid
00048 #endif
00049 
00050 //mDNS port number
00051 #define MDNS_PORT 5353
00052 //Default IP TTL value
00053 #define MDNS_DEFAULT_IP_TTL 255
00054 //Maximum RR TTL in legacy unicast responses
00055 #define MDNS_LEGACY_UNICAST_RR_TTL 10
00056 
00057 //QU flag
00058 #define MDNS_QCLASS_QU 0x8000
00059 //Cache Flush flag
00060 #define MDNS_RCLASS_CACHE_FLUSH 0x8000
00061 
00062 //mDNS IPv4 multicast group
00063 #define MDNS_IPV4_MULTICAST_ADDR IPV4_ADDR(224, 0, 0, 251)
00064 
00065 
00066 /**
00067  * @brief mDNS message
00068  **/
00069 
00070 typedef struct
00071 {
00072    NetBuffer *buffer;
00073    size_t offset;
00074    size_t length;
00075    const IpPseudoHeader *pseudoHeader;
00076    const UdpHeader *udpHeader;
00077    DnsHeader *dnsHeader;
00078    systime_t timestamp;
00079    systime_t timeout;
00080    uint_t sharedRecordCount;
00081 } MdnsMessage;
00082 
00083 
00084 //mDNS IPv6 multicast group
00085 extern const Ipv6Addr MDNS_IPV6_MULTICAST_ADDR;
00086 
00087 //mDNS related functions
00088 error_t mdnsInit(NetInterface *interface);
00089 
00090 void mdnsProcessMessage(NetInterface *interface, const IpPseudoHeader *pseudoHeader,
00091    const UdpHeader *udpHeader, const NetBuffer *buffer, size_t offset, void *params);
00092 
00093 void mdnsProcessResponse(NetInterface *interface, MdnsMessage *response);
00094 
00095 bool_t mdnsCheckSourceAddr(NetInterface *interface,
00096    const IpPseudoHeader *pseudoHeader);
00097 
00098 error_t mdnsCreateMessage(MdnsMessage *message, bool_t queryResponse);
00099 void mdnsDeleteMessage(MdnsMessage *message);
00100 
00101 error_t mdnsSendMessage(NetInterface *interface, const MdnsMessage *message,
00102    const IpAddr *destIpAddr, uint_t destPort);
00103 
00104 size_t mdnsEncodeName(const char_t *instance, const char_t *service,
00105    const char_t *domain, uint8_t *dest);
00106 
00107 int_t mdnsCompareName(const DnsHeader *message, size_t length, size_t pos,
00108    const char_t *instance, const char_t *service, const char_t *domain, uint_t level);
00109 
00110 int_t mdnsCompareRecord(const MdnsMessage *message1, size_t offset1,
00111    const DnsResourceRecord *record1, const MdnsMessage *message2,
00112    size_t offset2, const DnsResourceRecord *record2);
00113 
00114 bool_t mdnsCheckDuplicateRecord(const MdnsMessage *message, const char_t *instance,
00115    const char_t *service, const char_t *domain, uint16_t rtype);
00116 
00117 #endif
00118