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

AvahiSDNSServerBrowser* avahi_s_dns_server_browser_new ( AvahiServer server,
AvahiIfIndex  interface,
AvahiProtocol  protocol,
const char *  domain,
AvahiDNSServerType  type,
AvahiProtocol  aprotocol,
AvahiLookupFlags  flags,
AvahiSDNSServerBrowserCallback  callback,
void *  userdata 
)

Create a new AvahiSDNSServerBrowser object

Parameters:
aprotocol  Address protocol for the DNS server
flags  Lookup flags.

Definition at line 234 of file browse-dns-server.c.

References AVAHI_DNS_CLASS_IN, AVAHI_DOMAIN_NAME_MAX, AVAHI_ERR_INVALID_DOMAIN_NAME, AVAHI_ERR_INVALID_FLAGS, AVAHI_ERR_INVALID_INTERFACE, AVAHI_ERR_INVALID_PROTOCOL, AVAHI_ERR_NO_MEMORY, AVAHI_LLIST_HEAD_INIT, and AVAHI_LLIST_PREPEND.

                    {

    static const char * const type_table[AVAHI_DNS_SERVER_MAX] = {
        "_domain._udp",
        "_dns-update._udp"
    };

    AvahiSDNSServerBrowser *b;
    AvahiKey *k = NULL;
    char n[AVAHI_DOMAIN_NAME_MAX];
    int r;

    assert(server);
    assert(callback);

    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_PROTO_VALID(aprotocol), AVAHI_ERR_INVALID_PROTOCOL);
    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME);
    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_FLAGS_VALID(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, type < AVAHI_DNS_SERVER_MAX, AVAHI_ERR_INVALID_FLAGS);

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

    if ((r = avahi_service_name_join(n, sizeof(n), NULL, type_table[type], domain)) < 0) {
        avahi_server_set_errno(server, r);
        return NULL;
    }

    if (!(b = avahi_new(AvahiSDNSServerBrowser, 1))) {
        avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
        return NULL;
    }

    b->server = server;
    b->callback = callback;
    b->userdata = userdata;
    b->aprotocol = aprotocol;
    b->n_info = 0;
    b->user_flags = flags;

    AVAHI_LLIST_HEAD_INIT(AvahiDNSServerInfo, b->info);
    AVAHI_LLIST_PREPEND(AvahiSDNSServerBrowser, browser, server->dns_server_browsers, b);

    if (!(k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV))) {
        avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
        goto fail;
    }

    if (!(b->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, b)))
        goto fail;

    avahi_key_unref(k);

    return b;

fail:

    if (k)
        avahi_key_unref(k);

    avahi_s_dns_server_browser_free(b);
    return NULL;
}


Generated by  Doxygen 1.6.0   Back to index