Mercurial > templog
annotate network/uip.h @ 107:56d09a0969b5 avr-http
Import uIP and the PPP implementation from
https://code.google.com/p/avrusbmodem/
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 07 Sep 2012 23:53:53 +0800 |
parents | |
children |
rev | line source |
---|---|
107
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
3 * \addtogroup uip |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
4 * @{ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
5 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
6 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
7 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
8 * \file |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
9 * Header file for the uIP TCP/IP stack. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
10 * \author Adam Dunkels <[email protected]> |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
11 * \author Julien Abeille <[email protected]> (IPv6 related code) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
12 * \author Mathilde Durvy <[email protected]> (IPv6 related code) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
13 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
14 * The uIP TCP/IP stack header file contains definitions for a number |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
15 * of C macros that are used by uIP programs as well as internal uIP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
16 * structures, TCP/IP header structures and function declarations. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
17 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
18 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
19 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
20 /* |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
21 * Copyright (c) 2001-2003, Adam Dunkels. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
22 * All rights reserved. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
23 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
24 * Redistribution and use in source and binary forms, with or without |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
25 * modification, are permitted provided that the following conditions |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
26 * are met: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
27 * 1. Redistributions of source code must retain the above copyright |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
28 * notice, this list of conditions and the following disclaimer. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
29 * 2. Redistributions in binary form must reproduce the above copyright |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
30 * notice, this list of conditions and the following disclaimer in the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
31 * documentation and/or other materials provided with the distribution. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
32 * 3. The name of the author may not be used to endorse or promote |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
33 * products derived from this software without specific prior |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
34 * written permission. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
35 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
36 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
37 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
38 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
39 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
40 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
41 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
42 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
43 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
44 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
45 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
46 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
47 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
48 * This file is part of the uIP TCP/IP stack. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
49 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
50 * $Id: uip.h,v 1.35 2010/10/19 18:29:04 adamdunkels Exp $ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
51 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
52 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
53 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
54 #ifndef __UIP_H__ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
55 #define __UIP_H__ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
56 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
57 #include "uipopt.h" |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
58 #define CCIF |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
59 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
60 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
61 * Representation of an IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
62 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
63 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
64 #if UIP_CONF_IPV6 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
65 typedef union uip_ip6addr_t { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
66 u8_t u8[16]; /* Initializer, must come first!!! */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
67 u16_t u16[8]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
68 } uip_ip6addr_t; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
69 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
70 typedef uip_ip6addr_t uip_ipaddr_t; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
71 #else /* UIP_CONF_IPV6 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
72 typedef union uip_ip4addr_t { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
73 u8_t u8[4]; /* Initializer, must come first!!! */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
74 u16_t u16[2]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
75 #if 0 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
76 u32_t u32; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
77 #endif |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
78 } uip_ip4addr_t; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
79 typedef uip_ip4addr_t uip_ipaddr_t; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
80 #endif /* UIP_CONF_IPV6 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
81 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
82 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
83 /*---------------------------------------------------------------------------*/ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
84 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
85 /** \brief 16 bit 802.15.4 address */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
86 typedef struct uip_802154_shortaddr { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
87 u8_t addr[2]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
88 } uip_802154_shortaddr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
89 /** \brief 64 bit 802.15.4 address */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
90 typedef struct uip_802154_longaddr { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
91 u8_t addr[8]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
92 } uip_802154_longaddr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
93 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
94 /** \brief 802.11 address */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
95 typedef struct uip_80211_addr { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
96 u8_t addr[6]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
97 } uip_80211_addr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
98 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
99 /** \brief 802.3 address */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
100 typedef struct uip_eth_addr { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
101 u8_t addr[6]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
102 } uip_eth_addr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
103 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
104 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
105 #if UIP_CONF_LL_802154 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
106 /** \brief 802.15.4 address */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
107 typedef uip_802154_longaddr uip_lladdr_t; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
108 #define UIP_802154_SHORTADDR_LEN 2 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
109 #define UIP_802154_LONGADDR_LEN 8 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
110 #define UIP_LLADDR_LEN UIP_802154_LONGADDR_LEN |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
111 #else /*UIP_CONF_LL_802154*/ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
112 #if UIP_CONF_LL_80211 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
113 /** \brief 802.11 address */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
114 typedef uip_80211_addr uip_lladdr_t; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
115 #define UIP_LLADDR_LEN 6 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
116 #else /*UIP_CONF_LL_80211*/ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
117 /** \brief Ethernet address */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
118 typedef uip_eth_addr uip_lladdr_t; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
119 #define UIP_LLADDR_LEN 6 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
120 #endif /*UIP_CONF_LL_80211*/ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
121 #endif /*UIP_CONF_LL_802154*/ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
122 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
123 //#include "net/tcpip.h" |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
124 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
125 /*---------------------------------------------------------------------------*/ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
126 /* First, the functions that should be called from the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
127 * system. Initialization, the periodic timer, and incoming packets are |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
128 * handled by the following three functions. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
129 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
130 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
131 * \defgroup uipconffunc uIP configuration functions |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
132 * @{ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
133 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
134 * The uIP configuration functions are used for setting run-time |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
135 * parameters in uIP such as IP addresses. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
136 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
137 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
138 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
139 * Set the IP address of this host. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
140 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
141 * The IP address is represented as a 4-byte array where the first |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
142 * octet of the IP address is put in the first member of the 4-byte |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
143 * array. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
144 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
145 * Example: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
146 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
147 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
148 uip_ipaddr_t addr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
149 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
150 uip_ipaddr(&addr, 192,168,1,2); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
151 uip_sethostaddr(&addr); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
152 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
153 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
154 * \param addr A pointer to an IP address of type uip_ipaddr_t; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
155 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
156 * \sa uip_ipaddr() |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
157 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
158 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
159 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
160 #define uip_sethostaddr(addr) uip_ipaddr_copy(&uip_hostaddr, (addr)) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
161 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
162 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
163 * Get the IP address of this host. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
164 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
165 * The IP address is represented as a 4-byte array where the first |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
166 * octet of the IP address is put in the first member of the 4-byte |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
167 * array. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
168 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
169 * Example: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
170 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
171 uip_ipaddr_t hostaddr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
172 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
173 uip_gethostaddr(&hostaddr); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
174 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
175 * \param addr A pointer to a uip_ipaddr_t variable that will be |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
176 * filled in with the currently configured IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
177 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
178 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
179 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
180 #define uip_gethostaddr(addr) uip_ipaddr_copy((addr), &uip_hostaddr) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
181 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
182 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
183 * Set the default router's IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
184 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
185 * \param addr A pointer to a uip_ipaddr_t variable containing the IP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
186 * address of the default router. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
187 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
188 * \sa uip_ipaddr() |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
189 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
190 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
191 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
192 #define uip_setdraddr(addr) uip_ipaddr_copy(&uip_draddr, (addr)) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
193 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
194 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
195 * Set the netmask. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
196 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
197 * \param addr A pointer to a uip_ipaddr_t variable containing the IP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
198 * address of the netmask. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
199 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
200 * \sa uip_ipaddr() |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
201 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
202 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
203 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
204 #define uip_setnetmask(addr) uip_ipaddr_copy(&uip_netmask, (addr)) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
205 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
206 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
207 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
208 * Get the default router's IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
209 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
210 * \param addr A pointer to a uip_ipaddr_t variable that will be |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
211 * filled in with the IP address of the default router. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
212 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
213 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
214 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
215 #define uip_getdraddr(addr) uip_ipaddr_copy((addr), &uip_draddr) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
216 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
217 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
218 * Get the netmask. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
219 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
220 * \param addr A pointer to a uip_ipaddr_t variable that will be |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
221 * filled in with the value of the netmask. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
222 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
223 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
224 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
225 #define uip_getnetmask(addr) uip_ipaddr_copy((addr), &uip_netmask) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
226 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
227 /** @} */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
228 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
229 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
230 * \defgroup uipinit uIP initialization functions |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
231 * @{ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
232 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
233 * The uIP initialization functions are used for booting uIP. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
234 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
235 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
236 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
237 * uIP initialization function. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
238 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
239 * This function should be called at boot up to initilize the uIP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
240 * TCP/IP stack. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
241 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
242 void uip_init(void); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
243 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
244 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
245 * uIP initialization function. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
246 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
247 * This function may be used at boot time to set the initial ip_id. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
248 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
249 void uip_setipid(u16_t id); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
250 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
251 /** @} */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
252 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
253 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
254 * \defgroup uipdevfunc uIP device driver functions |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
255 * @{ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
256 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
257 * These functions are used by a network device driver for interacting |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
258 * with uIP. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
259 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
260 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
261 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
262 * Process an incoming packet. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
263 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
264 * This function should be called when the device driver has received |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
265 * a packet from the network. The packet from the device driver must |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
266 * be present in the uip_buf buffer, and the length of the packet |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
267 * should be placed in the uip_len variable. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
268 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
269 * When the function returns, there may be an outbound packet placed |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
270 * in the uip_buf packet buffer. If so, the uip_len variable is set to |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
271 * the length of the packet. If no packet is to be sent out, the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
272 * uip_len variable is set to 0. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
273 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
274 * The usual way of calling the function is presented by the source |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
275 * code below. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
276 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
277 uip_len = devicedriver_poll(); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
278 if(uip_len > 0) { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
279 uip_input(); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
280 if(uip_len > 0) { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
281 devicedriver_send(); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
282 } |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
283 } |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
284 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
285 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
286 * \note If you are writing a uIP device driver that needs ARP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
287 * (Address Resolution Protocol), e.g., when running uIP over |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
288 * Ethernet, you will need to call the uIP ARP code before calling |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
289 * this function: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
290 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
291 #define BUF ((struct uip_eth_hdr *)&uip_buf[0]) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
292 uip_len = ethernet_devicedrver_poll(); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
293 if(uip_len > 0) { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
294 if(BUF->type == UIP_HTONS(UIP_ETHTYPE_IP)) { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
295 uip_arp_ipin(); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
296 uip_input(); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
297 if(uip_len > 0) { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
298 uip_arp_out(); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
299 ethernet_devicedriver_send(); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
300 } |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
301 } else if(BUF->type == UIP_HTONS(UIP_ETHTYPE_ARP)) { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
302 uip_arp_arpin(); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
303 if(uip_len > 0) { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
304 ethernet_devicedriver_send(); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
305 } |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
306 } |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
307 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
308 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
309 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
310 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
311 #define uip_input() uip_process(UIP_DATA) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
312 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
313 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
314 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
315 * Periodic processing for a connection identified by its number. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
316 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
317 * This function does the necessary periodic processing (timers, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
318 * polling) for a uIP TCP conneciton, and should be called when the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
319 * periodic uIP timer goes off. It should be called for every |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
320 * connection, regardless of whether they are open of closed. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
321 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
322 * When the function returns, it may have an outbound packet waiting |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
323 * for service in the uIP packet buffer, and if so the uip_len |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
324 * variable is set to a value larger than zero. The device driver |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
325 * should be called to send out the packet. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
326 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
327 * The usual way of calling the function is through a for() loop like |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
328 * this: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
329 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
330 for(i = 0; i < UIP_CONNS; ++i) { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
331 uip_periodic(i); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
332 if(uip_len > 0) { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
333 devicedriver_send(); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
334 } |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
335 } |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
336 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
337 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
338 * \note If you are writing a uIP device driver that needs ARP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
339 * (Address Resolution Protocol), e.g., when running uIP over |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
340 * Ethernet, you will need to call the uip_arp_out() function before |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
341 * calling the device driver: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
342 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
343 for(i = 0; i < UIP_CONNS; ++i) { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
344 uip_periodic(i); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
345 if(uip_len > 0) { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
346 uip_arp_out(); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
347 ethernet_devicedriver_send(); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
348 } |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
349 } |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
350 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
351 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
352 * \param conn The number of the connection which is to be periodically polled. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
353 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
354 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
355 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
356 #if UIP_TCP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
357 #define uip_periodic(conn) do { uip_conn = &uip_conns[conn]; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
358 uip_process(UIP_TIMER); } while (0) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
359 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
360 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
361 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
362 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
363 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
364 #define uip_conn_active(conn) (uip_conns[conn].tcpstateflags != UIP_CLOSED) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
365 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
366 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
367 * Perform periodic processing for a connection identified by a pointer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
368 * to its structure. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
369 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
370 * Same as uip_periodic() but takes a pointer to the actual uip_conn |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
371 * struct instead of an integer as its argument. This function can be |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
372 * used to force periodic processing of a specific connection. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
373 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
374 * \param conn A pointer to the uip_conn struct for the connection to |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
375 * be processed. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
376 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
377 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
378 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
379 #define uip_periodic_conn(conn) do { uip_conn = conn; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
380 uip_process(UIP_TIMER); } while (0) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
381 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
382 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
383 * Request that a particular connection should be polled. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
384 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
385 * Similar to uip_periodic_conn() but does not perform any timer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
386 * processing. The application is polled for new data. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
387 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
388 * \param conn A pointer to the uip_conn struct for the connection to |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
389 * be processed. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
390 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
391 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
392 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
393 #define uip_poll_conn(conn) do { uip_conn = conn; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
394 uip_process(UIP_POLL_REQUEST); } while (0) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
395 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
396 #endif /* UIP_TCP */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
397 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
398 #if UIP_UDP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
399 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
400 * Periodic processing for a UDP connection identified by its number. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
401 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
402 * This function is essentially the same as uip_periodic(), but for |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
403 * UDP connections. It is called in a similar fashion as the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
404 * uip_periodic() function: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
405 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
406 for(i = 0; i < UIP_UDP_CONNS; i++) { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
407 uip_udp_periodic(i); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
408 if(uip_len > 0) { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
409 devicedriver_send(); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
410 } |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
411 } |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
412 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
413 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
414 * \note As for the uip_periodic() function, special care has to be |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
415 * taken when using uIP together with ARP and Ethernet: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
416 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
417 for(i = 0; i < UIP_UDP_CONNS; i++) { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
418 uip_udp_periodic(i); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
419 if(uip_len > 0) { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
420 uip_arp_out(); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
421 ethernet_devicedriver_send(); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
422 } |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
423 } |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
424 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
425 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
426 * \param conn The number of the UDP connection to be processed. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
427 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
428 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
429 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
430 #define uip_udp_periodic(conn) do { uip_udp_conn = &uip_udp_conns[conn]; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
431 uip_process(UIP_UDP_TIMER); } while(0) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
432 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
433 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
434 * Periodic processing for a UDP connection identified by a pointer to |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
435 * its structure. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
436 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
437 * Same as uip_udp_periodic() but takes a pointer to the actual |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
438 * uip_conn struct instead of an integer as its argument. This |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
439 * function can be used to force periodic processing of a specific |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
440 * connection. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
441 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
442 * \param conn A pointer to the uip_udp_conn struct for the connection |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
443 * to be processed. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
444 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
445 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
446 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
447 #define uip_udp_periodic_conn(conn) do { uip_udp_conn = conn; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
448 uip_process(UIP_UDP_TIMER); } while(0) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
449 #endif /* UIP_UDP */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
450 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
451 /** \brief Abandon the reassembly of the current packet */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
452 void uip_reass_over(void); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
453 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
454 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
455 * The uIP packet buffer. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
456 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
457 * The uip_buf array is used to hold incoming and outgoing |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
458 * packets. The device driver should place incoming data into this |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
459 * buffer. When sending data, the device driver should read the link |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
460 * level headers and the TCP/IP headers from this buffer. The size of |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
461 * the link level headers is configured by the UIP_LLH_LEN define. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
462 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
463 * \note The application data need not be placed in this buffer, so |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
464 * the device driver must read it from the place pointed to by the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
465 * uip_appdata pointer as illustrated by the following example: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
466 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
467 void |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
468 devicedriver_send(void) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
469 { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
470 hwsend(&uip_buf[0], UIP_LLH_LEN); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
471 if(uip_len <= UIP_LLH_LEN + UIP_TCPIP_HLEN) { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
472 hwsend(&uip_buf[UIP_LLH_LEN], uip_len - UIP_LLH_LEN); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
473 } else { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
474 hwsend(&uip_buf[UIP_LLH_LEN], UIP_TCPIP_HLEN); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
475 hwsend(uip_appdata, uip_len - UIP_TCPIP_HLEN - UIP_LLH_LEN); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
476 } |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
477 } |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
478 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
479 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
480 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
481 typedef union { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
482 uint32_t u32[(UIP_BUFSIZE + 3) / 4]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
483 uint8_t u8[UIP_BUFSIZE]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
484 } uip_buf_t; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
485 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
486 CCIF extern uip_buf_t uip_aligned_buf; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
487 #define uip_buf (uip_aligned_buf.u8) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
488 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
489 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
490 /** @} */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
491 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
492 /*---------------------------------------------------------------------------*/ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
493 /* Functions that are used by the uIP application program. Opening and |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
494 * closing connections, sending and receiving data, etc. is all |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
495 * handled by the functions below. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
496 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
497 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
498 * \defgroup uipappfunc uIP application functions |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
499 * @{ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
500 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
501 * Functions used by an application running of top of uIP. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
502 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
503 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
504 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
505 * Start listening to the specified port. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
506 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
507 * \note Since this function expects the port number in network byte |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
508 * order, a conversion using UIP_HTONS() or uip_htons() is necessary. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
509 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
510 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
511 uip_listen(UIP_HTONS(80)); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
512 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
513 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
514 * \param port A 16-bit port number in network byte order. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
515 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
516 void uip_listen(u16_t port); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
517 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
518 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
519 * Stop listening to the specified port. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
520 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
521 * \note Since this function expects the port number in network byte |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
522 * order, a conversion using UIP_HTONS() or uip_htons() is necessary. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
523 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
524 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
525 uip_unlisten(UIP_HTONS(80)); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
526 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
527 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
528 * \param port A 16-bit port number in network byte order. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
529 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
530 void uip_unlisten(u16_t port); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
531 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
532 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
533 * Connect to a remote host using TCP. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
534 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
535 * This function is used to start a new connection to the specified |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
536 * port on the specified host. It allocates a new connection identifier, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
537 * sets the connection to the SYN_SENT state and sets the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
538 * retransmission timer to 0. This will cause a TCP SYN segment to be |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
539 * sent out the next time this connection is periodically processed, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
540 * which usually is done within 0.5 seconds after the call to |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
541 * uip_connect(). |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
542 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
543 * \note This function is available only if support for active open |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
544 * has been configured by defining UIP_ACTIVE_OPEN to 1 in uipopt.h. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
545 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
546 * \note Since this function requires the port number to be in network |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
547 * byte order, a conversion using UIP_HTONS() or uip_htons() is necessary. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
548 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
549 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
550 uip_ipaddr_t ipaddr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
551 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
552 uip_ipaddr(&ipaddr, 192,168,1,2); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
553 uip_connect(&ipaddr, UIP_HTONS(80)); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
554 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
555 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
556 * \param ripaddr The IP address of the remote host. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
557 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
558 * \param port A 16-bit port number in network byte order. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
559 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
560 * \return A pointer to the uIP connection identifier for the new connection, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
561 * or NULL if no connection could be allocated. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
562 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
563 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
564 struct uip_conn *uip_connect(uip_ipaddr_t *ripaddr, u16_t port); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
565 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
566 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
567 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
568 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
569 * \internal |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
570 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
571 * Check if a connection has outstanding (i.e., unacknowledged) data. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
572 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
573 * \param conn A pointer to the uip_conn structure for the connection. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
574 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
575 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
576 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
577 #define uip_outstanding(conn) ((conn)->len) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
578 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
579 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
580 * Send data on the current connection. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
581 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
582 * This function is used to send out a single segment of TCP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
583 * data. Only applications that have been invoked by uIP for event |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
584 * processing can send data. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
585 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
586 * The amount of data that actually is sent out after a call to this |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
587 * function is determined by the maximum amount of data TCP allows. uIP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
588 * will automatically crop the data so that only the appropriate |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
589 * amount of data is sent. The function uip_mss() can be used to query |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
590 * uIP for the amount of data that actually will be sent. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
591 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
592 * \note This function does not guarantee that the sent data will |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
593 * arrive at the destination. If the data is lost in the network, the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
594 * application will be invoked with the uip_rexmit() event being |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
595 * set. The application will then have to resend the data using this |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
596 * function. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
597 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
598 * \param data A pointer to the data which is to be sent. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
599 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
600 * \param len The maximum amount of data bytes to be sent. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
601 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
602 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
603 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
604 CCIF void uip_send(const void *data, int len); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
605 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
606 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
607 * The length of any incoming data that is currently available (if available) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
608 * in the uip_appdata buffer. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
609 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
610 * The test function uip_data() must first be used to check if there |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
611 * is any data available at all. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
612 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
613 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
614 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
615 /*void uip_datalen(void);*/ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
616 #define uip_datalen() uip_len |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
617 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
618 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
619 * The length of any out-of-band data (urgent data) that has arrived |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
620 * on the connection. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
621 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
622 * \note The configuration parameter UIP_URGDATA must be set for this |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
623 * function to be enabled. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
624 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
625 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
626 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
627 #define uip_urgdatalen() uip_urglen |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
628 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
629 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
630 * Close the current connection. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
631 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
632 * This function will close the current connection in a nice way. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
633 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
634 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
635 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
636 #define uip_close() (uip_flags = UIP_CLOSE) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
637 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
638 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
639 * Abort the current connection. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
640 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
641 * This function will abort (reset) the current connection, and is |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
642 * usually used when an error has occurred that prevents using the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
643 * uip_close() function. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
644 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
645 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
646 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
647 #define uip_abort() (uip_flags = UIP_ABORT) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
648 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
649 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
650 * Tell the sending host to stop sending data. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
651 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
652 * This function will close our receiver's window so that we stop |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
653 * receiving data for the current connection. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
654 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
655 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
656 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
657 #define uip_stop() (uip_conn->tcpstateflags |= UIP_STOPPED) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
658 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
659 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
660 * Find out if the current connection has been previously stopped with |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
661 * uip_stop(). |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
662 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
663 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
664 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
665 #define uip_stopped(conn) ((conn)->tcpstateflags & UIP_STOPPED) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
666 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
667 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
668 * Restart the current connection, if is has previously been stopped |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
669 * with uip_stop(). |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
670 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
671 * This function will open the receiver's window again so that we |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
672 * start receiving data for the current connection. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
673 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
674 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
675 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
676 #define uip_restart() do { uip_flags |= UIP_NEWDATA; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
677 uip_conn->tcpstateflags &= ~UIP_STOPPED; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
678 } while(0) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
679 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
680 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
681 /* uIP tests that can be made to determine in what state the current |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
682 connection is, and what the application function should do. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
683 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
684 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
685 * Is the current connection a UDP connection? |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
686 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
687 * This function checks whether the current connection is a UDP connection. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
688 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
689 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
690 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
691 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
692 #define uip_udpconnection() (uip_conn == NULL) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
693 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
694 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
695 * Is new incoming data available? |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
696 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
697 * Will reduce to non-zero if there is new data for the application |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
698 * present at the uip_appdata pointer. The size of the data is |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
699 * available through the uip_len variable. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
700 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
701 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
702 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
703 #define uip_newdata() (uip_flags & UIP_NEWDATA) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
704 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
705 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
706 * Has previously sent data been acknowledged? |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
707 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
708 * Will reduce to non-zero if the previously sent data has been |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
709 * acknowledged by the remote host. This means that the application |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
710 * can send new data. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
711 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
712 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
713 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
714 #define uip_acked() (uip_flags & UIP_ACKDATA) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
715 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
716 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
717 * Has the connection just been connected? |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
718 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
719 * Reduces to non-zero if the current connection has been connected to |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
720 * a remote host. This will happen both if the connection has been |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
721 * actively opened (with uip_connect()) or passively opened (with |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
722 * uip_listen()). |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
723 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
724 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
725 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
726 #define uip_connected() (uip_flags & UIP_CONNECTED) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
727 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
728 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
729 * Has the connection been closed by the other end? |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
730 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
731 * Is non-zero if the connection has been closed by the remote |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
732 * host. The application may then do the necessary clean-ups. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
733 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
734 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
735 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
736 #define uip_closed() (uip_flags & UIP_CLOSE) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
737 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
738 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
739 * Has the connection been aborted by the other end? |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
740 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
741 * Non-zero if the current connection has been aborted (reset) by the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
742 * remote host. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
743 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
744 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
745 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
746 #define uip_aborted() (uip_flags & UIP_ABORT) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
747 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
748 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
749 * Has the connection timed out? |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
750 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
751 * Non-zero if the current connection has been aborted due to too many |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
752 * retransmissions. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
753 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
754 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
755 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
756 #define uip_timedout() (uip_flags & UIP_TIMEDOUT) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
757 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
758 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
759 * Do we need to retransmit previously data? |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
760 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
761 * Reduces to non-zero if the previously sent data has been lost in |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
762 * the network, and the application should retransmit it. The |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
763 * application should send the exact same data as it did the last |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
764 * time, using the uip_send() function. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
765 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
766 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
767 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
768 #define uip_rexmit() (uip_flags & UIP_REXMIT) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
769 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
770 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
771 * Is the connection being polled by uIP? |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
772 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
773 * Is non-zero if the reason the application is invoked is that the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
774 * current connection has been idle for a while and should be |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
775 * polled. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
776 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
777 * The polling event can be used for sending data without having to |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
778 * wait for the remote host to send data. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
779 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
780 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
781 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
782 #define uip_poll() (uip_flags & UIP_POLL) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
783 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
784 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
785 * Get the initial maximum segment size (MSS) of the current |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
786 * connection. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
787 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
788 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
789 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
790 #define uip_initialmss() (uip_conn->initialmss) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
791 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
792 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
793 * Get the current maximum segment size that can be sent on the current |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
794 * connection. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
795 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
796 * The current maximum segment size that can be sent on the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
797 * connection is computed from the receiver's window and the MSS of |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
798 * the connection (which also is available by calling |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
799 * uip_initialmss()). |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
800 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
801 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
802 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
803 #define uip_mss() (uip_conn->mss) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
804 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
805 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
806 * Set up a new UDP connection. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
807 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
808 * This function sets up a new UDP connection. The function will |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
809 * automatically allocate an unused local port for the new |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
810 * connection. However, another port can be chosen by using the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
811 * uip_udp_bind() call, after the uip_udp_new() function has been |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
812 * called. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
813 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
814 * Example: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
815 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
816 uip_ipaddr_t addr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
817 struct uip_udp_conn *c; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
818 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
819 uip_ipaddr(&addr, 192,168,2,1); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
820 c = uip_udp_new(&addr, UIP_HTONS(12345)); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
821 if(c != NULL) { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
822 uip_udp_bind(c, UIP_HTONS(12344)); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
823 } |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
824 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
825 * \param ripaddr The IP address of the remote host. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
826 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
827 * \param rport The remote port number in network byte order. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
828 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
829 * \return The uip_udp_conn structure for the new connection or NULL |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
830 * if no connection could be allocated. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
831 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
832 struct uip_udp_conn *uip_udp_new(const uip_ipaddr_t *ripaddr, u16_t rport); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
833 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
834 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
835 * Removed a UDP connection. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
836 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
837 * \param conn A pointer to the uip_udp_conn structure for the connection. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
838 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
839 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
840 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
841 #define uip_udp_remove(conn) (conn)->lport = 0 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
842 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
843 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
844 * Bind a UDP connection to a local port. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
845 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
846 * \param conn A pointer to the uip_udp_conn structure for the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
847 * connection. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
848 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
849 * \param port The local port number, in network byte order. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
850 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
851 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
852 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
853 #define uip_udp_bind(conn, port) (conn)->lport = port |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
854 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
855 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
856 * Send a UDP datagram of length len on the current connection. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
857 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
858 * This function can only be called in response to a UDP event (poll |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
859 * or newdata). The data must be present in the uip_buf buffer, at the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
860 * place pointed to by the uip_appdata pointer. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
861 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
862 * \param len The length of the data in the uip_buf buffer. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
863 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
864 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
865 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
866 #define uip_udp_send(len) uip_send((char *)uip_appdata, len) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
867 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
868 /** @} */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
869 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
870 /* uIP convenience and converting functions. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
871 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
872 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
873 * \defgroup uipconvfunc uIP conversion functions |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
874 * @{ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
875 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
876 * These functions can be used for converting between different data |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
877 * formats used by uIP. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
878 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
879 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
880 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
881 * Convert an IP address to four bytes separated by commas. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
882 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
883 * Example: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
884 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
885 uip_ipaddr_t ipaddr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
886 printf("ipaddr=%d.%d.%d.%d\n", uip_ipaddr_to_quad(&ipaddr)); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
887 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
888 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
889 * \param a A pointer to a uip_ipaddr_t. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
890 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
891 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
892 #define uip_ipaddr_to_quad(a) (a)->u8[0],(a)->u8[1],(a)->u8[2],(a)->u8[3] |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
893 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
894 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
895 * Construct an IP address from four bytes. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
896 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
897 * This function constructs an IP address of the type that uIP handles |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
898 * internally from four bytes. The function is handy for specifying IP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
899 * addresses to use with e.g. the uip_connect() function. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
900 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
901 * Example: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
902 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
903 uip_ipaddr_t ipaddr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
904 struct uip_conn *c; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
905 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
906 uip_ipaddr(&ipaddr, 192,168,1,2); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
907 c = uip_connect(&ipaddr, UIP_HTONS(80)); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
908 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
909 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
910 * \param addr A pointer to a uip_ipaddr_t variable that will be |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
911 * filled in with the IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
912 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
913 * \param addr0 The first octet of the IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
914 * \param addr1 The second octet of the IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
915 * \param addr2 The third octet of the IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
916 * \param addr3 The forth octet of the IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
917 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
918 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
919 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
920 #define uip_ipaddr(addr, addr0,addr1,addr2,addr3) do { \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
921 (addr)->u8[0] = addr0; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
922 (addr)->u8[1] = addr1; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
923 (addr)->u8[2] = addr2; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
924 (addr)->u8[3] = addr3; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
925 } while(0) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
926 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
927 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
928 * Construct an IPv6 address from eight 16-bit words. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
929 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
930 * This function constructs an IPv6 address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
931 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
932 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
933 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
934 #define uip_ip6addr(addr, addr0,addr1,addr2,addr3,addr4,addr5,addr6,addr7) do { \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
935 (addr)->u16[0] = UIP_HTONS(addr0); \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
936 (addr)->u16[1] = UIP_HTONS(addr1); \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
937 (addr)->u16[2] = UIP_HTONS(addr2); \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
938 (addr)->u16[3] = UIP_HTONS(addr3); \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
939 (addr)->u16[4] = UIP_HTONS(addr4); \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
940 (addr)->u16[5] = UIP_HTONS(addr5); \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
941 (addr)->u16[6] = UIP_HTONS(addr6); \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
942 (addr)->u16[7] = UIP_HTONS(addr7); \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
943 } while(0) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
944 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
945 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
946 * Construct an IPv6 address from eight 8-bit words. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
947 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
948 * This function constructs an IPv6 address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
949 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
950 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
951 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
952 #define uip_ip6addr_u8(addr, addr0,addr1,addr2,addr3,addr4,addr5,addr6,addr7,addr8,addr9,addr10,addr11,addr12,addr13,addr14,addr15) do { \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
953 (addr)->u8[0] = addr0; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
954 (addr)->u8[1] = addr1; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
955 (addr)->u8[2] = addr2; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
956 (addr)->u8[3] = addr3; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
957 (addr)->u8[4] = addr4; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
958 (addr)->u8[5] = addr5; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
959 (addr)->u8[6] = addr6; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
960 (addr)->u8[7] = addr7; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
961 (addr)->u8[8] = addr8; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
962 (addr)->u8[9] = addr9; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
963 (addr)->u8[10] = addr10; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
964 (addr)->u8[11] = addr11; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
965 (addr)->u8[12] = addr12; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
966 (addr)->u8[13] = addr13; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
967 (addr)->u8[14] = addr14; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
968 (addr)->u8[15] = addr15; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
969 } while(0) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
970 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
971 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
972 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
973 * Copy an IP address to another IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
974 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
975 * Copies an IP address from one place to another. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
976 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
977 * Example: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
978 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
979 uip_ipaddr_t ipaddr1, ipaddr2; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
980 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
981 uip_ipaddr(&ipaddr1, 192,16,1,2); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
982 uip_ipaddr_copy(&ipaddr2, &ipaddr1); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
983 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
984 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
985 * \param dest The destination for the copy. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
986 * \param src The source from where to copy. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
987 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
988 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
989 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
990 #ifndef uip_ipaddr_copy |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
991 #define uip_ipaddr_copy(dest, src) (*(dest) = *(src)) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
992 #endif |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
993 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
994 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
995 * Compare two IP addresses |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
996 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
997 * Compares two IP addresses. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
998 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
999 * Example: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1000 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1001 uip_ipaddr_t ipaddr1, ipaddr2; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1002 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1003 uip_ipaddr(&ipaddr1, 192,16,1,2); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1004 if(uip_ipaddr_cmp(&ipaddr2, &ipaddr1)) { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1005 printf("They are the same"); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1006 } |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1007 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1008 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1009 * \param addr1 The first IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1010 * \param addr2 The second IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1011 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1012 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1013 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1014 #if !UIP_CONF_IPV6 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1015 #define uip_ipaddr_cmp(addr1, addr2) ((addr1)->u16[0] == (addr2)->u16[0] && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1016 (addr1)->u16[1] == (addr2)->u16[1]) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1017 #else /* !UIP_CONF_IPV6 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1018 #define uip_ipaddr_cmp(addr1, addr2) (memcmp(addr1, addr2, sizeof(uip_ip6addr_t)) == 0) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1019 #endif /* !UIP_CONF_IPV6 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1020 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1021 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1022 * Compare two IP addresses with netmasks |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1023 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1024 * Compares two IP addresses with netmasks. The masks are used to mask |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1025 * out the bits that are to be compared. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1026 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1027 * Example: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1028 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1029 uip_ipaddr_t ipaddr1, ipaddr2, mask; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1030 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1031 uip_ipaddr(&mask, 255,255,255,0); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1032 uip_ipaddr(&ipaddr1, 192,16,1,2); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1033 uip_ipaddr(&ipaddr2, 192,16,1,3); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1034 if(uip_ipaddr_maskcmp(&ipaddr1, &ipaddr2, &mask)) { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1035 printf("They are the same"); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1036 } |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1037 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1038 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1039 * \param addr1 The first IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1040 * \param addr2 The second IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1041 * \param mask The netmask. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1042 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1043 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1044 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1045 #if !UIP_CONF_IPV6 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1046 #define uip_ipaddr_maskcmp(addr1, addr2, mask) \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1047 (((((u16_t *)addr1)[0] & ((u16_t *)mask)[0]) == \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1048 (((u16_t *)addr2)[0] & ((u16_t *)mask)[0])) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1049 ((((u16_t *)addr1)[1] & ((u16_t *)mask)[1]) == \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1050 (((u16_t *)addr2)[1] & ((u16_t *)mask)[1]))) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1051 #else |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1052 #define uip_ipaddr_prefixcmp(addr1, addr2, length) (memcmp(addr1, addr2, length>>3) == 0) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1053 #endif |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1054 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1055 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1056 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1057 * Check if an address is a broadcast address for a network. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1058 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1059 * Checks if an address is the broadcast address for a network. The |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1060 * network is defined by an IP address that is on the network and the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1061 * network's netmask. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1062 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1063 * \param addr The IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1064 * \param netaddr The network's IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1065 * \param netmask The network's netmask. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1066 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1067 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1068 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1069 /*#define uip_ipaddr_isbroadcast(addr, netaddr, netmask) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1070 ((uip_ipaddr_t *)(addr)).u16 & ((uip_ipaddr_t *)(addr)).u16*/ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1071 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1072 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1073 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1074 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1075 * Mask out the network part of an IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1076 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1077 * Masks out the network part of an IP address, given the address and |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1078 * the netmask. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1079 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1080 * Example: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1081 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1082 uip_ipaddr_t ipaddr1, ipaddr2, netmask; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1083 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1084 uip_ipaddr(&ipaddr1, 192,16,1,2); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1085 uip_ipaddr(&netmask, 255,255,255,0); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1086 uip_ipaddr_mask(&ipaddr2, &ipaddr1, &netmask); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1087 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1088 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1089 * In the example above, the variable "ipaddr2" will contain the IP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1090 * address 192.168.1.0. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1091 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1092 * \param dest Where the result is to be placed. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1093 * \param src The IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1094 * \param mask The netmask. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1095 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1096 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1097 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1098 #define uip_ipaddr_mask(dest, src, mask) do { \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1099 ((u16_t *)dest)[0] = ((u16_t *)src)[0] & ((u16_t *)mask)[0]; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1100 ((u16_t *)dest)[1] = ((u16_t *)src)[1] & ((u16_t *)mask)[1]; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1101 } while(0) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1102 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1103 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1104 * Pick the first octet of an IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1105 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1106 * Picks out the first octet of an IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1107 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1108 * Example: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1109 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1110 uip_ipaddr_t ipaddr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1111 u8_t octet; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1112 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1113 uip_ipaddr(&ipaddr, 1,2,3,4); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1114 octet = uip_ipaddr1(&ipaddr); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1115 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1116 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1117 * In the example above, the variable "octet" will contain the value 1. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1118 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1119 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1120 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1121 #define uip_ipaddr1(addr) ((addr)->u8[0]) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1122 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1123 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1124 * Pick the second octet of an IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1125 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1126 * Picks out the second octet of an IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1127 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1128 * Example: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1129 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1130 uip_ipaddr_t ipaddr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1131 u8_t octet; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1132 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1133 uip_ipaddr(&ipaddr, 1,2,3,4); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1134 octet = uip_ipaddr2(&ipaddr); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1135 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1136 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1137 * In the example above, the variable "octet" will contain the value 2. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1138 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1139 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1140 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1141 #define uip_ipaddr2(addr) ((addr)->u8[1]) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1142 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1143 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1144 * Pick the third octet of an IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1145 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1146 * Picks out the third octet of an IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1147 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1148 * Example: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1149 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1150 uip_ipaddr_t ipaddr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1151 u8_t octet; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1152 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1153 uip_ipaddr(&ipaddr, 1,2,3,4); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1154 octet = uip_ipaddr3(&ipaddr); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1155 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1156 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1157 * In the example above, the variable "octet" will contain the value 3. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1158 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1159 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1160 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1161 #define uip_ipaddr3(addr) ((addr)->u8[2]) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1162 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1163 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1164 * Pick the fourth octet of an IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1165 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1166 * Picks out the fourth octet of an IP address. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1167 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1168 * Example: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1169 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1170 uip_ipaddr_t ipaddr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1171 u8_t octet; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1172 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1173 uip_ipaddr(&ipaddr, 1,2,3,4); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1174 octet = uip_ipaddr4(&ipaddr); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1175 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1176 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1177 * In the example above, the variable "octet" will contain the value 4. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1178 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1179 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1180 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1181 #define uip_ipaddr4(addr) ((addr)->u8[3]) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1182 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1183 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1184 * Convert 16-bit quantity from host byte order to network byte order. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1185 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1186 * This macro is primarily used for converting constants from host |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1187 * byte order to network byte order. For converting variables to |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1188 * network byte order, use the uip_htons() function instead. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1189 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1190 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1191 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1192 #ifndef UIP_HTONS |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1193 # if UIP_BYTE_ORDER == UIP_BIG_ENDIAN |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1194 # define UIP_HTONS(n) (n) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1195 # define UIP_HTONL(n) (n) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1196 # else /* UIP_BYTE_ORDER == UIP_BIG_ENDIAN */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1197 # define UIP_HTONS(n) (u16_t)((((u16_t) (n)) << 8) | (((u16_t) (n)) >> 8)) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1198 # define UIP_HTONL(n) (((u32_t)UIP_HTONS(n) << 16) | UIP_HTONS((u32_t)(n) >> 16)) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1199 # endif /* UIP_BYTE_ORDER == UIP_BIG_ENDIAN */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1200 #else |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1201 #error "UIP_HTONS already defined!" |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1202 #endif /* UIP_HTONS */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1203 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1204 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1205 * Convert 16-bit quantity from host byte order to network byte order. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1206 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1207 * This function is primarily used for converting variables from host |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1208 * byte order to network byte order. For converting constants to |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1209 * network byte order, use the UIP_HTONS() macro instead. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1210 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1211 #ifndef uip_htons |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1212 CCIF u16_t uip_htons(u16_t val); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1213 #endif /* uip_htons */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1214 #ifndef uip_ntohs |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1215 #define uip_ntohs uip_htons |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1216 #endif |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1217 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1218 #ifndef uip_htonl |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1219 CCIF u32_t uip_htonl(u32_t val); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1220 #endif /* uip_htonl */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1221 #ifndef uip_ntohl |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1222 #define uip_ntohl uip_htonl |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1223 #endif |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1224 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1225 /** @} */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1226 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1227 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1228 * Pointer to the application data in the packet buffer. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1229 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1230 * This pointer points to the application data when the application is |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1231 * called. If the application wishes to send data, the application may |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1232 * use this space to write the data into before calling uip_send(). |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1233 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1234 CCIF extern void *uip_appdata; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1235 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1236 #if UIP_URGDATA > 0 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1237 /* u8_t *uip_urgdata: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1238 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1239 * This pointer points to any urgent data that has been received. Only |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1240 * present if compiled with support for urgent data (UIP_URGDATA). |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1241 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1242 extern void *uip_urgdata; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1243 #endif /* UIP_URGDATA > 0 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1244 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1245 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1246 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1247 * \defgroup uipdrivervars Variables used in uIP device drivers |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1248 * @{ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1249 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1250 * uIP has a few global variables that are used in device drivers for |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1251 * uIP. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1252 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1253 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1254 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1255 * The length of the packet in the uip_buf buffer. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1256 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1257 * The global variable uip_len holds the length of the packet in the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1258 * uip_buf buffer. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1259 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1260 * When the network device driver calls the uIP input function, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1261 * uip_len should be set to the length of the packet in the uip_buf |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1262 * buffer. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1263 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1264 * When sending packets, the device driver should use the contents of |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1265 * the uip_len variable to determine the length of the outgoing |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1266 * packet. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1267 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1268 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1269 CCIF extern u16_t uip_len; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1270 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1271 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1272 * The length of the extension headers |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1273 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1274 extern u8_t uip_ext_len; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1275 /** @} */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1276 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1277 #if UIP_URGDATA > 0 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1278 extern u16_t uip_urglen, uip_surglen; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1279 #endif /* UIP_URGDATA > 0 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1280 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1281 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1282 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1283 * Representation of a uIP TCP connection. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1284 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1285 * The uip_conn structure is used for identifying a connection. All |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1286 * but one field in the structure are to be considered read-only by an |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1287 * application. The only exception is the appstate field whose purpose |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1288 * is to let the application store application-specific state (e.g., |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1289 * file pointers) for the connection. The type of this field is |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1290 * configured in the "uipopt.h" header file. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1291 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1292 struct uip_conn { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1293 uip_ipaddr_t ripaddr; /**< The IP address of the remote host. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1294 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1295 u16_t lport; /**< The local TCP port, in network byte order. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1296 u16_t rport; /**< The local remote TCP port, in network byte |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1297 order. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1298 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1299 u8_t rcv_nxt[4]; /**< The sequence number that we expect to |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1300 receive next. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1301 u8_t snd_nxt[4]; /**< The sequence number that was last sent by |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1302 us. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1303 u16_t len; /**< Length of the data that was previously sent. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1304 u16_t mss; /**< Current maximum segment size for the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1305 connection. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1306 u16_t initialmss; /**< Initial maximum segment size for the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1307 connection. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1308 u8_t sa; /**< Retransmission time-out calculation state |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1309 variable. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1310 u8_t sv; /**< Retransmission time-out calculation state |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1311 variable. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1312 u8_t rto; /**< Retransmission time-out. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1313 u8_t tcpstateflags; /**< TCP state and flags. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1314 u8_t timer; /**< The retransmission timer. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1315 u8_t nrtx; /**< The number of retransmissions for the last |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1316 segment sent. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1317 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1318 /** The application state. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1319 uip_tcp_appstate_t appstate; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1320 }; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1321 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1322 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1323 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1324 * Pointer to the current TCP connection. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1325 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1326 * The uip_conn pointer can be used to access the current TCP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1327 * connection. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1328 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1329 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1330 CCIF extern struct uip_conn *uip_conn; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1331 #if UIP_TCP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1332 /* The array containing all uIP connections. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1333 CCIF extern struct uip_conn uip_conns[UIP_CONNS]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1334 #endif |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1335 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1336 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1337 * \addtogroup uiparch |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1338 * @{ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1339 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1340 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1341 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1342 * 4-byte array used for the 32-bit sequence number calculations. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1343 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1344 extern u8_t uip_acc32[4]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1345 /** @} */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1346 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1347 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1348 * Representation of a uIP UDP connection. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1349 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1350 struct uip_udp_conn { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1351 uip_ipaddr_t ripaddr; /**< The IP address of the remote peer. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1352 u16_t lport; /**< The local port number in network byte order. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1353 u16_t rport; /**< The remote port number in network byte order. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1354 u8_t ttl; /**< Default time-to-live. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1355 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1356 /** The application state. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1357 uip_udp_appstate_t appstate; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1358 }; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1359 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1360 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1361 * The current UDP connection. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1362 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1363 extern struct uip_udp_conn *uip_udp_conn; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1364 extern struct uip_udp_conn uip_udp_conns[UIP_UDP_CONNS]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1365 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1366 struct uip_fallback_interface { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1367 void (*init)(void); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1368 void (*output)(void); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1369 }; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1370 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1371 #if UIP_CONF_ICMP6 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1372 struct uip_icmp6_conn { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1373 uip_icmp6_appstate_t appstate; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1374 }; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1375 extern struct uip_icmp6_conn uip_icmp6_conns; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1376 #endif /*UIP_CONF_ICMP6*/ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1377 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1378 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1379 * The uIP TCP/IP statistics. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1380 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1381 * This is the variable in which the uIP TCP/IP statistics are gathered. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1382 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1383 #if UIP_STATISTICS == 1 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1384 extern struct uip_stats uip_stat; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1385 #define UIP_STAT(s) s |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1386 #else |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1387 #define UIP_STAT(s) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1388 #endif /* UIP_STATISTICS == 1 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1389 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1390 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1391 * The structure holding the TCP/IP statistics that are gathered if |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1392 * UIP_STATISTICS is set to 1. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1393 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1394 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1395 struct uip_stats { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1396 struct { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1397 uip_stats_t recv; /**< Number of received packets at the IP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1398 layer. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1399 uip_stats_t sent; /**< Number of sent packets at the IP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1400 layer. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1401 uip_stats_t forwarded;/**< Number of forwarded packets at the IP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1402 layer. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1403 uip_stats_t drop; /**< Number of dropped packets at the IP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1404 layer. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1405 uip_stats_t vhlerr; /**< Number of packets dropped due to wrong |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1406 IP version or header length. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1407 uip_stats_t hblenerr; /**< Number of packets dropped due to wrong |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1408 IP length, high byte. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1409 uip_stats_t lblenerr; /**< Number of packets dropped due to wrong |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1410 IP length, low byte. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1411 uip_stats_t fragerr; /**< Number of packets dropped since they |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1412 were IP fragments. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1413 uip_stats_t chkerr; /**< Number of packets dropped due to IP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1414 checksum errors. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1415 uip_stats_t protoerr; /**< Number of packets dropped since they |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1416 were neither ICMP, UDP nor TCP. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1417 } ip; /**< IP statistics. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1418 struct { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1419 uip_stats_t recv; /**< Number of received ICMP packets. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1420 uip_stats_t sent; /**< Number of sent ICMP packets. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1421 uip_stats_t drop; /**< Number of dropped ICMP packets. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1422 uip_stats_t typeerr; /**< Number of ICMP packets with a wrong |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1423 type. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1424 uip_stats_t chkerr; /**< Number of ICMP packets with a bad |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1425 checksum. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1426 } icmp; /**< ICMP statistics. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1427 #if UIP_TCP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1428 struct { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1429 uip_stats_t recv; /**< Number of recived TCP segments. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1430 uip_stats_t sent; /**< Number of sent TCP segments. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1431 uip_stats_t drop; /**< Number of dropped TCP segments. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1432 uip_stats_t chkerr; /**< Number of TCP segments with a bad |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1433 checksum. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1434 uip_stats_t ackerr; /**< Number of TCP segments with a bad ACK |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1435 number. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1436 uip_stats_t rst; /**< Number of recevied TCP RST (reset) segments. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1437 uip_stats_t rexmit; /**< Number of retransmitted TCP segments. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1438 uip_stats_t syndrop; /**< Number of dropped SYNs due to too few |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1439 connections was avaliable. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1440 uip_stats_t synrst; /**< Number of SYNs for closed ports, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1441 triggering a RST. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1442 } tcp; /**< TCP statistics. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1443 #endif |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1444 #if UIP_UDP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1445 struct { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1446 uip_stats_t drop; /**< Number of dropped UDP segments. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1447 uip_stats_t recv; /**< Number of recived UDP segments. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1448 uip_stats_t sent; /**< Number of sent UDP segments. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1449 uip_stats_t chkerr; /**< Number of UDP segments with a bad |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1450 checksum. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1451 } udp; /**< UDP statistics. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1452 #endif /* UIP_UDP */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1453 #if UIP_CONF_IPV6 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1454 struct { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1455 uip_stats_t drop; /**< Number of dropped ND6 packets. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1456 uip_stats_t recv; /**< Number of recived ND6 packets */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1457 uip_stats_t sent; /**< Number of sent ND6 packets */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1458 } nd6; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1459 #endif /*UIP_CONF_IPV6*/ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1460 }; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1461 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1462 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1463 /*---------------------------------------------------------------------------*/ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1464 /* All the stuff below this point is internal to uIP and should not be |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1465 * used directly by an application or by a device driver. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1466 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1467 /*---------------------------------------------------------------------------*/ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1468 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1469 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1470 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1471 /* u8_t uip_flags: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1472 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1473 * When the application is called, uip_flags will contain the flags |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1474 * that are defined in this file. Please read below for more |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1475 * information. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1476 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1477 CCIF extern u8_t uip_flags; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1478 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1479 /* The following flags may be set in the global variable uip_flags |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1480 before calling the application callback. The UIP_ACKDATA, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1481 UIP_NEWDATA, and UIP_CLOSE flags may both be set at the same time, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1482 whereas the others are mutually exclusive. Note that these flags |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1483 should *NOT* be accessed directly, but only through the uIP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1484 functions/macros. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1485 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1486 #define UIP_ACKDATA 1 /* Signifies that the outstanding data was |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1487 acked and the application should send |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1488 out new data instead of retransmitting |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1489 the last data. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1490 #define UIP_NEWDATA 2 /* Flags the fact that the peer has sent |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1491 us new data. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1492 #define UIP_REXMIT 4 /* Tells the application to retransmit the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1493 data that was last sent. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1494 #define UIP_POLL 8 /* Used for polling the application, to |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1495 check if the application has data that |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1496 it wants to send. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1497 #define UIP_CLOSE 16 /* The remote host has closed the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1498 connection, thus the connection has |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1499 gone away. Or the application signals |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1500 that it wants to close the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1501 connection. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1502 #define UIP_ABORT 32 /* The remote host has aborted the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1503 connection, thus the connection has |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1504 gone away. Or the application signals |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1505 that it wants to abort the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1506 connection. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1507 #define UIP_CONNECTED 64 /* We have got a connection from a remote |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1508 host and have set up a new connection |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1509 for it, or an active connection has |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1510 been successfully established. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1511 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1512 #define UIP_TIMEDOUT 128 /* The connection has been aborted due to |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1513 too many retransmissions. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1514 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1515 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1516 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1517 * \brief process the options within a hop by hop or destination option header |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1518 * \retval 0: nothing to send, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1519 * \retval 1: drop pkt |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1520 * \retval 2: ICMP error message to send |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1521 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1522 /*static u8_t |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1523 uip_ext_hdr_options_process(); */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1524 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1525 /* uip_process(flag): |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1526 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1527 * The actual uIP function which does all the work. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1528 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1529 void uip_process(u8_t flag); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1530 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1531 /* The following flags are passed as an argument to the uip_process() |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1532 function. They are used to distinguish between the two cases where |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1533 uip_process() is called. It can be called either because we have |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1534 incoming data that should be processed, or because the periodic |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1535 timer has fired. These values are never used directly, but only in |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1536 the macros defined in this file. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1537 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1538 #define UIP_DATA 1 /* Tells uIP that there is incoming |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1539 data in the uip_buf buffer. The |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1540 length of the data is stored in the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1541 global variable uip_len. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1542 #define UIP_TIMER 2 /* Tells uIP that the periodic timer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1543 has fired. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1544 #define UIP_POLL_REQUEST 3 /* Tells uIP that a connection should |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1545 be polled. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1546 #define UIP_UDP_SEND_CONN 4 /* Tells uIP that a UDP datagram |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1547 should be constructed in the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1548 uip_buf buffer. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1549 #if UIP_UDP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1550 #define UIP_UDP_TIMER 5 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1551 #endif /* UIP_UDP */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1552 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1553 /* The TCP states used in the uip_conn->tcpstateflags. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1554 #define UIP_CLOSED 0 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1555 #define UIP_SYN_RCVD 1 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1556 #define UIP_SYN_SENT 2 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1557 #define UIP_ESTABLISHED 3 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1558 #define UIP_FIN_WAIT_1 4 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1559 #define UIP_FIN_WAIT_2 5 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1560 #define UIP_CLOSING 6 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1561 #define UIP_TIME_WAIT 7 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1562 #define UIP_LAST_ACK 8 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1563 #define UIP_TS_MASK 15 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1564 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1565 #define UIP_STOPPED 16 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1566 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1567 /* The TCP and IP headers. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1568 struct uip_tcpip_hdr { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1569 #if UIP_CONF_IPV6 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1570 /* IPv6 header. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1571 u8_t vtc, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1572 tcflow; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1573 u16_t flow; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1574 u8_t len[2]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1575 u8_t proto, ttl; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1576 uip_ip6addr_t srcipaddr, destipaddr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1577 #else /* UIP_CONF_IPV6 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1578 /* IPv4 header. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1579 u8_t vhl, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1580 tos, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1581 len[2], |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1582 ipid[2], |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1583 ipoffset[2], |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1584 ttl, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1585 proto; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1586 u16_t ipchksum; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1587 uip_ipaddr_t srcipaddr, destipaddr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1588 #endif /* UIP_CONF_IPV6 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1589 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1590 /* TCP header. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1591 u16_t srcport, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1592 destport; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1593 u8_t seqno[4], |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1594 ackno[4], |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1595 tcpoffset, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1596 flags, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1597 wnd[2]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1598 u16_t tcpchksum; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1599 u8_t urgp[2]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1600 u8_t optdata[4]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1601 }; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1602 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1603 /* The ICMP and IP headers. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1604 struct uip_icmpip_hdr { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1605 #if UIP_CONF_IPV6 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1606 /* IPv6 header. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1607 u8_t vtc, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1608 tcf; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1609 u16_t flow; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1610 u8_t len[2]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1611 u8_t proto, ttl; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1612 uip_ip6addr_t srcipaddr, destipaddr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1613 #else /* UIP_CONF_IPV6 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1614 /* IPv4 header. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1615 u8_t vhl, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1616 tos, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1617 len[2], |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1618 ipid[2], |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1619 ipoffset[2], |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1620 ttl, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1621 proto; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1622 u16_t ipchksum; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1623 uip_ipaddr_t srcipaddr, destipaddr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1624 #endif /* UIP_CONF_IPV6 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1625 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1626 /* ICMP header. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1627 u8_t type, icode; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1628 u16_t icmpchksum; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1629 #if !UIP_CONF_IPV6 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1630 u16_t id, seqno; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1631 u8_t payload[1]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1632 #endif /* !UIP_CONF_IPV6 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1633 }; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1634 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1635 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1636 /* The UDP and IP headers. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1637 struct uip_udpip_hdr { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1638 #if UIP_CONF_IPV6 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1639 /* IPv6 header. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1640 u8_t vtc, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1641 tcf; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1642 u16_t flow; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1643 u8_t len[2]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1644 u8_t proto, ttl; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1645 uip_ip6addr_t srcipaddr, destipaddr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1646 #else /* UIP_CONF_IPV6 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1647 /* IP header. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1648 u8_t vhl, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1649 tos, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1650 len[2], |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1651 ipid[2], |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1652 ipoffset[2], |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1653 ttl, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1654 proto; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1655 u16_t ipchksum; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1656 uip_ipaddr_t srcipaddr, destipaddr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1657 #endif /* UIP_CONF_IPV6 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1658 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1659 /* UDP header. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1660 u16_t srcport, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1661 destport; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1662 u16_t udplen; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1663 u16_t udpchksum; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1664 }; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1665 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1666 /* |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1667 * In IPv6 the length of the L3 headers before the transport header is |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1668 * not fixed, due to the possibility to include extension option headers |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1669 * after the IP header. hence we split here L3 and L4 headers |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1670 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1671 /* The IP header */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1672 struct uip_ip_hdr { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1673 #if UIP_CONF_IPV6 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1674 /* IPV6 header */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1675 u8_t vtc; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1676 u8_t tcflow; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1677 u16_t flow; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1678 u8_t len[2]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1679 u8_t proto, ttl; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1680 uip_ip6addr_t srcipaddr, destipaddr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1681 #else /* UIP_CONF_IPV6 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1682 /* IPV4 header */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1683 u8_t vhl, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1684 tos, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1685 len[2], |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1686 ipid[2], |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1687 ipoffset[2], |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1688 ttl, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1689 proto; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1690 u16_t ipchksum; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1691 uip_ipaddr_t srcipaddr, destipaddr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1692 #endif /* UIP_CONF_IPV6 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1693 }; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1694 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1695 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1696 /* |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1697 * IPv6 extension option headers: we are able to process |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1698 * the 4 extension headers defined in RFC2460 (IPv6): |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1699 * - Hop by hop option header, destination option header: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1700 * These two are not used by any core IPv6 protocol, hence |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1701 * we just read them and go to the next. They convey options, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1702 * the options defined in RFC2460 are Pad1 and PadN, which do |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1703 * some padding, and that we do not need to read (the length |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1704 * field in the header is enough) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1705 * - Routing header: this one is most notably used by MIPv6, |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1706 * which we do not implement, hence we just read it and go |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1707 * to the next |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1708 * - Fragmentation header: we read this header and are able to |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1709 * reassemble packets |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1710 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1711 * We do not offer any means to send packets with extension headers |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1712 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1713 * We do not implement Authentication and ESP headers, which are |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1714 * used in IPSec and defined in RFC4302,4303,4305,4385 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1715 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1716 /* common header part */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1717 typedef struct uip_ext_hdr { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1718 u8_t next; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1719 u8_t len; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1720 } uip_ext_hdr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1721 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1722 /* Hop by Hop option header */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1723 typedef struct uip_hbho_hdr { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1724 u8_t next; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1725 u8_t len; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1726 } uip_hbho_hdr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1727 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1728 /* destination option header */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1729 typedef struct uip_desto_hdr { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1730 u8_t next; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1731 u8_t len; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1732 } uip_desto_hdr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1733 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1734 /* We do not define structures for PAD1 and PADN options */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1735 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1736 /* |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1737 * routing header |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1738 * the routing header as 4 common bytes, then routing header type |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1739 * specific data there are several types of routing header. Type 0 was |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1740 * deprecated as per RFC5095 most notable other type is 2, used in |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1741 * RFC3775 (MIPv6) here we do not implement MIPv6, so we just need to |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1742 * parse the 4 first bytes |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1743 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1744 typedef struct uip_routing_hdr { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1745 u8_t next; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1746 u8_t len; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1747 u8_t routing_type; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1748 u8_t seg_left; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1749 } uip_routing_hdr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1750 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1751 /* fragmentation header */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1752 typedef struct uip_frag_hdr { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1753 u8_t next; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1754 u8_t res; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1755 u16_t offsetresmore; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1756 u32_t id; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1757 } uip_frag_hdr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1758 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1759 /* |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1760 * an option within the destination or hop by hop option headers |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1761 * it contains type an length, which is true for all options but PAD1 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1762 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1763 typedef struct uip_ext_hdr_opt { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1764 u8_t type; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1765 u8_t len; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1766 } uip_ext_hdr_opt; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1767 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1768 /* PADN option */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1769 typedef struct uip_ext_hdr_opt_padn { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1770 u8_t opt_type; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1771 u8_t opt_len; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1772 } uip_ext_hdr_opt_padn; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1773 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1774 /* TCP header */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1775 struct uip_tcp_hdr { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1776 u16_t srcport; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1777 u16_t destport; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1778 u8_t seqno[4]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1779 u8_t ackno[4]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1780 u8_t tcpoffset; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1781 u8_t flags; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1782 u8_t wnd[2]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1783 u16_t tcpchksum; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1784 u8_t urgp[2]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1785 u8_t optdata[4]; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1786 }; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1787 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1788 /* The ICMP headers. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1789 struct uip_icmp_hdr { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1790 u8_t type, icode; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1791 u16_t icmpchksum; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1792 #if !UIP_CONF_IPV6 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1793 u16_t id, seqno; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1794 #endif /* !UIP_CONF_IPV6 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1795 }; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1796 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1797 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1798 /* The UDP headers. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1799 struct uip_udp_hdr { |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1800 u16_t srcport; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1801 u16_t destport; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1802 u16_t udplen; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1803 u16_t udpchksum; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1804 }; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1805 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1806 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1807 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1808 * The buffer size available for user data in the \ref uip_buf buffer. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1809 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1810 * This macro holds the available size for user data in the \ref |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1811 * uip_buf buffer. The macro is intended to be used for checking |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1812 * bounds of available user data. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1813 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1814 * Example: |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1815 \code |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1816 snprintf(uip_appdata, UIP_APPDATA_SIZE, "%u\n", i); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1817 \endcode |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1818 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1819 * \hideinitializer |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1820 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1821 #define UIP_APPDATA_SIZE (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1822 #define UIP_APPDATA_PTR (void *)&uip_buf[UIP_LLH_LEN + UIP_TCPIP_HLEN] |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1823 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1824 #define UIP_PROTO_ICMP 1 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1825 #define UIP_PROTO_TCP 6 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1826 #define UIP_PROTO_UDP 17 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1827 #define UIP_PROTO_ICMP6 58 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1828 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1829 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1830 #if UIP_CONF_IPV6 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1831 /** @{ */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1832 /** \brief extension headers types */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1833 #define UIP_PROTO_HBHO 0 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1834 #define UIP_PROTO_DESTO 60 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1835 #define UIP_PROTO_ROUTING 43 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1836 #define UIP_PROTO_FRAG 44 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1837 #define UIP_PROTO_NONE 59 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1838 /** @} */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1839 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1840 /** @{ */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1841 /** \brief Destination and Hop By Hop extension headers option types */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1842 #define UIP_EXT_HDR_OPT_PAD1 0 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1843 #define UIP_EXT_HDR_OPT_PADN 1 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1844 /** @} */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1845 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1846 /** @{ */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1847 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1848 * \brief Bitmaps for extension header processing |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1849 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1850 * When processing extension headers, we should record somehow which one we |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1851 * see, because you cannot have twice the same header, except for destination |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1852 * We store all this in one u8_t bitmap one bit for each header expected. The |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1853 * order in the bitmap is the order recommended in RFC2460 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1854 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1855 #define UIP_EXT_HDR_BITMAP_HBHO 0x01 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1856 #define UIP_EXT_HDR_BITMAP_DESTO1 0x02 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1857 #define UIP_EXT_HDR_BITMAP_ROUTING 0x04 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1858 #define UIP_EXT_HDR_BITMAP_FRAG 0x08 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1859 #define UIP_EXT_HDR_BITMAP_AH 0x10 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1860 #define UIP_EXT_HDR_BITMAP_ESP 0x20 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1861 #define UIP_EXT_HDR_BITMAP_DESTO2 0x40 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1862 /** @} */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1863 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1864 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1865 #endif /* UIP_CONF_IPV6 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1866 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1867 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1868 /* Header sizes. */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1869 #if UIP_CONF_IPV6 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1870 #define UIP_IPH_LEN 40 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1871 #define UIP_FRAGH_LEN 8 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1872 #else /* UIP_CONF_IPV6 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1873 #define UIP_IPH_LEN 20 /* Size of IP header */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1874 #endif /* UIP_CONF_IPV6 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1875 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1876 #define UIP_UDPH_LEN 8 /* Size of UDP header */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1877 #define UIP_TCPH_LEN 20 /* Size of TCP header */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1878 #ifdef UIP_IPH_LEN |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1879 #define UIP_ICMPH_LEN 4 /* Size of ICMP header */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1880 #endif |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1881 #define UIP_IPUDPH_LEN (UIP_UDPH_LEN + UIP_IPH_LEN) /* Size of IP + |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1882 * UDP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1883 * header */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1884 #define UIP_IPTCPH_LEN (UIP_TCPH_LEN + UIP_IPH_LEN) /* Size of IP + |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1885 * TCP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1886 * header */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1887 #define UIP_TCPIP_HLEN UIP_IPTCPH_LEN |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1888 #define UIP_IPICMPH_LEN (UIP_IPH_LEN + UIP_ICMPH_LEN) /* size of ICMP |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1889 + IP header */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1890 #define UIP_LLIPH_LEN (UIP_LLH_LEN + UIP_IPH_LEN) /* size of L2 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1891 + IP header */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1892 #if UIP_CONF_IPV6 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1893 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1894 * The sums below are quite used in ND. When used for uip_buf, we |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1895 * include link layer length when used for uip_len, we do not, hence |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1896 * we need values with and without LLH_LEN we do not use capital |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1897 * letters as these values are variable |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1898 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1899 #define uip_l2_l3_hdr_len (UIP_LLH_LEN + UIP_IPH_LEN + uip_ext_len) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1900 #define uip_l2_l3_icmp_hdr_len (UIP_LLH_LEN + UIP_IPH_LEN + uip_ext_len + UIP_ICMPH_LEN) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1901 #define uip_l3_hdr_len (UIP_IPH_LEN + uip_ext_len) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1902 #define uip_l3_icmp_hdr_len (UIP_IPH_LEN + uip_ext_len + UIP_ICMPH_LEN) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1903 #endif /*UIP_CONF_IPV6*/ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1904 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1905 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1906 #if UIP_FIXEDADDR |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1907 CCIF extern const uip_ipaddr_t uip_hostaddr, uip_netmask, uip_draddr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1908 #else /* UIP_FIXEDADDR */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1909 CCIF extern uip_ipaddr_t uip_hostaddr, uip_netmask, uip_draddr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1910 #endif /* UIP_FIXEDADDR */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1911 CCIF extern const uip_ipaddr_t uip_broadcast_addr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1912 CCIF extern const uip_ipaddr_t uip_all_zeroes_addr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1913 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1914 #if UIP_FIXEDETHADDR |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1915 CCIF extern const uip_lladdr_t uip_lladdr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1916 #else |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1917 CCIF extern uip_lladdr_t uip_lladdr; |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1918 #endif |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1919 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1920 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1921 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1922 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1923 #ifdef UIP_CONF_IPV6 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1924 /** Length of the link local prefix */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1925 #define UIP_LLPREF_LEN 10 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1926 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1927 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1928 * \brief Is IPv6 address a the unspecified address |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1929 * a is of type uip_ipaddr_t |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1930 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1931 #define uip_is_addr_loopback(a) \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1932 ((((a)->u16[0]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1933 (((a)->u16[1]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1934 (((a)->u16[2]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1935 (((a)->u16[3]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1936 (((a)->u16[4]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1937 (((a)->u16[5]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1938 (((a)->u16[6]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1939 (((a)->u16[7]) == 1)) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1940 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1941 * \brief Is IPv6 address a the unspecified address |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1942 * a is of type uip_ipaddr_t |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1943 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1944 #define uip_is_addr_unspecified(a) \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1945 ((((a)->u16[0]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1946 (((a)->u16[1]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1947 (((a)->u16[2]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1948 (((a)->u16[3]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1949 (((a)->u16[4]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1950 (((a)->u16[5]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1951 (((a)->u16[6]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1952 (((a)->u16[7]) == 0)) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1953 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1954 /** \brief Is IPv6 address a the link local all-nodes multicast address */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1955 #define uip_is_addr_linklocal_allnodes_mcast(a) \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1956 ((((a)->u8[0]) == 0xff) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1957 (((a)->u8[1]) == 0x02) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1958 (((a)->u16[1]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1959 (((a)->u16[2]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1960 (((a)->u16[3]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1961 (((a)->u16[4]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1962 (((a)->u16[5]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1963 (((a)->u16[6]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1964 (((a)->u8[14]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1965 (((a)->u8[15]) == 0x01)) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1966 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1967 /** \brief Is IPv6 address a the link local all-routers multicast address */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1968 #define uip_is_addr_linklocal_allrouters_mcast(a) \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1969 ((((a)->u8[0]) == 0xff) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1970 (((a)->u8[1]) == 0x02) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1971 (((a)->u16[1]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1972 (((a)->u16[2]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1973 (((a)->u16[3]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1974 (((a)->u16[4]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1975 (((a)->u16[5]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1976 (((a)->u16[6]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1977 (((a)->u8[14]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1978 (((a)->u8[15]) == 0x02)) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1979 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1980 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1981 * \brief Checks whether the address a is link local. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1982 * a is of type uip_ipaddr_t |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1983 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1984 #define uip_is_addr_linklocal(a) \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1985 ((a)->u8[0] == 0xfe && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1986 (a)->u8[1] == 0x80) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1987 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1988 /** \brief set IP address a to unspecified */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1989 #define uip_create_unspecified(a) uip_ip6addr(a, 0, 0, 0, 0, 0, 0, 0, 0) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1990 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1991 /** \brief set IP address a to the link local all-nodes multicast address */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1992 #define uip_create_linklocal_allnodes_mcast(a) uip_ip6addr(a, 0xff02, 0, 0, 0, 0, 0, 0, 0x0001) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1993 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1994 /** \brief set IP address a to the link local all-routers multicast address */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1995 #define uip_create_linklocal_allrouters_mcast(a) uip_ip6addr(a, 0xff02, 0, 0, 0, 0, 0, 0, 0x0002) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1996 #define uip_create_linklocal_prefix(addr) do { \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1997 (addr)->u16[0] = UIP_HTONS(0xfe80); \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1998 (addr)->u16[1] = 0; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1999 (addr)->u16[2] = 0; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2000 (addr)->u16[3] = 0; \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2001 } while(0) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2002 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2003 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2004 * \brief is addr (a) a solicited node multicast address, see RFC3513 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2005 * a is of type uip_ipaddr_t* |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2006 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2007 #define uip_is_addr_solicited_node(a) \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2008 ((((a)->u8[0]) == 0xFF) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2009 (((a)->u8[1]) == 0x02) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2010 (((a)->u16[1]) == 0x00) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2011 (((a)->u16[2]) == 0x00) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2012 (((a)->u16[3]) == 0x00) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2013 (((a)->u16[4]) == 0x00) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2014 (((a)->u8[10]) == 0x00) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2015 (((a)->u8[11]) == 0x01) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2016 (((a)->u8[12]) == 0xFF)) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2017 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2018 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2019 * \briefput in b the solicited node address corresponding to address a |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2020 * both a and b are of type uip_ipaddr_t* |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2021 * */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2022 #define uip_create_solicited_node(a, b) \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2023 (((b)->u8[0]) = 0xFF); \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2024 (((b)->u8[1]) = 0x02); \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2025 (((b)->u16[1]) = 0); \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2026 (((b)->u16[2]) = 0); \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2027 (((b)->u16[3]) = 0); \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2028 (((b)->u16[4]) = 0); \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2029 (((b)->u8[10]) = 0); \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2030 (((b)->u8[11]) = 0x01); \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2031 (((b)->u8[12]) = 0xFF); \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2032 (((b)->u8[13]) = ((a)->u8[13])); \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2033 (((b)->u16[7]) = ((a)->u16[7])) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2034 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2035 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2036 * \brief is addr (a) a link local unicast address, see RFC3513 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2037 * i.e. is (a) on prefix FE80::/10 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2038 * a is of type uip_ipaddr_t* |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2039 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2040 #define uip_is_addr_link_local(a) \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2041 ((((a)->u8[0]) == 0xFE) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2042 (((a)->u8[1]) == 0x80)) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2043 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2044 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2045 * \brief was addr (a) forged based on the mac address m |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2046 * a type is uip_ipaddr_t |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2047 * m type is uiplladdr_t |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2048 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2049 #if UIP_CONF_LL_802154 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2050 #define uip_is_addr_mac_addr_based(a, m) \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2051 ((((a)->u8[8]) == (((m)->addr[0]) ^ 0x02)) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2052 (((a)->u8[9]) == (m)->addr[1]) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2053 (((a)->u8[10]) == (m)->addr[2]) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2054 (((a)->u8[11]) == (m)->addr[3]) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2055 (((a)->u8[12]) == (m)->addr[4]) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2056 (((a)->u8[13]) == (m)->addr[5]) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2057 (((a)->u8[14]) == (m)->addr[6]) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2058 (((a)->u8[15]) == (m)->addr[7])) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2059 #else |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2060 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2061 #define uip_is_addr_mac_addr_based(a, m) \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2062 ((((a)->u8[8]) == (((m)->addr[0]) | 0x02)) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2063 (((a)->u8[9]) == (m)->addr[1]) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2064 (((a)->u8[10]) == (m)->addr[2]) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2065 (((a)->u8[11]) == 0xff) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2066 (((a)->u8[12]) == 0xfe) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2067 (((a)->u8[13]) == (m)->addr[3]) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2068 (((a)->u8[14]) == (m)->addr[4]) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2069 (((a)->u8[15]) == (m)->addr[5])) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2070 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2071 #endif /*UIP_CONF_LL_802154*/ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2072 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2073 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2074 * \brief is address a multicast address, see RFC 3513 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2075 * a is of type uip_ipaddr_t* |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2076 * */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2077 #define uip_is_addr_mcast(a) \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2078 (((a)->u8[0]) == 0xFF) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2079 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2080 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2081 * \brief is group-id of multicast address a |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2082 * the all nodes group-id |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2083 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2084 #define uip_is_mcast_group_id_all_nodes(a) \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2085 ((((a)->u16[1]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2086 (((a)->u16[2]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2087 (((a)->u16[3]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2088 (((a)->u16[4]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2089 (((a)->u16[5]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2090 (((a)->u16[6]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2091 (((a)->u8[14]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2092 (((a)->u8[15]) == 1)) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2093 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2094 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2095 * \brief is group-id of multicast address a |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2096 * the all routers group-id |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2097 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2098 #define uip_is_mcast_group_id_all_routers(a) \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2099 ((((a)->u16[1]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2100 (((a)->u16[2]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2101 (((a)->u16[3]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2102 (((a)->u16[4]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2103 (((a)->u16[5]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2104 (((a)->u16[6]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2105 (((a)->u8[14]) == 0) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2106 (((a)->u8[15]) == 2)) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2107 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2108 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2109 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2110 * \brief are last three bytes of both addresses equal? |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2111 * This is used to compare solicited node multicast addresses |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2112 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2113 #define uip_are_solicited_bytes_equal(a, b) \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2114 ((((a)->u8[13]) == ((b)->u8[13])) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2115 (((a)->u8[14]) == ((b)->u8[14])) && \ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2116 (((a)->u8[15]) == ((b)->u8[15]))) |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2117 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2118 #endif /*UIP_CONF_IPV6*/ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2119 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2120 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2121 * Calculate the Internet checksum over a buffer. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2122 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2123 * The Internet checksum is the one's complement of the one's |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2124 * complement sum of all 16-bit words in the buffer. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2125 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2126 * See RFC1071. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2127 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2128 * \param buf A pointer to the buffer over which the checksum is to be |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2129 * computed. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2130 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2131 * \param len The length of the buffer over which the checksum is to |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2132 * be computed. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2133 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2134 * \return The Internet checksum of the buffer. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2135 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2136 u16_t uip_chksum(u16_t *buf, u16_t len); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2137 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2138 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2139 * Calculate the IP header checksum of the packet header in uip_buf. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2140 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2141 * The IP header checksum is the Internet checksum of the 20 bytes of |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2142 * the IP header. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2143 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2144 * \return The IP header checksum of the IP header in the uip_buf |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2145 * buffer. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2146 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2147 u16_t uip_ipchksum(void); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2148 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2149 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2150 * Calculate the TCP checksum of the packet in uip_buf and uip_appdata. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2151 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2152 * The TCP checksum is the Internet checksum of data contents of the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2153 * TCP segment, and a pseudo-header as defined in RFC793. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2154 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2155 * \return The TCP checksum of the TCP segment in uip_buf and pointed |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2156 * to by uip_appdata. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2157 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2158 u16_t uip_tcpchksum(void); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2159 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2160 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2161 * Calculate the UDP checksum of the packet in uip_buf and uip_appdata. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2162 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2163 * The UDP checksum is the Internet checksum of data contents of the |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2164 * UDP segment, and a pseudo-header as defined in RFC768. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2165 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2166 * \return The UDP checksum of the UDP segment in uip_buf and pointed |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2167 * to by uip_appdata. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2168 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2169 u16_t uip_udpchksum(void); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2170 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2171 /** |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2172 * Calculate the ICMP checksum of the packet in uip_buf. |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2173 * |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2174 * \return The ICMP checksum of the ICMP packet in uip_buf |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2175 */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2176 u16_t uip_icmp6chksum(void); |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2177 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2178 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2179 #endif /* __UIP_H__ */ |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2180 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2181 |
56d09a0969b5
Import uIP and the PPP implementation from
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2182 /** @} */ |