}
}
-
gchar *avahi_key_to_string(const AvahiKey *k) {
g_assert(k);
g_assert(k->ref >= 1);
unescape_uneeded(s, tmp, sizeof(tmp));
- if ((l = strlen(tmp)) == 0)
- return g_strdup(".");
+ l = strlen(tmp);
- if (tmp[l-1] == '.')
- return g_strdup(tmp);
+ while (l > 0 && tmp[l-1] == '.')
+ tmp[--l] = 0;
- return g_strdup_printf("%s.", tmp);
+ return g_strdup(tmp);
}
gint avahi_timeval_compare(const GTimeVal *a, const GTimeVal *b) {
b = g_new(AvahiDomainBrowser, 1);
b->server = server;
- b->domain_name = avahi_normalize_name(domain ? domain : "local.");
+ b->domain_name = avahi_normalize_name(domain ? domain : "local");
b->callback = callback;
b->userdata = userdata;
b = g_new(AvahiServiceTypeBrowser, 1);
b->server = server;
- b->domain_name = avahi_normalize_name(domain ? domain : "local.");
+ b->domain_name = avahi_normalize_name(domain ? domain : "local");
b->callback = callback;
b->userdata = userdata;
b = g_new(AvahiServiceBrowser, 1);
b->server = server;
- b->domain_name = avahi_normalize_name(domain ? domain : "local.");
+ b->domain_name = avahi_normalize_name(domain ? domain : "local");
b->service_type = avahi_normalize_name(service_type);
b->callback = callback;
b->userdata = userdata;
- n = g_strdup_printf("%s%s", b->service_type, b->domain_name);
+ n = g_strdup_printf("%s.%s", b->service_type, b->domain_name);
k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR);
g_free(n);
p->rindex += 1+k;
return 0;
-
}
gconstpointer avahi_dns_packet_get_rptr(AvahiDnsPacket *p) {
r = g_new(AvahiServiceResolver, 1);
r->server = server;
- r->service_name = avahi_normalize_name(name);
+ r->service_name = g_strdup(name);
r->service_type = avahi_normalize_name(type);
r->domain_name = avahi_normalize_name(domain);
r->callback = callback;
n = t;
l = sizeof(t);
avahi_escape_label((guint8*) name, strlen(name), &n, &l);
- snprintf(n, l, ".%s%s", r->service_type, r->domain_name);
+ snprintf(n, l, ".%s.%s", r->service_type, r->domain_name);
avahi_elapse_time(&tv, 1000, 0);
r->time_event = avahi_time_event_queue_add(server->time_event_queue, &tv, time_event_callback, r);
withdraw_host_rrs(s);
g_free(s->domain_name);
- s->domain_name = domain_name ? avahi_normalize_name(domain_name) : g_strdup("local.");
+ s->domain_name = domain_name ? avahi_normalize_name(domain_name) : g_strdup("local");
update_fqdn(s);
delayed_register_stuff(s);
/* Get host name */
s->host_name = s->config.host_name ? avahi_normalize_name(s->config.host_name) : avahi_get_host_name();
s->host_name[strcspn(s->host_name, ".")] = 0;
- s->domain_name = s->config.domain_name ? avahi_normalize_name(s->config.domain_name) : g_strdup("local.");
+ s->domain_name = s->config.domain_name ? avahi_normalize_name(s->config.domain_name) : g_strdup("local");
s->host_name_fqdn = NULL;
update_fqdn(s);
AvahiStringList *strlst) {
gchar ptr_name[256], svc_name[256], ename[64], enum_ptr[256];
+ gchar *t, *d;
AvahiRecord *r;
gint ret = 0;
if (!host)
host = s->host_name_fqdn;
- snprintf(ptr_name, sizeof(ptr_name), "%s.%s", type, domain);
- snprintf(svc_name, sizeof(svc_name), "%s.%s.%s", ename, type, domain);
+ d = avahi_normalize_name(domain);
+ t = avahi_normalize_name(type);
+ snprintf(ptr_name, sizeof(ptr_name), "%s.%s", t, d);
+ snprintf(svc_name, sizeof(svc_name), "%s.%s.%s", ename, t, d);
+
ret = avahi_server_add_ptr(s, g, interface, protocol, AVAHI_ENTRY_NULL, AVAHI_DEFAULT_TTL, ptr_name, svc_name);
r = avahi_record_new_full(svc_name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV, AVAHI_DEFAULT_TTL_HOST_NAME);
ret |= avahi_server_add_txt_strlst(s, g, interface, protocol, AVAHI_ENTRY_UNIQUE, AVAHI_DEFAULT_TTL, svc_name, strlst);
- snprintf(enum_ptr, sizeof(enum_ptr), "_services._dns-sd._udp.%s", domain);
+ snprintf(enum_ptr, sizeof(enum_ptr), "_services._dns-sd._udp.%s", d);
ret |=avahi_server_add_ptr(s, g, interface, protocol, AVAHI_ENTRY_NULL, AVAHI_DEFAULT_TTL, enum_ptr, ptr_name);
+ g_free(d);
+ g_free(t);
+
return ret;
}
guint16 port /** should be 53 */) {
gint ret = -1;
- gchar t[256];
+ gchar t[256], *d;
AvahiRecord *r;
g_assert(s);
} else
domain = s->domain_name;
- snprintf(t, sizeof(t), "%s.%s", type == AVAHI_DNS_SERVER_RESOLVE ? "_domain._udp" : "_dns-update._udp", domain);
+ d = avahi_normalize_name(domain);
+ snprintf(t, sizeof(t), "%s.%s", type == AVAHI_DNS_SERVER_RESOLVE ? "_domain._udp" : "_dns-update._udp", d);
+ g_free(d);
r = avahi_record_new_full(t, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV, AVAHI_DEFAULT_TTL_HOST_NAME);
r->data.srv.priority = 0;
return ret;
}
-
static void post_query_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, gpointer userdata) {
AvahiKey *k = userdata;
avahi_log_info("dbus: name acquired (%s)", name);
return DBUS_HANDLER_RESULT_HANDLED;
+
} else if (dbus_message_is_signal(m, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) {
gchar *name, *old, *new;
entry_group_free(i);
return respond_ok(c, m);
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "Commit")) {
if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) {
avahi_entry_group_commit(i->entry_group);
return respond_ok(c, m);
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "GetState")) {
DBusMessage *reply;
gint32 t;
dbus_message_unref(reply);
return DBUS_HANDLER_RESULT_HANDLED;
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddService")) {
gint32 interface, protocol;
gchar *type, *name, *domain, *host;
avahi_log_info("Successfully added service: %s", name);
return respond_ok(c, m);
+
} else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddAddress")) {
gint32 interface, protocol;
gchar *name, *address;
todo:
+* finish DBUS stuff
* release!
-* drop trailing dot on avahi_normalize_name()
+
later:
* support for special domain PTR records based on local IP subnet address
* Changes resulting in updated RFC of 7th June 2005:
* test against apple test suite
* sensible logging
* c++ support
+* drop trailing dot on avahi_normalize_name()