From 09144a2c5fa06ed9067df8f16b706a4ce2d46b5f Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Fri, 26 Apr 2019 11:34:55 +0100 Subject: [PATCH] Added check of IP version to the eNB GTP-u. Helpfull for debug. --- srsenb/src/stack/upper/gtpu.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/srsenb/src/stack/upper/gtpu.cc b/srsenb/src/stack/upper/gtpu.cc index a04bfbd6b..dded6437b 100644 --- a/srsenb/src/stack/upper/gtpu.cc +++ b/srsenb/src/stack/upper/gtpu.cc @@ -22,6 +22,7 @@ #include "srsenb/hdr/stack/upper/gtpu.h" #include #include +#include #include #include @@ -114,6 +115,13 @@ void gtpu::stop() void gtpu::write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) { gtpu_log->info_hex(pdu->msg, pdu->N_bytes, "TX PDU, RNTI: 0x%x, LCID: %d, n_bytes=%d", rnti, lcid, pdu->N_bytes); + + // Check valid IP version + struct iphdr* ip_pkt = (struct iphdr*)pdu->msg; + if (ip_pkt->version != 4 && ip_pkt->version != 6) { + gtpu_log->error("Invalid IP version to TUN\n"); + } + gtpu_header_t header; header.flags = GTPU_FLAGS_VERSION_V1 | GTPU_FLAGS_GTP_PROTOCOL; header.message_type = GTPU_MSG_DATA_PDU;