mdns_common.c File Reference

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

#include "core/net.h"
#include "ipv4/ipv4_misc.h"
#include "ipv6/ipv6_misc.h"
#include "mdns/mdns_client.h"
#include "mdns/mdns_responder.h"
#include "mdns/mdns_responder_misc.h"
#include "dns_sd/dns_sd_misc.h"
#include "dns/dns_debug.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   MDNS_TRACE_LEVEL
 

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.

Description

Multicast DNS and its companion technology DNS-Based Service Discovery were created to provide ease-of-use and autoconfiguration to IP networks. Refer to the following RFCs for complete details:

  • RFC 6762: Multicast DNS
  • RFC 6763: DNS-Based Service Discovery
Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.0

Definition in file mdns_common.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   MDNS_TRACE_LEVEL

Definition at line 40 of file mdns_common.c.

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 920 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 647 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 798 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 433 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 543 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 67 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 110 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 457 of file mdns_common.c.

Variable Documentation

◆ MDNS_IPV6_MULTICAST_ADDR

const Ipv6Addr MDNS_IPV6_MULTICAST_ADDR
Initial value:
=
IPV6_ADDR(0xFF02, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00FB)
#define IPV6_ADDR(a, b, c, d, e, f, g, h)
Definition: ipv6.h:111

Definition at line 57 of file mdns_common.c.