diff options
author | Lennart Poettering <lennart@poettering.net> | 2005-03-22 18:01:38 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2005-03-22 18:01:38 +0000 |
commit | 54247ce93dc6f048c0ffea546f454653ce0e25a8 (patch) | |
tree | c0ea9dfd389be853544df00711da288d698741ec /dns.c | |
parent | f0f4bb0c37eeed71934e3191cffa5afb1cfdca0d (diff) |
make the daemon response to queries
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@13 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'dns.c')
-rw-r--r-- | dns.c | 39 |
1 files changed, 38 insertions, 1 deletions
@@ -78,6 +78,31 @@ guint8* flx_dns_packet_append_uint16(flxDnsPacket *p, guint16 v) { return d; } +guint8 *flx_dns_packet_append_uint32(flxDnsPacket *p, guint32 v) { + guint8 *d; + + g_assert(p); + d = flx_dns_packet_extend(p, sizeof(guint32)); + *((guint32*) d) = g_htonl(v); + + return d; +} + +guint8 *flx_dns_packet_append_bytes(flxDnsPacket *p, gconstpointer b, guint l) { + guint8* d; + + g_assert(p); + g_assert(b); + g_assert(l); + + d = flx_dns_packet_extend(p, l); + g_assert(d); + memcpy(d, b, l); + + return d; +} + + guint8 *flx_dns_packet_extend(flxDnsPacket *p, guint l) { guint8 *d; @@ -321,6 +346,18 @@ guint8* flx_dns_packet_append_key(flxDnsPacket *p, flxKey *k) { } guint8* flx_dns_packet_append_record(flxDnsPacket *p, flxRecord *r, gboolean cache_flush) { + guint8 *t; - + g_assert(p); + g_assert(r); + + if (!(t = flx_dns_packet_append_name(p, r->key->name)) || + !flx_dns_packet_append_uint16(p, r->key->type) || + !flx_dns_packet_append_uint16(p, cache_flush ? (r->key->class | MDNS_CACHE_FLUSH) : (r->key->class &~ MDNS_CACHE_FLUSH)) || + !flx_dns_packet_append_uint32(p, r->ttl) || + !flx_dns_packet_append_uint16(p, r->size) || + !flx_dns_packet_append_bytes(p, r->data, r->size)) + return NULL; + + return t; } |