tfDhcpUserStart

Jump to: navigation, search

Table of Contents >> Optional Protocols >> DHCP User Configured


#include <trsocket.h>


int tfDhcpUserStart (
ttUserInterface interfaceHandle,
int userIndex,
ttUserDhcpNotifyFuncPtr dhcpNotifyFuncPtr
);


Function Description

This function allows the user to reserve a DHCP address on the Ethernet interface for another interface (i.e. PPP for example). Prior to this call, the Ethernet interface must already be configured (possibly using DHCP as well). See tfOpenInterface() for details. This function starts sending a DHCP request on the Ethernet interface handle parameter. The index corresponds to a unique user DHCP request. It has to be between 0 and tvMaxUserDhcpEntries - 1.


Note Note: The default value for tvMaxUserDhcpEntries is 0 and must be changed using tfInitTreckOptions() with option name of TM_OPTION_DHCP_MAX_ENTRIES. The new value must be equal to the number of DHCP IP addresses that we want to reserve for our other interface(s), prior to this call.


'dhcpNotifyFunc' is a user-supplied call back function which will be called when either the DHCP request has succeeded, or has timed out, or when a previously leased DHCP address has been cancelled by the server.

If tfDhcpUserStart() returns TM_ENOERROR, the DHCP request has completed successfully. A TM_EINPROGRESS error return indicates that a DHCP configure or request has been sent (this is acceptable).

A TM_EALREADY error return indicates that a DHCP discover/request has been previously sent as a result of a previous call to tfDhcpUserStart(). If the function returns TM_EINPROGRESS or TM_EALREADY, the user must wait for the DHCP configuration to complete (i.e. for 'dhcpNotifyFunc' to be called). During the wait, the user must ensure that tfTimerUpdate() or tfTimerUpdateIsr() and tfTimerExecute() are being called.

If the function returns TM_EINPROGRESS or TM_EALREADY, then, when the DHCP request has completed or timed out, the 'dhcpNotifyFunc' will be called as follows:

(*dhcpNotifyFunc)(ethernetInterfaceHandle, errorCode, userIndex);

Where the 'userIndex' corresponds to the second parameter of tfDhcpUserStart(), and 'errorCode' indicates whether the DHCP request has been successful (errorCode == TM_ENOERROR), or timed out (errorCode ==TM_ETIMEDOUT).


Parameters

  • interfaceHandle
    The device entry as returned by tfAddInterface().
  • userIndex
    The user index of the BOOT entry. This value must be between 0 and tvMaxUserDhcpEntries - 1.
  • dhcpNotifyFuncPtr
    A pointer to the function that will be called when the DHCP request has been completed or has timed out.


Returns

  • TM_ENOERROR
    Success. (The DHCP notify function will not be called.)
  • TM_EINPROGRESS
    A DHCP request/discover was sent with no error.
  • TM_EALREADY
    A DHCP request/discover has already been sent.
  • TM_EINVAL
    One of the parameters was invalid.
  • TM_ENOBUFS
    Insufficient memory to complete the operation.
  • (Other)
    As returned from the device driver send routine.


Table of Contents >> Optional Protocols >> DHCP User Configured