net: if: Reshuffle fields in net_if and related structs
This does not save any space but sets the fields in the structs in more natural order. Move IPv6 related fields in net_if into internal ipv6 struct so that all IPv6 fields are located inside one struct. Same thing is done for IPv4 fields which are now located inside IPv4 internal struct in net_if. There is no functionality changes by this commit. Change-Id: I7d72ec0a28e2b88c79a4c294655d5ef6da6ccb25 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
8b8371f573
commit
f8c9439908
4 changed files with 72 additions and 72 deletions
|
@ -94,8 +94,8 @@ struct net_if_mcast_addr {
|
|||
* Stores the multicast IP addresses assigned to this network interface.
|
||||
*/
|
||||
struct net_if_ipv6_prefix {
|
||||
/** Is this prefix used or not */
|
||||
bool is_used;
|
||||
/** Prefix lifetime */
|
||||
struct k_delayed_work lifetime;
|
||||
|
||||
/** IPv6 prefix */
|
||||
struct in6_addr prefix;
|
||||
|
@ -106,8 +106,8 @@ struct net_if_ipv6_prefix {
|
|||
/** Is the IP prefix valid forever */
|
||||
bool is_infinite;
|
||||
|
||||
/** Prefix lifetime */
|
||||
struct k_delayed_work lifetime;
|
||||
/** Is this prefix used or not */
|
||||
bool is_used;
|
||||
};
|
||||
#endif /* CONFIG_NET_IPV6 */
|
||||
|
||||
|
@ -117,12 +117,15 @@ struct net_if_ipv6_prefix {
|
|||
* Stores the router information.
|
||||
*/
|
||||
struct net_if_router {
|
||||
/** Network interface the router is connected to */
|
||||
struct net_if *iface;
|
||||
/** Router lifetime */
|
||||
struct k_delayed_work lifetime;
|
||||
|
||||
/** IP address */
|
||||
struct net_addr address;
|
||||
|
||||
/** Network interface the router is connected to */
|
||||
struct net_if *iface;
|
||||
|
||||
/** Is this router used or not */
|
||||
bool is_used;
|
||||
|
||||
|
@ -131,9 +134,6 @@ struct net_if_router {
|
|||
|
||||
/** Is the router valid forever */
|
||||
bool is_infinite;
|
||||
|
||||
/** Router lifetime */
|
||||
struct k_delayed_work lifetime;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -185,18 +185,21 @@ struct net_if {
|
|||
/** The actually device driver instance the net_if is related to */
|
||||
struct device *dev;
|
||||
|
||||
/* For internal use */
|
||||
ATOMIC_DEFINE(flags, NET_IF_NUM_FLAGS);
|
||||
|
||||
/** Interface's L2 layer */
|
||||
const struct net_l2 * const l2;
|
||||
|
||||
/** Interface's private L2 data pointer */
|
||||
void *l2_data;
|
||||
|
||||
/* For internal use */
|
||||
ATOMIC_DEFINE(flags, NET_IF_NUM_FLAGS);
|
||||
|
||||
/** The hardware link address */
|
||||
struct net_linkaddr link_addr;
|
||||
|
||||
/** Queue for outgoing packets from apps */
|
||||
struct k_fifo tx_queue;
|
||||
|
||||
/** The hardware MTU */
|
||||
uint16_t mtu;
|
||||
|
||||
|
@ -209,9 +212,6 @@ struct net_if {
|
|||
struct net_offload *offload;
|
||||
#endif /* CONFIG_NET_OFFLOAD */
|
||||
|
||||
/** Queue for outgoing packets from apps */
|
||||
struct k_fifo tx_queue;
|
||||
|
||||
#if defined(CONFIG_NET_IPV6)
|
||||
#define NET_IF_MAX_IPV6_ADDR CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT
|
||||
#define NET_IF_MAX_IPV6_MADDR CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT
|
||||
|
@ -225,30 +225,30 @@ struct net_if {
|
|||
|
||||
/** Prefixes */
|
||||
struct net_if_ipv6_prefix prefix[NET_IF_MAX_IPV6_PREFIX];
|
||||
} ipv6;
|
||||
|
||||
/** IPv6 hop limit */
|
||||
uint8_t hop_limit;
|
||||
/** Router solicitation timer */
|
||||
struct k_delayed_work rs_timer;
|
||||
|
||||
/** Default reachable time (RFC 4861, page 52) */
|
||||
uint32_t base_reachable_time;
|
||||
|
||||
/** Reachable time (RFC 4861, page 20) */
|
||||
uint32_t reachable_time;
|
||||
|
||||
/** Retransmit timer (RFC 4861, page 52) */
|
||||
uint32_t retrans_timer;
|
||||
|
||||
/** IPv6 hop limit */
|
||||
uint8_t hop_limit;
|
||||
|
||||
#if defined(CONFIG_NET_IPV6_DAD)
|
||||
/** IPv6 current duplicate address detection count */
|
||||
uint8_t dad_count;
|
||||
/** IPv6 current duplicate address detection count */
|
||||
uint8_t dad_count;
|
||||
#endif /* CONFIG_NET_IPV6_DAD */
|
||||
|
||||
/** Router solicitation timer */
|
||||
struct k_delayed_work rs_timer;
|
||||
|
||||
/** RS count */
|
||||
uint8_t rs_count;
|
||||
|
||||
/** Default reachable time (RFC 4861, page 52) */
|
||||
uint32_t base_reachable_time;
|
||||
|
||||
/** Reachable time (RFC 4861, page 20) */
|
||||
uint32_t reachable_time;
|
||||
|
||||
/** Retransmit timer (RFC 4861, page 52) */
|
||||
uint32_t retrans_timer;
|
||||
/** RS count */
|
||||
uint8_t rs_count;
|
||||
} ipv6;
|
||||
#endif /* CONFIG_NET_IPV6 */
|
||||
|
||||
#if defined(CONFIG_NET_IPV4)
|
||||
|
@ -266,10 +266,10 @@ struct net_if {
|
|||
|
||||
/** Netmask */
|
||||
struct in_addr netmask;
|
||||
} ipv4;
|
||||
|
||||
/** IPv4 time-to-live */
|
||||
uint8_t ttl;
|
||||
/** IPv4 time-to-live */
|
||||
uint8_t ttl;
|
||||
} ipv4;
|
||||
#endif /* CONFIG_NET_IPV4 */
|
||||
|
||||
#if defined(CONFIG_NET_DHCPV4)
|
||||
|
@ -291,15 +291,6 @@ struct net_if {
|
|||
/** Requested IP addr */
|
||||
struct in_addr requested_ip;
|
||||
|
||||
/**
|
||||
* DHCPv4 client state in the process of network
|
||||
* address allocation.
|
||||
*/
|
||||
enum net_dhcpv4_state state;
|
||||
|
||||
/** Number of attempts made for REQUEST and RENEWAL messages */
|
||||
uint8_t attempts;
|
||||
|
||||
/** Timer for DHCPv4 Client requests (DISCOVER,
|
||||
* REQUEST or RENEWAL)
|
||||
*/
|
||||
|
@ -310,8 +301,16 @@ struct net_if {
|
|||
|
||||
/** T2 (Rebinding) timer */
|
||||
struct k_delayed_work t2_timer;
|
||||
} dhcpv4;
|
||||
|
||||
/**
|
||||
* DHCPv4 client state in the process of network
|
||||
* address allocation.
|
||||
*/
|
||||
enum net_dhcpv4_state state;
|
||||
|
||||
/** Number of attempts made for REQUEST and RENEWAL messages */
|
||||
uint8_t attempts;
|
||||
} dhcpv4;
|
||||
#endif
|
||||
} __net_if_align;
|
||||
|
||||
|
@ -824,7 +823,7 @@ bool net_if_ipv6_router_rm(struct net_if_router *router);
|
|||
*/
|
||||
static inline uint8_t net_if_ipv6_get_hop_limit(struct net_if *iface)
|
||||
{
|
||||
return iface->hop_limit;
|
||||
return iface->ipv6.hop_limit;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -836,7 +835,7 @@ static inline uint8_t net_if_ipv6_get_hop_limit(struct net_if *iface)
|
|||
static inline void net_ipv6_set_hop_limit(struct net_if *iface,
|
||||
uint8_t hop_limit)
|
||||
{
|
||||
iface->hop_limit = hop_limit;
|
||||
iface->ipv6.hop_limit = hop_limit;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -848,7 +847,7 @@ static inline void net_ipv6_set_hop_limit(struct net_if *iface,
|
|||
static inline void net_if_ipv6_set_base_reachable_time(struct net_if *iface,
|
||||
uint32_t reachable_time)
|
||||
{
|
||||
iface->base_reachable_time = reachable_time;
|
||||
iface->ipv6.base_reachable_time = reachable_time;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -860,7 +859,7 @@ static inline void net_if_ipv6_set_base_reachable_time(struct net_if *iface,
|
|||
*/
|
||||
static inline uint32_t net_if_ipv6_get_reachable_time(struct net_if *iface)
|
||||
{
|
||||
return iface->reachable_time;
|
||||
return iface->ipv6.reachable_time;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -880,7 +879,7 @@ uint32_t net_if_ipv6_calc_reachable_time(struct net_if *iface);
|
|||
*/
|
||||
static inline void net_if_ipv6_set_reachable_time(struct net_if *iface)
|
||||
{
|
||||
iface->reachable_time = net_if_ipv6_calc_reachable_time(iface);
|
||||
iface->ipv6.reachable_time = net_if_ipv6_calc_reachable_time(iface);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -892,7 +891,7 @@ static inline void net_if_ipv6_set_reachable_time(struct net_if *iface)
|
|||
static inline void net_if_ipv6_set_retrans_timer(struct net_if *iface,
|
||||
uint32_t retrans_timer)
|
||||
{
|
||||
iface->retrans_timer = retrans_timer;
|
||||
iface->ipv6.retrans_timer = retrans_timer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -904,7 +903,7 @@ static inline void net_if_ipv6_set_retrans_timer(struct net_if *iface,
|
|||
*/
|
||||
static inline uint32_t net_if_ipv6_get_retrans_timer(struct net_if *iface)
|
||||
{
|
||||
return iface->retrans_timer;
|
||||
return iface->ipv6.retrans_timer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -979,7 +978,7 @@ struct in6_addr *net_if_ipv6_get_global_addr(struct net_if **iface);
|
|||
*/
|
||||
static inline uint8_t net_if_ipv4_get_ttl(struct net_if *iface)
|
||||
{
|
||||
return iface->ttl;
|
||||
return iface->ipv4.ttl;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2360,7 +2360,7 @@ static enum net_verdict handle_ra_input(struct net_buf *buf)
|
|||
}
|
||||
|
||||
/* Cancel the RS timer on iface */
|
||||
k_delayed_work_cancel(&net_nbuf_iface(buf)->rs_timer);
|
||||
k_delayed_work_cancel(&net_nbuf_iface(buf)->ipv6.rs_timer);
|
||||
|
||||
net_nbuf_unref(buf);
|
||||
|
||||
|
|
|
@ -479,13 +479,13 @@ static inline void net_if_ipv6_start_dad(struct net_if *iface,
|
|||
static void rs_timeout(struct k_work *work)
|
||||
{
|
||||
/* Did not receive RA yet. */
|
||||
struct net_if *iface = CONTAINER_OF(work, struct net_if, rs_timer);
|
||||
struct net_if *iface = CONTAINER_OF(work, struct net_if, ipv6.rs_timer);
|
||||
|
||||
iface->rs_count++;
|
||||
iface->ipv6.rs_count++;
|
||||
|
||||
NET_DBG("RS no respond iface %p count %d", iface, iface->rs_count);
|
||||
NET_DBG("RS no respond iface %p count %d", iface, iface->ipv6.rs_count);
|
||||
|
||||
if (iface->rs_count < RS_COUNT) {
|
||||
if (iface->ipv6.rs_count < RS_COUNT) {
|
||||
net_if_start_rs(iface);
|
||||
}
|
||||
}
|
||||
|
@ -495,7 +495,7 @@ void net_if_start_rs(struct net_if *iface)
|
|||
NET_DBG("Interface %p", iface);
|
||||
|
||||
if (!net_ipv6_start_rs(iface)) {
|
||||
k_delayed_work_submit(&iface->rs_timer, RS_TIMEOUT);
|
||||
k_delayed_work_submit(&iface->ipv6.rs_timer, RS_TIMEOUT);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_NET_IPV6_ND */
|
||||
|
@ -1307,10 +1307,10 @@ const struct in6_addr *net_if_ipv6_select_src_addr(struct net_if *dst_iface,
|
|||
|
||||
uint32_t net_if_ipv6_calc_reachable_time(struct net_if *iface)
|
||||
{
|
||||
return MIN_RANDOM_FACTOR * iface->base_reachable_time +
|
||||
return MIN_RANDOM_FACTOR * iface->ipv6.base_reachable_time +
|
||||
sys_rand32_get() %
|
||||
(MAX_RANDOM_FACTOR * iface->base_reachable_time -
|
||||
MIN_RANDOM_FACTOR * iface->base_reachable_time);
|
||||
(MAX_RANDOM_FACTOR * iface->ipv6.base_reachable_time -
|
||||
MIN_RANDOM_FACTOR * iface->ipv6.base_reachable_time);
|
||||
}
|
||||
|
||||
#else /* CONFIG_NET_IPV6 */
|
||||
|
@ -1658,17 +1658,17 @@ void net_if_init(struct k_sem *startup_sync)
|
|||
init_iface(iface);
|
||||
|
||||
#if defined(CONFIG_NET_IPV4)
|
||||
iface->ttl = CONFIG_NET_INITIAL_TTL;
|
||||
iface->ipv4.ttl = CONFIG_NET_INITIAL_TTL;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NET_IPV6)
|
||||
iface->hop_limit = CONFIG_NET_INITIAL_HOP_LIMIT;
|
||||
iface->base_reachable_time = REACHABLE_TIME;
|
||||
iface->ipv6.hop_limit = CONFIG_NET_INITIAL_HOP_LIMIT;
|
||||
iface->ipv6.base_reachable_time = REACHABLE_TIME;
|
||||
|
||||
net_if_ipv6_set_reachable_time(iface);
|
||||
|
||||
#if defined(CONFIG_NET_IPV6_ND)
|
||||
k_delayed_work_init(&iface->rs_timer, rs_timeout);
|
||||
k_delayed_work_init(&iface->ipv6.rs_timer, rs_timeout);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -170,10 +170,11 @@ static void iface_cb(struct net_if *iface, void *user_data)
|
|||
router->is_infinite ? " infinite" : "");
|
||||
}
|
||||
|
||||
printk("IPv6 hop limit : %d\n", iface->hop_limit);
|
||||
printk("IPv6 base reachable time : %d\n", iface->base_reachable_time);
|
||||
printk("IPv6 reachable time : %d\n", iface->reachable_time);
|
||||
printk("IPv6 retransmit timer : %d\n", iface->retrans_timer);
|
||||
printk("IPv6 hop limit : %d\n", iface->ipv6.hop_limit);
|
||||
printk("IPv6 base reachable time : %d\n",
|
||||
iface->ipv6.base_reachable_time);
|
||||
printk("IPv6 reachable time : %d\n", iface->ipv6.reachable_time);
|
||||
printk("IPv6 retransmit timer : %d\n", iface->ipv6.retrans_timer);
|
||||
#endif /* CONFIG_NET_IPV6 */
|
||||
|
||||
#if defined(CONFIG_NET_IPV4)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue