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/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/21483 ) Change subject: gprs_ns2: use switch() case instead of multiple if in ns2_create_vc() ...................................................................... gprs_ns2: use switch() case instead of multiple if in ns2_create_vc() Improve readibilty and allows it to extend for future ns2 vty changes Change-Id: I8bd9c75fb04169a166b7a3f5e13a5902250cfd0e --- M src/gb/gprs_ns2.c 1 file changed, 14 insertions(+), 19 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c index 15364fc..69c1174 100644 --- a/src/gb/gprs_ns2.c +++ b/src/gb/gprs_ns2.c @@ -772,42 +772,37 @@ if (msg->len < sizeof(struct gprs_ns_hdr)) return GPRS_NS2_CS_ERROR; - if (nsh->pdu_type == NS_PDUT_STATUS) { + switch (nsh->pdu_type) { + case NS_PDUT_STATUS: /* Do not respond, see 3GPP TS 08.16, 7.5.1 */ LOGP(DLNS, LOGL_INFO, "Ignoring NS STATUS from %s " "for non-existing NS-VC\n", logname); return GPRS_NS2_CS_SKIPPED; - } - - if (nsh->pdu_type == NS_PDUT_ALIVE_ACK) { + case NS_PDUT_ALIVE_ACK: /* Ignore this, see 3GPP TS 08.16, 7.4.1 */ LOGP(DLNS, LOGL_INFO, "Ignoring NS ALIVE ACK from %s " "for non-existing NS-VC\n", logname); return GPRS_NS2_CS_SKIPPED; - } - - if (nsh->pdu_type == NS_PDUT_RESET_ACK) { + case NS_PDUT_RESET_ACK: /* Ignore this, see 3GPP TS 08.16, 7.3.1 */ LOGP(DLNS, LOGL_INFO, "Ignoring NS RESET ACK from %s " "for non-existing NS-VC\n", logname); return GPRS_NS2_CS_SKIPPED; - } + case NS_PDUT_RESET: + /* accept PDU RESET when vc_mode matches */ + if (bind->vc_mode == NS2_VC_MODE_BLOCKRESET) + break; - if (bind->vc_mode == NS2_VC_MODE_BLOCKRESET) { - /* Only the RESET procedure creates a new NSVC */ - if (nsh->pdu_type != NS_PDUT_RESET) { - rc = reject_status_msg(msg, &tp, reject, NS_CAUSE_PDU_INCOMP_PSTATE); - - if (rc < 0) { - LOGP(DLNS, LOGL_ERROR, "Failed to generate reject message (%d)\n", rc); - return rc; - } - return GPRS_NS2_CS_REJECTED; + rc = reject_status_msg(msg, &tp, reject, NS_CAUSE_PDU_INCOMP_PSTATE); + if (rc < 0) { + LOGP(DLNS, LOGL_ERROR, "Failed to generate reject message (%d)\n", rc); + return rc; } - } else { /* NS2_VC_MODE_ALIVE */ + return GPRS_NS2_CS_REJECTED; + default: rc = reject_status_msg(msg, &tp, reject, NS_CAUSE_PDU_INCOMP_PSTATE); if (rc < 0) { -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/21483 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I8bd9c75fb04169a166b7a3f5e13a5902250cfd0e Gerrit-Change-Number: 21483 Gerrit-PatchSet: 1 Gerrit-Owner: lynxis lazus <lynxis at fe80.eu> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge at osmocom.org> Gerrit-MessageType: merged -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201203/0cb0dd30/attachment.htm>