summaryrefslogtreecommitdiffstats
path: root/dns.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-03-31 23:31:11 +0000
committerLennart Poettering <lennart@poettering.net>2005-03-31 23:31:11 +0000
commitd553a1c2d1cd3fcdd65ade64940b5bd3efc70675 (patch)
tree5e240f9fcea9fdc77662df825f217107fbd95406 /dns.c
parent07b93a6d49a3252e3f5cacadd15083949241b071 (diff)
add client part of known answer suppresion
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@20 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'dns.c')
-rw-r--r--dns.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/dns.c b/dns.c
index 243c5a3..bed7344 100644
--- a/dns.c
+++ b/dns.c
@@ -409,29 +409,37 @@ flxKey* flx_dns_packet_consume_key(flxDnsPacket *p) {
guint8* flx_dns_packet_append_key(flxDnsPacket *p, flxKey *k) {
guint8 *t;
+ guint size;
g_assert(p);
g_assert(k);
+ size = p->size;
+
if (!(t = 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_append_uint16(p, k->class)) {
+ p->size = size;
return NULL;
+ }
return t;
}
guint8* flx_dns_packet_append_record(flxDnsPacket *p, flxRecord *r, gboolean cache_flush) {
guint8 *t;
+ guint size;
g_assert(p);
g_assert(r);
+ size = p->size;
+
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))
- return NULL;
+ goto fail;
switch (r->key->type) {
@@ -445,7 +453,7 @@ guint8* flx_dns_packet_append_record(flxDnsPacket *p, flxRecord *r, gboolean cac
if (!flx_dns_packet_append_uint16(p, strlen(ptr_name)+1) ||
!flx_dns_packet_append_name(p, ptr_name))
- return NULL;
+ goto fail;
break;
}
@@ -460,7 +468,7 @@ guint8* flx_dns_packet_append_record(flxDnsPacket *p, flxRecord *r, gboolean cac
if (!flx_dns_packet_append_uint16(p, strlen(name+6)+1+6) ||
!flx_dns_packet_append_bytes(p, r->data, 6) ||
!flx_dns_packet_append_name(p, name))
- return NULL;
+ goto fail;
break;
}
@@ -468,8 +476,19 @@ guint8* flx_dns_packet_append_record(flxDnsPacket *p, flxRecord *r, gboolean cac
default:
if (!flx_dns_packet_append_uint16(p, r->size) ||
(r->size != 0 && !flx_dns_packet_append_bytes(p, r->data, r->size)))
- return NULL;
+ goto fail;
}
return t;
+
+
+fail:
+ p->size = size;
+ return NULL;
+}
+
+gboolean flx_dns_packet_is_empty(flxDnsPacket *p) {
+ g_assert(p);
+
+ return p->size <= FLX_DNS_PACKET_HEADER_SIZE;
}