return 0;
}
-int config_parse_dnssd_service_name(
- 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) {
-
- static const Specifier specifier_table[] = {
- { 'a', specifier_architecture, NULL },
- { 'b', specifier_boot_id, NULL },
- { 'B', specifier_os_build_id, NULL },
- { 'H', specifier_hostname, NULL }, /* We will use specifier_dnssd_hostname(). */
- { 'm', specifier_machine_id, NULL },
- { 'o', specifier_os_id, NULL },
- { 'v', specifier_kernel_release, NULL },
- { 'w', specifier_os_version_id, NULL },
- { 'W', specifier_os_variant_id, NULL },
- {}
- };
- DnssdService *s = ASSERT_PTR(userdata);
- _cleanup_free_ char *name = NULL;
- int r;
-
- assert(filename);
- assert(lvalue);
- assert(rvalue);
-
- if (isempty(rvalue)) {
- s->name_template = mfree(s->name_template);
- return 0;
- }
-
- r = specifier_printf(rvalue, DNS_LABEL_MAX, specifier_table, NULL, NULL, &name);
- if (r < 0) {
- log_syntax(unit, LOG_WARNING, filename, line, r,
- "Invalid service instance name template '%s', ignoring assignment: %m", rvalue);
- return 0;
- }
-
- if (!dns_service_name_is_valid(name)) {
- log_syntax(unit, LOG_WARNING, filename, line, 0,
- "Service instance name template '%s' renders to invalid name '%s'. Ignoring assignment.",
- rvalue, name);
- return 0;
- }
-
- return free_and_strdup_warn(&s->name_template, rvalue);
-}
-
-int config_parse_dnssd_service_type(
- 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) {
-
- DnssdService *s = ASSERT_PTR(userdata);
- int r;
-
- assert(filename);
- assert(lvalue);
- assert(rvalue);
-
- if (isempty(rvalue)) {
- s->type = mfree(s->type);
- return 0;
- }
-
- if (!dnssd_srv_type_is_valid(rvalue)) {
- log_syntax(unit, LOG_WARNING, filename, line, 0, "Service type is invalid. Ignoring.");
- return 0;
- }
-
- r = free_and_strdup(&s->type, rvalue);
- if (r < 0)
- return log_oom();
-
- return 0;
-}
-
-int config_parse_dnssd_service_subtype(
- 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) {
-
- DnssdService *s = ASSERT_PTR(userdata);
-
- assert(filename);
- assert(lvalue);
- assert(rvalue);
-
- if (isempty(rvalue)) {
- s->subtype = mfree(s->subtype);
- return 0;
- }
-
- if (!dns_subtype_name_is_valid(rvalue)) {
- log_syntax(unit, LOG_WARNING, filename, line, 0, "Service subtype is invalid. Ignoring.");
- return 0;
- }
-
- return free_and_strdup_warn(&s->subtype, rvalue);
-}
-
-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 = ASSERT_PTR(userdata);
- DnsTxtItem *last = NULL;
-
- assert(filename);
- assert(lvalue);
- assert(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, *key = NULL, *value = NULL;
- _cleanup_free_ void *decoded = NULL;
- size_t length = 0;
- DnsTxtItem *i;
- int r;
-
- r = extract_first_word(&rvalue, &word, NULL,
- EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE|EXTRACT_UNESCAPE_RELAX);
- if (r == 0)
- break;
- if (r == -ENOMEM)
- return log_oom();
- if (r < 0) {
- log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", rvalue);
- return 0;
- }
-
- r = split_pair(word, "=", &key, &value);
- if (r == -ENOMEM)
- return log_oom();
- if (r == -EINVAL)
- key = TAKE_PTR(word);
-
- if (!ascii_is_valid(key)) {
- log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid key, ignoring: %s", key);
- continue;
- }
-
- switch (ltype) {
-
- case DNS_TXT_ITEM_DATA:
- if (value) {
- r = unbase64mem(value, &decoded, &length);
- if (r == -ENOMEM)
- return log_oom();
- if (r < 0) {
- log_syntax(unit, LOG_WARNING, filename, line, r,
- "Invalid base64 encoding, ignoring: %s", value);
- continue;
- }
- }
-
- r = dnssd_txt_item_new_from_data(key, decoded, length, &i);
- if (r < 0)
- return log_oom();
- break;
-
- case DNS_TXT_ITEM_TEXT:
- r = dnssd_txt_item_new_from_string(key, value, &i);
- if (r < 0)
- return log_oom();
- break;
-
- default:
- assert_not_reached();
- }
-
- LIST_INSERT_AFTER(items, txt_data->txts, last, i);
- last = i;
- }
-
- if (txt_data->txts) {
- LIST_PREPEND(items, s->txt_data_items, txt_data);
- TAKE_PTR(txt_data);
- }
-
- return 0;
-}
-
int config_parse_dns_stub_listener_extra(
const char *unit,
const char *filename,
CONFIG_PARSER_PROTOTYPE(config_parse_dns_servers);
CONFIG_PARSER_PROTOTYPE(config_parse_search_domains);
CONFIG_PARSER_PROTOTYPE(config_parse_dns_stub_listener_mode);
-CONFIG_PARSER_PROTOTYPE(config_parse_dnssd_service_name);
-CONFIG_PARSER_PROTOTYPE(config_parse_dnssd_service_subtype);
-CONFIG_PARSER_PROTOTYPE(config_parse_dnssd_service_type);
-CONFIG_PARSER_PROTOTYPE(config_parse_dnssd_txt);
CONFIG_PARSER_PROTOTYPE(config_parse_dns_stub_listener_extra);
#include "conf-files.h"
#include "conf-parser.h"
#include "constants.h"
+#include "hexdecoct.h"
#include "path-util.h"
#include "resolved-conf.h"
#include "resolved-dns-rr.h"
return 0;
}
+
+int config_parse_dnssd_service_name(
+ 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) {
+
+ static const Specifier specifier_table[] = {
+ { 'a', specifier_architecture, NULL },
+ { 'b', specifier_boot_id, NULL },
+ { 'B', specifier_os_build_id, NULL },
+ { 'H', specifier_hostname, NULL }, /* We will use specifier_dnssd_hostname(). */
+ { 'm', specifier_machine_id, NULL },
+ { 'o', specifier_os_id, NULL },
+ { 'v', specifier_kernel_release, NULL },
+ { 'w', specifier_os_version_id, NULL },
+ { 'W', specifier_os_variant_id, NULL },
+ {}
+ };
+ DnssdService *s = ASSERT_PTR(userdata);
+ _cleanup_free_ char *name = NULL;
+ int r;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+
+ if (isempty(rvalue)) {
+ s->name_template = mfree(s->name_template);
+ return 0;
+ }
+
+ r = specifier_printf(rvalue, DNS_LABEL_MAX, specifier_table, NULL, NULL, &name);
+ if (r < 0) {
+ log_syntax(unit, LOG_WARNING, filename, line, r,
+ "Invalid service instance name template '%s', ignoring assignment: %m", rvalue);
+ return 0;
+ }
+
+ if (!dns_service_name_is_valid(name)) {
+ log_syntax(unit, LOG_WARNING, filename, line, 0,
+ "Service instance name template '%s' renders to invalid name '%s'. Ignoring assignment.",
+ rvalue, name);
+ return 0;
+ }
+
+ return free_and_strdup_warn(&s->name_template, rvalue);
+}
+
+int config_parse_dnssd_service_type(
+ 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) {
+
+ DnssdService *s = ASSERT_PTR(userdata);
+ int r;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+
+ if (isempty(rvalue)) {
+ s->type = mfree(s->type);
+ return 0;
+ }
+
+ if (!dnssd_srv_type_is_valid(rvalue)) {
+ log_syntax(unit, LOG_WARNING, filename, line, 0, "Service type is invalid. Ignoring.");
+ return 0;
+ }
+
+ r = free_and_strdup(&s->type, rvalue);
+ if (r < 0)
+ return log_oom();
+
+ return 0;
+}
+
+int config_parse_dnssd_service_subtype(
+ 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) {
+
+ DnssdService *s = ASSERT_PTR(userdata);
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+
+ if (isempty(rvalue)) {
+ s->subtype = mfree(s->subtype);
+ return 0;
+ }
+
+ if (!dns_subtype_name_is_valid(rvalue)) {
+ log_syntax(unit, LOG_WARNING, filename, line, 0, "Service subtype is invalid. Ignoring.");
+ return 0;
+ }
+
+ return free_and_strdup_warn(&s->subtype, rvalue);
+}
+
+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 = ASSERT_PTR(userdata);
+ DnsTxtItem *last = NULL;
+
+ assert(filename);
+ assert(lvalue);
+ assert(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, *key = NULL, *value = NULL;
+ _cleanup_free_ void *decoded = NULL;
+ size_t length = 0;
+ DnsTxtItem *i;
+ int r;
+
+ r = extract_first_word(&rvalue, &word, NULL,
+ EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE|EXTRACT_UNESCAPE_RELAX);
+ if (r == 0)
+ break;
+ if (r == -ENOMEM)
+ return log_oom();
+ if (r < 0) {
+ log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", rvalue);
+ return 0;
+ }
+
+ r = split_pair(word, "=", &key, &value);
+ if (r == -ENOMEM)
+ return log_oom();
+ if (r == -EINVAL)
+ key = TAKE_PTR(word);
+
+ if (!ascii_is_valid(key)) {
+ log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid key, ignoring: %s", key);
+ continue;
+ }
+
+ switch (ltype) {
+
+ case DNS_TXT_ITEM_DATA:
+ if (value) {
+ r = unbase64mem(value, &decoded, &length);
+ if (r == -ENOMEM)
+ return log_oom();
+ if (r < 0) {
+ log_syntax(unit, LOG_WARNING, filename, line, r,
+ "Invalid base64 encoding, ignoring: %s", value);
+ continue;
+ }
+ }
+
+ r = dnssd_txt_item_new_from_data(key, decoded, length, &i);
+ if (r < 0)
+ return log_oom();
+ break;
+
+ case DNS_TXT_ITEM_TEXT:
+ r = dnssd_txt_item_new_from_string(key, value, &i);
+ if (r < 0)
+ return log_oom();
+ break;
+
+ default:
+ assert_not_reached();
+ }
+
+ LIST_INSERT_AFTER(items, txt_data->txts, last, i);
+ last = i;
+ }
+
+ if (txt_data->txts) {
+ LIST_PREPEND(items, s->txt_data_items, txt_data);
+ TAKE_PTR(txt_data);
+ }
+
+ return 0;
+}
int dnssd_signal_conflict(Manager *manager, const char *name);
const struct ConfigPerfItem* resolved_dnssd_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
+
+CONFIG_PARSER_PROTOTYPE(config_parse_dnssd_service_name);
+CONFIG_PARSER_PROTOTYPE(config_parse_dnssd_service_subtype);
+CONFIG_PARSER_PROTOTYPE(config_parse_dnssd_service_type);
+CONFIG_PARSER_PROTOTYPE(config_parse_dnssd_txt);