diff options
Diffstat (limited to 'avahi-daemon')
-rw-r--r-- | avahi-daemon/EntryGroup.introspect | 10 | ||||
-rw-r--r-- | avahi-daemon/dbus-protocol.c | 47 |
2 files changed, 51 insertions, 6 deletions
diff --git a/avahi-daemon/EntryGroup.introspect b/avahi-daemon/EntryGroup.introspect index 51cddf6..ef3fb5f 100644 --- a/avahi-daemon/EntryGroup.introspect +++ b/avahi-daemon/EntryGroup.introspect @@ -39,6 +39,16 @@ <arg name="txt" type="aay" direction="in"/> </method> + <method name="AddServiceSubtype"> + <arg name="interface" type="i" direction="in"/> + <arg name="protocol" type="i" direction="in"/> + <arg name="flags" type="u" direction="in"/> + <arg name="name" type="s" direction="in"/> + <arg name="type" type="s" direction="in"/> + <arg name="domain" type="s" direction="in"/> + <arg name="subtype" type="s" direction="in"/> + </method> + <method name="AddAddress"> <arg name="interface" type="i" direction="in"/> <arg name="protocol" type="i" direction="in"/> diff --git a/avahi-daemon/dbus-protocol.c b/avahi-daemon/dbus-protocol.c index 9270168..96d0118 100644 --- a/avahi-daemon/dbus-protocol.c +++ b/avahi-daemon/dbus-protocol.c @@ -859,13 +859,48 @@ static DBusHandlerResult msg_entry_group_impl(DBusConnection *c, DBusMessage *m, if (avahi_server_add_service_strlst(avahi_server, i->entry_group, (AvahiIfIndex) interface, (AvahiProtocol) protocol, (AvahiPublishFlags) flags, name, type, domain, host, port, strlst) < 0) { avahi_string_list_free(strlst); return respond_error(c, m, avahi_server_errno(avahi_server), NULL); - } else - i->n_entries ++; - + } + + i->n_entries ++; avahi_string_list_free(strlst); return respond_ok(c, m); + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddServiceSubtype")) { + + int32_t interface, protocol; + uint32_t flags; + char *type, *name, *domain, *subtype; + + if (!dbus_message_get_args( + m, &error, + DBUS_TYPE_INT32, &interface, + DBUS_TYPE_INT32, &protocol, + DBUS_TYPE_UINT32, &flags, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_STRING, &type, + DBUS_TYPE_STRING, &domain, + DBUS_TYPE_STRING, &subtype, + DBUS_TYPE_INVALID) || !type || !name || !subtype) { + avahi_log_warn("Error parsing EntryGroup::AddServiceSubtype message"); + goto fail; + } + + if (i->n_entries >= MAX_ENTRIES_PER_ENTRY_GROUP) { + avahi_log_warn("Too many entries per entry group, client request failed."); + return respond_error(c, m, AVAHI_ERR_TOO_MANY_ENTRIES, NULL); + } + + if (domain && !*domain) + domain = NULL; + + if (avahi_server_add_service_subtype(avahi_server, i->entry_group, (AvahiIfIndex) interface, (AvahiProtocol) protocol, (AvahiPublishFlags) flags, name, type, domain, subtype) < 0) + return respond_error(c, m, avahi_server_errno(avahi_server), NULL); + + i->n_entries ++; + + return respond_ok(c, m); + } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddAddress")) { int32_t interface, protocol; uint32_t flags; @@ -895,11 +930,11 @@ static DBusHandlerResult msg_entry_group_impl(DBusConnection *c, DBusMessage *m, if (avahi_server_add_address(avahi_server, i->entry_group, (AvahiIfIndex) interface, (AvahiProtocol) protocol, (AvahiPublishFlags) flags, name, &a) < 0) return respond_error(c, m, avahi_server_errno(avahi_server), NULL); - else - i->n_entries ++; + + i->n_entries ++; return respond_ok(c, m); - } + } avahi_log_warn("Missed message %s::%s()", dbus_message_get_interface(m), dbus_message_get_member(m)); |