From 6f5b69ea24985a79ab8656a54a1c051cb3f33631 Mon Sep 17 00:00:00 2001 From: Federico Lucifredi Date: Mon, 14 Jan 2008 03:46:13 +0000 Subject: deletion now functional, but needs tweaking. git-svn-id: file:///home/lennart/svn/public/avahi/branches/federico@1710 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- avahi-core/announce.c | 2 +- avahi-core/rr.h | 1 + avahi-core/wide-area.c | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) (limited to 'avahi-core') diff --git a/avahi-core/announce.c b/avahi-core/announce.c index 0e920e8..80789a0 100644 --- a/avahi-core/announce.c +++ b/avahi-core/announce.c @@ -521,7 +521,7 @@ void avahi_goodbye_entry(AvahiServer *s, AvahiEntry *e, int send_goodbye, int re /* tracing message for wide-area pub development */ printf("--- record of type %d named %s observed at exitpoint\n", e->record->key->type, e->record->key->name); - avahi_wide_area_publish(r, "dynamic.endorfine.org", s->wide_area_lookup_engine->next_id++, s->wide_area_lookup_engine->fd_ipv4, AVAHI_WIDEAREA_DELETE); + avahi_wide_area_publish(e->record, "dynamic.endorfine.org", s->wide_area_lookup_engine->next_id++, s->wide_area_lookup_engine->fd_ipv4, AVAHI_WIDEAREA_DELETE); } if (remove) diff --git a/avahi-core/rr.h b/avahi-core/rr.h index 70b793d..99c7130 100644 --- a/avahi-core/rr.h +++ b/avahi-core/rr.h @@ -61,6 +61,7 @@ enum { /** DNS record classes, see RFC 1035, in addition to those defined in defs.h */ enum { AVAHI_DNS_CLASS_ANY = 0xFF, /**< Special query type for requesting all records */ + AVAHI_DNS_CLASS_NONE = 0xFE, /**< Special query type for deleting a record */ AVAHI_DNS_CACHE_FLUSH = 0x8000, /**< Not really a class but a bit which may be set in response packets, see mDNS spec for more information */ AVAHI_DNS_UNICAST_RESPONSE = 0x8000 /**< Not really a class but a bit which may be set in query packets, see mDNS spec for more information */ }; diff --git a/avahi-core/wide-area.c b/avahi-core/wide-area.c index fc39763..a8602fb 100644 --- a/avahi-core/wide-area.c +++ b/avahi-core/wide-area.c @@ -828,6 +828,8 @@ int avahi_wide_area_publish(AvahiRecord *r, const char *zone, uint16_t id, int f char globalfield[AVAHI_DOMAIN_NAME_MAX]; char *backup = NULL; char *backupfield = NULL; + uint16_t backupclass; + uint32_t backupttl; char *tmp; AvahiDnsPacket *p; @@ -922,6 +924,12 @@ int avahi_wide_area_publish(AvahiRecord *r, const char *zone, uint16_t id, int f } if(action == AVAHI_WIDEAREA_DELETE) { /* deleting pre-existing record */ + backupclass = r->key->clazz; + r->key->clazz = AVAHI_DNS_CLASS_NONE; + + backupttl = r->ttl; /* TODO: fix library limit, support 0 TTL */ + r->ttl = 0; + result = avahi_dns_packet_append_record(p, r, 0, 0); /* bind max TTL to 0, deletion */ } else { /* publishing new record */ if(r->key->type == AVAHI_DNS_TYPE_A) { /* standardize TTLs independent of record for wide-area */ @@ -972,6 +980,7 @@ int avahi_wide_area_publish(AvahiRecord *r, const char *zone, uint16_t id, int f /* cleanup */ r->key->name = backup; /* restore original key */ + if (backupfield) if (r->key->type == AVAHI_DNS_TYPE_SRV) { /* SRV has a different layout than other records in the union */ r->data.srv.name = backupfield; /* restore field if altered */ @@ -979,5 +988,10 @@ int avahi_wide_area_publish(AvahiRecord *r, const char *zone, uint16_t id, int f r->data.ptr.name = backupfield; /* restore field if altered */ } + if(action == AVAHI_WIDEAREA_DELETE) { /* restore class if altered */ + r->key->clazz = backupclass; + r->ttl = backupttl; + } + return 0; } -- cgit