My fork of the HTTPServer (working)
Embed:
(wiki syntax)
Show/hide line numbers
autoip.h
Go to the documentation of this file.
00001 /** 00002 * @file 00003 * 00004 * AutoIP Automatic LinkLocal IP Configuration 00005 */ 00006 00007 /* 00008 * 00009 * Copyright (c) 2007 Dominik Spies <kontakt@dspies.de> 00010 * All rights reserved. 00011 * 00012 * Redistribution and use in source and binary forms, with or without modification, 00013 * are permitted provided that the following conditions are met: 00014 * 00015 * 1. Redistributions of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright notice, 00018 * this list of conditions and the following disclaimer in the documentation 00019 * and/or other materials provided with the distribution. 00020 * 3. The name of the author may not be used to endorse or promote products 00021 * derived from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00024 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00025 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00026 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00027 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00028 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00029 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00030 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00031 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00032 * OF SUCH DAMAGE. 00033 * 00034 * Author: Dominik Spies <kontakt@dspies.de> 00035 * 00036 * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform 00037 * with RFC 3927. 00038 * 00039 * 00040 * Please coordinate changes and requests with Dominik Spies 00041 * <kontakt@dspies.de> 00042 */ 00043 00044 #ifndef __LWIP_AUTOIP_H__ 00045 #define __LWIP_AUTOIP_H__ 00046 00047 #include "lwip/opt.h" 00048 00049 #if LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */ 00050 00051 #include "lwip/netif.h" 00052 #include "lwip/udp.h" 00053 #include "netif/etharp.h" 00054 00055 /* AutoIP Timing */ 00056 #define AUTOIP_TMR_INTERVAL 100 00057 #define AUTOIP_TICKS_PER_SECOND (1000 / AUTOIP_TMR_INTERVAL) 00058 00059 /* RFC 3927 Constants */ 00060 #define PROBE_WAIT 1 /* second (initial random delay) */ 00061 #define PROBE_MIN 1 /* second (minimum delay till repeated probe) */ 00062 #define PROBE_MAX 2 /* seconds (maximum delay till repeated probe) */ 00063 #define PROBE_NUM 3 /* (number of probe packets) */ 00064 #define ANNOUNCE_NUM 2 /* (number of announcement packets) */ 00065 #define ANNOUNCE_INTERVAL 2 /* seconds (time between announcement packets) */ 00066 #define ANNOUNCE_WAIT 2 /* seconds (delay before announcing) */ 00067 #define MAX_CONFLICTS 10 /* (max conflicts before rate limiting) */ 00068 #define RATE_LIMIT_INTERVAL 60 /* seconds (delay between successive attempts) */ 00069 #define DEFEND_INTERVAL 10 /* seconds (min. wait between defensive ARPs) */ 00070 00071 /* AutoIP client states */ 00072 #define AUTOIP_STATE_OFF 0 00073 #define AUTOIP_STATE_PROBING 1 00074 #define AUTOIP_STATE_ANNOUNCING 2 00075 #define AUTOIP_STATE_BOUND 3 00076 00077 struct autoip 00078 { 00079 struct ip_addr llipaddr; /* the currently selected, probed, announced or used LL IP-Address */ 00080 u8_t state; /* current AutoIP state machine state */ 00081 u8_t sent_num; /* sent number of probes or announces, dependent on state */ 00082 u16_t ttw; /* ticks to wait, tick is AUTOIP_TMR_INTERVAL long */ 00083 u8_t lastconflict; /* ticks until a conflict can be solved by defending */ 00084 u8_t tried_llipaddr; /* total number of probed/used Link Local IP-Addresses */ 00085 }; 00086 00087 00088 /** Init srand, has to be called before entering mainloop */ 00089 void autoip_init(void); 00090 00091 /** Start AutoIP client */ 00092 err_t autoip_start(struct netif *netif); 00093 00094 /** Stop AutoIP client */ 00095 err_t autoip_stop(struct netif *netif); 00096 00097 /** Handles every incoming ARP Packet, called by etharp_arp_input */ 00098 void autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr); 00099 00100 /** Has to be called in loop every AUTOIP_TMR_INTERVAL milliseconds */ 00101 void autoip_tmr(void); 00102 00103 #endif /* LWIP_AUTOIP */ 00104 00105 #endif /* __LWIP_AUTOIP_H__ */
Generated on Tue Jul 12 2022 19:24:05 by 1.7.2