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
|
@ -79,10 +79,10 @@ static int loopback_send(const struct device *dev, struct net_pkt *pkt)
|
||||||
if (net_pkt_family(pkt) == AF_INET6) {
|
if (net_pkt_family(pkt) == AF_INET6) {
|
||||||
struct in6_addr addr;
|
struct in6_addr addr;
|
||||||
|
|
||||||
net_ipaddr_copy(&addr, &NET_IPV6_HDR(pkt)->src);
|
net_ipv6_addr_copy_raw((uint8_t *)&addr, NET_IPV6_HDR(pkt)->src);
|
||||||
net_ipaddr_copy(&NET_IPV6_HDR(pkt)->src,
|
net_ipv6_addr_copy_raw(NET_IPV6_HDR(pkt)->src,
|
||||||
&NET_IPV6_HDR(pkt)->dst);
|
NET_IPV6_HDR(pkt)->dst);
|
||||||
net_ipaddr_copy(&NET_IPV6_HDR(pkt)->dst, &addr);
|
net_ipv6_addr_copy_raw(NET_IPV6_HDR(pkt)->dst, (uint8_t *)&addr);
|
||||||
} else {
|
} else {
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
|
|
||||||
|
|
|
@ -466,8 +466,8 @@ struct net_ipv6_hdr {
|
||||||
uint16_t len;
|
uint16_t len;
|
||||||
uint8_t nexthdr;
|
uint8_t nexthdr;
|
||||||
uint8_t hop_limit;
|
uint8_t hop_limit;
|
||||||
struct in6_addr src;
|
uint8_t src[NET_IPV6_ADDR_SIZE];
|
||||||
struct in6_addr dst;
|
uint8_t dst[NET_IPV6_ADDR_SIZE];
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
struct net_ipv6_frag_hdr {
|
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);
|
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
|
* @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));
|
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.
|
* @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_if_ipv6_select_src_addr(net_context_get_iface(
|
||||||
net_pkt_context(pkt)),
|
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)
|
static inline void net_pkt_set_overwrite(struct net_pkt *pkt, bool overwrite)
|
||||||
|
|
|
@ -166,8 +166,8 @@ static inline void set_dst_addr(sa_family_t family,
|
||||||
struct net_udp_hdr *udp_hdr,
|
struct net_udp_hdr *udp_hdr,
|
||||||
struct sockaddr *dst_addr)
|
struct sockaddr *dst_addr)
|
||||||
{
|
{
|
||||||
net_ipaddr_copy(&net_sin6(dst_addr)->sin6_addr,
|
net_ipv6_addr_copy_raw((uint8_t *)&net_sin6(dst_addr)->sin6_addr,
|
||||||
&ipv6_hdr->src);
|
ipv6_hdr->src);
|
||||||
net_sin6(dst_addr)->sin6_family = AF_INET6;
|
net_sin6(dst_addr)->sin6_family = AF_INET6;
|
||||||
net_sin6(dst_addr)->sin6_port = udp_hdr->src_port;
|
net_sin6(dst_addr)->sin6_port = udp_hdr->src_port;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ struct session *get_session(struct net_pkt *pkt,
|
||||||
port = udp_hdr->src_port;
|
port = udp_hdr->src_port;
|
||||||
|
|
||||||
if (net_pkt_family(pkt) == AF_INET6) {
|
if (net_pkt_family(pkt) == AF_INET6) {
|
||||||
net_ipaddr_copy(&ipv6, &ip_hdr->ipv6->src);
|
net_ipv6_addr_copy_raw((uint8_t *)&ipv6, ip_hdr->ipv6->src);
|
||||||
} else if (net_pkt_family(pkt) == AF_INET) {
|
} else if (net_pkt_family(pkt) == AF_INET) {
|
||||||
net_ipv4_addr_copy_raw((uint8_t *)&ipv4, ip_hdr->ipv4->src);
|
net_ipv4_addr_copy_raw((uint8_t *)&ipv4, ip_hdr->ipv4->src);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -37,8 +37,8 @@ static inline void set_dst_addr(const struct shell *shell,
|
||||||
struct sockaddr *dst_addr)
|
struct sockaddr *dst_addr)
|
||||||
{
|
{
|
||||||
if (IS_ENABLED(CONFIG_NET_IPV6) && family == AF_INET6) {
|
if (IS_ENABLED(CONFIG_NET_IPV6) && family == AF_INET6) {
|
||||||
net_ipaddr_copy(&net_sin6(dst_addr)->sin6_addr,
|
net_ipv6_addr_copy_raw((uint8_t *)&net_sin6(dst_addr)->sin6_addr,
|
||||||
&ip_hdr->ipv6->src);
|
ip_hdr->ipv6->src);
|
||||||
net_sin6(dst_addr)->sin6_family = AF_INET6;
|
net_sin6(dst_addr)->sin6_family = AF_INET6;
|
||||||
net_sin6(dst_addr)->sin6_port = udp_hdr->src_port;
|
net_sin6(dst_addr)->sin6_port = udp_hdr->src_port;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ struct net_6lo_context {
|
||||||
uint8_t compress : 1;
|
uint8_t compress : 1;
|
||||||
uint8_t cid : 4;
|
uint8_t cid : 4;
|
||||||
uint8_t unused : 2;
|
uint8_t unused : 2;
|
||||||
} __packed;
|
};
|
||||||
|
|
||||||
static inline uint8_t get_6co_compress(struct net_icmpv6_nd_opt_6co *opt)
|
static inline uint8_t get_6co_compress(struct net_icmpv6_nd_opt_6co *opt)
|
||||||
{
|
{
|
||||||
|
@ -368,7 +368,8 @@ static uint8_t *compress_sa(struct net_ipv6_hdr *ipv6, struct net_pkt *pkt,
|
||||||
NET_ASSERT(net_pkt_lladdr_src(pkt)->addr);
|
NET_ASSERT(net_pkt_lladdr_src(pkt)->addr);
|
||||||
|
|
||||||
/* Address is fully elided */
|
/* Address is fully elided */
|
||||||
if (net_ipv6_addr_based_on_ll(&ipv6->src, net_pkt_lladdr_src(pkt))) {
|
if (net_ipv6_addr_based_on_ll((struct in6_addr *)ipv6->src,
|
||||||
|
net_pkt_lladdr_src(pkt))) {
|
||||||
NET_DBG("SAM_11 src address is fully elided");
|
NET_DBG("SAM_11 src address is fully elided");
|
||||||
|
|
||||||
*iphc |= NET_6LO_IPHC_SAM_11;
|
*iphc |= NET_6LO_IPHC_SAM_11;
|
||||||
|
@ -376,12 +377,12 @@ static uint8_t *compress_sa(struct net_ipv6_hdr *ipv6, struct net_pkt *pkt,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Following 64 bits are 0000:00ff:fe00:XXXX */
|
/* Following 64 bits are 0000:00ff:fe00:XXXX */
|
||||||
if (net_6lo_addr_16_bit_compressible(&ipv6->src)) {
|
if (net_6lo_addr_16_bit_compressible((struct in6_addr *)ipv6->src)) {
|
||||||
NET_DBG("SAM_10 src addr 16 bit compressible");
|
NET_DBG("SAM_10 src addr 16 bit compressible");
|
||||||
*iphc |= NET_6LO_IPHC_SAM_10;
|
*iphc |= NET_6LO_IPHC_SAM_10;
|
||||||
|
|
||||||
inline_ptr -= sizeof(uint16_t);
|
inline_ptr -= sizeof(uint16_t);
|
||||||
memmove(inline_ptr, &ipv6->src.s6_addr[14], sizeof(uint16_t));
|
memmove(inline_ptr, &ipv6->src[14], sizeof(uint16_t));
|
||||||
|
|
||||||
return inline_ptr;
|
return inline_ptr;
|
||||||
}
|
}
|
||||||
|
@ -391,7 +392,7 @@ static uint8_t *compress_sa(struct net_ipv6_hdr *ipv6, struct net_pkt *pkt,
|
||||||
*iphc |= NET_6LO_IPHC_SAM_01;
|
*iphc |= NET_6LO_IPHC_SAM_01;
|
||||||
|
|
||||||
inline_ptr -= 8U;
|
inline_ptr -= 8U;
|
||||||
memmove(inline_ptr, &ipv6->src.s6_addr[8], 8U);
|
memmove(inline_ptr, &ipv6->src[8], 8U);
|
||||||
|
|
||||||
return inline_ptr;
|
return inline_ptr;
|
||||||
}
|
}
|
||||||
|
@ -401,7 +402,7 @@ static uint8_t *set_sa_inline(struct net_ipv6_hdr *ipv6, uint8_t *inline_ptr,
|
||||||
{
|
{
|
||||||
*iphc |= NET_6LO_IPHC_SAM_00;
|
*iphc |= NET_6LO_IPHC_SAM_00;
|
||||||
inline_ptr -= 16U;
|
inline_ptr -= 16U;
|
||||||
memmove(inline_ptr, &ipv6->src.s6_addr[0], 16U);
|
memmove(inline_ptr, &ipv6->src[0], 16U);
|
||||||
return inline_ptr;
|
return inline_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,7 +416,8 @@ static uint8_t *compress_sa_ctx(struct net_ipv6_hdr *ipv6, uint8_t *inline_ptr,
|
||||||
NET_DBG("SAC_1 src address context based");
|
NET_DBG("SAC_1 src address context based");
|
||||||
*iphc |= NET_6LO_IPHC_SAC_1;
|
*iphc |= NET_6LO_IPHC_SAC_1;
|
||||||
|
|
||||||
if (net_ipv6_addr_based_on_ll(&ipv6->src, net_pkt_lladdr_src(pkt))) {
|
if (net_ipv6_addr_based_on_ll((struct in6_addr *)ipv6->src,
|
||||||
|
net_pkt_lladdr_src(pkt))) {
|
||||||
NET_DBG("SAM_11 src address is fully elided");
|
NET_DBG("SAM_11 src address is fully elided");
|
||||||
|
|
||||||
/* Address is fully elided */
|
/* Address is fully elided */
|
||||||
|
@ -424,13 +426,13 @@ static uint8_t *compress_sa_ctx(struct net_ipv6_hdr *ipv6, uint8_t *inline_ptr,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Following 64 bits are 0000:00ff:fe00:XXXX */
|
/* Following 64 bits are 0000:00ff:fe00:XXXX */
|
||||||
if (net_6lo_addr_16_bit_compressible(&ipv6->src)) {
|
if (net_6lo_addr_16_bit_compressible((struct in6_addr *)ipv6->src)) {
|
||||||
NET_DBG("SAM_10 src addr 16 bit compressible");
|
NET_DBG("SAM_10 src addr 16 bit compressible");
|
||||||
|
|
||||||
*iphc |= NET_6LO_IPHC_SAM_10;
|
*iphc |= NET_6LO_IPHC_SAM_10;
|
||||||
|
|
||||||
inline_ptr -= sizeof(uint16_t);
|
inline_ptr -= sizeof(uint16_t);
|
||||||
memmove(inline_ptr, &ipv6->src.s6_addr[14], sizeof(uint16_t));
|
memmove(inline_ptr, &ipv6->src[14], sizeof(uint16_t));
|
||||||
return inline_ptr;
|
return inline_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,7 +442,7 @@ static uint8_t *compress_sa_ctx(struct net_ipv6_hdr *ipv6, uint8_t *inline_ptr,
|
||||||
*iphc |= NET_6LO_IPHC_SAM_01;
|
*iphc |= NET_6LO_IPHC_SAM_01;
|
||||||
|
|
||||||
inline_ptr -= 8U;
|
inline_ptr -= 8U;
|
||||||
memmove(inline_ptr, &ipv6->src.s6_addr[8], 8U);
|
memmove(inline_ptr, &ipv6->src[8], 8U);
|
||||||
|
|
||||||
return inline_ptr;
|
return inline_ptr;
|
||||||
}
|
}
|
||||||
|
@ -454,44 +456,44 @@ static uint8_t *compress_da_mcast(struct net_ipv6_hdr *ipv6, uint8_t *inline_ptr
|
||||||
|
|
||||||
NET_DBG("M_1 dst is mcast");
|
NET_DBG("M_1 dst is mcast");
|
||||||
|
|
||||||
if (net_6lo_maddr_8_bit_compressible(&ipv6->dst)) {
|
if (net_6lo_maddr_8_bit_compressible((struct in6_addr *)ipv6->dst)) {
|
||||||
NET_DBG("DAM_11 dst maddr 8 bit compressible");
|
NET_DBG("DAM_11 dst maddr 8 bit compressible");
|
||||||
|
|
||||||
/* last byte */
|
/* last byte */
|
||||||
*iphc |= NET_6LO_IPHC_DAM_11;
|
*iphc |= NET_6LO_IPHC_DAM_11;
|
||||||
|
|
||||||
inline_ptr -= sizeof(uint8_t);
|
inline_ptr -= sizeof(uint8_t);
|
||||||
memmove(inline_ptr, &ipv6->dst.s6_addr[15], sizeof(uint8_t));
|
memmove(inline_ptr, &ipv6->dst[15], sizeof(uint8_t));
|
||||||
|
|
||||||
return inline_ptr;
|
return inline_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (net_6lo_maddr_32_bit_compressible(&ipv6->dst)) {
|
if (net_6lo_maddr_32_bit_compressible((struct in6_addr *)ipv6->dst)) {
|
||||||
NET_DBG("DAM_10 4 bytes: 2nd byte + last three bytes");
|
NET_DBG("DAM_10 4 bytes: 2nd byte + last three bytes");
|
||||||
|
|
||||||
/* 4 bytes: 2nd byte + last three bytes */
|
/* 4 bytes: 2nd byte + last three bytes */
|
||||||
*iphc |= NET_6LO_IPHC_DAM_10;
|
*iphc |= NET_6LO_IPHC_DAM_10;
|
||||||
|
|
||||||
inline_ptr -= 3U;
|
inline_ptr -= 3U;
|
||||||
memmove(inline_ptr, &ipv6->dst.s6_addr[13], 3U);
|
memmove(inline_ptr, &ipv6->dst[13], 3U);
|
||||||
|
|
||||||
inline_ptr -= sizeof(uint8_t);
|
inline_ptr -= sizeof(uint8_t);
|
||||||
memmove(inline_ptr, &ipv6->dst.s6_addr[1], sizeof(uint8_t));
|
memmove(inline_ptr, &ipv6->dst[1], sizeof(uint8_t));
|
||||||
|
|
||||||
return inline_ptr;
|
return inline_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (net_6lo_maddr_48_bit_compressible(&ipv6->dst)) {
|
if (net_6lo_maddr_48_bit_compressible((struct in6_addr *)ipv6->dst)) {
|
||||||
NET_DBG("DAM_01 6 bytes: 2nd byte + last five bytes");
|
NET_DBG("DAM_01 6 bytes: 2nd byte + last five bytes");
|
||||||
|
|
||||||
/* 6 bytes: 2nd byte + last five bytes */
|
/* 6 bytes: 2nd byte + last five bytes */
|
||||||
*iphc |= NET_6LO_IPHC_DAM_01;
|
*iphc |= NET_6LO_IPHC_DAM_01;
|
||||||
|
|
||||||
inline_ptr -= 5U;
|
inline_ptr -= 5U;
|
||||||
memmove(inline_ptr, &ipv6->dst.s6_addr[11], 5U);
|
memmove(inline_ptr, &ipv6->dst[11], 5U);
|
||||||
|
|
||||||
inline_ptr -= sizeof(uint8_t);
|
inline_ptr -= sizeof(uint8_t);
|
||||||
memmove(inline_ptr, &ipv6->dst.s6_addr[1], sizeof(uint8_t));
|
memmove(inline_ptr, &ipv6->dst[1], sizeof(uint8_t));
|
||||||
|
|
||||||
return inline_ptr;
|
return inline_ptr;
|
||||||
}
|
}
|
||||||
|
@ -500,7 +502,7 @@ static uint8_t *compress_da_mcast(struct net_ipv6_hdr *ipv6, uint8_t *inline_ptr
|
||||||
|
|
||||||
/* complete address NET_6LO_IPHC_DAM_00 */
|
/* complete address NET_6LO_IPHC_DAM_00 */
|
||||||
inline_ptr -= 16U;
|
inline_ptr -= 16U;
|
||||||
memmove(inline_ptr, &ipv6->dst.s6_addr[0], 16U);
|
memmove(inline_ptr, &ipv6->dst[0], 16U);
|
||||||
|
|
||||||
return inline_ptr;
|
return inline_ptr;
|
||||||
}
|
}
|
||||||
|
@ -509,8 +511,10 @@ static uint8_t *compress_da(struct net_ipv6_hdr *ipv6, struct net_pkt *pkt,
|
||||||
uint8_t *inline_ptr, uint16_t *iphc)
|
uint8_t *inline_ptr, uint16_t *iphc)
|
||||||
{
|
{
|
||||||
NET_ASSERT(net_pkt_lladdr_dst(pkt)->addr);
|
NET_ASSERT(net_pkt_lladdr_dst(pkt)->addr);
|
||||||
|
|
||||||
/* Address is fully elided */
|
/* Address is fully elided */
|
||||||
if (net_ipv6_addr_based_on_ll(&ipv6->dst, net_pkt_lladdr_dst(pkt))) {
|
if (net_ipv6_addr_based_on_ll((struct in6_addr *)ipv6->dst,
|
||||||
|
net_pkt_lladdr_dst(pkt))) {
|
||||||
NET_DBG("DAM_11 dst addr fully elided");
|
NET_DBG("DAM_11 dst addr fully elided");
|
||||||
|
|
||||||
*iphc |= NET_6LO_IPHC_DAM_11;
|
*iphc |= NET_6LO_IPHC_DAM_11;
|
||||||
|
@ -518,13 +522,13 @@ static uint8_t *compress_da(struct net_ipv6_hdr *ipv6, struct net_pkt *pkt,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Following 64 bits are 0000:00ff:fe00:XXXX */
|
/* Following 64 bits are 0000:00ff:fe00:XXXX */
|
||||||
if (net_6lo_addr_16_bit_compressible(&ipv6->dst)) {
|
if (net_6lo_addr_16_bit_compressible((struct in6_addr *)ipv6->dst)) {
|
||||||
NET_DBG("DAM_10 dst addr 16 bit compressible");
|
NET_DBG("DAM_10 dst addr 16 bit compressible");
|
||||||
|
|
||||||
*iphc |= NET_6LO_IPHC_DAM_10;
|
*iphc |= NET_6LO_IPHC_DAM_10;
|
||||||
|
|
||||||
inline_ptr -= sizeof(uint16_t);
|
inline_ptr -= sizeof(uint16_t);
|
||||||
memmove(inline_ptr, &ipv6->dst.s6_addr[14], sizeof(uint16_t));
|
memmove(inline_ptr, &ipv6->dst[14], sizeof(uint16_t));
|
||||||
return inline_ptr;
|
return inline_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,7 +538,7 @@ static uint8_t *compress_da(struct net_ipv6_hdr *ipv6, struct net_pkt *pkt,
|
||||||
*iphc |= NET_6LO_IPHC_DAM_01;
|
*iphc |= NET_6LO_IPHC_DAM_01;
|
||||||
|
|
||||||
inline_ptr -= 8U;
|
inline_ptr -= 8U;
|
||||||
memmove(inline_ptr, &ipv6->dst.s6_addr[8], 8U);
|
memmove(inline_ptr, &ipv6->dst[8], 8U);
|
||||||
|
|
||||||
return inline_ptr;
|
return inline_ptr;
|
||||||
}
|
}
|
||||||
|
@ -544,7 +548,7 @@ static uint8_t *set_da_inline(struct net_ipv6_hdr *ipv6, uint8_t *inline_ptr,
|
||||||
{
|
{
|
||||||
*iphc |= NET_6LO_IPHC_DAM_00;
|
*iphc |= NET_6LO_IPHC_DAM_00;
|
||||||
inline_ptr -= 16U;
|
inline_ptr -= 16U;
|
||||||
memmove(inline_ptr, &ipv6->dst.s6_addr[0], 16U);
|
memmove(inline_ptr, &ipv6->dst[0], 16U);
|
||||||
return inline_ptr;
|
return inline_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -555,7 +559,8 @@ static uint8_t *compress_da_ctx(struct net_ipv6_hdr *ipv6, uint8_t *inline_ptr,
|
||||||
{
|
{
|
||||||
*iphc |= NET_6LO_IPHC_DAC_1;
|
*iphc |= NET_6LO_IPHC_DAC_1;
|
||||||
|
|
||||||
if (net_ipv6_addr_based_on_ll(&ipv6->dst, net_pkt_lladdr_dst(pkt))) {
|
if (net_ipv6_addr_based_on_ll((struct in6_addr *)ipv6->dst,
|
||||||
|
net_pkt_lladdr_dst(pkt))) {
|
||||||
NET_DBG("DAM_11 dst addr fully elided");
|
NET_DBG("DAM_11 dst addr fully elided");
|
||||||
|
|
||||||
*iphc |= NET_6LO_IPHC_DAM_11;
|
*iphc |= NET_6LO_IPHC_DAM_11;
|
||||||
|
@ -563,12 +568,12 @@ static uint8_t *compress_da_ctx(struct net_ipv6_hdr *ipv6, uint8_t *inline_ptr,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Following 64 bits are 0000:00ff:fe00:XXXX */
|
/* Following 64 bits are 0000:00ff:fe00:XXXX */
|
||||||
if (net_6lo_addr_16_bit_compressible(&ipv6->dst)) {
|
if (net_6lo_addr_16_bit_compressible((struct in6_addr *)ipv6->dst)) {
|
||||||
NET_DBG("DAM_10 dst addr 16 bit compressible");
|
NET_DBG("DAM_10 dst addr 16 bit compressible");
|
||||||
|
|
||||||
*iphc |= NET_6LO_IPHC_DAM_10;
|
*iphc |= NET_6LO_IPHC_DAM_10;
|
||||||
inline_ptr -= sizeof(uint16_t);
|
inline_ptr -= sizeof(uint16_t);
|
||||||
memmove(inline_ptr, &ipv6->dst.s6_addr[14], sizeof(uint16_t));
|
memmove(inline_ptr, &ipv6->dst[14], sizeof(uint16_t));
|
||||||
return inline_ptr;
|
return inline_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -578,7 +583,7 @@ static uint8_t *compress_da_ctx(struct net_ipv6_hdr *ipv6, uint8_t *inline_ptr,
|
||||||
*iphc |= NET_6LO_IPHC_DAM_01;
|
*iphc |= NET_6LO_IPHC_DAM_01;
|
||||||
|
|
||||||
inline_ptr -= 8U;
|
inline_ptr -= 8U;
|
||||||
memmove(inline_ptr, &ipv6->dst.s6_addr[8], 8U);
|
memmove(inline_ptr, &ipv6->dst[8], 8U);
|
||||||
|
|
||||||
return inline_ptr;
|
return inline_ptr;
|
||||||
}
|
}
|
||||||
|
@ -687,7 +692,8 @@ static struct net_6lo_context *get_src_addr_ctx(struct net_pkt *pkt,
|
||||||
/* If compress flag is unset means use only in uncompression. */
|
/* If compress flag is unset means use only in uncompression. */
|
||||||
struct net_6lo_context *src;
|
struct net_6lo_context *src;
|
||||||
|
|
||||||
src = get_6lo_context_by_addr(net_pkt_iface(pkt), &ipv6->src);
|
src = get_6lo_context_by_addr(net_pkt_iface(pkt),
|
||||||
|
(struct in6_addr *)ipv6->src);
|
||||||
if (!src || !src->compress) {
|
if (!src || !src->compress) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -701,7 +707,8 @@ static struct net_6lo_context *get_dst_addr_ctx(struct net_pkt *pkt,
|
||||||
/* If compress flag is unset means use only in uncompression. */
|
/* If compress flag is unset means use only in uncompression. */
|
||||||
struct net_6lo_context *dst;
|
struct net_6lo_context *dst;
|
||||||
|
|
||||||
dst = get_6lo_context_by_addr(net_pkt_iface(pkt), &ipv6->dst);
|
dst = get_6lo_context_by_addr(net_pkt_iface(pkt),
|
||||||
|
(struct in6_addr *)ipv6->dst);
|
||||||
if (!dst || !dst->compress) {
|
if (!dst || !dst->compress) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -752,12 +759,12 @@ static inline int compress_IPHC_header(struct net_pkt *pkt)
|
||||||
inline_pos = compress_nh_udp(udp, inline_pos, false);
|
inline_pos = compress_nh_udp(udp, inline_pos, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (net_6lo_ll_prefix_padded_with_zeros(&ipv6->dst)) {
|
if (net_6lo_ll_prefix_padded_with_zeros((struct in6_addr *)ipv6->dst)) {
|
||||||
inline_pos = compress_da(ipv6, pkt, inline_pos, &iphc);
|
inline_pos = compress_da(ipv6, pkt, inline_pos, &iphc);
|
||||||
goto da_end;
|
goto da_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (net_ipv6_is_addr_mcast(&ipv6->dst)) {
|
if (net_ipv6_is_addr_mcast((struct in6_addr *)ipv6->dst)) {
|
||||||
inline_pos = compress_da_mcast(ipv6, inline_pos, &iphc);
|
inline_pos = compress_da_mcast(ipv6, inline_pos, &iphc);
|
||||||
goto da_end;
|
goto da_end;
|
||||||
}
|
}
|
||||||
|
@ -774,12 +781,12 @@ static inline int compress_IPHC_header(struct net_pkt *pkt)
|
||||||
inline_pos = set_da_inline(ipv6, inline_pos, &iphc);
|
inline_pos = set_da_inline(ipv6, inline_pos, &iphc);
|
||||||
da_end:
|
da_end:
|
||||||
|
|
||||||
if (net_6lo_ll_prefix_padded_with_zeros(&ipv6->src)) {
|
if (net_6lo_ll_prefix_padded_with_zeros((struct in6_addr *)ipv6->src)) {
|
||||||
inline_pos = compress_sa(ipv6, pkt, inline_pos, &iphc);
|
inline_pos = compress_sa(ipv6, pkt, inline_pos, &iphc);
|
||||||
goto sa_end;
|
goto sa_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (net_ipv6_is_addr_unspecified(&ipv6->src)) {
|
if (net_ipv6_is_addr_unspecified((struct in6_addr *)ipv6->src)) {
|
||||||
NET_DBG("SAM_00, SAC_1 unspecified src address");
|
NET_DBG("SAM_00, SAC_1 unspecified src address");
|
||||||
|
|
||||||
/* Unspecified IPv6 src address */
|
/* Unspecified IPv6 src address */
|
||||||
|
@ -919,53 +926,58 @@ static inline uint8_t *uncompress_sa(uint16_t iphc, uint8_t *cursor,
|
||||||
struct net_ipv6_hdr *ipv6,
|
struct net_ipv6_hdr *ipv6,
|
||||||
struct net_pkt *pkt)
|
struct net_pkt *pkt)
|
||||||
{
|
{
|
||||||
|
struct in6_addr src_ip;
|
||||||
|
|
||||||
NET_DBG("SAC_0");
|
NET_DBG("SAC_0");
|
||||||
|
|
||||||
|
net_ipv6_addr_copy_raw((uint8_t *)&src_ip, ipv6->src);
|
||||||
|
|
||||||
switch (iphc & NET_6LO_IPHC_SAM_MASK) {
|
switch (iphc & NET_6LO_IPHC_SAM_MASK) {
|
||||||
case NET_6LO_IPHC_SAM_00:
|
case NET_6LO_IPHC_SAM_00:
|
||||||
NET_DBG("SAM_00 full src addr inlined");
|
NET_DBG("SAM_00 full src addr inlined");
|
||||||
|
|
||||||
memmove(ipv6->src.s6_addr, cursor, sizeof(ipv6->src.s6_addr));
|
memmove(src_ip.s6_addr, cursor, sizeof(src_ip.s6_addr));
|
||||||
cursor += sizeof(ipv6->src.s6_addr);
|
cursor += sizeof(src_ip.s6_addr);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NET_6LO_IPHC_SAM_01:
|
case NET_6LO_IPHC_SAM_01:
|
||||||
NET_DBG("SAM_01 last 64 bits are inlined");
|
NET_DBG("SAM_01 last 64 bits are inlined");
|
||||||
|
|
||||||
memmove(&ipv6->src.s6_addr[8], cursor, 8);
|
memmove(&src_ip.s6_addr[8], cursor, 8);
|
||||||
cursor += 8U;
|
cursor += 8U;
|
||||||
|
|
||||||
ipv6->src.s6_addr32[0] = 0x00;
|
src_ip.s6_addr32[0] = 0x00;
|
||||||
ipv6->src.s6_addr32[1] = 0x00;
|
src_ip.s6_addr32[1] = 0x00;
|
||||||
ipv6->src.s6_addr[0] = 0xFE;
|
src_ip.s6_addr[0] = 0xFE;
|
||||||
ipv6->src.s6_addr[1] = 0x80;
|
src_ip.s6_addr[1] = 0x80;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NET_6LO_IPHC_SAM_10:
|
case NET_6LO_IPHC_SAM_10:
|
||||||
NET_DBG("SAM_10 src addr 16 bit compressed");
|
NET_DBG("SAM_10 src addr 16 bit compressed");
|
||||||
|
|
||||||
memmove(&ipv6->src.s6_addr[14], cursor, 2);
|
memmove(&src_ip.s6_addr[14], cursor, 2);
|
||||||
cursor += 2U;
|
cursor += 2U;
|
||||||
ipv6->src.s6_addr16[6] = 0x00;
|
src_ip.s6_addr16[6] = 0x00;
|
||||||
|
|
||||||
ipv6->src.s6_addr32[0] = 0x00;
|
src_ip.s6_addr32[0] = 0x00;
|
||||||
ipv6->src.s6_addr32[1] = 0x00;
|
src_ip.s6_addr32[1] = 0x00;
|
||||||
ipv6->src.s6_addr32[2] = 0x00;
|
src_ip.s6_addr32[2] = 0x00;
|
||||||
ipv6->src.s6_addr[0] = 0xFE;
|
src_ip.s6_addr[0] = 0xFE;
|
||||||
ipv6->src.s6_addr[1] = 0x80;
|
src_ip.s6_addr[1] = 0x80;
|
||||||
ipv6->src.s6_addr[11] = 0xFF;
|
src_ip.s6_addr[11] = 0xFF;
|
||||||
ipv6->src.s6_addr[12] = 0xFE;
|
src_ip.s6_addr[12] = 0xFE;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NET_6LO_IPHC_SAM_11:
|
case NET_6LO_IPHC_SAM_11:
|
||||||
NET_DBG("SAM_11 generate src addr from ll");
|
NET_DBG("SAM_11 generate src addr from ll");
|
||||||
|
|
||||||
net_ipv6_addr_create_iid(&ipv6->src, net_pkt_lladdr_src(pkt));
|
net_ipv6_addr_create_iid(&src_ip, net_pkt_lladdr_src(pkt));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
net_ipv6_addr_copy_raw(ipv6->src, (uint8_t *)&src_ip);
|
||||||
|
|
||||||
return cursor;
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -975,15 +987,19 @@ static inline uint8_t *uncompress_sa_ctx(uint16_t iphc, uint8_t *cursor,
|
||||||
struct net_6lo_context *ctx,
|
struct net_6lo_context *ctx,
|
||||||
struct net_pkt *pkt)
|
struct net_pkt *pkt)
|
||||||
{
|
{
|
||||||
|
struct in6_addr src_ip;
|
||||||
|
|
||||||
|
net_ipv6_addr_copy_raw((uint8_t *)&src_ip, ipv6->src);
|
||||||
|
|
||||||
switch (iphc & NET_6LO_IPHC_SAM_MASK) {
|
switch (iphc & NET_6LO_IPHC_SAM_MASK) {
|
||||||
case NET_6LO_IPHC_SAM_01:
|
case NET_6LO_IPHC_SAM_01:
|
||||||
NET_DBG("SAM_01 last 64 bits are inlined");
|
NET_DBG("SAM_01 last 64 bits are inlined");
|
||||||
|
|
||||||
/* First 8 bytes are from context */
|
/* First 8 bytes are from context */
|
||||||
memmove(&ipv6->src.s6_addr[0], &ctx->prefix.s6_addr[0], 8);
|
memmove(&src_ip.s6_addr[0], &ctx->prefix.s6_addr[0], 8);
|
||||||
|
|
||||||
/* And the rest are carried in-line*/
|
/* And the rest are carried in-line*/
|
||||||
memmove(&ipv6->src.s6_addr[8], cursor, 8);
|
memmove(&src_ip.s6_addr[8], cursor, 8);
|
||||||
cursor += 8U;
|
cursor += 8U;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -991,16 +1007,16 @@ static inline uint8_t *uncompress_sa_ctx(uint16_t iphc, uint8_t *cursor,
|
||||||
NET_DBG("SAM_10 src addr 16 bit compressed");
|
NET_DBG("SAM_10 src addr 16 bit compressed");
|
||||||
|
|
||||||
/* 16 bit carried in-line */
|
/* 16 bit carried in-line */
|
||||||
memmove(&ipv6->src.s6_addr[14], cursor, 2);
|
memmove(&src_ip.s6_addr[14], cursor, 2);
|
||||||
cursor += 2U;
|
cursor += 2U;
|
||||||
|
|
||||||
/* First 8 bytes are from context */
|
/* First 8 bytes are from context */
|
||||||
memmove(&ipv6->src.s6_addr[0], &ctx->prefix.s6_addr[0], 8);
|
memmove(&src_ip.s6_addr[0], &ctx->prefix.s6_addr[0], 8);
|
||||||
|
|
||||||
ipv6->src.s6_addr32[2] = 0x00;
|
src_ip.s6_addr32[2] = 0x00;
|
||||||
ipv6->src.s6_addr16[6] = 0x00;
|
src_ip.s6_addr16[6] = 0x00;
|
||||||
ipv6->src.s6_addr[11] = 0xFF;
|
src_ip.s6_addr[11] = 0xFF;
|
||||||
ipv6->src.s6_addr[12] = 0xFE;
|
src_ip.s6_addr[12] = 0xFE;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NET_6LO_IPHC_SAM_11:
|
case NET_6LO_IPHC_SAM_11:
|
||||||
|
@ -1011,16 +1027,18 @@ static inline uint8_t *uncompress_sa_ctx(uint16_t iphc, uint8_t *cursor,
|
||||||
* the encapsulating header.
|
* the encapsulating header.
|
||||||
* (e.g., 802.15.4 or IPv6 source address).
|
* (e.g., 802.15.4 or IPv6 source address).
|
||||||
*/
|
*/
|
||||||
net_ipv6_addr_create_iid(&ipv6->src, net_pkt_lladdr_src(pkt));
|
net_ipv6_addr_create_iid(&src_ip, net_pkt_lladdr_src(pkt));
|
||||||
|
|
||||||
/* net_ipv6_addr_create_iid will copy first 8 bytes
|
/* net_ipv6_addr_create_iid will copy first 8 bytes
|
||||||
* as link local prefix.
|
* as link local prefix.
|
||||||
* Overwrite first 8 bytes from context prefix here.
|
* Overwrite first 8 bytes from context prefix here.
|
||||||
*/
|
*/
|
||||||
memmove(&ipv6->src.s6_addr[0], &ctx->prefix.s6_addr[0], 8);
|
memmove(&src_ip.s6_addr[0], &ctx->prefix.s6_addr[0], 8);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
net_ipv6_addr_copy_raw(ipv6->src, (uint8_t *)&src_ip);
|
||||||
|
|
||||||
return cursor;
|
return cursor;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1029,8 +1047,12 @@ static inline uint8_t *uncompress_sa_ctx(uint16_t iphc, uint8_t *cursor,
|
||||||
static inline uint8_t *uncompress_da_mcast(uint16_t iphc, uint8_t *cursor,
|
static inline uint8_t *uncompress_da_mcast(uint16_t iphc, uint8_t *cursor,
|
||||||
struct net_ipv6_hdr *ipv6)
|
struct net_ipv6_hdr *ipv6)
|
||||||
{
|
{
|
||||||
|
struct in6_addr dst_ip;
|
||||||
|
|
||||||
NET_DBG("Dst is multicast");
|
NET_DBG("Dst is multicast");
|
||||||
|
|
||||||
|
net_ipv6_addr_copy_raw((uint8_t *)&dst_ip, ipv6->dst);
|
||||||
|
|
||||||
if (iphc & NET_6LO_IPHC_DAC_1) {
|
if (iphc & NET_6LO_IPHC_DAC_1) {
|
||||||
NET_WARN("Unsupported DAM options");
|
NET_WARN("Unsupported DAM options");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1047,59 +1069,61 @@ static inline uint8_t *uncompress_da_mcast(uint16_t iphc, uint8_t *cursor,
|
||||||
case NET_6LO_IPHC_DAM_00:
|
case NET_6LO_IPHC_DAM_00:
|
||||||
NET_DBG("DAM_00 full dst addr inlined");
|
NET_DBG("DAM_00 full dst addr inlined");
|
||||||
|
|
||||||
memmove(&ipv6->dst.s6_addr[0], cursor,
|
memmove(&dst_ip.s6_addr[0], cursor,
|
||||||
sizeof(ipv6->dst.s6_addr));
|
sizeof(dst_ip.s6_addr));
|
||||||
|
|
||||||
cursor += sizeof(ipv6->dst.s6_addr);
|
cursor += sizeof(dst_ip.s6_addr);
|
||||||
break;
|
break;
|
||||||
case NET_6LO_IPHC_DAM_01:
|
case NET_6LO_IPHC_DAM_01:
|
||||||
NET_DBG("DAM_01 2nd byte and last five bytes");
|
NET_DBG("DAM_01 2nd byte and last five bytes");
|
||||||
|
|
||||||
ipv6->dst.s6_addr[1] = *cursor;
|
dst_ip.s6_addr[1] = *cursor;
|
||||||
cursor++;
|
cursor++;
|
||||||
memmove(&ipv6->dst.s6_addr[11], cursor, 5);
|
memmove(&dst_ip.s6_addr[11], cursor, 5);
|
||||||
cursor += 5U;
|
cursor += 5U;
|
||||||
|
|
||||||
|
|
||||||
ipv6->dst.s6_addr[0] = 0xFF;
|
dst_ip.s6_addr[0] = 0xFF;
|
||||||
ipv6->dst.s6_addr16[1] = 0x00;
|
dst_ip.s6_addr16[1] = 0x00;
|
||||||
ipv6->dst.s6_addr32[1] = 0x00;
|
dst_ip.s6_addr32[1] = 0x00;
|
||||||
ipv6->dst.s6_addr[10] = 0x00;
|
dst_ip.s6_addr[10] = 0x00;
|
||||||
ipv6->dst.s6_addr16[4] = 0x00;
|
dst_ip.s6_addr16[4] = 0x00;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NET_6LO_IPHC_DAM_10:
|
case NET_6LO_IPHC_DAM_10:
|
||||||
NET_DBG("DAM_10 2nd byte and last three bytes");
|
NET_DBG("DAM_10 2nd byte and last three bytes");
|
||||||
|
|
||||||
ipv6->dst.s6_addr[1] = *cursor;
|
dst_ip.s6_addr[1] = *cursor;
|
||||||
cursor++;
|
cursor++;
|
||||||
memmove(&ipv6->dst.s6_addr[13], cursor, 3);
|
memmove(&dst_ip.s6_addr[13], cursor, 3);
|
||||||
cursor += 3U;
|
cursor += 3U;
|
||||||
|
|
||||||
ipv6->dst.s6_addr[0] = 0xFF;
|
dst_ip.s6_addr[0] = 0xFF;
|
||||||
ipv6->dst.s6_addr16[1] = 0x00;
|
dst_ip.s6_addr16[1] = 0x00;
|
||||||
ipv6->dst.s6_addr32[1] = 0x00;
|
dst_ip.s6_addr32[1] = 0x00;
|
||||||
ipv6->dst.s6_addr32[2] = 0x00;
|
dst_ip.s6_addr32[2] = 0x00;
|
||||||
ipv6->dst.s6_addr[12] = 0x00;
|
dst_ip.s6_addr[12] = 0x00;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NET_6LO_IPHC_DAM_11:
|
case NET_6LO_IPHC_DAM_11:
|
||||||
NET_DBG("DAM_11 8 bit compressed");
|
NET_DBG("DAM_11 8 bit compressed");
|
||||||
|
|
||||||
ipv6->dst.s6_addr[15] = *cursor;
|
dst_ip.s6_addr[15] = *cursor;
|
||||||
cursor++;
|
cursor++;
|
||||||
ipv6->dst.s6_addr[14] = 0x00;
|
dst_ip.s6_addr[14] = 0x00;
|
||||||
|
|
||||||
ipv6->dst.s6_addr32[0] = 0x00;
|
dst_ip.s6_addr32[0] = 0x00;
|
||||||
ipv6->dst.s6_addr32[1] = 0x00;
|
dst_ip.s6_addr32[1] = 0x00;
|
||||||
ipv6->dst.s6_addr32[2] = 0x00;
|
dst_ip.s6_addr32[2] = 0x00;
|
||||||
ipv6->dst.s6_addr16[6] = 0x00;
|
dst_ip.s6_addr16[6] = 0x00;
|
||||||
ipv6->dst.s6_addr[0] = 0xFF;
|
dst_ip.s6_addr[0] = 0xFF;
|
||||||
ipv6->dst.s6_addr[1] = 0x02;
|
dst_ip.s6_addr[1] = 0x02;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
net_ipv6_addr_copy_raw(ipv6->dst, (uint8_t *)&dst_ip);
|
||||||
|
|
||||||
return cursor;
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1108,55 +1132,59 @@ static inline uint8_t *uncompress_da(uint16_t iphc, uint8_t *cursor,
|
||||||
struct net_ipv6_hdr *ipv6,
|
struct net_ipv6_hdr *ipv6,
|
||||||
struct net_pkt *pkt)
|
struct net_pkt *pkt)
|
||||||
{
|
{
|
||||||
|
struct in6_addr dst_ip;
|
||||||
|
|
||||||
NET_DBG("DAC_0");
|
NET_DBG("DAC_0");
|
||||||
|
|
||||||
|
net_ipv6_addr_copy_raw((uint8_t *)&dst_ip, ipv6->dst);
|
||||||
|
|
||||||
switch (iphc & NET_6LO_IPHC_DAM_MASK) {
|
switch (iphc & NET_6LO_IPHC_DAM_MASK) {
|
||||||
case NET_6LO_IPHC_DAM_00:
|
case NET_6LO_IPHC_DAM_00:
|
||||||
NET_DBG("DAM_00 full dst addr inlined");
|
NET_DBG("DAM_00 full dst addr inlined");
|
||||||
|
|
||||||
memmove(&ipv6->dst.s6_addr[0], cursor,
|
memmove(&dst_ip.s6_addr[0], cursor,
|
||||||
sizeof(ipv6->dst.s6_addr));
|
sizeof(dst_ip.s6_addr));
|
||||||
cursor += sizeof(ipv6->dst.s6_addr);
|
cursor += sizeof(dst_ip.s6_addr);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NET_6LO_IPHC_DAM_01:
|
case NET_6LO_IPHC_DAM_01:
|
||||||
NET_DBG("DAM_01 last 64 bits are inlined");
|
NET_DBG("DAM_01 last 64 bits are inlined");
|
||||||
|
|
||||||
memmove(&ipv6->dst.s6_addr[8], cursor, 8);
|
memmove(&dst_ip.s6_addr[8], cursor, 8);
|
||||||
cursor += 8U;
|
cursor += 8U;
|
||||||
|
|
||||||
ipv6->dst.s6_addr32[0] = 0x00;
|
dst_ip.s6_addr32[0] = 0x00;
|
||||||
ipv6->dst.s6_addr32[1] = 0x00;
|
dst_ip.s6_addr32[1] = 0x00;
|
||||||
ipv6->dst.s6_addr[0] = 0xFE;
|
dst_ip.s6_addr[0] = 0xFE;
|
||||||
ipv6->dst.s6_addr[1] = 0x80;
|
dst_ip.s6_addr[1] = 0x80;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NET_6LO_IPHC_DAM_10:
|
case NET_6LO_IPHC_DAM_10:
|
||||||
NET_DBG("DAM_10 dst addr 16 bit compressed");
|
NET_DBG("DAM_10 dst addr 16 bit compressed");
|
||||||
|
|
||||||
memmove(&ipv6->dst.s6_addr[14], cursor, 2);
|
memmove(&dst_ip.s6_addr[14], cursor, 2);
|
||||||
cursor += 2U;
|
cursor += 2U;
|
||||||
|
|
||||||
ipv6->dst.s6_addr32[0] = 0x00;
|
dst_ip.s6_addr32[0] = 0x00;
|
||||||
ipv6->dst.s6_addr32[1] = 0x00;
|
dst_ip.s6_addr32[1] = 0x00;
|
||||||
ipv6->dst.s6_addr32[2] = 0x00;
|
dst_ip.s6_addr32[2] = 0x00;
|
||||||
ipv6->dst.s6_addr16[6] = 0x00;
|
dst_ip.s6_addr16[6] = 0x00;
|
||||||
ipv6->dst.s6_addr[0] = 0xFE;
|
dst_ip.s6_addr[0] = 0xFE;
|
||||||
ipv6->dst.s6_addr[1] = 0x80;
|
dst_ip.s6_addr[1] = 0x80;
|
||||||
ipv6->dst.s6_addr[11] = 0xFF;
|
dst_ip.s6_addr[11] = 0xFF;
|
||||||
ipv6->dst.s6_addr[12] = 0xFE;
|
dst_ip.s6_addr[12] = 0xFE;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NET_6LO_IPHC_DAM_11:
|
case NET_6LO_IPHC_DAM_11:
|
||||||
NET_DBG("DAM_11 generate dst addr from ll");
|
NET_DBG("DAM_11 generate dst addr from ll");
|
||||||
|
|
||||||
net_ipv6_addr_create_iid(&ipv6->dst, net_pkt_lladdr_dst(pkt));
|
net_ipv6_addr_create_iid(&dst_ip, net_pkt_lladdr_dst(pkt));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
net_ipv6_addr_copy_raw(ipv6->dst, (uint8_t *)&dst_ip);
|
||||||
|
|
||||||
return cursor;
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1166,34 +1194,38 @@ static inline uint8_t *uncompress_da_ctx(uint16_t iphc, uint8_t *cursor,
|
||||||
struct net_6lo_context *ctx,
|
struct net_6lo_context *ctx,
|
||||||
struct net_pkt *pkt)
|
struct net_pkt *pkt)
|
||||||
{
|
{
|
||||||
|
struct in6_addr dst_ip;
|
||||||
|
|
||||||
NET_DBG("DAC_1");
|
NET_DBG("DAC_1");
|
||||||
|
|
||||||
|
net_ipv6_addr_copy_raw((uint8_t *)&dst_ip, ipv6->dst);
|
||||||
|
|
||||||
switch (iphc & NET_6LO_IPHC_DAM_MASK) {
|
switch (iphc & NET_6LO_IPHC_DAM_MASK) {
|
||||||
case NET_6LO_IPHC_DAM_01:
|
case NET_6LO_IPHC_DAM_01:
|
||||||
NET_DBG("DAM_01 last 64 bits are inlined");
|
NET_DBG("DAM_01 last 64 bits are inlined");
|
||||||
|
|
||||||
/* Last 8 bytes carried in-line */
|
/* Last 8 bytes carried in-line */
|
||||||
memmove(&ipv6->dst.s6_addr[8], cursor, 8);
|
memmove(&dst_ip.s6_addr[8], cursor, 8);
|
||||||
cursor += 8U;
|
cursor += 8U;
|
||||||
|
|
||||||
/* First 8 bytes are from context */
|
/* First 8 bytes are from context */
|
||||||
memmove(&ipv6->dst.s6_addr[0], &ctx->prefix.s6_addr[0], 8);
|
memmove(&dst_ip.s6_addr[0], &ctx->prefix.s6_addr[0], 8);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NET_6LO_IPHC_DAM_10:
|
case NET_6LO_IPHC_DAM_10:
|
||||||
NET_DBG("DAM_10 src addr 16 bit compressed");
|
NET_DBG("DAM_10 src addr 16 bit compressed");
|
||||||
|
|
||||||
/* 16 bit carried in-line */
|
/* 16 bit carried in-line */
|
||||||
memmove(&ipv6->dst.s6_addr[14], cursor, 2);
|
memmove(&dst_ip.s6_addr[14], cursor, 2);
|
||||||
cursor += 2U;
|
cursor += 2U;
|
||||||
|
|
||||||
/* First 8 bytes are from context */
|
/* First 8 bytes are from context */
|
||||||
memmove(&ipv6->dst.s6_addr[0], &ctx->prefix.s6_addr[0], 8);
|
memmove(&dst_ip.s6_addr[0], &ctx->prefix.s6_addr[0], 8);
|
||||||
|
|
||||||
ipv6->dst.s6_addr32[2] = 0x00;
|
dst_ip.s6_addr32[2] = 0x00;
|
||||||
ipv6->dst.s6_addr16[6] = 0x00;
|
dst_ip.s6_addr16[6] = 0x00;
|
||||||
ipv6->dst.s6_addr[11] = 0xFF;
|
dst_ip.s6_addr[11] = 0xFF;
|
||||||
ipv6->dst.s6_addr[12] = 0xFE;
|
dst_ip.s6_addr[12] = 0xFE;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NET_6LO_IPHC_DAM_11:
|
case NET_6LO_IPHC_DAM_11:
|
||||||
|
@ -1204,17 +1236,19 @@ static inline uint8_t *uncompress_da_ctx(uint16_t iphc, uint8_t *cursor,
|
||||||
* the encapsulating header.
|
* the encapsulating header.
|
||||||
* (e.g., 802.15.4 or IPv6 source address).
|
* (e.g., 802.15.4 or IPv6 source address).
|
||||||
*/
|
*/
|
||||||
net_ipv6_addr_create_iid(&ipv6->dst, net_pkt_lladdr_dst(pkt));
|
net_ipv6_addr_create_iid(&dst_ip, net_pkt_lladdr_dst(pkt));
|
||||||
|
|
||||||
/* net_ipv6_addr_create_iid will copy first 8 bytes
|
/* net_ipv6_addr_create_iid will copy first 8 bytes
|
||||||
* as link local prefix.
|
* as link local prefix.
|
||||||
* Overwrite first 8 bytes from context prefix here.
|
* Overwrite first 8 bytes from context prefix here.
|
||||||
*/
|
*/
|
||||||
memmove(&ipv6->dst.s6_addr[0], &ctx->prefix.s6_addr[0], 8);
|
memmove(&dst_ip.s6_addr[0], &ctx->prefix.s6_addr[0], 8);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
net_ipv6_addr_copy_raw(ipv6->dst, (uint8_t *)&dst_ip);
|
||||||
|
|
||||||
return cursor;
|
return cursor;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1406,8 +1440,8 @@ static bool uncompress_IPHC_header(struct net_pkt *pkt)
|
||||||
|
|
||||||
if ((iphc & NET_6LO_IPHC_SAM_MASK) == NET_6LO_IPHC_SAM_00) {
|
if ((iphc & NET_6LO_IPHC_SAM_MASK) == NET_6LO_IPHC_SAM_00) {
|
||||||
NET_DBG("SAM_00 unspecified address");
|
NET_DBG("SAM_00 unspecified address");
|
||||||
memset(&ipv6->src.s6_addr[0], 0,
|
memset(&ipv6->src[0], 0,
|
||||||
sizeof(ipv6->src.s6_addr));
|
sizeof(ipv6->src));
|
||||||
} else if (IS_ENABLED(CONFIG_NET_6LO_CONTEXT)) {
|
} else if (IS_ENABLED(CONFIG_NET_6LO_CONTEXT)) {
|
||||||
#if defined(CONFIG_NET_6LO_CONTEXT)
|
#if defined(CONFIG_NET_6LO_CONTEXT)
|
||||||
if (!src) {
|
if (!src) {
|
||||||
|
|
|
@ -420,18 +420,18 @@ static bool conn_addr_cmp(struct net_pkt *pkt,
|
||||||
if (IS_ENABLED(CONFIG_NET_IPV6) &&
|
if (IS_ENABLED(CONFIG_NET_IPV6) &&
|
||||||
net_pkt_family(pkt) == AF_INET6 &&
|
net_pkt_family(pkt) == AF_INET6 &&
|
||||||
addr->sa_family == AF_INET6) {
|
addr->sa_family == AF_INET6) {
|
||||||
struct in6_addr *addr6;
|
uint8_t *addr6;
|
||||||
|
|
||||||
if (is_remote) {
|
if (is_remote) {
|
||||||
addr6 = &ip_hdr->ipv6->src;
|
addr6 = ip_hdr->ipv6->src;
|
||||||
} else {
|
} else {
|
||||||
addr6 = &ip_hdr->ipv6->dst;
|
addr6 = ip_hdr->ipv6->dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!net_ipv6_is_addr_unspecified(
|
if (!net_ipv6_is_addr_unspecified(
|
||||||
&net_sin6(addr)->sin6_addr)) {
|
&net_sin6(addr)->sin6_addr)) {
|
||||||
if (!net_ipv6_addr_cmp(&net_sin6(addr)->sin6_addr,
|
if (!net_ipv6_addr_cmp_raw((uint8_t *)&net_sin6(addr)->sin6_addr,
|
||||||
addr6)) {
|
addr6)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -501,9 +501,9 @@ static bool conn_are_end_points_valid(struct net_pkt *pkt,
|
||||||
}
|
}
|
||||||
} else if (IS_ENABLED(CONFIG_NET_IPV6) &&
|
} else if (IS_ENABLED(CONFIG_NET_IPV6) &&
|
||||||
net_pkt_family(pkt) == AF_INET6) {
|
net_pkt_family(pkt) == AF_INET6) {
|
||||||
if (net_ipv6_addr_cmp(&ip_hdr->ipv6->src,
|
if (net_ipv6_addr_cmp_raw(ip_hdr->ipv6->src,
|
||||||
&ip_hdr->ipv6->dst) ||
|
ip_hdr->ipv6->dst) ||
|
||||||
net_ipv6_is_my_addr(&ip_hdr->ipv6->src)) {
|
net_ipv6_is_my_addr((struct in6_addr *)ip_hdr->ipv6->src)) {
|
||||||
my_src_addr = true;
|
my_src_addr = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -622,7 +622,7 @@ enum net_verdict net_conn_input(struct net_pkt *pkt,
|
||||||
}
|
}
|
||||||
} else if (IS_ENABLED(CONFIG_NET_IPV6) &&
|
} else if (IS_ENABLED(CONFIG_NET_IPV6) &&
|
||||||
net_pkt_family(pkt) == AF_INET6) {
|
net_pkt_family(pkt) == AF_INET6) {
|
||||||
if (net_ipv6_is_addr_mcast(&ip_hdr->ipv6->dst)) {
|
if (net_ipv6_is_addr_mcast((struct in6_addr *)ip_hdr->ipv6->dst)) {
|
||||||
is_mcast_pkt = true;
|
is_mcast_pkt = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,11 +132,11 @@ enum net_verdict icmpv6_handle_echo_request(struct net_pkt *pkt,
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (net_ipv6_is_addr_mcast(&ip_hdr->dst)) {
|
if (net_ipv6_is_addr_mcast((struct in6_addr *)ip_hdr->dst)) {
|
||||||
src = net_if_ipv6_select_src_addr(net_pkt_iface(pkt),
|
src = net_if_ipv6_select_src_addr(net_pkt_iface(pkt),
|
||||||
&ip_hdr->dst);
|
(struct in6_addr *)ip_hdr->dst);
|
||||||
} else {
|
} else {
|
||||||
src = &ip_hdr->dst;
|
src = (struct in6_addr *)ip_hdr->dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We must not set the destination ll address here but trust
|
/* We must not set the destination ll address here but trust
|
||||||
|
@ -146,7 +146,7 @@ enum net_verdict icmpv6_handle_echo_request(struct net_pkt *pkt,
|
||||||
net_pkt_lladdr_dst(reply)->addr = NULL;
|
net_pkt_lladdr_dst(reply)->addr = NULL;
|
||||||
net_pkt_lladdr_src(reply)->addr = NULL;
|
net_pkt_lladdr_src(reply)->addr = NULL;
|
||||||
|
|
||||||
if (net_ipv6_create(reply, src, &ip_hdr->src)) {
|
if (net_ipv6_create(reply, src, (struct in6_addr *)ip_hdr->src)) {
|
||||||
NET_DBG("DROP: wrong buffer");
|
NET_DBG("DROP: wrong buffer");
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
|
@ -279,14 +279,14 @@ int net_icmpv6_send_error(struct net_pkt *orig, uint8_t type, uint8_t code,
|
||||||
net_pkt_lladdr_src(pkt)->len = net_pkt_lladdr_dst(orig)->len;
|
net_pkt_lladdr_src(pkt)->len = net_pkt_lladdr_dst(orig)->len;
|
||||||
net_pkt_lladdr_dst(pkt)->len = net_pkt_lladdr_src(orig)->len;
|
net_pkt_lladdr_dst(pkt)->len = net_pkt_lladdr_src(orig)->len;
|
||||||
|
|
||||||
if (net_ipv6_is_addr_mcast(&ip_hdr->dst)) {
|
if (net_ipv6_is_addr_mcast((struct in6_addr *)ip_hdr->dst)) {
|
||||||
src = net_if_ipv6_select_src_addr(net_pkt_iface(pkt),
|
src = net_if_ipv6_select_src_addr(net_pkt_iface(pkt),
|
||||||
&ip_hdr->dst);
|
(struct in6_addr *)ip_hdr->dst);
|
||||||
} else {
|
} else {
|
||||||
src = &ip_hdr->dst;
|
src = (struct in6_addr *)ip_hdr->dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (net_ipv6_create(pkt, src, &ip_hdr->src) ||
|
if (net_ipv6_create(pkt, src, (struct in6_addr *)ip_hdr->src) ||
|
||||||
net_icmpv6_create(pkt, type, code)) {
|
net_icmpv6_create(pkt, type, code)) {
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,8 +75,8 @@ int net_ipv6_create(struct net_pkt *pkt,
|
||||||
net_if_ipv6_get_hop_limit(net_pkt_iface(pkt));
|
net_if_ipv6_get_hop_limit(net_pkt_iface(pkt));
|
||||||
}
|
}
|
||||||
|
|
||||||
net_ipaddr_copy(&ipv6_hdr->dst, dst);
|
net_ipv6_addr_copy_raw(ipv6_hdr->dst, (uint8_t *)dst);
|
||||||
net_ipaddr_copy(&ipv6_hdr->src, src);
|
net_ipv6_addr_copy_raw(ipv6_hdr->src, (uint8_t *)src);
|
||||||
|
|
||||||
net_pkt_set_ip_hdr_len(pkt, sizeof(struct net_ipv6_hdr));
|
net_pkt_set_ip_hdr_len(pkt, sizeof(struct net_ipv6_hdr));
|
||||||
net_pkt_set_ipv6_ext_len(pkt, 0);
|
net_pkt_set_ipv6_ext_len(pkt, 0);
|
||||||
|
@ -153,7 +153,7 @@ static inline bool ipv6_drop_on_unknown_option(struct net_pkt *pkt,
|
||||||
case 0x40:
|
case 0x40:
|
||||||
break;
|
break;
|
||||||
case 0xc0:
|
case 0xc0:
|
||||||
if (net_ipv6_is_addr_mcast(&hdr->dst)) {
|
if (net_ipv6_is_addr_mcast((struct in6_addr *)hdr->dst)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,21 +290,23 @@ static enum net_verdict ipv6_route_packet(struct net_pkt *pkt,
|
||||||
|
|
||||||
/* Check if the packet can be routed */
|
/* Check if the packet can be routed */
|
||||||
if (IS_ENABLED(CONFIG_NET_ROUTING)) {
|
if (IS_ENABLED(CONFIG_NET_ROUTING)) {
|
||||||
found = net_route_get_info(NULL, &hdr->dst, &route,
|
found = net_route_get_info(NULL, (struct in6_addr *)hdr->dst,
|
||||||
&nexthop);
|
&route, &nexthop);
|
||||||
} else {
|
} else {
|
||||||
found = net_route_get_info(net_pkt_iface(pkt),
|
found = net_route_get_info(net_pkt_iface(pkt),
|
||||||
&hdr->dst, &route, &nexthop);
|
(struct in6_addr *)hdr->dst,
|
||||||
|
&route, &nexthop);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_NET_ROUTING) &&
|
if (IS_ENABLED(CONFIG_NET_ROUTING) &&
|
||||||
(net_ipv6_is_ll_addr(&hdr->src) ||
|
(net_ipv6_is_ll_addr((struct in6_addr *)hdr->src) ||
|
||||||
net_ipv6_is_ll_addr(&hdr->dst))) {
|
net_ipv6_is_ll_addr((struct in6_addr *)hdr->dst))) {
|
||||||
/* RFC 4291 ch 2.5.6 */
|
/* RFC 4291 ch 2.5.6 */
|
||||||
ipv6_no_route_info(pkt, &hdr->src, &hdr->dst);
|
ipv6_no_route_info(pkt, (struct in6_addr *)hdr->src,
|
||||||
|
(struct in6_addr *)hdr->dst);
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,7 +329,8 @@ static enum net_verdict ipv6_route_packet(struct net_pkt *pkt,
|
||||||
pkt, net_pkt_orig_iface(pkt),
|
pkt, net_pkt_orig_iface(pkt),
|
||||||
net_pkt_iface(pkt));
|
net_pkt_iface(pkt));
|
||||||
|
|
||||||
add_route(net_pkt_orig_iface(pkt), &hdr->src, 128);
|
add_route(net_pkt_orig_iface(pkt),
|
||||||
|
(struct in6_addr *)hdr->src, 128);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = net_route_packet(pkt, nexthop);
|
ret = net_route_packet(pkt, nexthop);
|
||||||
|
@ -343,7 +346,7 @@ static enum net_verdict ipv6_route_packet(struct net_pkt *pkt,
|
||||||
struct net_if *iface = NULL;
|
struct net_if *iface = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (net_if_ipv6_addr_onlink(&iface, &hdr->dst)) {
|
if (net_if_ipv6_addr_onlink(&iface, (struct in6_addr *)hdr->dst)) {
|
||||||
ret = net_route_packet_if(pkt, iface);
|
ret = net_route_packet_if(pkt, iface);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
NET_DBG("Cannot re-route pkt %p "
|
NET_DBG("Cannot re-route pkt %p "
|
||||||
|
@ -385,9 +388,9 @@ static enum net_verdict ipv6_forward_mcast_packet(struct net_pkt *pkt,
|
||||||
/* check if routing loop could be created or if the destination is of
|
/* check if routing loop could be created or if the destination is of
|
||||||
* interface local scope or if from link local source
|
* interface local scope or if from link local source
|
||||||
*/
|
*/
|
||||||
if (net_ipv6_is_addr_mcast(&hdr->src) ||
|
if (net_ipv6_is_addr_mcast((struct in6_addr *)hdr->src) ||
|
||||||
net_ipv6_is_addr_mcast_iface(&hdr->dst) ||
|
net_ipv6_is_addr_mcast_iface((struct in6_addr *)hdr->dst) ||
|
||||||
net_ipv6_is_ll_addr(&hdr->src)) {
|
net_ipv6_is_ll_addr((struct in6_addr *)hdr->src)) {
|
||||||
return NET_CONTINUE;
|
return NET_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,29 +467,30 @@ enum net_verdict net_ipv6_input(struct net_pkt *pkt, bool is_loopback)
|
||||||
log_strdup(net_sprint_ipv6_addr(&hdr->src)),
|
log_strdup(net_sprint_ipv6_addr(&hdr->src)),
|
||||||
log_strdup(net_sprint_ipv6_addr(&hdr->dst)));
|
log_strdup(net_sprint_ipv6_addr(&hdr->dst)));
|
||||||
|
|
||||||
if (net_ipv6_is_addr_unspecified(&hdr->src)) {
|
if (net_ipv6_is_addr_unspecified((struct in6_addr *)hdr->src)) {
|
||||||
NET_DBG("DROP: src addr is %s", "unspecified");
|
NET_DBG("DROP: src addr is %s", "unspecified");
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (net_ipv6_is_addr_mcast(&hdr->src) ||
|
if (net_ipv6_is_addr_mcast((struct in6_addr *)hdr->src) ||
|
||||||
net_ipv6_is_addr_mcast_scope(&hdr->dst, 0)) {
|
net_ipv6_is_addr_mcast_scope((struct in6_addr *)hdr->dst, 0)) {
|
||||||
NET_DBG("DROP: multicast packet");
|
NET_DBG("DROP: multicast packet");
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_loopback) {
|
if (!is_loopback) {
|
||||||
if (net_ipv6_is_addr_loopback(&hdr->dst) ||
|
if (net_ipv6_is_addr_loopback((struct in6_addr *)hdr->dst) ||
|
||||||
net_ipv6_is_addr_loopback(&hdr->src)) {
|
net_ipv6_is_addr_loopback((struct in6_addr *)hdr->src)) {
|
||||||
NET_DBG("DROP: ::1 packet");
|
NET_DBG("DROP: ::1 packet");
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (net_ipv6_is_addr_mcast_iface(&hdr->dst) ||
|
if (net_ipv6_is_addr_mcast_iface((struct in6_addr *)hdr->dst) ||
|
||||||
(net_ipv6_is_addr_mcast_group(
|
(net_ipv6_is_addr_mcast_group(
|
||||||
&hdr->dst, net_ipv6_unspecified_address()) &&
|
(struct in6_addr *)hdr->dst,
|
||||||
(net_ipv6_is_addr_mcast_site(&hdr->dst) ||
|
net_ipv6_unspecified_address()) &&
|
||||||
net_ipv6_is_addr_mcast_org(&hdr->dst)))) {
|
(net_ipv6_is_addr_mcast_site((struct in6_addr *)hdr->dst) ||
|
||||||
|
net_ipv6_is_addr_mcast_org((struct in6_addr *)hdr->dst)))) {
|
||||||
NET_DBG("DROP: invalid scope multicast packet");
|
NET_DBG("DROP: invalid scope multicast packet");
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
|
@ -500,7 +504,7 @@ enum net_verdict net_ipv6_input(struct net_pkt *pkt, bool is_loopback)
|
||||||
net_pkt_set_family(pkt, PF_INET6);
|
net_pkt_set_family(pkt, PF_INET6);
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_NET_ROUTE_MCAST) &&
|
if (IS_ENABLED(CONFIG_NET_ROUTE_MCAST) &&
|
||||||
net_ipv6_is_addr_mcast(&hdr->dst)) {
|
net_ipv6_is_addr_mcast((struct in6_addr *)hdr->dst)) {
|
||||||
/* If the packet is a multicast packet and multicast routing
|
/* If the packet is a multicast packet and multicast routing
|
||||||
* is activated, we give the packet to the routing engine.
|
* is activated, we give the packet to the routing engine.
|
||||||
*
|
*
|
||||||
|
@ -513,8 +517,8 @@ enum net_verdict net_ipv6_input(struct net_pkt *pkt, bool is_loopback)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!net_ipv6_is_addr_mcast(&hdr->dst)) {
|
if (!net_ipv6_is_addr_mcast((struct in6_addr *)hdr->dst)) {
|
||||||
if (!net_ipv6_is_my_addr(&hdr->dst)) {
|
if (!net_ipv6_is_my_addr((struct in6_addr *)hdr->dst)) {
|
||||||
if (ipv6_route_packet(pkt, hdr) == NET_OK) {
|
if (ipv6_route_packet(pkt, hdr) == NET_OK) {
|
||||||
return NET_OK;
|
return NET_OK;
|
||||||
}
|
}
|
||||||
|
@ -528,16 +532,18 @@ enum net_verdict net_ipv6_input(struct net_pkt *pkt, bool is_loopback)
|
||||||
* RFC 4291 ch 2.5.6
|
* RFC 4291 ch 2.5.6
|
||||||
*/
|
*/
|
||||||
if (IS_ENABLED(CONFIG_NET_ROUTING) &&
|
if (IS_ENABLED(CONFIG_NET_ROUTING) &&
|
||||||
net_ipv6_is_ll_addr(&hdr->src) &&
|
net_ipv6_is_ll_addr((struct in6_addr *)hdr->src) &&
|
||||||
!net_if_ipv6_addr_lookup_by_iface(pkt_iface, &hdr->dst)) {
|
!net_if_ipv6_addr_lookup_by_iface(
|
||||||
ipv6_no_route_info(pkt, &hdr->src, &hdr->dst);
|
pkt_iface, (struct in6_addr *)hdr->dst)) {
|
||||||
|
ipv6_no_route_info(pkt, (struct in6_addr *)hdr->src,
|
||||||
|
(struct in6_addr *)hdr->dst);
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (net_ipv6_is_addr_mcast(&hdr->dst) &&
|
if (net_ipv6_is_addr_mcast((struct in6_addr *)hdr->dst) &&
|
||||||
!(net_ipv6_is_addr_mcast_iface(&hdr->dst) ||
|
!(net_ipv6_is_addr_mcast_iface((struct in6_addr *)hdr->dst) ||
|
||||||
net_ipv6_is_addr_mcast_link_all_nodes(&hdr->dst))) {
|
net_ipv6_is_addr_mcast_link_all_nodes((struct in6_addr *)hdr->dst))) {
|
||||||
/* If we receive a packet with a interface-local or
|
/* If we receive a packet with a interface-local or
|
||||||
* link-local all-nodes multicast destination address we
|
* link-local all-nodes multicast destination address we
|
||||||
* always have to pass it to the upper layer.
|
* always have to pass it to the upper layer.
|
||||||
|
@ -548,7 +554,8 @@ enum net_verdict net_ipv6_input(struct net_pkt *pkt, bool is_loopback)
|
||||||
* packet will be dropped.
|
* packet will be dropped.
|
||||||
* RFC4291 ch 2.7.1, ch 2.8
|
* RFC4291 ch 2.7.1, ch 2.8
|
||||||
*/
|
*/
|
||||||
if_mcast_addr = net_if_ipv6_maddr_lookup(&hdr->dst, &pkt_iface);
|
if_mcast_addr = net_if_ipv6_maddr_lookup(
|
||||||
|
(struct in6_addr *)hdr->dst, &pkt_iface);
|
||||||
|
|
||||||
if (!if_mcast_addr ||
|
if (!if_mcast_addr ||
|
||||||
!net_if_ipv6_maddr_is_joined(if_mcast_addr)) {
|
!net_if_ipv6_maddr_is_joined(if_mcast_addr)) {
|
||||||
|
@ -679,7 +686,7 @@ enum net_verdict net_ipv6_input(struct net_pkt *pkt, bool is_loopback)
|
||||||
struct net_addr remote_addr;
|
struct net_addr remote_addr;
|
||||||
|
|
||||||
remote_addr.family = AF_INET6;
|
remote_addr.family = AF_INET6;
|
||||||
net_ipaddr_copy(&remote_addr.in6_addr, &hdr->src);
|
net_ipv6_addr_copy_raw((uint8_t *)&remote_addr.in6_addr, hdr->src);
|
||||||
|
|
||||||
/* Get rid of the old IP header */
|
/* Get rid of the old IP header */
|
||||||
net_pkt_cursor_restore(pkt, &hdr_start);
|
net_pkt_cursor_restore(pkt, &hdr_start);
|
||||||
|
|
|
@ -491,7 +491,8 @@ enum net_verdict net_ipv6_handle_fragment_hdr(struct net_pkt *pkt,
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
|
|
||||||
reass = reassembly_get(id, &hdr->src, &hdr->dst);
|
reass = reassembly_get(id, (struct in6_addr *)hdr->src,
|
||||||
|
(struct in6_addr *)hdr->dst);
|
||||||
if (!reass) {
|
if (!reass) {
|
||||||
NET_DBG("Cannot get reassembly slot, dropping pkt %p", pkt);
|
NET_DBG("Cannot get reassembly slot, dropping pkt %p", pkt);
|
||||||
goto drop;
|
goto drop;
|
||||||
|
|
|
@ -843,9 +843,9 @@ ignore_frag_error:
|
||||||
*/
|
*/
|
||||||
if ((net_pkt_lladdr_dst(pkt)->addr &&
|
if ((net_pkt_lladdr_dst(pkt)->addr &&
|
||||||
((IS_ENABLED(CONFIG_NET_ROUTING) &&
|
((IS_ENABLED(CONFIG_NET_ROUTING) &&
|
||||||
net_ipv6_is_ll_addr(&ip_hdr->dst)) ||
|
net_ipv6_is_ll_addr((struct in6_addr *)ip_hdr->dst)) ||
|
||||||
!IS_ENABLED(CONFIG_NET_ROUTING))) ||
|
!IS_ENABLED(CONFIG_NET_ROUTING))) ||
|
||||||
net_ipv6_is_addr_mcast(&ip_hdr->dst) ||
|
net_ipv6_is_addr_mcast((struct in6_addr *)ip_hdr->dst) ||
|
||||||
/* Workaround Linux bug, see:
|
/* Workaround Linux bug, see:
|
||||||
* https://github.com/zephyrproject-rtos/zephyr/issues/3111
|
* https://github.com/zephyrproject-rtos/zephyr/issues/3111
|
||||||
*/
|
*/
|
||||||
|
@ -854,8 +854,8 @@ ignore_frag_error:
|
||||||
return NET_OK;
|
return NET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (net_if_ipv6_addr_onlink(&iface, &ip_hdr->dst)) {
|
if (net_if_ipv6_addr_onlink(&iface, (struct in6_addr *)ip_hdr->dst)) {
|
||||||
nexthop = &ip_hdr->dst;
|
nexthop = (struct in6_addr *)ip_hdr->dst;
|
||||||
net_pkt_set_iface(pkt, iface);
|
net_pkt_set_iface(pkt, iface);
|
||||||
} else {
|
} else {
|
||||||
/* We need to figure out where the destination
|
/* We need to figure out where the destination
|
||||||
|
@ -863,7 +863,8 @@ ignore_frag_error:
|
||||||
*/
|
*/
|
||||||
bool try_route = false;
|
bool try_route = false;
|
||||||
|
|
||||||
nexthop = check_route(NULL, &ip_hdr->dst, &try_route);
|
nexthop = check_route(NULL, (struct in6_addr *)ip_hdr->dst,
|
||||||
|
&try_route);
|
||||||
if (!nexthop) {
|
if (!nexthop) {
|
||||||
return NET_DROP;
|
return NET_DROP;
|
||||||
}
|
}
|
||||||
|
@ -936,7 +937,8 @@ try_send:
|
||||||
#if defined(CONFIG_NET_IPV6_ND)
|
#if defined(CONFIG_NET_IPV6_ND)
|
||||||
/* We need to send NS and wait for NA before sending the packet. */
|
/* We need to send NS and wait for NA before sending the packet. */
|
||||||
ret = net_ipv6_send_ns(net_pkt_iface(pkt), pkt,
|
ret = net_ipv6_send_ns(net_pkt_iface(pkt), pkt,
|
||||||
&ip_hdr->src, NULL, nexthop, false);
|
(struct in6_addr *)ip_hdr->src, NULL, nexthop,
|
||||||
|
false);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
/* In case of an error, the NS send function will unref
|
/* In case of an error, the NS send function will unref
|
||||||
* the pkt.
|
* the pkt.
|
||||||
|
@ -1198,7 +1200,8 @@ static enum net_verdict handle_ns_input(struct net_pkt *pkt,
|
||||||
|
|
||||||
switch (nd_opt_hdr->type) {
|
switch (nd_opt_hdr->type) {
|
||||||
case NET_ICMPV6_ND_OPT_SLLAO:
|
case NET_ICMPV6_ND_OPT_SLLAO:
|
||||||
if (net_ipv6_is_addr_unspecified(&ip_hdr->src)) {
|
if (net_ipv6_is_addr_unspecified(
|
||||||
|
(struct in6_addr *)ip_hdr->src)) {
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1245,7 +1248,7 @@ static enum net_verdict handle_ns_input(struct net_pkt *pkt,
|
||||||
nexthop = check_route(NULL, &ns_hdr->tgt, NULL);
|
nexthop = check_route(NULL, &ns_hdr->tgt, NULL);
|
||||||
if (nexthop) {
|
if (nexthop) {
|
||||||
ns_routing_info(pkt, nexthop, &ns_hdr->tgt);
|
ns_routing_info(pkt, nexthop, &ns_hdr->tgt);
|
||||||
na_dst = &ip_hdr->dst;
|
na_dst = (struct in6_addr *)ip_hdr->dst;
|
||||||
/* Note that the target is not the address of
|
/* Note that the target is not the address of
|
||||||
* the "nethop" as that is a link-local address
|
* the "nethop" as that is a link-local address
|
||||||
* which is not routable.
|
* which is not routable.
|
||||||
|
@ -1257,7 +1260,8 @@ static enum net_verdict handle_ns_input(struct net_pkt *pkt,
|
||||||
* received.
|
* received.
|
||||||
*/
|
*/
|
||||||
na_src = net_if_ipv6_select_src_addr(
|
na_src = net_if_ipv6_select_src_addr(
|
||||||
net_pkt_iface(pkt), &ip_hdr->src);
|
net_pkt_iface(pkt),
|
||||||
|
(struct in6_addr *)ip_hdr->src);
|
||||||
if (!na_src) {
|
if (!na_src) {
|
||||||
NET_DBG("DROP: No interface address "
|
NET_DBG("DROP: No interface address "
|
||||||
"for dst %s iface %p/%d",
|
"for dst %s iface %p/%d",
|
||||||
|
@ -1280,22 +1284,22 @@ static enum net_verdict handle_ns_input(struct net_pkt *pkt,
|
||||||
goto drop;
|
goto drop;
|
||||||
} else {
|
} else {
|
||||||
tgt = &ifaddr->address.in6_addr;
|
tgt = &ifaddr->address.in6_addr;
|
||||||
na_src = &ip_hdr->dst;
|
na_src = (struct in6_addr *)ip_hdr->dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
nexthop_found:
|
nexthop_found:
|
||||||
|
|
||||||
#if !defined(CONFIG_NET_IPV6_DAD)
|
#if !defined(CONFIG_NET_IPV6_DAD)
|
||||||
if (net_ipv6_is_addr_unspecified(&ip_hdr->src)) {
|
if (net_ipv6_is_addr_unspecified((struct in6_addr *)ip_hdr->src)) {
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* CONFIG_NET_IPV6_DAD */
|
#else /* CONFIG_NET_IPV6_DAD */
|
||||||
|
|
||||||
/* Do DAD */
|
/* Do DAD */
|
||||||
if (net_ipv6_is_addr_unspecified(&ip_hdr->src)) {
|
if (net_ipv6_is_addr_unspecified((struct in6_addr *)ip_hdr->src)) {
|
||||||
|
|
||||||
if (!net_ipv6_is_addr_solicited_node(&ip_hdr->dst)) {
|
if (!net_ipv6_is_addr_solicited_node((struct in6_addr *)ip_hdr->dst)) {
|
||||||
NET_DBG("DROP: Not solicited node addr %s",
|
NET_DBG("DROP: Not solicited node addr %s",
|
||||||
log_strdup(net_sprint_ipv6_addr(&ip_hdr->dst)));
|
log_strdup(net_sprint_ipv6_addr(&ip_hdr->dst)));
|
||||||
goto drop;
|
goto drop;
|
||||||
|
@ -1314,27 +1318,30 @@ nexthop_found:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We reuse the received packet for the NA addresses*/
|
/* We reuse the received packet for the NA addresses*/
|
||||||
net_ipv6_addr_create_ll_allnodes_mcast(&ip_hdr->dst);
|
net_ipv6_addr_create_ll_allnodes_mcast(
|
||||||
net_ipaddr_copy(&ip_hdr->src,
|
(struct in6_addr *)ip_hdr->dst);
|
||||||
net_if_ipv6_select_src_addr(net_pkt_iface(pkt),
|
net_ipaddr_copy((struct in6_addr *)ip_hdr->src,
|
||||||
&ip_hdr->dst));
|
net_if_ipv6_select_src_addr(
|
||||||
na_src = &ip_hdr->src;
|
net_pkt_iface(pkt),
|
||||||
na_dst = &ip_hdr->dst;
|
(struct in6_addr *)ip_hdr->dst));
|
||||||
|
|
||||||
|
na_src = (struct in6_addr *)ip_hdr->src;
|
||||||
|
na_dst = (struct in6_addr *)ip_hdr->dst;
|
||||||
flags = NET_ICMPV6_NA_FLAG_OVERRIDE;
|
flags = NET_ICMPV6_NA_FLAG_OVERRIDE;
|
||||||
goto send_na;
|
goto send_na;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPV6_DAD */
|
#endif /* CONFIG_NET_IPV6_DAD */
|
||||||
|
|
||||||
if (net_ipv6_is_my_addr(&ip_hdr->src)) {
|
if (net_ipv6_is_my_addr((struct in6_addr *)ip_hdr->src)) {
|
||||||
NET_DBG("DROP: Duplicate IPv6 %s address",
|
NET_DBG("DROP: Duplicate IPv6 %s address",
|
||||||
log_strdup(net_sprint_ipv6_addr(&ip_hdr->src)));
|
log_strdup(net_sprint_ipv6_addr(&ip_hdr->src)));
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Address resolution */
|
/* Address resolution */
|
||||||
if (net_ipv6_is_addr_solicited_node(&ip_hdr->dst)) {
|
if (net_ipv6_is_addr_solicited_node((struct in6_addr *)ip_hdr->dst)) {
|
||||||
na_src = &ns_hdr->tgt;
|
na_src = &ns_hdr->tgt;
|
||||||
na_dst = &ip_hdr->src;
|
na_dst = (struct in6_addr *)ip_hdr->src;
|
||||||
flags = NET_ICMPV6_NA_FLAG_SOLICITED |
|
flags = NET_ICMPV6_NA_FLAG_SOLICITED |
|
||||||
NET_ICMPV6_NA_FLAG_OVERRIDE;
|
NET_ICMPV6_NA_FLAG_OVERRIDE;
|
||||||
goto send_na;
|
goto send_na;
|
||||||
|
@ -1347,15 +1354,17 @@ nexthop_found:
|
||||||
|
|
||||||
/* Neighbor Unreachability Detection (NUD) */
|
/* Neighbor Unreachability Detection (NUD) */
|
||||||
if (IS_ENABLED(CONFIG_NET_ROUTING)) {
|
if (IS_ENABLED(CONFIG_NET_ROUTING)) {
|
||||||
ifaddr = net_if_ipv6_addr_lookup(&ip_hdr->dst, NULL);
|
ifaddr = net_if_ipv6_addr_lookup((struct in6_addr *)ip_hdr->dst,
|
||||||
|
NULL);
|
||||||
} else {
|
} else {
|
||||||
ifaddr = net_if_ipv6_addr_lookup_by_iface(net_pkt_iface(pkt),
|
ifaddr = net_if_ipv6_addr_lookup_by_iface(
|
||||||
&ip_hdr->dst);
|
net_pkt_iface(pkt),
|
||||||
|
(struct in6_addr *)ip_hdr->dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ifaddr) {
|
if (ifaddr) {
|
||||||
na_src = &ns_hdr->tgt;
|
na_src = &ns_hdr->tgt;
|
||||||
na_dst = &ip_hdr->src;
|
na_dst = (struct in6_addr *)ip_hdr->src;
|
||||||
tgt = &ifaddr->address.in6_addr;
|
tgt = &ifaddr->address.in6_addr;
|
||||||
flags = NET_ICMPV6_NA_FLAG_SOLICITED |
|
flags = NET_ICMPV6_NA_FLAG_SOLICITED |
|
||||||
NET_ICMPV6_NA_FLAG_OVERRIDE;
|
NET_ICMPV6_NA_FLAG_OVERRIDE;
|
||||||
|
@ -1368,7 +1377,7 @@ nexthop_found:
|
||||||
send_na:
|
send_na:
|
||||||
if (src_lladdr.len) {
|
if (src_lladdr.len) {
|
||||||
if (!net_ipv6_nbr_add(net_pkt_iface(pkt),
|
if (!net_ipv6_nbr_add(net_pkt_iface(pkt),
|
||||||
&ip_hdr->src,
|
(struct in6_addr *)ip_hdr->src,
|
||||||
&src_lladdr, false,
|
&src_lladdr, false,
|
||||||
NET_IPV6_NBR_STATE_INCOMPLETE)) {
|
NET_IPV6_NBR_STATE_INCOMPLETE)) {
|
||||||
goto drop;
|
goto drop;
|
||||||
|
@ -1741,7 +1750,7 @@ static enum net_verdict handle_na_input(struct net_pkt *pkt,
|
||||||
(ip_hdr->hop_limit != NET_IPV6_ND_HOP_LIMIT) ||
|
(ip_hdr->hop_limit != NET_IPV6_ND_HOP_LIMIT) ||
|
||||||
net_ipv6_is_addr_mcast(&na_hdr->tgt) ||
|
net_ipv6_is_addr_mcast(&na_hdr->tgt) ||
|
||||||
(na_hdr->flags & NET_ICMPV6_NA_FLAG_SOLICITED &&
|
(na_hdr->flags & NET_ICMPV6_NA_FLAG_SOLICITED &&
|
||||||
net_ipv6_is_addr_mcast(&ip_hdr->dst))) &&
|
net_ipv6_is_addr_mcast((struct in6_addr *)ip_hdr->dst))) &&
|
||||||
(icmp_hdr->code != 0U)) {
|
(icmp_hdr->code != 0U)) {
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
|
@ -2046,7 +2055,7 @@ static inline struct net_nbr *handle_ra_neighbor(struct net_pkt *pkt, uint8_t le
|
||||||
lladdr.addr = llstorage.addr;
|
lladdr.addr = llstorage.addr;
|
||||||
|
|
||||||
return net_ipv6_nbr_add(net_pkt_iface(pkt),
|
return net_ipv6_nbr_add(net_pkt_iface(pkt),
|
||||||
&NET_IPV6_HDR(pkt)->src,
|
(struct in6_addr *)NET_IPV6_HDR(pkt)->src,
|
||||||
&lladdr, true,
|
&lladdr, true,
|
||||||
NET_IPV6_NBR_STATE_STALE);
|
NET_IPV6_NBR_STATE_STALE);
|
||||||
}
|
}
|
||||||
|
@ -2294,7 +2303,7 @@ static enum net_verdict handle_ra_input(struct net_pkt *pkt,
|
||||||
sizeof(struct net_icmpv6_ra_hdr) +
|
sizeof(struct net_icmpv6_ra_hdr) +
|
||||||
sizeof(struct net_icmpv6_nd_opt_hdr))) ||
|
sizeof(struct net_icmpv6_nd_opt_hdr))) ||
|
||||||
(ip_hdr->hop_limit != NET_IPV6_ND_HOP_LIMIT) ||
|
(ip_hdr->hop_limit != NET_IPV6_ND_HOP_LIMIT) ||
|
||||||
!net_ipv6_is_ll_addr(&ip_hdr->src)) &&
|
!net_ipv6_is_ll_addr((struct in6_addr *)ip_hdr->src)) &&
|
||||||
icmp_hdr->code != 0U) {
|
icmp_hdr->code != 0U) {
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
|
@ -2414,7 +2423,8 @@ static enum net_verdict handle_ra_input(struct net_pkt *pkt,
|
||||||
net_pkt_get_data(pkt, &nd_access);
|
net_pkt_get_data(pkt, &nd_access);
|
||||||
}
|
}
|
||||||
|
|
||||||
router = net_if_ipv6_router_lookup(net_pkt_iface(pkt), &ip_hdr->src);
|
router = net_if_ipv6_router_lookup(net_pkt_iface(pkt),
|
||||||
|
(struct in6_addr *)ip_hdr->src);
|
||||||
if (router) {
|
if (router) {
|
||||||
if (!router_lifetime) {
|
if (!router_lifetime) {
|
||||||
/* TODO: Start rs_timer on iface if no routers
|
/* TODO: Start rs_timer on iface if no routers
|
||||||
|
@ -2431,7 +2441,8 @@ static enum net_verdict handle_ra_input(struct net_pkt *pkt,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
net_if_ipv6_router_add(net_pkt_iface(pkt),
|
net_if_ipv6_router_add(net_pkt_iface(pkt),
|
||||||
&ip_hdr->src, router_lifetime);
|
(struct in6_addr *)ip_hdr->src,
|
||||||
|
router_lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nbr && net_ipv6_nbr_data(nbr)->pending) {
|
if (nbr && net_ipv6_nbr_data(nbr)->pending) {
|
||||||
|
|
|
@ -199,7 +199,7 @@ static inline int check_ip_addr(struct net_pkt *pkt)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_NET_IPV6)
|
#if defined(CONFIG_NET_IPV6)
|
||||||
if (net_pkt_family(pkt) == AF_INET6) {
|
if (net_pkt_family(pkt) == AF_INET6) {
|
||||||
if (net_ipv6_addr_cmp(&NET_IPV6_HDR(pkt)->dst,
|
if (net_ipv6_addr_cmp((struct in6_addr *)NET_IPV6_HDR(pkt)->dst,
|
||||||
net_ipv6_unspecified_address())) {
|
net_ipv6_unspecified_address())) {
|
||||||
NET_DBG("IPv6 dst address missing");
|
NET_DBG("IPv6 dst address missing");
|
||||||
return -EADDRNOTAVAIL;
|
return -EADDRNOTAVAIL;
|
||||||
|
@ -208,17 +208,19 @@ static inline int check_ip_addr(struct net_pkt *pkt)
|
||||||
/* If the destination address is our own, then route it
|
/* If the destination address is our own, then route it
|
||||||
* back to us.
|
* back to us.
|
||||||
*/
|
*/
|
||||||
if (net_ipv6_is_addr_loopback(&NET_IPV6_HDR(pkt)->dst) ||
|
if (net_ipv6_is_addr_loopback(
|
||||||
net_ipv6_is_my_addr(&NET_IPV6_HDR(pkt)->dst)) {
|
(struct in6_addr *)NET_IPV6_HDR(pkt)->dst) ||
|
||||||
|
net_ipv6_is_my_addr(
|
||||||
|
(struct in6_addr *)NET_IPV6_HDR(pkt)->dst)) {
|
||||||
struct in6_addr addr;
|
struct in6_addr addr;
|
||||||
|
|
||||||
/* Swap the addresses so that in receiving side
|
/* Swap the addresses so that in receiving side
|
||||||
* the packet is accepted.
|
* the packet is accepted.
|
||||||
*/
|
*/
|
||||||
net_ipaddr_copy(&addr, &NET_IPV6_HDR(pkt)->src);
|
net_ipv6_addr_copy_raw((uint8_t *)&addr, NET_IPV6_HDR(pkt)->src);
|
||||||
net_ipaddr_copy(&NET_IPV6_HDR(pkt)->src,
|
net_ipv6_addr_copy_raw(NET_IPV6_HDR(pkt)->src,
|
||||||
&NET_IPV6_HDR(pkt)->dst);
|
NET_IPV6_HDR(pkt)->dst);
|
||||||
net_ipaddr_copy(&NET_IPV6_HDR(pkt)->dst, &addr);
|
net_ipv6_addr_copy_raw(NET_IPV6_HDR(pkt)->dst, (uint8_t *)&addr);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -229,7 +231,8 @@ static inline int check_ip_addr(struct net_pkt *pkt)
|
||||||
* in local host, so this is similar as how ::1 unicast
|
* in local host, so this is similar as how ::1 unicast
|
||||||
* addresses are handled. See RFC 3513 ch 2.7 for details.
|
* addresses are handled. See RFC 3513 ch 2.7 for details.
|
||||||
*/
|
*/
|
||||||
if (net_ipv6_is_addr_mcast_iface(&NET_IPV6_HDR(pkt)->dst)) {
|
if (net_ipv6_is_addr_mcast_iface(
|
||||||
|
(struct in6_addr *)NET_IPV6_HDR(pkt)->dst)) {
|
||||||
NET_DBG("IPv6 interface scope mcast dst address");
|
NET_DBG("IPv6 interface scope mcast dst address");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -237,7 +240,8 @@ static inline int check_ip_addr(struct net_pkt *pkt)
|
||||||
/* The source check must be done after the destination check
|
/* The source check must be done after the destination check
|
||||||
* as having src ::1 is perfectly ok if dst is ::1 too.
|
* as having src ::1 is perfectly ok if dst is ::1 too.
|
||||||
*/
|
*/
|
||||||
if (net_ipv6_is_addr_loopback(&NET_IPV6_HDR(pkt)->src)) {
|
if (net_ipv6_is_addr_loopback(
|
||||||
|
(struct in6_addr *)NET_IPV6_HDR(pkt)->src)) {
|
||||||
NET_DBG("IPv6 loopback src address");
|
NET_DBG("IPv6 loopback src address");
|
||||||
return -EADDRNOTAVAIL;
|
return -EADDRNOTAVAIL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -659,7 +659,7 @@ int net_route_mcast_forward_packet(struct net_pkt *pkt,
|
||||||
|
|
||||||
if (!net_if_flag_is_set(route->iface,
|
if (!net_if_flag_is_set(route->iface,
|
||||||
NET_IF_FORWARD_MULTICASTS) ||
|
NET_IF_FORWARD_MULTICASTS) ||
|
||||||
!net_ipv6_is_prefix(hdr->dst.s6_addr,
|
!net_ipv6_is_prefix(hdr->dst,
|
||||||
route->group.s6_addr,
|
route->group.s6_addr,
|
||||||
route->prefix_len) ||
|
route->prefix_len) ||
|
||||||
(pkt->iface == route->iface)) {
|
(pkt->iface == route->iface)) {
|
||||||
|
|
|
@ -185,9 +185,9 @@ static int tcp_endpoint_set(union tcp_endpoint *ep, struct net_pkt *pkt,
|
||||||
|
|
||||||
ep->sin6.sin6_port = src == TCP_EP_SRC ? th_sport(th) :
|
ep->sin6.sin6_port = src == TCP_EP_SRC ? th_sport(th) :
|
||||||
th_dport(th);
|
th_dport(th);
|
||||||
net_ipaddr_copy(&ep->sin6.sin6_addr,
|
net_ipv6_addr_copy_raw((uint8_t *)&ep->sin6.sin6_addr,
|
||||||
src == TCP_EP_SRC ?
|
src == TCP_EP_SRC ?
|
||||||
&ip->src : &ip->dst);
|
ip->src : ip->dst);
|
||||||
ep->sa.sa_family = AF_INET6;
|
ep->sa.sa_family = AF_INET6;
|
||||||
} else {
|
} else {
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
|
@ -837,8 +837,10 @@ static bool is_destination_local(struct net_pkt *pkt)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_NET_IPV6) && net_pkt_family(pkt) == AF_INET6) {
|
if (IS_ENABLED(CONFIG_NET_IPV6) && net_pkt_family(pkt) == AF_INET6) {
|
||||||
if (net_ipv6_is_addr_loopback(&NET_IPV6_HDR(pkt)->dst) ||
|
if (net_ipv6_is_addr_loopback(
|
||||||
net_ipv6_is_my_addr(&NET_IPV6_HDR(pkt)->dst)) {
|
(struct in6_addr *)NET_IPV6_HDR(pkt)->dst) ||
|
||||||
|
net_ipv6_is_my_addr(
|
||||||
|
(struct in6_addr *)NET_IPV6_HDR(pkt)->dst)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1041,7 +1041,7 @@ static void canbus_ipv6_mcast_to_dest(struct net_pkt *pkt,
|
||||||
struct net_canbus_lladdr *dest_addr)
|
struct net_canbus_lladdr *dest_addr)
|
||||||
{
|
{
|
||||||
dest_addr->addr =
|
dest_addr->addr =
|
||||||
sys_be16_to_cpu(UNALIGNED_GET(&NET_IPV6_HDR(pkt)->dst.s6_addr16[7]));
|
sys_be16_to_cpu(UNALIGNED_GET((uint16_t *)&NET_IPV6_HDR(pkt)->dst[14]));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint16_t canbus_eth_to_can_addr(struct net_linkaddr *lladdr)
|
static inline uint16_t canbus_eth_to_can_addr(struct net_linkaddr *lladdr)
|
||||||
|
@ -1062,7 +1062,7 @@ static int canbus_send(struct net_if *iface, struct net_pkt *pkt)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
mcast = net_ipv6_is_addr_mcast(&NET_IPV6_HDR(pkt)->dst);
|
mcast = net_ipv6_is_addr_mcast((struct in6_addr *)NET_IPV6_HDR(pkt)->dst);
|
||||||
if (mcast || canbus_dest_is_mcast(pkt)) {
|
if (mcast || canbus_dest_is_mcast(pkt)) {
|
||||||
canbus_ipv6_mcast_to_dest(pkt, &dest_addr);
|
canbus_ipv6_mcast_to_dest(pkt, &dest_addr);
|
||||||
} else if (IS_ENABLED(CONFIG_NET_L2_CANBUS_ETH_TRANSLATOR) &&
|
} else if (IS_ENABLED(CONFIG_NET_L2_CANBUS_ETH_TRANSLATOR) &&
|
||||||
|
|
|
@ -415,11 +415,11 @@ static bool ethernet_fill_in_dst_on_ipv6_mcast(struct net_pkt *pkt,
|
||||||
struct net_eth_addr *dst)
|
struct net_eth_addr *dst)
|
||||||
{
|
{
|
||||||
if (net_pkt_family(pkt) == AF_INET6 &&
|
if (net_pkt_family(pkt) == AF_INET6 &&
|
||||||
net_ipv6_is_addr_mcast(&NET_IPV6_HDR(pkt)->dst)) {
|
net_ipv6_is_addr_mcast((struct in6_addr *)NET_IPV6_HDR(pkt)->dst)) {
|
||||||
memcpy(dst, (uint8_t *)multicast_eth_addr.addr,
|
memcpy(dst, (uint8_t *)multicast_eth_addr.addr,
|
||||||
sizeof(struct net_eth_addr) - 4);
|
sizeof(struct net_eth_addr) - 4);
|
||||||
memcpy((uint8_t *)dst + 2,
|
memcpy((uint8_t *)dst + 2,
|
||||||
(uint8_t *)(&NET_IPV6_HDR(pkt)->dst) + 12,
|
NET_IPV6_HDR(pkt)->dst + 12,
|
||||||
sizeof(struct net_eth_addr) - 2);
|
sizeof(struct net_eth_addr) - 2);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -446,7 +446,7 @@ static enum net_verdict set_vlan_tag(struct ethernet_context *ctx,
|
||||||
if (net_pkt_family(pkt) == AF_INET6) {
|
if (net_pkt_family(pkt) == AF_INET6) {
|
||||||
struct net_if *target;
|
struct net_if *target;
|
||||||
|
|
||||||
if (net_if_ipv6_addr_lookup(&NET_IPV6_HDR(pkt)->src,
|
if (net_if_ipv6_addr_lookup((struct in6_addr *)NET_IPV6_HDR(pkt)->src,
|
||||||
&target)) {
|
&target)) {
|
||||||
if (target != iface) {
|
if (target != iface) {
|
||||||
NET_DBG("Iface %p should be %p", iface,
|
NET_DBG("Iface %p should be %p", iface,
|
||||||
|
|
|
@ -292,8 +292,8 @@ static int ieee802154_send(struct net_if *iface, struct net_pkt *pkt)
|
||||||
frame_buf = net_buf_alloc(&frame_buf_pool, K_FOREVER);
|
frame_buf = net_buf_alloc(&frame_buf_pool, K_FOREVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
ll_hdr_size = ieee802154_compute_header_size(iface,
|
ll_hdr_size = ieee802154_compute_header_size(
|
||||||
&NET_IPV6_HDR(pkt)->dst);
|
iface, (struct in6_addr *)&NET_IPV6_HDR(pkt)->dst);
|
||||||
|
|
||||||
/* len will hold the hdr size difference on success */
|
/* len will hold the hdr size difference on success */
|
||||||
len = net_6lo_compress(pkt, true);
|
len = net_6lo_compress(pkt, true);
|
||||||
|
|
|
@ -329,7 +329,7 @@ static enum net_verdict interface_input(struct net_if *input_iface,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* RFC4213 chapter 3.6 */
|
/* RFC4213 chapter 3.6 */
|
||||||
iface = net_if_ipv6_select_src_iface(&hdr->dst);
|
iface = net_if_ipv6_select_src_iface((struct in6_addr *)hdr->dst);
|
||||||
if (iface == NULL) {
|
if (iface == NULL) {
|
||||||
NET_DBG("DROP: not for me (dst %s)",
|
NET_DBG("DROP: not for me (dst %s)",
|
||||||
net_sprint_ipv6_addr(&hdr->dst));
|
net_sprint_ipv6_addr(&hdr->dst));
|
||||||
|
|
|
@ -76,7 +76,7 @@ static void create_ipv6_dst_addr(struct net_pkt *pkt,
|
||||||
addr->sin6_family = AF_INET6;
|
addr->sin6_family = AF_INET6;
|
||||||
addr->sin6_port = udp_hdr->src_port;
|
addr->sin6_port = udp_hdr->src_port;
|
||||||
|
|
||||||
net_ipaddr_copy(&addr->sin6_addr, &NET_IPV6_HDR(pkt)->src);
|
net_ipv6_addr_copy_raw((uint8_t *)&addr->sin6_addr, NET_IPV6_HDR(pkt)->src);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -301,7 +301,7 @@ static int create_ipv4_answer(struct net_context *ctx,
|
||||||
} else if (qtype == DNS_RR_TYPE_AAAA) {
|
} else if (qtype == DNS_RR_TYPE_AAAA) {
|
||||||
#if defined(CONFIG_NET_IPV6)
|
#if defined(CONFIG_NET_IPV6)
|
||||||
addr = get_ipv6_src(net_pkt_iface(pkt),
|
addr = get_ipv6_src(net_pkt_iface(pkt),
|
||||||
&ip_hdr->ipv6->src);
|
(struct in6_addr *)ip_hdr->ipv6->src);
|
||||||
if (!addr) {
|
if (!addr) {
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ static int create_ipv6_answer(struct net_context *ctx,
|
||||||
|
|
||||||
if (qtype == DNS_RR_TYPE_AAAA) {
|
if (qtype == DNS_RR_TYPE_AAAA) {
|
||||||
addr = get_ipv6_src(net_pkt_iface(pkt),
|
addr = get_ipv6_src(net_pkt_iface(pkt),
|
||||||
&ip_hdr->ipv6->src);
|
(struct in6_addr *)ip_hdr->ipv6->src);
|
||||||
if (!addr) {
|
if (!addr) {
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -264,7 +264,7 @@ static int send_response(struct net_context *ctx,
|
||||||
const struct in6_addr *addr;
|
const struct in6_addr *addr;
|
||||||
|
|
||||||
addr = net_if_ipv6_select_src_addr(net_pkt_iface(pkt),
|
addr = net_if_ipv6_select_src_addr(net_pkt_iface(pkt),
|
||||||
&ip_hdr->ipv6->src);
|
(struct in6_addr *)ip_hdr->ipv6->src);
|
||||||
|
|
||||||
ret = create_answer(ctx, query, qtype,
|
ret = create_answer(ctx, query, qtype,
|
||||||
sizeof(struct in6_addr), (uint8_t *)addr);
|
sizeof(struct in6_addr), (uint8_t *)addr);
|
||||||
|
@ -353,7 +353,7 @@ static void send_sd_response(struct net_context *ctx,
|
||||||
if (IS_ENABLED(CONFIG_NET_IPV6)) {
|
if (IS_ENABLED(CONFIG_NET_IPV6)) {
|
||||||
/* Look up the local IPv6 address */
|
/* Look up the local IPv6 address */
|
||||||
addr6 = net_if_ipv6_select_src_addr(net_pkt_iface(pkt),
|
addr6 = net_if_ipv6_select_src_addr(net_pkt_iface(pkt),
|
||||||
&ip_hdr->ipv6->src);
|
(struct in6_addr *)ip_hdr->ipv6->src);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = dns_sd_query_extract(dns_msg->msg,
|
ret = dns_sd_query_extract(dns_msg->msg,
|
||||||
|
|
|
@ -889,7 +889,7 @@ static int sock_get_pkt_src_addr(struct net_pkt *pkt,
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
net_ipaddr_copy(&addr6->sin6_addr, &ipv6_hdr->src);
|
net_ipv6_addr_copy_raw((uint8_t *)&addr6->sin6_addr, ipv6_hdr->src);
|
||||||
port = &addr6->sin6_port;
|
port = &addr6->sin6_port;
|
||||||
} else {
|
} else {
|
||||||
ret = -ENOTSUP;
|
ret = -ENOTSUP;
|
||||||
|
|
|
@ -46,54 +46,54 @@ LOG_MODULE_REGISTER(net_test, CONFIG_NET_6LO_LOG_LEVEL);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define src_sac1_sam00 \
|
#define src_sac1_sam00 \
|
||||||
{ { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
||||||
|
|
||||||
#define src_sam00 \
|
#define src_sam00 \
|
||||||
{ { { 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
||||||
|
|
||||||
#define src_sam01 \
|
#define src_sam01 \
|
||||||
{ { { 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa } } }
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa }
|
||||||
|
|
||||||
#define src_sam10 \
|
#define src_sam10 \
|
||||||
{ { { 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0xbb } } }
|
0x00, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0xbb }
|
||||||
#define src_sam11 \
|
#define src_sam11 \
|
||||||
{ { { 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xbb } } }
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xbb }
|
||||||
|
|
||||||
#define dst_m1_dam00 \
|
#define dst_m1_dam00 \
|
||||||
{ { { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 } } }
|
0x00, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 }
|
||||||
|
|
||||||
#define dst_m1_dam01 \
|
#define dst_m1_dam01 \
|
||||||
{ { { 0xff, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xff, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 } } }
|
0x00, 0x00, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 }
|
||||||
|
|
||||||
#define dst_m1_dam10 \
|
#define dst_m1_dam10 \
|
||||||
{ { { 0xff, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xff, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x22, 0x33 } } }
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x22, 0x33 }
|
||||||
|
|
||||||
#define dst_m1_dam11 \
|
#define dst_m1_dam11 \
|
||||||
{ { { 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11 } } }
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11 }
|
||||||
|
|
||||||
#define dst_dam00 \
|
#define dst_dam00 \
|
||||||
{ { { 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
||||||
|
|
||||||
#define dst_dam01 \
|
#define dst_dam01 \
|
||||||
{ { { 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa } } }
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa }
|
||||||
|
|
||||||
#define dst_dam10 \
|
#define dst_dam10 \
|
||||||
{ { { 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0xbb } } }
|
0x00, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0xbb }
|
||||||
#define dst_dam11 \
|
#define dst_dam11 \
|
||||||
{ { { 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbb, 0xaa } } }
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbb, 0xaa }
|
||||||
|
|
||||||
uint8_t src_mac[8] = { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xbb };
|
uint8_t src_mac[8] = { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xbb };
|
||||||
uint8_t dst_mac[8] = { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbb, 0xaa };
|
uint8_t dst_mac[8] = { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbb, 0xaa };
|
||||||
|
@ -129,23 +129,23 @@ static struct net_icmpv6_nd_opt_6co ctx2 = {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define src_sac1_sam01 \
|
#define src_sac1_sam01 \
|
||||||
{ { { 0xaa, 0xbb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xaa, 0xbb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa } } }
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa }
|
||||||
#define dst_dac1_dam01 \
|
#define dst_dac1_dam01 \
|
||||||
{ { { 0xaa, 0xbb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xaa, 0xbb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa } } }
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa }
|
||||||
#define src_sac1_sam10 \
|
#define src_sac1_sam10 \
|
||||||
{ { { 0xcc, 0xdd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xcc, 0xdd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0xbb } } }
|
0x00, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0xbb }
|
||||||
#define dst_dac1_dam10 \
|
#define dst_dac1_dam10 \
|
||||||
{ { { 0xcc, 0xdd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xcc, 0xdd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0xbb } } }
|
0x00, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0xbb }
|
||||||
#define src_sac1_sam11 \
|
#define src_sac1_sam11 \
|
||||||
{ { { 0xaa, 0xbb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xaa, 0xbb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xbb } } }
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xbb }
|
||||||
#define dst_dac1_dam11 \
|
#define dst_dac1_dam11 \
|
||||||
{ { { 0xcc, 0xdd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xcc, 0xdd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbb, 0xaa } } }
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbb, 0xaa }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* UDP Ports */
|
/* UDP Ports */
|
||||||
|
|
|
@ -163,10 +163,10 @@ static int eth_tx_offloading_disabled(const struct device *dev,
|
||||||
if (net_pkt_family(pkt) == AF_INET6) {
|
if (net_pkt_family(pkt) == AF_INET6) {
|
||||||
struct in6_addr addr;
|
struct in6_addr addr;
|
||||||
|
|
||||||
net_ipaddr_copy(&addr, &NET_IPV6_HDR(pkt)->src);
|
net_ipv6_addr_copy_raw((uint8_t *)&addr, NET_IPV6_HDR(pkt)->src);
|
||||||
net_ipaddr_copy(&NET_IPV6_HDR(pkt)->src,
|
net_ipv6_addr_copy_raw(NET_IPV6_HDR(pkt)->src,
|
||||||
&NET_IPV6_HDR(pkt)->dst);
|
NET_IPV6_HDR(pkt)->dst);
|
||||||
net_ipaddr_copy(&NET_IPV6_HDR(pkt)->dst, &addr);
|
net_ipv6_addr_copy_raw(NET_IPV6_HDR(pkt)->dst, (uint8_t *)&addr);
|
||||||
} else {
|
} else {
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
|
|
||||||
|
|
|
@ -914,10 +914,10 @@ static int tester_send(const struct device *dev, struct net_pkt *pkt)
|
||||||
if (net_pkt_family(pkt) == AF_INET6) {
|
if (net_pkt_family(pkt) == AF_INET6) {
|
||||||
struct in6_addr addr;
|
struct in6_addr addr;
|
||||||
|
|
||||||
net_ipaddr_copy(&addr, &NET_IPV6_HDR(pkt)->src);
|
net_ipv6_addr_copy_raw((uint8_t *)&addr, NET_IPV6_HDR(pkt)->src);
|
||||||
net_ipaddr_copy(&NET_IPV6_HDR(pkt)->src,
|
net_ipv6_addr_copy_raw(NET_IPV6_HDR(pkt)->src,
|
||||||
&NET_IPV6_HDR(pkt)->dst);
|
NET_IPV6_HDR(pkt)->dst);
|
||||||
net_ipaddr_copy(&NET_IPV6_HDR(pkt)->dst, &addr);
|
net_ipv6_addr_copy_raw(NET_IPV6_HDR(pkt)->dst, (uint8_t *)&addr);
|
||||||
} else {
|
} else {
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
|
|
||||||
|
|
|
@ -45,48 +45,48 @@ LOG_MODULE_REGISTER(net_test, CONFIG_NET_L2_IEEE802154_LOG_LEVEL);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define src_sac1_sam00 \
|
#define src_sac1_sam00 \
|
||||||
{ { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
||||||
|
|
||||||
#define src_sam00 \
|
#define src_sam00 \
|
||||||
{ { { 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
||||||
|
|
||||||
#define src_sam01 \
|
#define src_sam01 \
|
||||||
{ { { 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa } } }
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa }
|
||||||
|
|
||||||
#define src_sam10 \
|
#define src_sam10 \
|
||||||
{ { { 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0xbb } } }
|
0x00, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0xbb }
|
||||||
|
|
||||||
#define dst_m1_dam00 \
|
#define dst_m1_dam00 \
|
||||||
{ { { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 } } }
|
0x00, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 }
|
||||||
|
|
||||||
#define dst_m1_dam01 \
|
#define dst_m1_dam01 \
|
||||||
{ { { 0xff, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xff, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 } } }
|
0x00, 0x00, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 }
|
||||||
|
|
||||||
#define dst_m1_dam10 \
|
#define dst_m1_dam10 \
|
||||||
{ { { 0xff, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xff, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x22, 0x33 } } }
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x22, 0x33 }
|
||||||
|
|
||||||
#define dst_m1_dam11 \
|
#define dst_m1_dam11 \
|
||||||
{ { { 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11 } } }
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11 }
|
||||||
|
|
||||||
#define dst_dam00 \
|
#define dst_dam00 \
|
||||||
{ { { 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
||||||
|
|
||||||
#define dst_dam01 \
|
#define dst_dam01 \
|
||||||
{ { { 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa } } }
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa }
|
||||||
|
|
||||||
#define dst_dam10 \
|
#define dst_dam10 \
|
||||||
{ { { 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
{ 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||||
0x00, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0xbb } } }
|
0x00, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0xbb }
|
||||||
|
|
||||||
|
|
||||||
/* UDP Ports */
|
/* UDP Ports */
|
||||||
|
|
|
@ -214,8 +214,8 @@ static bool check_packet_addresses(struct net_pkt *pkt)
|
||||||
&ipv6_hdr->src,
|
&ipv6_hdr->src,
|
||||||
sizeof(struct in6_addr)) != 0) ||
|
sizeof(struct in6_addr)) != 0) ||
|
||||||
(memcmp(&active_scenario.mcast,
|
(memcmp(&active_scenario.mcast,
|
||||||
&ipv6_hdr->dst,
|
ipv6_hdr->dst,
|
||||||
sizeof(struct in6_addr)) != 0)) {
|
sizeof(struct in6_addr)) != 0)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,10 +172,10 @@ static int eth_tx(const struct device *dev, struct net_pkt *pkt)
|
||||||
/* Swap IP src and destination address so that we can receive
|
/* Swap IP src and destination address so that we can receive
|
||||||
* the packet and the stack will not reject it.
|
* the packet and the stack will not reject it.
|
||||||
*/
|
*/
|
||||||
net_ipaddr_copy(&addr, &NET_IPV6_HDR(pkt)->src);
|
net_ipv6_addr_copy_raw((uint8_t *)&addr, NET_IPV6_HDR(pkt)->src);
|
||||||
net_ipaddr_copy(&NET_IPV6_HDR(pkt)->src,
|
net_ipv6_addr_copy_raw(NET_IPV6_HDR(pkt)->src,
|
||||||
&NET_IPV6_HDR(pkt)->dst);
|
NET_IPV6_HDR(pkt)->dst);
|
||||||
net_ipaddr_copy(&NET_IPV6_HDR(pkt)->dst, &addr);
|
net_ipv6_addr_copy_raw(NET_IPV6_HDR(pkt)->dst, (uint8_t *)&addr);
|
||||||
|
|
||||||
udp_hdr = net_udp_get_hdr(pkt, &hdr);
|
udp_hdr = net_udp_get_hdr(pkt, &hdr);
|
||||||
zassert_not_null(udp_hdr, "UDP header missing");
|
zassert_not_null(udp_hdr, "UDP header missing");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue