TwitterExample with newer library (2012Aug)

Dependencies:   EthernetNetIf HTTPClient mbed

Committer:
nxpfan
Date:
Wed Aug 29 03:50:19 2012 +0000
Revision:
0:075157567b0c
simple twitter example with newer library

Who changed what in which revision?

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