tfDhcpUserSetAttributes

Jump to: navigation, search

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


#include <trsocket.h>


int tfDhcpUserSetAttributes (
ttUserInterface interfaceHandle,
unsigned int multiHomeIndex,
int attrName,
void * attrValuePtr,
int attrLength
);



Function Description

This function allows the user to change the default values for the following attributes for an individual multi-homed index on an interface:

  • Set a timeout value to limit the length of time spent in the selecting phase.
  • Set an upper limit on the number of DHCP offers that the interface will cache (only valid when using the callback feature).
  • Specify the preferred IP address that will automatically be accepted.
  • Control what is to happen if the preferred IP address has not been offered within the timeout period:
    • accept any other offer , or
    • cancel DHCP.
  • Select an offer that is currently in the cache (only valid when using the callback feature).
  • Remove an offer that is currently in the cache (only valid when using the callback feature). Use this feature to create space in the offer cache so that other, more important offers are not bumped from the cache.
  • Revert back to legacy mode of operation, as discussed earlier.


Note Note: You cannot mix use of preferred IP address or legacy mode with the user callback feature on the same interface. The user's offer callback function is global to all indices on an interface and, at the moment you register your callback function, will become the sole mode of operation across all multi-home indices. Conversely, when you specify a preferred IP address or select legacy mode for a multi-home index, any previously registered offer callback will be undone for all indices.


Default values for time limit and cache size are inherited from the interface, as set with tfInterfaceSetOptions() or as defined by macros TM_DHCP_DEF_COLLECT_TIMEOUT and TM_DHCP_DEF_COLLECT_CACHE.


Parameters

  • interfaceHandle
    The device entry as returned by tfAddInterface().
  • multiHomeIndex
    Index of IPv4 configured address on interfaceHandle that has been configured for DHCP.
  • attrName
    Name of the attribute (see below).
  • attrValuePtr
    Pointer to a user variable that contains the attribute value.
  • attrLength
    Size of the user variable in bytes.


Returns

  • TM_ENOERROR
    Success.
  • TM_EINVAL
    Invalid parameter
  • TM_ENOENT
    ServerId not found in offer cache.


Attributes

Name Size Description
TM_DHCP_ATTR_COLLECT_TIME sizeof(int) Set the time limit in seconds that the interface will continue to collect DHCP offers after the first offer is received.
Restrictions: Use prior to starting DHCP.

Default value: 15 seconds

TM_DHCP_ATTR_COLLECT_CACHE sizeof(int) Set the upper limit on the number of DHCP offers that can be held in the offer cache.
Restrictions: Use prior to starting DHCP. Use with callback feature only.

Default value: 1. Minimum value: 1.

TM_DHCP_ATTR_PREF_ADDRESS sizeof(ttUserIpAddress) Set the preferred IP address to be accepted the moment it is offered. If it is not offered within the time limit, take any offer in the cache.
Restrictions: Use prior to starting DHCP.
TM_DHCP_ATTR_EXCL_ADDRESS sizeof(ttUserIpAddress) Set the exclusive IP address to be accepted the moment it is offered. If it is not offered within the time limit, cancel DHCP.

Restrictions: Use prior to starting DHCP.

TM_DHCP_ATTR_CACHE_SELECT sizeof(ttUserIpAddress) Select a DHCP offer from the cache. Treck will send a DHCP request to the associated server. If the server responds with a negative acknowledgement, the DHCP process will start over from the beginning. Note that the offer may have been dropped if the number of offers received is greater than the cache size.
Restrictions: Use during DHCP offer collection/selection phase only.
Attribute value: serverId that was received by the user's callback function to which the user responded with TM_DHCP_OFFER_COLLECT.
TM_DHCP_ATTR_CACHE_DROP sizeof(ttUserIpAddress) Remove a DHCP offer from the cache. Note that the offer may already have been dropped if the number of offers received is greater than the cache size.
Restrictions: Use during DHCP offer collection/selection phase only.
Attribute value: serverId that was received by the user's callback function to which the user responded with TM_DHCP_OFFER_COLLECT.
TM_DHCP_ATTR_LEGACY_MODE unused Use legacy mode: unconditionally select the first DHCP offer received. This is the default mode. It is the only mode supported by previous Treck versions.
Restrictions: Use prior to starting DHCP.
Attribute value is not used and can be set to any value.


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