dns_sd_misc.c File Reference

Helper functions for DNS-SD. More...

#include <stdlib.h>
#include "core/net.h"
#include "mdns/mdns_responder.h"
#include "dns_sd/dns_sd.h"
#include "dns_sd/dns_sd_misc.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   DNS_SD_TRACE_LEVEL
 

Functions

void dnsSdChangeState (DnsSdContext *context, MdnsState newState, systime_t delay)
 Update FSM state. More...
 
void dnsSdChangeInstanceName (DnsSdContext *context)
 Programmatically change the service instance name. More...
 
error_t dnsSdSendProbe (DnsSdContext *context)
 Send probe packet. More...
 
error_t dnsSdSendAnnouncement (DnsSdContext *context)
 Send announcement packet. More...
 
error_t dnsSdSendGoodbye (DnsSdContext *context, const DnsSdService *service)
 Send goodbye packet. More...
 
error_t dnsSdParseQuestion (NetInterface *interface, const MdnsMessage *query, size_t offset, const DnsQuestion *question, MdnsMessage *response)
 Parse a question. More...
 
void dnsSdParseNsRecord (NetInterface *interface, const MdnsMessage *query, size_t offset, const DnsResourceRecord *record)
 Parse a resource record from the Authority Section. More...
 
void dnsSdParseAnRecord (NetInterface *interface, const MdnsMessage *response, size_t offset, const DnsResourceRecord *record)
 Parse a resource record from the Answer Section. More...
 
void dnsSdGenerateAdditionalRecords (NetInterface *interface, MdnsMessage *response, bool_t legacyUnicast)
 Additional record generation. More...
 
error_t dnsSdFormatServiceEnumPtrRecord (NetInterface *interface, MdnsMessage *message, const DnsSdService *service, uint32_t ttl)
 Format PTR resource record (in response to a meta-query) More...
 
error_t dnsSdFormatPtrRecord (NetInterface *interface, MdnsMessage *message, const DnsSdService *service, uint32_t ttl)
 Format PTR resource record. More...
 
error_t dnsSdFormatSrvRecord (NetInterface *interface, MdnsMessage *message, const DnsSdService *service, bool_t cacheFlush, uint32_t ttl)
 Format SRV resource record. More...
 
error_t dnsSdFormatTxtRecord (NetInterface *interface, MdnsMessage *message, const DnsSdService *service, bool_t cacheFlush, uint32_t ttl)
 Format TXT resource record. More...
 
error_t dnsSdFormatNsecRecord (NetInterface *interface, MdnsMessage *message, const DnsSdService *service, bool_t cacheFlush, uint32_t ttl)
 Format NSEC resource record. More...
 

Detailed Description

Helper functions for DNS-SD.

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.0

Definition in file dns_sd_misc.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   DNS_SD_TRACE_LEVEL

Definition at line 32 of file dns_sd_misc.c.

Function Documentation

◆ dnsSdChangeInstanceName()

void dnsSdChangeInstanceName ( DnsSdContext context)

Programmatically change the service instance name.

Parameters
[in]contextPointer to the DNS-SD context

Definition at line 88 of file dns_sd_misc.c.

◆ dnsSdChangeState()

void dnsSdChangeState ( DnsSdContext context,
MdnsState  newState,
systime_t  delay 
)

Update FSM state.

Parameters
[in]contextPointer to the DNS-SD context
[in]newStateNew state to switch to
[in]delayInitial delay

Definition at line 53 of file dns_sd_misc.c.

◆ dnsSdFormatNsecRecord()

error_t dnsSdFormatNsecRecord ( NetInterface interface,
MdnsMessage message,
const DnsSdService service,
bool_t  cacheFlush,
uint32_t  ttl 
)

Format NSEC resource record.

Parameters
[in]interfaceUnderlying network interface
[in,out]messagePointer to the mDNS message
[in]servicePointer to a DNS-SD service
[in]cacheFlushCache-flush bit
[in]ttlResource record TTL (cache lifetime)
Returns
Error code

Definition at line 1273 of file dns_sd_misc.c.

◆ dnsSdFormatPtrRecord()

error_t dnsSdFormatPtrRecord ( NetInterface interface,
MdnsMessage message,
const DnsSdService service,
uint32_t  ttl 
)

Format PTR resource record.

Parameters
[in]interfaceUnderlying network interface
[in,out]messagePointer to the mDNS message
[in]servicePointer to a DNS-SD service
[in]ttlResource record TTL (cache lifetime)
Returns
Error code

