TCPIP_DHCP_HostNameCallbackRegister Function

C

bool TCPIP_DHCP_HostNameCallbackRegister(
    TCPIP_NET_HANDLE hNet, 
    TCPIP_DHCP_HOST_NAME_CALLBACK nameCallback, 
    bool writeBack
);

Description

This function registers a DHCP host name callback function. The DHCP module will call the registered callback when a host name needs to be presented to the DHCP server.

Preconditions

The DHCP module must be initialized.

Parameters

ParametersDescription
hNetInterface to query.
nameCallbackCallback to be called to get a DHCP host name.
writeBackIf true, the resulting name will be written to the address returned by the nameCallback (it shouldn't be const).

Returns

  • True - If the call succeeds.

  • False - If error (no such interface, etc.).

Remarks

The nameCallback() function has to be valid for the length of DHCP client communication with the server, i.e. when the reported status is bound or some error.

There is no corresponding deregister function. Simply call TCPIP_DHCP_HostNameCallbackRegister() with the nameCallback set to 0.

If such a callback is not registered, then the NetBios name will be used for the DHCP host name.

The callback function has to return a character string that's compatible with the rules imposed for the host names:

  • Host names may contain only alphanumeric characters, minus signs ("-"), and periods (".")

  • They must begin with an alphabetic character and end with an alphanumeric character

To enforce these rules the extra processing is performed internally (on either user supplied host name or NetBios name):

  • spaces, if present, will be stripped from the string

  • illegal characters will be replaced by TCPIP_DHCP_HOST_REPLACE_CHAR character (default is lower case 'x')

If after processing the resulting string is null, the DHCP host name option is skipped.

The callback function has to return a character string that's at least 2 characters in size;