osmith submitted this change.
gsm48_cc_tx_setup_set_transaction_id: split out
Move the code for setting the transaction ID to a separate function to
start making gsm48_cc_tx_setup shorter and easier to read. Return -1 on
error instead of rc from mncc_release_ind() as it returns 0 on success.
Make some tweaks while at it:
* Set LOGL_ERROR for the "TX Setup with assigned transaction" error.
* Add a log message for the "could not get a free transaction ID" case.
* Minor formatting tweaks.
Change-Id: I715f12d09570211a98b667c56960309bd326e8d8
---
M src/libmsc/gsm_04_08_cc.c
1 file changed, 32 insertions(+), 23 deletions(-)
diff --git a/src/libmsc/gsm_04_08_cc.c b/src/libmsc/gsm_04_08_cc.c
index b82c018..3a78b6d 100644
--- a/src/libmsc/gsm_04_08_cc.c
+++ b/src/libmsc/gsm_04_08_cc.c
@@ -836,37 +836,46 @@
msc_a_tx_assignment_cmd(trans->msc_a);
}
+static int gsm48_cc_tx_setup_set_transaction_id(struct gsm_trans *trans)
+{
+ int id;
+
+ /* Transaction ID must not be assigned */
+ if (trans->transaction_id != TRANS_ID_UNASSIGNED) {
+ LOG_TRANS(trans, LOGL_ERROR, "TX Setup with assigned transaction. This is not allowed!\n");
+ mncc_release_ind(trans->net, trans, trans->callref,
+ GSM48_CAUSE_LOC_PRN_S_LU,
+ GSM48_CC_CAUSE_RESOURCE_UNAVAIL);
+ trans->callref = 0;
+ return -1;
+ }
+
+ /* Get free transaction ID */
+ id = trans_assign_trans_id(trans->net, trans->vsub, TRANS_CC);
+ if (id < 0) {
+ LOG_TRANS(trans, LOGL_ERROR, "TX Setup: could not get a free transaction ID!\n");
+ mncc_release_ind(trans->net, trans, trans->callref,
+ GSM48_CAUSE_LOC_PRN_S_LU,
+ GSM48_CC_CAUSE_RESOURCE_UNAVAIL);
+ trans->callref = 0;
+ return -1;
+ }
+
+ trans->transaction_id = id;
+ return 0;
+}
+
static int gsm48_cc_tx_setup(struct gsm_trans *trans, void *arg)
{
struct msgb *msg;
struct gsm48_hdr *gh;
struct gsm_mncc *setup = arg;
- int rc, trans_id;
+ int rc;
struct gsm_mncc_bearer_cap bearer_cap;
- /* transaction id must not be assigned */
- if (trans->transaction_id != TRANS_ID_UNASSIGNED) {
- LOG_TRANS(trans, LOGL_DEBUG, "TX Setup with assigned transaction. "
- "This is not allowed!\n");
- /* Temporarily out of order */
- rc = mncc_release_ind(trans->net, trans, trans->callref,
- GSM48_CAUSE_LOC_PRN_S_LU,
- GSM48_CC_CAUSE_RESOURCE_UNAVAIL);
- trans->callref = 0;
+ rc = gsm48_cc_tx_setup_set_transaction_id(trans);
+ if (rc < 0)
goto error;
- }
-
- /* Get free transaction_id */
- trans_id = trans_assign_trans_id(trans->net, trans->vsub, TRANS_CC);
- if (trans_id < 0) {
- /* no free transaction ID */
- rc = mncc_release_ind(trans->net, trans, trans->callref,
- GSM48_CAUSE_LOC_PRN_S_LU,
- GSM48_CC_CAUSE_RESOURCE_UNAVAIL);
- trans->callref = 0;
- goto error;
- }
- trans->transaction_id = trans_id;
gsm48_start_cc_timer(trans, 0x303, GSM48_T303);
To view, visit change 41038. To unsubscribe, or for help writing mail filters, visit settings.