Fix GTP-U bearer address conversion

Addresses with a leading 0 in hex represenatation were converted
without the leading 0 and padded afterwards with a trailing 0. This
leaded to wrong IPs in the GTP-U bearer setup.
master
Nils Fürste 3 years ago committed by Ismael Gomez
parent b036da07de
commit 3b1131936e

@ -86,7 +86,7 @@ int ngap_ue_bearer_manager::add_gtpu_bearer(uint16_t
logger.info("Addr in %x", addr_in); logger.info("Addr in %x", addr_in);
tunnel.address_in.from_number(addr_in); tunnel.address_in.from_number(addr_in, 32);
tunnel.teid_in = rtn.value(); tunnel.teid_in = rtn.value();
logger.info("Added GTPU tunnel rnti 0x%04x, pdu_session_id=%d, teid_out %d, teid_in %d, address out 0x%x, " logger.info("Added GTPU tunnel rnti 0x%04x, pdu_session_id=%d, teid_out %d, teid_in %d, address out 0x%x, "

@ -510,11 +510,12 @@ srsran::expected<uint32_t> gtpu::add_bearer(uint16_t rnti,
} }
// Return bind address for S1AP and NGAP setup // Return bind address for S1AP and NGAP setup
struct in_addr inaddr; uint8_t addr_in_tmp[4];
if ((inet_pton(AF_INET, gtp_bind_addr.c_str(), &inaddr)) < 1) { if ((inet_pton(AF_INET, gtp_bind_addr.c_str(), &addr_in_tmp)) < 1) {
logger.error("Invalid address or failure during conversion: %s\n", gtp_bind_addr.c_str()); logger.error("Invalid address or failure during conversion: %s\n", gtp_bind_addr.c_str());
} }
addr_in = ntohl(inaddr.s_addr); addr_in = 0;
addr_in = addr_in_tmp[3] | (addr_in_tmp[2] << 8) | (addr_in_tmp[1] << 16) | (addr_in_tmp[0] << 24);
return teid_in; return teid_in;
} }

Loading…
Cancel
Save