mdns_common.h File Reference

Definitions common to mDNS client and mDNS responder. More...

#include "core/net.h"
#include "dns/dns_common.h"

Go to the source code of this file.

Data Structures

struct  MdnsMessage
 mDNS message More...
 

Macros

#define MDNS_MESSAGE_MAX_SIZE   1232
 
#define MDNS_DEFAULT_RR_TTL   120
 
#define MDNS_PORT   5353
 
#define MDNS_DEFAULT_IP_TTL   255
 
#define MDNS_LEGACY_UNICAST_RR_TTL   10
 
#define MDNS_QCLASS_QU   0x8000
 
#define MDNS_RCLASS_CACHE_FLUSH   0x8000
 
#define MDNS_IPV4_MULTICAST_ADDR   IPV4_ADDR(224, 0, 0, 251)
 

Functions

error_t mdnsInit (NetInterface *interface)
 mDNS related initialization More...
 
void mdnsProcessMessage (NetInterface *interface, const IpPseudoHeader *pseudoHeader, const UdpHeader *udpHeader, const NetBuffer *buffer, size_t offset, const NetRxAncillary *ancillary, void *param)
 Process incoming mDNS message. More...
 
void mdnsProcessResponse (NetInterface *interface, MdnsMessage *response)
 Process mDNS response message. More...
 
bool_t mdnsCheckSourceAddr (NetInterface *interface, const IpPseudoHeader *pseudoHeader)
 Source address check. More...
 
error_t mdnsCreateMessage (MdnsMessage *message, bool_t queryResponse)
 Create an empty mDNS message. More...
 
void mdnsDeleteMessage (MdnsMessage *message)
 release a mDNS message More...
 
error_t mdnsSendMessage (NetInterface *interface, const MdnsMessage *message, const IpAddr *destIpAddr, uint_t destPort)
 Send mDNS message. More...
 
size_t mdnsEncodeName (const char_t *instance, const char_t *service, const char_t *domain, uint8_t *dest)
 Encode instance, service and domain names using the DNS name notation. More...
 
int_t mdnsCompareName (const DnsHeader *message, size_t length, size_t pos, const char_t *instance, const char_t *service, const char_t *domain, uint_t level)
 Compare instance, service and domain names. More...
 
int_t mdnsCompareRecord (const MdnsMessage *message1, const DnsResourceRecord *record1, const MdnsMessage *message2, const DnsResourceRecord *record2)
 Compare resource records. More...
 
bool_t mdnsCheckDuplicateRecord (const MdnsMessage *message, const char_t *instance, const char_t *service, const char_t *domain, uint16_t rtype, const uint8_t *rdata, size_t rdlength)
 Check for duplicate resource records. More...
 

Variables

const Ipv6Addr MDNS_IPV6_MULTICAST_ADDR
 

Detailed Description

Definitions common to mDNS client and mDNS responder.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.4

Definition in file mdns_common.h.

Macro Definition Documentation

◆ MDNS_DEFAULT_IP_TTL

#define MDNS_DEFAULT_IP_TTL   255

Definition at line 55 of file mdns_common.h.

◆ MDNS_DEFAULT_RR_TTL

#define MDNS_DEFAULT_RR_TTL   120

Definition at line 47 of file mdns_common.h.

◆ MDNS_IPV4_MULTICAST_ADDR

#define MDNS_IPV4_MULTICAST_ADDR   IPV4_ADDR(224, 0, 0, 251)

Definition at line 65 of file mdns_common.h.

◆ MDNS_LEGACY_UNICAST_RR_TTL

#define MDNS_LEGACY_UNICAST_RR_TTL   10

Definition at line 57 of file mdns_common.h.

◆ MDNS_MESSAGE_MAX_SIZE

#define MDNS_MESSAGE_MAX_SIZE   1232

Definition at line 40 of file mdns_common.h.

◆ MDNS_PORT

#define MDNS_PORT   5353

Definition at line 53 of file mdns_common.h.

◆ MDNS_QCLASS_QU

#define MDNS_QCLASS_QU   0x8000

Definition at line 60 of file mdns_common.h.

◆ MDNS_RCLASS_CACHE_FLUSH

#define MDNS_RCLASS_CACHE_FLUSH   0x8000

Definition at line 62 of file mdns_common.h.

Function Documentation

◆ mdnsCheckDuplicateRecord()

bool_t mdnsCheckDuplicateRecord ( const MdnsMessage message,
const char_t instance,
const char_t service,
const char_t domain,
uint16_t  rtype,
const uint8_t *  rdata,
size_t  rdlength 
)

Check for duplicate resource records.

