factor out gen of USSD notify and release complete to libosmocore
Both libmsc and libbsc will need distinct gsm0480_send_ussdNotify() and gsm0480_send_releaseComplete() functions, since there will be distinct subscriber connection structs. Rename to msc_send_ussd_notify() and msc_send_ussd_release_complete(), and add the same in libbsc with bsc_ prefix in new file gsm_04_80_utils.c. In preparation of this patch, the message generation part of these functions has been added to libosmocore as gsm0480_create_ussd_notify() and gsm0480_create_ussd_release_complete(). Use these. Adjust all libmsc and libbsc callers according to use the msc_* or bsc_* implementation, respectively. Change-Id: I33a84e3c28576ced91d2ea24103123431f551173
This commit is contained in:
parent
eb52aad198
commit
43273c63de
|
@ -14,7 +14,12 @@ int gsm0480_send_ussd_reject(struct gsm_subscriber_connection *conn,
|
|||
const struct msgb *msg,
|
||||
const struct ss_request *request);
|
||||
|
||||
int gsm0480_send_ussdNotify(struct gsm_subscriber_connection *conn, int level, const char *text);
|
||||
int gsm0480_send_releaseComplete(struct gsm_subscriber_connection *conn);
|
||||
int msc_send_ussd_notify(struct gsm_subscriber_connection *conn, int level,
|
||||
const char *text);
|
||||
int msc_send_ussd_release_complete(struct gsm_subscriber_connection *conn);
|
||||
|
||||
int bsc_send_ussd_notify(struct gsm_subscriber_connection *conn, int level,
|
||||
const char *text);
|
||||
int bsc_send_ussd_release_complete(struct gsm_subscriber_connection *conn);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -41,6 +41,7 @@ libbsc_a_SOURCES = \
|
|||
bsc_api.c \
|
||||
bsc_msc.c bsc_vty.c \
|
||||
gsm_04_08_utils.c \
|
||||
gsm_04_80_utils.c \
|
||||
bsc_init.c \
|
||||
bts_init.c \
|
||||
bsc_rf_ctrl.c \
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/* OpenBSC utility functions for 3GPP TS 04.80 */
|
||||
|
||||
/* (C) 2016 by sysmocom s.m.f.c. GmbH <info@sysmocom.de>
|
||||
*
|
||||
* All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <osmocom/gsm/gsm0480.h>
|
||||
#include <openbsc/bsc_api.h>
|
||||
|
||||
int bsc_send_ussd_notify(struct gsm_subscriber_connection *conn, int level,
|
||||
const char *text)
|
||||
{
|
||||
struct msgb *msg = gsm0480_create_ussd_notify(level, text);
|
||||
if (!msg)
|
||||
return -1;
|
||||
return gsm0808_submit_dtap(conn, msg, 0, 0);
|
||||
}
|
||||
|
||||
int bsc_send_ussd_release_complete(struct gsm_subscriber_connection *conn)
|
||||
{
|
||||
struct msgb *msg = gsm0480_create_ussd_release_complete();
|
||||
if (!msg)
|
||||
return -1;
|
||||
return gsm0808_submit_dtap(conn, msg, 0, 0);
|
||||
}
|
|
@ -138,38 +138,18 @@ int gsm0480_send_ussd_reject(struct gsm_subscriber_connection *conn,
|
|||
return gsm0808_submit_dtap(conn, msg, 0, 0);
|
||||
}
|
||||
|
||||
int gsm0480_send_ussdNotify(struct gsm_subscriber_connection *conn, int level, const char *text)
|
||||
int msc_send_ussd_notify(struct gsm_subscriber_connection *conn, int level, const char *text)
|
||||
{
|
||||
struct gsm48_hdr *gh;
|
||||
struct msgb *msg;
|
||||
|
||||
msg = gsm0480_create_unstructuredSS_Notify(level, text);
|
||||
struct msgb *msg = gsm0480_create_ussd_notify(level, text);
|
||||
if (!msg)
|
||||
return -1;
|
||||
|
||||
gsm0480_wrap_invoke(msg, GSM0480_OP_CODE_USS_NOTIFY, 0);
|
||||
gsm0480_wrap_facility(msg);
|
||||
|
||||
/* And finally pre-pend the L3 header */
|
||||
gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh));
|
||||
gh->proto_discr = GSM48_PDISC_NC_SS;
|
||||
gh->msg_type = GSM0480_MTYPE_REGISTER;
|
||||
|
||||
return gsm0808_submit_dtap(conn, msg, 0, 0);
|
||||
}
|
||||
|
||||
int gsm0480_send_releaseComplete(struct gsm_subscriber_connection *conn)
|
||||
int msc_send_ussd_release_complete(struct gsm_subscriber_connection *conn)
|
||||
{
|
||||
struct gsm48_hdr *gh;
|
||||
struct msgb *msg;
|
||||
|
||||
msg = gsm48_msgb_alloc_name("GSM 04.08 USSD REL COMPL");
|
||||
struct msgb *msg = gsm0480_create_ussd_release_complete();
|
||||
if (!msg)
|
||||
return -1;
|
||||
|
||||
gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh));
|
||||
gh->proto_discr = GSM48_PDISC_NC_SS;
|
||||
gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE;
|
||||
|
||||
return gsm0808_submit_dtap(conn, msg, 0, 0);
|
||||
}
|
||||
|
|
|
@ -473,8 +473,8 @@ DEFUN(subscriber_ussd_notify,
|
|||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
gsm0480_send_ussdNotify(conn, level, text);
|
||||
gsm0480_send_releaseComplete(conn);
|
||||
msc_send_ussd_notify(conn, level, text);
|
||||
msc_send_ussd_release_complete(conn);
|
||||
|
||||
subscr_put(subscr);
|
||||
talloc_free(text);
|
||||
|
|
|
@ -205,8 +205,8 @@ static void bsc_send_ussd_no_srv(struct gsm_subscriber_connection *conn,
|
|||
gsm48_tx_mm_serv_ack(conn);
|
||||
|
||||
LOGP(DMSC, LOGL_INFO, "Sending USSD message: '%s'\n", text);
|
||||
gsm0480_send_ussdNotify(conn, 1, text);
|
||||
gsm0480_send_releaseComplete(conn);
|
||||
bsc_send_ussd_notify(conn, 1, text);
|
||||
bsc_send_ussd_release_complete(conn);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -598,8 +598,8 @@ static int set_net_ussd_notify(struct ctrl_cmd *cmd, void *data)
|
|||
* the release complete when we get a returnResultLast
|
||||
* for this invoke id.
|
||||
*/
|
||||
gsm0480_send_releaseComplete(conn);
|
||||
gsm0480_send_ussdNotify(conn, alert, text_str);
|
||||
bsc_send_ussd_release_complete(conn);
|
||||
bsc_send_ussd_notify(conn, alert, text_str);
|
||||
cmd->reply = "Found a connection";
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -246,8 +246,8 @@ static int send_welcome_ussd(struct gsm_subscriber_connection *conn)
|
|||
|
||||
int bsc_send_welcome_ussd(struct gsm_subscriber_connection *conn)
|
||||
{
|
||||
gsm0480_send_ussdNotify(conn, 1, conn->sccp_con->msc->ussd_welcome_txt);
|
||||
gsm0480_send_releaseComplete(conn);
|
||||
bsc_send_ussd_notify(conn, 1, conn->sccp_con->msc->ussd_welcome_txt);
|
||||
bsc_send_ussd_release_complete(conn);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -112,8 +112,8 @@ static int handle_sub(struct gsm_lchan *lchan, const char *text)
|
|||
if (lchan->state != LCHAN_S_ACTIVE)
|
||||
return -1;
|
||||
|
||||
gsm0480_send_ussdNotify(conn, 0, text);
|
||||
gsm0480_send_releaseComplete(conn);
|
||||
bsc_send_ussd_notify(conn, 0, text);
|
||||
bsc_send_ussd_release_complete(conn);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -285,8 +285,8 @@ static void bsc_notify_msc_lost(struct osmo_bsc_sccp_con *con)
|
|||
return;
|
||||
|
||||
/* send USSD notification */
|
||||
gsm0480_send_ussdNotify(conn, 1, conn->sccp_con->msc->ussd_msc_lost_txt);
|
||||
gsm0480_send_releaseComplete(conn);
|
||||
bsc_send_ussd_notify(conn, 1, conn->sccp_con->msc->ussd_msc_lost_txt);
|
||||
bsc_send_ussd_release_complete(conn);
|
||||
}
|
||||
|
||||
static void bsc_notify_and_close_conns(struct bsc_msc_connection *msc_con)
|
||||
|
|
Loading…
Reference in New Issue