blob: 541b9d3fcf0c39cabf5e9525d9c2fca6e8ca7e3f [file] [log] [blame]
adamdunkels1e45c6d2003-09-02 21:47:27 +00001/**
adamdunkels0170b082003-10-01 11:25:37 +00002 * \addtogroup uip
3 * @{
4 */
5
6/**
adamdunkels1e45c6d2003-09-02 21:47:27 +00007 * \file
8 * Header file for the uIP TCP/IP stack.
9 * \author Adam Dunkels <adam@dunkels.com>
10 *
11 * The uIP TCP/IP stack header file contains definitions for a number
12 * of C macros that are used by uIP programs as well as internal uIP
13 * structures, TCP/IP header structures and function declarations.
14 *
15 */
16
adamdunkels0170b082003-10-01 11:25:37 +000017
adamdunkelsca9ddcb2003-03-19 14:13:31 +000018/*
adamdunkels1e45c6d2003-09-02 21:47:27 +000019 * Copyright (c) 2001-2003, Adam Dunkels.
adamdunkelsca9ddcb2003-03-19 14:13:31 +000020 * All rights reserved.
21 *
22 * Redistribution and use in source and binary forms, with or without
23 * modification, are permitted provided that the following conditions
24 * are met:
25 * 1. Redistributions of source code must retain the above copyright
26 * notice, this list of conditions and the following disclaimer.
27 * 2. Redistributions in binary form must reproduce the above copyright
28 * notice, this list of conditions and the following disclaimer in the
29 * documentation and/or other materials provided with the distribution.
adamdunkels1e45c6d2003-09-02 21:47:27 +000030 * 3. The name of the author may not be used to endorse or promote
adamdunkelsca9ddcb2003-03-19 14:13:31 +000031 * products derived from this software without specific prior
32 * written permission.
33 *
34 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
35 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
36 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
37 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
38 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
39 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
40 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
41 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
42 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
43 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
44 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 *
46 * This file is part of the uIP TCP/IP stack.
47 *
adamdunkels399a0782004-02-16 20:52:07 +000048 * $Id: uip.h,v 1.10 2004/02/16 20:52:07 adamdunkels Exp $
adamdunkelsca9ddcb2003-03-19 14:13:31 +000049 *
50 */
51
52#ifndef __UIP_H__
53#define __UIP_H__
54
55#include "uipopt.h"
56
adamdunkelsca9ddcb2003-03-19 14:13:31 +000057/*-----------------------------------------------------------------------------------*/
58/* First, the functions that should be called from the
59 * system. Initialization, the periodic timer and incoming packets are
60 * handled by the following three functions.
61 */
62
adamdunkels1e45c6d2003-09-02 21:47:27 +000063/**
adamdunkels0170b082003-10-01 11:25:37 +000064 * \defgroup uipconffunc uIP configuration functions
65 * @{
66 *
67 * The uIP configuration functions are used for setting run-time
68 * parameters in uIP such as IP addresses.
69 */
70
71/**
adamdunkels1e45c6d2003-09-02 21:47:27 +000072 * Set the IP address of this host.
adamdunkelsca9ddcb2003-03-19 14:13:31 +000073 *
adamdunkels1e45c6d2003-09-02 21:47:27 +000074 * The IP address is represented as a 4-byte array where the first
75 * octet of the IP address is put in the first member of the 4-byte
76 * array.
adamdunkelsca9ddcb2003-03-19 14:13:31 +000077 *
adamdunkels1e45c6d2003-09-02 21:47:27 +000078 * \param addr A pointer to a 4-byte representation of the IP address.
adamdunkelsb489e7a2003-10-14 11:12:50 +000079 *
80 * \hideinitializer
adamdunkelsca9ddcb2003-03-19 14:13:31 +000081 */
82#define uip_sethostaddr(addr) do { uip_hostaddr[0] = addr[0]; \
83 uip_hostaddr[1] = addr[1]; } while(0)
84
adamdunkels1e45c6d2003-09-02 21:47:27 +000085/**
86 * Get the IP address of this host.
adamdunkels66c6af62003-04-16 18:28:16 +000087 *
adamdunkels1e45c6d2003-09-02 21:47:27 +000088 * The IP address is represented as a 4-byte array where the first
89 * octet of the IP address is put in the first member of the 4-byte
90 * array.
91 *
92 * \param addr A pointer to a 4-byte array that will be filled in with
93 * the currently configured IP address.
adamdunkelsb489e7a2003-10-14 11:12:50 +000094 *
95 * \hideinitializer
adamdunkels66c6af62003-04-16 18:28:16 +000096 */
97#define uip_gethostaddr(addr) do { addr[0] = uip_hostaddr[0]; \
98 addr[1] = uip_hostaddr[1]; } while(0)
99
adamdunkels0170b082003-10-01 11:25:37 +0000100/** @} */
101
adamdunkelsb489e7a2003-10-14 11:12:50 +0000102/**
103 * \defgroup uipinit uIP initialization functions
104 * @{
105 *
106 * The uIP initialization functions are used for booting uIP.
107 */
adamdunkels0170b082003-10-01 11:25:37 +0000108
109/**
110 * uIP initialization function.
111 *
112 * This function should be called at boot up to initilize the uIP
113 * TCP/IP stack.
114 */
115void uip_init(void);
116
adamdunkelsb489e7a2003-10-14 11:12:50 +0000117/** @} */
118
adamdunkels0170b082003-10-01 11:25:37 +0000119/**
120 * \defgroup uipdevfunc uIP device driver functions
121 * @{
122 *
123 * These functions are used by a network device driver for interacting
124 * with uIP.
125 */
126
adamdunkels1e45c6d2003-09-02 21:47:27 +0000127/**
128 * Process an incoming packet.
129 *
130 * This function should be called when the device driver has received
131 * a packet from the network. The packet from the device driver must
132 * be present in the uip_buf buffer, and the length of the packet
133 * should be placed in the uip_len variable.
134 *
135 * When the function returns, there may be an outbound packet placed
136 * in the uip_buf packet buffer. If so, the uip_len variable is set to
137 * the length of the packet. If no packet is to be sent out, the
138 * uip_len variable is set to 0.
139 *
140 * The usual way of calling the function is presented by the source
141 * code below.
142 \code
143 uip_len = devicedriver_poll();
144 if(uip_len > 0) {
145 uip_input();
146 if(uip_len > 0) {
147 devicedriver_send();
148 }
149 }
150 \endcode
151 *
152 * \note If you are writing a uIP device driver that needs ARP
153 * (Address Resolution Protocol), e.g., when running uIP over
154 * Ethernet, you will need to call the uIP ARP code before calling
155 * this function:
156 \code
157 #define BUF ((struct uip_eth_hdr *)&uip_buf[0])
158 uip_len = ethernet_devicedrver_poll();
159 if(uip_len > 0) {
160 if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
161 uip_arp_ipin();
adamdunkels1e45c6d2003-09-02 21:47:27 +0000162 uip_input();
163 if(uip_len > 0) {
164 uip_arp_out();
165 ethernet_devicedriver_send();
166 }
167 } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
168 uip_arp_arpin();
169 if(uip_len > 0) {
170 ethernet_devicedriver_send();
171 }
172 }
173 \endcode
adamdunkelsb489e7a2003-10-14 11:12:50 +0000174 *
175 * \hideinitializer
adamdunkels1e45c6d2003-09-02 21:47:27 +0000176 */
177#define uip_input() uip_process(UIP_DATA)
178
179/**
adamdunkels1e45c6d2003-09-02 21:47:27 +0000180 * Periodic processing for a connection identified by its number.
181 *
182 * This function does the necessary periodic processing (timers,
183 * polling) for a uIP TCP conneciton, and should be called when the
184 * periodic uIP timer goes off. It should be called for every
185 * connection, regardless of whether they are open of closed.
186 *
187 * When the function returns, it may have an outbound packet waiting
188 * for service in the uIP packet buffer, and if so the uip_len
189 * variable is set to a value larger than zero. The device driver
190 * should be called to send out the packet.
191 *
192 * The ususal way of calling the function is through a for() loop like
193 * this:
194 \code
195 for(i = 0; i < UIP_CONNS; ++i) {
196 uip_periodic(i);
197 if(uip_len > 0) {
198 devicedriver_send();
199 }
200 }
201 \endcode
202 *
203 * \note If you are writing a uIP device driver that needs ARP
204 * (Address Resolution Protocol), e.g., when running uIP over
205 * Ethernet, you will need to call the uip_arp_out() function before
206 * calling the device driver:
207 \code
208 for(i = 0; i < UIP_CONNS; ++i) {
209 uip_periodic(i);
210 if(uip_len > 0) {
211 uip_arp_out();
212 ethernet_devicedriver_send();
213 }
214 }
215 \endcode
216 *
217 * \param conn The number of the connection which is to be periodically polled.
adamdunkelsb489e7a2003-10-14 11:12:50 +0000218 *
219 * \hideinitializer
adamdunkels1e45c6d2003-09-02 21:47:27 +0000220 */
221#define uip_periodic(conn) do { uip_conn = &uip_conns[conn]; \
222 uip_process(UIP_TIMER); } while (0)
223
224/**
225 * Periodic processing for a connection identified by a pointer to its structure.
226 *
227 * Same as uip_periodic() but takes a pointer to the actual uip_conn
228 * struct instead of an integer as its argument. This function can be
229 * used to force periodic processing of a specific connection.
230 *
231 * \param conn A pointer to the uip_conn struct for the connection to
232 * be processed.
adamdunkelsb489e7a2003-10-14 11:12:50 +0000233 *
234 * \hideinitializer
adamdunkels1e45c6d2003-09-02 21:47:27 +0000235 */
236#define uip_periodic_conn(conn) do { uip_conn = conn; \
237 uip_process(UIP_TIMER); } while (0)
238
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000239#if UIP_UDP
adamdunkels1e45c6d2003-09-02 21:47:27 +0000240/**
241 * Periodic processing for a UDP connection identified by its number.
242 *
243 * This function is essentially the same as uip_prerioic(), but for
244 * UDP connections. It is called in a similar fashion as the
245 * uip_periodic() function:
246 \code
247 for(i = 0; i < UIP_UDP_CONNS; i++) {
248 uip_udp_periodic(i);
249 if(uip_len > 0) {
250 devicedriver_send();
251 }
252 }
253 \endcode
254 *
255 * \note As for the uip_periodic() function, special care has to be
256 * taken when using uIP together with ARP and Ethernet:
257 \code
258 for(i = 0; i < UIP_UDP_CONNS; i++) {
259 uip_udp_periodic(i);
260 if(uip_len > 0) {
261 uip_arp_out();
262 ethernet_devicedriver_send();
263 }
264 }
265 \endcode
266 *
267 * \param conn The number of the UDP connection to be processed.
adamdunkelsb489e7a2003-10-14 11:12:50 +0000268 *
269 * \hideinitializer
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000270 */
271#define uip_udp_periodic(conn) do { uip_udp_conn = &uip_udp_conns[conn]; \
272 uip_process(UIP_UDP_TIMER); } while (0)
adamdunkelseb91d5f2003-08-20 20:58:08 +0000273
adamdunkels1e45c6d2003-09-02 21:47:27 +0000274/**
275 * Periodic processing for a UDP connection identified by a pointer to
276 * its structure.
277 *
278 * Same as uip_udp_periodic() but takes a pointer to the actual
279 * uip_conn struct instead of an integer as its argument. This
280 * function can be used to force periodic processing of a specific
281 * connection.
282 *
283 * \param conn A pointer to the uip_udp_conn struct for the connection
284 * to be processed.
adamdunkelsb489e7a2003-10-14 11:12:50 +0000285 *
286 * \hideinitializer
adamdunkelseb91d5f2003-08-20 20:58:08 +0000287 */
288#define uip_udp_periodic_conn(conn) do { uip_udp_conn = conn; \
289 uip_process(UIP_UDP_TIMER); } while (0)
adamdunkelsb489e7a2003-10-14 11:12:50 +0000290
291
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000292#endif /* UIP_UDP */
adamdunkels0170b082003-10-01 11:25:37 +0000293
294/**
295 * The uIP packet buffer.
296 *
297 * The uip_buf array is used to hold incoming and outgoing
298 * packets. The device driver should place incoming data into this
299 * buffer. When sending data, the device driver should read the link
300 * level headers and the TCP/IP headers from this buffer. The size of
301 * the link level headers is configured by the UIP_LLH_LEN define.
302 *
303 * \note The application data need not be placed in this buffer, so
304 * the device driver must read it from the place pointed to by the
305 * uip_appdata pointer as illustrated by the following example:
306 \code
307 void
308 devicedriver_send(void)
309 {
310 hwsend(&uip_buf[0], UIP_LLH_LEN);
311 hwsend(&uip_buf[UIP_LLH_LEN], 40);
312 hwsend(uip_appdata, uip_len - 40 - UIP_LLH_LEN);
313 }
314 \endcode
315 */
316extern u8_t uip_buf[UIP_BUFSIZE+2];
317
318/** @} */
319
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000320/*-----------------------------------------------------------------------------------*/
321/* Functions that are used by the uIP application program. Opening and
322 * closing connections, sending and receiving data, etc. is all
323 * handled by the functions below.
324*/
adamdunkels0170b082003-10-01 11:25:37 +0000325/**
326 * \defgroup uipappfunc uIP application functions
327 * @{
328 *
329 * Functions used by an application running of top of uIP.
330 */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000331
adamdunkels1e45c6d2003-09-02 21:47:27 +0000332/**
333 * Start listening to the specified port.
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000334 *
adamdunkels1e45c6d2003-09-02 21:47:27 +0000335 * \note Since this function expects the port number in network byte
336 * order, a conversion using HTONS() or htons() is necessary.
337 *
338 \code
339 uip_listen(HTONS(80));
340 \endcode
341 *
342 * \param port A 16-bit port number in network byte order.
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000343 */
344void uip_listen(u16_t port);
345
adamdunkels1e45c6d2003-09-02 21:47:27 +0000346/**
347 * Stop listening to the specified port.
adamdunkelscd8c3a22003-08-13 22:52:48 +0000348 *
adamdunkels1e45c6d2003-09-02 21:47:27 +0000349 * \note Since this function expects the port number in network byte
350 * order, a conversion using HTONS() or htons() is necessary.
351 *
352 \code
353 uip_unlisten(HTONS(80));
354 \endcode
355 *
356 * \param port A 16-bit port number in network byte order.
adamdunkelscd8c3a22003-08-13 22:52:48 +0000357 */
358void uip_unlisten(u16_t port);
359
adamdunkels1e45c6d2003-09-02 21:47:27 +0000360/**
361 * Connect to a remote host using TCP.
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000362 *
adamdunkels1e45c6d2003-09-02 21:47:27 +0000363 * This function is used to start a new connection to the specified
364 * port on the specied host. It allocates a new connection identifier,
365 * sets the connection to the SYN_SENT state and sets the
366 * retransmission timer to 0. This will cause a TCP SYN segment to be
367 * sent out the next time this connection is periodically processed,
368 * which usually is done within 0.5 seconds after the call to
369 * uip_connect().
370 *
371 * \note This function is avaliable only if support for active open
372 * has been configured by defining UIP_ACTIVE_OPEN to 1 in uipopt.h.
373 *
374 * \note Since this function requires the port number to be in network
375 * byte order, a convertion using HTONS() or htons() is necessary.
376 *
377 \code
378 u16_t ipaddr[2];
379
380 uip_ipaddr(ipaddr, 192,168,1,2);
381 uip_connect(ipaddr, HTONS(80));
382 \endcode
383 *
384 * \param ripaddr A pointer to a 4-byte array representing the IP
385 * address of the remote hot.
386 *
387 * \param port A 16-bit port number in network byte order.
388 *
389 * \return A pointer to the uIP connection identifier for the new connection,
390 * or NULL if no connection could be allocated.
391 *
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000392 */
393struct uip_conn *uip_connect(u16_t *ripaddr, u16_t port);
394
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000395
396
adamdunkels0170b082003-10-01 11:25:37 +0000397/**
adamdunkelsb489e7a2003-10-14 11:12:50 +0000398 * \internal
399 *
adamdunkels0170b082003-10-01 11:25:37 +0000400 * Check if a connection has outstanding (i.e., unacknowledged) data.
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000401 *
adamdunkels0170b082003-10-01 11:25:37 +0000402 * \param conn A pointer to the uip_conn structure for the connection.
adamdunkelsb489e7a2003-10-14 11:12:50 +0000403 *
404 * \hideinitializer
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000405 */
406#define uip_outstanding(conn) ((conn)->len)
407
adamdunkels0170b082003-10-01 11:25:37 +0000408/**
409 * Send data on the current connection.
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000410 *
adamdunkels0170b082003-10-01 11:25:37 +0000411 * This function is used to send out a single segment of TCP
412 * data. Only applications that have been invoked by uIP for event
413 * processing can send data.
414 *
adamdunkelsb489e7a2003-10-14 11:12:50 +0000415 * The amount of data that actually is sent out after a call to this
416 * funcion is determined by the maximum amount of data TCP allows. uIP
417 * will automatically crop the data so that only the appropriate
418 * amount of data is sent. The function uip_mss() can be used to query
419 * uIP for the amount of data that actually will be sent.
420 *
adamdunkels0170b082003-10-01 11:25:37 +0000421 * \note This function does not guarantee that the sent data will
422 * arrive at the destination. If the data is lost in the network, the
423 * application will be invoked with the uip_rexmit() event being
424 * set. The application will then have to resend the data using this
425 * function.
426 *
427 * \param data A pointer to the data which is to be sent.
428 *
adamdunkelsb489e7a2003-10-14 11:12:50 +0000429 * \param len The maximum amount of data bytes to be sent.
430 *
431 * \hideinitializer
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000432 */
adamdunkels0170b082003-10-01 11:25:37 +0000433#define uip_send(data, len) do { uip_sappdata = (data); uip_slen = (len);} while(0)
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000434
adamdunkels0170b082003-10-01 11:25:37 +0000435/**
436 * The length of any incoming data that is currently avaliable (if avaliable)
437 * in the uip_appdata buffer.
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000438 *
adamdunkels0170b082003-10-01 11:25:37 +0000439 * The test function uip_data() must first be used to check if there
440 * is any data available at all.
adamdunkelsb489e7a2003-10-14 11:12:50 +0000441 *
442 * \hideinitializer
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000443 */
444#define uip_datalen() uip_len
445
adamdunkels0170b082003-10-01 11:25:37 +0000446/**
447 * The length of any out-of-band data (urgent data) that has arrived
448 * on the connection.
449 *
450 * \note The configuration parameter UIP_URGDATA must be set for this
451 * function to be enabled.
adamdunkelsb489e7a2003-10-14 11:12:50 +0000452 *
453 * \hideinitializer
adamdunkels0170b082003-10-01 11:25:37 +0000454 */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000455#define uip_urgdatalen() uip_urglen
456
adamdunkels0170b082003-10-01 11:25:37 +0000457/**
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000458 * Close the current connection.
adamdunkels0170b082003-10-01 11:25:37 +0000459 *
460 * This function will close the current connection in a nice way.
adamdunkelsb489e7a2003-10-14 11:12:50 +0000461 *
462 * \hideinitializer
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000463 */
464#define uip_close() (uip_flags = UIP_CLOSE)
465
adamdunkels0170b082003-10-01 11:25:37 +0000466/**
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000467 * Abort the current connection.
adamdunkels0170b082003-10-01 11:25:37 +0000468 *
469 * This function will abort (reset) the current connection, and is
470 * usually used when an error has occured that prevents using the
471 * uip_close() function.
adamdunkelsb489e7a2003-10-14 11:12:50 +0000472 *
473 * \hideinitializer
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000474 */
475#define uip_abort() (uip_flags = UIP_ABORT)
476
adamdunkels0170b082003-10-01 11:25:37 +0000477/**
478 * Tell the sending host to stop sending data.
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000479 *
adamdunkels0170b082003-10-01 11:25:37 +0000480 * This function will close our receiver's window so that we stop
481 * receiving data for the current connection.
adamdunkelsb489e7a2003-10-14 11:12:50 +0000482 *
483 * \hideinitializer
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000484 */
485#define uip_stop() (uip_conn->tcpstateflags |= UIP_STOPPED)
486
adamdunkels0170b082003-10-01 11:25:37 +0000487/**
488 * Find out if the current connection has been previously stopped with
489 * uip_stop().
adamdunkelsb489e7a2003-10-14 11:12:50 +0000490 *
491 * \hideinitializer
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000492 */
493#define uip_stopped(conn) ((conn)->tcpstateflags & UIP_STOPPED)
494
adamdunkels0170b082003-10-01 11:25:37 +0000495/**
496 * Restart the current connection, if is has previously been stopped
497 * with uip_stop().
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000498 *
adamdunkels0170b082003-10-01 11:25:37 +0000499 * This function will open the receiver's window again so that we
500 * start receiving data for the current connection.
adamdunkelsb489e7a2003-10-14 11:12:50 +0000501 *
502 * \hideinitializer
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000503 */
504#define uip_restart() do { uip_flags |= UIP_NEWDATA; \
505 uip_conn->tcpstateflags &= ~UIP_STOPPED; \
506 } while(0)
507
508
509/* uIP tests that can be made to determine in what state the current
510 connection is, and what the application function should do. */
511
adamdunkels0170b082003-10-01 11:25:37 +0000512/**
513 * Is new incoming data available?
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000514 *
515 * Will reduce to non-zero if there is new data for the application
516 * present at the uip_appdata pointer. The size of the data is
517 * avaliable through the uip_len variable.
adamdunkelsb489e7a2003-10-14 11:12:50 +0000518 *
519 * \hideinitializer
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000520 */
521#define uip_newdata() (uip_flags & UIP_NEWDATA)
522
adamdunkels0170b082003-10-01 11:25:37 +0000523/**
524 * Has previously sent data been acknowledged?
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000525 *
526 * Will reduce to non-zero if the previously sent data has been
527 * acknowledged by the remote host. This means that the application
adamdunkels0170b082003-10-01 11:25:37 +0000528 * can send new data.
adamdunkelsb489e7a2003-10-14 11:12:50 +0000529 *
530 * \hideinitializer
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000531 */
532#define uip_acked() (uip_flags & UIP_ACKDATA)
adamdunkels0170b082003-10-01 11:25:37 +0000533
534/**
adamdunkels0170b082003-10-01 11:25:37 +0000535 * Has the connection just been connected?
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000536 *
537 * Reduces to non-zero if the current connection has been connected to
538 * a remote host. This will happen both if the connection has been
539 * actively opened (with uip_connect()) or passively opened (with
540 * uip_listen()).
adamdunkelsb489e7a2003-10-14 11:12:50 +0000541 *
542 * \hideinitializer
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000543 */
544#define uip_connected() (uip_flags & UIP_CONNECTED)
545
adamdunkels0170b082003-10-01 11:25:37 +0000546/**
547 * Has the connection been closed by the other end?
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000548 *
549 * Is non-zero if the connection has been closed by the remote
adamdunkels0170b082003-10-01 11:25:37 +0000550 * host. The application may then do the necessary clean-ups.
adamdunkelsb489e7a2003-10-14 11:12:50 +0000551 *
552 * \hideinitializer
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000553 */
554#define uip_closed() (uip_flags & UIP_CLOSE)
555
adamdunkels0170b082003-10-01 11:25:37 +0000556/**
557 * Has the connection been aborted by the other end?
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000558 *
559 * Non-zero if the current connection has been aborted (reset) by the
560 * remote host.
adamdunkelsb489e7a2003-10-14 11:12:50 +0000561 *
562 * \hideinitializer
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000563 */
564#define uip_aborted() (uip_flags & UIP_ABORT)
565
adamdunkels0170b082003-10-01 11:25:37 +0000566/**
567 * Has the connection timed out?
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000568 *
569 * Non-zero if the current connection has been aborted due to too many
570 * retransmissions.
adamdunkelsb489e7a2003-10-14 11:12:50 +0000571 *
572 * \hideinitializer
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000573 */
adamdunkels399a0782004-02-16 20:52:07 +0000574#define uip_timedout() (uip_flags & UIP_TIMEDOUT)
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000575
adamdunkels0170b082003-10-01 11:25:37 +0000576/**
577 * Do we need to retransmit previously data?
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000578 *
579 * Reduces to non-zero if the previously sent data has been lost in
580 * the network, and the application should retransmit it. The
adamdunkels0170b082003-10-01 11:25:37 +0000581 * application should send the exact same data as it did the last
582 * time, using the uip_send() function.
adamdunkelsb489e7a2003-10-14 11:12:50 +0000583 *
584 * \hideinitializer
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000585 */
586#define uip_rexmit() (uip_flags & UIP_REXMIT)
587
adamdunkels0170b082003-10-01 11:25:37 +0000588/**
589 * Is the connection being polled by uIP?
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000590 *
591 * Is non-zero if the reason the application is invoked is that the
592 * current connection has been idle for a while and should be
593 * polled.
adamdunkels0170b082003-10-01 11:25:37 +0000594 *
595 * The polling event can be used for sending data without having to
596 * wait for the remote host to send data.
adamdunkelsb489e7a2003-10-14 11:12:50 +0000597 *
598 * \hideinitializer
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000599 */
600#define uip_poll() (uip_flags & UIP_POLL)
601
adamdunkels0170b082003-10-01 11:25:37 +0000602/**
603 * Get the initial maxium segment size (MSS) of the current
604 * connection.
adamdunkelsb489e7a2003-10-14 11:12:50 +0000605 *
606 * \hideinitializer
adamdunkels0170b082003-10-01 11:25:37 +0000607 */
608#define uip_initialmss() (uip_conn->initialmss)
609
610/**
adamdunkelsb489e7a2003-10-14 11:12:50 +0000611 * Get the current maxium segment size that can be sent on the current
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000612 * connection.
adamdunkelsb489e7a2003-10-14 11:12:50 +0000613 *
614 * The current maxiumum segment size that can be sent on the
615 * connection is computed from the receiver's window and the MSS of
616 * the connection (which also is available by calling
617 * uip_initialmss()).
618 *
619 * \hideinitializer
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000620 */
621#define uip_mss() (uip_conn->mss)
622
adamdunkelsb489e7a2003-10-14 11:12:50 +0000623/**
624 * Set up a new UDP connection.
625 *
626 * \param ripaddr A pointer to a 4-byte structure representing the IP
627 * address of the remote host.
628 *
629 * \param rport The remote port number in network byte order.
630 *
631 * \return The uip_udp_conn structure for the new connection or NULL
632 * if no connection could be allocated.
633 */
634struct uip_udp_conn *uip_udp_new(u16_t *ripaddr, u16_t rport);
635
636/**
637 * Removed a UDP connection.
638 *
639 * \param conn A pointer to the uip_udp_conn structure for the connection.
640 *
641 * \hideinitializer
642 */
643#define uip_udp_remove(conn) (conn)->lport = 0
644
645/**
646 * Send a UDP datagram of length len on the current connection.
647 *
648 * This function can only be called in response to a UDP event (poll
649 * or newdata). The data must be present in the uip_buf buffer, at the
650 * place pointed to by the uip_appdata pointer.
651 *
652 * \param len The length of the data in the uip_buf buffer.
653 *
654 * \hideinitializer
655 */
656#define uip_udp_send(len) uip_slen = (len)
657
adamdunkels0170b082003-10-01 11:25:37 +0000658/** @} */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000659
660/* uIP convenience and converting functions. */
661
adamdunkels0170b082003-10-01 11:25:37 +0000662/**
663 * \defgroup uipconvfunc uIP conversion functions
664 * @{
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000665 *
adamdunkels0170b082003-10-01 11:25:37 +0000666 * These functions can be used for converting between different data
667 * formats used by uIP.
668 */
669
670/**
671 * Pack an IP address into a 4-byte array which is used by uIP to
672 * represent IP addresses.
673 *
674 * Example:
675 \code
676 u16_t ipaddr[2];
677
678 uip_ipaddr(&ipaddr, 192,168,1,2);
679 \endcode
680 *
681 * \param addr A pointer to a 4-byte array that will be filled in with
682 * the IP addres.
683 * \param addr0 The first octet of the IP address.
684 * \param addr1 The second octet of the IP address.
685 * \param addr2 The third octet of the IP address.
686 * \param addr3 The forth octet of the IP address.
adamdunkelsb489e7a2003-10-14 11:12:50 +0000687 *
688 * \hideinitializer
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000689 */
690#define uip_ipaddr(addr, addr0,addr1,addr2,addr3) do { \
adamdunkels47ec7fa2003-03-28 12:11:17 +0000691 (addr)[0] = HTONS(((addr0) << 8) | (addr1)); \
692 (addr)[1] = HTONS(((addr2) << 8) | (addr3)); \
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000693 } while(0)
694
adamdunkels0170b082003-10-01 11:25:37 +0000695/**
696 * Convert 16-bit quantity from host byte order to network byte order.
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000697 *
adamdunkels0170b082003-10-01 11:25:37 +0000698 * This macro is primarily used for converting constants from host
699 * byte order to network byte order. For converting variables to
700 * network byte order, use the htons() function instead.
adamdunkelsb489e7a2003-10-14 11:12:50 +0000701 *
702 * \hideinitializer
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000703 */
adamdunkels47ec7fa2003-03-28 12:11:17 +0000704#ifndef HTONS
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000705# if BYTE_ORDER == BIG_ENDIAN
adamdunkels47ec7fa2003-03-28 12:11:17 +0000706# define HTONS(n) (n)
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000707# else /* BYTE_ORDER == BIG_ENDIAN */
adamdunkels47ec7fa2003-03-28 12:11:17 +0000708# define HTONS(n) ((((u16_t)((n) & 0xff)) << 8) | (((n) & 0xff00) >> 8))
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000709# endif /* BYTE_ORDER == BIG_ENDIAN */
adamdunkels47ec7fa2003-03-28 12:11:17 +0000710#endif /* HTONS */
711
adamdunkels0170b082003-10-01 11:25:37 +0000712/**
713 * Convert 16-bit quantity from host byte order to network byte order.
714 *
715 * This function is primarily used for converting variables from host
716 * byte order to network byte order. For converting constants to
717 * network byte order, use the HTONS() macro instead.
718 */
adamdunkels47ec7fa2003-03-28 12:11:17 +0000719#ifndef htons
720u16_t htons(u16_t val);
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000721#endif /* htons */
722
adamdunkels0170b082003-10-01 11:25:37 +0000723/** @} */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000724
adamdunkels0170b082003-10-01 11:25:37 +0000725/**
726 * Pointer to the application data in the packet buffer.
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000727 *
728 * This pointer points to the application data when the application is
adamdunkels0170b082003-10-01 11:25:37 +0000729 * called. If the application wishes to send data, the application may
730 * use this space to write the data into before calling uip_send().
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000731 */
adamdunkels0170b082003-10-01 11:25:37 +0000732extern volatile u8_t *uip_appdata;
733extern volatile u8_t *uip_sappdata;
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000734
735#if UIP_URGDATA > 0
736/* u8_t *uip_urgdata:
737 *
738 * This pointer points to any urgent data that has been received. Only
739 * present if compiled with support for urgent data (UIP_URGDATA).
740 */
741extern volatile u8_t *uip_urgdata;
742#endif /* UIP_URGDATA > 0 */
743
744
745/* u[8|16]_t uip_len:
746 *
747 * When the application is called, uip_len contains the length of any
748 * new data that has been received from the remote host. The
749 * application should set this variable to the size of any data that
750 * the application wishes to send. When the network device driver
751 * output function is called, uip_len should contain the length of the
752 * outgoing packet.
753 */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000754extern volatile u16_t uip_len, uip_slen;
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000755
756#if UIP_URGDATA > 0
757extern volatile u8_t uip_urglen, uip_surglen;
758#endif /* UIP_URGDATA > 0 */
759
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000760
adamdunkels0170b082003-10-01 11:25:37 +0000761/**
762 * Representation of a uIP TCP connection.
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000763 *
764 * The uip_conn structure is used for identifying a connection. All
765 * but one field in the structure are to be considered read-only by an
766 * application. The only exception is the appstate field whos purpose
767 * is to let the application store application-specific state (e.g.,
768 * file pointers) for the connection. The size of this field is
769 * configured in the "uipopt.h" header file.
770 */
771struct uip_conn {
adamdunkels0170b082003-10-01 11:25:37 +0000772 u16_t ripaddr[2]; /**< The IP address of the remote host. */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000773
adamdunkels0170b082003-10-01 11:25:37 +0000774 u16_t lport; /**< The local TCP port, in network byte order. */
775 u16_t rport; /**< The local remote TCP port, in network byte
776 order. */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000777
adamdunkels0170b082003-10-01 11:25:37 +0000778 u8_t rcv_nxt[4]; /**< The sequence number that we expect to
779 receive next. */
780 u8_t snd_nxt[4]; /**< The sequence number that was last sent by
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000781 us. */
adamdunkels0170b082003-10-01 11:25:37 +0000782 u16_t len; /**< Length of the data that was previously sent. */
783 u16_t mss; /**< Current maximum segment size for the
784 connection. */
785 u16_t initialmss; /**< Initial maximum segment size for the
786 connection. */
adamdunkelsb489e7a2003-10-14 11:12:50 +0000787 u8_t sa; /**< Retransmission time-out calculation state
788 variable. */
789 u8_t sv; /**< Retransmission time-out calculation state
790 variable. */
791 u8_t rto; /**< Retransmission time-out. */
adamdunkels0170b082003-10-01 11:25:37 +0000792 u8_t tcpstateflags; /**< TCP state and flags. */
793 u8_t timer; /**< The retransmission timer. */
794 u8_t nrtx; /**< The number of retransmissions for the last
795 segment sent. */
796
797 /** The application state. */
798 u8_t appstate[UIP_APPSTATE_SIZE];
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000799};
800
adamdunkels0170b082003-10-01 11:25:37 +0000801
802/* Pointer to the current connection. */
803extern struct uip_conn *uip_conn;
804/* The array containing all uIP connections. */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000805extern struct uip_conn uip_conns[UIP_CONNS];
adamdunkels0170b082003-10-01 11:25:37 +0000806/**
807 * \addtogroup uiparch
808 * @{
809 */
810
811/**
812 * 4-byte array used for the 32-bit sequence number calculations.
813 */
814extern volatile u8_t uip_acc32[4];
815
816/** @} */
817
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000818
819#if UIP_UDP
adamdunkels1e45c6d2003-09-02 21:47:27 +0000820/**
821 * Representation of a uIP UDP connection.
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000822 */
823struct uip_udp_conn {
adamdunkelsb489e7a2003-10-14 11:12:50 +0000824 u16_t ripaddr[2]; /**< The IP address of the remote peer. */
825 u16_t lport; /**< The local port number in network byte order. */
826 u16_t rport; /**< The remote port number in network byte order. */
adamdunkels399a0782004-02-16 20:52:07 +0000827
828 /** The application state. */
829 u8_t appstate[UIP_APPSTATE_SIZE];
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000830};
831
832extern struct uip_udp_conn *uip_udp_conn;
833extern struct uip_udp_conn uip_udp_conns[UIP_UDP_CONNS];
834#endif /* UIP_UDP */
835
adamdunkelsb489e7a2003-10-14 11:12:50 +0000836/**
837 * The structure holding the TCP/IP statistics that are gathered if
838 * UIP_STATISTICS is set to 1.
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000839 *
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000840 */
841struct uip_stats {
842 struct {
adamdunkelsb489e7a2003-10-14 11:12:50 +0000843 uip_stats_t drop; /**< Number of dropped packets at the IP
844 layer. */
845 uip_stats_t recv; /**< Number of received packets at the IP
846 layer. */
847 uip_stats_t sent; /**< Number of sent packets at the IP
848 layer. */
849 uip_stats_t vhlerr; /**< Number of packets dropped due to wrong
850 IP version or header length. */
851 uip_stats_t hblenerr; /**< Number of packets dropped due to wrong
852 IP length, high byte. */
853 uip_stats_t lblenerr; /**< Number of packets dropped due to wrong
854 IP length, low byte. */
855 uip_stats_t fragerr; /**< Number of packets dropped since they
856 were IP fragments. */
857 uip_stats_t chkerr; /**< Number of packets dropped due to IP
858 checksum errors. */
859 uip_stats_t protoerr; /**< Number of packets dropped since they
860 were neither ICMP, UDP nor TCP. */
861 } ip; /**< IP statistics. */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000862 struct {
adamdunkelsb489e7a2003-10-14 11:12:50 +0000863 uip_stats_t drop; /**< Number of dropped ICMP packets. */
864 uip_stats_t recv; /**< Number of received ICMP packets. */
865 uip_stats_t sent; /**< Number of sent ICMP packets. */
866 uip_stats_t typeerr; /**< Number of ICMP packets with a wrong
867 type. */
868 } icmp; /**< ICMP statistics. */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000869 struct {
adamdunkelsb489e7a2003-10-14 11:12:50 +0000870 uip_stats_t drop; /**< Number of dropped TCP segments. */
871 uip_stats_t recv; /**< Number of recived TCP segments. */
872 uip_stats_t sent; /**< Number of sent TCP segments. */
873 uip_stats_t chkerr; /**< Number of TCP segments with a bad
874 checksum. */
875 uip_stats_t ackerr; /**< Number of TCP segments with a bad ACK
876 number. */
877 uip_stats_t rst; /**< Number of recevied TCP RST (reset) segments. */
878 uip_stats_t rexmit; /**< Number of retransmitted TCP segments. */
879 uip_stats_t syndrop; /**< Number of dropped SYNs due to too few
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000880 connections was avaliable. */
adamdunkelsb489e7a2003-10-14 11:12:50 +0000881 uip_stats_t synrst; /**< Number of SYNs for closed ports,
882 triggering a RST. */
883 } tcp; /**< TCP statistics. */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000884};
885
adamdunkelsb489e7a2003-10-14 11:12:50 +0000886/**
887 * The uIP TCP/IP statistics.
888 *
889 * This is the variable in which the uIP TCP/IP statistics are gathered.
890 */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000891extern struct uip_stats uip_stat;
892
893
894/*-----------------------------------------------------------------------------------*/
895/* All the stuff below this point is internal to uIP and should not be
896 * used directly by an application or by a device driver.
897 */
898/*-----------------------------------------------------------------------------------*/
899/* u8_t uip_flags:
900 *
901 * When the application is called, uip_flags will contain the flags
902 * that are defined in this file. Please read below for more
903 * infomation.
904 */
905extern volatile u8_t uip_flags;
906
907/* The following flags may be set in the global variable uip_flags
908 before calling the application callback. The UIP_ACKDATA and
909 UIP_NEWDATA flags may both be set at the same time, whereas the
910 others are mutualy exclusive. Note that these flags should *NOT* be
911 accessed directly, but through the uIP functions/macros. */
912
913#define UIP_ACKDATA 1 /* Signifies that the outstanding data was
914 acked and the application should send
915 out new data instead of retransmitting
916 the last data. */
917#define UIP_NEWDATA 2 /* Flags the fact that the peer has sent
918 us new data. */
919#define UIP_REXMIT 4 /* Tells the application to retransmit the
920 data that was last sent. */
921#define UIP_POLL 8 /* Used for polling the application, to
922 check if the application has data that
923 it wants to send. */
924#define UIP_CLOSE 16 /* The remote host has closed the
925 connection, thus the connection has
926 gone away. Or the application signals
927 that it wants to close the
928 connection. */
929#define UIP_ABORT 32 /* The remote host has aborted the
930 connection, thus the connection has
931 gone away. Or the application signals
932 that it wants to abort the
933 connection. */
934#define UIP_CONNECTED 64 /* We have got a connection from a remote
935 host and have set up a new connection
936 for it, or an active connection has
937 been successfully established. */
938
939#define UIP_TIMEDOUT 128 /* The connection has been aborted due to
940 too many retransmissions. */
941
942
943/* uip_process(flag):
944 *
945 * The actual uIP function which does all the work.
946 */
947void uip_process(u8_t flag);
948
949/* The following flags are passed as an argument to the uip_process()
950 function. They are used to distinguish between the two cases where
951 uip_process() is called. It can be called either because we have
952 incoming data that should be processed, or because the periodic
953 timer has fired. */
954
955#define UIP_DATA 1 /* Tells uIP that there is incoming data in
956 the uip_buf buffer. The length of the
957 data is stored in the global variable
958 uip_len. */
959#define UIP_TIMER 2 /* Tells uIP that the periodic timer has
960 fired. */
961#if UIP_UDP
962#define UIP_UDP_TIMER 3
963#endif /* UIP_UDP */
964
965/* The TCP states used in the uip_conn->tcpstateflags. */
966#define CLOSED 0
967#define SYN_RCVD 1
968#define SYN_SENT 2
969#define ESTABLISHED 3
970#define FIN_WAIT_1 4
971#define FIN_WAIT_2 5
972#define CLOSING 6
973#define TIME_WAIT 7
974#define LAST_ACK 8
975#define TS_MASK 15
976
977#define UIP_STOPPED 16
978
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000979#define UIP_TCPIP_HLEN 40
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000980
981/* The TCP and IP headers. */
982typedef struct {
983 /* IP header. */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000984 u8_t vhl,
985 tos,
986 len[2],
987 ipid[2],
988 ipoffset[2],
989 ttl,
990 proto;
991 u16_t ipchksum;
992 u16_t srcipaddr[2],
993 destipaddr[2];
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000994
995 /* TCP header. */
996 u16_t srcport,
997 destport;
998 u8_t seqno[4],
999 ackno[4],
1000 tcpoffset,
1001 flags,
1002 wnd[2];
1003 u16_t tcpchksum;
1004 u8_t urgp[2];
1005 u8_t optdata[4];
1006} uip_tcpip_hdr;
1007
1008/* The ICMP and IP headers. */
1009typedef struct {
1010 /* IP header. */
adamdunkelsca9ddcb2003-03-19 14:13:31 +00001011 u8_t vhl,
1012 tos,
1013 len[2],
1014 ipid[2],
1015 ipoffset[2],
1016 ttl,
1017 proto;
1018 u16_t ipchksum;
1019 u16_t srcipaddr[2],
1020 destipaddr[2];
adamdunkelsca9ddcb2003-03-19 14:13:31 +00001021 /* ICMP (echo) header. */
1022 u8_t type, icode;
1023 u16_t icmpchksum;
1024 u16_t id, seqno;
1025} uip_icmpip_hdr;
1026
1027
1028/* The UDP and IP headers. */
1029typedef struct {
1030 /* IP header. */
adamdunkelsca9ddcb2003-03-19 14:13:31 +00001031 u8_t vhl,
1032 tos,
1033 len[2],
1034 ipid[2],
1035 ipoffset[2],
1036 ttl,
1037 proto;
1038 u16_t ipchksum;
1039 u16_t srcipaddr[2],
1040 destipaddr[2];
adamdunkelsca9ddcb2003-03-19 14:13:31 +00001041
1042 /* UDP header. */
1043 u16_t srcport,
1044 destport;
1045 u16_t udplen;
1046 u16_t udpchksum;
1047} uip_udpip_hdr;
1048
1049#define UIP_PROTO_ICMP 1
1050#define UIP_PROTO_TCP 6
1051#define UIP_PROTO_UDP 17
1052
1053#if UIP_FIXEDADDR
adamdunkelsca9ddcb2003-03-19 14:13:31 +00001054extern const u16_t uip_hostaddr[2];
adamdunkelsca9ddcb2003-03-19 14:13:31 +00001055#else /* UIP_FIXEDADDR */
adamdunkelsca9ddcb2003-03-19 14:13:31 +00001056extern u16_t uip_hostaddr[2];
adamdunkelsca9ddcb2003-03-19 14:13:31 +00001057#endif /* UIP_FIXEDADDR */
1058
1059#endif /* __UIP_H__ */
1060
1061
adamdunkels0170b082003-10-01 11:25:37 +00001062/** @} */
adamdunkelsca9ddcb2003-03-19 14:13:31 +00001063