Zephyr API Documentation  3.7.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
dns_sd.h
Go to the documentation of this file.
1
5/*
6 * Copyright (c) 2020 Friedt Professional Engineering Services, Inc
7 *
8 * SPDX-License-Identifier: Apache-2.0
9 */
10
11#ifndef ZEPHYR_INCLUDE_NET_DNS_SD_H_
12#define ZEPHYR_INCLUDE_NET_DNS_SD_H_
13
14#include <stdint.h>
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
37#define DNS_SD_INSTANCE_MIN_SIZE 1
39#define DNS_SD_INSTANCE_MAX_SIZE 63
41#define DNS_SD_SERVICE_MIN_SIZE 2
43#define DNS_SD_SERVICE_MAX_SIZE 16
45#define DNS_SD_SERVICE_PREFIX '_'
47#define DNS_SD_PROTO_SIZE 4
49#define DNS_SD_DOMAIN_MIN_SIZE 2
51#define DNS_SD_DOMAIN_MAX_SIZE 63
52
67#define DNS_SD_MIN_LABELS 3
83#define DNS_SD_MAX_LABELS 4
84
109#define DNS_SD_REGISTER_SERVICE(_id, _instance, _service, _proto, \
110 _domain, _text, _port) \
111 static const STRUCT_SECTION_ITERABLE(dns_sd_rec, _id) = { \
112 .instance = _instance, \
113 .service = _service, \
114 .proto = _proto, \
115 .domain = _domain, \
116 .text = (const char *)_text, \
117 .text_size = sizeof(_text) - 1, \
118 .port = _port, \
119 }
120
161#define DNS_SD_REGISTER_TCP_SERVICE(id, instance, service, domain, text, \
162 port) \
163 static const uint16_t id ## _port = sys_cpu_to_be16(port); \
164 DNS_SD_REGISTER_SERVICE(id, instance, service, "_tcp", domain, \
165 text, &id ## _port)
166
192#define DNS_SD_REGISTER_UDP_SERVICE(id, instance, service, domain, text, \
193 port) \
194 static const uint16_t id ## _port = sys_cpu_to_be16(port); \
195 DNS_SD_REGISTER_SERVICE(id, instance, service, "_udp", domain, \
196 text, &id ## _port)
197
199#define DNS_SD_EMPTY_TXT dns_sd_empty_txt
200
219 const char *instance;
221 const char *service;
223 const char *proto;
225 const char *domain;
227 const char *text;
229 size_t text_size;
232};
233
241extern const char dns_sd_empty_txt[1];
247extern const uint16_t dns_sd_port_zero;
248
257static inline size_t dns_sd_txt_size(const struct dns_sd_rec *rec)
258{
259 return rec->text_size;
260}
261
280
287
292#ifdef __cplusplus
293};
294#endif
295
296#endif /* ZEPHYR_INCLUDE_NET_DNS_SD_H_ */
void dns_sd_create_wildcard_filter(struct dns_sd_rec *filter)
Create a wildcard filter for DNS-SD records.
static size_t dns_sd_txt_size(const struct dns_sd_rec *rec)
Obtain the size of DNS-SD TXT data.
Definition: dns_sd.h:257
bool dns_sd_is_service_type_enumeration(const struct dns_sd_rec *rec)
Check if rec is a DNS-SD Service Type Enumeration.
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
DNS Service Discovery record.
Definition: dns_sd.h:217
const char * instance
"<Instance>" - e.g.
Definition: dns_sd.h:219
const uint16_t * port
A pointer to the port number used by the service.
Definition: dns_sd.h:231
size_t text_size
Size (in bytes) of the DNS TXT record
Definition: dns_sd.h:229
const char * domain
"<Domain>" such as "local" or "zephyrproject.org"
Definition: dns_sd.h:225
const char * proto
Bottom half of the "<Service>" "_tcp" or "_udp".
Definition: dns_sd.h:223
const char * text
DNS TXT record.
Definition: dns_sd.h:227
const char * service
Top half of the "<Service>" such as "_http".
Definition: dns_sd.h:221
Byte order helpers.