From bd0e641633c0b2b2cd313323180e0b2ceba233ea Mon Sep 17 00:00:00 2001 From: David Rupprecht Date: Fri, 10 Sep 2021 13:00:50 +0200 Subject: [PATCH] Added GTPU PDU Session header parsing --- lib/include/srsran/upper/gtpu.h | 3 +++ lib/src/gtpu/gtpu.cc | 31 ++++++++++++++++++++----------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/lib/include/srsran/upper/gtpu.h b/lib/include/srsran/upper/gtpu.h index f78ac17b2..ba0943bdd 100644 --- a/lib/include/srsran/upper/gtpu.h +++ b/lib/include/srsran/upper/gtpu.h @@ -58,8 +58,11 @@ namespace srsran { #define GTPU_MSG_END_MARKER 254 #define GTPU_MSG_DATA_PDU 255 +#define GTPU_EXT_NO_MORE_EXTENSION_HEADERS 0x00 #define GTPU_EXT_HEADER_PDCP_PDU_NUMBER 0b11000000 +#define GTPU_EXT_HEADER_PDU_SESSION_CONTAINER 0x85 +#define GTPU_EXT_HEADER_PDU_SESSION_CONTAINER_LEN 4 struct gtpu_header_t { uint8_t flags = 0; uint8_t message_type = 0; diff --git a/lib/src/gtpu/gtpu.cc b/lib/src/gtpu/gtpu.cc index aa616c411..9dda8ee93 100644 --- a/lib/src/gtpu/gtpu.cc +++ b/lib/src/gtpu/gtpu.cc @@ -112,17 +112,26 @@ bool gtpu_read_ext_header(srsran::byte_buffer_t* pdu, return true; } - if (header->next_ext_hdr_type == GTPU_EXT_HEADER_PDCP_PDU_NUMBER) { - pdu->msg += HEADER_PDCP_PDU_NUMBER_SIZE; - pdu->N_bytes -= HEADER_PDCP_PDU_NUMBER_SIZE; - header->ext_buffer.resize(HEADER_PDCP_PDU_NUMBER_SIZE); - for (size_t i = 0; i < HEADER_PDCP_PDU_NUMBER_SIZE; ++i) { - header->ext_buffer[i] = **ptr; - (*ptr)++; - } - } else { - logger.error("gtpu_read_header - Unhandled GTP-U Extension Header Type: 0x%x", header->next_ext_hdr_type); - return false; + // TODO: Iterate over next headers until no more extension headers + switch (header->next_ext_hdr_type) { + case GTPU_EXT_HEADER_PDCP_PDU_NUMBER: + pdu->msg += HEADER_PDCP_PDU_NUMBER_SIZE; + pdu->N_bytes -= HEADER_PDCP_PDU_NUMBER_SIZE; + header->ext_buffer.resize(HEADER_PDCP_PDU_NUMBER_SIZE); + for (size_t i = 0; i < HEADER_PDCP_PDU_NUMBER_SIZE; ++i) { + header->ext_buffer[i] = **ptr; + (*ptr)++; + } + break; + case GTPU_EXT_HEADER_PDU_SESSION_CONTAINER: + pdu->msg += GTPU_EXT_HEADER_PDU_SESSION_CONTAINER_LEN; + pdu->N_bytes -= GTPU_EXT_HEADER_PDU_SESSION_CONTAINER_LEN; + logger.warning("skip parsing of GTPU_EXT_HEADER_PDU_SESSION_CONTAINER"); + // TODO: Save Header Extension + break; + default: + logger.error("gtpu_read_header - Unhandled GTP-U Extension Header Type: 0x%x", header->next_ext_hdr_type); + return false; } return true; }