VxWorks API Reference : OS Libraries
dhcpcCommonLib - DHCP client interface shared code library
dhcpcOptionSet( ) - add an option to the option request list
dhcpcOptionAdd( ) - add an option to the client messages
This library contains the shared functions used by the both the run-time and boot-time portions of the DHCP client.
dhcpcLib.h
dhcpcOptionSet( ) - add an option to the option request list
STATUS dhcpcOptionSet ( void * pCookie, /* identifier returned by dhcpcInit() */ int option /* RFC 2132 tag of desired option */ )
This routine specifies which options the lease indicated by the pCookie parameter will request from a server. The option parameter specifies an option tag as defined in RFC 2132. See the dhcp/dhcp.h include file for a listing of defined aliases for the available option tags. This routine will not accept the following option values, which are either used by the server for control purposes or only supplied by the client:
_DHCP_PAD_TAG
_DHCP_REQUEST_IPADDR_TAG
_DHCP_LEASE_TIME_TAG
_DHCP_OPT_OVERLOAD_TAG
_DHCP_MSGTYPE_TAG
_DHCP_SERVER_ID_TAG
_DHCP_REQ_LIST_TAG
_DHCP_ERRMSG_TAG
_DHCP_MAXMSGSIZE_TAG
_DHCP_CLASS_ID_TAG
_DHCP_CLIENT_ID_TAG
_DHCP_END_TAGThis routine also will not accept option values 62 or 63, which are not currently defined.
The maximum length of the option field in a DHCP message depends on the MTU size of the associated interface and the maximum DHCP message size set during the DHCP library initialization. Both the option request list and the options sent by the client through the dhcpcOptionAdd( ) routine share that field. Options which exceed the limit will not be stored.
The boot program automatically requests all options necessary for default target configuration. This routine is only necessary to support special circumstances in which additional options are required. Any options requested in that case may be retrieved after the runtime image has started.
The DHCP specification forbids changing the option request list after a lease has been established. Therefore, this routine must not be used after the dhcpcBind( ) call (in a runtime image) or the dhcpcBootBind( ) call (for a boot image). Changing the request list at that point could have unpredictable results.
Options are added directly to outgoing DHCP messages, and numeric options (e.g. lease duration time) are expected to be provided in network byte order. Care must be taken on little-endian hosts to insure that numeric arguments are properly byte-swapped before being passed to this routine.
OK if the option was set successfully, or ERROR if the option is invalid or storage failed.
S_dhcpcLib_BAD_OPTION, S_dhcpcLib_OPTION_NOT_STORED
dhcpcOptionAdd( ) - add an option to the client messages
STATUS dhcpcOptionAdd ( void * pCookie, /* identifier returned by dhcpcInit() */ UCHAR option, /* RFC 2132 tag of desired option */ int length, /* length of option data */ UCHAR * pData /* option data */ )
This routine inserts option tags and associated values into the body of all outgoing messages for the lease indicated by the pCookie parameter. Each lease can accept option data up to the MTU size of the underlying interface, minus the link-level header size and the additional 283 bytes required for a minimum DHCP message (including mandatory options).
The option parameter specifies an option tag defined in RFC 2132. See the dhcp/dhcp.h include file for a listing of defined aliases for the available option tags. This routine will not accept the following option values, which are used for control purposes and cannot be included arbitrarily:
_DHCP_PAD_TAG
_DHCP_OPT_OVERLOAD_TAG
_DHCP_MSGTYPE_TAG
_DHCP_SERVER_ID_TAG
_DHCP_MAXMSGSIZE_TAG
_DHCP_END_TAGThis routine also will not accept option values 62 or 63, which are not currently defined.
The length parameter indicates the number of bytes in the option body provided by the pData parameter.
The maximum length of the option field in a DHCP message depends on the MTU size of the associated interface and the maximum DHCP message size set during the DHCP library initialization. These option settings share that field with any option request list created through the dhcpcOptionSet( ) routine. Options which exceed the limit will not be stored.
Each call to this routine with the same option value usually replaces the value of the existing option, if any. However, the routine will append the new data for the option values which contain variable length lists, corresponding to tags 3-11, 21, 25, 33, 41-45, 48-49, 55, 65, and 68-76.
The _DHCP_REQ_LIST_TAG option value (55) will replace any existing list created with the dhcpcOptionSet( ) routine.
OK if the option was inserted successfully, or ERROR if the option is invalid or storage failed.
S_dhcpcLib_BAD_OPTION, S_dhcpcLib_OPTION_NOT_STORED