gtpu,bugfix - fixed formatting of addresses in GTPU

master
Francisco 4 years ago committed by Francisco Paisana
parent 20e341d0a1
commit 4969c98665

@ -12,6 +12,7 @@
#include "srslte/upper/gtpu.h" #include "srslte/upper/gtpu.h"
#include "srsenb/hdr/stack/upper/gtpu.h" #include "srsenb/hdr/stack/upper/gtpu.h"
#include "srslte/common/network_utils.h" #include "srslte/common/network_utils.h"
#include "srslte/common/string_helpers.h"
#include "srslte/interfaces/enb_interfaces.h" #include "srslte/interfaces/enb_interfaces.h"
#include "srslte/interfaces/enb_pdcp_interfaces.h" #include "srslte/interfaces/enb_pdcp_interfaces.h"
#include <errno.h> #include <errno.h>
@ -153,14 +154,14 @@ uint32_t gtpu::add_bearer(uint16_t rnti, uint32_t lcid, uint32_t addr, uint32_t
ue_teidin_db[rnti][lcid].push_back(teid_in); ue_teidin_db[rnti][lcid].push_back(teid_in);
fmt::memory_buffer buffer; fmt::memory_buffer str_buffer;
srslte::gtpu_ntoa(buffer, htonl(addr)); srslte::gtpu_ntoa(str_buffer, htonl(addr));
logger.info("New tunnel teid_in=0x%x, teid_out=0x%x, rnti=0x%x, lcid=%d, addr=%s", logger.info("New tunnel teid_in=0x%x, teid_out=0x%x, rnti=0x%x, lcid=%d, addr=%s",
teid_in, teid_in,
teid_out, teid_out,
rnti, rnti,
lcid, lcid,
buffer.data()); srslte::to_c_str(str_buffer));
if (props != nullptr) { if (props != nullptr) {
if (props->flush_before_teidin_present) { if (props->flush_before_teidin_present) {
@ -534,14 +535,14 @@ void gtpu::log_message(tunnel& tun, bool is_rx, srslte::span<uint8_t> pdu, int p
srslte::gtpu_ntoa(addrbuf, htonl(tun.spgw_addr)); srslte::gtpu_ntoa(addrbuf, htonl(tun.spgw_addr));
if (is_rx) { if (is_rx) {
dir = "Rx"; dir = "Rx";
fmt::format_to(strbuf2, "{}:0x{:0x} > ", addrbuf.data(), tun.teid_in); fmt::format_to(strbuf2, "{}:0x{:0x} > ", srslte::to_c_str(addrbuf), tun.teid_in);
if (not tun.dl_enabled) { if (not tun.dl_enabled) {
fmt::format_to(strbuf2, "DL (buffered), "); fmt::format_to(strbuf2, "DL (buffered), ");
} else if (tun.fwd_teid_in_present) { } else if (tun.fwd_teid_in_present) {
tunnel& tx_tun = tunnels.at(tun.fwd_teid_in); tunnel& tx_tun = tunnels.at(tun.fwd_teid_in);
addrbuf.clear(); addrbuf.clear();
srslte::gtpu_ntoa(addrbuf, htonl(tx_tun.spgw_addr)); srslte::gtpu_ntoa(addrbuf, htonl(tx_tun.spgw_addr));
fmt::format_to(strbuf2, "{}:0x{:0x} (forwarded), ", addrbuf.data(), tx_tun.teid_in); fmt::format_to(strbuf2, "{}:0x{:0x} (forwarded), ", srslte::to_c_str(addrbuf), tx_tun.teid_in);
} else { } else {
fmt::format_to(strbuf2, "DL, "); fmt::format_to(strbuf2, "DL, ");
} }
@ -551,7 +552,7 @@ void gtpu::log_message(tunnel& tun, bool is_rx, srslte::span<uint8_t> pdu, int p
} else { } else {
fmt::format_to(strbuf2, "UL "); fmt::format_to(strbuf2, "UL ");
} }
fmt::format_to(strbuf2, "> {}:0x{:0x}, ", addrbuf.data(), tun.teid_in); fmt::format_to(strbuf2, "> {}:0x{:0x}, ", srslte::to_c_str(addrbuf), tun.teid_in);
} }
fmt::format_to(strbuf, fmt::format_to(strbuf,
"{} S1-U SDU, {}rnti=0x{:0x}, lcid={}, n_bytes={}, IPv{}", "{} S1-U SDU, {}rnti=0x{:0x}, lcid={}, n_bytes={}, IPv{}",
@ -566,12 +567,12 @@ void gtpu::log_message(tunnel& tun, bool is_rx, srslte::span<uint8_t> pdu, int p
strbuf2.clear(); strbuf2.clear();
srslte::gtpu_ntoa(addrbuf, ip_pkt->saddr); srslte::gtpu_ntoa(addrbuf, ip_pkt->saddr);
srslte::gtpu_ntoa(strbuf2, ip_pkt->daddr); srslte::gtpu_ntoa(strbuf2, ip_pkt->daddr);
fmt::format_to(strbuf, " {} > {}", addrbuf.data(), strbuf2.data()); fmt::format_to(strbuf, " {} > {}", srslte::to_c_str(addrbuf), srslte::to_c_str(strbuf2));
if (ntohs(ip_pkt->tot_len) != pdu.size()) { if (ntohs(ip_pkt->tot_len) != pdu.size()) {
logger.error("IP Len and PDU N_bytes mismatch"); logger.error("IP Len and PDU N_bytes mismatch");
} }
} }
logger.info(pdu.data(), pdu.size(), "%s", strbuf.data()); logger.info(pdu.data(), pdu.size(), "%s", srslte::to_c_str(strbuf));
} }
/**************************************************************************** /****************************************************************************

@ -12,6 +12,7 @@
#include "srsepc/hdr/spgw/gtpu.h" #include "srsepc/hdr/spgw/gtpu.h"
#include "srsepc/hdr/mme/mme_gtpc.h" #include "srsepc/hdr/mme/mme_gtpc.h"
#include "srslte/common/string_helpers.h"
#include "srslte/upper/gtpu.h" #include "srslte/upper/gtpu.h"
#include <algorithm> #include <algorithm>
#include <arpa/inet.h> #include <arpa/inet.h>
@ -208,10 +209,10 @@ void spgw::gtpu::handle_sgi_pdu(srslte::unique_byte_buffer_t msg)
m_logger.debug("SGi PDU -- IP version %d, Total length %d", int(iph->version), ntohs(iph->tot_len)); m_logger.debug("SGi PDU -- IP version %d, Total length %d", int(iph->version), ntohs(iph->tot_len));
fmt::memory_buffer buffer; fmt::memory_buffer buffer;
srslte::gtpu_ntoa(buffer, iph->saddr); srslte::gtpu_ntoa(buffer, iph->saddr);
m_logger.debug("SGi PDU -- IP src addr %s", buffer.data()); m_logger.debug("SGi PDU -- IP src addr %s", srslte::to_c_str(buffer));
buffer.clear(); buffer.clear();
srslte::gtpu_ntoa(buffer, iph->daddr); srslte::gtpu_ntoa(buffer, iph->daddr);
m_logger.debug("SGi PDU -- IP dst addr %s", buffer.data()); m_logger.debug("SGi PDU -- IP dst addr %s", srslte::to_c_str(buffer));
// Find user and control tunnel // Find user and control tunnel
gtpu_fteid_it = m_ip_to_usr_teid.find(iph->daddr); gtpu_fteid_it = m_ip_to_usr_teid.find(iph->daddr);
@ -315,10 +316,10 @@ bool spgw::gtpu::modify_gtpu_tunnel(in_addr_t ue_ipv4, srslte::gtpc_f_teid_ie dw
m_logger.info("Modifying GTP-U Tunnel."); m_logger.info("Modifying GTP-U Tunnel.");
fmt::memory_buffer buffer; fmt::memory_buffer buffer;
srslte::gtpu_ntoa(buffer, ue_ipv4); srslte::gtpu_ntoa(buffer, ue_ipv4);
m_logger.info("UE IP %s", buffer.data()); m_logger.info("UE IP %s", srslte::to_c_str(buffer));
buffer.clear(); buffer.clear();
srslte::gtpu_ntoa(buffer, dw_user_fteid.ipv4); srslte::gtpu_ntoa(buffer, dw_user_fteid.ipv4);
m_logger.info("Downlink eNB addr %s, U-TEID 0x%x", buffer.data(), dw_user_fteid.teid); m_logger.info("Downlink eNB addr %s, U-TEID 0x%x", srslte::to_c_str(buffer), dw_user_fteid.teid);
m_logger.info("Uplink C-TEID: 0x%x", up_ctrl_teid); m_logger.info("Uplink C-TEID: 0x%x", up_ctrl_teid);
m_ip_to_usr_teid[ue_ipv4] = dw_user_fteid; m_ip_to_usr_teid[ue_ipv4] = dw_user_fteid;
m_ip_to_ctr_teid[ue_ipv4] = up_ctrl_teid; m_ip_to_ctr_teid[ue_ipv4] = up_ctrl_teid;

Loading…
Cancel
Save