59#if LWIP_IPV4 && LWIP_AUTOIP
76#ifndef LWIP_AUTOIP_CREATE_SEED_ADDR
77#define LWIP_AUTOIP_CREATE_SEED_ADDR(netif) \
78 lwip_htonl(AUTOIP_RANGE_START + ((u32_t)(((u8_t)(netif->hwaddr[4])) | \
79 ((u32_t)((u8_t)(netif->hwaddr[5]))) << 8)))
83static void autoip_restart(
struct netif *
netif);
84static void autoip_create_addr(
struct netif *
netif, ip4_addr_t *ipaddr);
86static void autoip_conflict_callback(
struct netif *
netif,
98autoip_set_struct(
struct netif *
netif,
struct autoip *autoip)
103 LWIP_ASSERT(
"netif already has a struct autoip set",
107 memset(autoip, 0,
sizeof(
struct autoip));
109 netif_set_client_data(
netif, LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP, autoip);
126 netif_set_client_data(
netif, LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP,
NULL);
136 struct autoip *autoip = netif_autoip_data(
netif);
137 autoip->tried_llipaddr++;
149autoip_create_addr(
struct netif *
netif, ip4_addr_t *ipaddr)
151 struct autoip *autoip = netif_autoip_data(
netif);
158 addr += autoip->tried_llipaddr;
174 (
u16_t)(autoip->tried_llipaddr), ip4_addr1_16(ipaddr), ip4_addr2_16(ipaddr),
175 ip4_addr3_16(ipaddr), ip4_addr4_16(ipaddr)));
187 struct autoip *autoip = netif_autoip_data(
netif);
188 ip4_addr_t sn_mask, gw_addr;
195 ip4_addr1_16(&autoip->llipaddr), ip4_addr2_16(&autoip->llipaddr),
196 ip4_addr3_16(&autoip->llipaddr), ip4_addr4_16(&autoip->llipaddr)));
198 IP4_ADDR(&sn_mask, 255, 255, 0, 0);
199 IP4_ADDR(&gw_addr, 0, 0, 0, 0);
201 netif_set_addr(
netif, &autoip->llipaddr, &sn_mask, &gw_addr);
216 struct autoip *autoip = netif_autoip_data(
netif);
223 autoip_restart(
netif);
228 ip4_addr_set_any(&autoip->llipaddr);
245 struct autoip *autoip = netif_autoip_data(
netif);
251 if (autoip ==
NULL) {
254 (
"autoip_start(): starting new AUTOIP client\n"));
255 autoip = (
struct autoip *)
mem_calloc(1,
sizeof(
struct autoip));
256 if (autoip ==
NULL) {
258 (
"autoip_start(): could not allocate autoip\n"));
262 netif_set_client_data(
netif, LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP, autoip);
272 acd_add(
netif, &autoip->acd, autoip_conflict_callback);
278 if (!ip4_addr_islinklocal(&autoip->llipaddr)) {
279 autoip_create_addr(
netif, &(autoip->llipaddr));
282 acd_start(
netif, &autoip->acd, autoip->llipaddr);
285 (
"autoip_start(): already started on netif=%p %c%c%"U16_F"\n",
301autoip_network_changed_link_up(
struct netif *
netif)
303 struct autoip *autoip = netif_autoip_data(
netif);
307 (
"autoip_network_changed_link_up(): start acd\n"));
310 acd_start(
netif, &autoip->acd, autoip->llipaddr);
322autoip_network_changed_link_down(
struct netif *
netif)
324 struct autoip *autoip = netif_autoip_data(
netif);
328 (
"autoip_network_changed_link_down(): stop autoip\n"));
342 struct autoip *autoip = netif_autoip_data(
netif);
345 if (autoip !=
NULL) {
347 if (ip4_addr_islinklocal(netif_ip4_addr(
netif))) {
348 netif_set_addr(
netif, IP4_ADDR_ANY4, IP4_ADDR_ANY4, IP4_ADDR_ANY4);
364 struct autoip *autoip = netif_autoip_data(
netif);
365 return (autoip !=
NULL)
366 && (ip4_addr_eq(netif_ip4_addr(
netif), &(autoip->llipaddr)))
373 struct autoip *autoip = netif_autoip_data(
netif);
374 return (autoip !=
NULL)
375 && (ip4_addr_eq(
addr, &(autoip->llipaddr)))
void * mem_calloc(mem_size_t count, mem_size_t size)
#define LWIP_DEBUGF(debug, message)
#define LWIP_ERROR(message, expression, handler)
#define LWIP_ASSERT(message, assertion)
GLenum const GLvoid * addr
#define LWIP_DHCP_AUTOIP_COOP
#define LWIP_ASSERT_CORE_LOCKED()
#define netif_is_up(netif)
#define AUTOIP_RANGE_START