?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 32

Line No. Rev Author Line
1 32 kaklik /*********************************************************************
2 *
3 * TCP Module Defs for Microchip TCP/IP Stack
4 *
5 *********************************************************************
6 * FileName: TCP.h
7 * Dependencies: StackTsk.h
8 * Processor: PIC18, PIC24F, PIC24H, dsPIC30F, dsPIC33F, PIC32
9 * Compiler: Microchip C32 v1.05 or higher
10 * Microchip C30 v3.12 or higher
11 * Microchip C18 v3.30 or higher
12 * HI-TECH PICC-18 PRO 9.63PL2 or higher
13 * Company: Microchip Technology, Inc.
14 *
15 * Software License Agreement
16 *
17 * Copyright (C) 2002-2009 Microchip Technology Inc. All rights
18 * reserved.
19 *
20 * Microchip licenses to you the right to use, modify, copy, and
21 * distribute:
22 * (i) the Software when embedded on a Microchip microcontroller or
23 * digital signal controller product ("Device") which is
24 * integrated into Licensee's product; or
25 * (ii) ONLY the Software driver source files ENC28J60.c, ENC28J60.h,
26 * ENCX24J600.c and ENCX24J600.h ported to a non-Microchip device
27 * used in conjunction with a Microchip ethernet controller for
28 * the sole purpose of interfacing with the ethernet controller.
29 *
30 * You should refer to the license agreement accompanying this
31 * Software for additional information regarding your rights and
32 * obligations.
33 *
34 * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT
35 * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT
36 * LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A
37 * PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
38 * MICROCHIP BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR
39 * CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF
40 * PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
41 * BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE
42 * THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER
43 * SIMILAR COSTS, WHETHER ASSERTED ON THE BASIS OF CONTRACT, TORT
44 * (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR OTHERWISE.
45 *
46 *
47 * Author Date Comment
48 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49 * Nilesh Rajbharti 5/8/01 Original (Rev 1.0)
50 * Howard Schlunder 11/30/06 See "TCPIP Stack Version.txt" file
51 ********************************************************************/
52 #ifndef __TCP_HITECH_WORKAROUND_H
53 #define __TCP_HITECH_WORKAROUND_H
54  
55 /****************************************************************************
56 Section:
57 Type Definitions
58 ***************************************************************************/
59  
60 // A TCP_SOCKET is stored as a single BYTE
61 typedef BYTE TCP_SOCKET;
62  
63 #define INVALID_SOCKET (0xFE) // The socket is invalid or could not be opened
64 #define UNKNOWN_SOCKET (0xFF) // The socket is not known
65  
66 /****************************************************************************
67 Section:
68 State Machine Variables
69 ***************************************************************************/
70  
71 // TCP States as defined by RFC 793
72 typedef enum
73 {
74 TCP_GET_DNS_MODULE, // Special state for TCP client mode sockets
75 TCP_DNS_RESOLVE, // Special state for TCP client mode sockets
76 TCP_GATEWAY_SEND_ARP, // Special state for TCP client mode sockets
77 TCP_GATEWAY_GET_ARP, // Special state for TCP client mode sockets
78  
79 TCP_LISTEN, // Socket is listening for connections
80 TCP_SYN_SENT, // A SYN has been sent, awaiting an SYN+ACK
81 TCP_SYN_RECEIVED, // A SYN has been received, awaiting an ACK
82 TCP_ESTABLISHED, // Socket is connected and connection is established
83 TCP_FIN_WAIT_1, // FIN WAIT state 1
84 TCP_FIN_WAIT_2, // FIN WAIT state 2
85 TCP_CLOSING, // Socket is closing
86 // TCP_TIME_WAIT, state is not implemented
87 TCP_CLOSE_WAIT, // Waiting to close the socket
88 TCP_LAST_ACK, // The final ACK has been sent
89 TCP_CLOSED, // Socket is idle and unallocated
90  
91 TCP_CLOSED_BUT_RESERVED // Special state for TCP client mode sockets. Socket is idle, but still allocated pending application closure of the handle.
92 } TCP_STATE;
93  
94 typedef enum
95 {
96 SSL_NONE = 0, // No security is enabled
97 SSL_HANDSHAKING, // Handshake is progressing (no application data allowed)
98 SSL_ESTABLISHED, // Connection is established and secured
99 SSL_CLOSED // Connection has been closed (no applicaiton data is allowed)
100 } SSL_STATE;
101  
102 /****************************************************************************
103 Section:
104 TCB Definitions
105 ***************************************************************************/
106  
107 // TCP Control Block (TCB) stub data storage. Stubs are stored in local PIC RAM for speed.
108 // Current size is 34 bytes (PIC18), 36 bytes (PIC24/dsPIC), or 56 (PIC32)
109 typedef struct
110 {
111 PTR_BASE bufferTxStart; // First byte of TX buffer
112 PTR_BASE bufferRxStart; // First byte of RX buffer. TX buffer ends 1 byte prior
113 PTR_BASE bufferEnd; // Last byte of RX buffer
114 PTR_BASE txHead; // Head pointer for TX
115 PTR_BASE txTail; // Tail pointer for TX
116 PTR_BASE rxHead; // Head pointer for RX
117 PTR_BASE rxTail; // Tail pointer for RX
118 DWORD eventTime; // Packet retransmissions, state changes
119 WORD eventTime2; // Window updates, automatic transmission
120 union
121 {
122 WORD delayedACKTime; // Delayed Acknowledgement timer
123 WORD closeWaitTime; // TCP_CLOSE_WAIT timeout timer
124 } OverlappedTimers;
125 TCP_STATE smState; // State of this socket
126 struct
127 {
128 unsigned char vUnackedKeepalives : 3; // Count of how many keepalives have been sent with no response
129 unsigned char bServer : 1; // Socket should return to listening state when closed
130 unsigned char bTimerEnabled : 1; // Timer is enabled
131 unsigned char bTimer2Enabled : 1; // Second timer is enabled
132 unsigned char bDelayedACKTimerEnabled : 1; // DelayedACK timer is enabled
133 unsigned char bOneSegmentReceived : 1; // A segment has been received
134 unsigned char bHalfFullFlush : 1; // Flush is for being half full
135 unsigned char bTXASAP : 1; // Transmit as soon as possible (for Flush)
136 unsigned char bTXASAPWithoutTimerReset : 1; // Transmit as soon as possible (for Flush), but do not reset retransmission timers
137 unsigned char bTXFIN : 1; // FIN needs to be transmitted
138 unsigned char bSocketReset : 1; // Socket has been reset (self-clearing semaphore)
139 unsigned char bSSLHandshaking : 1; // Socket is in an SSL handshake
140 unsigned char filler : 2; // Future expansion
141 } Flags;
142 WORD_VAL remoteHash; // Consists of remoteIP, remotePort, localPort for connected sockets. It is a localPort number only for listening server sockets.
143  
144 #if defined(STACK_USE_SSL)
145 PTR_BASE sslTxHead; // Position of data being written in next SSL application record
146 // Also serves as cache of localSSLPort when smState = TCP_LISTENING
147 PTR_BASE sslRxHead; // Position of incoming data not yet handled by SSL
148 BYTE sslStubID; // Which sslStub is associated with this connection
149 BYTE sslReqMessage; // Currently requested SSL message
150 #endif
151  
152 BYTE vMemoryMedium; // Which memory medium the TCB is actually stored
153  
154 } TCB_STUB;
155  
156 // Remainder of TCP Control Block data.
157 // The rest of the TCB is stored in Ethernet buffer RAM or elsewhere as defined by vMemoryMedium.
158 // Current size is 41 (PIC18), 42 (PIC24/dsPIC), or 48 bytes (PIC32)
159 typedef struct
160 {
161 DWORD retryInterval; // How long to wait before retrying transmission
162 DWORD MySEQ; // Local sequence number
163 DWORD RemoteSEQ; // Remote sequence number
164 PTR_BASE txUnackedTail; // TX tail pointer for data that is not yet acked
165 WORD_VAL remotePort; // Remote port number
166 WORD_VAL localPort; // Local port number
167 WORD remoteWindow; // Remote window size
168 WORD wFutureDataSize; // How much out-of-order data has been received
169 union
170 {
171 NODE_INFO niRemoteMACIP; // 10 bytes for MAC and IP address
172 DWORD dwRemoteHost; // RAM or ROM pointer to a hostname string (ex: "www.microchip.com")
173 } remote;
174 SHORT sHoleSize; // Size of the hole, or -1 for none exists. (0 indicates hole has just been filled)
175 struct
176 {
177 unsigned char bFINSent : 1; // A FIN has been sent
178 unsigned char bSYNSent : 1; // A SYN has been sent
179 unsigned char bRemoteHostIsROM : 1; // Remote host is stored in ROM
180 unsigned char bRXNoneACKed1 : 1; // A duplicate ACK was likely received
181 unsigned char bRXNoneACKed2 : 1; // A second duplicate ACK was likely received
182 unsigned char filler : 3; // future use
183 } flags;
184 WORD wRemoteMSS; // Maximum Segment Size option advirtised by the remote node during initial handshaking
185 #if defined(STACK_USE_SSL)
186 WORD_VAL localSSLPort; // Local SSL port number (for listening sockets)
187 #endif
188 BYTE retryCount; // Counter for transmission retries
189 BYTE vSocketPurpose; // Purpose of socket (as defined in TCPIPConfig.h)
190 } TCB;
191  
192 // Information about a socket
193 typedef struct
194 {
195 NODE_INFO remote; // NODE_INFO structure for remote node
196 WORD_VAL remotePort; // Port number associated with remote node
197 } SOCKET_INFO;
198  
199 /****************************************************************************
200 Section:
201 Function Declarations
202 ***************************************************************************/
203  
204 void TCPInit(void);
205 SOCKET_INFO* TCPGetRemoteInfo(TCP_SOCKET hTCP);
206 BOOL TCPWasReset(TCP_SOCKET hTCP);
207 BOOL TCPIsConnected(TCP_SOCKET hTCP);
208 void TCPDisconnect(TCP_SOCKET hTCP);
209 void TCPClose(TCP_SOCKET hTCP);
210 WORD TCPIsPutReady(TCP_SOCKET hTCP);
211 BOOL TCPPut(TCP_SOCKET hTCP, BYTE byte);
212 WORD TCPPutArray(TCP_SOCKET hTCP, BYTE* Data, WORD Len);
213 BYTE* TCPPutString(TCP_SOCKET hTCP, BYTE* Data);
214 WORD TCPIsGetReady(TCP_SOCKET hTCP);
215 WORD TCPGetRxFIFOFree(TCP_SOCKET hTCP);
216 BOOL TCPGet(TCP_SOCKET hTCP, BYTE* byte);
217 WORD TCPGetArray(TCP_SOCKET hTCP, BYTE* buffer, WORD count);
218 BYTE TCPPeek(TCP_SOCKET hTCP, WORD wStart);
219 WORD TCPPeekArray(TCP_SOCKET hTCP, BYTE *vBuffer, WORD wLen, WORD wStart);
220 WORD TCPFindEx(TCP_SOCKET hTCP, BYTE cFind, WORD wStart, WORD wSearchLen, BOOL bTextCompare);
221 WORD TCPFindArrayEx(TCP_SOCKET hTCP, BYTE* cFindArray, WORD wLen, WORD wStart, WORD wSearchLen, BOOL bTextCompare);
222 void TCPDiscard(TCP_SOCKET hTCP);
223 BOOL TCPProcess(NODE_INFO* remote, IP_ADDR* localIP, WORD len);
224 void TCPTick(void);
225 void TCPFlush(TCP_SOCKET hTCP);
226  
227 // Create a server socket and ignore dwRemoteHost.
228 #define TCP_OPEN_SERVER 0u
229 #if defined(STACK_CLIENT_MODE)
230 #if defined(STACK_USE_DNS)
231 // Create a client socket and use dwRemoteHost as a RAM pointer to a hostname string.
232 #define TCP_OPEN_RAM_HOST 1u
233 // Create a client socket and use dwRemoteHost as a ROM pointer to a hostname string.
234 #define TCP_OPEN_ROM_HOST 2u
235 #else
236 // Emit an undeclared identifier diagnostic if code tries to use TCP_OPEN_RAM_HOST while the DNS client module is not enabled.
237 #define TCP_OPEN_RAM_HOST You_need_to_enable_STACK_USE_DNS_to_use_TCP_OPEN_RAM_HOST
238 // Emit an undeclared identifier diagnostic if code tries to use TCP_OPEN_ROM_HOST while the DNS client module is not enabled.
239 #define TCP_OPEN_ROM_HOST You_need_to_enable_STACK_USE_DNS_to_use_TCP_OPEN_ROM_HOST
240 #endif
241 // Create a client socket and use dwRemoteHost as a literal IP address.
242 #define TCP_OPEN_IP_ADDRESS 3u
243 // Create a client socket and use dwRemoteHost as a pointer to a NODE_INFO structure containing the exact remote IP address and MAC address to use.
244 #define TCP_OPEN_NODE_INFO 4u
245 #else
246 // Emit an undeclared identifier diagnostic if code tries to use TCP_OPEN_RAM_HOST while STACK_CLIENT_MODE feature is not enabled.
247 #define TCP_OPEN_RAM_HOST You_need_to_enable_STACK_CLIENT_MODE_to_use_TCP_OPEN_RAM_HOST
248 // Emit an undeclared identifier diagnostic if code tries to use TCP_OPEN_ROM_HOST while STACK_CLIENT_MODE feature is not enabled.
249 #define TCP_OPEN_ROM_HOST You_need_to_enable_STACK_CLIENT_MODE_to_use_TCP_OPEN_ROM_HOST
250 // Emit an undeclared identifier diagnostic if code tries to use TCP_OPEN_IP_ADDRESS while STACK_CLIENT_MODE feature is not enabled.
251 #define TCP_OPEN_IP_ADDRESS You_need_to_enable_STACK_CLIENT_MODE_to_use_TCP_OPEN_IP_ADDRESS
252 // Emit an undeclared identifier diagnostic if code tries to use TCP_OPEN_NODE_INFO while STACK_CLIENT_MODE feature is not enabled.
253 #define TCP_OPEN_NODE_INFO You_need_to_enable_STACK_CLIENT_MODE_to_use_TCP_OPEN_NODE_INFO
254 #endif
255 TCP_SOCKET TCPOpen(DWORD dwRemoteHost, BYTE vRemoteHostType, WORD wPort, BYTE vSocketPurpose);
256  
257 #if defined(__18CXX)
258 WORD TCPFindROMArrayEx(TCP_SOCKET hTCP, ROM BYTE* cFindArray, WORD wLen, WORD wStart, WORD wSearchLen, BOOL bTextCompare);
259  
260 /*****************************************************************************
261 Summary:
262 Alias to TCPFindROMArrayEx with no length parameter.
263  
264 Description:
265 This function is an alias to TCPFindROMArrayEx with no length parameter.
266 It is provided for backwards compatibility with an older API.
267 ***************************************************************************/
268 #define TCPFindROMArray(a,b,c,d,e) TCPFindROMArrayEx(a,b,c,d,0,e)
269  
270 WORD TCPPutROMArray(TCP_SOCKET hTCP, ROM BYTE* Data, WORD Len);
271 ROM BYTE* TCPPutROMString(TCP_SOCKET hTCP, ROM BYTE* Data);
272 #else
273 #define TCPFindROMArray(a,b,c,d,e) TCPFindArray(a,(BYTE*)b,c,d,e)
274 #define TCPFindROMArrayEx(a,b,c,d,e,f) TCPFindArrayEx(a,(BYTE*)b,c,d,e,f)
275 #define TCPPutROMArray(a,b,c) TCPPutArray(a,(BYTE*)b,c)
276 #define TCPPutROMString(a,b) TCPPutString(a,(BYTE*)b)
277 #endif
278  
279 WORD TCPGetTxFIFOFull(TCP_SOCKET hTCP);
280 // Alias to TCPIsGetReady provided for API completeness
281 #define TCPGetRxFIFOFull(a) TCPIsGetReady(a)
282 // Alias to TCPIsPutReady provided for API completeness
283 #define TCPGetTxFIFOFree(a) TCPIsPutReady(a)
284  
285 #define TCP_ADJUST_GIVE_REST_TO_RX 0x01u // Resize flag: extra bytes go to RX
286 #define TCP_ADJUST_GIVE_REST_TO_TX 0x02u // Resize flag: extra bytes go to TX
287 #define TCP_ADJUST_PRESERVE_RX 0x04u // Resize flag: attempt to preserve RX buffer
288 #define TCP_ADJUST_PRESERVE_TX 0x08u // Resize flag: attempt to preserve TX buffer
289 BOOL TCPAdjustFIFOSize(TCP_SOCKET hTCP, WORD wMinRXSize, WORD wMinTXSize, BYTE vFlags);
290  
291 #if defined(STACK_USE_SSL)
292 BOOL TCPStartSSLClient(TCP_SOCKET hTCP, BYTE* host);
293 BOOL TCPStartSSLClientEx(TCP_SOCKET hTCP, BYTE* host, void * buffer, BYTE suppDataType);
294 BOOL TCPStartSSLServer(TCP_SOCKET hTCP);
295 BOOL TCPAddSSLListener(TCP_SOCKET hTCP, WORD port);
296 BOOL TCPRequestSSLMessage(TCP_SOCKET hTCP, BYTE msg);
297 BOOL TCPSSLIsHandshaking(TCP_SOCKET hTCP);
298 BOOL TCPIsSSL(TCP_SOCKET hTCP);
299 void TCPSSLHandshakeComplete(TCP_SOCKET hTCP);
300 void TCPSSLDecryptMAC(TCP_SOCKET hTCP, ARCFOUR_CTX* ctx, WORD len);
301 void TCPSSLInPlaceMACEncrypt(TCP_SOCKET hTCP, ARCFOUR_CTX* ctx, BYTE* MACSecret, WORD len);
302 void TCPSSLPutRecordHeader(TCP_SOCKET hTCP, BYTE* hdr, BOOL recDone);
303 WORD TCPSSLGetPendingTxSize(TCP_SOCKET hTCP);
304 void TCPSSLHandleIncoming(TCP_SOCKET hTCP);
305 #endif
306  
307 /*****************************************************************************
308 Summary:
309 Alias to TCPFindEx with no length parameter.
310  
311 Description:
312 This function is an alias to TCPFindEx with no length parameter. It is
313 provided for backwards compatibility with an older API.
314 ***************************************************************************/
315 #define TCPFind(a,b,c,d) TCPFindEx(a,b,c,0,d)
316  
317  
318 /*****************************************************************************
319 Summary:
320 Alias to TCPFindArrayEx with no length parameter.
321  
322 Description:
323 This function is an alias to TCPFindArrayEx with no length parameter. It is
324 provided for backwards compatibility with an older API.
325 ***************************************************************************/
326 #define TCPFindArray(a,b,c,d,e) TCPFindArrayEx(a,b,c,d,0,e)
327  
328 /*****************************************************************************
329 Summary:
330 Alias to TCPOpen as a server.
331  
332 Description:
333 This function is an alias to TCPOpen for server sockets. It is provided
334 for backwards compatibility with older versions of the stack. New
335 applications should use the TCPOpen API instead.
336 ***************************************************************************/
337 #define TCPListen(port) TCPOpen(0, TCP_OPEN_SERVER, port, TCP_PURPOSE_DEFAULT)
338  
339 /*****************************************************************************
340 Summary:
341 Alias to TCPOpen as a client.
342  
343 Description:
344 This function is an alias to TCPOpen for client sockets. It is provided
345 for backwards compatibility with older versions of the stack. New
346 applications should use the TCPOpen API instead.
347 ***************************************************************************/
348 #define TCPConnect(remote,port) TCPOpen((DWORD)remote, TCP_OPEN_NODE_INFO, port, TCP_PURPOSE_DEFAULT)
349  
350  
351 #endif
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3