This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Harald Welte gerrit-no-reply at lists.osmocom.orgHarald Welte has submitted this change and it was merged. Change subject: GPRS: clarify ip/frgre union use ...................................................................... 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 --- M include/osmocom/gprs/gprs_ns.h M src/gb/gprs_ns.c M src/gb/gprs_ns_vty.c 3 files changed, 22 insertions(+), 9 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/gprs/gprs_ns.h b/include/osmocom/gprs/gprs_ns.h index 2d2f86e..4fb9f58 100644 --- a/include/osmocom/gprs/gprs_ns.h +++ b/include/osmocom/gprs/gprs_ns.h @@ -140,6 +140,8 @@ /*! which link-layer are we based on? */ enum gprs_ns_ll ll; + /*! make sure to always keep bts_addr as first struct member to not break the assumption + that those structs are similar */ union { struct { struct sockaddr_in bts_addr; 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; diff --git a/src/gb/gprs_ns_vty.c b/src/gb/gprs_ns_vty.c index 317a6a1..4ed4fef 100644 --- a/src/gb/gprs_ns_vty.c +++ b/src/gb/gprs_ns_vty.c @@ -165,12 +165,11 @@ nsvc->remote_end_is_sgsn ? "SGSN" : "BSS", NS_DESC_A(nsvc->remote_state), NS_DESC_B(nsvc->remote_state)); - if (nsvc->ll == GPRS_NS_LL_UDP || nsvc->ll == GPRS_NS_LL_FR_GRE) - vty_out(vty, ", %s %15s:%u", - nsvc->ll == GPRS_NS_LL_UDP ? "UDP " : "FR-GRE", - inet_ntoa(nsvc->ip.bts_addr.sin_addr), - osmo_ntohs(nsvc->ip.bts_addr.sin_port)); - vty_out(vty, "%s", VTY_NEWLINE); + + vty_out(vty, ", %s %s%s", + nsvc->ll == GPRS_NS_LL_UDP ? "UDP " : "FR-GRE", + gprs_ns_ll_str(nsvc), VTY_NEWLINE); + if (stats) { vty_out_rate_ctr_group(vty, " ", nsvc->ctrg); vty_out_stat_item_group(vty, " ", nsvc->statg); -- To view, visit https://gerrit.osmocom.org/4394 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Idcb912b7b3f7460fd2b058e16650c0bde8f757ee Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max <msuraev at sysmocom.de> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>