mikroSDK Reference Manual
auto_ip.h
Go to the documentation of this file.
1
31#ifndef _AUTO_IP_H
32#define _AUTO_IP_H
33
34//Dependencies
35#include "core/net.h"
36
37//Auto-IP support
38#ifndef AUTO_IP_SUPPORT
39 #define AUTO_IP_SUPPORT DISABLED
40#elif (AUTO_IP_SUPPORT != ENABLED && AUTO_IP_SUPPORT != DISABLED)
41 #error AUTO_IP_SUPPORT parameter is not valid
42#endif
43
44//Bonjour Conformance Test support
45#ifndef AUTO_IP_BCT_SUPPORT
46 #define AUTO_IP_BCT_SUPPORT DISABLED
47#elif (AUTO_IP_BCT_SUPPORT != ENABLED && AUTO_IP_BCT_SUPPORT != DISABLED)
48 #error AUTO_IP_BCT_SUPPORT parameter is not valid
49#endif
50
51//Auto-IP tick interval
52#ifndef AUTO_IP_TICK_INTERVAL
53 #define AUTO_IP_TICK_INTERVAL 200
54#elif (AUTO_IP_TICK_INTERVAL < 10)
55 #error AUTO_IP_TICK_INTERVAL parameter is not valid
56#endif
57
58//Initial random delay
59#ifndef AUTO_IP_PROBE_WAIT
60 #define AUTO_IP_PROBE_WAIT 1000
61#elif (AUTO_IP_PROBE_WAIT < 0)
62 #error AUTO_IP_PROBE_WAIT parameter is not valid
63#endif
64
65//Number of probe packets
66#ifndef AUTO_IP_PROBE_NUM
67 #define AUTO_IP_PROBE_NUM 3
68#elif (AUTO_IP_PROBE_NUM < 1)
69 #error AUTO_IP_PROBE_NUM parameter is not valid
70#endif
71
72//Minimum delay till repeated probe
73#ifndef AUTO_IP_PROBE_MIN
74 #define AUTO_IP_PROBE_MIN 1000
75#elif (AUTO_IP_PROBE_MIN < 100)
76 #error AUTO_IP_PROBE_MIN parameter is not valid
77#endif
78
79//Maximum delay till repeated probe
80#ifndef AUTO_IP_PROBE_MAX
81 #define AUTO_IP_PROBE_MAX 2000
82#elif (AUTO_IP_PROBE_MAX < AUTO_IP_PROBE_MIN)
83 #error AUTO_IP_PROBE_MAX parameter is not valid
84#endif
85
86//Delay before announcing
87#ifndef AUTO_IP_ANNOUNCE_WAIT
88 #define AUTO_IP_ANNOUNCE_WAIT 2000
89#elif (AUTO_IP_ANNOUNCE_WAIT < 100)
90 #error AUTO_IP_ANNOUNCE_WAIT parameter is not valid
91#endif
92
93//Number of announcement packets
94#ifndef AUTO_IP_ANNOUNCE_NUM
95 #define AUTO_IP_ANNOUNCE_NUM 2
96#elif (AUTO_IP_ANNOUNCE_NUM < 1)
97 #error AUTO_IP_ANNOUNCE_NUM parameter is not valid
98#endif
99
100//Time between announcement packets
101#ifndef AUTO_IP_ANNOUNCE_INTERVAL
102 #define AUTO_IP_ANNOUNCE_INTERVAL 2000
103#elif (AUTO_IP_ANNOUNCE_INTERVAL < 100)
104 #error AUTO_IP_ANNOUNCE_INTERVAL parameter is not valid
105#endif
106
107//Max conflicts before rate limiting
108#ifndef AUTO_IP_MAX_CONFLICTS
109 #define AUTO_IP_MAX_CONFLICTS 10
110#elif (AUTO_IP_MAX_CONFLICTS < 1)
111 #error AUTO_IP_MAX_CONFLICTS parameter is not valid
112#endif
113
114//Delay between successive attempts
115#ifndef AUTO_IP_RATE_LIMIT_INTERVAL
116 #define AUTO_IP_RATE_LIMIT_INTERVAL 60000
117#elif (AUTO_IP_RATE_LIMIT_INTERVAL < 1000)
118 #error AUTO_IP_RATE_LIMIT_INTERVAL parameter is not valid
119#endif
120
121//Minimum interval between defensive
122#ifndef AUTO_IP_DEFEND_INTERVAL
123 #define AUTO_IP_DEFEND_INTERVAL 10000
124#elif (AUTO_IP_DEFEND_INTERVAL < 1000)
125 #error AUTO_IP_DEFEND_INTERVAL parameter is not valid
126#endif
127
128//Auto-IP address prefix
129#define AUTO_IP_PREFIX IPV4_ADDR(169, 254, 0, 0)
130//Auto-IP subnet mask
131#define AUTO_IP_MASK IPV4_ADDR(255, 255, 0, 0)
132
133//Auto-IP address range
134#define AUTO_IP_ADDR_MIN IPV4_ADDR(169, 254, 1, 0)
135#define AUTO_IP_ADDR_MAX IPV4_ADDR(169, 254, 254, 255)
136
137//Forward declaration of AutoIpContext structure
138struct _AutoIpContext;
139#define AutoIpContext struct _AutoIpContext
140
141//C++ guard
142#ifdef __cplusplus
143extern "C" {
144#endif
145
146
151typedef enum
152{
153 AUTO_IP_STATE_INIT = 0,
154 AUTO_IP_STATE_PROBING = 1,
155 AUTO_IP_STATE_ANNOUNCING = 2,
156 AUTO_IP_STATE_CONFIGURED = 3,
157 AUTO_IP_STATE_DEFENDING = 4
159
160
165typedef void (*AutoIpLinkChangeCallback)(AutoIpContext *context,
166 NetInterface *interface, bool_t linkState);
167
168
173typedef void (*AutoIpStateChangeCallback)(AutoIpContext *context,
174 NetInterface *interface, AutoIpState state);
175
176
189
190
206
207
208//Auto-IP related functions
209void autoIpGetDefaultSettings(AutoIpSettings *settings);
210error_t autoIpInit(AutoIpContext *context, const AutoIpSettings *settings);
211
212error_t autoIpStart(AutoIpContext *context);
213error_t autoIpStop(AutoIpContext *context);
214
215AutoIpState autoIpGetState(AutoIpContext *context);
216
217//C++ guard
218#ifdef __cplusplus
219}
220#endif
221
222#endif
void(* AutoIpStateChangeCallback)(AutoIpContext *context, NetInterface *interface, AutoIpState state)
FSM state change callback.
Definition auto_ip.h:173
AutoIpState
Auto-IP FSM states.
Definition auto_ip.h:152
void(* AutoIpLinkChangeCallback)(AutoIpContext *context, NetInterface *interface, bool_t linkState)
Link state change callback.
Definition auto_ip.h:165
error_t
Error codes.
Definition error.h:43
uint32_t Ipv4Addr
IPv4 network address.
Definition ipv4.h:267
TCP/IP stack core.
uint32_t systime_t
System time.
Definition os_port_none.h:90
Auto-IP settings.
Definition auto_ip.h:182
Ipv4Addr linkLocalAddr
Initial link-local address to be used.
Definition auto_ip.h:185
AutoIpLinkChangeCallback linkChangeEvent
Link state change event.
Definition auto_ip.h:186
uint_t ipAddrIndex
Index of the IP address to be configured.
Definition auto_ip.h:184
NetInterface * interface
Network interface to configure.
Definition auto_ip.h:183
AutoIpStateChangeCallback stateChangeEvent
FSM state change event.
Definition auto_ip.h:187
Auto-IP context.
Definition auto_ip.h:196
bool_t running
Auto-IP is currently running.
Definition auto_ip.h:198
AutoIpSettings settings
Auto-IP settings.
Definition auto_ip.h:197
Ipv4Addr linkLocalAddr
Link-local address.
Definition auto_ip.h:200
AutoIpState state
Current state of the FSM.
Definition auto_ip.h:199
uint_t retransmitCount
Retransmission counter.
Definition auto_ip.h:203
systime_t timeout
Timeout value.
Definition auto_ip.h:202
uint_t conflictCount
Number of conflicts.
Definition auto_ip.h:204
systime_t timestamp
Timestamp to manage retransmissions.
Definition auto_ip.h:201