X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;ds=sidebyside;f=avahi-core%2Fserver.c;h=6eedd6e8963d68a80af9c569f26d49e1d967b9fe;hb=2f56f8a0943f92d430c8f395880ace8f5922f85b;hp=02c343fafb57e29c53f031ebe56d4cc4a282ca44;hpb=ca05343f045a05f52141c920a53812c565d9d66c;p=catta diff --git a/avahi-core/server.c b/avahi-core/server.c index 02c343f..6eedd6e 100644 --- a/avahi-core/server.c +++ b/avahi-core/server.c @@ -1,5 +1,3 @@ -/* $Id$ */ - /*** This file is part of avahi. @@ -659,7 +657,6 @@ static void handle_response_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInter avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ARCOUNT); n > 0; n--) { AvahiRecord *record; int cache_flush = 0; -/* char *txt; */ if (!(record = avahi_dns_packet_consume_record(p, &cache_flush))) { avahi_log_warn(__FILE__": Packet too short or invalid while reading response record. (Maybe a UTF-8 problem?)"); @@ -669,7 +666,7 @@ static void handle_response_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInter if (!avahi_key_is_pattern(record->key)) { if (handle_conflict(s, i, record, cache_flush)) { - if (!from_local_iface) + if (!from_local_iface && !avahi_record_is_link_local_address(record)) reflect_response(s, i, record, cache_flush); avahi_cache_update(i->cache, record, cache_flush, a); avahi_response_scheduler_incoming(i->response_scheduler, record, cache_flush); @@ -680,7 +677,7 @@ static void handle_response_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInter } /* If the incoming response contained a conflicting record, some - records have been scheduling for sending. We need to flush them + records have been scheduled for sending. We need to flush them here. */ if (!avahi_record_list_is_empty(s->record_list)) avahi_server_generate_response(s, i, NULL, NULL, 0, 0, 1); @@ -844,7 +841,7 @@ static int originates_from_local_legacy_unicast_socket(AvahiServer *s, const Ava if (getsockname(s->fd_legacy_unicast_ipv4, (struct sockaddr*) &lsa, &l) != 0) avahi_log_warn("getsockname(): %s", strerror(errno)); else - return lsa.sin_port == port; + return avahi_port_from_sockaddr((struct sockaddr*) &lsa) == port; } @@ -855,7 +852,7 @@ static int originates_from_local_legacy_unicast_socket(AvahiServer *s, const Ava if (getsockname(s->fd_legacy_unicast_ipv6, (struct sockaddr*) &lsa, &l) != 0) avahi_log_warn("getsockname(): %s", strerror(errno)); else - return lsa.sin6_port == port; + return avahi_port_from_sockaddr((struct sockaddr*) &lsa) == port; } return 0; @@ -1009,13 +1006,6 @@ static void dispatch_legacy_unicast_packet(AvahiServer *s, AvahiDnsPacket *p) { avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_ID, slot->id); } -static void cleanup_dead(AvahiServer *s) { - assert(s); - - avahi_cleanup_dead_entries(s); - avahi_browser_cleanup(s); -} - static void mcast_socket_event(AvahiWatch *w, int fd, AvahiWatchEvent events, void *userdata) { AvahiServer *s = userdata; AvahiAddress dest, src; @@ -1044,11 +1034,11 @@ static void mcast_socket_event(AvahiWatch *w, int fd, AvahiWatchEvent events, vo if (iface != AVAHI_IF_UNSPEC) dispatch_packet(s, p, &src, port, &dest, iface, ttl); else - avahi_log_error("Incoming packet recieved on address that isn't local."); + avahi_log_error("Incoming packet received on address that isn't local."); avahi_dns_packet_free(p); - cleanup_dead(s); + avahi_cleanup_dead_entries(s); } } @@ -1071,7 +1061,7 @@ static void legacy_unicast_socket_event(AvahiWatch *w, int fd, AvahiWatchEvent e dispatch_legacy_unicast_packet(s, p); avahi_dns_packet_free(p); - cleanup_dead(s); + avahi_cleanup_dead_entries(s); } } @@ -1572,6 +1562,8 @@ AvahiServerConfig* avahi_server_config_init(AvahiServerConfig *c) { memset(c, 0, sizeof(AvahiServerConfig)); c->use_ipv6 = 1; c->use_ipv4 = 1; + c->allow_interfaces = NULL; + c->deny_interfaces = NULL; c->host_name = NULL; c->domain_name = NULL; c->check_response_ttl = 0; @@ -1601,11 +1593,13 @@ void avahi_server_config_free(AvahiServerConfig *c) { avahi_free(c->host_name); avahi_free(c->domain_name); avahi_string_list_free(c->browse_domains); + avahi_string_list_free(c->allow_interfaces); + avahi_string_list_free(c->deny_interfaces); } AvahiServerConfig* avahi_server_config_copy(AvahiServerConfig *ret, const AvahiServerConfig *c) { char *d = NULL, *h = NULL; - AvahiStringList *l = NULL; + AvahiStringList *browse = NULL, *allow = NULL, *deny = NULL; assert(ret); assert(c); @@ -1619,7 +1613,22 @@ AvahiServerConfig* avahi_server_config_copy(AvahiServerConfig *ret, const AvahiS return NULL; } - if (!(l = avahi_string_list_copy(c->browse_domains)) && c->browse_domains) { + if (!(browse = avahi_string_list_copy(c->browse_domains)) && c->browse_domains) { + avahi_free(h); + avahi_free(d); + return NULL; + } + + if (!(allow = avahi_string_list_copy(c->allow_interfaces)) && c->allow_interfaces) { + avahi_string_list_free(browse); + avahi_free(h); + avahi_free(d); + return NULL; + } + + if (!(deny = avahi_string_list_copy(c->deny_interfaces)) && c->deny_interfaces) { + avahi_string_list_free(allow); + avahi_string_list_free(browse); avahi_free(h); avahi_free(d); return NULL; @@ -1628,7 +1637,9 @@ AvahiServerConfig* avahi_server_config_copy(AvahiServerConfig *ret, const AvahiS *ret = *c; ret->host_name = h; ret->domain_name = d; - ret->browse_domains = l; + ret->browse_domains = browse; + ret->allow_interfaces = allow; + ret->deny_interfaces = deny; return ret; }