net/dhcp.h File Reference
DHCP client Module for Modtronix TCP/IP Stack.
More...
|
Data Structures |
| union | _DHCP_CLIENT_FLAGS |
Defines |
| #define | BOOT_HW_TYPE (1u) |
| #define | BOOT_LEN_OF_HW_TYPE (6u) |
| #define | BOOT_REPLY (2u) |
| #define | BOOT_REQUEST (1u) |
| #define | DHCP_ACK_MESSAGE (5u) |
| #define | DHCP_CLIENT_PORT (68ul) |
| #define | DHCP_DECLINE_MESSAGE (4u) |
| #define | DHCP_DISCOVER_MESSAGE (1u) |
| #define | DHCP_DNS (6u) |
| #define | DHCP_END_OPTION (255u) |
| #define | DHCP_HOST_NAME (12u) |
| #define | DHCP_IP_LEASE_TIME (51u) |
| #define | DHCP_MESSAGE_TYPE (53u) |
| #define | DHCP_MESSAGE_TYPE_LEN (1u) |
| #define | DHCP_NAK_MESSAGE (6u) |
| #define | DHCP_OFFER_MESSAGE (2u) |
| #define | DHCP_OPTION_ACK_MESSAGE (53u) |
| #define | DHCP_PARAM_REQUEST_IP_ADDRESS (50u) |
| #define | DHCP_PARAM_REQUEST_IP_ADDRESS_LEN (4u) |
| #define | DHCP_PARAM_REQUEST_LIST (55u) |
| #define | DHCP_PARAM_REQUEST_LIST_LEN (4u) |
| #define | DHCP_RELEASE_MESSAGE (7u) |
| #define | DHCP_REQUEST_MESSAGE (3u) |
| #define | DHCP_ROUTER (3u) |
| #define | DHCP_SERVER_IDENTIFIER (54u) |
| #define | DHCP_SERVER_IDENTIFIER_LEN (4u) |
| #define | DHCP_SERVER_PORT (67ul) |
| #define | DHCP_SUBNET_MASK (1u) |
| #define | DHCP_TIMEOUT ((TICK)2 * (TICK)TICKS_PER_SECOND) |
| #define | DHCP_UNKNOWN_MESSAGE (0u) |
| #define | DHCPIsBound() (DHCPFlags.bits.bIsBound) |
| #define | STACK_IS_DHCP_ENABLED (1ul) |
Typedefs |
| typedef union _DHCP_CLIENT_FLAGS | DHCP_CLIENT_FLAGS |
| typedef enum _SM_DHCP | SM_DHCP |
Enumerations |
| enum | _SM_DHCP {
SM_DHCP_DISABLED = 0,
SM_DHCP_GET_SOCKET,
SM_DHCP_SEND_DISCOVERY,
SM_DHCP_GET_OFFER,
SM_DHCP_SEND_REQUEST,
SM_DHCP_GET_REQUEST_ACK,
SM_DHCP_BOUND,
SM_DHCP_SEND_RENEW,
SM_DHCP_GET_RENEW_ACK,
SM_DHCP_SEND_RENEW2,
SM_DHCP_GET_RENEW_ACK2,
SM_DHCP_SEND_RENEW3,
SM_DHCP_GET_RENEW_ACK3,
SM_DHCP_DISABLED = 0,
SM_DHCP_GET_SOCKET,
SM_DHCP_SEND_DISCOVERY,
SM_DHCP_GET_OFFER,
SM_DHCP_SEND_REQUEST,
SM_DHCP_GET_REQUEST_ACK,
SM_DHCP_BOUND,
SM_DHCP_SEND_RENEW,
SM_DHCP_GET_RENEW_ACK,
SM_DHCP_SEND_RENEW2,
SM_DHCP_GET_RENEW_ACK2,
SM_DHCP_SEND_RENEW3,
SM_DHCP_GET_RENEW_ACK3,
SM_DHCP_GET_SOCKET,
SM_DHCP_SEND_DISCOVERY,
SM_DHCP_GET_OFFER,
SM_DHCP_SEND_REQUEST,
SM_DHCP_GET_REQUEST_ACK,
SM_DHCP_BOUND,
SM_DHCP_SEND_RENEW,
SM_DHCP_GET_RENEW_ACK,
SM_DHCP_SEND_RENEW2,
SM_DHCP_GET_RENEW_ACK2,
SM_DHCP_SEND_RENEW3,
SM_DHCP_GET_RENEW_ACK3,
SM_DHCP_DISABLED,
SM_DHCP_DISABLED = 0,
SM_DHCP_GET_SOCKET,
SM_DHCP_SEND_DISCOVERY,
SM_DHCP_GET_OFFER,
SM_DHCP_SEND_REQUEST,
SM_DHCP_GET_REQUEST_ACK,
SM_DHCP_BOUND,
SM_DHCP_SEND_RENEW,
SM_DHCP_GET_RENEW_ACK,
SM_DHCP_SEND_RENEW2,
SM_DHCP_GET_RENEW_ACK2,
SM_DHCP_SEND_RENEW3,
SM_DHCP_GET_RENEW_ACK3,
SM_DHCP_INIT_FIRST_TIME,
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
} |
Functions |
| void | DHCPDisable (void) |
| void | DHCPEnable (void) |
| void | DHCPReset (void) |
| void | DHCPServerTask (void) |
| void | DHCPTask (void) |
Variables |
| BYTE | DHCPBindCount |
| DHCP_CLIENT_FLAGS | DHCPFlags |
| SM_DHCP | smDHCPState |
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
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].
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.
#define DHCP_CLIENT_PORT (68ul)
#define DHCP_SERVER_PORT (67ul)
#define DHCP_TIMEOUT ((TICK16)4 * (TICK16)TICKS_PER_SECOND)
- Author:
- Modtronix Engineering
- Dependencies:
- stacktsk.h, udp.h
- Compiler:
- MPLAB C18 v2.10 or higher
HITECH PICC-18 V8.35PL3 or higher
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].
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.
- Author:
- Modtronix Engineering
- Dependencies:
- stacktsk.h, udp.h
- Compiler:
- MPLAB C18 v2.10 or higher
HITECH PICC-18 V8.35PL3 or higher
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].
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.
#define DHCP_CLIENT_PORT (68)
#define DHCP_SERVER_PORT (67)
#define DHCP_TIMEOUT ((TICK16)4 * (TICK16)TICKS_PER_SECOND)
Define Documentation
| #define BOOT_HW_TYPE (1u) |
| #define BOOT_LEN_OF_HW_TYPE (6u) |
| #define BOOT_REQUEST (1u) |
| #define DHCP_ACK_MESSAGE (5u) |
| #define DHCP_CLIENT_PORT (68ul) |
| #define DHCP_DECLINE_MESSAGE (4u) |
| #define DHCP_DISCOVER_MESSAGE (1u) |
| #define DHCP_END_OPTION (255u) |
| #define DHCP_HOST_NAME (12u) |
| #define DHCP_IP_LEASE_TIME (51u) |
| #define DHCP_MESSAGE_TYPE (53u) |
| #define DHCP_MESSAGE_TYPE_LEN (1u) |
| #define DHCP_NAK_MESSAGE (6u) |
| #define DHCP_OFFER_MESSAGE (2u) |
| #define DHCP_OPTION_ACK_MESSAGE (53u) |
| #define DHCP_PARAM_REQUEST_IP_ADDRESS (50u) |
| #define DHCP_PARAM_REQUEST_IP_ADDRESS_LEN (4u) |
| #define DHCP_PARAM_REQUEST_LIST (55u) |
| #define DHCP_PARAM_REQUEST_LIST_LEN (4u) |
| #define DHCP_RELEASE_MESSAGE (7u) |
| #define DHCP_REQUEST_MESSAGE (3u) |
| #define DHCP_SERVER_IDENTIFIER (54u) |
| #define DHCP_SERVER_IDENTIFIER_LEN (4u) |
| #define DHCP_SERVER_PORT (67ul) |
| #define DHCP_SUBNET_MASK (1u) |
| #define DHCP_TIMEOUT ((TICK)2 * (TICK)TICKS_PER_SECOND) |
| #define DHCP_UNKNOWN_MESSAGE (0u) |
| #define DHCPIsBound |
( |
|
) |
(DHCPFlags.bits.bIsBound) |
Checks is DHCP is bound. This function is a MACRO to DHCPFlags.bits.bIsBound.
- Returns:
- TRUE if DHCP is bound to given configuration FALSE if DHCP has yet to be bound.
| #define STACK_IS_DHCP_ENABLED (1ul) |
Typedef Documentation
Enumeration Type Documentation
- Enumerator:
-
| SM_DHCP_DISABLED |
|
| SM_DHCP_GET_SOCKET |
|
| SM_DHCP_SEND_DISCOVERY |
|
| SM_DHCP_GET_OFFER |
|
| SM_DHCP_SEND_REQUEST |
|
| SM_DHCP_GET_REQUEST_ACK |
|
| SM_DHCP_BOUND |
|
| SM_DHCP_SEND_RENEW |
|
| SM_DHCP_GET_RENEW_ACK |
|
| SM_DHCP_SEND_RENEW2 |
|
| SM_DHCP_GET_RENEW_ACK2 |
|
| SM_DHCP_SEND_RENEW3 |
|
| SM_DHCP_GET_RENEW_ACK3 |
|
| SM_DHCP_DISABLED |
|
| SM_DHCP_GET_SOCKET |
|
| SM_DHCP_SEND_DISCOVERY |
|
| SM_DHCP_GET_OFFER |
|
| SM_DHCP_SEND_REQUEST |
|
| SM_DHCP_GET_REQUEST_ACK |
|
| SM_DHCP_BOUND |
|
| SM_DHCP_SEND_RENEW |
|
| SM_DHCP_GET_RENEW_ACK |
|
| SM_DHCP_SEND_RENEW2 |
|
| SM_DHCP_GET_RENEW_ACK2 |
|
| SM_DHCP_SEND_RENEW3 |
|
| SM_DHCP_GET_RENEW_ACK3 |
|
| SM_DHCP_GET_SOCKET |
|
| SM_DHCP_SEND_DISCOVERY |
|
| SM_DHCP_GET_OFFER |
|
| SM_DHCP_SEND_REQUEST |
|
| SM_DHCP_GET_REQUEST_ACK |
|
| SM_DHCP_BOUND |
|
| SM_DHCP_SEND_RENEW |
|
| SM_DHCP_GET_RENEW_ACK |
|
| SM_DHCP_SEND_RENEW2 |
|
| SM_DHCP_GET_RENEW_ACK2 |
|
| SM_DHCP_SEND_RENEW3 |
|
| SM_DHCP_GET_RENEW_ACK3 |
|
| SM_DHCP_DISABLED |
|
| SM_DHCP_DISABLED |
|
| SM_DHCP_GET_SOCKET |
|
| SM_DHCP_SEND_DISCOVERY |
|
| SM_DHCP_GET_OFFER |
|
| SM_DHCP_SEND_REQUEST |
|
| SM_DHCP_GET_REQUEST_ACK |
|
| SM_DHCP_BOUND |
|
| SM_DHCP_SEND_RENEW |
|
| SM_DHCP_GET_RENEW_ACK |
|
| SM_DHCP_SEND_RENEW2 |
|
| SM_DHCP_GET_RENEW_ACK2 |
|
| SM_DHCP_SEND_RENEW3 |
|
| SM_DHCP_GET_RENEW_ACK3 |
|
| SM_DHCP_INIT_FIRST_TIME |
|
| 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 |
|
Function Documentation
| void DHCPDisable |
( |
void |
|
) |
|
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.
Enables the DHCP Client. Enables the DHCP client if it is disabled. If it is already enabled, nothing is done.
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 DHCPServerTask |
( |
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() ) { MACGetHeader() 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