1 --- /usr/tmp/clean/avahi-0.6.28/avahi-core/browse.c 2010-08-26 01:51:38.983153000 +0100
2 +++ avahi-0.6.28/avahi-core/browse.c 2011-01-20 15:27:33.366236170 +0000
9 #include <avahi-common/timeval.h>
10 #include <avahi-common/malloc.h>
16 +static void resolve_socket_event(AvahiWatch *w, int fd, AvahiWatchEvent events,
18 + AvahiSRecordBrowser *b = userdata;
19 + DNSServiceErrorType ret;
20 + DNSServiceRef client;
24 + assert(events & AVAHI_WATCH_IN);
26 + assert (fd == DNSServiceRefSockFD(b->client));
28 + ret = DNSServiceProcessResult(b->client);
29 + if (ret != kDNSServiceErr_NoError) {
31 + b->server->poll_api->watch_free(b->watch);
34 + DNSServiceRefDeallocate(b->client);
36 + avahi_server_set_errno(b->server, AVAHI_ERR_DISCONNECTED);
37 + b->callback(b, b->interface, b->protocol, AVAHI_BROWSER_FAILURE, NULL, 0, b->userdata);
41 +static void resolve_error_callback(AvahiTimeEvent *e, void *userdata) {
42 + AvahiSRecordBrowser *b = userdata;
44 + if (b->defer_time_event) {
45 + avahi_time_event_free(b->defer_time_event);
46 + b->defer_time_event = NULL;
48 + avahi_server_set_errno(b->server, AVAHI_ERR_FAILURE);
50 + b, b->interface, b->protocol, AVAHI_BROWSER_FAILURE, NULL,
55 +static void browse_reply(DNSServiceRef client, DNSServiceFlags flags, uint32_t ifIndex, DNSServiceErrorType errorCode,
56 + const char *fullname, uint16_t rrtype, uint16_t rrclass, uint16_t rdlen, const void *rdata, uint32_t ttl, void *context) {
57 + AvahiSRecordBrowser *b = context;
61 + k = avahi_key_new(fullname, rrclass, rrtype);
62 + rr = avahi_record_new(k, ttl);
63 + if (avahi_rdata_parse(rr, rdata, rdlen) != 0) {
64 + printf("parse failed\n");
67 + b->callback(b, b->interface, b->protocol, AVAHI_BROWSER_NEW, rr, 0, b->userdata);
68 + avahi_record_unref(rr);
71 +static void avahi_browse_record_start(AvahiSRecordBrowser *b) {
72 + DNSServiceErrorType ret;
73 + DNSServiceFlags flags;
75 + if (b->flags != AVAHI_LOOKUP_USE_WIDE_AREA)
76 + flags = kDNSServiceFlagsForceMulticast;
80 + ret = DNSServiceQueryRecord(&b->client,
82 + b->interface == AVAHI_IF_UNSPEC ?
83 + kDNSServiceInterfaceIndexAny :
90 + if (ret != kDNSServiceErr_NoError || !b->client) {
91 + b->defer_time_event = avahi_time_event_new(b->server->time_event_queue,
92 +NULL, resolve_error_callback, b);
94 + b->defer_time_event = NULL;
95 + b->watch = b->server->poll_api->watch_new(b->server->poll_api, DNSServiceRefSockFD(b->client), AVAHI_WATCH_IN, resolve_socket_event, b);
100 AvahiSRecordBrowser *avahi_s_record_browser_new(
102 AvahiIfIndex interface,
105 AVAHI_LLIST_PREPEND(AvahiSRecordBrowser, browser, server->record_browsers, b);
110 + avahi_browse_record_start(b);
112 /* The currently cached entries are scanned a bit later, and than we will start querying, too */
113 b->defer_time_event = avahi_time_event_new(server->time_event_queue, NULL, defer_callback, b);
114 assert(b->defer_time_event);
120 b->server->need_browser_cleanup = 1;
125 + b->server->poll_api->watch_free(b->watch);
128 + DNSServiceRefDeallocate(b->client);
132 void avahi_s_record_browser_destroy(AvahiSRecordBrowser *b) {
135 if (server->wide_area_lookup_engine)
136 avahi_wide_area_cleanup(server->wide_area_lookup_engine);
137 +#ifndef HAVE_BONJOUR
138 avahi_multicast_lookup_engine_cleanup(server->multicast_lookup_engine);
142 --- /usr/tmp/clean/avahi-0.6.28/avahi-core/browse.h 2010-08-26 01:51:38.983153000 +0100
143 +++ avahi-0.6.28/avahi-core/browse.h 2011-01-21 09:33:14.663164775 +0000
147 AvahiSRBLookup *root_lookup;
150 + DNSServiceRef client;
156 void avahi_browser_cleanup(AvahiServer *server);