Neels Hofmeyr has uploaded this change for review. ( 
https://gerrit.osmocom.org/9672


Change subject: add and tweak inter-BSC HO API
......................................................................

add and tweak inter-BSC HO API

Add:
gsm0808_create_handover_detect()
gsm0808_create_handover_complete()
gsm0808_create_handover_failure()

To existing structs gsm0808_old_bss_to_new_bss_info and
gsm0808_handover_required, add a final 'more_items' flag that makes future
extensions API and ABI compatible.

Fix the msgb string for Handover Request Ack.

Extend some API doc comments.

Related: OS#2283 (inter-BSC Handover, BSC side, MT)
Change-Id: I03ee7ce840ecfa0b6a33358e7385528aabd4873f
---
M include/osmocom/gsm/gsm0808.h
M include/osmocom/gsm/gsm_utils.h
M src/gsm/gsm0808.c
M src/gsm/libosmogsm.map
4 files changed, 129 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/72/9672/1

diff --git a/include/osmocom/gsm/gsm0808.h b/include/osmocom/gsm/gsm0808.h
index d704aa9..5ae0af8 100644
--- a/include/osmocom/gsm/gsm0808.h
+++ b/include/osmocom/gsm/gsm0808.h
@@ -103,6 +103,7 @@
        } current_channel_type_2;

        /* more items are defined in the spec and may be added later */
+       bool more_items; /*< always set this to false */
 };

 /*! 3GPP TS 48.008 ยง3.2.1.9 HANDOVER REQUIRED */
@@ -120,6 +121,7 @@
        struct gsm0808_old_bss_to_new_bss_info old_bss_to_new_bss_info;

        /* 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_required(const struct 
gsm0808_handover_required *params);

@@ -127,6 +129,44 @@
                                                 uint8_t chosen_channel, 
uint8_t chosen_encr_alg,
                                                 uint8_t chosen_speech_version);

+struct msgb *gsm0808_create_handover_detect();
+
+struct gsm0808_handover_complete {
+       bool rr_cause_present;
+       uint8_t rr_cause;
+
+       bool speech_codec_chosen_present;
+       struct gsm0808_speech_codec speech_codec_chosen;
+
+       struct gsm0808_speech_codec_list codec_list_bss_supported; /*< omit 
when .len == 0 */
+
+       bool chosen_encr_alg_present;
+       uint8_t chosen_encr_alg;
+
+       bool chosen_channel_present;
+       uint8_t chosen_channel;
+
+       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_complete(const struct 
gsm0808_handover_complete *params);
+
+struct gsm0808_handover_failure {
+       uint16_t cause;
+
+       bool rr_cause_present;
+       uint8_t rr_cause;
+
+       struct gsm0808_speech_codec_list codec_list_bss_supported; /*< omit 
when .len == 0 */
+
+       /* 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_failure(const struct 
gsm0808_handover_failure *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);

diff --git a/include/osmocom/gsm/gsm_utils.h b/include/osmocom/gsm/gsm_utils.h
index 83e29ca..6ff4459 100644
--- a/include/osmocom/gsm/gsm_utils.h
+++ b/include/osmocom/gsm/gsm_utils.h
@@ -30,6 +30,8 @@

 #include <osmocom/core/defs.h>
 #include <osmocom/core/utils.h>
+#include <osmocom/gsm/protocol/gsm_08_08.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>

 #define ADD_MODULO(sum, delta, modulo) do {    \
        if ((sum += delta) >= modulo)           \
diff --git a/src/gsm/gsm0808.c b/src/gsm/gsm0808.c
index 3a63137..625de81 100644
--- a/src/gsm/gsm0808.c
+++ b/src/gsm/gsm0808.c
@@ -739,14 +739,16 @@
        return msg;
 }

-/*! Create BSSMAP HANDOVER REQUEST ACKNOWLEDGE message, 3GPP TS 48.008 
3.2.1.10. */
+/*! Create BSSMAP HANDOVER REQUEST ACKNOWLEDGE message, 3GPP TS 48.008 
3.2.1.10.
+ * Sent from the MT BSC back to the MSC when it has allocated an lchan to 
handover to.
+ * l3_info is the RR Handover Command that the MO BSC sends to the MS to move 
over. */
 struct msgb *gsm0808_create_handover_request_ack(const uint8_t *l3_info, 
uint8_t l3_info_len,
                                                 uint8_t chosen_channel, 
uint8_t chosen_encr_alg,
                                                 uint8_t chosen_speech_version)
 {
        struct msgb *msg;

-       msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM, 
"BSSMAP-HANDOVER-ACCEPT-ACK");
+       msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM, 
"BSSMAP-HANDOVER-REQUEST-ACK");
        if (!msg)
                return NULL;

