aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Rozhkov <dmitry.rozhkov@linux.intel.com>2017-11-29 11:03:44 +0200
committerDmitry Rozhkov <dmitry.rozhkov@linux.intel.com>2017-12-08 14:29:27 +0200
commit400f54fb3666e49115dc36a585f68047370096af (patch)
tree3e209a9cfd6b8ea51b2ed4e3cd1a7b195436a026 /src/resolve/resolved-conf.c
parentresolved: consult Polkit for privileges when manipulating DNS-SD (diff)
downloadsystemd-400f54fb3666e49115dc36a585f68047370096af.tar.gz
systemd-400f54fb3666e49115dc36a585f68047370096af.tar.bz2
systemd-400f54fb3666e49115dc36a585f68047370096af.zip
resolved: support multiple TXT RRs per DNS-SD service
Section 6.8 of RFC 6763 allows having service instances with multiple TXT resource records.
Diffstat (limited to 'src/resolve/resolved-conf.c')
-rw-r--r--src/resolve/resolved-conf.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/resolve/resolved-conf.c b/src/resolve/resolved-conf.c
index 71188fcec..ca69d70e3 100644
--- a/src/resolve/resolved-conf.c
+++ b/src/resolve/resolved-conf.c
@@ -297,6 +297,7 @@ int config_parse_dnssd_service_type(const char *unit, const char *filename, unsi
}
int config_parse_dnssd_txt(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata) {
+ _cleanup_(dnssd_txtdata_freep) DnssdTxtData *txt_data = NULL;
DnssdService *s = userdata;
DnsTxtItem *last = NULL;
@@ -305,13 +306,15 @@ int config_parse_dnssd_txt(const char *unit, const char *filename, unsigned line
assert(rvalue);
assert(s);
- /* TODO: Since RFC6763 allows more than one TXT RR per service
- * this s->txt field should be implemented as a list
- * of DnsTxtItem lists. */
- s->txt = dns_txt_item_free_all(s->txt);
-
- if (isempty(rvalue))
+ if (isempty(rvalue)) {
+ /* Flush out collected items */
+ s->txt_data_items = dnssd_txtdata_free_all(s->txt_data_items);
return 0;
+ }
+
+ txt_data = new0(DnssdTxtData, 1);
+ if (!txt_data)
+ return log_oom();
for (;;) {
_cleanup_free_ char *word = NULL;
@@ -371,10 +374,15 @@ int config_parse_dnssd_txt(const char *unit, const char *filename, unsigned line
assert_not_reached("Unknown type of Txt config");
}
- LIST_INSERT_AFTER(items, s->txt, last, i);
+ LIST_INSERT_AFTER(items, txt_data->txt, last, i);
last = i;
}
+ if (!LIST_IS_EMPTY(txt_data->txt)) {
+ LIST_PREPEND(items, s->txt_data_items, txt_data);
+ txt_data = NULL;
+ }
+
return 0;
}