1 /* SPDX-License-Identifier: LGPL-2.1-or-later */ 2 3 #pragma once 4 5 #include "list.h" 6 7 typedef struct DnssdService DnssdService; 8 typedef struct DnssdTxtData DnssdTxtData; 9 10 typedef struct Manager Manager; 11 typedef struct DnsResourceRecord DnsResourceRecord; 12 typedef struct DnsTxtItem DnsTxtItem; 13 14 enum { 15 DNS_TXT_ITEM_TEXT, 16 DNS_TXT_ITEM_DATA 17 }; 18 19 struct DnssdTxtData { 20 DnsResourceRecord *rr; 21 22 LIST_HEAD(DnsTxtItem, txt); 23 24 LIST_FIELDS(DnssdTxtData, items); 25 }; 26 27 struct DnssdService { 28 char *filename; 29 char *name; 30 char *name_template; 31 char *type; 32 uint16_t port; 33 uint16_t priority; 34 uint16_t weight; 35 36 DnsResourceRecord *ptr_rr; 37 DnsResourceRecord *srv_rr; 38 39 /* Section 6.8 of RFC 6763 allows having service 40 * instances with multiple TXT resource records. */ 41 LIST_HEAD(DnssdTxtData, txt_data_items); 42 43 Manager *manager; 44 45 bool withdrawn:1; 46 uid_t originator; 47 }; 48 49 DnssdService *dnssd_service_free(DnssdService *service); 50 DnssdTxtData *dnssd_txtdata_free(DnssdTxtData *txt_data); 51 DnssdTxtData *dnssd_txtdata_free_all(DnssdTxtData *txt_data); 52 53 DEFINE_TRIVIAL_CLEANUP_FUNC(DnssdService*, dnssd_service_free); 54 DEFINE_TRIVIAL_CLEANUP_FUNC(DnssdTxtData*, dnssd_txtdata_free); 55 56 int dnssd_render_instance_name(Manager *m, DnssdService *s, char **ret); 57 int dnssd_load(Manager *manager); 58 int dnssd_txt_item_new_from_string(const char *key, const char *value, DnsTxtItem **ret_item); 59 int dnssd_txt_item_new_from_data(const char *key, const void *value, const size_t size, DnsTxtItem **ret_item); 60 int dnssd_update_rrs(DnssdService *s); 61 int dnssd_signal_conflict(Manager *manager, const char *name); 62