net: ipv6: Remove in6_addr from packed net_ipv6_hdr struct
Replace unpacked in6_addr structures with raw buffers in net_ipv6_hdr struct, to prevent compiler warnings about unaligned access. Remove __packed parameter from `struct net_6lo_context` since the structure isn't really serialized. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
parent
064200b420
commit
666e9f80d6
28 changed files with 403 additions and 317 deletions
|
@ -466,8 +466,8 @@ struct net_ipv6_hdr {
|
|||
uint16_t len;
|
||||
uint8_t nexthdr;
|
||||
uint8_t hop_limit;
|
||||
struct in6_addr src;
|
||||
struct in6_addr dst;
|
||||
uint8_t src[NET_IPV6_ADDR_SIZE];
|
||||
uint8_t dst[NET_IPV6_ADDR_SIZE];
|
||||
} __packed;
|
||||
|
||||
struct net_ipv6_frag_hdr {
|
||||
|
@ -751,6 +751,18 @@ static inline void net_ipv4_addr_copy_raw(uint8_t *dest,
|
|||
net_ipaddr_copy((struct in_addr *)dest, (const struct in_addr *)src);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Copy an IPv6 address raw buffer
|
||||
*
|
||||
* @param dest Destination IP address.
|
||||
* @param src Source IP address.
|
||||
*/
|
||||
static inline void net_ipv6_addr_copy_raw(uint8_t *dest,
|
||||
const uint8_t *src)
|
||||
{
|
||||
memcpy(dest, src, sizeof(struct in6_addr));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Compare two IPv4 addresses
|
||||
*
|
||||
|
@ -794,6 +806,21 @@ static inline bool net_ipv6_addr_cmp(const struct in6_addr *addr1,
|
|||
return !memcmp(addr1, addr2, sizeof(struct in6_addr));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Compare two raw IPv6 address buffers
|
||||
*
|
||||
* @param addr1 Pointer to IPv6 address buffer.
|
||||
* @param addr2 Pointer to IPv6 address buffer.
|
||||
*
|
||||
* @return True if the addresses are the same, false otherwise.
|
||||
*/
|
||||
static inline bool net_ipv6_addr_cmp_raw(const uint8_t *addr1,
|
||||
const uint8_t *addr2)
|
||||
{
|
||||
return net_ipv6_addr_cmp((const struct in6_addr *)addr1,
|
||||
(const struct in6_addr *)addr2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if the given IPv6 address is a link local address.
|
||||
*
|
||||
|
|
|
@ -1199,7 +1199,7 @@ static inline void net_pkt_set_src_ipv6_addr(struct net_pkt *pkt)
|
|||
{
|
||||
net_if_ipv6_select_src_addr(net_context_get_iface(
|
||||
net_pkt_context(pkt)),
|
||||
&NET_IPV6_HDR(pkt)->src);
|
||||
(struct in6_addr *)NET_IPV6_HDR(pkt)->src);
|
||||
}
|
||||
|
||||
static inline void net_pkt_set_overwrite(struct net_pkt *pkt, bool overwrite)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue