DHCPc_GetOptVal()

Gets the value of a specific DHCP option for a given interface.

Files

dhcp-c.h/dhcp-c.c

Prototype

          void  DHCPc_GetOptVal (NET_IF_NBR       if_nbr,
                                 DHCPc_OPT_CODE   opt_code,
                                 CPU_INT08U      *pval_buf,
                                 CPU_INT16U      *pval_buf_len,
                                 DHCPc_ERR       *perr);


Arguments

if_nbr

Interface number to get option value.

opt_code

Option code to get value.

pval_buf

Pointer to buffer that will receive the option value.

pval_buf_len

Pointer to a variable to… :

Pass the size of the buffer, in octets, pointed to by pval_buf;

Return the actual length of the option, if no errors;
Return an undefined value, otherwise.

perr

Pointer to variable that will receive the return error code from this function:

DHCPc_ERR_NONE
DHCPc_ERR_NULL_PTR
DHCPc_ERR_INIT_INCOMPLETE
DHCPc_ERR_IF_NOT_MANAGED
DHCPc_ERR_IF_NOT_CFG
DHCPc_ERR_IF_OPT_NONE
DHCPc_ERR_OPT_BUF_SIZE
DHCPc_OS_ERR_LOCK

Returned Values

None.

Required Configuration

None.

Notes / Warnings

None.

Example Usage

          #define  DHCP_TIME_OFFSET_VAL_BUF_LEN   4
           
          CPU_INT08U  time_offset_val_buf[DHCP_TIME_OFFSET_VAL_BUF_LEN];
          CPU_INT16U  offset_val_buf_len;
          DHCPc_ERR   err;
           
          offset_val_buf_len = DHCP_TIME_OFFSET_VAL_BUF_LEN;
          DHCPc_GetOptVal((NET_IF_NBR    ) NET_IF_NBR_BASE_CFGD,
                          (DHCPc_OPT_CODE) DHCP_OPT_TIME_OFFSET,
                          (CPU_INT08U   *)&time_offset_val_buf[0],
                          (CPU_INT16U   *)&offset_val_buf_len,
                          (DHCPc_ERR    *)&err);
          if (err == DHCPc_ERR_NONE) {
              printf("Time offset successful retrieved\n\r");
          } else {
              printf("Error retrieving DHCP time offset\n\r");
          }