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

int avahi_server_set_host_name ( AvahiServer s,
const char *  host_name 
)

Change the host name of a running mDNS responder. This will drop all automicatilly generated RRs and readd them with the new name. Since the responder has to probe for the new RRs this function takes some time to take effect altough it returns immediately. This function is intended to be called when a host name conflict is reported using AvahiServerCallback. The caller should readd all user defined RRs too since they otherwise continue to point to the outdated host name..

Definition at line 1247 of file server.c.

References AVAHI_ERR_INVALID_HOST_NAME, AVAHI_ERR_NO_CHANGE, AVAHI_OK, AVAHI_SERVER_COLLISION, and avahi_server_set_host_name().

Referenced by avahi_server_set_host_name().

                                                                      {
    char *hn = NULL;
    assert(s);

    AVAHI_CHECK_VALIDITY(s, !host_name || avahi_is_valid_host_name(host_name), AVAHI_ERR_INVALID_HOST_NAME);

    if (!host_name) {
        hn = avahi_get_host_name_strdup();
        hn[strcspn(hn, ".")] = 0;
        host_name = hn;
    }

    if (avahi_domain_equal(s->host_name, host_name) && s->state != AVAHI_SERVER_COLLISION) {
        avahi_free(hn);
        return avahi_server_set_errno(s, AVAHI_ERR_NO_CHANGE);
    }

    withdraw_host_rrs(s);

    avahi_free(s->host_name);
    s->host_name = hn ? hn : avahi_strdup(host_name);

    update_fqdn(s);

    register_stuff(s);
    return AVAHI_OK;
}


Generated by  Doxygen 1.6.0   Back to index