From 5fd4c81c634c3f441d66a01ffde28c5834029004 Mon Sep 17 00:00:00 2001 From: Alexander Couzens Date: Wed, 28 Sep 2022 16:22:29 +0200 Subject: [PATCH] gb: add bssgp2_enc_flush_ll encode FLUSH-LL Change-Id: I76dc3b08a63cfd78c9f7657fb58c2ddfa9b4b7e2 --- include/osmocom/gprs/gprs_bssgp2.h | 1 + src/gb/gprs_bssgp2.c | 29 +++++++++++++++++++++++++++++ src/gb/libosmogb.map | 1 + 3 files changed, 31 insertions(+) diff --git a/include/osmocom/gprs/gprs_bssgp2.h b/include/osmocom/gprs/gprs_bssgp2.h index 3b5b6e823..23312fc2f 100644 --- a/include/osmocom/gprs/gprs_bssgp2.h +++ b/include/osmocom/gprs/gprs_bssgp2.h @@ -59,6 +59,7 @@ struct msgb *bssgp2_enc_bvc_reset(uint16_t bvci, enum gprs_bssgp_cause cause, struct msgb *bssgp2_enc_bvc_reset_ack(uint16_t bvci, const struct gprs_ra_id *ra_id, uint16_t cell_id, const uint8_t *feat_bm, const uint8_t *ext_feat_bm); +struct msgb *bssgp2_enc_flush_ll(uint32_t tlli, uint16_t old_bvci, uint16_t *new_bvci, uint16_t *nsei); struct msgb *bssgp2_enc_status(uint8_t cause, const uint16_t *bvci, const struct msgb *orig_msg, uint16_t max_pdu_len); diff --git a/src/gb/gprs_bssgp2.c b/src/gb/gprs_bssgp2.c index 8e2ba66ce..104fe08e1 100644 --- a/src/gb/gprs_bssgp2.c +++ b/src/gb/gprs_bssgp2.c @@ -349,6 +349,35 @@ struct msgb *bssgp2_enc_fc_bvc(const struct bssgp2_flow_ctrl *fc, enum bssgp_fc_ return msg; } +/*! Encode BSSGP FLUSH-LL PDU as per TS 48.018 Section 10.4.1. + * \param[in] tlli - the TLLI of the MS + * \param[in] old_bvci BVCI + * \param[in] new_bvci2 optional BVCI - only encoded if non-NULL + * \param[in] nsei optional - only encoded if non-NULL + * \returns encoded PDU or NULL in case of error */ +struct msgb *bssgp2_enc_flush_ll(uint32_t tlli, uint16_t old_bvci, + const uint16_t *new_bvci, const uint16_t *nsei) +{ + struct msgb *msg = bssgp_msgb_alloc(); + struct bssgp_normal_hdr *bgph; + + if (!msg) + return NULL; + + bgph = (struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph)); + bgph->pdu_type = BSSGP_PDUT_FLUSH_LL; + + msgb_tvlv_put_32be(msg, BSSGP_IE_TLLI, tlli); + msgb_tvlv_put_16be(msg, BSSGP_IE_BVCI, old_bvci); + if (new_bvci) + msgb_tvlv_put_16be(msg, BSSGP_IE_BVCI, *new_bvci); + + if (nsei) + msgb_tvlv_put_16be(msg, BSSGP_IE_BVCI, *nsei); + + return msg; +} + /*! Encode a FLOW-CONTROL-BVC-ACK PDU as per TS 48.018 Section 10.4.4. * \param[in] tag the tag IE value to encode * \returns encoded PDU or NULL in case of error */ diff --git a/src/gb/libosmogb.map b/src/gb/libosmogb.map index ff5b34a23..e02273d91 100644 --- a/src/gb/libosmogb.map +++ b/src/gb/libosmogb.map @@ -85,6 +85,7 @@ bssgp2_enc_fc_bvc; bssgp2_enc_fc_bvc_ack; bssgp2_enc_fc_ms; bssgp2_enc_fc_ms_ack; +bssgp2_enc_flush_ll; bssgp2_enc_status; bssgp_bvc_fsm_alloc_sig_bss;