@@ -764,6 +766,86 @@
        return msg;
 }

+/*! Create BSSMAP HANDOVER DETECT message, 3GPP TS 48.008 3.2.1.40.
+ * Sent from the MT BSC back to the MSC when the MS has sent a handover RACH 
request and the MT BSC has
+ * received the Handover Detect message. */
+struct msgb *gsm0808_create_handover_detect()
+{
+       struct msgb *msg;
+
+       msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM, 
"BSSMAP-HANDOVER-DETECT");
+       if (!msg)
+               return NULL;
+
+       /* Message Type, 3.2.2.1 */
+       msgb_v_put(msg, BSS_MAP_MSG_HANDOVER_DETECT);
+
+       return msg;
+}
+
+/*! Create BSSMAP HANDOVER COMPLETE message, 3GPP TS 48.008 3.2.1.12.
+ * Sent from the MT BSC back to the MSC when the MS has fully settled into the 
new lchan. */
+struct msgb *gsm0808_create_handover_complete(const struct 
gsm0808_handover_complete *params)
+{
+       struct msgb *msg;
+
+       msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM, 
"BSSMAP-HANDOVER-COMPLETE");
+       if (!msg)
+               return NULL;
+
+       /* Message Type, 3.2.2.1 */
+       msgb_v_put(msg, BSS_MAP_MSG_HANDOVER_COMPLETE);
+
+       /* RR Cause, 3.2.2.22 */
+       if (params->rr_cause_present)
+               msgb_tlv_put(msg, GSM0808_IE_RR_CAUSE, 1, &params->rr_cause);
+
+       /* AoIP: Speech Codec (Chosen) 3.2.2.104 */
+       if (params->speech_codec_chosen_present)
+               gsm0808_enc_speech_codec(msg, &params->speech_codec_chosen);
+
+       /* AoIP: add Codec List (BSS Supported) 3.2.2.103 */
+       if (params->codec_list_bss_supported.len)
+               gsm0808_enc_speech_codec_list(msg, 
&params->codec_list_bss_supported);
+
+       /* 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);
+
+       /* 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);
+
+       return msg;
+}
+
+/*! Create BSSMAP HANDOVER FAILURE message, 3GPP TS 48.008 3.2.1.16.
+ * Sent from the MT BSC back to the MSC when the handover has failed. */
+struct msgb *gsm0808_create_handover_failure(const struct 
gsm0808_handover_failure *params)
+{
+       struct msgb *msg;
+
+       msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM, 
"BSSMAP-HANDOVER-FAILURE");
+       if (!msg)
+               return NULL;
+
+       /* Message Type, 3.2.2.1 */
+       msgb_v_put(msg, BSS_MAP_MSG_HANDOVER_FAILURE);
+
+       /* Cause, 3.2.2.5 */
+       msgb_tlv_put(msg, GSM0808_IE_CAUSE, params->cause & 0x80? 2 : 1, (const 
uint8_t*)&params->cause);
+
+       /* RR Cause, 3.2.2.22 */
+       if (params->rr_cause_present)
+               msgb_tlv_put(msg, GSM0808_IE_RR_CAUSE, 1, &params->rr_cause);
+
+       /* AoIP: add Codec List (BSS Supported) 3.2.2.103 */
+       if (params->codec_list_bss_supported.len)
+               gsm0808_enc_speech_codec_list(msg, 
&params->codec_list_bss_supported);
+
+       return msg;
+}
+
 /*! Prepend a DTAP header to given Message Buffer
  *  \param[in] msgb Message Buffer
  *  \param[in] link_id Link Identifier */
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index 4d9811b..69fb24a 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -168,6 +168,9 @@
 gsm0808_create_sapi_reject;
 gsm0808_create_handover_required;
 gsm0808_create_handover_request_ack;
+gsm0808_create_handover_detect;
+gsm0808_create_handover_complete;
+gsm0808_create_handover_failure;
 gsm0808_prepend_dtap_header;
 gsm0808_enc_aoip_trasp_addr;
 gsm0808_dec_aoip_trasp_addr;

--
To view, visit https://gerrit.osmocom.org/9672
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I03ee7ce840ecfa0b6a33358e7385528aabd4873f
Gerrit-Change-Number: 9672
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <nhofm...@sysmocom.de>

Reply via email to