tfUseDhcp

Jump to: navigation, search

Table of Contents >> Optional Protocols >> DHCP Automatic Configuration


#include <trsocket.h>


int tfUseDhcp (
ttUserInterface interfaceHandle,
ttDevNotifyFuncPtr notifyFuncPtr
);


Function Description

This function is used to initialize the DHCP client interface and should be called between tfAddInterface() and tfOpenInterface() to allow configuration using the DHCP client protocol. If the second parameter is non-NULL, then upon completion of tfOpenInterface(), the function that it points to will be called.


Function prototype for the user supplied notify function:


void devNotifyFunc (
ttUserInterface interfaceHandle,
int mHomeIndex,
int errorCode
);


Warning Warning: The 'mHomeIndex' parameter is only available if TM_DHCP_CB_WITH_MHOME is defined in trsystem.h.


This function will be called with the 'interfaceHandle' passed to tfOpenInterface() and with an error code value which is TM_ENOERROR on success.

If you have defined TM_DHCP_CB_RELEASE in trsystem.h, and you call tfNgUnConfigInterface() on a DHCP autoconfigured address, your notification function will be called with a TM_ENETDOWN error when the DHCP Release message send has completed (successfully or not, for example, if an ARP query on the DHCP server IP address times out). After receiving this notification, you may call tfCloseInterface() (if you close the interface prior to getting the notification, the DHCP Release message may be lost).


Parameters

  • interfaceHandle
    The device entry as returned by tfAddInterface().
  • notifyFuncPtr
    A pointer to a function that will be called upon completion of tfOpenInterface() for a DHCP configuration.


Returns

  • TM_ENOERROR
    Success.
  • TM_EINVAL
    'interfaceHandle' is invalid.
  • TM_EMFILE
    Not enough sockets to open the BOOTP client UDP socket.
  • TM_ADDRINUSE
    Another socket is already bound to the BOOTP client UDP port.


Table of Contents >> Optional Protocols >> DHCP Automatic Configuration