WIZlib Library API  ver 1.0
WIZlib Library API User Menual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Enumerations | Functions

Dynamic Host Configuration Protocol. More...

Collaboration diagram for DHCP:

Enumerations

enum  dhcp_state {
  DHCP_STATE_INIT, DHCP_STATE_SEARCHING, DHCP_STATE_SELECTING, DHCP_STATE_REQUESTING,
  DHCP_STATE_IP_CHECK, DHCP_STATE_BOUND, DHCP_STATE_FAILED
}
 DHCP State. More...
 
enum  dhcp_action { DHCP_ACT_NONE, DHCP_ACT_START, DHCP_ACT_RENEW, DHCP_ACT_REBIND }
 DHCP Action. More...
 

Functions

int8 dhcp_init (uint8 sock, void_func ip_update_hook, void_func ip_conflict_hook, wiz_NetInfo *def)
 Initialize DHCP module. More...
 
int8 dhcp_manual (dhcp_action action, uint32 *renew, uint32 *rebind)
 DHCP manual mode handler. More...
 
dhcp_state dhcp_get_state (void)
 Return current DHCP state. More...
 
void dhcp_set_storage (wiz_NetInfo *net)
 Update DHCP default address storage. More...
 
void dhcp_get_storage (wiz_NetInfo *net)
 Return DHCP default address storage. More...
 
void dhcp_static_mode (wiz_NetInfo *net)
 Change DHCP mode to Static. More...
 
void dhcp_auto_start (void)
 DHCP Auto mode (alarm mode) start function. More...
 

Detailed Description

Dynamic Host Configuration Protocol.

Enumeration Type Documentation

DHCP Action.

Enumerator
DHCP_ACT_NONE 

Do nothing (maybe previous DHCP action was failed)

DHCP_ACT_START 

Start IP Assign only when INIT state.

DHCP_ACT_RENEW 

Start Renew only when BOUND state.

DHCP_ACT_REBIND 

Start Rebind only when BOUND state.

Definition at line 38 of file dhcp.h.

enum dhcp_state

DHCP State.

Enumerator
DHCP_STATE_INIT 

INIT State - Send Discover Packet.

DHCP_STATE_SEARCHING 

SEARCHING State - Waiting for Offer.

DHCP_STATE_SELECTING 

SELECTING State - Send Request.

DHCP_STATE_REQUESTING 

REQUESTING State - Waiting for ACK.

DHCP_STATE_IP_CHECK 

IP_CHECK State - Check IP Validity.

DHCP_STATE_BOUND 

BOUND State - Set Alarm for next step.

DHCP_STATE_FAILED 

FAILED State - Set Static addresses temporally.

Definition at line 25 of file dhcp.h.

Function Documentation

void dhcp_auto_start ( void  )

DHCP Auto mode (alarm mode) start function.

  • Used for DHCP start action at Auto mode
    Auto mode can be selected at wizconfig.h file.
    (set USE_DHCP to VAL_ENABLE, and uncomment DHCP_AUTO define)
    and in the main loop, alarm_run should be called continuously.
  • At Static mode, it can be changed to DHCP mode through this function

Definition at line 404 of file dhcp.c.

dhcp_state dhcp_get_state ( void  )

Return current DHCP state.

Returns
DHCP state enum value (dhcp_state)

Definition at line 295 of file dhcp.c.

void dhcp_get_storage ( wiz_NetInfo net)

Return DHCP default address storage.

  • This may be different from real address device, because this is just default value.
  • MAC address of the storage is used when DHCP action (on the send packet)
  • The others are used when Static mode or DHCP failed
Parameters
netThe struct variable in which storage addresses will be returned

Definition at line 342 of file dhcp.c.

int8 dhcp_init ( uint8  sock,
void_func  ip_update_hook,
void_func  ip_conflict_hook,
wiz_NetInfo def 
)

Initialize DHCP module.

This should be called just one time at first time

Parameters
sockSocket number to use
ip_update_hookCallback function for IP-update hooking
ip_conflict_hookCallback function for IP-conflict hooking (Not implemented yet)
defDefault Address to set
Returns
RET_OK: Success
RET_NOK: Error

Definition at line 191 of file dhcp.c.

Here is the caller graph for this function:

int8 dhcp_manual ( dhcp_action  action,
uint32 *  renew,
uint32 *  rebind 
)

DHCP manual mode handler.

  • Blocking Function
  • Used only at DHCP manual mode (DHCP mode could be chosen at wizconfig.h file)
  • DHCP_MANUAL mode does not need a loop structure, but if there is no loop structure,
    you should handle renew & rebind with your own way, or just ignore renew & rebind action
Parameters
actionThe action you want to do. (dhcp_action)
renewFor returning renew time when DHCP be bound (NULL will be ignored)
rebindFor returning rebind time when DHCP be bound (NULL will be ignored)
Returns
RET_OK: Success
RET_NOK: Error

Definition at line 234 of file dhcp.c.

void dhcp_set_storage ( wiz_NetInfo net)

Update DHCP default address storage.

You can update DHCP internal address storage through this

  • Normally, don't need to use this function except MAC address changed case
  • MAC address of the storage is used when DHCP action (on the send packet)
  • The others are used when Static mode or DHCP failed
Parameters
netThe addresses you want to set at default address storage
  • All zero address (like 0.0.0.0 or 0:0:0:0:0:0) will be ignored
    and be returned with address set formerly in it for reference
  • Member variable DHCP is not used (just ignored)
See Also
wiz_NetInfo, dhcp_get_storage
Note
You should update MAC address when chip MAC address is changed.
If not, DHCP send packet will have wrong MAC address.

Definition at line 315 of file dhcp.c.

void dhcp_static_mode ( wiz_NetInfo net)

Change DHCP mode to Static.

Even though DHCP was enabled, it can be changed to Static mode through this function

Parameters
netThe addresses you want to set as static addresses
  • NULL parameter or NULL member variable will be ignored and internal storage addresses will be used
    and these address will be returned in this net parameter (if not NULL)

Definition at line 364 of file dhcp.c.