char *t = avahi_record_to_string(record);
if (won)
- avahi_log_debug("Recieved conflicting probe [%s]. Local host won.", t);
+ avahi_log_debug("Received conflicting probe [%s]. Local host won.", t);
else if (lost) {
- avahi_log_debug("Recieved conflicting probe [%s]. Local host lost. Withdrawing.", t);
+ avahi_log_debug("Received conflicting probe [%s]. Local host lost. Withdrawing.", t);
withdraw_rrset(s, record->key);
}
/* Refresh */
t = avahi_record_to_string(record);
- avahi_log_debug("Recieved goodbye record for one of our records [%s]. Refreshing.", t);
+ avahi_log_debug("Received goodbye record for one of our records [%s]. Refreshing.", t);
avahi_server_prepare_matching_responses(s, i, e->record->key, 0);
valid = 0;
/* Refresh */
t = avahi_record_to_string(record);
- avahi_log_debug("Recieved record with bad TTL [%s]. Refreshing.", t);
+ avahi_log_debug("Received record with bad TTL [%s]. Refreshing.", t);
avahi_server_prepare_matching_responses(s, i, e->record->key, 0);
valid = 0;
t = avahi_record_to_string(record);
if (withdraw_immediately) {
- avahi_log_debug("Recieved conflicting record [%s] with local record to be. Withdrawing.", t);
+ avahi_log_debug("Received conflicting record [%s] with local record to be. Withdrawing.", t);
withdraw_rrset(s, record->key);
} else {
assert(conflicting_entry);
- avahi_log_debug("Recieved conflicting record [%s]. Resetting our record.", t);
+ avahi_log_debug("Received conflicting record [%s]. Resetting our record.", t);
avahi_entry_return_to_initial_state(s, conflicting_entry, i);
/* Local unique records are returned to probing
AvahiDnsPacket *reply;
AvahiRecord *r;
- if (!(reply = avahi_dns_packet_new_reply(p, 512 /* unicast DNS maximum packet size is 512 */ , 1, 1)))
+ if (!(reply = avahi_dns_packet_new_reply(p, 512 + AVAHI_DNS_PACKET_EXTRA_SIZE /* unicast DNS maximum packet size is 512 */ , 1, 1)))
return; /* OOM */
while ((r = avahi_record_list_next(s->record_list, NULL, NULL, NULL))) {
* the specific header field, and return to the caller */
avahi_dns_packet_inc_field(reply, AVAHI_DNS_FIELD_ANCOUNT);
-
break;
}
avahi_dns_packet_free(reply);
size = avahi_record_get_estimate_size(r) + AVAHI_DNS_PACKET_HEADER_SIZE;
- if (size > AVAHI_DNS_PACKET_SIZE_MAX)
- size = AVAHI_DNS_PACKET_SIZE_MAX;
- if (!(reply = avahi_dns_packet_new_reply(p, size, 0, 1)))
+ if (!(reply = avahi_dns_packet_new_reply(p, size + AVAHI_DNS_PACKET_EXTRA_SIZE, 0, 1)))
break; /* OOM */
- if (!avahi_dns_packet_append_record(reply, r, flush_cache, 0)) {
+ if (avahi_dns_packet_append_record(reply, r, flush_cache, 0)) {
+
+ /* Appending this record succeeded, so incremeant
+ * the specific header field, and return to the caller */
+
+ avahi_dns_packet_inc_field(reply, AVAHI_DNS_FIELD_ANCOUNT);
+ break;
+
+ } else {
+
+ /* We completely fucked up, there's
+ * nothing we can do. The RR just doesn't
+ * fit in. Let's ignore it. */
+
char *t;
avahi_dns_packet_free(reply);
+ reply = NULL;
t = avahi_record_to_string(r);
avahi_log_warn("Record [%s] too large, doesn't fit in any packet!", t);
avahi_free(t);
break;
- } else
- avahi_dns_packet_inc_field(reply, AVAHI_DNS_FIELD_ANCOUNT);
+ }
}
/* Appending the record didn't succeeed, so let's send this packet, and create a new one */
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 a UTF-8 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 a UTF-8 problem?)");
goto fail;
}
- if (handle_conflict(s, i, record, unique)) {
- avahi_response_scheduler_suppress(i->response_scheduler, record, a);
- avahi_record_list_drop(s->record_list, record);
- avahi_cache_stop_poof(i->cache, record, a);
- }
+ avahi_response_scheduler_suppress(i->response_scheduler, record, a);
+ avahi_record_list_drop(s->record_list, record);
+ avahi_cache_stop_poof(i->cache, record, a);
avahi_record_unref(record);
}
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 a UTF-8 problem?)");
goto fail;
}
/* 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 a UTF-8 problem?)");
break;
}
avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_ID, slot->id);
for (j = s->monitor->interfaces; j; j = j->interface_next)
- if (avahi_interface_is_relevant(j) &&
+ if (j->announcing &&
j != i &&
(s->config.reflect_ipv || j->protocol == i->protocol)) {
assert(src_address->proto == dst_address->proto);
if (!(i = avahi_interface_monitor_get_interface(s->monitor, iface, src_address->proto)) ||
- !avahi_interface_is_relevant(i)) {
- avahi_log_warn("Recieved packet from invalid interface.");
+ !i->announcing) {
+ avahi_log_warn("Received packet from invalid interface.");
return;
}
from_local_iface = originates_from_local_iface(s, iface, src_address, port);
if (avahi_dns_packet_check_valid_multicast(p) < 0) {
- avahi_log_warn("Recieved invalid packet.");
+ avahi_log_warn("Received invalid packet.");
return;
}
} 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);
+ avahi_log_warn("Received response with invalid source port %u on interface '%s.%i'", port, i->hardware->name, i->protocol);
return;
}
if (ttl != 255 && s->config.check_response_ttl) {
- avahi_log_warn("Recieved response with invalid TTL %u on interface '%s.%i'.", ttl, i->hardware->name, i->protocol);
+ avahi_log_warn("Received response with invalid TTL %u on interface '%s.%i'.", ttl, i->hardware->name, i->protocol);
return;
}
assert(p);
if (avahi_dns_packet_check_valid(p) < 0 || avahi_dns_packet_is_query(p)) {
- avahi_log_warn("Recieved invalid packet.");
+ avahi_log_warn("Received invalid packet.");
return;
}
if (!(slot = find_slot(s, avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ID)))) {
- avahi_log_warn("Recieved legacy unicast response with unknown id");
+ avahi_log_warn("Received legacy unicast response with unknown id");
return;
}
if (!(j = avahi_interface_monitor_get_interface(s->monitor, slot->interface, slot->address.proto)) ||
- !avahi_interface_is_relevant(j))
+ !j->announcing)
return;
/* Patch the original ID into this response */
}
int avahi_server_set_host_name(AvahiServer *s, const char *host_name) {
+ char *hn = NULL;
assert(s);
- assert(host_name);
+
+ AVAHI_CHECK_VALIDITY(s, !host_name || avahi_is_valid_host_name(host_name), AVAHI_ERR_INVALID_HOST_NAME);
- if (host_name && !avahi_is_valid_host_name(host_name))
- return avahi_server_set_errno(s, AVAHI_ERR_INVALID_HOST_NAME);
+ if (!host_name) {
+ hn = avahi_get_host_name_strdup();
+ hn[strcspn(hn, ".")] = 0;
+ host_name = hn;
+ }
+ if (avahi_domain_equal(s->host_name, host_name) && s->state != AVAHI_SERVER_COLLISION) {
+ avahi_free(hn);
+ return avahi_server_set_errno(s, AVAHI_ERR_NO_CHANGE);
+ }
+
withdraw_host_rrs(s);
avahi_free(s->host_name);
- s->host_name = host_name ? avahi_normalize_name_strdup(host_name) : avahi_get_host_name_strdup();
- s->host_name[strcspn(s->host_name, ".")] = 0;
+ s->host_name = hn ? hn : avahi_strdup(host_name);
+
update_fqdn(s);
register_stuff(s);
}
int avahi_server_set_domain_name(AvahiServer *s, const char *domain_name) {
+ char *dn = NULL;
assert(s);
- assert(domain_name);
- if (domain_name && !avahi_is_valid_domain_name(domain_name))
- return avahi_server_set_errno(s, AVAHI_ERR_INVALID_DOMAIN_NAME);
+ AVAHI_CHECK_VALIDITY(s, !domain_name || avahi_is_valid_domain_name(domain_name), AVAHI_ERR_INVALID_DOMAIN_NAME);
+
+ if (!domain_name) {
+ dn = avahi_strdup("local");
+ domain_name = dn;
+ }
+
+ if (avahi_domain_equal(s->domain_name, domain_name)) {
+ avahi_free(dn);
+ return avahi_server_set_errno(s, AVAHI_ERR_NO_CHANGE);
+ }
withdraw_host_rrs(s);
avahi_free(s->domain_name);
- s->domain_name = domain_name ? avahi_normalize_name_strdup(domain_name) : avahi_strdup("local");
+ s->domain_name = avahi_normalize_name_strdup(domain_name);
update_fqdn(s);
register_stuff(s);
+
+ avahi_free(dn);
return AVAHI_OK;
}
static int valid_server_config(const AvahiServerConfig *sc) {
+ AvahiStringList *l;
+
+ assert(sc);
+ if (sc->n_wide_area_servers > AVAHI_WIDE_AREA_SERVERS_MAX)
+ return AVAHI_ERR_INVALID_CONFIG;
+
if (sc->host_name && !avahi_is_valid_host_name(sc->host_name))
return AVAHI_ERR_INVALID_HOST_NAME;
if (sc->domain_name && !avahi_is_valid_domain_name(sc->domain_name))
return AVAHI_ERR_INVALID_DOMAIN_NAME;
+ for (l = sc->browse_domains; l; l = l->next)
+ if (!avahi_is_valid_domain_name((char*) l->text))
+ return AVAHI_ERR_INVALID_DOMAIN_NAME;
+
return AVAHI_OK;
}
c->use_iff_running = 0;
c->enable_reflector = 0;
c->reflect_ipv = 0;
- c->add_service_cookie = 1;
+ c->add_service_cookie = 0;
c->enable_wide_area = 0;
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;
+ c->publish_aaaa_on_ipv4 = 1;
+ c->publish_a_on_ipv6 = 0;
return c;
}
avahi_wide_area_set_servers(s->wide_area_lookup_engine, a, n);
return AVAHI_OK;
}
+
+const AvahiServerConfig* avahi_server_get_config(AvahiServer *s) {
+ assert(s);
+
+ return &s->config;
+}
+
+/** Set the browsing domains */
+int avahi_server_set_browse_domains(AvahiServer *s, AvahiStringList *domains) {
+ AvahiStringList *l;
+
+ assert(s);
+
+ for (l = s->config.browse_domains; l; l = l->next)
+ if (!avahi_is_valid_domain_name((char*) l->text))
+ return avahi_server_set_errno(s, AVAHI_ERR_INVALID_DOMAIN_NAME);
+
+ avahi_string_list_free(s->config.browse_domains);
+ s->config.browse_domains = avahi_string_list_copy(domains);
+
+ return AVAHI_OK;
+}