gsm0808: add message generator for BSSMAP HANDOVER PERFORMED

We currently have no generator function that can generate BSSMAP
HANDOVER PERFORMED messages. Lets add function for this.

Change-Id: I825106858bd89afc9837811b8fed2e8accc82441
Related: OS#3645
This commit is contained in:
Philipp Maier 2018-10-30 14:56:59 +01:00 committed by Harald Welte
parent a2f696fa5c
commit 225bdf4779
3 changed files with 71 additions and 0 deletions

View File

@ -172,6 +172,30 @@ struct gsm0808_handover_failure {
};
struct msgb *gsm0808_create_handover_failure(const struct gsm0808_handover_failure *params);
struct gsm0808_handover_performed {
uint16_t cause;
struct gsm0808_cell_id cell_id;
bool chosen_channel_present;
uint8_t chosen_channel;
bool chosen_encr_alg_present;
uint8_t chosen_encr_alg;
bool speech_version_chosen_present;
uint8_t speech_version_chosen;
bool speech_codec_chosen_present;
struct gsm0808_speech_codec speech_codec_chosen;
bool lcls_bss_status_present;
enum gsm0808_lcls_status lcls_bss_status;
/* more items are defined in the spec and may be added later */
bool more_items; /*< always set this to false */
};
struct msgb *gsm0808_create_handover_performed(const struct gsm0808_handover_performed *params);
struct msgb *gsm0808_create_dtap(struct msgb *msg, uint8_t link_id);
void gsm0808_prepend_dtap_header(struct msgb *msg, uint8_t link_id);

View File

@ -892,6 +892,52 @@ struct msgb *gsm0808_create_handover_failure(const struct gsm0808_handover_failu
return msg;
}
/*! Create BSSMAP HANDOVER PERFORMED message, 3GPP TS 48.008 3.2.1.25.
* \param[in] params All information to be encoded.
* \returns callee-allocated msgb with BSSMAP HANDOVER PERFORMED message */
struct msgb *gsm0808_create_handover_performed(const struct gsm0808_handover_performed *params)
{
struct msgb *msg;
msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM, "BSSMAP-HANDOVER-PERFORMED");
if (!msg)
return NULL;
/* Message Type, 3.2.2.1 */
msgb_v_put(msg, BSS_MAP_MSG_HANDOVER_PERFORMED);
/* Cause, 3.2.2.5 */
msgb_tlv_put(msg, GSM0808_IE_CAUSE, gsm0808_cause_ext(params->cause) ? 2 : 1, (const uint8_t *)&params->cause);
/* Cell Identifier, 3.2.2.17 */
gsm0808_enc_cell_id(msg, &params->cell_id);
/* Chosen Channel 3.2.2.33 */
if (params->chosen_channel_present)
msgb_tv_put(msg, GSM0808_IE_CHOSEN_CHANNEL, params->chosen_channel);
/* Chosen Encryption Algorithm 3.2.2.44 */
if (params->chosen_encr_alg_present)
msgb_tv_put(msg, GSM0808_IE_CHOSEN_ENCR_ALG, params->chosen_encr_alg);
/* Speech Version (chosen) 3.2.2.51 */
if (params->speech_version_chosen_present)
msgb_tv_put(msg, GSM0808_IE_SPEECH_VERSION, params->speech_version_chosen);
/* AoIP: Speech Codec (chosen) 3.2.2.104 */
if (params->speech_codec_chosen_present)
gsm0808_enc_speech_codec(msg, &params->speech_codec_chosen);
/* LCLS-BSS-Status 3.2.2.119 */
if (params->lcls_bss_status_present)
msgb_tv_put(msg, GSM0808_IE_LCLS_BSS_STATUS, params->lcls_bss_status);
/* prepend header with final length */
msg->l3h = msgb_tv_push(msg, BSSAP_MSG_BSS_MANAGEMENT, msgb_length(msg));
return msg;
}
/*! Prepend a DTAP header to given Message Buffer
* \param[in] msgb Message Buffer
* \param[in] link_id Link Identifier */

View File

@ -181,6 +181,7 @@ gsm0808_create_handover_request_ack;
gsm0808_create_handover_detect;
gsm0808_create_handover_complete;
gsm0808_create_handover_failure;
gsm0808_create_handover_performed;
gsm0808_prepend_dtap_header;
gsm0808_enc_aoip_trasp_addr;
gsm0808_dec_aoip_trasp_addr;