]> git.meshlink.io Git - catta/blobdiff - avahi-core/browse.c
* rename all limit defs so that they end with _MAX
[catta] / avahi-core / browse.c
index 639a7cbe75c4f7503bb6f72382ef2bf1c621476d..5fd3a011b55f2f218ccdb3e7d11fe1dcbac1a4e5 100644 (file)
@@ -36,7 +36,7 @@
 #include "log.h"
 #include "querier.h"
 
-#define AVAHI_MAX_LOOKUPS_PER_BROWSER 15
+#define AVAHI_LOOKUPS_PER_BROWSER_MAX 15
 
 struct AvahiSRBLookup {
     AvahiSRecordBrowser *record_browser;
@@ -79,7 +79,6 @@ static void transport_flags_from_domain(AvahiServer *s, AvahiLookupFlags *flags,
         *flags |= AVAHI_LOOKUP_USE_WIDE_AREA;
 }
 
-
 static AvahiSRBLookup* lookup_new(
     AvahiSRecordBrowser *b,
     AvahiIfIndex interface,
@@ -93,7 +92,7 @@ static AvahiSRBLookup* lookup_new(
     assert(AVAHI_IF_VALID(interface));
     assert(AVAHI_PROTO_VALID(protocol));
 
-    if (b->n_lookups >= AVAHI_MAX_LOOKUPS_PER_BROWSER)
+    if (b->n_lookups >= AVAHI_LOOKUPS_PER_BROWSER_MAX)
         /* We don't like cyclic CNAMEs */
         return NULL;
     
@@ -180,6 +179,21 @@ static AvahiSRBLookup *lookup_find(
     return NULL;
 }
 
+static void browser_cancel(AvahiSRecordBrowser *b) {
+    assert(b);
+
+    if (b->root_lookup) {
+        lookup_unref(b->root_lookup);
+        b->root_lookup = NULL;
+    }
+
+    if (b->defer_time_event) {
+        avahi_time_event_free(b->defer_time_event);
+        b->defer_time_event = NULL;
+    }
+}
+
+
 static void lookup_wide_area_callback(
     AvahiWideAreaLookupEngine *e,
     AvahiBrowserEvent event,
@@ -266,6 +280,9 @@ static void lookup_multicast_callback(
                 /* It's a normal record, so let's call the user callback */
                 assert(avahi_key_equal(b->key, l->key));
 
+                if (avahi_server_is_record_local(b->server, interface, protocol, r))
+                    flags |= AVAHI_LOOKUP_RESULT_LOCAL;
+                
                 b->callback(b, interface, protocol, event, r, flags, b->userdata);
             }
             break;
@@ -469,7 +486,7 @@ static void defer_callback(AvahiTimeEvent *e, void *userdata) {
             b->flags & AVAHI_LOOKUP_USE_WIDE_AREA ? AVAHI_LOOKUP_RESULT_WIDE_AREA : AVAHI_LOOKUP_RESULT_MULTICAST,
             b->userdata);
         
-        avahi_s_record_browser_cancel(b);
+        browser_cancel(b);
         return;
     }
     
@@ -493,7 +510,7 @@ void avahi_s_record_browser_restart(AvahiSRecordBrowser *b) {
     assert(b);
     assert(!b->dead);
 
-    avahi_s_record_browser_cancel(b);
+    browser_cancel(b);
 
     /* Request a new iteration of the cache scanning */
     if (!b->defer_time_event) {
@@ -550,20 +567,6 @@ AvahiSRecordBrowser *avahi_s_record_browser_new(
     return b;
 }
 
-void avahi_s_record_browser_cancel(AvahiSRecordBrowser *b) {
-    assert(b);
-
-    if (b->root_lookup) {
-        lookup_unref(b->root_lookup);
-        b->root_lookup = NULL;
-    }
-
-    if (b->defer_time_event) {
-        avahi_time_event_free(b->defer_time_event);
-        b->defer_time_event = NULL;
-    }
-}
-
 void avahi_s_record_browser_free(AvahiSRecordBrowser *b) {
     assert(b);
     assert(!b->dead);
@@ -571,13 +574,13 @@ void avahi_s_record_browser_free(AvahiSRecordBrowser *b) {
     b->dead = 1;
     b->server->need_browser_cleanup = 1;
 
-    avahi_s_record_browser_cancel(b);
+    browser_cancel(b);
 }
 
 void avahi_s_record_browser_destroy(AvahiSRecordBrowser *b) {
     assert(b);
 
-    avahi_s_record_browser_cancel(b);
+    browser_cancel(b);
     
     AVAHI_LLIST_REMOVE(AvahiSRecordBrowser, browser, b->server->record_browsers, b);