1 /**
2  * @file
3  * ACD protocol definitions
4  */
5 
6 /*
7  *
8  * Copyright (c) 2007 Dominik Spies <kontakt@dspies.de>
9  * Copyright (c) 2018 Jasper Verschueren <jasper.verschueren@apart-audio.com>
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without modification,
13  * are permitted provided that the following conditions are met:
14  *
15  * 1. Redistributions of source code must retain the above copyright notice,
16  *    this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright notice,
18  *    this list of conditions and the following disclaimer in the documentation
19  *    and/or other materials provided with the distribution.
20  * 3. The name of the author may not be used to endorse or promote products
21  *    derived from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
24  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
26  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
28  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
31  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
32  * OF SUCH DAMAGE.
33  *
34  * Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
35  * Author: Dominik Spies <kontakt@dspies.de>
36  */
37 
38 #ifndef LWIP_HDR_PROT_ACD_H
39 #define LWIP_HDR_PROT_ACD_H
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 /* RFC 5227 and RFC 3927 Constants */
46 #define PROBE_WAIT           1   /* second  (initial random delay)                    */
47 #define PROBE_MIN            1   /* second  (minimum delay till repeated probe)       */
48 #define PROBE_MAX            2   /* seconds (maximum delay till repeated probe)       */
49 #define PROBE_NUM            3   /*         (number of probe packets)                 */
50 #define ANNOUNCE_NUM         2   /*         (number of announcement packets)          */
51 #define ANNOUNCE_INTERVAL    2   /* seconds (time between announcement packets)       */
52 #define ANNOUNCE_WAIT        2   /* seconds (delay before announcing)                 */
53 #define MAX_CONFLICTS        10  /*         (max conflicts before rate limiting)      */
54 #define RATE_LIMIT_INTERVAL  60  /* seconds (delay between successive attempts)       */
55 #define DEFEND_INTERVAL      10  /* seconds (minimum interval between defensive ARPs) */
56 
57 /* ACD states */
58 typedef enum {
59   /* ACD is module is off */
60   ACD_STATE_OFF,
61   /* Waiting before probing can be started */
62   ACD_STATE_PROBE_WAIT,
63   /* Probing the ipaddr */
64   ACD_STATE_PROBING,
65   /* Waiting before announcing the probed ipaddr */
66   ACD_STATE_ANNOUNCE_WAIT,
67   /* Announcing the new ipaddr */
68   ACD_STATE_ANNOUNCING,
69   /* Performing ongoing conflict detection with one defend within defend inferval */
70   ACD_STATE_ONGOING,
71   /* Performing ongoing conflict detection but immediately back off and Release
72    * the address when a conflict occurs. This state is used for LL addresses
73    * that stay active even if the netif has a routable address selected.
74    * In such a case, we cannot defend our address */
75   ACD_STATE_PASSIVE_ONGOING,
76   /* To many conflicts occurred, we need to wait before restarting the selection
77    * process */
78   ACD_STATE_RATE_LIMIT
79 } acd_state_enum_t;
80 
81 typedef enum {
82   ACD_IP_OK,            /* IP address is good, no conflicts found in checking state */
83   ACD_RESTART_CLIENT,   /* Conflict found -> the client should try again */
84   ACD_DECLINE           /* Decline the received IP address (rate limiting)*/
85 } acd_callback_enum_t;
86 
87 #ifdef __cplusplus
88 }
89 #endif
90 
91 #endif /* LWIP_HDR_PROT_ACD_H */
92