Name

cyg_mdns_gethostname — Get current hostname value

Synopsis

#include <mdns.h>

cyg_bool cyg_mdns_gethostname(cyg_uint8 *dstbuf, cyg_uint8 *len);

Description

This function provides access to the currently configured mDNS UTF-8 hostname (shared across all mDNS configured lwIP network interfaces) and is intended for debug or UI usage. The active hostname is copied into the supplied buffer, where the passed *len specifies the valid buffer length of dstbuf. Normally the referenced dstbuf should have at least MDNS_MAX_LABEL available space, and *len set accordingly. The return boolean state indicates success or failure, with *len updated with the number of bytes written/required. On failure the contents of dstbuf are undefined. If dstbuf is NULL then the call can be used with a valid len pointer to ascertain the amount of storage required to hold the name.

[Note]Note

It is possible due to a dynamically changing external network that any returned hostname may already be invalid by the time the call returns the filled buffer to the application. For normal real-world operations the hostname callback function should be tracked by the application to cope with the actual active/current state with suitable cross-thread synchronisation implemented as required.

Return value

If a non-null len is supplied then the referenced location is updated with the hostname length at the time of the function call. Boolean true is returned if dstbuf is NULL or is a pointer to a *len buffer large enough to hold the hostname at the time of the call, which is filled with the hostname. On error boolean false is returned.