GPRS: clarify ip/frgre union use
* add comment about underlying assumption that structs in ip/frgre union
members in gprs_nsvc struct have the same memory layout
* remove such assumption from gprs_ns_ll_str()
* use gprs_ns_ll_str() for NSE dump
Change-Id: Idcb912b7b3f7460fd2b058e16650c0bde8f757ee
diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index 2d062cf..18d43cc 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -1173,9 +1173,21 @@
const char *gprs_ns_ll_str(struct gprs_nsvc *nsvc)
{
static char buf[80];
- snprintf(buf, sizeof(buf), "%s:%u",
- inet_ntoa(nsvc->ip.bts_addr.sin_addr),
- osmo_ntohs(nsvc->ip.bts_addr.sin_port));
+
+ switch(nsvc->ll) {
+ case GPRS_NS_LL_UDP:
+ snprintf(buf, sizeof(buf), "%s:%u",
+ inet_ntoa(nsvc->ip.bts_addr.sin_addr), osmo_ntohs(nsvc->ip.bts_addr.sin_port));
+ break;
+ case GPRS_NS_LL_FR_GRE:
+ snprintf(buf, sizeof(buf), "%s:%u",
+ inet_ntoa(nsvc->frgre.bts_addr.sin_addr), osmo_ntohs(nsvc->frgre.bts_addr.sin_port));
+ break;
+ default:
+ buf[0] = '\0';
+ break;
+ }
+
buf[sizeof(buf) - 1] = '\0';
return buf;