Modified version of NetServices. Fixes an issue where connections failed should the HTTP response status line be received in a packet on its own prior to any further headers. Changes are made to the HTTPClient.cpp file's readHeaders method.

Committer:
andrewbonney
Date:
Fri Apr 08 14:39:41 2011 +0000
Revision:
0:ec559500a63f

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewbonney 0:ec559500a63f 1 /**
andrewbonney 0:ec559500a63f 2 * @file
andrewbonney 0:ec559500a63f 3 *
andrewbonney 0:ec559500a63f 4 * AutoIP Automatic LinkLocal IP Configuration
andrewbonney 0:ec559500a63f 5 */
andrewbonney 0:ec559500a63f 6
andrewbonney 0:ec559500a63f 7 /*
andrewbonney 0:ec559500a63f 8 *
andrewbonney 0:ec559500a63f 9 * Copyright (c) 2007 Dominik Spies <kontakt@dspies.de>
andrewbonney 0:ec559500a63f 10 * All rights reserved.
andrewbonney 0:ec559500a63f 11 *
andrewbonney 0:ec559500a63f 12 * Redistribution and use in source and binary forms, with or without modification,
andrewbonney 0:ec559500a63f 13 * are permitted provided that the following conditions are met:
andrewbonney 0:ec559500a63f 14 *
andrewbonney 0:ec559500a63f 15 * 1. Redistributions of source code must retain the above copyright notice,
andrewbonney 0:ec559500a63f 16 * this list of conditions and the following disclaimer.
andrewbonney 0:ec559500a63f 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
andrewbonney 0:ec559500a63f 18 * this list of conditions and the following disclaimer in the documentation
andrewbonney 0:ec559500a63f 19 * and/or other materials provided with the distribution.
andrewbonney 0:ec559500a63f 20 * 3. The name of the author may not be used to endorse or promote products
andrewbonney 0:ec559500a63f 21 * derived from this software without specific prior written permission.
andrewbonney 0:ec559500a63f 22 *
andrewbonney 0:ec559500a63f 23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
andrewbonney 0:ec559500a63f 24 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
andrewbonney 0:ec559500a63f 25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
andrewbonney 0:ec559500a63f 26 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
andrewbonney 0:ec559500a63f 27 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
andrewbonney 0:ec559500a63f 28 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
andrewbonney 0:ec559500a63f 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
andrewbonney 0:ec559500a63f 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
andrewbonney 0:ec559500a63f 31 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
andrewbonney 0:ec559500a63f 32 * OF SUCH DAMAGE.
andrewbonney 0:ec559500a63f 33 *
andrewbonney 0:ec559500a63f 34 * Author: Dominik Spies <kontakt@dspies.de>
andrewbonney 0:ec559500a63f 35 *
andrewbonney 0:ec559500a63f 36 * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform
andrewbonney 0:ec559500a63f 37 * with RFC 3927.
andrewbonney 0:ec559500a63f 38 *
andrewbonney 0:ec559500a63f 39 *
andrewbonney 0:ec559500a63f 40 * Please coordinate changes and requests with Dominik Spies
andrewbonney 0:ec559500a63f 41 * <kontakt@dspies.de>
andrewbonney 0:ec559500a63f 42 */
andrewbonney 0:ec559500a63f 43
andrewbonney 0:ec559500a63f 44 #ifndef __LWIP_AUTOIP_H__
andrewbonney 0:ec559500a63f 45 #define __LWIP_AUTOIP_H__
andrewbonney 0:ec559500a63f 46
andrewbonney 0:ec559500a63f 47 #include "lwip/opt.h"
andrewbonney 0:ec559500a63f 48
andrewbonney 0:ec559500a63f 49 #if LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */
andrewbonney 0:ec559500a63f 50
andrewbonney 0:ec559500a63f 51 #include "lwip/netif.h"
andrewbonney 0:ec559500a63f 52 #include "lwip/udp.h"
andrewbonney 0:ec559500a63f 53 #include "netif/etharp.h"
andrewbonney 0:ec559500a63f 54
andrewbonney 0:ec559500a63f 55 #ifdef __cplusplus
andrewbonney 0:ec559500a63f 56 extern "C" {
andrewbonney 0:ec559500a63f 57 #endif
andrewbonney 0:ec559500a63f 58
andrewbonney 0:ec559500a63f 59 /* AutoIP Timing */
andrewbonney 0:ec559500a63f 60 #define AUTOIP_TMR_INTERVAL 100
andrewbonney 0:ec559500a63f 61 #define AUTOIP_TICKS_PER_SECOND (1000 / AUTOIP_TMR_INTERVAL)
andrewbonney 0:ec559500a63f 62
andrewbonney 0:ec559500a63f 63 /* RFC 3927 Constants */
andrewbonney 0:ec559500a63f 64 #define PROBE_WAIT 1 /* second (initial random delay) */
andrewbonney 0:ec559500a63f 65 #define PROBE_MIN 1 /* second (minimum delay till repeated probe) */
andrewbonney 0:ec559500a63f 66 #define PROBE_MAX 2 /* seconds (maximum delay till repeated probe) */
andrewbonney 0:ec559500a63f 67 #define PROBE_NUM 3 /* (number of probe packets) */
andrewbonney 0:ec559500a63f 68 #define ANNOUNCE_NUM 2 /* (number of announcement packets) */
andrewbonney 0:ec559500a63f 69 #define ANNOUNCE_INTERVAL 2 /* seconds (time between announcement packets) */
andrewbonney 0:ec559500a63f 70 #define ANNOUNCE_WAIT 2 /* seconds (delay before announcing) */
andrewbonney 0:ec559500a63f 71 #define MAX_CONFLICTS 10 /* (max conflicts before rate limiting) */
andrewbonney 0:ec559500a63f 72 #define RATE_LIMIT_INTERVAL 60 /* seconds (delay between successive attempts) */
andrewbonney 0:ec559500a63f 73 #define DEFEND_INTERVAL 10 /* seconds (min. wait between defensive ARPs) */
andrewbonney 0:ec559500a63f 74
andrewbonney 0:ec559500a63f 75 /* AutoIP client states */
andrewbonney 0:ec559500a63f 76 #define AUTOIP_STATE_OFF 0
andrewbonney 0:ec559500a63f 77 #define AUTOIP_STATE_PROBING 1
andrewbonney 0:ec559500a63f 78 #define AUTOIP_STATE_ANNOUNCING 2
andrewbonney 0:ec559500a63f 79 #define AUTOIP_STATE_BOUND 3
andrewbonney 0:ec559500a63f 80
andrewbonney 0:ec559500a63f 81 struct autoip
andrewbonney 0:ec559500a63f 82 {
andrewbonney 0:ec559500a63f 83 ip_addr_t llipaddr; /* the currently selected, probed, announced or used LL IP-Address */
andrewbonney 0:ec559500a63f 84 u8_t state; /* current AutoIP state machine state */
andrewbonney 0:ec559500a63f 85 u8_t sent_num; /* sent number of probes or announces, dependent on state */
andrewbonney 0:ec559500a63f 86 u16_t ttw; /* ticks to wait, tick is AUTOIP_TMR_INTERVAL long */
andrewbonney 0:ec559500a63f 87 u8_t lastconflict; /* ticks until a conflict can be solved by defending */
andrewbonney 0:ec559500a63f 88 u8_t tried_llipaddr; /* total number of probed/used Link Local IP-Addresses */
andrewbonney 0:ec559500a63f 89 };
andrewbonney 0:ec559500a63f 90
andrewbonney 0:ec559500a63f 91
andrewbonney 0:ec559500a63f 92 /** Init srand, has to be called before entering mainloop */
andrewbonney 0:ec559500a63f 93 void autoip_init(void);
andrewbonney 0:ec559500a63f 94
andrewbonney 0:ec559500a63f 95 /** Set a struct autoip allocated by the application to work with */
andrewbonney 0:ec559500a63f 96 void autoip_set_struct(struct netif *netif, struct autoip *autoip);
andrewbonney 0:ec559500a63f 97
andrewbonney 0:ec559500a63f 98 /** Start AutoIP client */
andrewbonney 0:ec559500a63f 99 err_t autoip_start(struct netif *netif);
andrewbonney 0:ec559500a63f 100
andrewbonney 0:ec559500a63f 101 /** Stop AutoIP client */
andrewbonney 0:ec559500a63f 102 err_t autoip_stop(struct netif *netif);
andrewbonney 0:ec559500a63f 103
andrewbonney 0:ec559500a63f 104 /** Handles every incoming ARP Packet, called by etharp_arp_input */
andrewbonney 0:ec559500a63f 105 void autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr);
andrewbonney 0:ec559500a63f 106
andrewbonney 0:ec559500a63f 107 /** Has to be called in loop every AUTOIP_TMR_INTERVAL milliseconds */
andrewbonney 0:ec559500a63f 108 void autoip_tmr(void);
andrewbonney 0:ec559500a63f 109
andrewbonney 0:ec559500a63f 110 /** Handle a possible change in the network configuration */
andrewbonney 0:ec559500a63f 111 void autoip_network_changed(struct netif *netif);
andrewbonney 0:ec559500a63f 112
andrewbonney 0:ec559500a63f 113 #ifdef __cplusplus
andrewbonney 0:ec559500a63f 114 }
andrewbonney 0:ec559500a63f 115 #endif
andrewbonney 0:ec559500a63f 116
andrewbonney 0:ec559500a63f 117 #endif /* LWIP_AUTOIP */
andrewbonney 0:ec559500a63f 118
andrewbonney 0:ec559500a63f 119 #endif /* __LWIP_AUTOIP_H__ */