Definition at line 1004 of file dns_sd_misc.c.

◆ dnsSdFormatServiceEnumPtrRecord()

error_t dnsSdFormatServiceEnumPtrRecord ( NetInterface interface,
MdnsMessage message,
const DnsSdService service,
uint32_t  ttl 
)

Format PTR resource record (in response to a meta-query)

Parameters
[in]interfaceUnderlying network interface
[in,out]messagePointer to the mDNS message
[in]servicePointer to a DNS-SD service
[in]ttlResource record TTL (cache lifetime)
Returns
Error code

Definition at line 925 of file dns_sd_misc.c.

◆ dnsSdFormatSrvRecord()

error_t dnsSdFormatSrvRecord ( NetInterface interface,
MdnsMessage message,
const DnsSdService service,
bool_t  cacheFlush,
uint32_t  ttl 
)

Format SRV resource record.

Parameters
[in]interfaceUnderlying network interface
[in,out]messagePointer to the mDNS message
[in]servicePointer to a DNS-SD service
[in]cacheFlushCache-flush bit
[in]ttlResource record TTL (cache lifetime)
Returns
Error code

Definition at line 1089 of file dns_sd_misc.c.

◆ dnsSdFormatTxtRecord()

error_t dnsSdFormatTxtRecord ( NetInterface interface,
MdnsMessage message,
const DnsSdService service,
bool_t  cacheFlush,
uint32_t  ttl 
)

Format TXT resource record.

Parameters
[in]interfaceUnderlying network interface
[in,out]messagePointer to the mDNS message
[in]servicePointer to a DNS-SD service
[in]cacheFlushCache-flush bit
[in]ttlResource record TTL (cache lifetime)
Returns
Error code

Definition at line 1188 of file dns_sd_misc.c.

◆ dnsSdGenerateAdditionalRecords()

void dnsSdGenerateAdditionalRecords ( NetInterface interface,
MdnsMessage response,
bool_t  legacyUnicast 
)

Additional record generation.

Parameters
[in]interfaceUnderlying network interface
[in,out]responsemDNS response message
[in]legacyUnicastThis flag is set for legacy unicast responses

Definition at line 771 of file dns_sd_misc.c.

◆ dnsSdParseAnRecord()

void dnsSdParseAnRecord ( NetInterface interface,
const MdnsMessage response,
size_t  offset,
const DnsResourceRecord record 
)

Parse a resource record from the Answer Section.

Parameters
[in]interfaceUnderlying network interface
[in]responseIncoming mDNS response message
[in]offsetOffset to first byte of the resource record to be checked
[in]recordPointer to the resource record

Definition at line 701 of file dns_sd_misc.c.

◆ dnsSdParseNsRecord()

void dnsSdParseNsRecord ( NetInterface interface,
const MdnsMessage query,
size_t  offset,
const DnsResourceRecord record 
)

Parse a resource record from the Authority Section.

Parameters
[in]interfaceUnderlying network interface
[in]queryIncoming mDNS query message
[in]offsetOffset to first byte of the resource record
[in]recordPointer to the resource record

Definition at line 606 of file dns_sd_misc.c.

◆ dnsSdParseQuestion()

error_t dnsSdParseQuestion ( NetInterface interface,
const MdnsMessage query,
size_t  offset,
const DnsQuestion question,
MdnsMessage response 
)

Parse a question.

Parameters
[in]interfaceUnderlying network interface
[in]queryIncoming mDNS query message
[in]offsetOffset to first byte of the question
[in]questionPointer to the question
[in,out]responsemDNS response message
Returns
Error code

Definition at line 448 of file dns_sd_misc.c.

◆ dnsSdSendAnnouncement()

error_t dnsSdSendAnnouncement ( DnsSdContext context)

Send announcement packet.

Parameters
[in]contextPointer to the DNS-SD context
Returns
Error code

Definition at line 279 of file dns_sd_misc.c.

◆ dnsSdSendGoodbye()

error_t dnsSdSendGoodbye ( DnsSdContext context,
const DnsSdService service 
)

Send goodbye packet.

Parameters
[in]contextPointer to the DNS-SD context
[in]servicePointer to a DNS-SD service
Returns
Error code

Definition at line 368 of file dns_sd_misc.c.

◆ dnsSdSendProbe()

error_t dnsSdSendProbe ( DnsSdContext context)

Send probe packet.

Parameters
[in]contextPointer to the DNS-SD context
Returns
Error code

Definition at line 163 of file dns_sd_misc.c.