Merge pull request #2534 from jfischer-phytec-iot/pr@udp-header-decompression
lowpan.c: add udp header decompression
This commit is contained in:
commit
f1becc6870
@ -78,6 +78,8 @@ extern "C" {
|
|||||||
* </a>
|
* </a>
|
||||||
*/
|
*/
|
||||||
#define SIXLOWPAN_IPHC1_NH (0x04)
|
#define SIXLOWPAN_IPHC1_NH (0x04)
|
||||||
|
#define SIXLOWPAN_NHC_UDP_MASK (0xF8)
|
||||||
|
#define SIXLOWPAN_NHC_UDP_ID (0xF0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Flag for Context Identifier Extention (part of second byte
|
* @brief Flag for Context Identifier Extention (part of second byte
|
||||||
|
|||||||
@ -1233,10 +1233,7 @@ void lowpan_iphc_decoding(uint8_t *data, uint8_t length, net_if_eui64_t *s_addr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* NH: Next Header: */
|
/* NH: Next Header: */
|
||||||
if (lowpan_iphc[0] & SIXLOWPAN_IPHC1_NH) {
|
if (!(lowpan_iphc[0] & SIXLOWPAN_IPHC1_NH)) {
|
||||||
// TODO: next header decompression
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ipv6_buf->nextheader = ipv6_hdr_fields[hdr_pos];
|
ipv6_buf->nextheader = ipv6_hdr_fields[hdr_pos];
|
||||||
hdr_pos++;
|
hdr_pos++;
|
||||||
}
|
}
|
||||||
@ -1474,11 +1471,30 @@ void lowpan_iphc_decoding(uint8_t *data, uint8_t length, net_if_eui64_t *s_addr,
|
|||||||
|
|
||||||
uint8_t *ptr = get_payload_buf(ipv6_ext_hdr_len);
|
uint8_t *ptr = get_payload_buf(ipv6_ext_hdr_len);
|
||||||
|
|
||||||
memcpy(ptr, &ipv6_hdr_fields[hdr_pos], length - hdr_pos);
|
if (lowpan_iphc[0] & SIXLOWPAN_IPHC1_NH) {
|
||||||
|
if ((ipv6_hdr_fields[hdr_pos] & SIXLOWPAN_NHC_UDP_MASK) == SIXLOWPAN_NHC_UDP_ID) {
|
||||||
|
ipv6_buf->nextheader = IPV6_PROTO_NUM_UDP;
|
||||||
|
/* ipv6 length */
|
||||||
|
ipv6_buf->length = HTONS(length - hdr_pos + 1);
|
||||||
|
packet_length = IPV6_HDR_LEN + ipv6_buf->length;
|
||||||
|
|
||||||
/* ipv6 length */
|
hdr_pos ++;
|
||||||
ipv6_buf->length = HTONS(length - hdr_pos);
|
/* copy inline src_port and dst_port */
|
||||||
packet_length = IPV6_HDR_LEN + ipv6_buf->length;
|
memcpy(ptr, &ipv6_hdr_fields[hdr_pos], 4);
|
||||||
|
hdr_pos += 4;
|
||||||
|
ptr += 4;
|
||||||
|
/* insert length value */
|
||||||
|
*((uint16_t*)ptr) = ipv6_buf->length;
|
||||||
|
ptr += 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* ipv6 length */
|
||||||
|
ipv6_buf->length = HTONS(length - hdr_pos);
|
||||||
|
packet_length = IPV6_HDR_LEN + ipv6_buf->length;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(ptr, &ipv6_hdr_fields[hdr_pos], length - hdr_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t lowpan_context_len(void)
|
uint8_t lowpan_context_len(void)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user