/[H8]/trunk/docs/Microchip TCP_IP stack/Include/TCPIP Stack/DHCP.h
ViewVC logotype

Contents of /trunk/docs/Microchip TCP_IP stack/Include/TCPIP Stack/DHCP.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 15 - (show annotations) (download)
Thu Apr 19 09:01:15 2007 UTC (17 years, 1 month ago) by hedin
File MIME type: text/plain
File size: 5991 byte(s)
added the TCP/IP stack, source code.
1 /*********************************************************************
2 *
3 * DHCP Defs for Microchip TCP/IP Stack
4 *
5 *********************************************************************
6 * FileName: DHCP.h
7 * Dependencies: TCPIPStack.h
8 * UDP.h
9 * Processor: PIC18, PIC24F, PIC24H, dsPIC30F, dsPIC33F
10 * Complier: Microchip C18 v3.02 or higher
11 * Microchip C30 v2.01 or higher
12 * Company: Microchip Technology, Inc.
13 *
14 * Software License Agreement
15 *
16 * Copyright © 2002-2007 Microchip Technology Inc. All rights
17 * reserved.
18 *
19 * Microchip licenses to you the right to use, modify, copy, and
20 * distribute:
21 * (i) the Software when embedded on a Microchip microcontroller or
22 * digital signal controller product (“Device”) which is
23 * integrated into Licensee’s product; or
24 * (ii) ONLY the Software driver source files ENC28J60.c and
25 * ENC28J60.h ported to a non-Microchip device used in
26 * conjunction with a Microchip ethernet controller for the
27 * sole purpose of interfacing with the ethernet controller.
28 *
29 * You should refer to the license agreement accompanying this
30 * Software for additional information regarding your rights and
31 * obligations.
32 *
33 * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS” WITHOUT
34 * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT
35 * LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A
36 * PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
37 * MICROCHIP BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR
38 * CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF
39 * PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
40 * BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE
41 * THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER
42 * SIMILAR COSTS, WHETHER ASSERTED ON THE BASIS OF CONTRACT, TORT
43 * (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR OTHERWISE.
44 *
45 *
46 * Author Date Comment
47 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
48 * Nilesh Rajbharti 3/21/01 Original (Rev 1.0)
49 ********************************************************************/
50 #ifndef __DHCP_H
51 #define __DHCP_H
52
53 #define DHCP_CLIENT_PORT (68u)
54 #define DHCP_SERVER_PORT (67u)
55
56 #define BOOT_REQUEST (1u)
57 #define BOOT_REPLY (2u)
58 #define BOOT_HW_TYPE (1u)
59 #define BOOT_LEN_OF_HW_TYPE (6u)
60
61 #define DHCP_MESSAGE_TYPE (53u)
62 #define DHCP_MESSAGE_TYPE_LEN (1u)
63
64 #define DHCP_UNKNOWN_MESSAGE (0u)
65
66 #define DHCP_DISCOVER_MESSAGE (1u)
67 #define DHCP_OFFER_MESSAGE (2u)
68 #define DHCP_REQUEST_MESSAGE (3u)
69 #define DHCP_DECLINE_MESSAGE (4u)
70 #define DHCP_ACK_MESSAGE (5u)
71 #define DHCP_NAK_MESSAGE (6u)
72 #define DHCP_RELEASE_MESSAGE (7u)
73
74 #define DHCP_SERVER_IDENTIFIER (54u)
75 #define DHCP_SERVER_IDENTIFIER_LEN (4u)
76
77 #define DHCP_OPTION_ACK_MESSAGE (53u)
78 #define DHCP_PARAM_REQUEST_LIST (55u)
79 #define DHCP_PARAM_REQUEST_LIST_LEN (4u)
80 #define DHCP_PARAM_REQUEST_IP_ADDRESS (50u)
81 #define DHCP_PARAM_REQUEST_IP_ADDRESS_LEN (4u)
82 #define DHCP_SUBNET_MASK (1u)
83 #define DHCP_ROUTER (3u)
84 #define DHCP_DNS (6u)
85 #define DHCP_HOST_NAME (12u)
86 #define DHCP_IP_LEASE_TIME (51u)
87 #define DHCP_END_OPTION (255u)
88
89
90 typedef struct _BOOTP_HEADER
91 {
92 BYTE MessageType;
93 BYTE HardwareType;
94 BYTE HardwareLen;
95 BYTE Hops;
96 DWORD TransactionID;
97 WORD SecondsElapsed;
98 WORD BootpFlags;
99 IP_ADDR ClientIP;
100 IP_ADDR YourIP;
101 IP_ADDR NextServerIP;
102 IP_ADDR RelayAgentIP;
103 MAC_ADDR ClientMAC;
104 } BOOTP_HEADER;
105
106
107 typedef enum _SM_DHCP
108 {
109 SM_DHCP_DISABLED = 0,
110 SM_DHCP_GET_SOCKET,
111 SM_DHCP_SEND_DISCOVERY,
112 SM_DHCP_GET_OFFER,
113 SM_DHCP_SEND_REQUEST,
114 SM_DHCP_GET_REQUEST_ACK,
115 SM_DHCP_BOUND,
116 SM_DHCP_SEND_RENEW,
117 SM_DHCP_GET_RENEW_ACK,
118 SM_DHCP_SEND_RENEW2,
119 SM_DHCP_GET_RENEW_ACK2,
120 SM_DHCP_SEND_RENEW3,
121 SM_DHCP_GET_RENEW_ACK3
122 } SM_DHCP;
123
124
125 typedef union _DHCP_CLIENT_FLAGS
126 {
127 struct
128 {
129 unsigned char bIsBound : 1;
130 unsigned char bOfferReceived : 1;
131 unsigned char bDHCPServerDetected : 1;
132 } bits;
133 BYTE Val;
134 } DHCP_CLIENT_FLAGS;
135
136 #if !defined(__DHCP_C)
137 extern DHCP_CLIENT_FLAGS DHCPFlags;
138 extern SM_DHCP smDHCPState;
139 extern BYTE DHCPBindCount;
140 #endif
141
142 void DHCPReset(void);
143 void DHCPTask(void);
144 void DHCPServerTask(void);
145
146
147 /*********************************************************************
148 * Macro: void DHCPDisable(void)
149 *
150 * PreCondition: None
151 *
152 * Input: None
153 *
154 * Output: None
155 *
156 * Side Effects: None
157 *
158 * Overview: Puts DHCPTask into unhandled state "SM_DHCP_DISABLED"
159 * and hence DHCP is effictively disabled.
160 *
161 * Note: This macro should be called before DHCPTask is called
162 * or else a UDP port will be kept open and there will
163 * be no task to process it.
164 ********************************************************************/
165 #define DHCPDisable() (smDHCPState = SM_DHCP_DISABLED)
166
167
168 /*********************************************************************
169 * Macro: BOOL DHCPIsBound(void)
170 *
171 * PreCondition: None
172 *
173 * Input: None
174 *
175 * Output: TRUE if DHCP is bound to given configuration
176 * FALSE if DHCP has yet to be bound.
177 *
178 * Side Effects: None
179 *
180 * Overview: None
181 *
182 * Note:
183 ********************************************************************/
184 #define DHCPIsBound() (DHCPFlags.bits.bIsBound)
185
186 #endif

  ViewVC Help
Powered by ViewVC 1.1.20