diff --git a/src/libmsc/gsm_04_08_cc.c b/src/libmsc/gsm_04_08_cc.c index 93b4995dd..abf604f25 100644 --- a/src/libmsc/gsm_04_08_cc.c +++ b/src/libmsc/gsm_04_08_cc.c @@ -865,34 +865,22 @@ static int gsm48_cc_tx_setup_set_transaction_id(struct gsm_trans *trans) return 0; } -static int gsm48_cc_tx_setup(struct gsm_trans *trans, void *arg) +/* MT call leg is starting. Gather all codecs information so far known. + * (Usually) paging has succeeded, and now we're processing the MNCC Setup from + * the remote MO call leg. Initialize the codecs filter with this side's BSS' + * codec list, received at Complete Layer 3. We haven't received the MT MS's + * Bearer Capabilities yet; the Bearer Capabilities handled here are actually + * the remote call leg's Bearer Capabilities. */ +static int gsm48_cc_tx_setup_select_codecs(struct gsm_trans *trans, const struct gsm_mncc *setup) { - struct msgb *msg; - struct gsm48_hdr *gh; - struct gsm_mncc *setup = arg; - int rc; - struct gsm_mncc_bearer_cap bearer_cap; - - rc = gsm48_cc_tx_setup_set_transaction_id(trans); - if (rc < 0) - goto error; - - gsm48_start_cc_timer(trans, 0x303, GSM48_T303); - - /* MT call leg is starting. Gather all codecs information so far known. - * (Usually) paging has succeeded, and now we're processing the MNCC Setup from the remote MO call leg. - * Initialize the codecs filter with this side's BSS' codec list, received at Complete Layer 3. - * We haven't received the MT MS's Bearer Capabilities yet; the Bearer Capabilities handled here are - * actually the remote call leg's Bearer Capabilities. */ trans_cc_filter_init(trans); trans_cc_filter_set_ran(trans, trans->msc_a->c.ran->type); trans_cc_filter_set_bss(trans, trans->msc_a); - if (setup->fields & MNCC_F_BEARER_CAP) - trans->bearer_cap.transfer = setup->bearer_cap.transfer; switch (trans->bearer_cap.transfer) { case GSM48_BCAP_ITCAP_SPEECH: - /* if SDP is included in the MNCC, take that as definitive list of remote audio codecs. */ + /* if SDP is included in the MNCC, take that as definitive list + * of remote audio codecs. */ rx_mncc_sdp(trans, setup->msg_type, setup->sdp, (setup->fields & MNCC_F_BEARER_CAP) ? &setup->bearer_cap : NULL); /* rx_mncc_sdp() has called trans_cc_filter_run(trans); */ @@ -915,9 +903,33 @@ static int gsm48_cc_tx_setup(struct gsm_trans *trans, void *arg) default: LOG_TRANS(trans, LOGL_ERROR, "Handling of information transfer capability %d not implemented\n", trans->bearer_cap.transfer); - break; + return -1; } + 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; + struct gsm_mncc_bearer_cap bearer_cap; + + rc = gsm48_cc_tx_setup_set_transaction_id(trans); + if (rc < 0) + goto error; + + gsm48_start_cc_timer(trans, 0x303, GSM48_T303); + + if (setup->fields & MNCC_F_BEARER_CAP) + trans->bearer_cap.transfer = setup->bearer_cap.transfer; + + rc = gsm48_cc_tx_setup_select_codecs(trans, setup); + if (rc < 0) + goto error; + /* Compose Bearer Capability information that reflects only the codecs (Speech Versions) / CSD bearer services * remaining after intersecting MS, BSS and remote call leg restrictions. To store in trans for later use, and * to include in the outgoing CC Setup message. */