Lines Matching refs:r
65 static void finish(AvahiSServiceResolver *r, AvahiResolverEvent event) { in finish() argument
68 assert(r); in finish()
70 if (r->time_event) { in finish()
71 avahi_time_event_free(r->time_event); in finish()
72 r->time_event = NULL; in finish()
76 r->txt_flags | in finish()
77 r->srv_flags | in finish()
78 r->address_flags; in finish()
83 r->callback( in finish()
84 r, in finish()
85 r->interface, in finish()
86 r->protocol, in finish()
88 r->service_name, in finish()
89 r->service_type, in finish()
90 r->domain_name, in finish()
96 r->userdata); in finish()
105 assert(r->srv_record); in finish()
107 if (r->address_record) { in finish()
108 switch (r->address_record->key->type) { in finish()
111 a.data.ipv4 = r->address_record->data.a.address; in finish()
116 a.data.ipv6 = r->address_record->data.aaaa.address; in finish()
124 r->callback( in finish()
125 r, in finish()
126 r->interface, in finish()
127 r->protocol, in finish()
129 r->service_name, in finish()
130 r->service_type, in finish()
131 r->domain_name, in finish()
132 r->srv_record->data.srv.name, in finish()
133 r->address_record ? &a : NULL, in finish()
134 r->srv_record->data.srv.port, in finish()
135 r->txt_record ? r->txt_record->data.txt.string_list : NULL, in finish()
137 r->userdata); in finish()
145 AvahiSServiceResolver *r = userdata; in time_event_callback() local
148 assert(r); in time_event_callback()
150 avahi_server_set_errno(r->server, AVAHI_ERR_TIMEOUT); in time_event_callback()
151 finish(r, AVAHI_RESOLVER_FAILURE); in time_event_callback()
154 static void start_timeout(AvahiSServiceResolver *r) { in start_timeout() argument
156 assert(r); in start_timeout()
158 if (r->time_event) in start_timeout()
163 r->time_event = avahi_time_event_new(r->server->time_event_queue, &tv, time_event_callback, r); in start_timeout()
175 AvahiSServiceResolver *r = userdata; in record_browser_callback() local
178 assert(r); in record_browser_callback()
180 if (rr == r->record_browser_aaaa || rr == r->record_browser_a) in record_browser_callback()
181 r->address_flags = flags; in record_browser_callback()
182 else if (rr == r->record_browser_srv) in record_browser_callback()
183 r->srv_flags = flags; in record_browser_callback()
184 else if (rr == r->record_browser_txt) in record_browser_callback()
185 r->txt_flags = flags; in record_browser_callback()
193 if (r->interface > 0 && interface > 0 && interface != r->interface) in record_browser_callback()
196 …if (r->protocol != AVAHI_PROTO_UNSPEC && protocol != AVAHI_PROTO_UNSPEC && protocol != r->protocol) in record_browser_callback()
199 if (r->interface <= 0) in record_browser_callback()
200 r->interface = interface; in record_browser_callback()
202 if (r->protocol == AVAHI_PROTO_UNSPEC) in record_browser_callback()
203 r->protocol = protocol; in record_browser_callback()
207 if (!r->srv_record) { in record_browser_callback()
208 r->srv_record = avahi_record_ref(record); in record_browser_callback()
211 if (r->record_browser_a) { in record_browser_callback()
212 avahi_s_record_browser_free(r->record_browser_a); in record_browser_callback()
213 r->record_browser_a = NULL; in record_browser_callback()
216 if (r->record_browser_aaaa) { in record_browser_callback()
217 avahi_s_record_browser_free(r->record_browser_aaaa); in record_browser_callback()
218 r->record_browser_aaaa = NULL; in record_browser_callback()
221 if (!(r->user_flags & AVAHI_LOOKUP_NO_ADDRESS)) { in record_browser_callback()
223 … if (r->address_protocol == AVAHI_PROTO_INET || r->address_protocol == AVAHI_PROTO_UNSPEC) { in record_browser_callback()
224 … AvahiKey *k = avahi_key_new(r->srv_record->data.srv.name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_A); in record_browser_callback()
225 …r->record_browser_a = avahi_s_record_browser_new(r->server, r->interface, r->protocol, k, r->user_… in record_browser_callback()
229 … if (r->address_protocol == AVAHI_PROTO_INET6 || r->address_protocol == AVAHI_PROTO_UNSPEC) { in record_browser_callback()
230 …AvahiKey *k = avahi_key_new(r->srv_record->data.srv.name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_AAAA); in record_browser_callback()
231 …r->record_browser_aaaa = avahi_s_record_browser_new(r->server, r->interface, r->protocol, k, r->us… in record_browser_callback()
240 assert(!(r->user_flags & AVAHI_LOOKUP_NO_TXT)); in record_browser_callback()
242 if (!r->txt_record) { in record_browser_callback()
243 r->txt_record = avahi_record_ref(record); in record_browser_callback()
251 assert(!(r->user_flags & AVAHI_LOOKUP_NO_ADDRESS)); in record_browser_callback()
253 if (!r->address_record) { in record_browser_callback()
254 r->address_record = avahi_record_ref(record); in record_browser_callback()
265 r->srv_record && in record_browser_callback()
266 (r->txt_record || (r->user_flags & AVAHI_LOOKUP_NO_TXT)) && in record_browser_callback()
267 (r->address_record || (r->user_flags & AVAHI_LOOKUP_NO_ADDRESS))) in record_browser_callback()
268 finish(r, AVAHI_RESOLVER_FOUND); in record_browser_callback()
281 if (r->srv_record && avahi_record_equal_no_ttl(record, r->srv_record)) { in record_browser_callback()
282 avahi_record_unref(r->srv_record); in record_browser_callback()
283 r->srv_record = NULL; in record_browser_callback()
285 if (r->record_browser_a) { in record_browser_callback()
286 avahi_s_record_browser_free(r->record_browser_a); in record_browser_callback()
287 r->record_browser_a = NULL; in record_browser_callback()
290 if (r->record_browser_aaaa) { in record_browser_callback()
291 avahi_s_record_browser_free(r->record_browser_aaaa); in record_browser_callback()
292 r->record_browser_aaaa = NULL; in record_browser_callback()
296 avahi_s_record_browser_restart(r->record_browser_srv); in record_browser_callback()
297 start_timeout(r); in record_browser_callback()
304 assert(!(r->user_flags & AVAHI_LOOKUP_NO_TXT)); in record_browser_callback()
306 if (r->txt_record && avahi_record_equal_no_ttl(record, r->txt_record)) { in record_browser_callback()
307 avahi_record_unref(r->txt_record); in record_browser_callback()
308 r->txt_record = NULL; in record_browser_callback()
311 avahi_s_record_browser_restart(r->record_browser_txt); in record_browser_callback()
312 start_timeout(r); in record_browser_callback()
319 assert(!(r->user_flags & AVAHI_LOOKUP_NO_ADDRESS)); in record_browser_callback()
321 if (r->address_record && avahi_record_equal_no_ttl(record, r->address_record)) { in record_browser_callback()
322 avahi_record_unref(r->address_record); in record_browser_callback()
323 r->address_record = NULL; in record_browser_callback()
326 if (r->record_browser_aaaa) in record_browser_callback()
327 avahi_s_record_browser_restart(r->record_browser_aaaa); in record_browser_callback()
328 if (r->record_browser_a) in record_browser_callback()
329 avahi_s_record_browser_restart(r->record_browser_a); in record_browser_callback()
330 start_timeout(r); in record_browser_callback()
346 if (rr == r->record_browser_a && r->record_browser_aaaa) { in record_browser_callback()
348 avahi_s_record_browser_free(r->record_browser_a); in record_browser_callback()
349 r->record_browser_a = NULL; in record_browser_callback()
353 if (rr == r->record_browser_aaaa && r->record_browser_a) { in record_browser_callback()
355 avahi_s_record_browser_free(r->record_browser_aaaa); in record_browser_callback()
356 r->record_browser_aaaa = NULL; in record_browser_callback()
362 if (r->record_browser_srv) in record_browser_callback()
363 avahi_s_record_browser_free(r->record_browser_srv); in record_browser_callback()
364 if (r->record_browser_txt) in record_browser_callback()
365 avahi_s_record_browser_free(r->record_browser_txt); in record_browser_callback()
366 if (r->record_browser_a) in record_browser_callback()
367 avahi_s_record_browser_free(r->record_browser_a); in record_browser_callback()
368 if (r->record_browser_aaaa) in record_browser_callback()
369 avahi_s_record_browser_free(r->record_browser_aaaa); in record_browser_callback()
371 …r->record_browser_srv = r->record_browser_txt = r->record_browser_a = r->record_browser_aaaa = NUL… in record_browser_callback()
373 finish(r, AVAHI_RESOLVER_FAILURE); in record_browser_callback()
390 AvahiSServiceResolver *r; in avahi_s_service_resolver_new() local
415 if (!(r = avahi_new(AvahiSServiceResolver, 1))) { in avahi_s_service_resolver_new()
420 r->server = server; in avahi_s_service_resolver_new()
421 r->service_name = avahi_strdup(name); in avahi_s_service_resolver_new()
422 r->service_type = avahi_normalize_name_strdup(type); in avahi_s_service_resolver_new()
423 r->domain_name = avahi_normalize_name_strdup(domain); in avahi_s_service_resolver_new()
424 r->callback = callback; in avahi_s_service_resolver_new()
425 r->userdata = userdata; in avahi_s_service_resolver_new()
426 r->address_protocol = aprotocol; in avahi_s_service_resolver_new()
427 r->srv_record = r->txt_record = r->address_record = NULL; in avahi_s_service_resolver_new()
428 r->srv_flags = r->txt_flags = r->address_flags = 0; in avahi_s_service_resolver_new()
429 r->interface = interface; in avahi_s_service_resolver_new()
430 r->protocol = protocol; in avahi_s_service_resolver_new()
431 r->user_flags = flags; in avahi_s_service_resolver_new()
432 …r->record_browser_a = r->record_browser_aaaa = r->record_browser_srv = r->record_browser_txt = NUL… in avahi_s_service_resolver_new()
433 r->time_event = NULL; in avahi_s_service_resolver_new()
434 AVAHI_LLIST_PREPEND(AvahiSServiceResolver, resolver, server->service_resolvers, r); in avahi_s_service_resolver_new()
437 …r->record_browser_srv = avahi_s_record_browser_new(server, interface, protocol, k, flags & ~(AVAHI… in avahi_s_service_resolver_new()
440 if (!r->record_browser_srv) { in avahi_s_service_resolver_new()
441 avahi_s_service_resolver_free(r); in avahi_s_service_resolver_new()
447 …r->record_browser_txt = avahi_s_record_browser_new(server, interface, protocol, k, flags & ~(AVAHI… in avahi_s_service_resolver_new()
450 if (!r->record_browser_txt) { in avahi_s_service_resolver_new()
451 avahi_s_service_resolver_free(r); in avahi_s_service_resolver_new()
456 start_timeout(r); in avahi_s_service_resolver_new()
458 return r; in avahi_s_service_resolver_new()
461 void avahi_s_service_resolver_free(AvahiSServiceResolver *r) { in avahi_s_service_resolver_free() argument
462 assert(r); in avahi_s_service_resolver_free()
464 AVAHI_LLIST_REMOVE(AvahiSServiceResolver, resolver, r->server->service_resolvers, r); in avahi_s_service_resolver_free()
466 if (r->time_event) in avahi_s_service_resolver_free()
467 avahi_time_event_free(r->time_event); in avahi_s_service_resolver_free()
469 if (r->record_browser_srv) in avahi_s_service_resolver_free()
470 avahi_s_record_browser_free(r->record_browser_srv); in avahi_s_service_resolver_free()
471 if (r->record_browser_txt) in avahi_s_service_resolver_free()
472 avahi_s_record_browser_free(r->record_browser_txt); in avahi_s_service_resolver_free()
473 if (r->record_browser_a) in avahi_s_service_resolver_free()
474 avahi_s_record_browser_free(r->record_browser_a); in avahi_s_service_resolver_free()
475 if (r->record_browser_aaaa) in avahi_s_service_resolver_free()
476 avahi_s_record_browser_free(r->record_browser_aaaa); in avahi_s_service_resolver_free()
478 if (r->srv_record) in avahi_s_service_resolver_free()
479 avahi_record_unref(r->srv_record); in avahi_s_service_resolver_free()
480 if (r->txt_record) in avahi_s_service_resolver_free()
481 avahi_record_unref(r->txt_record); in avahi_s_service_resolver_free()
482 if (r->address_record) in avahi_s_service_resolver_free()
483 avahi_record_unref(r->address_record); in avahi_s_service_resolver_free()
485 avahi_free(r->service_name); in avahi_s_service_resolver_free()
486 avahi_free(r->service_type); in avahi_s_service_resolver_free()
487 avahi_free(r->domain_name); in avahi_s_service_resolver_free()
488 avahi_free(r); in avahi_s_service_resolver_free()