1 |
/*********************************************************************
|
2 |
*
|
3 |
* DHCP Defs for Microchip TCP/IP Stack
|
4 |
*
|
5 |
*********************************************************************
|
6 |
* FileName: DHCP.h
|
7 |
* Dependencies: StackTsk.h
|
8 |
* UDP.h
|
9 |
* Processor: PIC18
|
10 |
* Complier: MCC18 v1.00.50 or higher
|
11 |
* HITECH PICC-18 V8.10PL1 or higher
|
12 |
* Company: Microchip Technology, Inc.
|
13 |
*
|
14 |
* Software License Agreement
|
15 |
*
|
16 |
* The software supplied herewith by Microchip Technology Incorporated
|
17 |
* (the “Company”) for its PICmicro® Microcontroller is intended and
|
18 |
* supplied to you, the Company’s customer, for use solely and
|
19 |
* exclusively on Microchip PICmicro Microcontroller products. The
|
20 |
* software is owned by the Company and/or its supplier, and is
|
21 |
* protected under applicable copyright laws. All rights are reserved.
|
22 |
* Any use in violation of the foregoing restrictions may subject the
|
23 |
* user to criminal sanctions under applicable laws, as well as to
|
24 |
* civil liability for the breach of the terms and conditions of this
|
25 |
* license.
|
26 |
*
|
27 |
* THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
|
28 |
* WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
|
29 |
* TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
30 |
* PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
|
31 |
* IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
|
32 |
* CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
33 |
*
|
34 |
* Author Date Comment
|
35 |
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
36 |
* Nilesh Rajbharti 3/21/01 Original (Rev 1.0)
|
37 |
********************************************************************/
|
38 |
#ifndef DHCP_H
|
39 |
#define DHCP_H
|
40 |
|
41 |
#include "stacktsk.h"
|
42 |
|
43 |
|
44 |
typedef enum _SM_DHCP
|
45 |
{
|
46 |
SM_DHCP_INIT,
|
47 |
SM_DHCP_RESET_WAIT,
|
48 |
SM_DHCP_BROADCAST,
|
49 |
SM_DHCP_DISCOVER,
|
50 |
SM_DHCP_REQUEST,
|
51 |
SM_DHCP_BIND,
|
52 |
SM_DHCP_BOUND,
|
53 |
SM_DHCP_DISABLED,
|
54 |
SM_DHCP_ABORTED
|
55 |
} SM_DHCP;
|
56 |
|
57 |
#if !defined(THIS_IS_DHCP)
|
58 |
extern SM_DHCP smDHCPState;
|
59 |
#endif
|
60 |
|
61 |
/*********************************************************************
|
62 |
* Macro: void DHCPDisable(void)
|
63 |
*
|
64 |
* PreCondition: None
|
65 |
*
|
66 |
* Input: None
|
67 |
*
|
68 |
* Output: None
|
69 |
*
|
70 |
* Side Effects: None
|
71 |
*
|
72 |
* Overview: Puts DHCPTask into unhandled state "SM_DHCP_DISABLED"
|
73 |
* and hence DHCP is effictively disabled.
|
74 |
*
|
75 |
* Note: This macro should be called before DHCPTask is called
|
76 |
* or else a UDP port will be kept open and there will
|
77 |
* be no task to process it.
|
78 |
********************************************************************/
|
79 |
#define DHCPDisable() (smDHCPState = SM_DHCP_DISABLED)
|
80 |
|
81 |
|
82 |
/*********************************************************************
|
83 |
* Function: void DHCPTask(void)
|
84 |
*
|
85 |
* PreCondition: DHCPInit() is already called AND
|
86 |
* IPGetHeader() is called with
|
87 |
* IPFrameType == IP_PROT_UDP
|
88 |
*
|
89 |
* Input: None
|
90 |
*
|
91 |
* Output: None
|
92 |
*
|
93 |
* Side Effects: None
|
94 |
*
|
95 |
* Overview: Fetches pending UDP packet from MAC receive buffer
|
96 |
* and dispatches it appropriate UDP socket.
|
97 |
* If not UDP socket is matched, UDP packet is
|
98 |
* silently discarded.
|
99 |
*
|
100 |
* Note: Caller must make sure that MAC receive buffer
|
101 |
* access pointer is set to begining of UDP packet.
|
102 |
* Required steps before calling this function is:
|
103 |
*
|
104 |
* If ( MACIsRxReady() )
|
105 |
* {
|
106 |
* MACGetHeader()
|
107 |
* If MACFrameType == IP
|
108 |
* IPGetHeader()
|
109 |
* if ( IPFrameType == IP_PROT_UDP )
|
110 |
* Call DHCPTask()
|
111 |
* ...
|
112 |
********************************************************************/
|
113 |
void DHCPTask(void);
|
114 |
|
115 |
|
116 |
/*********************************************************************
|
117 |
* Function: void DHCPAbort(void)
|
118 |
*
|
119 |
* PreCondition: DHCPTask() must have been called at least once.
|
120 |
*
|
121 |
* Input: None
|
122 |
*
|
123 |
* Output: None
|
124 |
*
|
125 |
* Side Effects: None
|
126 |
*
|
127 |
* Overview: Forgets about any previous DHCP attempts and
|
128 |
* closes DHCPSocket.
|
129 |
*
|
130 |
* Note:
|
131 |
********************************************************************/
|
132 |
void DHCPAbort(void);
|
133 |
|
134 |
|
135 |
|
136 |
/*********************************************************************
|
137 |
* Macro: BOOL DHCPIsBound(void)
|
138 |
*
|
139 |
* PreCondition: None
|
140 |
*
|
141 |
* Input: None
|
142 |
*
|
143 |
* Output: TRUE if DHCP is bound to given configuration
|
144 |
* FALSE if DHCP has yet to be bound.
|
145 |
*
|
146 |
* Side Effects: None
|
147 |
*
|
148 |
* Overview: None
|
149 |
*
|
150 |
* Note:
|
151 |
********************************************************************/
|
152 |
#define DHCPIsBound() (DHCPState.bits.bIsBound)
|
153 |
|
154 |
typedef union _DHCP_STATE
|
155 |
{
|
156 |
struct
|
157 |
{
|
158 |
unsigned int bIsBound : 1;
|
159 |
} bits;
|
160 |
BYTE Val;
|
161 |
} DHCP_STATE;
|
162 |
|
163 |
#if !defined(THIS_IS_DHCP)
|
164 |
extern DHCP_STATE DHCPState;
|
165 |
#endif
|
166 |
|
167 |
/*********************************************************************
|
168 |
* Macro: void DHCPReset(void)
|
169 |
*
|
170 |
* PreCondition: None
|
171 |
*
|
172 |
* Input: None
|
173 |
*
|
174 |
* Output: None
|
175 |
*
|
176 |
* Side Effects: None
|
177 |
*
|
178 |
* Overview: Closes any previously opened DHCP socket
|
179 |
* and resets DHCP state machine so that on next
|
180 |
* call to DHCPTask will result in new DHCP request.
|
181 |
*
|
182 |
* Note: None
|
183 |
********************************************************************/
|
184 |
void DHCPReset(void);
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
#endif
|