friendev EtherDune TCP/IP library
/home/jander/temp/etherdune/config.h
Go to the documentation of this file.
1 // EtherDune configuration file
2 // Author: Javier Peletier <jm@friendev.com>
3 // Summary: EtherDune settings, buffer sizes, compilation options, etc
4 //
5 // Copyright (c) 2015 All Rights Reserved, http://friendev.com
6 //
7 // This source is subject to the GPLv2 license.
8 // Please see the License.txt file for more information.
9 // All other rights reserved.
10 //
11 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
12 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
14 // PARTICULAR PURPOSE.
15 
16 #ifndef __EtherDune_CONFIG__
17 #define __EtherDune_CONFIG__
18 
19 #include <ACross.h>
20 
24 
30 static const uint16_t NETWORK_TIMER_RESOLUTION = 200;
31 
32 
36 
41 #define EtherDune_BUFFER_SIZE 566
42 
43 
75 #define EtherDune_SAMPLE_SIZE 42
76 
78 
82 
87 #define ENABLE_IP_RX_CHECKSUM true
88 
93 #define ENABLE_UDPTCP_RX_CHECKSUM true
94 
99 #define ENABLE_ICMP_RX_CHECKSUM true
100 
102 
124 
128 #define MAX_FRAMELEN 1500
129 
130 #define RXBUFFER_SIZE 3072
131 #define TXBUFFER_SIZE 1024
132 
133 
139 
143 static const uint8_t TCP_SRC_PORT_H = 250;
144 
148 static const uint8_t UDP_SRC_PORT_H = 240;
149 
150 static const uint16_t TCP_MAXIMUM_SEGMENT_SIZE = 512;
151 static const uint8_t MAX_TCP_CONNECT_RETRIES = 50;
152 
153 
159  #define SCK_TIMEOUT_SYN_SENT_MS 5000
160  #define SCK_TIMEOUT_SYN_RECEIVED_MS 5000
161  #define SCK_TIMEOUT_FIN_WAIT_1_MS 6000
162  #define SCK_TIMEOUT_FIN_WAIT_2_MS 2000
163  #define SCK_TIMEOUT_CLOSE_WAIT_MS 2000
164  #define SCK_TIMEOUT_CLOSING_MS 2000
165  #define SCK_TIMEOUT_LAST_ACK_MS 2000
166  #define SCK_TIMEOUT_TIME_WAIT_MS 3000
167  #define SCK_TIMEOUT_RESOLVING_MS 3000
168 
170 
176 
177 static const uint8_t ARP_TABLE_LENGTH = 2;
178 static const int16_t MAX_ARP_TTL = 20;
179 
181 
186 
187 #define DNS_TIMEOUT_QUERY_MS 5000
188 
189 
191 
196 
201 #define ENABLE_DHCP_HOSTNAME _DEBUG
202 
203 static const char DHCP_HOSTNAME[] PROGMEM = "ARDUINO";
204 
210 
211  #define DHCP_TIMEOUT_SELECTING_MS 1000
212  #define DHCP_TIMEOUT_REQUESTING_MS 5000
213  #define DHCP_TIMEOUT_BOUND_MS 1000
214 
215  static const uint8_t DHCP_MAX_ATTEMPTS = 4;
216 
217  static const uint16_t DHCP_DEFAULT_RENEWAL_TIMER_S = 7200;
218 
220 
222 
228 
229 static const uint8_t ICMP_PING_DATA_LENGTH = 32;
230 
232 
240 #define HTTP_SERVER_HEADER_NAME_MAX_LENGTH 20
241 #define HTTP_SERVER_HEADER_VALUE_MAX_LENGTH 20
242 #define HTTP_SERVER_QUERY_STRING_MAX_LENGTH 41
243 
245 // ----------------- END OF CONFIGURATION ------------------------
246 
247 // what follows are just computed values based on the above.
248 
249 #ifndef DOXYGEN_SHOULD_SKIP_THIS
250 
255 #define RXSTART_INIT 0x0000
256 #define RXSTOP_INIT (RXBUFFER_SIZE-1)
257 
258 #define TX_STATUS_VECTOR_SIZE 15
259 
260 #define TXSTART_INIT (RXSTOP_INIT + 1)
261 #define TXSTOP_INIT (TXSTART_INIT + TXBUFFER_SIZE - 1)
262 
263 #define ENC28J60_MEMSIZE 8192
265 
266 #define SHARED_BUFFER_INIT (TXSTOP_INIT + 1 + TX_STATUS_VECTOR_SIZE)
267 #define SHARED_BUFFER_CAPACITY (ENC28J60_MEMSIZE - SHARED_BUFFER_INIT)
268 
269 #define TXSTART_INIT_DATA (TXSTART_INIT + 1) // skip 1 byte to make room for the control byte required by ENC28J60
270 
271 static const uint16_t i2 = TXSTOP_INIT;
272 static const uint16_t i1 = SHARED_BUFFER_INIT;
274 
275 #define NTICKS(ms) ((ms)/NETWORK_TIMER_RESOLUTION)
276 
277 static const uint8_t SCK_TIMEOUT_SYN_SENT = NTICKS(SCK_TIMEOUT_SYN_SENT_MS); // (client) represents waiting for a matching connection request after having sent a connection request.
278 static const uint8_t SCK_TIMEOUT_SYN_RECEIVED = NTICKS(SCK_TIMEOUT_SYN_RECEIVED_MS); //(server) SYN has been received, SYN ACK was sent and now waiting for ACK.
279 static const uint8_t SCK_TIMEOUT_FIN_WAIT_1 = NTICKS(SCK_TIMEOUT_FIN_WAIT_1_MS); // (both server and client) represents waiting for a connection termination request from the remote TCP, or an acknowledgment of the connection termination request previously sent.
280 static const uint8_t SCK_TIMEOUT_FIN_WAIT_2 = NTICKS(SCK_TIMEOUT_FIN_WAIT_2_MS); // (both server and client) represents waiting for a connection termination request from the remote TCP.
281 static const uint8_t SCK_TIMEOUT_CLOSE_WAIT = NTICKS(SCK_TIMEOUT_CLOSE_WAIT_MS); // (both server and client) represents waiting for a connection termination request from the local user.
282 static const uint8_t SCK_TIMEOUT_CLOSING = NTICKS(SCK_TIMEOUT_CLOSING_MS); // (both server and client) represents waiting for a connection termination request acknowledgment from the remote TCP.
283 static const uint8_t SCK_TIMEOUT_LAST_ACK = NTICKS(SCK_TIMEOUT_LAST_ACK_MS); // (both server and client) represents waiting for an acknowledgment of the connection termination request previously sent to the remote TCP (which includes an acknowledgment of its connection termination request).
284 static const uint8_t SCK_TIMEOUT_TIME_WAIT = NTICKS(SCK_TIMEOUT_TIME_WAIT_MS); //(either server or client) represents waiting for enough time to pass to be sure the remote TCP received the acknowledgment of its connection termination request. [According to RFC 793 a connection can stay in TIME-WAIT for a maximum of four minutes known as a MSL (maximum segment lifetime).]
285 static const uint8_t SCK_TIMEOUT_RESOLVING = NTICKS(SCK_TIMEOUT_RESOLVING_MS); // waiting for a DNS query to resolve
286 
287 static const uint8_t DNS_TIMEOUT_QUERY = NTICKS(DNS_TIMEOUT_QUERY_MS);//DNS timeout
288 
289 static const uint8_t DHCP_TIMEOUT_SELECTING = NTICKS(DHCP_TIMEOUT_SELECTING_MS);
290 static const uint8_t DHCP_TIMEOUT_REQUESTING = NTICKS(DHCP_TIMEOUT_REQUESTING_MS);
291 static const uint8_t DHCP_TIMEOUT_BOUND = NTICKS(DHCP_TIMEOUT_BOUND_MS);
292 static const uint16_t DHCP_DEFAULT_RENEWAL_TIMER = DHCP_DEFAULT_RENEWAL_TIMER_S * 1000 / DHCP_TIMEOUT_BOUND_MS;
293 
294 #define QUOTE(str) #str
295 
296 //error checking
297 
298 #if EtherDune_BUFFER_SIZE < 566
299 #error EtherDune_BUFFER_SIZE must be at least 566 bytes
300 #endif
301 
302 //see EtherDune_SAMPLE_SIZE definition above to see why 42
303 #if EtherDune_SAMPLE_SIZE < 42
304 #error EtherDune_SAMPLE_SIZE must be at least 42 bytes
305 #endif
306 
307 #if EtherDune_SAMPLE_SIZE > EtherDune_BUFFER_SIZE
308 #error EtherDune_SAMPLE_SIZE must be less than EtherDune_BUFFER_SIZE
309 #endif
310 
311 #if EtherDune_BUFFER_SIZE & 1
312 #error EtherDune_BUFFER_SIZE must be an even number
313 #endif
314 
315 #define BUFFER_END (SHARED_BUFFER_INIT + SHARED_BUFFER_CAPACITY)
316 
317 #if (BUFFER_END) != (ENC28J60_MEMSIZE)
318 #error Memory mapping error
319 #endif
320 
321 #if RXBUFFER_SIZE & 1
322 #error RXBUFFER_SIZE must be an even number
323 #endif
324 
325 #if (SHARED_BUFFER_CAPACITY) < 2048
326 #error Resulting shared buffer capacity is too small. Reduce TXBUFFER_SIZE or RXBUFFER_SIZE to allow for more shared buffer.
327 #endif
328 
329 #endif
330 
332 
333 #endif
static const int16_t MAX_ARP_TTL
Time the ARP entry is considered fresh, in minutes.
Definition: config.h:178
static const uint8_t TCP_SRC_PORT_H
Indicates the most significant byte of the source port number that EtherDune will use by default when...
Definition: config.h:143
static const char DHCP_HOSTNAME[]
host name sent to DHCP server.
Definition: config.h:203
static const uint8_t DHCP_MAX_ATTEMPTS
how many times to retry if address request is denied.
Definition: config.h:215
#define DHCP_TIMEOUT_SELECTING_MS
(in milliseconds) DHCP timeout in the SELECTING DHCP phase (waiting for reply to DHCP DISCOVER) ...
Definition: config.h:211
#define SCK_TIMEOUT_TIME_WAIT_MS
(either server or client) represents waiting for enough time to pass to be sure the remote TCP receiv...
Definition: config.h:166
static const uint16_t TCP_MAXIMUM_SEGMENT_SIZE
Maximum size of payload accepted by the library.
Definition: config.h:150
#define DHCP_TIMEOUT_REQUESTING_MS
(in milliseconds) DHCP timeout in the REQUESTING phase (waiting for reply to DHCP REQUEST) ...
Definition: config.h:212
#define SCK_TIMEOUT_RESOLVING_MS
waiting for a DNS query to resolve.
Definition: config.h:167
#define DHCP_TIMEOUT_BOUND_MS
(in milliseconds) set to 1 second so as to decrement the renewal timer
Definition: config.h:213
static const uint8_t ARP_TABLE_LENGTH
Maximum number of entries in the ARP table.
Definition: config.h:177
#define SCK_TIMEOUT_SYN_RECEIVED_MS
(server) SYN has been received, SYN ACK was sent and now waiting for ACK.
Definition: config.h:160
#define SCK_TIMEOUT_CLOSING_MS
(both server and client) represents waiting for a connection termination request acknowledgment from ...
Definition: config.h:164
#define SCK_TIMEOUT_FIN_WAIT_2_MS
(both server and client) represents waiting for a connection termination request from the remote TCP...
Definition: config.h:162
#define DNS_TIMEOUT_QUERY_MS
How long to wait before giving up on a DNS query.
Definition: config.h:187
static const uint16_t DHCP_DEFAULT_RENEWAL_TIMER_S
Time in seconds to hold the IP lease, unless stated otherwise by the DHCP server. ...
Definition: config.h:217
static const uint8_t ICMP_PING_DATA_LENGTH
size of data to send as part of an echo request
Definition: config.h:229
static const uint16_t NETWORK_TIMER_RESOLUTION
Resolution of the NetworkService timer.
Definition: config.h:30
#define SCK_TIMEOUT_LAST_ACK_MS
(both server and client) represents waiting for an acknowledgment of the connection termination reque...
Definition: config.h:165
static const uint8_t MAX_TCP_CONNECT_RETRIES
how many SYN packets to send before giving up.
Definition: config.h:151
#define SCK_TIMEOUT_SYN_SENT_MS
(client) represents waiting for a matching connection request after having sent a connection request...
Definition: config.h:159
static const uint8_t UDP_SRC_PORT_H
Indicates the most significant byte of the source port number that EtherDune will use by default when...
Definition: config.h:148
#define SCK_TIMEOUT_FIN_WAIT_1_MS
(both server and client) represents waiting for a connection termination request from the remote TCP...
Definition: config.h:161
#define SCK_TIMEOUT_CLOSE_WAIT_MS
(both server and client) represents waiting for a connection termination request from the local user...
Definition: config.h:163