From 91a5d1a74ea23e9eaf38f5e5244b308905669da0 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Thu, 20 Feb 2020 14:52:13 +0100 Subject: [PATCH] gtpu: Log bind failure cause --- srsenb/src/stack/upper/gtpu.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/srsenb/src/stack/upper/gtpu.cc b/srsenb/src/stack/upper/gtpu.cc index a30e27f6a..c60804bda 100644 --- a/srsenb/src/stack/upper/gtpu.cc +++ b/srsenb/src/stack/upper/gtpu.cc @@ -26,6 +26,7 @@ #include #include #include +#include using namespace srslte; namespace srsenb { @@ -48,6 +49,8 @@ bool gtpu::init(std::string gtp_bind_addr_, pool = byte_buffer_pool::get_instance(); stack = stack_; + char errbuf[128]; + // Set up socket fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd < 0) { @@ -71,8 +74,9 @@ bool gtpu::init(std::string gtp_bind_addr_, bindaddr.sin_port = htons(GTPU_PORT); if (bind(fd, (struct sockaddr*)&bindaddr, sizeof(struct sockaddr_in))) { - gtpu_log->error("Failed to bind on address %s, port %d\n", gtp_bind_addr.c_str(), GTPU_PORT); - gtpu_log->console("Failed to bind on address %s, port %d\n", gtp_bind_addr.c_str(), GTPU_PORT); + snprintf(errbuf, sizeof(errbuf), "%s", strerror(errno)); + gtpu_log->error("Failed to bind on address %s, port %d: %s\n", gtp_bind_addr.c_str(), GTPU_PORT, errbuf); + gtpu_log->console("Failed to bind on address %s, port %d: %s\n", gtp_bind_addr.c_str(), GTPU_PORT, errbuf); return false; }