int tc = p && !!(avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_FLAGS) & AVAHI_DNS_FLAG_TC);
while ((r = avahi_record_list_next(s->record_list, &flush_cache, &unicast_response, &auxiliary))) {
-
- if (!avahi_interface_post_response(i, r, flush_cache, a, immediately || (flush_cache && !tc && !auxiliary)) && unicast_response) {
- append_aux_records_to_list(s, i, r, unicast_response);
-
+ int im = immediately;
+
+ /* Only send the response immediately if it contains a
+ * unique entry AND it is not in reply to a truncated
+ * packet AND it is not an auxiliary record AND all other
+ * responses for this record are unique too. */
+
+ if (flush_cache && !tc && !auxiliary && avahi_record_list_all_flush_cache(s->record_list))
+ im = 1;
+
+ if (!avahi_interface_post_response(i, r, flush_cache, a, im) && unicast_response) {
+
/* Due to some reasons the record has not been scheduled.
* The client requested an unicast response in that
* case. Therefore we prepare such a response */
+ append_aux_records_to_list(s, i, r, unicast_response);
+
for (;;) {
if (!reply) {
avahi_record_list_flush(s->record_list);
}
-
static void reflect_response(AvahiServer *s, AvahiInterface *i, AvahiRecord *r, int flush_cache) {
AvahiInterface *j;
for (j = s->monitor->interfaces; j; j = j->interface_next)
if (j != i && (s->config.reflect_ipv || j->protocol == i->protocol)) {
/* Post the query to other networks */
- avahi_interface_post_query(j, k, 1);
+ avahi_interface_post_query(j, k, 1, NULL);
/* Reply from caches of other network. This is needed to
* "work around" known answer suppression. */
assert(i);
assert(a);
-/* avahi_log_debug("query"); */
-
assert(avahi_record_list_is_empty(s->record_list));
is_probe = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_NSCOUNT) > 0;
int unicast_response = 0;
if (!(key = avahi_dns_packet_consume_key(p, &unicast_response))) {
- avahi_log_warn("Packet too short (1)");
+ avahi_log_warn(__FILE__": Packet too short or invalid while reading question key. (Maybe an UTF8 problem?)");
goto fail;
}
int unique = 0;
if (!(record = avahi_dns_packet_consume_record(p, &unique))) {
- avahi_log_warn("Packet too short (2)");
+ avahi_log_warn(__FILE__": Packet too short or invalid while reading known answer record. (Maybe an UTF8 problem?)");
goto fail;
}
int unique = 0;
if (!(record = avahi_dns_packet_consume_record(p, &unique))) {
- avahi_log_warn("Packet too short (3)");
+ avahi_log_warn(__FILE__": Packet too short or invalid while reading probe record. (Maybe an UTF8 problem?)");
goto fail;
}
assert(i);
assert(a);
-/* avahi_log_debug("response"); */
-
for (n = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ANCOUNT) +
avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ARCOUNT); n > 0; n--) {
AvahiRecord *record;
/* char *txt; */
if (!(record = avahi_dns_packet_consume_record(p, &cache_flush))) {
- avahi_log_warn("Packet too short (4)");
+ avahi_log_warn(__FILE__": Packet too short or invalid while reading response record. (Maybe an UTF8 problem?)");
break;
}
if (!avahi_key_is_pattern(record->key)) {
-/* avahi_log_debug("Handling response: %s", txt = avahi_record_to_string(record)); */
-/* avahi_free(txt); */
-
if (handle_conflict(s, i, record, cache_flush)) {
if (!from_local_iface)
reflect_response(s, i, record, cache_flush);
if (!s->config.enable_reflector)
return;
-/* avahi_log_debug("legacy unicast reflector"); */
-
/* Reflecting legacy unicast queries is a little more complicated
than reflecting normal queries, since we must route the
responses back to the right client. Therefore we must store
return;
}
-/* avahi_log_debug("new packet received on interface '%s.%i'.", i->hardware->name, i->protocol); */
-
if (avahi_address_is_ipv4_in_ipv6(src_address))
/* This is an IPv4 address encapsulated in IPv6, so let's ignore it. */
return;
handle_query_packet(s, p, i, src_address, port, legacy_unicast, from_local_iface);
-/* avahi_log_debug("Handled query"); */
} else {
if (port != AVAHI_MDNS_PORT) {
avahi_log_warn("Recieved repsonse with invalid source port %u on interface '%s.%i'", port, i->hardware->name, i->protocol);
}
handle_response_packet(s, p, i, src_address, from_local_iface);
-/* avahi_log_debug("Handled response"); */
}
}
s->state = state;
+ avahi_interface_monitor_update_rrs(s->monitor, 0);
+
if (s->callback)
s->callback(s, state, s->userdata);
}
/* Fill in HINFO rr */
if ((r = avahi_record_new_full(s->host_name_fqdn, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_HINFO, AVAHI_DEFAULT_TTL_HOST_NAME))) {
- uname(&utsname);
- r->data.hinfo.cpu = avahi_strdup(avahi_strup(utsname.machine));
- r->data.hinfo.os = avahi_strdup(avahi_strup(utsname.sysname));
- if (avahi_server_add(s, s->hinfo_entry_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_PUBLISH_UNIQUE, r) < 0) {
- avahi_log_warn("Failed to add HINFO RR: %s", avahi_strerror(s->error));
- return;
+ if (uname(&utsname) < 0)
+ avahi_log_warn("uname() failed: %s\n", avahi_strerror(errno));
+ else {
+
+ r->data.hinfo.cpu = avahi_strdup(avahi_strup(utsname.machine));
+ r->data.hinfo.os = avahi_strdup(avahi_strup(utsname.sysname));
+
+ avahi_log_info("Registering HINFO record with values '%s'/'%s'.", r->data.hinfo.cpu, r->data.hinfo.os);
+
+ if (avahi_server_add(s, s->hinfo_entry_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_PUBLISH_UNIQUE, r) < 0) {
+ avahi_log_warn("Failed to add HINFO RR: %s", avahi_strerror(s->error));
+ return;
+ }
}
avahi_record_unref(r);
if (!s->config.publish_domain)
return;
+ if (avahi_domain_equal(s->domain_name, "local"))
+ return;
+
if (s->browse_domain_entry_group)
assert(avahi_s_entry_group_is_empty(s->browse_domain_entry_group));
else
c->n_wide_area_servers = 0;
c->disallow_other_stacks = 0;
c->browse_domains = NULL;
+ c->disable_publishing = 0;
+ c->allow_point_to_point = 0;
return c;
}
assert(type);
assert(ret_group);
- if (!AVAHI_IF_VALID(interface))
- return avahi_server_set_errno(s, AVAHI_ERR_INVALID_INTERFACE);
-
- if (!AVAHI_IF_VALID(protocol))
- return avahi_server_set_errno(s, AVAHI_ERR_INVALID_PROTOCOL);
-
- if (!avahi_is_valid_service_name(name))
- return avahi_server_set_errno(s, AVAHI_ERR_INVALID_SERVICE_NAME);
-
- if (!avahi_is_valid_service_type_strict(type))
- return avahi_server_set_errno(s, AVAHI_ERR_INVALID_SERVICE_TYPE);
-
- if (domain && !avahi_is_valid_domain_name(domain))
- return avahi_server_set_errno(s, AVAHI_ERR_INVALID_DOMAIN_NAME);
+ AVAHI_CHECK_VALIDITY(s, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
+ AVAHI_CHECK_VALIDITY(s, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
+ AVAHI_CHECK_VALIDITY(s, avahi_is_valid_service_name(name), AVAHI_ERR_INVALID_SERVICE_NAME);
+ AVAHI_CHECK_VALIDITY(s, avahi_is_valid_service_type_strict(type), AVAHI_ERR_INVALID_SERVICE_TYPE);
+ AVAHI_CHECK_VALIDITY(s, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME);
if ((ret = avahi_service_name_join(n, sizeof(n), name, type, domain) < 0))
return avahi_server_set_errno(s, ret);