Parameters
[in]messagePointer to the mDNS message
[in]instanceInstance name
[in]serviceService name
[in]domainDomain name
[in]rtypeResource record type
[in]rdataResource record data
[in]rdlengthLength of the resource record data, in bytes
Returns
The function returns TRUE is the specified resource record is a duplicate. Otherwise FALSE is returned

Definition at line 921 of file mdns_common.c.

◆ mdnsCheckSourceAddr()

bool_t mdnsCheckSourceAddr ( NetInterface interface,
const IpPseudoHeader pseudoHeader 
)

Source address check.

Parameters
[in]interfaceUnderlying network interface
[in]pseudoHeaderUDP pseudo header
Returns
TRUE if the source address is valid, else FALSE

Definition at line 275 of file mdns_common.c.

◆ mdnsCompareName()

int_t mdnsCompareName ( const DnsHeader message,
size_t  length,
size_t  pos,
const char_t instance,
const char_t service,
const char_t domain,
uint_t  level 
)

Compare instance, service and domain names.

Parameters
[in]messagePointer to the DNS message
[in]lengthLength of the DNS message
[in]posOffset of the encoded name
[in]instanceInstance name
[in]serviceService name
[in]domainDomain name
[in]levelCurrent level of recursion
Returns
The function returns 0 if the domain names match, -1 if the first domain name lexicographically precedes the second name, or 1 if the second domain name lexicographically precedes the first name

Definition at line 648 of file mdns_common.c.

◆ mdnsCompareRecord()

int_t mdnsCompareRecord ( const MdnsMessage message1,
const DnsResourceRecord record1,
const MdnsMessage message2,
const DnsResourceRecord record2 
)

Compare resource records.

Parameters
[in]message1Pointer to the first mDNS message
[in]record1Pointer the first resource record
[in]message2Pointer to the second mDNS message
[in]record2Pointer the second resource record
Returns
The function returns 0 if the resource records match, -1 if the first resource record lexicographically precedes the second one, or 1 if the second resource record lexicographically precedes the first one

Definition at line 799 of file mdns_common.c.

◆ mdnsCreateMessage()

error_t mdnsCreateMessage ( MdnsMessage message,
bool_t  queryResponse 
)

Create an empty mDNS message.

Parameters
[in,out]messageNewly created mDNS message
[in]queryResponseThis flag specifies whether the message is a query or a response
Returns
Error code

Definition at line 357 of file mdns_common.c.

◆ mdnsDeleteMessage()

void mdnsDeleteMessage ( MdnsMessage message)

release a mDNS message

Parameters
[in]messagemDNS message to be released

Definition at line 434 of file mdns_common.c.

◆ mdnsEncodeName()

size_t mdnsEncodeName ( const char_t instance,
const char_t service,
const char_t domain,
uint8_t *  dest 
)

Encode instance, service and domain names using the DNS name notation.

Parameters
[in]instanceInstance name
[in]serviceService name
[in]domainDomain name
[out]destPointer to the encoded name (optional parameter)
Returns
Length of the encoded domain name

Definition at line 544 of file mdns_common.c.

◆ mdnsInit()

error_t mdnsInit ( NetInterface interface)

mDNS related initialization

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 69 of file mdns_common.c.

◆ mdnsProcessMessage()

void mdnsProcessMessage ( NetInterface interface,
const IpPseudoHeader pseudoHeader,
const UdpHeader udpHeader,
const NetBuffer buffer,
size_t  offset,
const NetRxAncillary ancillary,
void *  param 
)

Process incoming mDNS message.

Parameters
[in]interfaceUnderlying network interface
[in]pseudoHeaderUDP pseudo header
[in]udpHeaderUDP header
[in]bufferMulti-part buffer containing the incoming mDNS message
[in]offsetOffset to the first byte of the mDNS message
[in]ancillaryAdditional options passed to the stack along with the packet
[in]paramCallback function parameter (not used)

Definition at line 112 of file mdns_common.c.

◆ mdnsProcessResponse()

void mdnsProcessResponse ( NetInterface interface,
MdnsMessage response 
)

Process mDNS response message.

Parameters
[in]interfaceUnderlying network interface
[in]responseIncoming mDNS response message

Definition at line 180 of file mdns_common.c.

◆ mdnsSendMessage()

error_t mdnsSendMessage ( NetInterface interface,
const MdnsMessage message,
const IpAddr destIpAddr,
uint_t  destPort 
)

Send mDNS message.

Parameters
[in]interfaceUnderlying network interface
[in]messagemDNS message to be sent
[in]destIpAddrDestination IP address (optional parameter)
[in]destPortDestination port
Returns
Error code

Definition at line 458 of file mdns_common.c.

Variable Documentation

◆ MDNS_IPV6_MULTICAST_ADDR

const Ipv6Addr MDNS_IPV6_MULTICAST_ADDR
extern

Definition at line 59 of file mdns_common.c.