1 /*
2  * Copyright (c) 2017 Matthias Boesl
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /** @file
8  * @brief IPv4 Autoconfiguration
9  *
10  * This is not to be included by the application.
11  */
12 
13 #ifndef __IPV4_AUTOCONF_INTERNAL_H
14 #define __IPV4_AUTOCONF_INTERNAL_H
15 
16 #include <zephyr.h>
17 
18 #include <net/ipv4_autoconf.h>
19 
20 /* Initial random delay*/
21 #define IPV4_AUTOCONF_PROBE_WAIT 1
22 
23 /* Number of probe packets */
24 #define IPV4_AUTOCONF_PROBE_NUM 3
25 
26 /* Minimum delay till repeated probe */
27 #define IPV4_AUTOCONF_PROBE_MIN 1
28 
29 /* Maximum delay till repeated probe */
30 #define IPV4_AUTOCONF_PROBE_MAX 2
31 
32 /* Number of announcement packets */
33 #define IPV4_AUTOCONF_ANNOUNCE_NUM 2
34 
35 /* Time between announcement packets */
36 #define IPV4_AUTOCONF_ANNOUNCE_INTERVAL 2
37 
38 /* Max conflicts before rate limiting */
39 #define IPV4_AUTOCONF_MAX_CONFLICTS 10
40 
41 /* Delay between successive attempts */
42 #define IPV4_AUTOCONF_RATE_LIMIT_INTERVAL 60
43 
44 /* Minimum interval between defensive ARPs */
45 #define IPV4_AUTOCONF_DEFEND_INTERVAL 10
46 
47 /* Time between carrier up and first probe */
48 #define IPV4_AUTOCONF_START_DELAY 3
49 
50 /**
51  * @brief Start IPv4 autocofiguration RFC 3927: IPv4 Link Local
52  *
53  * @details Start IPv4 IP autoconfiguration
54  *
55  * @param iface A valid pointer on an interface
56  */
57 #if defined(CONFIG_NET_IPV4_AUTO)
58 void net_ipv4_autoconf_start(struct net_if *iface);
59 #else
60 #define net_ipv4_autoconf_start(...)
61 #endif
62 
63 /**
64  * @brief Reset autoconf process
65  *
66  * @details Reset IPv4 IP autoconfiguration
67  *
68  * @param iface A valid pointer on an interface
69  */
70 #if defined(CONFIG_NET_IPV4_AUTO)
71 void net_ipv4_autoconf_reset(struct net_if *iface);
72 #else
73 #define net_ipv4_autoconf_reset(...)
74 #endif
75 
76 /**
77  * @brief Autoconf ARP input message handler.
78  *
79  * @details Called when ARP message is received when auto is enabled.
80  *
81  * @param iface A valid pointer on an interface
82  * @param pkt Received network packet
83  *
84  * @return What should be done with packet (drop or accept)
85  */
86 #if defined(CONFIG_NET_IPV4_AUTO)
87 enum net_verdict net_ipv4_autoconf_input(struct net_if *iface,
88 					 struct net_pkt *pkt);
89 #else
90 #define net_ipv4_autoconf_input(...) NET_CONTINUE
91 #endif
92 
93 #endif /* __IPV4_AUTOCONF_INTERNAL_H */
94