Hi. This is the feed program for Cosm. (The previous name of the services is Pachube.)

Dependencies:   mbed ThermistorPack Pachube ConfigFile EthernetNetIf TextLCD HTTPClient_ToBeRemoved FatFileSystem SDFileSystem

Committer:
shintamainjp
Date:
Mon Aug 06 12:37:59 2012 +0000
Revision:
0:521ba375aa0f
Pachube renamed to Cosm.

Who changed what in which revision?

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