mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
gnrc_sixlowpan_iphc: set correct length for IPv6 header
This commit is contained in:
parent
d438984ae5
commit
ab9d57dec5
@ -38,12 +38,15 @@ extern "C" {
|
|||||||
* @p pkt
|
* @p pkt
|
||||||
* @param[in,out] pkt A received 6LoWPAN IPHC frame. IPHC dispatch will not
|
* @param[in,out] pkt A received 6LoWPAN IPHC frame. IPHC dispatch will not
|
||||||
* be marked.
|
* be marked.
|
||||||
|
* @param[in] datagram_size Size of the full uncompressed IPv6 datagram. May be 0, if @p pkt
|
||||||
|
* contains the full (unfragmented) IPv6 datagram.
|
||||||
* @param[in] offset Offset of the IPHC dispatch in 6LoWPaN frame.
|
* @param[in] offset Offset of the IPHC dispatch in 6LoWPaN frame.
|
||||||
*
|
*
|
||||||
* @return length of the HC dispatches + inline values on success.
|
* @return length of the HC dispatches + inline values on success.
|
||||||
* @return 0 on error.
|
* @return 0 on error.
|
||||||
*/
|
*/
|
||||||
size_t gnrc_sixlowpan_iphc_decode(gnrc_pktsnip_t *ipv6, gnrc_pktsnip_t *pkt, size_t offset);
|
size_t gnrc_sixlowpan_iphc_decode(gnrc_pktsnip_t *ipv6, gnrc_pktsnip_t *pkt, size_t datagram_size,
|
||||||
|
size_t offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Compresses a 6LoWPAN for IPHC.
|
* @brief Compresses a 6LoWPAN for IPHC.
|
||||||
|
@ -93,7 +93,7 @@ void rbuf_add(gnrc_netif_hdr_t *netif_hdr, gnrc_pktsnip_t *pkt,
|
|||||||
#ifdef MODULE_GNRC_SIXLOWPAN_IPHC
|
#ifdef MODULE_GNRC_SIXLOWPAN_IPHC
|
||||||
else if (sixlowpan_iphc_is(data)) {
|
else if (sixlowpan_iphc_is(data)) {
|
||||||
size_t iphc_len;
|
size_t iphc_len;
|
||||||
iphc_len = gnrc_sixlowpan_iphc_decode(entry->pkt, pkt,
|
iphc_len = gnrc_sixlowpan_iphc_decode(entry->pkt, pkt, entry->pkt->size,
|
||||||
sizeof(sixlowpan_frag_t));
|
sizeof(sixlowpan_frag_t));
|
||||||
if (iphc_len == 0) {
|
if (iphc_len == 0) {
|
||||||
DEBUG("6lo rfrag: could not decode IPHC dispatch\n");
|
DEBUG("6lo rfrag: could not decode IPHC dispatch\n");
|
||||||
|
@ -129,7 +129,7 @@ static void _receive(gnrc_pktsnip_t *pkt)
|
|||||||
gnrc_pktsnip_t *ipv6 = gnrc_pktbuf_add(NULL, NULL, sizeof(ipv6_hdr_t),
|
gnrc_pktsnip_t *ipv6 = gnrc_pktbuf_add(NULL, NULL, sizeof(ipv6_hdr_t),
|
||||||
GNRC_NETTYPE_IPV6);
|
GNRC_NETTYPE_IPV6);
|
||||||
if ((ipv6 == NULL) ||
|
if ((ipv6 == NULL) ||
|
||||||
(dispatch_size = gnrc_sixlowpan_iphc_decode(ipv6, pkt, 0)) == 0) {
|
(dispatch_size = gnrc_sixlowpan_iphc_decode(ipv6, pkt, 0, 0)) == 0) {
|
||||||
DEBUG("6lo: error on IPHC decoding\n");
|
DEBUG("6lo: error on IPHC decoding\n");
|
||||||
if (ipv6 != NULL) {
|
if (ipv6 != NULL) {
|
||||||
gnrc_pktbuf_release(ipv6);
|
gnrc_pktbuf_release(ipv6);
|
||||||
|
@ -90,7 +90,8 @@ static inline bool _context_overlaps_iid(gnrc_sixlowpan_ctx_t *ctx,
|
|||||||
(iid->uint8[(ctx->prefix_len / 8) - 8] & byte_mask[ctx->prefix_len % 8])));
|
(iid->uint8[(ctx->prefix_len / 8) - 8] & byte_mask[ctx->prefix_len % 8])));
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t gnrc_sixlowpan_iphc_decode(gnrc_pktsnip_t *ipv6, gnrc_pktsnip_t *pkt, size_t offset)
|
size_t gnrc_sixlowpan_iphc_decode(gnrc_pktsnip_t *ipv6, gnrc_pktsnip_t *pkt, size_t datagram_size,
|
||||||
|
size_t offset)
|
||||||
{
|
{
|
||||||
gnrc_netif_hdr_t *netif_hdr = pkt->next->data;
|
gnrc_netif_hdr_t *netif_hdr = pkt->next->data;
|
||||||
ipv6_hdr_t *ipv6_hdr;
|
ipv6_hdr_t *ipv6_hdr;
|
||||||
@ -370,7 +371,12 @@ size_t gnrc_sixlowpan_iphc_decode(gnrc_pktsnip_t *ipv6, gnrc_pktsnip_t *pkt, siz
|
|||||||
|
|
||||||
/* set IPv6 header payload length field to the length of whatever is left
|
/* set IPv6 header payload length field to the length of whatever is left
|
||||||
* after removing the 6LoWPAN header */
|
* after removing the 6LoWPAN header */
|
||||||
|
if (datagram_size == 0) {
|
||||||
ipv6_hdr->len = byteorder_htons((uint16_t)(pkt->size - payload_offset));
|
ipv6_hdr->len = byteorder_htons((uint16_t)(pkt->size - payload_offset));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ipv6_hdr->len = byteorder_htons((uint16_t)(datagram_size - sizeof(ipv6_hdr_t)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return payload_offset;
|
return payload_offset;
|
||||||
|
Loading…
Reference in New Issue
Block a user