Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/include/lwip/autoip.h need to be fixed.

0001 /**
0002  * @file
0003  *
0004  * AutoIP Automatic LinkLocal IP Configuration
0005  */
0006 
0007 /*
0008  *
0009  * Copyright (c) 2007 Dominik Spies <kontakt@dspies.de>
0010  * All rights reserved.
0011  *
0012  * Redistribution and use in source and binary forms, with or without modification,
0013  * are permitted provided that the following conditions are met:
0014  *
0015  * 1. Redistributions of source code must retain the above copyright notice,
0016  *    this list of conditions and the following disclaimer.
0017  * 2. Redistributions in binary form must reproduce the above copyright notice,
0018  *    this list of conditions and the following disclaimer in the documentation
0019  *    and/or other materials provided with the distribution.
0020  * 3. The name of the author may not be used to endorse or promote products
0021  *    derived from this software without specific prior written permission.
0022  *
0023  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
0024  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
0025  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
0026  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
0027  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
0028  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0029  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0030  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
0031  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
0032  * OF SUCH DAMAGE.
0033  *
0034  * Author: Dominik Spies <kontakt@dspies.de>
0035  *
0036  * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform
0037  * with RFC 3927.
0038  *
0039  *
0040  * Please coordinate changes and requests with Dominik Spies
0041  * <kontakt@dspies.de>
0042  */
0043  
0044 #ifndef __LWIP_AUTOIP_H__
0045 #define __LWIP_AUTOIP_H__
0046 
0047 #include "lwip/opt.h"
0048 
0049 #if LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */
0050 
0051 #include "lwip/netif.h"
0052 #include "lwip/udp.h"
0053 #include "netif/etharp.h"
0054 
0055 #ifdef __cplusplus
0056 extern "C" {
0057 #endif
0058 
0059 /* AutoIP Timing */
0060 #define AUTOIP_TMR_INTERVAL      100
0061 #define AUTOIP_TICKS_PER_SECOND (1000 / AUTOIP_TMR_INTERVAL)
0062 
0063 /* RFC 3927 Constants */
0064 #define PROBE_WAIT               1   /* second   (initial random delay)                 */
0065 #define PROBE_MIN                1   /* second   (minimum delay till repeated probe)    */
0066 #define PROBE_MAX                2   /* seconds  (maximum delay till repeated probe)    */
0067 #define PROBE_NUM                3   /*          (number of probe packets)              */
0068 #define ANNOUNCE_NUM             2   /*          (number of announcement packets)       */
0069 #define ANNOUNCE_INTERVAL        2   /* seconds  (time between announcement packets)    */
0070 #define ANNOUNCE_WAIT            2   /* seconds  (delay before announcing)              */
0071 #define MAX_CONFLICTS            10  /*          (max conflicts before rate limiting)   */
0072 #define RATE_LIMIT_INTERVAL      60  /* seconds  (delay between successive attempts)    */
0073 #define DEFEND_INTERVAL          10  /* seconds  (min. wait between defensive ARPs)     */
0074 
0075 /* AutoIP client states */
0076 #define AUTOIP_STATE_OFF         0
0077 #define AUTOIP_STATE_PROBING     1
0078 #define AUTOIP_STATE_ANNOUNCING  2
0079 #define AUTOIP_STATE_BOUND       3
0080 
0081 struct autoip
0082 {
0083   struct ip_addr llipaddr;  /* the currently selected, probed, announced or used LL IP-Address */
0084   u8_t state;               /* current AutoIP state machine state */
0085   u8_t sent_num;            /* sent number of probes or announces, dependent on state */
0086   u16_t ttw;                /* ticks to wait, tick is AUTOIP_TMR_INTERVAL long */
0087   u8_t lastconflict;        /* ticks until a conflict can be solved by defending */
0088   u8_t tried_llipaddr;      /* total number of probed/used Link Local IP-Addresses */
0089 };
0090 
0091 
0092 /** Init srand, has to be called before entering mainloop */
0093 void autoip_init(void);
0094 
0095 /** Start AutoIP client */
0096 err_t autoip_start(struct netif *netif);
0097 
0098 /** Stop AutoIP client */
0099 err_t autoip_stop(struct netif *netif);
0100 
0101 /** Handles every incoming ARP Packet, called by etharp_arp_input */
0102 void autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr);
0103 
0104 /** Has to be called in loop every AUTOIP_TMR_INTERVAL milliseconds */
0105 void autoip_tmr(void);
0106 
0107 /** Handle a possible change in the network configuration */
0108 void autoip_network_changed(struct netif *netif);
0109 
0110 #ifdef __cplusplus
0111 }
0112 #endif
0113 
0114 #endif /* LWIP_AUTOIP */
0115 
0116 #endif /* __LWIP_AUTOIP_H__ */