summaryrefslogtreecommitdiffstats
path: root/iface.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-01-21 22:08:15 +0000
committerLennart Poettering <lennart@poettering.net>2005-01-21 22:08:15 +0000
commit4ba1a4b0b4488e5058af67b789187735b529075e (patch)
treed1d0f8ee6c36659b552fc371cad67678ae90b7c8 /iface.c
parentb25580915c7223c276348c39d5e7ed496a58a26e (diff)
add infrastrtcur for creating and sending DNS packets
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@10 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'iface.c')
-rw-r--r--iface.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/iface.c b/iface.c
index 6ea7054..d3f4719 100644
--- a/iface.c
+++ b/iface.c
@@ -8,6 +8,8 @@
#include "iface.h"
#include "netlink.h"
+#include "dns.h"
+#include "socket.h"
static void update_address_rr(flxInterfaceMonitor *m, flxInterfaceAddress *a, int remove) {
g_assert(m);
@@ -343,6 +345,28 @@ int flx_address_is_relevant(flxInterfaceAddress *a) {
}
void flx_interface_send_query(flxInterface *i, guchar protocol, flxKey *k) {
+ flxDnsPacket *p;
g_assert(i);
g_assert(k);
+
+ p = flx_dns_packet_new();
+ flx_dns_packet_set_field(p, DNS_FIELD_FLAGS, DNS_FLAGS(0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
+
+ flx_dns_packet_append_name(p, k->name);
+ flx_dns_packet_append_uint16(p, k->type);
+ flx_dns_packet_append_uint16(p, k->class);
+
+ flx_dns_packet_set_field(p, DNS_FIELD_QDCOUNT, 1);
+
+ if ((protocol == AF_INET || protocol == AF_UNSPEC) && i->n_ipv4_addrs > 0 && flx_interface_is_relevant(i)) {
+ g_message("sending on '%s':IPv4", i->name);
+ flx_send_dns_packet_ipv4(i->monitor->server->fd_ipv4, i->index, p);
+ }
+
+ if ((protocol == AF_INET6 || protocol == AF_UNSPEC) && i->n_ipv6_addrs > 0 && flx_interface_is_relevant(i)) {
+ g_message("sending on '%s':IPv6", i->name);
+ flx_send_dns_packet_ipv6(i->monitor->server->fd_ipv6, i->index, p);
+ }
+
+ flx_dns_packet_free(p);
}