Skip to content

Commit

Permalink
net: ipv4: autoconf: Integrate with the ACD module
Browse files Browse the repository at this point in the history
The autoconf module can now reuse generic address conflict detection,
which was added for all address types.

Signed-off-by: Robert Lubos <[email protected]>
  • Loading branch information
rlubos authored and carlescufi committed Jun 10, 2024
1 parent 80339ac commit cc53826
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 421 deletions.
38 changes: 35 additions & 3 deletions include/zephyr/net/ipv4_autoconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,44 @@
/** Current state of IPv4 Autoconfiguration */
enum net_ipv4_autoconf_state {
NET_IPV4_AUTOCONF_INIT, /**< Initialization state */
NET_IPV4_AUTOCONF_PROBE, /**< Probing state */
NET_IPV4_AUTOCONF_ANNOUNCE, /**< Announce state */
NET_IPV4_AUTOCONF_ASSIGNED, /**< Assigned state */
NET_IPV4_AUTOCONF_RENEW, /**< Renew state */
};

struct net_if;

/**
* @brief Start IPv4 autoconfiguration RFC 3927: IPv4 Link Local
*
* @details Start IPv4 IP autoconfiguration
*
* @param iface A valid pointer on an interface
*/
#if defined(CONFIG_NET_IPV4_AUTO)
void net_ipv4_autoconf_start(struct net_if *iface);
#else
static inline void net_ipv4_autoconf_start(struct net_if *iface)
{
ARG_UNUSED(iface);
}
#endif

/**
* @brief Reset autoconf process
*
* @details Reset IPv4 IP autoconfiguration
*
* @param iface A valid pointer on an interface
*/
#if defined(CONFIG_NET_IPV4_AUTO)
void net_ipv4_autoconf_reset(struct net_if *iface);
#else
static inline void net_ipv4_autoconf_reset(struct net_if *iface)
{
ARG_UNUSED(iface);
}
#endif

/** @cond INTERNAL_HIDDEN */

/**
Expand All @@ -28,7 +60,7 @@ enum net_ipv4_autoconf_state {
#if defined(CONFIG_NET_IPV4_AUTO)
void net_ipv4_autoconf_init(void);
#else
#define net_ipv4_autoconf_init(...)
static inline void net_ipv4_autoconf_init(void) { }
#endif

/** @endcond */
Expand Down
21 changes: 0 additions & 21 deletions include/zephyr/net/net_if.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,36 +519,15 @@ struct net_if_dhcpv4 {

#if defined(CONFIG_NET_IPV4_AUTO) && defined(CONFIG_NET_NATIVE_IPV4)
struct net_if_ipv4_autoconf {
/** Used for timer lists */
sys_snode_t node;

/** Backpointer to correct network interface */
struct net_if *iface;

/** Timer start */
int64_t timer_start;

/** Time for INIT, DISCOVER, REQUESTING, RENEWAL */
uint32_t timer_timeout;

/** Current IP addr */
struct in_addr current_ip;

/** Requested IP addr */
struct in_addr requested_ip;

/** IPV4 Autoconf state in the process of network address allocation.
*/
enum net_ipv4_autoconf_state state;

/** Number of sent probe requests */
uint8_t probe_cnt;

/** Number of sent announcements */
uint8_t announce_cnt;

/** Incoming conflict count */
uint8_t conflict_cnt;
};
#endif /* CONFIG_NET_IPV4_AUTO */

Expand Down
3 changes: 3 additions & 0 deletions subsys/net/ip/Kconfig.ipv4
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ config NET_IPV4_AUTO
depends on NET_ARP
select EXPERIMENTAL
select NET_IPV4_ACD
select NET_MGMT
select NET_MGMT_EVENT
select NET_MGMT_EVENT_INFO
help
Enables IPv4 auto IP address configuration (see RFC 3927)

Expand Down
Loading

0 comments on commit cc53826

Please sign in to comment.