/[H8]/trunk/PIC/Demo trimmet/ip.h
ViewVC logotype

Contents of /trunk/PIC/Demo trimmet/ip.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 91 - (show annotations) (download)
Tue May 8 09:37:15 2007 UTC (17 years ago) by hedin
File MIME type: text/plain
File size: 7867 byte(s)
added tcp/ip stack demo, trimmed.
1 /*********************************************************************
2 *
3 * IP Defs for Microchip TCP/IP Stack
4 *
5 *********************************************************************
6 * FileName: IP.h
7 * Dependencies: StackTsk.h
8 * MAC.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 4/27/01 Original (Rev 1.0)
37 * Nilesh Rajbharti 2/9/02 Cleanup
38 * Nilesh Rajbharti 5/22/02 Rev 2.0 (See version.log for detail)
39 ********************************************************************/
40
41 #ifndef IP_H
42 #define IP_H
43
44 #include "stacktsk.h"
45 #include "mac.h"
46
47
48 #define IP_PROT_ICMP (1)
49 #define IP_PROT_TCP (6)
50 #define IP_PROT_UDP (17)
51
52
53 /*
54 * IP packet header definition
55 */
56 typedef struct _IP_HEADER
57 {
58 BYTE VersionIHL;
59 BYTE TypeOfService;
60 WORD TotalLength;
61 WORD Identification;
62 WORD FragmentInfo;
63 BYTE TimeToLive;
64 BYTE Protocol;
65 WORD HeaderChecksum;
66 IP_ADDR SourceAddress;
67 IP_ADDR DestAddress;
68
69 } IP_HEADER;
70
71
72 /*********************************************************************
73 * Function: BOOL IPIsTxReady()
74 *
75 * PreCondition: None
76 *
77 * Input: None
78 *
79 * Output: TRUE if transmit buffer is empty
80 * FALSE if transmit buffer is not empty
81 *
82 * Side Effects: None
83 *
84 * Note: None
85 *
86 ********************************************************************/
87 #define IPIsTxReady() MACIsTxReady()
88
89
90 /*********************************************************************
91 * Macro: IPSetTxBuffer(a, b)
92 *
93 * PreCondition: None
94 *
95 * Input: a - Buffer identifier
96 * b - Offset
97 *
98 * Output: Next Read/Write access to transmit buffer 'a'
99 * set to offset 'b'
100 *
101 * Side Effects: None
102 *
103 * Note: None
104 *
105 ********************************************************************/
106 #define IPSetTxBuffer(a, b) MACSetTxBuffer(a, b+sizeof(IP_HEADER))
107
108
109
110 /*********************************************************************
111 * Function: WORD IPPutHeader( IP_ADDR *Dest,
112 * BYTE Protocol,
113 * WORD Identifier,
114 * WORD DataLen)
115 *
116 * PreCondition: IPIsTxReady() == TRUE
117 *
118 * Input: Src - Destination node address
119 * Protocol - Current packet protocol
120 * Identifier - Current packet identifier
121 * DataLen - Current packet data length
122 *
123 * Output: Handle to current packet - For use by
124 * IPSendByte() function.
125 *
126 * Side Effects: None
127 *
128 * Note: Only one IP message can be transmitted at any
129 * time.
130 * Caller may not transmit and receive a message
131 * at the same time.
132 *
133 ********************************************************************/
134 WORD IPPutHeader(NODE_INFO *remote,
135 BYTE protocol,
136 WORD len);
137
138
139 /*********************************************************************
140 * Macro: IPPutArray(a, b)
141 *
142 * PreCondition: IPIsTxReady() == TRUE
143 *
144 * Input: a - Data buffer
145 * b - Buffer length
146 *
147 * Output: None
148 *
149 * Side Effects: None
150 *
151 * Note: Data is copied to IP data area.
152 *
153 ********************************************************************/
154 #define IPPutArray(a, b) MACPutArray(a, b)
155
156
157
158
159 /*********************************************************************
160 * Function: BOOL IPGetHeader( IP_ADDR *localIP,
161 * NODE_INFO *remote,
162 * BYTE *Protocol,
163 * WORD *len)
164 *
165 * PreCondition: MACGetHeader() == TRUE
166 *
167 * Input: localIP - Local node IP Address as received
168 * in current IP header.
169 * If this information is not required
170 * caller may pass NULL value.
171 * remote - Remote node info
172 * Protocol - Current packet protocol
173 * len - Current packet data length
174 *
175 * Output: TRUE, if valid packet was received
176 * FALSE otherwise
177 *
178 * Side Effects: None
179 *
180 * Note: Only one IP message can be received.
181 * Caller may not transmit and receive a message
182 * at the same time.
183 *
184 ********************************************************************/
185 BOOL IPGetHeader(IP_ADDR *localIP,
186 NODE_INFO *remote,
187 BYTE *protocol,
188 WORD *len);
189
190
191 /*********************************************************************
192 * Macro: IPDiscard()
193 *
194 * PreCondition: MACGetHeader() == TRUE
195 *
196 * Input: None
197 *
198 * Output: Current packet is discarded and buffer is
199 * freed-up
200 *
201 * Side Effects: None
202 *
203 * Note: None
204 *
205 ********************************************************************/
206 #define IPDiscard() MACDiscard()
207
208
209
210 /*********************************************************************
211 * Macro: IPGetArray(a, b)
212 *
213 * PreCondition: MACGetHeader() == TRUE
214 *
215 * Input: a - Data buffer
216 * b - Buffer length
217 *
218 * Output: None
219 *
220 * Side Effects: None
221 *
222 * Note: Data is copied from IP data to given buffer
223 *
224 ********************************************************************/
225 #define IPGetArray(a, b) MACGetArray(a, b)
226
227
228
229
230 /*********************************************************************
231 * Macro: IPSetRxBuffer(a)
232 *
233 * PreCondition: None
234 *
235 * Input: a - Offset
236 *
237 * Output: Next Read/Write access to receive buffer is
238 * set to offset 'b'
239 *
240 * Side Effects: None
241 *
242 * Note: None
243 *
244 ********************************************************************/
245 #define IPSetRxBuffer(a) MACSetRxBuffer(a+sizeof(IP_HEADER))
246
247
248
249
250
251 #endif
252
253
254

  ViewVC Help
Powered by ViewVC 1.1.20