2009-11-14 09:08:40 +00:00
|
|
|
/* GSM silent call feature */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* (C) 2009 by Harald Welte <laforge@gnumonks.org>
|
|
|
|
*
|
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2011-01-01 14:25:50 +00:00
|
|
|
* 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
|
2009-11-14 09:08:40 +00:00
|
|
|
* (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
|
2011-01-01 14:25:50 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
2009-11-14 09:08:40 +00:00
|
|
|
*
|
2011-01-01 14:25:50 +00:00
|
|
|
* 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/>.
|
2009-11-14 09:08:40 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
split 'libosmocore' from openbsc codebase
This library is intended to collect all generic/common funcitionality
of all Osmocom.org projects, including OpenBSC but also OsmocomBB
The library currently includes the following modules:
bitvec, comp128, gsm_utils, msgb, select, signal, statistics, talloc, timer,
tlv_parse, linuxlist
msgb allocation error debugging had to be temporarily disabled as it depends on
'debug.c' functionality which at the moment remains in OpenBSC
2010-02-20 15:24:02 +00:00
|
|
|
#include <osmocore/msgb.h>
|
2009-11-14 09:08:40 +00:00
|
|
|
#include <openbsc/signal.h>
|
|
|
|
#include <openbsc/debug.h>
|
|
|
|
#include <openbsc/paging.h>
|
|
|
|
#include <openbsc/gsm_data.h>
|
|
|
|
#include <openbsc/gsm_subscriber.h>
|
|
|
|
#include <openbsc/abis_rsl.h>
|
2009-11-17 05:12:16 +00:00
|
|
|
#include <openbsc/chan_alloc.h>
|
2010-06-30 04:44:07 +00:00
|
|
|
#include <openbsc/osmo_msc.h>
|
2009-11-14 09:08:40 +00:00
|
|
|
|
2009-12-29 10:49:12 +00:00
|
|
|
/* paging of the requested subscriber has completed */
|
2009-11-14 09:08:40 +00:00
|
|
|
static int paging_cb_silent(unsigned int hooknum, unsigned int event,
|
2010-06-17 07:05:57 +00:00
|
|
|
struct msgb *msg, void *_conn, void *_data)
|
2009-11-14 09:08:40 +00:00
|
|
|
{
|
2010-06-17 07:05:57 +00:00
|
|
|
struct gsm_subscriber_connection *conn = _conn;
|
2009-11-14 09:08:40 +00:00
|
|
|
struct scall_signal_data sigdata;
|
2010-07-23 11:34:34 +00:00
|
|
|
int rc = 0;
|
2009-11-14 09:08:40 +00:00
|
|
|
|
|
|
|
if (hooknum != GSM_HOOK_RR_PAGING)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
DEBUGP(DSMS, "paging_cb_silent: ");
|
|
|
|
|
2010-06-17 07:05:57 +00:00
|
|
|
sigdata.conn = conn;
|
2009-11-14 09:08:40 +00:00
|
|
|
sigdata.data = _data;
|
|
|
|
|
|
|
|
switch (event) {
|
|
|
|
case GSM_PAGING_SUCCEEDED:
|
|
|
|
DEBUGPC(DSMS, "success, using Timeslot %u on ARFCN %u\n",
|
2010-06-17 07:05:57 +00:00
|
|
|
conn->lchan->ts->nr, conn->lchan->ts->trx->arfcn);
|
2010-03-23 05:41:45 +00:00
|
|
|
conn->silent_call = 1;
|
2009-11-14 09:08:40 +00:00
|
|
|
/* increment lchan reference count */
|
|
|
|
dispatch_signal(SS_SCALL, S_SCALL_SUCCESS, &sigdata);
|
|
|
|
break;
|
|
|
|
case GSM_PAGING_EXPIRED:
|
2010-12-23 17:19:17 +00:00
|
|
|
case GSM_PAGING_BUSY:
|
2009-11-14 09:08:40 +00:00
|
|
|
DEBUGP(DSMS, "expired\n");
|
|
|
|
dispatch_signal(SS_SCALL, S_SCALL_EXPIRED, &sigdata);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rc = -EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2009-12-29 10:49:12 +00:00
|
|
|
/* receive a layer 3 message from a silent call */
|
2010-06-21 02:34:03 +00:00
|
|
|
int silent_call_rx(struct gsm_subscriber_connection *conn, struct msgb *msg)
|
2009-12-29 10:49:12 +00:00
|
|
|
{
|
|
|
|
/* FIXME: do something like sending it through a UDP port */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct msg_match {
|
|
|
|
u_int8_t pdisc;
|
|
|
|
u_int8_t msg_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* list of messages that are handled inside OpenBSC, even in a silent call */
|
|
|
|
static const struct msg_match silent_call_accept[] = {
|
|
|
|
{ GSM48_PDISC_MM, GSM48_MT_MM_LOC_UPD_REQUEST },
|
|
|
|
{ GSM48_PDISC_MM, GSM48_MT_MM_CM_SERV_REQ },
|
|
|
|
};
|
|
|
|
|
|
|
|
/* decide if we need to reroute a message as part of a silent call */
|
2010-06-21 02:34:03 +00:00
|
|
|
int silent_call_reroute(struct gsm_subscriber_connection *conn, struct msgb *msg)
|
2009-12-29 10:49:12 +00:00
|
|
|
{
|
|
|
|
struct gsm48_hdr *gh = msgb_l3(msg);
|
|
|
|
u_int8_t pdisc = gh->proto_discr & 0x0f;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* if we're not part of a silent call, never reroute */
|
2010-06-21 02:34:03 +00:00
|
|
|
if (!conn->silent_call)
|
2009-12-29 10:49:12 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* check if we are a special message that is handled in openbsc */
|
|
|
|
for (i = 0; i < ARRAY_SIZE(silent_call_accept); i++) {
|
|
|
|
if (silent_call_accept[i].pdisc == pdisc &&
|
|
|
|
silent_call_accept[i].msg_type == gh->msg_type)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* otherwise, reroute */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* initiate a silent call with a given subscriber */
|
2010-01-02 13:29:43 +00:00
|
|
|
int gsm_silent_call_start(struct gsm_subscriber *subscr, void *data, int type)
|
2009-11-14 09:08:40 +00:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
2010-01-02 13:29:43 +00:00
|
|
|
rc = paging_request(subscr->net, subscr, type,
|
2009-11-14 09:08:40 +00:00
|
|
|
paging_cb_silent, data);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2009-12-29 10:49:12 +00:00
|
|
|
/* end a silent call with a given subscriber */
|
2009-11-14 09:08:40 +00:00
|
|
|
int gsm_silent_call_stop(struct gsm_subscriber *subscr)
|
|
|
|
{
|
2010-03-23 05:41:45 +00:00
|
|
|
struct gsm_subscriber_connection *conn;
|
2009-11-14 09:08:40 +00:00
|
|
|
|
2010-06-16 05:23:55 +00:00
|
|
|
conn = connection_for_subscr(subscr);
|
|
|
|
if (!conn)
|
2009-11-14 09:08:40 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
2009-12-29 10:17:18 +00:00
|
|
|
/* did we actually establish a silent call for this guy? */
|
2010-03-23 05:41:45 +00:00
|
|
|
if (!conn->silent_call)
|
2009-12-29 10:17:18 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
2010-06-28 09:09:29 +00:00
|
|
|
conn->silent_call = 0;
|
|
|
|
msc_release_connection(conn);
|
2009-11-14 09:08:40 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|