]> git.meshlink.io Git - catta/blob - server.c
* improve dns.c testing program
[catta] / server.c
1 #include <sys/socket.h>
2 #include <arpa/inet.h>
3 #include <string.h>
4 #include <sys/utsname.h>
5 #include <unistd.h>
6
7 #include "server.h"
8 #include "util.h"
9 #include "iface.h"
10 #include "socket.h"
11 #include "subscribe.h"
12
13 static void handle_query_key(flxServer *s, flxKey *k, flxInterface *i, const flxAddress *a) {
14     flxServerEntry *e;
15     gchar *txt;
16     
17     g_assert(s);
18     g_assert(k);
19     g_assert(i);
20     g_assert(a);
21
22     g_message("Handling query: %s", txt = flx_key_to_string(k));
23     g_free(txt);
24
25     flx_packet_scheduler_incoming_query(i->scheduler, k);
26
27     if (k->type == FLX_DNS_TYPE_ANY) {
28
29         /* Handle ANY query */
30         
31         for (e = s->entries; e; e = e->entry_next)
32             if (flx_key_pattern_match(k, e->record->key))
33                 if (flx_interface_match(i, e->interface, e->protocol) && flx_entry_established(s, e, i))
34                     flx_interface_post_response(i, a, e->record, e->flags & FLX_SERVER_ENTRY_UNIQUE, FALSE);
35     } else {
36
37         /* Handle all other queries */
38         
39         for (e = g_hash_table_lookup(s->rrset_by_key, k); e; e = e->by_key_next)
40             if (flx_interface_match(i, e->interface, e->protocol) && flx_entry_established(s, e, i))
41                 flx_interface_post_response(i, a, e->record, e->flags & FLX_SERVER_ENTRY_UNIQUE, FALSE);
42     }
43 }
44
45 static void handle_query(flxServer *s, flxDnsPacket *p, flxInterface *i, const flxAddress *a) {
46     guint n;
47     
48     g_assert(s);
49     g_assert(p);
50     g_assert(i);
51     g_assert(a);
52
53     for (n = flx_dns_packet_get_field(p, FLX_DNS_FIELD_QDCOUNT); n > 0; n --) {
54         flxKey *key;
55
56         if (!(key = flx_dns_packet_consume_key(p))) {
57             g_warning("Packet too short");
58             return;
59         }
60
61         handle_query_key(s, key, i, a);
62         flx_key_unref(key);
63     }
64
65     /* Known Answer Suppresion */
66     for (n = flx_dns_packet_get_field(p, FLX_DNS_FIELD_ANCOUNT); n > 0; n --) {
67         flxRecord *record;
68         gboolean unique = FALSE;
69
70         if (!(record = flx_dns_packet_consume_record(p, &unique))) {
71             g_warning("Packet too short (2)");
72             return;
73         }
74
75         flx_packet_scheduler_incoming_known_answer(i->scheduler, record, a);
76         flx_record_unref(record);
77     }
78 }
79
80 static void handle_response(flxServer *s, flxDnsPacket *p, flxInterface *i, const flxAddress *a) {
81     guint n;
82     
83     g_assert(s);
84     g_assert(p);
85     g_assert(i);
86     g_assert(a);
87     
88     for (n = flx_dns_packet_get_field(p, FLX_DNS_FIELD_ANCOUNT) +
89              flx_dns_packet_get_field(p, FLX_DNS_FIELD_ARCOUNT); n > 0; n--) {
90         flxRecord *record;
91         gboolean cache_flush = FALSE;
92         gchar *txt;
93         
94         if (!(record = flx_dns_packet_consume_record(p, &cache_flush))) {
95             g_warning("Packet too short (3)");
96             return;
97         }
98
99         if (record->key->type == FLX_DNS_TYPE_ANY)
100             continue;
101         
102         g_message("Handling response: %s", txt = flx_record_to_string(record));
103         g_free(txt);
104         
105         flx_cache_update(i->cache, record, cache_flush, a);
106         
107         flx_packet_scheduler_incoming_response(i->scheduler, record);
108         flx_record_unref(record);
109     }
110 }
111
112 static void dispatch_packet(flxServer *s, flxDnsPacket *p, struct sockaddr *sa, gint iface, gint ttl) {
113     flxInterface *i;
114     flxAddress a;
115     
116     g_assert(s);
117     g_assert(p);
118     g_assert(sa);
119     g_assert(iface > 0);
120
121     g_message("new packet recieved.");
122
123     if (!(i = flx_interface_monitor_get_interface(s->monitor, iface, sa->sa_family))) {
124         g_warning("Recieved packet from invalid interface.");
125         return;
126     }
127
128     if (ttl != 255) {
129         g_warning("Recieved packet with invalid TTL on interface '%s.%i'.", i->hardware->name, i->protocol);
130         return;
131     }
132
133     if (sa->sa_family == AF_INET6) {
134         static const unsigned char ipv4_in_ipv6[] = {
135             0x00, 0x00, 0x00, 0x00,
136             0x00, 0x00, 0x00, 0x00,
137             0xFF, 0xFF, 0xFF, 0xFF };
138
139         if (memcmp(((struct sockaddr_in6*) sa)->sin6_addr.s6_addr, ipv4_in_ipv6, sizeof(ipv4_in_ipv6)) == 0) {
140
141             /* This is an IPv4 address encapsulated in IPv6, so let's ignore it. */
142             return;
143         }
144     }
145
146     if (flx_dns_packet_check_valid(p) < 0) {
147         g_warning("Recieved invalid packet.");
148         return;
149     }
150
151     flx_address_from_sockaddr(sa, &a);
152
153     if (flx_dns_packet_is_query(p)) {
154
155         if (flx_dns_packet_get_field(p, FLX_DNS_FIELD_QDCOUNT) == 0 ||
156             flx_dns_packet_get_field(p, FLX_DNS_FIELD_ARCOUNT) != 0) {
157             g_warning("Invalid query packet.");
158             return;
159         }
160                 
161         handle_query(s, p, i, &a);    
162         g_message("Handled query");
163     } else {
164         if (flx_dns_packet_get_field(p, FLX_DNS_FIELD_QDCOUNT) != 0 ||
165             flx_dns_packet_get_field(p, FLX_DNS_FIELD_ANCOUNT) == 0 ||
166             flx_dns_packet_get_field(p, FLX_DNS_FIELD_NSCOUNT) != 0) {
167             g_warning("Invalid response packet.");
168             return;
169         }
170
171         handle_response(s, p, i, &a);
172         g_message("Handled response");
173     }
174 }
175
176 static gboolean work(flxServer *s) {
177     struct sockaddr_in6 sa6;
178     struct sockaddr_in sa;
179     flxDnsPacket *p;
180     gint iface = -1;
181     guint8 ttl;
182         
183     g_assert(s);
184
185     if (s->pollfd_ipv4.revents & G_IO_IN) {
186         if ((p = flx_recv_dns_packet_ipv4(s->fd_ipv4, &sa, &iface, &ttl))) {
187             dispatch_packet(s, p, (struct sockaddr*) &sa, iface, ttl);
188             flx_dns_packet_free(p);
189         }
190     }
191
192     if (s->pollfd_ipv6.revents & G_IO_IN) {
193         if ((p = flx_recv_dns_packet_ipv6(s->fd_ipv6, &sa6, &iface, &ttl))) {
194             dispatch_packet(s, p, (struct sockaddr*) &sa6, iface, ttl);
195             flx_dns_packet_free(p);
196         }
197     }
198
199     return TRUE;
200 }
201
202 static gboolean prepare_func(GSource *source, gint *timeout) {
203     g_assert(source);
204     g_assert(timeout);
205     
206     *timeout = -1;
207     return FALSE;
208 }
209
210 static gboolean check_func(GSource *source) {
211     flxServer* s;
212     g_assert(source);
213
214     s = *((flxServer**) (((guint8*) source) + sizeof(GSource)));
215     g_assert(s);
216     
217     return (s->pollfd_ipv4.revents | s->pollfd_ipv6.revents) & (G_IO_IN | G_IO_HUP | G_IO_ERR);
218 }
219
220 static gboolean dispatch_func(GSource *source, GSourceFunc callback, gpointer user_data) {
221     flxServer* s;
222     g_assert(source);
223
224     s = *((flxServer**) (((guint8*) source) + sizeof(GSource)));
225     g_assert(s);
226     
227     return work(s);
228 }
229
230 static void add_default_entries(flxServer *s) {
231     gint length = 0;
232     struct utsname utsname;
233     gchar *hinfo;
234     flxAddress a;
235     flxRecord *r;
236     
237     g_assert(s);
238     
239     /* Fill in HINFO rr */
240     r = flx_record_new_full(s->hostname, FLX_DNS_CLASS_IN, FLX_DNS_TYPE_HINFO);
241     uname(&utsname);
242     r->data.hinfo.cpu = g_strdup(g_strup(utsname.machine));
243     r->data.hinfo.os = g_strdup(g_strup(utsname.sysname));
244     flx_server_add(s, 0, 0, AF_UNSPEC, FLX_SERVER_ENTRY_UNIQUE, r);
245     flx_record_unref(r);
246
247     /* Add localhost entries */
248     flx_address_parse("127.0.0.1", AF_INET, &a);
249     flx_server_add_address(s, 0, 0, AF_UNSPEC, FLX_SERVER_ENTRY_UNIQUE|FLX_SERVER_ENTRY_NOPROBE|FLX_SERVER_ENTRY_NOANNOUNCE, "localhost", &a);
250
251     flx_address_parse("::1", AF_INET6, &a);
252     flx_server_add_address(s, 0, 0, AF_UNSPEC, FLX_SERVER_ENTRY_UNIQUE|FLX_SERVER_ENTRY_NOPROBE|FLX_SERVER_ENTRY_NOANNOUNCE, "ip6-localhost", &a);
253 }
254
255 flxServer *flx_server_new(GMainContext *c) {
256     gchar *hn, *e;
257     flxServer *s;
258     
259     static GSourceFuncs source_funcs = {
260         prepare_func,
261         check_func,
262         dispatch_func,
263         NULL,
264         NULL,
265         NULL
266     };
267
268     s = g_new(flxServer, 1);
269
270     s->fd_ipv4 = flx_open_socket_ipv4();
271     s->fd_ipv6 = flx_open_socket_ipv6();
272     
273     if (s->fd_ipv6 < 0 && s->fd_ipv4 < 0) {
274         g_critical("Failed to create sockets.\n");
275         g_free(s);
276         return NULL;
277     }
278
279     if (s->fd_ipv4 < 0)
280         g_message("Failed to create IPv4 socket, proceeding in IPv6 only mode");
281     else if (s->fd_ipv6 < 0)
282         g_message("Failed to create IPv6 socket, proceeding in IPv4 only mode");
283     
284     if (c)
285         g_main_context_ref(s->context = c);
286     else
287         s->context = g_main_context_default();
288     
289     s->current_id = 1;
290
291     FLX_LLIST_HEAD_INIT(flxServerEntry, s->entries);
292     s->rrset_by_id = g_hash_table_new(g_int_hash, g_int_equal);
293     s->rrset_by_key = g_hash_table_new((GHashFunc) flx_key_hash, (GEqualFunc) flx_key_equal);
294
295     FLX_LLIST_HEAD_INIT(flxSubscription, s->subscriptions);
296     s->subscription_hashtable = g_hash_table_new((GHashFunc) flx_key_hash, (GEqualFunc) flx_key_equal);
297
298     s->monitor = flx_interface_monitor_new(s);
299     s->time_event_queue = flx_time_event_queue_new(s->context);
300     
301     /* Get host name */
302     hn = flx_get_host_name();
303     hn[strcspn(hn, ".")] = 0;
304
305     s->hostname = g_strdup_printf("%s.local.", hn);
306     g_free(hn);
307
308     add_default_entries(s);
309
310     s->source = g_source_new(&source_funcs, sizeof(GSource) + sizeof(flxServer*));
311     *((flxServer**) (((guint8*) s->source) + sizeof(GSource))) = s;
312
313     memset(&s->pollfd_ipv4, 0, sizeof(s->pollfd_ipv4));
314     s->pollfd_ipv4.fd = s->fd_ipv4;
315     s->pollfd_ipv4.events = G_IO_IN|G_IO_ERR|G_IO_HUP;
316     g_source_add_poll(s->source, &s->pollfd_ipv4);
317     
318     memset(&s->pollfd_ipv6, 0, sizeof(s->pollfd_ipv6));
319     s->pollfd_ipv6.fd = s->fd_ipv6;
320     s->pollfd_ipv6.events = G_IO_IN|G_IO_ERR|G_IO_HUP;
321     g_source_add_poll(s->source, &s->pollfd_ipv6);
322
323     g_source_attach(s->source, s->context);
324     
325     return s;
326 }
327
328 void flx_server_free(flxServer* s) {
329     g_assert(s);
330
331     flx_interface_monitor_free(s->monitor);
332     
333     flx_server_remove(s, 0);
334
335     while (s->subscriptions)
336         flx_subscription_free(s->subscriptions);
337     g_hash_table_destroy(s->subscription_hashtable);
338     
339     g_hash_table_destroy(s->rrset_by_id);
340     g_hash_table_destroy(s->rrset_by_key);
341
342     flx_time_event_queue_free(s->time_event_queue);
343
344     if (s->fd_ipv4 >= 0)
345         close(s->fd_ipv4);
346     if (s->fd_ipv6 >= 0)
347         close(s->fd_ipv6);
348     
349     g_free(s->hostname);
350
351     g_source_destroy(s->source);
352     g_source_unref(s->source);
353     g_main_context_unref(s->context);
354
355     g_free(s);
356 }
357
358 gint flx_server_get_next_id(flxServer *s) {
359     g_assert(s);
360
361     return s->current_id++;
362 }
363
364 void flx_server_add(
365     flxServer *s,
366     gint id,
367     gint interface,
368     guchar protocol,
369     flxServerEntryFlags flags,
370     flxRecord *r) {
371     
372     flxServerEntry *e, *t;
373     g_assert(s);
374     g_assert(r);
375
376     g_assert(r->key->type != FLX_DNS_TYPE_ANY);
377
378     e = g_new(flxServerEntry, 1);
379     e->record = flx_record_ref(r);
380     e->id = id;
381     e->interface = interface;
382     e->protocol = protocol;
383     e->flags = flags;
384
385     FLX_LLIST_HEAD_INIT(flxAnnouncement, e->announcements);
386
387     FLX_LLIST_PREPEND(flxServerEntry, entry, s->entries, e);
388
389     /* Insert into hash table indexed by id */
390     t = g_hash_table_lookup(s->rrset_by_id, &e->id);
391     FLX_LLIST_PREPEND(flxServerEntry, by_id, t, e);
392     g_hash_table_replace(s->rrset_by_id, &e->id, t);
393     
394     /* Insert into hash table indexed by name */
395     t = g_hash_table_lookup(s->rrset_by_key, e->record->key);
396     FLX_LLIST_PREPEND(flxServerEntry, by_key, t, e);
397     g_hash_table_replace(s->rrset_by_key, e->record->key, t);
398
399     flx_announce_entry(s, e);
400 }
401 const flxRecord *flx_server_iterate(flxServer *s, gint id, void **state) {
402     flxServerEntry **e = (flxServerEntry**) state;
403     g_assert(s);
404     g_assert(e);
405
406     if (e)
407         *e = id > 0 ? (*e)->by_id_next : (*e)->entry_next;
408     else
409         *e = id > 0 ? g_hash_table_lookup(s->rrset_by_id, &id) : s->entries;
410         
411     if (!*e)
412         return NULL;
413
414     return flx_record_ref((*e)->record);
415 }
416
417 static void free_entry(flxServer*s, flxServerEntry *e) {
418     flxServerEntry *t;
419     
420     g_assert(e);
421
422     flx_goodbye_entry(s, e, TRUE);
423
424     /* Remove from linked list */
425     FLX_LLIST_REMOVE(flxServerEntry, entry, s->entries, e);
426
427     /* Remove from hash table indexed by id */
428     t = g_hash_table_lookup(s->rrset_by_id, &e->id);
429     FLX_LLIST_REMOVE(flxServerEntry, by_id, t, e);
430     if (t)
431         g_hash_table_replace(s->rrset_by_id, &t->id, t);
432     else
433         g_hash_table_remove(s->rrset_by_id, &e->id);
434     
435     /* Remove from hash table indexed by name */
436     t = g_hash_table_lookup(s->rrset_by_key, e->record->key);
437     FLX_LLIST_REMOVE(flxServerEntry, by_key, t, e);
438     if (t)
439         g_hash_table_replace(s->rrset_by_key, t->record->key, t);
440     else
441         g_hash_table_remove(s->rrset_by_key, e->record->key);
442
443     flx_record_unref(e->record);
444     g_free(e);
445 }
446
447 void flx_server_remove(flxServer *s, gint id) {
448     g_assert(s);
449
450     if (id <= 0) {
451         while (s->entries)
452             free_entry(s, s->entries);
453     } else {
454         flxServerEntry *e;
455
456         while ((e = g_hash_table_lookup(s->rrset_by_id, &id)))
457             free_entry(s, e);
458     }
459 }
460
461 void flx_server_dump(flxServer *s, FILE *f) {
462     flxServerEntry *e;
463     g_assert(s);
464     g_assert(f);
465
466     fprintf(f, "\n;;; ZONE DUMP FOLLOWS ;;;\n");
467
468     for (e = s->entries; e; e = e->entry_next) {
469         gchar *t;
470
471         t = flx_record_to_string(e->record);
472         fprintf(f, "%s\n", t);
473         g_free(t);
474     }
475
476     flx_dump_caches(s->monitor, f);
477 }
478
479 void flx_server_add_ptr(
480     flxServer *s,
481     gint id,
482     gint interface,
483     guchar protocol,
484     flxServerEntryFlags flags,
485     const gchar *name,
486     const gchar *dest) {
487
488     flxRecord *r;
489
490     g_assert(dest);
491
492     r = flx_record_new_full(name ? name : s->hostname, FLX_DNS_CLASS_IN, FLX_DNS_TYPE_PTR);
493     r->data.ptr.name = flx_normalize_name(dest);
494     flx_server_add(s, id, interface, protocol, flags, r);
495     flx_record_unref(r);
496
497 }
498
499 void flx_server_add_address(
500     flxServer *s,
501     gint id,
502     gint interface,
503     guchar protocol,
504     flxServerEntryFlags flags,
505     const gchar *name,
506     flxAddress *a) {
507
508     gchar *n = NULL;
509     g_assert(s);
510     g_assert(a);
511
512     name = name ? (n = flx_normalize_name(name)) : s->hostname;
513     
514     if (a->family == AF_INET) {
515         gchar *reverse;
516         flxRecord  *r;
517
518         r = flx_record_new_full(name, FLX_DNS_CLASS_IN, FLX_DNS_TYPE_A);
519         r->data.a.address = a->data.ipv4;
520         flx_server_add(s, id, interface, protocol, flags, r);
521         flx_record_unref(r);
522         
523         reverse = flx_reverse_lookup_name_ipv4(&a->data.ipv4);
524         g_assert(reverse);
525         flx_server_add_ptr(s, id, interface, protocol, flags, reverse, name);
526         g_free(reverse);
527         
528     } else {
529         gchar *reverse;
530         flxRecord *r;
531             
532         r = flx_record_new_full(name, FLX_DNS_CLASS_IN, FLX_DNS_TYPE_AAAA);
533         r->data.aaaa.address = a->data.ipv6;
534         flx_server_add(s, id, interface, protocol, flags, r);
535         flx_record_unref(r);
536
537         reverse = flx_reverse_lookup_name_ipv6_arpa(&a->data.ipv6);
538         g_assert(reverse);
539         flx_server_add_ptr(s, id, interface, protocol, flags, reverse, name);
540         g_free(reverse);
541     
542         reverse = flx_reverse_lookup_name_ipv6_int(&a->data.ipv6);
543         g_assert(reverse);
544         flx_server_add_ptr(s, id, interface, protocol, flags, reverse, name);
545         g_free(reverse);
546     }
547     
548     g_free(n);
549 }
550
551 void flx_server_add_text_va(
552     flxServer *s,
553     gint id,
554     gint interface,
555     guchar protocol,
556     flxServerEntryFlags flags,
557     const gchar *name,
558     va_list va) {
559
560     flxRecord *r;
561     
562     g_assert(s);
563     
564     r = flx_record_new_full(name ? name : s->hostname, FLX_DNS_CLASS_IN, FLX_DNS_TYPE_TXT);
565     r->data.txt.string_list = flx_string_list_new_va(va);
566     flx_server_add(s, id, interface, protocol, flags, r);
567     flx_record_unref(r);
568 }
569
570 void flx_server_add_text(
571     flxServer *s,
572     gint id,
573     gint interface,
574     guchar protocol,
575     flxServerEntryFlags flags,
576     const gchar *name,
577     ...) {
578
579     va_list va;
580     
581     g_assert(s);
582
583     va_start(va, name);
584     flx_server_add_text_va(s, id, interface, protocol, flags, name, va);
585     va_end(va);
586 }
587
588 static void escape_service_name(gchar *d, guint size, const gchar *s) {
589     g_assert(d);
590     g_assert(size);
591     g_assert(s);
592
593     while (*s && size >= 2) {
594         if (*s == '.' || *s == '\\') {
595             if (size < 3)
596                 break;
597
598             *(d++) = '\\';
599             size--;
600         }
601             
602         *(d++) = *(s++);
603         size--;
604     }
605
606     g_assert(size > 0);
607     *(d++) = 0;
608 }
609
610
611 void flx_server_add_service_va(
612     flxServer *s,
613     gint id,
614     gint interface,
615     guchar protocol,
616     const gchar *type,
617     const gchar *name,
618     const gchar *domain,
619     const gchar *host,
620     guint16 port,
621     va_list va) {
622
623     gchar ptr_name[256], svc_name[256], ename[64], enum_ptr[256];
624     flxRecord *r;
625     
626     g_assert(s);
627     g_assert(type);
628     g_assert(name);
629
630     escape_service_name(ename, sizeof(ename), name);
631
632     if (domain) {
633         while (domain[0] == '.')
634             domain++;
635     } else
636         domain = "local";
637
638     if (!host)
639         host = s->hostname;
640
641     snprintf(ptr_name, sizeof(ptr_name), "%s.%s", type, domain);
642     snprintf(svc_name, sizeof(svc_name), "%s.%s.%s", ename, type, domain);
643     
644     flx_server_add_ptr(s, id, interface, protocol, FALSE, ptr_name, svc_name);
645
646     r = flx_record_new_full(svc_name, FLX_DNS_CLASS_IN, FLX_DNS_TYPE_SRV);
647     r->data.srv.priority = 0;
648     r->data.srv.weight = 0;
649     r->data.srv.port = port;
650     r->data.srv.name = flx_normalize_name(host);
651     flx_server_add(s, id, interface, protocol, TRUE, r);
652     flx_record_unref(r);
653
654     flx_server_add_text_va(s, id, interface, protocol, FALSE, svc_name, va);
655
656     snprintf(enum_ptr, sizeof(enum_ptr), "_services._dns-sd._udp.%s", domain);
657     flx_server_add_ptr(s, id, interface, protocol, FALSE, enum_ptr, ptr_name);
658 }
659
660 void flx_server_add_service(
661     flxServer *s,
662     gint id,
663     gint interface,
664     guchar protocol,
665     const gchar *type,
666     const gchar *name,
667     const gchar *domain,
668     const gchar *host,
669     guint16 port,
670     ... ){
671
672     va_list va;
673     
674     g_assert(s);
675     g_assert(type);
676     g_assert(name);
677
678     va_start(va, port);
679     flx_server_add_service_va(s, id, interface, protocol, type, name, domain, host, port, va);
680     va_end(va);
681 }
682
683 static void post_query_callback(flxInterfaceMonitor *m, flxInterface *i, gpointer userdata) {
684     flxKey *k = userdata;
685
686     g_assert(m);
687     g_assert(i);
688     g_assert(k);
689
690     flx_interface_post_query(i, k, FALSE);
691 }
692
693 void flx_server_post_query(flxServer *s, gint interface, guchar protocol, flxKey *key) {
694     g_assert(s);
695     g_assert(key);
696
697     flx_interface_monitor_walk(s->monitor, interface, protocol, post_query_callback, key);
698 }
699
700 struct tmpdata {
701     flxRecord *record;
702     gboolean flush_cache;
703 };
704
705 static void post_response_callback(flxInterfaceMonitor *m, flxInterface *i, gpointer userdata) {
706     struct tmpdata *tmpdata = userdata;
707
708     g_assert(m);
709     g_assert(i);
710     g_assert(tmpdata);
711
712     flx_interface_post_response(i, NULL, tmpdata->record, tmpdata->flush_cache, FALSE);
713 }
714
715 void flx_server_post_response(flxServer *s, gint interface, guchar protocol, flxRecord *record, gboolean flush_cache) {
716     struct tmpdata tmpdata;
717     
718     g_assert(s);
719     g_assert(record);
720
721     tmpdata.record = record;
722     tmpdata.flush_cache = flush_cache;
723
724     flx_interface_monitor_walk(s->monitor, interface, protocol, post_response_callback, &tmpdata);
725 }