summaryrefslogtreecommitdiff
path: root/avahi-compat-libdns_sd
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-08-24 21:04:24 +0000
committerLennart Poettering <lennart@poettering.net>2006-08-24 21:04:24 +0000
commitfc3830c24fd0341d762a2c4f05198f27fc3ccac0 (patch)
tree38ad0f16e42824908ea300816f00392b5928cd55 /avahi-compat-libdns_sd
parent8a0e03b4fc8687a91b9a6800145e613c3a009247 (diff)
downloadavahi-fc3830c24fd0341d762a2c4f05198f27fc3ccac0.tar.gz
implement DNSServiceUpdateRecord() for updating existing TXT records (closes #56)
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1270 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-compat-libdns_sd')
-rw-r--r--avahi-compat-libdns_sd/compat.c64
-rw-r--r--avahi-compat-libdns_sd/unsupported.c13
2 files changed, 63 insertions, 14 deletions
diff --git a/avahi-compat-libdns_sd/compat.c b/avahi-compat-libdns_sd/compat.c
index 6433f6d..88a98a7 100644
--- a/avahi-compat-libdns_sd/compat.c
+++ b/avahi-compat-libdns_sd/compat.c
@@ -1024,6 +1024,7 @@ static void reg_entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState st
switch (state) {
case AVAHI_ENTRY_GROUP_ESTABLISHED:
+
/* Inform the user */
reg_report_error(sdref, kDNSServiceErr_NoError);
@@ -1092,13 +1093,14 @@ DNSServiceErrorType DNSSD_API DNSServiceRegister (
assert(ret_sdref);
assert(regtype);
+ assert(txtRecord || txtLen == 0);
if (interface == kDNSServiceInterfaceIndexLocalOnly || flags) {
AVAHI_WARN_UNSUPPORTED;
return kDNSServiceErr_Unsupported;
}
- if (txtRecord && txtLen > 0)
+ if (txtLen > 0)
if (avahi_string_list_parse(txtRecord, txtLen, &txt) < 0)
return kDNSServiceErr_Invalid;
@@ -1189,3 +1191,63 @@ finish:
return ret;
}
+DNSServiceErrorType DNSSD_API DNSServiceUpdateRecord(
+ DNSServiceRef sdref,
+ DNSRecordRef rref,
+ DNSServiceFlags flags,
+ uint16_t rdlen,
+ const void *rdata,
+ AVAHI_GCC_UNUSED uint32_t ttl) {
+
+ int ret = kDNSServiceErr_Unknown;
+ AvahiStringList *txt = NULL;
+ assert(sdref);
+
+ AVAHI_WARN_LINKAGE;
+
+ if (flags || rref) {
+ AVAHI_WARN_UNSUPPORTED;
+ return kDNSServiceErr_Unsupported;
+ }
+
+ if (rdlen > 0)
+ if (avahi_string_list_parse(rdata, rdlen, &txt) < 0)
+ return kDNSServiceErr_Invalid;
+
+ ASSERT_SUCCESS(pthread_mutex_lock(&sdref->mutex));
+
+ if (!avahi_string_list_equal(txt, sdref->service_txt)) {
+
+ avahi_string_list_free(sdref->service_txt);
+ sdref->service_txt = txt;
+
+ if (avahi_client_get_state(sdref->client) == AVAHI_CLIENT_S_RUNNING &&
+ sdref->entry_group &&
+ (avahi_entry_group_get_state(sdref->entry_group) == AVAHI_ENTRY_GROUP_ESTABLISHED ||
+ avahi_entry_group_get_state(sdref->entry_group) == AVAHI_ENTRY_GROUP_REGISTERING))
+
+ if (avahi_entry_group_update_service_txt_strlst(
+ sdref->entry_group,
+ sdref->service_interface,
+ AVAHI_PROTO_UNSPEC,
+ 0,
+ sdref->service_name_chosen,
+ sdref->type_info.type,
+ sdref->service_domain,
+ sdref->service_txt) < 0) {
+
+ ret = map_error(avahi_client_errno(sdref->client));
+ goto finish;
+ }
+
+ } else
+ avahi_string_list_free(txt);
+
+ ret = kDNSServiceErr_NoError;
+
+finish:
+ ASSERT_SUCCESS(pthread_mutex_unlock(&sdref->mutex));
+
+ return ret;
+}
+
diff --git a/avahi-compat-libdns_sd/unsupported.c b/avahi-compat-libdns_sd/unsupported.c
index 0e08ad6..2df3847 100644
--- a/avahi-compat-libdns_sd/unsupported.c
+++ b/avahi-compat-libdns_sd/unsupported.c
@@ -96,19 +96,6 @@ DNSServiceErrorType DNSSD_API DNSServiceAddRecord(
return kDNSServiceErr_Unsupported;
}
-DNSServiceErrorType DNSSD_API DNSServiceUpdateRecord(
- AVAHI_GCC_UNUSED DNSServiceRef sdRef,
- AVAHI_GCC_UNUSED DNSRecordRef RecordRef,
- AVAHI_GCC_UNUSED DNSServiceFlags flags,
- AVAHI_GCC_UNUSED uint16_t rdlen,
- AVAHI_GCC_UNUSED const void *rdata,
- AVAHI_GCC_UNUSED uint32_t ttl) {
-
- AVAHI_WARN_UNSUPPORTED;
-
- return kDNSServiceErr_Unsupported;
-}
-
DNSServiceErrorType DNSSD_API DNSServiceRemoveRecord(
AVAHI_GCC_UNUSED DNSServiceRef sdRef,
AVAHI_GCC_UNUSED DNSRecordRef RecordRef,