uint16_t port;
int protocol;
+ AvahiStringList *subtypes;
+
AvahiStringList *txt_records;
AVAHI_LLIST_FIELDS(StaticService, services);
s->protocol = AVAHI_PROTO_UNSPEC;
s->txt_records = NULL;
+ s->subtypes = NULL;
AVAHI_LLIST_PREPEND(StaticService, services, group->services, s);
avahi_free(s->domain_name);
avahi_string_list_free(s->txt_records);
+ avahi_string_list_free(s->subtypes);
avahi_free(s);
}
assert(s);
assert(g);
-
- if (state == AVAHI_ENTRY_GROUP_COLLISION) {
- char *n;
- remove_static_service_group_from_server(g);
-
- n = avahi_alternative_service_name(g->chosen_name);
- avahi_free(g->chosen_name);
- g->chosen_name = n;
+ switch (state) {
+
+ case AVAHI_ENTRY_GROUP_COLLISION: {
+ char *n;
+
+ remove_static_service_group_from_server(g);
+
+ n = avahi_alternative_service_name(g->chosen_name);
+ avahi_free(g->chosen_name);
+ g->chosen_name = n;
+
+ avahi_log_notice("Service name conflict for \"%s\" (%s), retrying with \"%s\".", g->name, g->filename, g->chosen_name);
+
+ add_static_service_group_to_server(g);
+ break;
+ }
+
+ case AVAHI_ENTRY_GROUP_ESTABLISHED:
+ avahi_log_info("Service \"%s\" (%s) successfully established.", g->chosen_name, g->filename);
+ break;
- avahi_log_notice("Service name conflict for \"%s\" (%s), retrying with \"%s\".", g->name, g->filename, g->chosen_name);
+ case AVAHI_ENTRY_GROUP_FAILURE:
+ avahi_log_warn("Failed to publish service \"%s\" (%s): %s", g->chosen_name, g->filename, avahi_strerror(avahi_server_errno(s)));
+ remove_static_service_group_from_server(g);
+ break;
- add_static_service_group_to_server(g);
- } else if (state == AVAHI_ENTRY_GROUP_ESTABLISHED)
- avahi_log_info("Service \"%s\" (%s) successfully established.", g->chosen_name, g->filename);
+ case AVAHI_ENTRY_GROUP_UNCOMMITED:
+ case AVAHI_ENTRY_GROUP_REGISTERING:
+ ;
+ }
}
static void add_static_service_group_to_server(StaticServiceGroup *g) {
assert(avahi_s_entry_group_is_empty(g->entry_group));
for (s = g->services; s; s = s->services_next) {
+ AvahiStringList *i;
if (avahi_server_add_service_strlst(
avahi_server,
g->entry_group,
AVAHI_IF_UNSPEC, s->protocol,
0,
- g->chosen_name, s->type,
- s->domain_name, s->host_name, s->port,
+ g->chosen_name, s->type, s->domain_name,
+ s->host_name, s->port,
s->txt_records) < 0) {
avahi_log_error("Failed to add service '%s' of type '%s', ignoring service group (%s): %s",
g->chosen_name, s->type, g->filename,
remove_static_service_group_from_server(g);
return;
}
+
+ for (i = s->subtypes; i; i = i->next) {
+
+ if (avahi_server_add_service_subtype(
+ avahi_server,
+ g->entry_group,
+ AVAHI_IF_UNSPEC, s->protocol,
+ 0,
+ g->chosen_name, s->type, s->domain_name,
+ (char*) i->text) < 0) {
+
+ avahi_log_error("Failed to add subtype '%s' for service '%s' of type '%s', ignoring subtype (%s): %s",
+ i->text, g->chosen_name, s->type, g->filename,
+ avahi_strerror(avahi_server_errno(avahi_server)));
+ }
+ }
}
avahi_s_entry_group_commit(g->entry_group);
XML_TAG_NAME,
XML_TAG_SERVICE,
XML_TAG_TYPE,
+ XML_TAG_SUBTYPE,
XML_TAG_DOMAIN_NAME,
XML_TAG_HOST_NAME,
XML_TAG_PORT,
goto invalid_attr;
u->current_tag = XML_TAG_TYPE;
+ } else if (u->current_tag == XML_TAG_SERVICE && strcmp(el, "subtype") == 0) {
+ if (attr[0])
+ goto invalid_attr;
+
+ u->current_tag = XML_TAG_SUBTYPE;
} else if (u->current_tag == XML_TAG_SERVICE && strcmp(el, "domain-name") == 0) {
if (attr[0])
goto invalid_attr;
u->current_tag = XML_TAG_SERVICE;
break;
}
+
+ case XML_TAG_SUBTYPE: {
+ assert(u->service);
+
+ u->service->subtypes = avahi_string_list_add(u->service->subtypes, u->buf ? u->buf : "");
+ u->current_tag = XML_TAG_SERVICE;
+ break;
+ }
case XML_TAG_TYPE:
case XML_TAG_DOMAIN_NAME:
case XML_TAG_PORT:
case XML_TAG_TXT_RECORD:
+ case XML_TAG_SUBTYPE:
assert(u->service);
u->buf = append_cdata(u->buf, s, len);
break;
type. Should contain one <opt><type></opt> and one
<opt><port></opt> element. Optionally it may contain one
<opt><domain-name></opt>, one
- <opt><host-name></opt> and multiple
+ <opt><host-name></opt>, any number of
+ <opt><subtype></opt> and any number of
<opt><txt-record></opt> elements. The attribute
- <opt>protocol</opt> specifies the protocol to
- advertise the service on. If <opt>any</opt> is used (which is
- the default), the service will be advertised on both IPv4 and
- IPv6.</p>
+ <opt>protocol</opt> specifies the protocol to advertise the
+ service on. If <opt>any</opt> is used (which is the default),
+ the service will be advertised on both IPv4 and IPv6.</p>
</option>
<option>
<p><opt><type></opt> Contains the DNS-SD service type for this service. e.g. "_http._tcp".</p>
</option>
+ <option>
+ <p><opt><subtype></opt> Contains an additional DNS-SD service subtype for this service. e.g. "_anon._sub._ftp._tcp".</p>
+ </option>
+
<option>
<p><opt><domain-name></opt> The domain name this service
should be registered. If omited defaults to the default domain