From 1438c0119533ea6374f233ee5dc9898b32f7e7c6 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 5 Jan 2007 22:19:28 +0000 Subject: [PATCH] add new config options "publish-aaaa-on-ipv4=" and "publish-a-on-ipv6=" git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1366 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- avahi-daemon/avahi-daemon.conf | 2 ++ avahi-daemon/main.c | 10 +++++++--- avahi-daemon/static-hosts.c | 9 ++++++++- man/avahi-daemon.conf.5.xml.in | 16 ++++++++++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/avahi-daemon/avahi-daemon.conf b/avahi-daemon/avahi-daemon.conf index 1992a67..21fa166 100644 --- a/avahi-daemon/avahi-daemon.conf +++ b/avahi-daemon/avahi-daemon.conf @@ -45,6 +45,8 @@ enable-wide-area=yes #publish-domain=yes #publish-dns-servers=192.168.50.1, 192.168.50.2 #publish-resolv-conf-dns-servers=yes +#publish-aaaa-on-ipv4=yes +#publish-a-on-ipv6=no [reflector] #enable-reflector=no diff --git a/avahi-daemon/main.c b/avahi-daemon/main.c index 33f1265..0b26446 100644 --- a/avahi-daemon/main.c +++ b/avahi-daemon/main.c @@ -442,7 +442,7 @@ static int parse_command_line(DaemonConfig *c, int argc, char *argv[]) { static int is_yes(const char *s) { assert(s); - return *s == 'y' || *s == 'Y'; + return *s == 'y' || *s == 'Y' || *s == '1' || *s == 't' || *s == 'T'; } static int load_config_file(DaemonConfig *c) { @@ -541,8 +541,12 @@ static int load_config_file(DaemonConfig *c) { c->server_config.add_service_cookie = is_yes(p->value); else if (strcasecmp(p->key, "publish-dns-servers") == 0) { avahi_strfreev(c->publish_dns_servers); - c->publish_dns_servers = avahi_split_csv(p->value); - } else { + c->publish_dns_servers = avahi_split_csv(p->value); + } else if (strcasecmp(p->key, "publish-a-on-ipv6") == 0) + c->server_config.publish_a_on_ipv6 = is_yes(p->value); + else if (strcasecmp(p->key, "publish-aaaa-on-ipv4") == 0) + c->server_config.publish_aaaa_on_ipv4 = is_yes(p->value); + else { avahi_log_error("Invalid configuration key \"%s\" in group \"%s\"\n", p->key, g->name); goto finish; } diff --git a/avahi-daemon/static-hosts.c b/avahi-daemon/static-hosts.c index 9941a51..35058fc 100644 --- a/avahi-daemon/static-hosts.c +++ b/avahi-daemon/static-hosts.c @@ -110,7 +110,9 @@ static void static_host_free(StaticHost *s) { static void add_static_host_to_server(StaticHost *h) { AvahiAddress a; + AvahiProtocol p; int err; + const AvahiServerConfig *config; if (!h->group) if (!(h->group = avahi_s_entry_group_new (avahi_server, entry_group_callback, h))) { @@ -123,7 +125,12 @@ static void add_static_host_to_server(StaticHost *h) return; } - if ((err = avahi_server_add_address(avahi_server, h->group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, h->host, &a))) { + config = avahi_server_get_config(avahi_server); + + p = (a.proto == AVAHI_PROTO_INET && config->publish_a_on_ipv6) || + (a.proto == AVAHI_PROTO_INET6 && config->publish_aaaa_on_ipv4) ? AVAHI_PROTO_UNSPEC : a.proto; + + if ((err = avahi_server_add_address(avahi_server, h->group, AVAHI_IF_UNSPEC, p, 0, h->host, &a))) { avahi_log_error ("Static host name %s: avahi_server_add_address failure: %s", h->host, avahi_strerror(err)); return; } diff --git a/man/avahi-daemon.conf.5.xml.in b/man/avahi-daemon.conf.5.xml.in index bfbd0e5..efd1a41 100644 --- a/man/avahi-daemon.conf.5.xml.in +++ b/man/avahi-daemon.conf.5.xml.in @@ -223,6 +223,22 @@ SIGHUP to have it reload this file. Defaults to "no".

+ + + +
-- 2.39.5