lwIP  2.1.0
Lightweight IP stack
autoip.c File Reference
#include "lwip/opt.h"
#include "lwip/mem.h"
#include "lwip/ip_addr.h"
#include "lwip/netif.h"
#include "lwip/autoip.h"
#include "lwip/etharp.h"
#include "lwip/prot/autoip.h"
#include <string.h>

Macros

#define LWIP_AUTOIP_RAND(netif)
 
#define LWIP_AUTOIP_CREATE_SEED_ADDR(netif)
 

Functions

void autoip_set_struct (struct netif *netif, struct autoip *autoip)
 
err_t autoip_start (struct netif *netif)
 
void autoip_network_changed (struct netif *netif)
 
err_t autoip_stop (struct netif *netif)
 
void autoip_tmr (void)
 
void autoip_arp_reply (struct netif *netif, struct etharp_hdr *hdr)
 
u8_t autoip_supplied_address (const struct netif *netif)
 

Detailed Description

AutoIP Automatic LinkLocal IP Configuration

This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform with RFC 3927.

Macro Definition Documentation

◆ LWIP_AUTOIP_CREATE_SEED_ADDR

#define LWIP_AUTOIP_CREATE_SEED_ADDR (   netif)
Value:
lwip_htonl(AUTOIP_RANGE_START + ((u32_t)(((u8_t)(netif->hwaddr[4])) | \
((u32_t)((u8_t)(netif->hwaddr[5]))) << 8)))
u8_t hwaddr[6U]
Definition: netif.h:341
u32_t lwip_htonl(u32_t n)
Definition: def.c:90
Definition: netif.h:260

Macro that generates the initial IP address to be tried by AUTOIP. If you want to override this, define it to something else in lwipopts.h.

◆ LWIP_AUTOIP_RAND

#define LWIP_AUTOIP_RAND (   netif)
Value:
( (((u32_t)((netif->hwaddr[5]) & 0xff) << 24) | \
((u32_t)((netif->hwaddr[3]) & 0xff) << 16) | \
((u32_t)((netif->hwaddr[2]) & 0xff) << 8) | \
((u32_t)((netif->hwaddr[4]) & 0xff))) + \
(netif_autoip_data(netif)? netif_autoip_data(netif)->tried_llipaddr : 0))
u8_t hwaddr[6U]
Definition: netif.h:341
Definition: netif.h:260

Pseudo random macro based on netif informations. You could use "rand()" from the C Library if you define LWIP_AUTOIP_RAND in lwipopts.h

Function Documentation

◆ autoip_arp_reply()

void autoip_arp_reply ( struct netif netif,
struct etharp_hdr hdr 
)

Handles every incoming ARP Packet, called by etharp_input().

Parameters
netifnetwork interface to use for autoip processing
hdrIncoming ARP packet

◆ autoip_network_changed()

void autoip_network_changed ( struct netif netif)

Handle a possible change in the network configuration.

If there is an AutoIP address configured, take the interface down and begin probing with the same address.

◆ autoip_supplied_address()

u8_t autoip_supplied_address ( const struct netif netif)

check if AutoIP supplied netif->ip_addr

Parameters
netifthe netif to check
Returns
1 if AutoIP supplied netif->ip_addr (state BOUND or ANNOUNCING), 0 otherwise

◆ autoip_tmr()

void autoip_tmr ( void  )

Has to be called in loop every AUTOIP_TMR_INTERVAL milliseconds