net/dhcp.h File Reference


Detailed Description

DHCP client Module for Modtronix TCP/IP Stack.

Author:
Modtronix Engineering
Dependencies:
stacktsk.h, udp.h
Compiler:
MPLAB C18 v2.10 or higher
HITECH PICC-18 V8.35PL3 or higher

Description

This module implements a DHCP client.
For a detailed description, see the DHCP section of this document - in [Modules] [TCP/IP Stack] [TCP/IP User Protocols].

Configuration

The following defines are used to configure this module, and should be placed in the projdefs.h (or similar) file. For details, see Project Configuration. To configure the module, the required defines should be uncommended, and the rest commented out.
 //*********************************************************************
 //-------------------- DHCP Configuration --------------------
 //*********************************************************************
 //Defines DHCP ports
 #define DHCP_CLIENT_PORT    (68)
 #define DHCP_SERVER_PORT    (67)

 //The stack uses the macro STACK_IS_DHCP_ENABLED to determine if DHCP is enabled or not.
 //The user can for example assign this macro to check if a flag is set. If not defined
 //by the user, it will be set to true.
 //#define STACK_IS_DHCP_ENABLED   (netflags & 0x01)

 //Timeouts
 #define DHCP_TIMEOUT        (TICK)(5 * TICK_SECOND)


Data Structures

union  _DHCP_STATE

Defines

#define DHCP_CLIENT_PORT   (68)
#define DHCP_SERVER_PORT   (67)
#define DHCP_TIMEOUT   ((TICK16)(2 * TICKS_PER_SECOND))
#define DHCPDisable()   (smDHCPState = SM_DHCP_DISABLED)
#define DHCPIsBound()   (DHCPState.bits.bIsBound)
#define STACK_IS_DHCP_ENABLED   (1)

Typedefs

typedef _DHCP_STATE DHCP_STATE
typedef enum _SM_DHCP SM_DHCP

Enumerations

enum  _SM_DHCP {
  SM_DHCP_INIT, SM_DHCP_RESET_WAIT, SM_DHCP_BROADCAST, SM_DHCP_DISCOVER,
  SM_DHCP_REQUEST, SM_DHCP_BIND, SM_DHCP_BOUND, SM_DHCP_DISABLED,
  SM_DHCP_ABORTED
}

Functions

void DHCPAbort (void)
void DHCPReset (void)
void DHCPTask (void)

Variables

DHCP_STATE DHCPState
SM_DHCP smDHCPState


Define Documentation

#define DHCP_CLIENT_PORT   (68)
 

#define DHCP_SERVER_PORT   (67)
 

#define DHCP_TIMEOUT   ((TICK16)(2 * TICKS_PER_SECOND))
 

 
#define DHCPDisable  )     (smDHCPState = SM_DHCP_DISABLED)
 

Puts DHCPTask into unhandled state "SM_DHCP_DISABLED" and hence DHCP is effictively disabled. Note: This macro should be called before DHCPTask is called or else a UDP port will be kept open and there will be no task to process it.

 
#define DHCPIsBound  )     (DHCPState.bits.bIsBound)
 

Checks is DHCP is bound

Returns:
TRUE if DHCP is bound to given configuration FALSE if DHCP has yet to be bound.

#define STACK_IS_DHCP_ENABLED   (1)
 


Typedef Documentation

typedef union _DHCP_STATE DHCP_STATE
 

typedef enum _SM_DHCP SM_DHCP
 


Enumeration Type Documentation

enum _SM_DHCP
 

Enumerator:
SM_DHCP_INIT 
SM_DHCP_RESET_WAIT 
SM_DHCP_BROADCAST 
SM_DHCP_DISCOVER 
SM_DHCP_REQUEST 
SM_DHCP_BIND 
SM_DHCP_BOUND 
SM_DHCP_DISABLED 
SM_DHCP_ABORTED 


Function Documentation

void DHCPAbort void   ) 
 

Forgets about any previous DHCP attempts and closes DHCPSocket.

Pre-Condition:
: DHCPTask() must have been called at least once.

void DHCPReset void   ) 
 

Closes any previously opened DHCP socket and resets DHCP state machine so that on next call to DHCPTask will result in new DHCP request.

void DHCPTask void   ) 
 

Fetches pending UDP packet from MAC receive buffer and dispatches it appropriate UDP socket. If not UDP socket is matched, UDP packet is silently discarded. Note: Caller must make sure that MAC receive buffer access pointer is set to begining of UDP packet. Required steps before calling this function is:

If ( MACIsRxReady() ) { MACRxbufGetHdr() If MACFrameType == IP IPGetHeader() if ( IPFrameType == IP_PROT_UDP ) Call DHCPTask() ... }

Pre-Condition:
: DHCPInit() is already called AND IPGetHeader() is called with IPFrameType == IP_PROT_UDP


Variable Documentation

DHCP_STATE DHCPState
 

SM_DHCP smDHCPState
 


Generated on Tue Feb 21 15:18:06 2006 for SBC65EC Web Server by  doxygen 1.4.5