Zephyr API 3.6.99
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>
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
40#define DNS_SD_INSTANCE_MIN_SIZE 1
42#define DNS_SD_INSTANCE_MAX_SIZE 63
44#define DNS_SD_SERVICE_MIN_SIZE 2
46#define DNS_SD_SERVICE_MAX_SIZE 16
48#define DNS_SD_SERVICE_PREFIX '_'
50#define DNS_SD_PROTO_SIZE 4
52#define DNS_SD_DOMAIN_MIN_SIZE 2
54#define DNS_SD_DOMAIN_MAX_SIZE 63
55
70#define DNS_SD_MIN_LABELS 3
86#define DNS_SD_MAX_LABELS 4
87
112#define DNS_SD_REGISTER_SERVICE(_id, _instance, _service, _proto, \
113 _domain, _text, _port) \
114 static const STRUCT_SECTION_ITERABLE(dns_sd_rec, _id) = { \
115 .instance = _instance, \
116 .service = _service, \
117 .proto = _proto, \
118 .domain = _domain, \
119 .text = (const char *)_text, \
120 .text_size = sizeof(_text) - 1, \
121 .port = _port, \
122 }
123
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
190#define DNS_SD_REGISTER_UDP_SERVICE(id, instance, service, domain, text, \
191 port) \
192 static const uint16_t id ## _port = sys_cpu_to_be16(port); \
193 DNS_SD_REGISTER_SERVICE(id, instance, service, "_udp", domain, \
194 text, &id ## _port)
195
197#define DNS_SD_EMPTY_TXT dns_sd_empty_txt
198
217 const char *instance;
219 const char *service;
221 const char *proto;
223 const char *domain;
225 const char *text;
227 size_t text_size;
230};
231
239extern const char dns_sd_empty_txt[1];
245extern const uint16_t dns_sd_port_zero;
246
255static inline size_t dns_sd_txt_size(const struct dns_sd_rec *rec)
256{
257 return rec->text_size;
258}
259
278
285
290#ifdef __cplusplus
291};
292#endif
293
294#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:255
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:215
const char * instance
"<Instance>" - e.g.
Definition dns_sd.h:217
const uint16_t * port
A pointer to the port number used by the service.
Definition dns_sd.h:229
size_t text_size
Size (in bytes) of the DNS TXT record
Definition dns_sd.h:227
const char * domain
"<Domain>" such as "local" or "zephyrproject.org"
Definition dns_sd.h:223
const char * proto
Bottom half of the "<Service>" "_tcp" or "_udp".
Definition dns_sd.h:221
const char * text
DNS TXT record.
Definition dns_sd.h:225
const char * service
Top half of the "<Service>" such as "_http".
Definition dns_sd.h:219
Byte order helpers.