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

AvahiSAddressResolver* avahi_s_address_resolver_new ( AvahiServer server,
AvahiIfIndex  interface,
AvahiProtocol  protocol,
const AvahiAddress address,
AvahiLookupFlags  flags,
AvahiSAddressResolverCallback  calback,
void *  userdata 
)

Create an AvahiSAddressResolver object. See AvahiSRecordBrowser for more info on the paramters.

Parameters:
flags  Lookup flags.

Definition at line 179 of file resolve-address.c.

References AVAHI_DNS_CLASS_IN, AVAHI_DOMAIN_NAME_MAX, AVAHI_ERR_INVALID_FLAGS, AVAHI_ERR_INVALID_INTERFACE, AVAHI_ERR_INVALID_PROTOCOL, AVAHI_ERR_NO_MEMORY, AVAHI_LLIST_PREPEND, AVAHI_LOOKUP_USE_MULTICAST, AVAHI_LOOKUP_USE_WIDE_AREA, avahi_new, avahi_s_address_resolver_free(), avahi_s_address_resolver_new(), and AvahiAddress::proto.

Referenced by avahi_s_address_resolver_new().

                    {
    
    AvahiSAddressResolver *r;
    AvahiKey *k;
    char n[AVAHI_DOMAIN_NAME_MAX];

    assert(server);
    assert(address);
    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, address->proto == AVAHI_PROTO_INET || address->proto == AVAHI_PROTO_INET6, AVAHI_ERR_INVALID_PROTOCOL);
    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_FLAGS_VALID(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
    
    avahi_reverse_lookup_name(address, n, sizeof(n));

    if (!(k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR))) {
        avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
        return NULL;
    }

    if (!(r = avahi_new(AvahiSAddressResolver, 1))) {
        avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
        avahi_key_unref(k);
        return NULL;
    }
    
    r->server = server;
    r->address = *address;
    r->callback = callback;
    r->userdata = userdata;
    r->ptr_record = NULL;
    r->interface = interface;
    r->protocol = protocol;
    r->flags = 0;
    r->retry_with_multicast = 0;
    r->key = k;

    r->record_browser = NULL;
    AVAHI_LLIST_PREPEND(AvahiSAddressResolver, resolver, server->address_resolvers, r);

    r->time_event = NULL;

    if (!(flags & (AVAHI_LOOKUP_USE_MULTICAST|AVAHI_LOOKUP_USE_WIDE_AREA))) {

        if (!server->wide_area_lookup_engine || !avahi_wide_area_has_servers(server->wide_area_lookup_engine))
            flags |= AVAHI_LOOKUP_USE_MULTICAST;
        else {
            flags |= AVAHI_LOOKUP_USE_WIDE_AREA;
            r->retry_with_multicast = 1;
        }
    }
    
    r->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, r);

    if (!r->record_browser) {
        avahi_s_address_resolver_free(r);
        return NULL;
    }

    start_timeout(r);
    
    return r;
}


Generated by  Doxygen 1.6.0   Back to index