Logo Search packages:      
Sourcecode: avahi version File versions  Download package

int avahi_server_add_service_subtype ( AvahiServer s,
AvahiSEntryGroup g,
AvahiIfIndex  interface,
AvahiProtocol  protocol,
AvahiPublishFlags  flags,
const char *  name,
const char *  type,
const char *  domain,
const char *  subtype 
)

Add a subtype for an already existing service

Parameters:
name  Specify the name of main service you already added here
type  Specify the main type of the service you already added here
domain  Specify the main type of the service you already added here
subtype  The new subtype for the specified service

Definition at line 825 of file entry.c.

References AVAHI_DEFAULT_TTL, AVAHI_DOMAIN_NAME_MAX, AVAHI_ERR_INVALID_DOMAIN_NAME, AVAHI_ERR_INVALID_FLAGS, AVAHI_ERR_INVALID_INTERFACE, AVAHI_ERR_INVALID_PROTOCOL, AVAHI_ERR_INVALID_SERVICE_NAME, AVAHI_ERR_INVALID_SERVICE_SUBTYPE, AVAHI_ERR_INVALID_SERVICE_TYPE, AVAHI_ERR_NOT_SUPPORTED, and AVAHI_OK.

                         {

    int ret = AVAHI_OK;
    char svc_name[AVAHI_DOMAIN_NAME_MAX], ptr_name[AVAHI_DOMAIN_NAME_MAX];

    assert(name);
    assert(type);
    assert(subtype);

    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, AVAHI_FLAGS_VALID(flags, AVAHI_PUBLISH_USE_MULTICAST|AVAHI_PUBLISH_USE_WIDE_AREA), AVAHI_ERR_INVALID_FLAGS);
    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, avahi_is_valid_service_name(name), AVAHI_ERR_INVALID_SERVICE_NAME);
    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, avahi_is_valid_service_type_strict(type), AVAHI_ERR_INVALID_SERVICE_TYPE);
    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME);
    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, avahi_is_valid_service_subtype(subtype), AVAHI_ERR_INVALID_SERVICE_SUBTYPE);

    if (!domain)
        domain = s->domain_name;

    transport_flags_from_domain(s, &flags, domain);
    AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(s, flags & AVAHI_PUBLISH_USE_MULTICAST, AVAHI_ERR_NOT_SUPPORTED);

    if ((ret = avahi_service_name_join(svc_name, sizeof(svc_name), name, type, domain)) < 0 ||
        (ret = avahi_service_name_join(ptr_name, sizeof(ptr_name), NULL, subtype, domain)) < 0) {
        avahi_server_set_errno(s, ret);
        goto fail;
    }

    if ((ret = avahi_server_add_ptr(s, g, interface, protocol, 0, AVAHI_DEFAULT_TTL, ptr_name, svc_name)) < 0)
        goto fail;

fail:

    return ret;
}


Generated by  Doxygen 1.6.0   Back to index