Details | Last modification | View Log | SVN | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 363 | johboh | 1 | /********************************************************************* |
| 2 | * |
||
| 3 | * Microchip TCP/IP Stack Definitions |
||
| 4 | * |
||
| 5 | ********************************************************************* |
||
| 6 | * FileName: StackTsk.h |
||
| 7 | * Dependencies: Compiler.h |
||
| 8 | * Processor: PIC18, PIC24F, PIC24H, dsPIC30F, dsPIC33F |
||
| 9 | * Complier: Microchip C18 v3.02 or higher |
||
| 10 | * Microchip C30 v2.01 or higher |
||
| 11 | * Company: Microchip Technology, Inc. |
||
| 12 | * |
||
| 13 | * Software License Agreement |
||
| 14 | * |
||
| 15 | * This software is owned by Microchip Technology Inc. ("Microchip") |
||
| 16 | * and is supplied to you for use exclusively as described in the |
||
| 17 | * associated software agreement. This software is protected by |
||
| 18 | * software and other intellectual property laws. Any use in |
||
| 19 | * violation of the software license may subject the user to criminal |
||
| 20 | * sanctions as well as civil liability. Copyright 2006 Microchip |
||
| 21 | * Technology Inc. All rights reserved. |
||
| 22 | * |
||
| 23 | * This software is provided "AS IS." MICROCHIP DISCLAIMS ALL |
||
| 24 | * WARRANTIES, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, NOT LIMITED |
||
| 25 | * TO MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND |
||
| 26 | * INFRINGEMENT. Microchip shall in no event be liable for special, |
||
| 27 | * incidental, or consequential damages. |
||
| 28 | * |
||
| 29 | * |
||
| 30 | * Author Date Comment |
||
| 31 | *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
| 32 | * Nilesh Rajbharti 8/10/01 Original (Rev 1.0) |
||
| 33 | * Nilesh Rajbharti 2/9/02 Cleanup |
||
| 34 | * Nilesh Rajbharti 5/22/02 Rev 2.0 (See version.log for detail) |
||
| 35 | * Nilesh Rajbharti 8/7/03 Rev 2.21 - TFTP Client addition |
||
| 36 | * Howard Schlunder 9/30/04 Added MCHP_MAC, MAC_POWER_ON_TEST, |
||
| 37 | EEPROM_BUFFER_SIZE, USE_LCD |
||
| 38 | * Howard Schlunder 8/09/06 Removed MCHP_MAC, added STACK_USE_NBNS, |
||
| 39 | * STACK_USE_DNS, and STACK_USE_GENERIC_TCP_EXAMPLE |
||
| 40 | ********************************************************************/ |
||
| 41 | #ifndef STACK_TSK_H |
||
| 42 | #define STACK_TSK_H |
||
| 43 | |||
| 44 | #include "..\Include\GenericTypeDefs.h" |
||
| 45 | #include "..\Include\Compiler.h" |
||
| 46 | |||
| 47 | /* |
||
| 48 | * This value is used by TCP to implement timeout actions. |
||
| 49 | * If SNMP module is in use, this value should be 100 as required |
||
| 50 | * by SNMP protocol unless main application is providing separate |
||
| 51 | * tick which 10mS. |
||
| 52 | */ |
||
| 53 | #define TICKS_PER_SECOND (100) // 10ms |
||
| 54 | |||
| 55 | #if (TICKS_PER_SECOND < 10 || TICKS_PER_SECOND > 255) |
||
| 56 | #error Invalid TICKS_PER_SECONDS specified. |
||
| 57 | #endif |
||
| 58 | |||
| 59 | /* |
||
| 60 | * Manually select prescale value to achieve necessary tick period |
||
| 61 | * for a given clock frequency. |
||
| 62 | */ |
||
| 63 | #define TICK_PRESCALE_VALUE (256) |
||
| 64 | |||
| 65 | #if (TICK_PRESCALE_VALUE != 2 && \ |
||
| 66 | TICK_PRESCALE_VALUE != 4 && \ |
||
| 67 | TICK_PRESCALE_VALUE != 8 && \ |
||
| 68 | TICK_PRESCALE_VALUE != 16 && \ |
||
| 69 | TICK_PRESCALE_VALUE != 32 && \ |
||
| 70 | TICK_PRESCALE_VALUE != 64 && \ |
||
| 71 | TICK_PRESCALE_VALUE != 128 && \ |
||
| 72 | TICK_PRESCALE_VALUE != 256 ) |
||
| 73 | #error Invalid TICK_PRESCALE_VALUE specified. |
||
| 74 | #endif |
||
| 75 | |||
| 76 | #if defined(WIN32) |
||
| 77 | #undef TICKS_PER_SECOND |
||
| 78 | #define TICKS_PER_SECOND (1) |
||
| 79 | #endif |
||
| 80 | |||
| 81 | |||
| 82 | /* |
||
| 83 | * This value is specific to the Microchip Ethernet controllers. |
||
| 84 | * If a different Ethernet controller is used, this define is not |
||
| 85 | * used. If a Microchip controller is used and a self memory test |
||
| 86 | * should be done when the MACInit() function is called, |
||
| 87 | * uncomment this define. The test requires ~512 bytes of |
||
| 88 | * program memory. |
||
| 89 | */ |
||
| 90 | //#define MAC_POWER_ON_TEST |
||
| 91 | |||
| 92 | |||
| 93 | /* |
||
| 94 | * This value is specific to the Microchip Ethernet controllers. |
||
| 95 | * If a different Ethernet controller is used, this define is not |
||
| 96 | * used. Ideally, when MAC_FILTER_BROADCASTS is defined, all |
||
| 97 | * broadcast packets that are received would be discarded by the |
||
| 98 | * hardware, except for ARP requests for our IP address. This could |
||
| 99 | * be accomplished by filtering all broadcasts, but allowing the ARPs |
||
| 100 | * using the patter match filter. The code for this feature has been |
||
| 101 | * partially implemented, but it is not complete nor tested, so this |
||
| 102 | * option should remain unused in this stack version. |
||
| 103 | */ |
||
| 104 | //#define MAC_FILTER_BROADCASTS |
||
| 105 | |||
| 106 | |||
| 107 | /* |
||
| 108 | * SPI Serial EEPROM buffer size. To enhance performance while |
||
| 109 | * cooperatively sharing the SPI bus with other peripherals, bytes |
||
| 110 | * read and written to the memory are locally buffered. This |
||
| 111 | * parameter has no effect if spieeprom.c is not included in the |
||
| 112 | * project. Legal sizes are 1 to the EEPROM page size. |
||
| 113 | */ |
||
| 114 | #define EEPROM_BUFFER_SIZE (12) |
||
| 115 | |||
| 116 | |||
| 117 | /* |
||
| 118 | * This value is for Microchip 24LC256 - 256kb serial EEPROM |
||
| 119 | */ |
||
| 120 | #define EEPROM_CONTROL (0xa0) |
||
| 121 | |||
| 122 | |||
| 123 | /* |
||
| 124 | * Number of bytes to be reserved before MPFS storage is to start. |
||
| 125 | * |
||
| 126 | * These bytes host application configurations such as IP Address, |
||
| 127 | * MAC Address, and any other required variables. |
||
| 128 | * |
||
| 129 | * After making any change to this variable, MPFS.exe must be |
||
| 130 | * executed with correct block size. |
||
| 131 | * See MPFS.exe help message by executing MPFS /? |
||
| 132 | */ |
||
| 133 | #define MPFS_RESERVE_BLOCK (64) |
||
| 134 | |||
| 135 | |||
| 136 | |||
| 137 | /* |
||
| 138 | * Modules to include in this project |
||
| 139 | * For demo purpose only, each sample project defines one or more |
||
| 140 | * of following defines in compiler command-line options. (See |
||
| 141 | * each MPLAB Project Node Properties under "Project->Edit Project" menu. |
||
| 142 | * In real applcation, user may want to define them here. |
||
| 143 | */ |
||
| 144 | #define STACK_USE_ICMP |
||
| 145 | #define STACK_USE_HTTP_SERVER |
||
| 146 | #define STACK_USE_SGP_SERVER |
||
| 147 | #define STACK_USE_TIMESYNC |
||
| 148 | //#define STACK_USE_SLIP // Not currently supported |
||
| 149 | //#define STACK_USE_IP_GLEANING |
||
| 150 | //#define STACK_USE_DHCP |
||
| 151 | //#define STACK_USE_SNMP_SERVER |
||
| 152 | //#define STACK_USE_TFTP_CLIENT |
||
| 153 | #define STACK_USE_DNS // Domain Name Service Client |
||
| 154 | //#define STACK_USE_NBNS // NetBIOS Name Service Server |
||
| 155 | |||
| 156 | /* |
||
| 157 | * Following low level modules are automatically enabled/disabled based on high-level |
||
| 158 | * module selections. |
||
| 159 | * If you need them with your custom application, enable it here. |
||
| 160 | */ |
||
| 161 | //#define STACK_USE_TCP |
||
| 162 | //#define STACK_USE_UDP |
||
| 163 | |||
| 164 | // Uncomment following line if SNMP TRAP support is required |
||
| 165 | //#define SNMP_TRAP_DISABED |
||
| 166 | |||
| 167 | /* |
||
| 168 | * When SLIP is used, DHCP is not supported. |
||
| 169 | */ |
||
| 170 | #if defined(STACK_USE_SLIP) |
||
| 171 | #undef STACK_USE_DHCP |
||
| 172 | #endif |
||
| 173 | |||
| 174 | |||
| 175 | |||
| 176 | /* |
||
| 177 | * Comment following line if StackTsk should wait for acknowledgement |
||
| 178 | * from remote host before transmitting another packet. |
||
| 179 | * Commenting following line may reduce throughput. |
||
| 180 | */ |
||
| 181 | //#define TCP_NO_WAIT_FOR_ACK |
||
| 182 | |||
| 183 | |||
| 184 | /* |
||
| 185 | * Uncomment following line if this stack will be used in CLIENT |
||
| 186 | * mode. In CLIENT mode, some functions specific to client operation |
||
| 187 | * are enabled. |
||
| 188 | */ |
||
| 189 | //#define STACK_CLIENT_MODE |
||
| 190 | |||
| 191 | |||
| 192 | /* |
||
| 193 | * If html pages are stored in internal program memory, |
||
| 194 | * uncomment MPFS_USE_PRGM and comment MPFS_USE_EEPROM |
||
| 195 | * If html pages are stored in external eeprom memory, |
||
| 196 | * comment MPFS_USE_PRGM and uncomment MPFS_USE_EEPROM |
||
| 197 | */ |
||
| 198 | //#define MPFS_USE_PGRM |
||
| 199 | //#define MPFS_USE_EEPROM |
||
| 200 | |||
| 201 | #if defined(MPFS_USE_PGRM) && defined(MPFS_USE_EEPROM) |
||
| 202 | #error Invalid MPFS Storage option specified. |
||
| 203 | #endif |
||
| 204 | |||
| 205 | #if !defined(MPFS_USE_PGRM) && !defined(MPFS_USE_EEPROM) |
||
| 206 | #error You have not specified MPFS storage option. |
||
| 207 | #endif |
||
| 208 | |||
| 209 | |||
| 210 | /* |
||
| 211 | * When HTTP is enabled, TCP must be enabled. |
||
| 212 | */ |
||
| 213 | #if defined(STACK_USE_HTTP_SERVER) |
||
| 214 | #if !defined(STACK_USE_TCP) |
||
| 215 | #define STACK_USE_TCP |
||
| 216 | #endif |
||
| 217 | #endif |
||
| 218 | |||
| 219 | /* |
||
| 220 | * When FTP is enabled, TCP must be enabled. |
||
| 221 | */ |
||
| 222 | #if defined(STACK_USE_FTP_SERVER) |
||
| 223 | #if !defined(STACK_USE_TCP) |
||
| 224 | #define STACK_USE_TCP |
||
| 225 | #endif |
||
| 226 | #endif |
||
| 227 | |||
| 228 | |||
| 229 | #if (defined(STACK_USE_FTP_SERVER) || \ |
||
| 230 | defined(STACK_USE_SNMP_SERVER) || \ |
||
| 231 | defined(STACK_USE_DNS) || \ |
||
| 232 | defined(STACK_USE_GENERIC_TCP_EXAMPLE) || \ |
||
| 233 | defined(STACK_USE_TFTP_CLIENT) ) |
||
| 234 | #if !defined(STACK_CLIENT_MODE) |
||
| 235 | #define STACK_CLIENT_MODE |
||
| 236 | #endif |
||
| 237 | #endif |
||
| 238 | |||
| 239 | /* |
||
| 240 | * When DHCP is enabled, UDP must also be enabled. |
||
| 241 | */ |
||
| 242 | #if defined(STACK_USE_DHCP) || \ |
||
| 243 | defined(STACK_USE_DNS) || \ |
||
| 244 | defined(STACK_USE_NBNS) || \ |
||
| 245 | defined(STACK_USE_SNMP_SERVER) || \ |
||
| 246 | defined(STACK_USE_TFTP_CLIENT) || \ |
||
| 247 | defined(STACK_USE_ANNOUNCE) |
||
| 248 | #if !defined(STACK_USE_UDP) |
||
| 249 | #define STACK_USE_UDP |
||
| 250 | #endif |
||
| 251 | #endif |
||
| 252 | |||
| 253 | /* |
||
| 254 | * When IP Gleaning is enabled, ICMP must also be enabled. |
||
| 255 | */ |
||
| 256 | #if defined(STACK_USE_IP_GLEANING) |
||
| 257 | #if !defined(STACK_USE_ICMP) |
||
| 258 | #define STACK_USE_ICMP |
||
| 259 | #endif |
||
| 260 | #endif |
||
| 261 | |||
| 262 | |||
| 263 | /* |
||
| 264 | * DHCP requires unfragmented packet size of at least 328 bytes, |
||
| 265 | * and while in SLIP mode, our maximum packet size is less than |
||
| 266 | * 255. Hence disallow DHCP module while SLIP is in use. |
||
| 267 | * If required, one can use DHCP while SLIP is in use by modifying |
||
| 268 | * C18 linker scipt file such that C18 compiler can allocate |
||
| 269 | * a static array larger than 255 bytes. |
||
| 270 | * Due to very specific application that would require this, |
||
| 271 | * sample stack does not provide such facility. Interested users |
||
| 272 | * must do this on their own. |
||
| 273 | */ |
||
| 274 | #if defined(STACK_USE_SLIP) |
||
| 275 | #if defined(STACK_USE_DHCP) |
||
| 276 | #error DHCP cannot be used when SLIP is enabled. |
||
| 277 | #endif |
||
| 278 | #endif |
||
| 279 | |||
| 280 | |||
| 281 | // |
||
| 282 | // Default Address information - If not found in data EEPROM. |
||
| 283 | // |
||
| 284 | #define MY_DEFAULT_HOST_NAME "ETEMP" |
||
| 285 | |||
| 286 | #define MY_DEFAULT_MAC_BYTE1 (0x00) |
||
| 287 | #define MY_DEFAULT_MAC_BYTE2 (0x10) |
||
| 288 | #define MY_DEFAULT_MAC_BYTE3 (0xA7) |
||
| 289 | #define MY_DEFAULT_MAC_BYTE4 (0x02) |
||
| 290 | #define MY_DEFAULT_MAC_BYTE5 (0xF2) |
||
| 291 | #define MY_DEFAULT_MAC_BYTE6 (0xBF) |
||
| 292 | |||
| 293 | #define MY_DEFAULT_IP_ADDR_BYTE1 (193) |
||
| 294 | #define MY_DEFAULT_IP_ADDR_BYTE2 (11) |
||
| 295 | #define MY_DEFAULT_IP_ADDR_BYTE3 (249) |
||
| 296 | #define MY_DEFAULT_IP_ADDR_BYTE4 (228) |
||
| 297 | |||
| 298 | #define MY_DEFAULT_MASK_BYTE1 (255) |
||
| 299 | #define MY_DEFAULT_MASK_BYTE2 (255) |
||
| 300 | #define MY_DEFAULT_MASK_BYTE3 (255) |
||
| 301 | #define MY_DEFAULT_MASK_BYTE4 (0) |
||
| 302 | |||
| 303 | #define MY_DEFAULT_GATE_BYTE1 MY_DEFAULT_IP_ADDR_BYTE1 |
||
| 304 | #define MY_DEFAULT_GATE_BYTE2 MY_DEFAULT_IP_ADDR_BYTE2 |
||
| 305 | #define MY_DEFAULT_GATE_BYTE3 MY_DEFAULT_IP_ADDR_BYTE3 |
||
| 306 | #define MY_DEFAULT_GATE_BYTE4 (1) |
||
| 307 | |||
| 308 | #define MY_DEFAULT_DNS_BYTE1 MY_DEFAULT_GATE_BYTE1 |
||
| 309 | #define MY_DEFAULT_DNS_BYTE2 MY_DEFAULT_GATE_BYTE2 |
||
| 310 | #define MY_DEFAULT_DNS_BYTE3 MY_DEFAULT_GATE_BYTE3 |
||
| 311 | #define MY_DEFAULT_DNS_BYTE4 MY_DEFAULT_GATE_BYTE4 |
||
| 312 | |||
| 313 | /* |
||
| 314 | * TCP configurations |
||
| 315 | * To minmize page update, match number of sockets and |
||
| 316 | * HTTP connections with different page sources in a |
||
| 317 | * page. |
||
| 318 | * For example, if page contains reference to 3 more pages, |
||
| 319 | * browser may try to open 4 simultaneous HTTP connections, |
||
| 320 | * and to minimize browser delay, set HTTP connections to |
||
| 321 | * 4, MAX_SOCKETS to 4. |
||
| 322 | * If you are using other applications, you should |
||
| 323 | * keep at least one socket available for them. |
||
| 324 | */ |
||
| 325 | |||
| 326 | // Maximum TCP sockets to be defined. |
||
| 327 | // Note that each TCP socket consumes 38 bytes of RAM. |
||
| 328 | #define MAX_SOCKETS (6u) |
||
| 329 | |||
| 330 | // Maximum avaialble UDP Sockets |
||
| 331 | #define MAX_UDP_SOCKETS (4u) |
||
| 332 | |||
| 333 | |||
| 334 | #if (MAX_SOCKETS <= 0 || MAX_SOCKETS > 255) |
||
| 335 | #error Invalid MAX_SOCKETS value specified. |
||
| 336 | #endif |
||
| 337 | |||
| 338 | #if (MAX_UDP_SOCKETS <= 0 || MAX_UDP_SOCKETS > 255 ) |
||
| 339 | #error Invlaid MAX_UDP_SOCKETS value specified |
||
| 340 | #endif |
||
| 341 | |||
| 342 | |||
| 343 | #if !defined(STACK_USE_SLIP) |
||
| 344 | // The MAC_TX_BUFFER_COUNT must be equal to MAX_SOCKETS + 1 |
||
| 345 | // (for high priority messages), or else calls to TCPPut may |
||
| 346 | // fail when multiple TCP sockets have data pending in the |
||
| 347 | // output buffer that hasn't been acked. Changing this value |
||
| 348 | // is recommended only if the rammifications of doing so are |
||
| 349 | // properly understood. |
||
| 350 | #if defined(NON_MCHP_MAC) |
||
| 351 | #define MAC_TX_BUFFER_SIZE (1024) |
||
| 352 | #define MAC_TX_BUFFER_COUNT (1) |
||
| 353 | #else |
||
| 354 | #define MAC_TX_BUFFER_SIZE (576) |
||
| 355 | #define MAC_TX_BUFFER_COUNT (MAX_SOCKETS+1) |
||
| 356 | #endif |
||
| 357 | #else |
||
| 358 | /* |
||
| 359 | * For SLIP, there can only be one transmit and one receive buffer. |
||
| 360 | * Both buffer must fit in one bank. If bigger buffer is required, |
||
| 361 | * you must manually locate tx and rx buffer in different bank |
||
| 362 | * or modify your linker script file to support arrays bigger than |
||
| 363 | * 256 bytes. |
||
| 364 | */ |
||
| 365 | #define MAC_TX_BUFFER_SIZE (250) |
||
| 366 | #define MAC_TX_BUFFER_COUNT (1) |
||
| 367 | #endif |
||
| 368 | // Rests are Receive Buffers |
||
| 369 | |||
| 370 | #define MAC_RX_BUFFER_SIZE (MAC_TX_BUFFER_SIZE) |
||
| 371 | |||
| 372 | #if (MAC_TX_BUFFER_SIZE <= 0 || MAC_TX_BUFFER_SIZE > 1500 ) |
||
| 373 | #error Invalid MAC_TX_BUFFER_SIZE value specified. |
||
| 374 | #endif |
||
| 375 | |||
| 376 | #if ( (MAC_TX_BUFFER_SIZE * MAC_TX_BUFFER_COUNT) > (5* 1024) ) |
||
| 377 | #error Warning, receive buffer is small. Excessive packet loss may occur. |
||
| 378 | #endif |
||
| 379 | |||
| 380 | /* |
||
| 381 | * Maximum numbers of simultaneous HTTP connections allowed. |
||
| 382 | * Each connection consumes 10 bytes. |
||
| 383 | */ |
||
| 384 | #define MAX_HTTP_CONNECTIONS (3u) |
||
| 385 | |||
| 386 | #if (MAX_HTTP_CONNECTIONS <= 0 || MAX_HTTP_CONNECTIONS > 255 ) |
||
| 387 | #error Invalid MAX_HTTP_CONNECTIONS value specified. |
||
| 388 | #endif |
||
| 389 | |||
| 390 | #define AVAILABLE_SOCKETS (MAX_SOCKETS) |
||
| 391 | #if defined(STACK_USE_HTTP_SERVER) |
||
| 392 | #define AVAILABLE_SOCKETS2 (AVAILABLE_SOCKETS - MAX_HTTP_CONNECTIONS) |
||
| 393 | #else |
||
| 394 | #define AVAILABLE_SOCKETS2 (MAX_SOCKETS) |
||
| 395 | #endif |
||
| 396 | |||
| 397 | /* |
||
| 398 | * When using FTP, you must have at least two sockets free |
||
| 399 | */ |
||
| 400 | #if defined(STACK_USE_FTP_SERVER) |
||
| 401 | #define AVAILABLE_SOCKETS3 (AVAILABLE_SOCKETS2 - 2) |
||
| 402 | #else |
||
| 403 | #define AVAILABLE_SOCKETS3 (AVAILABLE_SOCKETS2) |
||
| 404 | #endif |
||
| 405 | |||
| 406 | #if AVAILABLE_SOCKETS3 < 0 || AVAILABLE_SOCKETS3 > MAX_SOCKETS |
||
| 407 | #error MAX_SOCKETS is too low to accommodate MAX_HTTP_CONNECTIONS and/or STACK_USE_FTP_SERVER |
||
| 408 | #error Either increase MAX_SOCKETS in StackTsk.h or decrease module socket usage. |
||
| 409 | #endif |
||
| 410 | |||
| 411 | |||
| 412 | #define AVAILABLE_UDP_SOCKETS (MAX_UDP_SOCKETS) |
||
| 413 | #if defined(STACK_USE_DHCP) |
||
| 414 | #define AVAILABLE_UDP_SOCKETS2 (AVAILABLE_UDP_SOCKETS - 1) |
||
| 415 | #else |
||
| 416 | #define AVAILABLE_UDP_SOCKETS2 AVAILABLE_UDP_SOCKETS |
||
| 417 | #endif |
||
| 418 | |||
| 419 | #if defined(STACK_USE_SNMP_SERVER) |
||
| 420 | #define AVAILABLE_UDP_SOCKETS3 (AVAILABLE_UDP_SOCKETS2 - 1) |
||
| 421 | #else |
||
| 422 | #define AVAILABLE_UDP_SOCKETS3 AVAILABLE_UDP_SOCKETS2 |
||
| 423 | #endif |
||
| 424 | |||
| 425 | #if defined(STACK_USE_TFTP_CLIENT) |
||
| 426 | #define AVAILABLE_UDP_SOCKETS4 (AVAILABLE_UDP_SOCKETS2) |
||
| 427 | #else |
||
| 428 | #define AVAILABLE_UDP_SOCKETS4 AVAILABLE_UDP_SOCKETS3 |
||
| 429 | #endif |
||
| 430 | |||
| 431 | |||
| 432 | #if AVAILABLE_UDP_SOCKETS4 < 0 || AVAILABLE_UDP_SOCKETS4 > MAX_UDP_SOCKETS |
||
| 433 | #error MAX_UDP_SOCKETS is too low to accommodate DHCP, SNMP, and/or TFTP client |
||
| 434 | #error Either increase MAX_UDP_SOCKETS in StackTsk.h or decrease module UDP socket usage. |
||
| 435 | #endif |
||
| 436 | |||
| 437 | |||
| 438 | typedef BYTE BUFFER; |
||
| 439 | |||
| 440 | typedef struct _MAC_ADDR |
||
| 441 | { |
||
| 442 | BYTE v[6]; |
||
| 443 | } MAC_ADDR; |
||
| 444 | |||
| 445 | typedef union _IP_ADDR |
||
| 446 | { |
||
| 447 | BYTE v[4]; |
||
| 448 | DWORD Val; |
||
| 449 | } IP_ADDR; |
||
| 450 | |||
| 451 | |||
| 452 | typedef struct _NODE_INFO |
||
| 453 | { |
||
| 454 | MAC_ADDR MACAddr; |
||
| 455 | IP_ADDR IPAddr; |
||
| 456 | } NODE_INFO; |
||
| 457 | |||
| 458 | typedef struct _APP_CONFIG |
||
| 459 | { |
||
| 460 | IP_ADDR MyIPAddr; |
||
| 461 | MAC_ADDR MyMACAddr; |
||
| 462 | IP_ADDR MyMask; |
||
| 463 | IP_ADDR MyGateway; |
||
| 464 | IP_ADDR PrimaryDNSServer; |
||
| 465 | struct |
||
| 466 | { |
||
| 467 | unsigned char bIsDHCPEnabled : 1; |
||
| 468 | unsigned char bInConfigMode : 1; |
||
| 469 | } Flags; |
||
| 470 | WORD_VAL SerialNumber; |
||
| 471 | IP_ADDR SMTPServerAddr; // Not used. |
||
| 472 | IP_ADDR TFTPServerAddr; // Not used. |
||
| 473 | BYTE NetBIOSName[16]; |
||
| 474 | } APP_CONFIG; |
||
| 475 | |||
| 476 | |||
| 477 | #ifndef THIS_IS_STACK_APPLICATION |
||
| 478 | extern APP_CONFIG AppConfig; |
||
| 479 | #endif |
||
| 480 | |||
| 481 | #if defined(STACK_USE_IP_GLEANING) || defined(STACK_USE_DHCP) |
||
| 482 | #define StackIsInConfigMode() (AppConfig.Flags.bInConfigMode) |
||
| 483 | #else |
||
| 484 | #define StackIsInConfigMode() (FALSE) |
||
| 485 | #endif |
||
| 486 | |||
| 487 | |||
| 488 | /********************************************************************* |
||
| 489 | * Function: void StackInit(void) |
||
| 490 | * |
||
| 491 | * PreCondition: None |
||
| 492 | * |
||
| 493 | * Input: None |
||
| 494 | * |
||
| 495 | * Output: Stack and its componentns are initialized |
||
| 496 | * |
||
| 497 | * Side Effects: None |
||
| 498 | * |
||
| 499 | * Note: This function must be called before any of the |
||
| 500 | * stack or its component routines be used. |
||
| 501 | * |
||
| 502 | ********************************************************************/ |
||
| 503 | void StackInit(void); |
||
| 504 | |||
| 505 | |||
| 506 | /********************************************************************* |
||
| 507 | * Function: void StackTask(void) |
||
| 508 | * |
||
| 509 | * PreCondition: StackInit() is already called. |
||
| 510 | * |
||
| 511 | * Input: None |
||
| 512 | * |
||
| 513 | * Output: Stack FSM is executed. |
||
| 514 | * |
||
| 515 | * Side Effects: None |
||
| 516 | * |
||
| 517 | * Note: This FSM checks for new incoming packets, |
||
| 518 | * and routes it to appropriate stack components. |
||
| 519 | * It also performs timed operations. |
||
| 520 | * |
||
| 521 | * This function must be called periodically called |
||
| 522 | * to make sure that timely response. |
||
| 523 | * |
||
| 524 | ********************************************************************/ |
||
| 525 | void StackTask(void); |
||
| 526 | |||
| 527 | |||
| 528 | #endif |