8 * Header file for the uIP TCP/IP stack.
\r
9 * \author Adam Dunkels <adam@dunkels.com>
\r
11 * The uIP TCP/IP stack header file contains definitions for a number
\r
12 * of C macros that are used by uIP programs as well as internal uIP
\r
13 * structures, TCP/IP header structures and function declarations.
\r
19 * Copyright (c) 2001-2003, Adam Dunkels.
\r
20 * All rights reserved.
\r
22 * Redistribution and use in source and binary forms, with or without
\r
23 * modification, are permitted provided that the following conditions
\r
25 * 1. Redistributions of source code must retain the above copyright
\r
26 * notice, this list of conditions and the following disclaimer.
\r
27 * 2. Redistributions in binary form must reproduce the above copyright
\r
28 * notice, this list of conditions and the following disclaimer in the
\r
29 * documentation and/or other materials provided with the distribution.
\r
30 * 3. The name of the author may not be used to endorse or promote
\r
31 * products derived from this software without specific prior
\r
32 * written permission.
\r
34 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
\r
35 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
\r
36 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
\r
37 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
\r
38 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
\r
39 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
\r
40 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
\r
41 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
\r
42 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
\r
43 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
\r
44 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
46 * This file is part of the uIP TCP/IP stack.
\r
48 * $Id: uip.h,v 1.36.2.7 2003/10/07 13:47:51 adam Exp $
\r
57 /*-----------------------------------------------------------------------------------*/
\r
58 /* First, the functions that should be called from the
\r
59 * system. Initialization, the periodic timer and incoming packets are
\r
60 * handled by the following three functions.
\r
64 * \defgroup uipconffunc uIP configuration functions
\r
67 * The uIP configuration functions are used for setting run-time
\r
68 * parameters in uIP such as IP addresses.
\r
72 * Set the IP address of this host.
\r
74 * The IP address is represented as a 4-byte array where the first
\r
75 * octet of the IP address is put in the first member of the 4-byte
\r
78 * \param addr A pointer to a 4-byte representation of the IP address.
\r
82 #define uip_sethostaddr(addr) do { uip_hostaddr[0] = addr[0]; \
\r
83 uip_hostaddr[1] = addr[1]; } while(0)
\r
86 * Get the IP address of this host.
\r
88 * The IP address is represented as a 4-byte array where the first
\r
89 * octet of the IP address is put in the first member of the 4-byte
\r
92 * \param addr A pointer to a 4-byte array that will be filled in with
\r
93 * the currently configured IP address.
\r
97 #define uip_gethostaddr(addr) do { addr[0] = uip_hostaddr[0]; \
\r
98 addr[1] = uip_hostaddr[1]; } while(0)
\r
103 * \defgroup uipinit uIP initialization functions
\r
106 * The uIP initialization functions are used for booting uIP.
\r
110 * uIP initialization function.
\r
112 * This function should be called at boot up to initilize the uIP
\r
115 void uip_init(void);
\r
120 * \defgroup uipdevfunc uIP device driver functions
\r
123 * These functions are used by a network device driver for interacting
\r
128 * Process an incoming packet.
\r
130 * This function should be called when the device driver has received
\r
131 * a packet from the network. The packet from the device driver must
\r
132 * be present in the uip_buf buffer, and the length of the packet
\r
133 * should be placed in the uip_len variable.
\r
135 * When the function returns, there may be an outbound packet placed
\r
136 * in the uip_buf packet buffer. If so, the uip_len variable is set to
\r
137 * the length of the packet. If no packet is to be sent out, the
\r
138 * uip_len variable is set to 0.
\r
140 * The usual way of calling the function is presented by the source
\r
143 uip_len = devicedriver_poll();
\r
147 devicedriver_send();
\r
152 * \note If you are writing a uIP device driver that needs ARP
\r
153 * (Address Resolution Protocol), e.g., when running uIP over
\r
154 * Ethernet, you will need to call the uIP ARP code before calling
\r
157 #define BUF ((struct uip_eth_hdr *)&uip_buf[0])
\r
158 uip_len = ethernet_devicedrver_poll();
\r
160 if(BUF->type == HTONS(UIP_ETHTYPE_IP)) {
\r
165 ethernet_devicedriver_send();
\r
167 } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) {
\r
170 ethernet_devicedriver_send();
\r
177 #define uip_input() uip_process(UIP_DATA)
\r
180 * Periodic processing for a connection identified by its number.
\r
182 * This function does the necessary periodic processing (timers,
\r
183 * polling) for a uIP TCP conneciton, and should be called when the
\r
184 * periodic uIP timer goes off. It should be called for every
\r
185 * connection, regardless of whether they are open of closed.
\r
187 * When the function returns, it may have an outbound packet waiting
\r
188 * for service in the uIP packet buffer, and if so the uip_len
\r
189 * variable is set to a value larger than zero. The device driver
\r
190 * should be called to send out the packet.
\r
192 * The ususal way of calling the function is through a for() loop like
\r
195 for(i = 0; i < UIP_CONNS; ++i) {
\r
198 devicedriver_send();
\r
203 * \note If you are writing a uIP device driver that needs ARP
\r
204 * (Address Resolution Protocol), e.g., when running uIP over
\r
205 * Ethernet, you will need to call the uip_arp_out() function before
\r
206 * calling the device driver:
\r
208 for(i = 0; i < UIP_CONNS; ++i) {
\r
212 ethernet_devicedriver_send();
\r
217 * \param conn The number of the connection which is to be periodically polled.
\r
221 #define uip_periodic(conn) do { uip_conn = &uip_conns[conn]; \
\r
222 uip_process(UIP_TIMER); } while (0)
\r
225 * Periodic processing for a connection identified by a pointer to its structure.
\r
227 * Same as uip_periodic() but takes a pointer to the actual uip_conn
\r
228 * struct instead of an integer as its argument. This function can be
\r
229 * used to force periodic processing of a specific connection.
\r
231 * \param conn A pointer to the uip_conn struct for the connection to
\r
236 #define uip_periodic_conn(conn) do { uip_conn = conn; \
\r
237 uip_process(UIP_TIMER); } while (0)
\r
241 * Periodic processing for a UDP connection identified by its number.
\r
243 * This function is essentially the same as uip_prerioic(), but for
\r
244 * UDP connections. It is called in a similar fashion as the
\r
245 * uip_periodic() function:
\r
247 for(i = 0; i < UIP_UDP_CONNS; i++) {
\r
248 uip_udp_periodic(i);
\r
250 devicedriver_send();
\r
255 * \note As for the uip_periodic() function, special care has to be
\r
256 * taken when using uIP together with ARP and Ethernet:
\r
258 for(i = 0; i < UIP_UDP_CONNS; i++) {
\r
259 uip_udp_periodic(i);
\r
262 ethernet_devicedriver_send();
\r
267 * \param conn The number of the UDP connection to be processed.
\r
271 #define uip_udp_periodic(conn) do { uip_udp_conn = &uip_udp_conns[conn]; \
\r
272 uip_process(UIP_UDP_TIMER); } while (0)
\r
275 * Periodic processing for a UDP connection identified by a pointer to
\r
278 * Same as uip_udp_periodic() but takes a pointer to the actual
\r
279 * uip_conn struct instead of an integer as its argument. This
\r
280 * function can be used to force periodic processing of a specific
\r
283 * \param conn A pointer to the uip_udp_conn struct for the connection
\r
288 #define uip_udp_periodic_conn(conn) do { uip_udp_conn = conn; \
\r
289 uip_process(UIP_UDP_TIMER); } while (0)
\r
292 #endif /* UIP_UDP */
\r
295 * The uIP packet buffer.
\r
297 * The uip_buf array is used to hold incoming and outgoing
\r
298 * packets. The device driver should place incoming data into this
\r
299 * buffer. When sending data, the device driver should read the link
\r
300 * level headers and the TCP/IP headers from this buffer. The size of
\r
301 * the link level headers is configured by the UIP_LLH_LEN define.
\r
303 * \note The application data need not be placed in this buffer, so
\r
304 * the device driver must read it from the place pointed to by the
\r
305 * uip_appdata pointer as illustrated by the following example:
\r
308 devicedriver_send(void)
\r
310 hwsend(&uip_buf[0], UIP_LLH_LEN);
\r
311 hwsend(&uip_buf[UIP_LLH_LEN], 40);
\r
312 hwsend(uip_appdata, uip_len - 40 - UIP_LLH_LEN);
\r
316 extern u8_t uip_buf[UIP_BUFSIZE+2] __attribute__ ((aligned (4)));
\r
320 /*-----------------------------------------------------------------------------------*/
\r
321 /* Functions that are used by the uIP application program. Opening and
\r
322 * closing connections, sending and receiving data, etc. is all
\r
323 * handled by the functions below.
\r
326 * \defgroup uipappfunc uIP application functions
\r
329 * Functions used by an application running of top of uIP.
\r
333 * Start listening to the specified port.
\r
335 * \note Since this function expects the port number in network byte
\r
336 * order, a conversion using HTONS() or htons() is necessary.
\r
339 uip_listen(HTONS(80));
\r
342 * \param port A 16-bit port number in network byte order.
\r
344 void uip_listen(u16_t port);
\r
347 * Stop listening to the specified port.
\r
349 * \note Since this function expects the port number in network byte
\r
350 * order, a conversion using HTONS() or htons() is necessary.
\r
353 uip_unlisten(HTONS(80));
\r
356 * \param port A 16-bit port number in network byte order.
\r
358 void uip_unlisten(u16_t port);
\r
361 * Connect to a remote host using TCP.
\r
363 * This function is used to start a new connection to the specified
\r
364 * port on the specied host. It allocates a new connection identifier,
\r
365 * sets the connection to the SYN_SENT state and sets the
\r
366 * retransmission timer to 0. This will cause a TCP SYN segment to be
\r
367 * sent out the next time this connection is periodically processed,
\r
368 * which usually is done within 0.5 seconds after the call to
\r
371 * \note This function is avaliable only if support for active open
\r
372 * has been configured by defining UIP_ACTIVE_OPEN to 1 in uipopt.h.
\r
374 * \note Since this function requires the port number to be in network
\r
375 * byte order, a convertion using HTONS() or htons() is necessary.
\r
380 uip_ipaddr(ipaddr, 192,168,1,2);
\r
381 uip_connect(ipaddr, HTONS(80));
\r
384 * \param ripaddr A pointer to a 4-byte array representing the IP
\r
385 * address of the remote hot.
\r
387 * \param port A 16-bit port number in network byte order.
\r
389 * \return A pointer to the uIP connection identifier for the new connection,
\r
390 * or NULL if no connection could be allocated.
\r
393 struct uip_conn *uip_connect(u16_t *ripaddr, u16_t port);
\r
400 * Check if a connection has outstanding (i.e., unacknowledged) data.
\r
402 * \param conn A pointer to the uip_conn structure for the connection.
\r
406 #define uip_outstanding(conn) ((conn)->len)
\r
409 * Send data on the current connection.
\r
411 * This function is used to send out a single segment of TCP
\r
412 * data. Only applications that have been invoked by uIP for event
\r
413 * processing can send data.
\r
415 * The amount of data that actually is sent out after a call to this
\r
416 * funcion is determined by the maximum amount of data TCP allows. uIP
\r
417 * will automatically crop the data so that only the appropriate
\r
418 * amount of data is sent. The function uip_mss() can be used to query
\r
419 * uIP for the amount of data that actually will be sent.
\r
421 * \note This function does not guarantee that the sent data will
\r
422 * arrive at the destination. If the data is lost in the network, the
\r
423 * application will be invoked with the uip_rexmit() event being
\r
424 * set. The application will then have to resend the data using this
\r
427 * \param data A pointer to the data which is to be sent.
\r
429 * \param len The maximum amount of data bytes to be sent.
\r
433 #define uip_send(data, len) do { uip_sappdata = (data); uip_slen = (len);} while(0)
\r
436 * The length of any incoming data that is currently avaliable (if avaliable)
\r
437 * in the uip_appdata buffer.
\r
439 * The test function uip_data() must first be used to check if there
\r
440 * is any data available at all.
\r
444 #define uip_datalen() uip_len
\r
447 * The length of any out-of-band data (urgent data) that has arrived
\r
448 * on the connection.
\r
450 * \note The configuration parameter UIP_URGDATA must be set for this
\r
451 * function to be enabled.
\r
455 #define uip_urgdatalen() uip_urglen
\r
458 * Close the current connection.
\r
460 * This function will close the current connection in a nice way.
\r
464 #define uip_close() (uip_flags = UIP_CLOSE)
\r
467 * Abort the current connection.
\r
469 * This function will abort (reset) the current connection, and is
\r
470 * usually used when an error has occured that prevents using the
\r
471 * uip_close() function.
\r
475 #define uip_abort() (uip_flags = UIP_ABORT)
\r
478 * Tell the sending host to stop sending data.
\r
480 * This function will close our receiver's window so that we stop
\r
481 * receiving data for the current connection.
\r
485 #define uip_stop() (uip_conn->tcpstateflags |= UIP_STOPPED)
\r
488 * Find out if the current connection has been previously stopped with
\r
493 #define uip_stopped(conn) ((conn)->tcpstateflags & UIP_STOPPED)
\r
496 * Restart the current connection, if is has previously been stopped
\r
499 * This function will open the receiver's window again so that we
\r
500 * start receiving data for the current connection.
\r
504 #define uip_restart() do { uip_flags |= UIP_NEWDATA; \
\r
505 uip_conn->tcpstateflags &= ~UIP_STOPPED; \
\r
509 /* uIP tests that can be made to determine in what state the current
\r
510 connection is, and what the application function should do. */
\r
513 * Is new incoming data available?
\r
515 * Will reduce to non-zero if there is new data for the application
\r
516 * present at the uip_appdata pointer. The size of the data is
\r
517 * avaliable through the uip_len variable.
\r
521 #define uip_newdata() (uip_flags & UIP_NEWDATA)
\r
524 * Has previously sent data been acknowledged?
\r
526 * Will reduce to non-zero if the previously sent data has been
\r
527 * acknowledged by the remote host. This means that the application
\r
528 * can send new data.
\r
532 #define uip_acked() (uip_flags & UIP_ACKDATA)
\r
535 * Has the connection just been connected?
\r
537 * Reduces to non-zero if the current connection has been connected to
\r
538 * a remote host. This will happen both if the connection has been
\r
539 * actively opened (with uip_connect()) or passively opened (with
\r
544 #define uip_connected() (uip_flags & UIP_CONNECTED)
\r
547 * Has the connection been closed by the other end?
\r
549 * Is non-zero if the connection has been closed by the remote
\r
550 * host. The application may then do the necessary clean-ups.
\r
554 #define uip_closed() (uip_flags & UIP_CLOSE)
\r
557 * Has the connection been aborted by the other end?
\r
559 * Non-zero if the current connection has been aborted (reset) by the
\r
564 #define uip_aborted() (uip_flags & UIP_ABORT)
\r
567 * Has the connection timed out?
\r
569 * Non-zero if the current connection has been aborted due to too many
\r
574 #define uip_timedout() (uip_flags & UIP_TIMEDOUT)
\r
577 * Do we need to retransmit previously data?
\r
579 * Reduces to non-zero if the previously sent data has been lost in
\r
580 * the network, and the application should retransmit it. The
\r
581 * application should send the exact same data as it did the last
\r
582 * time, using the uip_send() function.
\r
586 #define uip_rexmit() (uip_flags & UIP_REXMIT)
\r
589 * Is the connection being polled by uIP?
\r
591 * Is non-zero if the reason the application is invoked is that the
\r
592 * current connection has been idle for a while and should be
\r
595 * The polling event can be used for sending data without having to
\r
596 * wait for the remote host to send data.
\r
600 #define uip_poll() (uip_flags & UIP_POLL)
\r
603 * Get the initial maxium segment size (MSS) of the current
\r
608 #define uip_initialmss() (uip_conn->initialmss)
\r
611 * Get the current maxium segment size that can be sent on the current
\r
614 * The current maxiumum segment size that can be sent on the
\r
615 * connection is computed from the receiver's window and the MSS of
\r
616 * the connection (which also is available by calling
\r
617 * uip_initialmss()).
\r
621 #define uip_mss() (uip_conn->mss)
\r
624 * Set up a new UDP connection.
\r
626 * \param ripaddr A pointer to a 4-byte structure representing the IP
\r
627 * address of the remote host.
\r
629 * \param rport The remote port number in network byte order.
\r
631 * \return The uip_udp_conn structure for the new connection or NULL
\r
632 * if no connection could be allocated.
\r
634 struct uip_udp_conn *uip_udp_new(u16_t *ripaddr, u16_t rport);
\r
637 * Removed a UDP connection.
\r
639 * \param conn A pointer to the uip_udp_conn structure for the connection.
\r
643 #define uip_udp_remove(conn) (conn)->lport = 0
\r
646 * Send a UDP datagram of length len on the current connection.
\r
648 * This function can only be called in response to a UDP event (poll
\r
649 * or newdata). The data must be present in the uip_buf buffer, at the
\r
650 * place pointed to by the uip_appdata pointer.
\r
652 * \param len The length of the data in the uip_buf buffer.
\r
656 #define uip_udp_send(len) uip_slen = (len)
\r
660 /* uIP convenience and converting functions. */
\r
663 * \defgroup uipconvfunc uIP conversion functions
\r
666 * These functions can be used for converting between different data
\r
667 * formats used by uIP.
\r
671 * Pack an IP address into a 4-byte array which is used by uIP to
\r
672 * represent IP addresses.
\r
678 uip_ipaddr(&ipaddr, 192,168,1,2);
\r
681 * \param addr A pointer to a 4-byte array that will be filled in with
\r
683 * \param addr0 The first octet of the IP address.
\r
684 * \param addr1 The second octet of the IP address.
\r
685 * \param addr2 The third octet of the IP address.
\r
686 * \param addr3 The forth octet of the IP address.
\r
690 #define uip_ipaddr(addr, addr0,addr1,addr2,addr3) do { \
\r
691 (addr)[0] = HTONS(((addr0) << 8) | (addr1)); \
\r
692 (addr)[1] = HTONS(((addr2) << 8) | (addr3)); \
\r
696 * Convert 16-bit quantity from host byte order to network byte order.
\r
698 * This macro is primarily used for converting constants from host
\r
699 * byte order to network byte order. For converting variables to
\r
700 * network byte order, use the htons() function instead.
\r
705 # if BYTE_ORDER == BIG_ENDIAN
\r
706 # define HTONS(n) (n)
\r
707 # else /* BYTE_ORDER == BIG_ENDIAN */
\r
708 # define HTONS(n) ((((u16_t)((n) & 0xff)) << 8) | (((n) & 0xff00) >> 8))
\r
709 # endif /* BYTE_ORDER == BIG_ENDIAN */
\r
713 * Convert 16-bit quantity from host byte order to network byte order.
\r
715 * This function is primarily used for converting variables from host
\r
716 * byte order to network byte order. For converting constants to
\r
717 * network byte order, use the HTONS() macro instead.
\r
720 u16_t htons(u16_t val);
\r
726 * Pointer to the application data in the packet buffer.
\r
728 * This pointer points to the application data when the application is
\r
729 * called. If the application wishes to send data, the application may
\r
730 * use this space to write the data into before calling uip_send().
\r
732 extern volatile u8_t *uip_appdata;
\r
733 extern volatile u8_t *uip_sappdata;
\r
735 #if UIP_URGDATA > 0
\r
736 /* u8_t *uip_urgdata:
\r
738 * This pointer points to any urgent data that has been received. Only
\r
739 * present if compiled with support for urgent data (UIP_URGDATA).
\r
741 extern volatile u8_t *uip_urgdata;
\r
742 #endif /* UIP_URGDATA > 0 */
\r
745 /* u[8|16]_t uip_len:
\r
747 * When the application is called, uip_len contains the length of any
\r
748 * new data that has been received from the remote host. The
\r
749 * application should set this variable to the size of any data that
\r
750 * the application wishes to send. When the network device driver
\r
751 * output function is called, uip_len should contain the length of the
\r
754 extern volatile u16_t uip_len, uip_slen;
\r
756 #if UIP_URGDATA > 0
\r
757 extern volatile u8_t uip_urglen, uip_surglen;
\r
758 #endif /* UIP_URGDATA > 0 */
\r
762 * Representation of a uIP TCP connection.
\r
764 * The uip_conn structure is used for identifying a connection. All
\r
765 * but one field in the structure are to be considered read-only by an
\r
766 * application. The only exception is the appstate field whos purpose
\r
767 * is to let the application store application-specific state (e.g.,
\r
768 * file pointers) for the connection. The size of this field is
\r
769 * configured in the "uipopt.h" header file.
\r
772 u16_t ripaddr[2]; /**< The IP address of the remote host. */
\r
774 u16_t lport; /**< The local TCP port, in network byte order. */
\r
775 u16_t rport; /**< The local remote TCP port, in network byte
\r
778 u8_t rcv_nxt[4]; /**< The sequence number that we expect to
\r
780 u8_t snd_nxt[4]; /**< The sequence number that was last sent by
\r
782 u16_t len; /**< Length of the data that was previously sent. */
\r
783 u16_t mss; /**< Current maximum segment size for the
\r
785 u16_t initialmss; /**< Initial maximum segment size for the
\r
787 u8_t sa; /**< Retransmission time-out calculation state
\r
789 u8_t sv; /**< Retransmission time-out calculation state
\r
791 u8_t rto; /**< Retransmission time-out. */
\r
792 u8_t tcpstateflags; /**< TCP state and flags. */
\r
793 u8_t timer; /**< The retransmission timer. */
\r
794 u8_t nrtx; /**< The number of retransmissions for the last
\r
797 /** The application state. */
\r
798 u8_t appstate[UIP_APPSTATE_SIZE];
\r
802 /* Pointer to the current connection. */
\r
803 extern struct uip_conn *uip_conn;
\r
804 /* The array containing all uIP connections. */
\r
805 extern struct uip_conn uip_conns[UIP_CONNS];
\r
807 * \addtogroup uiparch
\r
812 * 4-byte array used for the 32-bit sequence number calculations.
\r
814 extern volatile u8_t uip_acc32[4];
\r
821 * Representation of a uIP UDP connection.
\r
823 struct uip_udp_conn {
\r
824 u16_t ripaddr[2]; /**< The IP address of the remote peer. */
\r
825 u16_t lport; /**< The local port number in network byte order. */
\r
826 u16_t rport; /**< The remote port number in network byte order. */
\r
829 extern struct uip_udp_conn *uip_udp_conn;
\r
830 extern struct uip_udp_conn uip_udp_conns[UIP_UDP_CONNS];
\r
831 #endif /* UIP_UDP */
\r
834 * The structure holding the TCP/IP statistics that are gathered if
\r
835 * UIP_STATISTICS is set to 1.
\r
840 uip_stats_t drop; /**< Number of dropped packets at the IP
\r
842 uip_stats_t recv; /**< Number of received packets at the IP
\r
844 uip_stats_t sent; /**< Number of sent packets at the IP
\r
846 uip_stats_t vhlerr; /**< Number of packets dropped due to wrong
\r
847 IP version or header length. */
\r
848 uip_stats_t hblenerr; /**< Number of packets dropped due to wrong
\r
849 IP length, high byte. */
\r
850 uip_stats_t lblenerr; /**< Number of packets dropped due to wrong
\r
851 IP length, low byte. */
\r
852 uip_stats_t fragerr; /**< Number of packets dropped since they
\r
853 were IP fragments. */
\r
854 uip_stats_t chkerr; /**< Number of packets dropped due to IP
\r
855 checksum errors. */
\r
856 uip_stats_t protoerr; /**< Number of packets dropped since they
\r
857 were neither ICMP, UDP nor TCP. */
\r
858 } ip; /**< IP statistics. */
\r
860 uip_stats_t drop; /**< Number of dropped ICMP packets. */
\r
861 uip_stats_t recv; /**< Number of received ICMP packets. */
\r
862 uip_stats_t sent; /**< Number of sent ICMP packets. */
\r
863 uip_stats_t typeerr; /**< Number of ICMP packets with a wrong
\r
865 } icmp; /**< ICMP statistics. */
\r
867 uip_stats_t drop; /**< Number of dropped TCP segments. */
\r
868 uip_stats_t recv; /**< Number of recived TCP segments. */
\r
869 uip_stats_t sent; /**< Number of sent TCP segments. */
\r
870 uip_stats_t chkerr; /**< Number of TCP segments with a bad
\r
872 uip_stats_t ackerr; /**< Number of TCP segments with a bad ACK
\r
874 uip_stats_t rst; /**< Number of recevied TCP RST (reset) segments. */
\r
875 uip_stats_t rexmit; /**< Number of retransmitted TCP segments. */
\r
876 uip_stats_t syndrop; /**< Number of dropped SYNs due to too few
\r
877 connections was avaliable. */
\r
878 uip_stats_t synrst; /**< Number of SYNs for closed ports,
\r
879 triggering a RST. */
\r
880 } tcp; /**< TCP statistics. */
\r
884 * The uIP TCP/IP statistics.
\r
886 * This is the variable in which the uIP TCP/IP statistics are gathered.
\r
888 extern struct uip_stats uip_stat;
\r
891 /*-----------------------------------------------------------------------------------*/
\r
892 /* All the stuff below this point is internal to uIP and should not be
\r
893 * used directly by an application or by a device driver.
\r
895 /*-----------------------------------------------------------------------------------*/
\r
898 * When the application is called, uip_flags will contain the flags
\r
899 * that are defined in this file. Please read below for more
\r
902 extern volatile u8_t uip_flags;
\r
904 /* The following flags may be set in the global variable uip_flags
\r
905 before calling the application callback. The UIP_ACKDATA and
\r
906 UIP_NEWDATA flags may both be set at the same time, whereas the
\r
907 others are mutualy exclusive. Note that these flags should *NOT* be
\r
908 accessed directly, but through the uIP functions/macros. */
\r
910 #define UIP_ACKDATA 1 /* Signifies that the outstanding data was
\r
911 acked and the application should send
\r
912 out new data instead of retransmitting
\r
914 #define UIP_NEWDATA 2 /* Flags the fact that the peer has sent
\r
916 #define UIP_REXMIT 4 /* Tells the application to retransmit the
\r
917 data that was last sent. */
\r
918 #define UIP_POLL 8 /* Used for polling the application, to
\r
919 check if the application has data that
\r
920 it wants to send. */
\r
921 #define UIP_CLOSE 16 /* The remote host has closed the
\r
922 connection, thus the connection has
\r
923 gone away. Or the application signals
\r
924 that it wants to close the
\r
926 #define UIP_ABORT 32 /* The remote host has aborted the
\r
927 connection, thus the connection has
\r
928 gone away. Or the application signals
\r
929 that it wants to abort the
\r
931 #define UIP_CONNECTED 64 /* We have got a connection from a remote
\r
932 host and have set up a new connection
\r
933 for it, or an active connection has
\r
934 been successfully established. */
\r
936 #define UIP_TIMEDOUT 128 /* The connection has been aborted due to
\r
937 too many retransmissions. */
\r
940 /* uip_process(flag):
\r
942 * The actual uIP function which does all the work.
\r
944 void uip_process(u8_t flag);
\r
946 /* The following flags are passed as an argument to the uip_process()
\r
947 function. They are used to distinguish between the two cases where
\r
948 uip_process() is called. It can be called either because we have
\r
949 incoming data that should be processed, or because the periodic
\r
950 timer has fired. */
\r
952 #define UIP_DATA 1 /* Tells uIP that there is incoming data in
\r
953 the uip_buf buffer. The length of the
\r
954 data is stored in the global variable
\r
956 #define UIP_TIMER 2 /* Tells uIP that the periodic timer has
\r
959 #define UIP_UDP_TIMER 3
\r
960 #endif /* UIP_UDP */
\r
962 /* The TCP states used in the uip_conn->tcpstateflags. */
\r
966 #define ESTABLISHED 3
\r
967 #define FIN_WAIT_1 4
\r
968 #define FIN_WAIT_2 5
\r
970 #define TIME_WAIT 7
\r
974 #define UIP_STOPPED 16
\r
976 #define UIP_TCPIP_HLEN 40
\r
978 /* The TCP and IP headers. */
\r
989 u16_t srcipaddr[2],
\r
1005 /* The ICMP and IP headers. */
\r
1016 u16_t srcipaddr[2],
\r
1018 /* ICMP (echo) header. */
\r
1025 /* The UDP and IP headers. */
\r
1036 u16_t srcipaddr[2],
\r
1046 #define UIP_PROTO_ICMP 1
\r
1047 #define UIP_PROTO_TCP 6
\r
1048 #define UIP_PROTO_UDP 17
\r
1051 extern const u16_t uip_hostaddr[2];
\r
1052 #else /* UIP_FIXEDADDR */
\r
1053 extern u16_t uip_hostaddr[2];
\r
1054 #endif /* UIP_FIXEDADDR */
\r
1056 #endif /* __UIP_H__ */
\r