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

Annotation of /trunk/docs/Microchip TCP_IP stack/Include/TCPIP Stack/TCP.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 15 - (hide annotations) (download)
Thu Apr 19 09:01:15 2007 UTC (17 years, 3 months ago) by hedin
File MIME type: text/plain
File size: 5630 byte(s)
added the TCP/IP stack, source code.
1 hedin 15 /*********************************************************************
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
9     * Complier: Microchip C18 v3.02 or higher
10     * Microchip C30 v2.01 or higher
11     * Company: Microchip Technology, Inc.
12     *
13     * Software License Agreement
14     *
15     * Copyright © 2002-2007 Microchip Technology Inc. All rights
16     * reserved.
17     *
18     * Microchip licenses to you the right to use, modify, copy, and
19     * distribute:
20     * (i) the Software when embedded on a Microchip microcontroller or
21     * digital signal controller product (“Device”) which is
22     * integrated into Licensee’s product; or
23     * (ii) ONLY the Software driver source files ENC28J60.c and
24     * ENC28J60.h ported to a non-Microchip device used in
25     * conjunction with a Microchip ethernet controller for the
26     * sole purpose of interfacing with the ethernet controller.
27     *
28     * You should refer to the license agreement accompanying this
29     * Software for additional information regarding your rights and
30     * obligations.
31     *
32     * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS” WITHOUT
33     * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT
34     * LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A
35     * PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
36     * MICROCHIP BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR
37     * CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF
38     * PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
39     * BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE
40     * THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER
41     * SIMILAR COSTS, WHETHER ASSERTED ON THE BASIS OF CONTRACT, TORT
42     * (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR OTHERWISE.
43     *
44     *
45     * Author Date Comment
46     *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
47     * Nilesh Rajbharti 5/8/01 Original (Rev 1.0)
48     * Howard Schlunder 11/30/06 See "TCPIP Stack Version.txt" file
49     ********************************************************************/
50     #ifndef __TCP_H
51     #define __TCP_H
52    
53    
54     typedef BYTE TCP_SOCKET;
55    
56     #define INVALID_SOCKET (0xFE)
57     #define UNKNOWN_SOCKET (0xFF)
58    
59     // TCP States as defined by RFC 793
60     typedef enum _TCP_STATE
61     {
62     TCP_LISTEN = 0,
63     TCP_SYN_SENT,
64     TCP_SYN_RECEIVED,
65     TCP_ESTABLISHED,
66     TCP_FIN_WAIT_1,
67     TCP_FIN_WAIT_2,
68     TCP_CLOSING,
69     TCP_TIME_WAIT,
70     TCP_CLOSE_WAIT,
71     TCP_LAST_ACK,
72     TCP_CLOSED,
73     } TCP_STATE;
74    
75     // TCP Control Block (TCB) Information
76     // Stubs are stored in local PIC RAM
77     // Current size is 26 bytes
78     typedef struct _TCB_STUB
79     {
80     WORD_VAL remoteHash; // Hash consists of remoteIP, remotePort, localPort for connected sockets. It is a localPort number only for listening server sockets.
81     WORD bufferTxStart; // TCB is located sizeof(TCB) bytes before this address
82     WORD bufferRxStart;
83     WORD bufferEnd;
84     WORD txHead;
85     WORD txTail;
86     WORD rxHead;
87     WORD rxTail;
88     TICK eventTime; // Packet retransmissions, state changes
89     WORD eventTime2; // Window updates, automatic transmission
90     WORD delayedACKTime; // Delayed Acknowledgement timer
91     TCP_STATE smState;
92     struct
93     {
94     unsigned char bServer : 1;
95     unsigned char bTimerEnabled : 1;
96     unsigned char bTimer2Enabled : 1;
97     unsigned char bDelayedACKTimerEnabled : 1;
98     unsigned char bOneSegmentReceived : 1;
99     unsigned char bHalfFullFlush : 1;
100     unsigned char bTXASAP : 1;
101     } Flags;
102     } TCB_STUB;
103    
104     // The rest of the TCB is stored in Ethernet buffer RAM
105     // Current size is 35 bytes
106     typedef struct _TCB
107     {
108     NODE_INFO remote;
109     WORD_VAL remotePort;
110     WORD_VAL localPort;
111    
112     WORD txUnackedTail;
113     WORD remoteWindow;
114     DWORD MySEQ;
115     DWORD RemoteSEQ;
116     BYTE retryCount;
117     TICK retryInterval;
118     SHORT sHoleSize;
119     WORD wFutureDataSize;
120     } TCB;
121    
122     typedef struct _SOCKET_INFO
123     {
124     NODE_INFO remote;
125     WORD_VAL remotePort;
126     } SOCKET_INFO;
127    
128     #undef RESERVED_TCP_MEMORY
129     #define RESERVED_TCP_MEMORY ((DWORD)MAX_TCP_SOCKETS*((DWORD)(TCP_TX_FIFO_SIZE+1)+(DWORD)TCP_RX_FIFO_SIZE+(DWORD)sizeof(TCB)))
130    
131     #if !defined(__TCP_C)
132     extern TCB_STUB TCBStubs[MAX_TCP_SOCKETS];
133     #endif
134    
135    
136     void TCPInit(void);
137     SOCKET_INFO* TCPGetRemoteInfo(TCP_SOCKET hTCP);
138     TCP_SOCKET TCPListen(WORD port);
139     TCP_SOCKET TCPConnect(NODE_INFO *remote, WORD port);
140     BOOL TCPIsConnected(TCP_SOCKET hTCP);
141     void TCPDisconnect(TCP_SOCKET hTCP);
142     WORD TCPIsPutReady(TCP_SOCKET hTCP);
143     BOOL TCPPut(TCP_SOCKET hTCP, BYTE byte);
144     WORD TCPPutArray(TCP_SOCKET hTCP, BYTE *Data, WORD Len);
145     WORD TCPPutROMArray(TCP_SOCKET hTCP, ROM BYTE *Data, WORD Len);
146     BYTE* TCPPutString(TCP_SOCKET hTCP, BYTE *Data);
147     ROM BYTE* TCPPutROMString(TCP_SOCKET hTCP, ROM BYTE *Data);
148     WORD TCPIsGetReady(TCP_SOCKET hTCP);
149     WORD TCPGetRxFIFOFree(TCP_SOCKET hTCP);
150     BOOL TCPGet(TCP_SOCKET hTCP, BYTE *byte);
151     WORD TCPGetArray(TCP_SOCKET hTCP, BYTE *buffer, WORD count);
152     WORD TCPFind(TCP_SOCKET hTCP, BYTE cFind, WORD wStart, BOOL bTextCompare);
153     WORD TCPFindROMArray(TCP_SOCKET hTCP, ROM BYTE *cFindArray, WORD wLen, WORD wStart, BOOL bTextCompare);
154     WORD TCPFindArray(TCP_SOCKET hTCP, BYTE *cFindArray, WORD wLen, WORD wStart, BOOL bTextCompare);
155     void TCPDiscard(TCP_SOCKET hTCP);
156     BOOL TCPProcess(NODE_INFO *remote, IP_ADDR *localIP, WORD len);
157     void TCPTick(void);
158     void TCPFlush(TCP_SOCKET hTCP);
159    
160    
161    
162     #endif

  ViewVC Help
Powered by ViewVC 1.1.20