]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/resolve/resolved-dnssd.h
Merge pull request #7540 from fbuihuu/systemd-delta-tweaks
[thirdparty/systemd.git] / src / resolve / resolved-dnssd.h
1 #pragma once
2
3 /***
4 This file is part of systemd.
5
6 Copyright 2017 Dmitry Rozhkov
7
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #include "list.h"
23
24 typedef struct DnssdService DnssdService;
25 typedef struct DnssdTxtData DnssdTxtData;
26
27 typedef struct Manager Manager;
28 typedef struct DnsResourceRecord DnsResourceRecord;
29 typedef struct DnsTxtItem DnsTxtItem;
30
31 enum {
32 DNS_TXT_ITEM_TEXT,
33 DNS_TXT_ITEM_DATA
34 };
35
36 struct DnssdTxtData {
37 DnsResourceRecord *rr;
38
39 LIST_HEAD(DnsTxtItem, txt);
40
41 LIST_FIELDS(DnssdTxtData, items);
42 };
43
44 struct DnssdService {
45 char *filename;
46 char *name;
47 char *name_template;
48 char *type;
49 uint16_t port;
50 uint16_t priority;
51 uint16_t weight;
52
53 DnsResourceRecord *ptr_rr;
54 DnsResourceRecord *srv_rr;
55
56 /* Section 6.8 of RFC 6763 allows having service
57 * instances with multiple TXT resource records. */
58 LIST_HEAD(DnssdTxtData, txt_data_items);
59
60 Manager *manager;
61
62 bool withdrawn:1;
63 uid_t originator;
64 };
65
66 DnssdService *dnssd_service_free(DnssdService *service);
67 DnssdTxtData *dnssd_txtdata_free(DnssdTxtData *txt_data);
68 DnssdTxtData *dnssd_txtdata_free_all(DnssdTxtData *txt_data);
69
70 DEFINE_TRIVIAL_CLEANUP_FUNC(DnssdService*, dnssd_service_free);
71 DEFINE_TRIVIAL_CLEANUP_FUNC(DnssdTxtData*, dnssd_txtdata_free);
72
73 int dnssd_render_instance_name(DnssdService *s, char **ret_name);
74 int dnssd_load(Manager *manager);
75 int dnssd_txt_item_new_from_string(const char *key, const char *value, DnsTxtItem **ret_item);
76 int dnssd_txt_item_new_from_data(const char *key, const void *value, const size_t size, DnsTxtItem **ret_item);
77 int dnssd_update_rrs(DnssdService *s);
78 void dnssd_signal_conflict(Manager *manager, const char *name);