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