Zephyr API Documentation  3.5.0
A Scalable Open Source RTOS
3.5.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
221struct dns_sd_rec {
223 const char *instance;
225 const char *service;
227 const char *proto;
229 const char *domain;
231 const char *text;
233 size_t text_size;
235 const uint16_t *port;
236};
237
243extern const char dns_sd_empty_txt[1];
249extern const uint16_t dns_sd_port_zero;
250
259static inline size_t dns_sd_txt_size(const struct dns_sd_rec *rec)
260{
261 return rec->text_size;
262}
263
281bool dns_sd_is_service_type_enumeration(const struct dns_sd_rec *rec);
282
288void dns_sd_create_wildcard_filter(struct dns_sd_rec *filter);
289
294#ifdef __cplusplus
295};
296#endif
297
298#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:259
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
Byte order helpers.