tfDhcpGetDomainSearch

Jump to: navigation, search

Table of Contents >> Optional Protocols >> DHCP


#include <trsocket.h>


int tfDhcpGetDomainSearch (
ttUserInterface interfaceHandle,
int configType,
int configIndex,
int domainIndex,
char TM_FAR * bufPtr,
int TM_FAR * bufLenPtr
);


Function Description

Use this function to retrieve the domain names returned by a DHCP server in a Domain Search Option (see RFC 3397). By default, this function is omitted from the Treck build and the Treck DHCP client will not request the Domain Search Option. Uncomment the following configuration macro in trsystem.h to support the Domain Search Option.
#define TM_USE_DHCP_DOMAIN_SEARCH
The list of domain names is received in compressed binary form (see RFC 1035). This function is used to retrieve a single entry in the list at offset domainIndex and convert the name to ASCII form. You can retrieve all the domain names by calling this function repeatedly and increasing domainIndex each time until TM_ENOENT is returned.


Parameters

  • interfaceHandle
    The interface on which to retrieve the domain name.
  • int configType
    The configIndex parameter type. Specify TM_BT_CONF for multihome index (Automatic Configuration) or TM_BT_USER for user index (User-Controlled Configuration).
  • int configIndex
    The configured multihome or user index on which to retrieve the domain name.
  • int domainIndex
    Specifies which domain name to retrieve. This is a zero-based index into the list of domain names returned in the Domain Search Option.
  • char TM_FAR * bufPtr
    Pointer to a buffer to store the domain name into. You can specify a NULL pointer and a buffer size of zero to probe for the domain name length. For DSPs, the domain name is stored as unpacked characters.
  • int TM_FAR * bufLenPtr
    Pointer to an integer variable that, on input, contains the length of the data buffer (unpacked character count). Upon return, the variable will be updated to reflect the actual length of the domain name as stored in the buffer. No terminating '\0' is stored in the buffer or included in the returned length.


Returns

  • TM_ENOERROR
    Success.
  • TM_EINVAL
    Invalid arguments in the call.
  • TM_EMSGSIZE
    Insufficient buffer space to store the option data. *bufLenPtr will be updated to reflect the actual length of the option data.
  • TM_ENOENT
    No entry at the specified location.


Usage

The following example illustrates how to retrieve all domain names returned in the Domain Search Option for a DHCP auto-configured address on multihome index 0.

    for (i = 0; ; ++i)
    {
/* Get the next domain name for multihome index 0 */
        bufLen = sizeof(buf) - 1;
        errorCode = tfDhcpGetDomainSearch(interfaceHandle,
                                          TM_BT_CONF,
                                          0,
                                          i,
                                          buf,
                                          &bufLen);
        if (errorCode == TM_ENOENT)
        {
/* End of list */
            break;
        }
        if (errorCode != TM_ENOERROR)
        {
            printf("Error on index %d: %d\n", i, errorCode);
            break;
        }
        buf[bufLen] = '\0';
        printf("Domain name for index %d: %s\n", i, buf);
    }


Table of Contents >> Optional Protocols >> DHCP