Lines Matching refs:l

107     AvahiWideAreaLookup *l;  in find_lookup()  local
112 if (!(l = avahi_hashmap_lookup(e->lookups_by_id, &i))) in find_lookup()
115 assert(l->id == id); in find_lookup()
117 if (l->dead) in find_lookup()
120 return l; in find_lookup()
123 static int send_to_dns_server(AvahiWideAreaLookup *l, AvahiDnsPacket *p) { in send_to_dns_server() argument
126 assert(l); in send_to_dns_server()
129 if (l->engine->n_dns_servers <= 0) in send_to_dns_server()
132 assert(l->engine->current_dns_server < l->engine->n_dns_servers); in send_to_dns_server()
134 a = &l->engine->dns_servers[l->engine->current_dns_server]; in send_to_dns_server()
135 l->dns_server_used = *a; in send_to_dns_server()
139 if (l->engine->fd_ipv4 < 0) in send_to_dns_server()
142 …return avahi_send_dns_packet_ipv4(l->engine->fd_ipv4, AVAHI_IF_UNSPEC, p, NULL, &a->data.ipv4, AVA… in send_to_dns_server()
147 if (l->engine->fd_ipv6 < 0) in send_to_dns_server()
150 …return avahi_send_dns_packet_ipv6(l->engine->fd_ipv6, AVAHI_IF_UNSPEC, p, NULL, &a->data.ipv6, AVA… in send_to_dns_server()
163 static void lookup_stop(AvahiWideAreaLookup *l) { in lookup_stop() argument
164 assert(l); in lookup_stop()
166 l->callback = NULL; in lookup_stop()
168 if (l->time_event) { in lookup_stop()
169 avahi_time_event_free(l->time_event); in lookup_stop()
170 l->time_event = NULL; in lookup_stop()
175 AvahiWideAreaLookup *l = userdata; in sender_timeout_callback() local
178 assert(l); in sender_timeout_callback()
181 …if (l->n_send >= 3 && avahi_address_cmp(&l->engine->dns_servers[l->engine->current_dns_server], &l in sender_timeout_callback()
182 next_dns_server(l->engine); in sender_timeout_callback()
184 …if (avahi_address_cmp(&l->engine->dns_servers[l->engine->current_dns_server], &l->dns_server_used)… in sender_timeout_callback()
186 l->n_send = 1000; in sender_timeout_callback()
189 if (l->n_send >= 6) { in sender_timeout_callback()
191 avahi_server_set_errno(l->engine->server, AVAHI_ERR_TIMEOUT); in sender_timeout_callback()
192l->callback(l->engine, AVAHI_BROWSER_FAILURE, AVAHI_LOOKUP_RESULT_WIDE_AREA, NULL, l->userdata); in sender_timeout_callback()
193 lookup_stop(l); in sender_timeout_callback()
197 assert(l->packet); in sender_timeout_callback()
198 send_to_dns_server(l, l->packet); in sender_timeout_callback()
199 l->n_send++; in sender_timeout_callback()
211 AvahiWideAreaLookup *l, *t; in avahi_wide_area_lookup_new() local
219 l = avahi_new(AvahiWideAreaLookup, 1); in avahi_wide_area_lookup_new()
220 l->engine = e; in avahi_wide_area_lookup_new()
221 l->dead = 0; in avahi_wide_area_lookup_new()
222 l->key = avahi_key_ref(key); in avahi_wide_area_lookup_new()
223 l->cname_key = avahi_key_new_cname(l->key); in avahi_wide_area_lookup_new()
224 l->callback = callback; in avahi_wide_area_lookup_new()
225 l->userdata = userdata; in avahi_wide_area_lookup_new()
234 l->id = e->next_id++; in avahi_wide_area_lookup_new()
237 l->packet = avahi_dns_packet_new(0); in avahi_wide_area_lookup_new()
239 avahi_dns_packet_set_field(l->packet, AVAHI_DNS_FIELD_ID, (uint16_t) l->id); in avahi_wide_area_lookup_new()
240 …avahi_dns_packet_set_field(l->packet, AVAHI_DNS_FIELD_FLAGS, AVAHI_DNS_FLAGS(0, 0, 0, 0, 1, 0, 0, … in avahi_wide_area_lookup_new()
242 p = avahi_dns_packet_append_key(l->packet, key, 0); in avahi_wide_area_lookup_new()
245 avahi_dns_packet_set_field(l->packet, AVAHI_DNS_FIELD_QDCOUNT, 1); in avahi_wide_area_lookup_new()
247 if (send_to_dns_server(l, l->packet) < 0) { in avahi_wide_area_lookup_new()
249 avahi_dns_packet_free(l->packet); in avahi_wide_area_lookup_new()
250 avahi_key_unref(l->key); in avahi_wide_area_lookup_new()
251 if (l->cname_key) in avahi_wide_area_lookup_new()
252 avahi_key_unref(l->cname_key); in avahi_wide_area_lookup_new()
253 avahi_free(l); in avahi_wide_area_lookup_new()
257 l->n_send = 1; in avahi_wide_area_lookup_new()
259l->time_event = avahi_time_event_new(e->server->time_event_queue, avahi_elapse_time(&tv, 500, 0), … in avahi_wide_area_lookup_new()
261 avahi_hashmap_insert(e->lookups_by_id, &l->id, l); in avahi_wide_area_lookup_new()
263 t = avahi_hashmap_lookup(e->lookups_by_key, l->key); in avahi_wide_area_lookup_new()
264 AVAHI_LLIST_PREPEND(AvahiWideAreaLookup, by_key, t, l); in avahi_wide_area_lookup_new()
265 avahi_hashmap_replace(e->lookups_by_key, avahi_key_ref(l->key), t); in avahi_wide_area_lookup_new()
267 AVAHI_LLIST_PREPEND(AvahiWideAreaLookup, lookups, e->lookups, l); in avahi_wide_area_lookup_new()
269 return l; in avahi_wide_area_lookup_new()
272 static void lookup_destroy(AvahiWideAreaLookup *l) { in lookup_destroy() argument
274 assert(l); in lookup_destroy()
276 lookup_stop(l); in lookup_destroy()
278 t = avahi_hashmap_lookup(l->engine->lookups_by_key, l->key); in lookup_destroy()
279 AVAHI_LLIST_REMOVE(AvahiWideAreaLookup, by_key, t, l); in lookup_destroy()
281 avahi_hashmap_replace(l->engine->lookups_by_key, avahi_key_ref(l->key), t); in lookup_destroy()
283 avahi_hashmap_remove(l->engine->lookups_by_key, l->key); in lookup_destroy()
285 AVAHI_LLIST_REMOVE(AvahiWideAreaLookup, lookups, l->engine->lookups, l); in lookup_destroy()
287 avahi_hashmap_remove(l->engine->lookups_by_id, &l->id); in lookup_destroy()
288 avahi_dns_packet_free(l->packet); in lookup_destroy()
290 if (l->key) in lookup_destroy()
291 avahi_key_unref(l->key); in lookup_destroy()
293 if (l->cname_key) in lookup_destroy()
294 avahi_key_unref(l->cname_key); in lookup_destroy()
296 avahi_free(l); in lookup_destroy()
299 void avahi_wide_area_lookup_free(AvahiWideAreaLookup *l) { in avahi_wide_area_lookup_free() argument
300 assert(l); in avahi_wide_area_lookup_free()
302 if (l->dead) in avahi_wide_area_lookup_free()
305 l->dead = 1; in avahi_wide_area_lookup_free()
306 l->engine->cleanup_dead = 1; in avahi_wide_area_lookup_free()
307 lookup_stop(l); in avahi_wide_area_lookup_free()
311 AvahiWideAreaLookup *l, *n; in avahi_wide_area_cleanup() local
317 for (l = e->lookups; l; l = n) { in avahi_wide_area_cleanup()
318 n = l->lookups_next; in avahi_wide_area_cleanup()
320 if (l->dead) in avahi_wide_area_cleanup()
321 lookup_destroy(l); in avahi_wide_area_cleanup()
371 AvahiWideAreaLookup *l; in run_callbacks() local
376 for (l = avahi_hashmap_lookup(e->lookups_by_key, r->key); l; l = l->by_key_next) { in run_callbacks()
377 if (l->dead || !l->callback) in run_callbacks()
380 l->callback(e, AVAHI_BROWSER_NEW, AVAHI_LOOKUP_RESULT_WIDE_AREA, r, l->userdata); in run_callbacks()
386 for (l = e->lookups; l; l = l->lookups_next) { in run_callbacks()
389 if (l->dead || !l->callback) in run_callbacks()
392 if ((key = avahi_key_new_cname(l->key))) { in run_callbacks()
394l->callback(e, AVAHI_BROWSER_NEW, AVAHI_LOOKUP_RESULT_WIDE_AREA, r, l->userdata); in run_callbacks()
481 AvahiWideAreaLookup *l = NULL; in handle_packet() local
496 if (!(l = find_lookup(e, avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ID))) || l->dead) in handle_packet()
545 if (l && !l->dead) { in handle_packet()
546 if (l->callback) in handle_packet()
547 l->callback(e, final_event, AVAHI_LOOKUP_RESULT_WIDE_AREA, NULL, l->userdata); in handle_packet()
549 lookup_stop(l); in handle_packet()