mirror of https://gerrit.osmocom.org/libosmocore
LCLS: add gsm0808_create_ass2()
It allows setting additional assignment parameters explicitly. Change-Id: Id89765df3f8c12f55f73f1d7a9d90c8883eb3bba Related: OS#2487
This commit is contained in:
parent
969fb2ed84
commit
5207432780
|
@ -64,6 +64,12 @@ struct msgb *gsm0808_create_ass(const struct gsm0808_channel_type *ct,
|
|||
const struct sockaddr_storage *ss,
|
||||
const struct gsm0808_speech_codec_list *scl,
|
||||
const uint32_t *ci);
|
||||
struct msgb *gsm0808_create_ass2(const struct gsm0808_channel_type *ct,
|
||||
const uint16_t *cic,
|
||||
const struct sockaddr_storage *ss,
|
||||
const struct gsm0808_speech_codec_list *scl,
|
||||
const uint32_t *ci,
|
||||
const uint8_t *kc, const struct osmo_lcls *lcls);
|
||||
struct msgb *gsm0808_create_ass_compl(uint8_t rr_cause, uint8_t chosen_channel,
|
||||
uint8_t encr_alg_id, uint8_t speech_mode,
|
||||
const struct sockaddr_storage *ss,
|
||||
|
|
|
@ -425,18 +425,22 @@ struct msgb *gsm0808_create_sapi_reject(uint8_t link_id)
|
|||
return msg;
|
||||
}
|
||||
|
||||
/*! Create BSSMAP Assignment Request message, 3GPP TS 48.008 §3.2.1.1
|
||||
/*! Create BSSMAP Assignment Request message, 3GPP TS 48.008 §3.2.1.1.
|
||||
* This is identical to gsm0808_create_ass(), but adds KC and LCLS IEs.
|
||||
* \param[in] ct Channel Type
|
||||
* \param[in] cic Circuit Identity Code (Classic A only)
|
||||
* \param[in] ss Socket Address of MSC-side RTP socket (AoIP only)
|
||||
* \param[in] scl Speech Codec List (AoIP only)
|
||||
* \param[in] ci Call Identifier (Optional), §3.2.2.105
|
||||
* \param[in] kc Kc128 ciphering key (Optional, A5/4), §3.2.2.109
|
||||
* \param[in] lcls Optional LCLS parameters
|
||||
* \returns callee-allocated msgb with BSSMAP Assignment Request message */
|
||||
struct msgb *gsm0808_create_ass(const struct gsm0808_channel_type *ct,
|
||||
const uint16_t *cic,
|
||||
const struct sockaddr_storage *ss,
|
||||
const struct gsm0808_speech_codec_list *scl,
|
||||
const uint32_t *ci)
|
||||
struct msgb *gsm0808_create_ass2(const struct gsm0808_channel_type *ct,
|
||||
const uint16_t *cic,
|
||||
const struct sockaddr_storage *ss,
|
||||
const struct gsm0808_speech_codec_list *scl,
|
||||
const uint32_t *ci,
|
||||
const uint8_t *kc, const struct osmo_lcls *lcls)
|
||||
{
|
||||
/* See also: 3GPP TS 48.008 3.2.1.1 ASSIGNMENT REQUEST */
|
||||
struct msgb *msg;
|
||||
|
@ -481,6 +485,27 @@ struct msgb *gsm0808_create_ass(const struct gsm0808_channel_type *ct,
|
|||
(uint8_t *) & ci_sw);
|
||||
}
|
||||
|
||||
if (kc)
|
||||
msgb_tv_fixed_put(msg, GSM0808_IE_KC_128, 16, kc);
|
||||
|
||||
if (lcls) {
|
||||
/* LCLS: §3.2.2.115 Global Call Reference */
|
||||
if (lcls->gcr)
|
||||
gsm0808_enc_gcr(msg, lcls->gcr);
|
||||
|
||||
/* LCLS: §3.2.2.116 Configuration */
|
||||
if (lcls->config != GSM0808_LCLS_CFG_NA)
|
||||
msgb_tv_put(msg, GSM0808_IE_LCLS_CONFIG, lcls->config);
|
||||
|
||||
/* LCLS: §3.2.2.117 Connection Status Control */
|
||||
if (lcls->control != GSM0808_LCLS_CSC_NA)
|
||||
msgb_tv_put(msg, GSM0808_IE_LCLS_CONN_STATUS_CTRL, lcls->control);
|
||||
|
||||
/* LCLS: §3.2.2.118 Correlation-Not-Needed */
|
||||
if (!lcls->corr_needed)
|
||||
msgb_v_put(msg, GSM0808_IE_LCLS_CORR_NOT_NEEDED);
|
||||
}
|
||||
|
||||
/* push the bssmap header */
|
||||
msg->l3h =
|
||||
msgb_tv_push(msg, BSSAP_MSG_BSS_MANAGEMENT, msgb_length(msg));
|
||||
|
@ -488,6 +513,22 @@ struct msgb *gsm0808_create_ass(const struct gsm0808_channel_type *ct,
|
|||
return msg;
|
||||
}
|
||||
|
||||
/*! Create BSSMAP Assignment Request message, 3GPP TS 48.008 §3.2.1.1.
|
||||
* \param[in] ct Channel Type
|
||||
* \param[in] cic Circuit Identity Code (Classic A only)
|
||||
* \param[in] ss Socket Address of MSC-side RTP socket (AoIP only)
|
||||
* \param[in] scl Speech Codec List (AoIP only)
|
||||
* \param[in] ci Call Identifier (Optional), §3.2.2.105
|
||||
* \returns callee-allocated msgb with BSSMAP Assignment Request message */
|
||||
struct msgb *gsm0808_create_ass(const struct gsm0808_channel_type *ct,
|
||||
const uint16_t *cic,
|
||||
const struct sockaddr_storage *ss,
|
||||
const struct gsm0808_speech_codec_list *scl,
|
||||
const uint32_t *ci)
|
||||
{
|
||||
return gsm0808_create_ass2(ct, cic, ss, scl, ci, NULL, NULL);
|
||||
}
|
||||
|
||||
/*! Create BSSMAP Assignment Completed message
|
||||
* \param[in] rr_cause GSM 04.08 RR Cause value
|
||||
* \param[in] chosen_channel Chosen Channel
|
||||
|
|
|
@ -150,6 +150,7 @@ gsm0808_bssmap_name;
|
|||
gsm0808_cause_name;
|
||||
gsm0808_cause_class_name;
|
||||
gsm0808_create_ass;
|
||||
gsm0808_create_ass2;
|
||||
gsm0808_create_assignment_completed;
|
||||
gsm0808_create_ass_compl;
|
||||
gsm0808_create_assignment_failure;
|
||||
|
|
|
@ -415,6 +415,83 @@ static void test_create_ass()
|
|||
msgb_free(msg);
|
||||
}
|
||||
|
||||
static void test_create_ass2()
|
||||
{
|
||||
static const uint8_t res[] = {
|
||||
BSSAP_MSG_BSS_MANAGEMENT,
|
||||
0x45,
|
||||
BSS_MAP_MSG_ASSIGMENT_RQST,
|
||||
GSM0808_IE_CHANNEL_TYPE,
|
||||
0x04, 0x01, 0x0b, 0x91, 0x15, 0x01, 0x00, 0x04,
|
||||
GSM0808_IE_AOIP_TRASP_ADDR,
|
||||
0x06,
|
||||
0xac, 0x0c, 0x65, 0x0d, /* IPv4 */
|
||||
0x02, 0x9a,
|
||||
GSM0808_IE_SPEECH_CODEC_LIST,
|
||||
0x07,
|
||||
GSM0808_SCT_FR3 | 0x50,
|
||||
0xef, 0xcd,
|
||||
GSM0808_SCT_FR2 | 0xa0,
|
||||
0x9f,
|
||||
GSM0808_SCT_CSD | 0x90,
|
||||
0xc0,
|
||||
GSM0808_IE_CALL_ID,
|
||||
0xde, 0xad, 0xfa, 0xce, /* CallID */
|
||||
0x83, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, /* Kc */
|
||||
GSM0808_IE_GLOBAL_CALL_REF, 0x0d, /* GCR, length */
|
||||
0x03, 0x44, 0x44, 0x44, /* GCR, Net ID */
|
||||
0x02, 0xfe, 0xed, /* GCR, Node ID */
|
||||
0x05, 0x41, 0x41, 0x41, 0x41, 0x41, /* GCR, Call ref. ID */
|
||||
GSM0808_IE_LCLS_CONFIG, GSM0808_LCLS_CFG_BOTH_WAY,
|
||||
GSM0808_IE_LCLS_CONN_STATUS_CTRL, GSM0808_LCLS_CSC_CONNECT,
|
||||
GSM0808_IE_LCLS_CORR_NOT_NEEDED,
|
||||
};
|
||||
struct msgb *msg;
|
||||
struct gsm0808_channel_type ct;
|
||||
uint16_t cic = 4;
|
||||
struct sockaddr_storage ss;
|
||||
struct sockaddr_in sin;
|
||||
struct gsm0808_speech_codec_list sc_list;
|
||||
uint32_t call_id = 0xDEADFACE;
|
||||
struct osmo_gcr_parsed gcr = { .net_len = 3, .node = 0xFEED };
|
||||
uint8_t Kc[16];
|
||||
struct osmo_lcls lcls = {
|
||||
.config = GSM0808_LCLS_CFG_BOTH_WAY,
|
||||
.control = GSM0808_LCLS_CSC_CONNECT,
|
||||
.gcr = &gcr,
|
||||
.corr_needed = false
|
||||
};
|
||||
|
||||
memset(gcr.cr, 'A', 5);
|
||||
memset(gcr.net, 'D', gcr.net_len);
|
||||
memset(Kc, 'E', 16);
|
||||
|
||||
memset(&ct, 0, sizeof(ct));
|
||||
ct.ch_indctr = GSM0808_CHAN_SPEECH;
|
||||
ct.ch_rate_type = GSM0808_SPEECH_HALF_PREF;
|
||||
ct.perm_spch[0] = GSM0808_PERM_FR2;
|
||||
ct.perm_spch[1] = GSM0808_PERM_HR2;
|
||||
ct.perm_spch_len = 2;
|
||||
|
||||
memset(&sin, 0, sizeof(sin));
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(666);
|
||||
inet_aton("172.12.101.13", &sin.sin_addr); /* IPv4 */
|
||||
|
||||
memset(&ss, 0, sizeof(ss));
|
||||
memcpy(&ss, &sin, sizeof(sin));
|
||||
|
||||
setup_codec_list(&sc_list);
|
||||
|
||||
printf("Testing creating Assignment Request with Kc and LCLS\n");
|
||||
|
||||
msg = gsm0808_create_ass2(&ct, &cic, &ss, &sc_list, &call_id, Kc, &lcls);
|
||||
if (!msgb_eq_l3_data_print(msg, res, ARRAY_SIZE(res)))
|
||||
abort();
|
||||
|
||||
msgb_free(msg);
|
||||
}
|
||||
|
||||
static void test_create_ass_compl()
|
||||
{
|
||||
static const uint8_t res1[] = {
|
||||
|
@ -1880,6 +1957,7 @@ int main(int argc, char **argv)
|
|||
test_create_cm_u();
|
||||
test_create_sapi_reject();
|
||||
test_create_ass();
|
||||
test_create_ass2();
|
||||
test_create_ass_compl();
|
||||
test_create_ass_compl_aoip();
|
||||
test_create_ass_fail();
|
||||
|
|
|
@ -14,6 +14,7 @@ Testing creating Cipher Reject (extended)
|
|||
Testing creating CM U
|
||||
Testing creating SAPI Reject
|
||||
Testing creating Assignment Request
|
||||
Testing creating Assignment Request with Kc and LCLS
|
||||
Testing creating Assignment Complete
|
||||
Testing creating Assignment Complete (AoIP)
|
||||
Testing creating Assignment Failure
|
||||
|
|
Loading…
Reference in New Issue