Making sure that GTPU optional fields get written

This commit is contained in:
Pedro Alvarez 2018-10-01 16:02:00 +01:00
parent c9cd355cdb
commit 2ff900d971
1 changed files with 24 additions and 3 deletions

View File

@ -73,9 +73,30 @@ bool gtpu_write_header(gtpu_header_t *header, srslte::byte_buffer_t *pdu, srslte
uint16_to_uint8(header->length, ptr);
ptr += 2;
uint32_to_uint8(header->teid, ptr);
//write optional fields
//write optional fields, if E, S or PN are set.
if (header->flags & (GTPU_FLAGS_EXTENDED_HDR | GTPU_FLAGS_SEQUENCE | GTPU_FLAGS_PACKET_NUM)) {
//S
if (header->flags & GTPU_FLAGS_SEQUENCE ) {
uint16_to_uint8(header->seq_number, ptr);
} else {
uint16_to_uint8(0, ptr);
}
ptr+=2;
//PN
if (header->flags & GTPU_FLAGS_PACKET_NUM ) {
*ptr = header->n_pdu;
} else {
header=>n_pdu = 0;
}
ptr++;
//E
if (header->flags & GTPU_FLAGS_EXTENDED_HDR ) {
*ptr = header->next_ext_hdr_type;
} else {
*ptr = 0;
}
ptr++;
}
return true;
}