blob: 500d1873db5947ce5f99664bc1146a9111eb64f8 [file] [log] [blame]
Harald Weltea1482332009-11-14 10:08:40 +01001/* GSM silent call feature */
2
3/*
4 * (C) 2009 by Harald Welte <laforge@gnumonks.org>
5 *
6 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 */
23
24#include <stdlib.h>
25#include <unistd.h>
26#include <errno.h>
27
28#include <openbsc/msgb.h>
29#include <openbsc/signal.h>
30#include <openbsc/debug.h>
31#include <openbsc/paging.h>
32#include <openbsc/gsm_data.h>
33#include <openbsc/gsm_subscriber.h>
34#include <openbsc/abis_rsl.h>
Harald Welte986c3d72009-11-17 06:12:16 +010035#include <openbsc/chan_alloc.h>
Harald Weltea1482332009-11-14 10:08:40 +010036
37static int paging_cb_silent(unsigned int hooknum, unsigned int event,
38 struct msgb *msg, void *_lchan, void *_data)
39{
40 struct gsm_lchan *lchan = _lchan;
41 struct scall_signal_data sigdata;
42 int rc;
43
44 if (hooknum != GSM_HOOK_RR_PAGING)
45 return -EINVAL;
46
47 DEBUGP(DSMS, "paging_cb_silent: ");
48
49 sigdata.lchan = lchan;
50 sigdata.data = _data;
51
52 switch (event) {
53 case GSM_PAGING_SUCCEEDED:
54 DEBUGPC(DSMS, "success, using Timeslot %u on ARFCN %u\n",
55 lchan->ts->nr, lchan->ts->trx->arfcn);
Harald Welte83579ca2009-12-29 11:17:18 +010056 lchan->silent_call = 1;
Harald Weltea1482332009-11-14 10:08:40 +010057 /* increment lchan reference count */
58 dispatch_signal(SS_SCALL, S_SCALL_SUCCESS, &sigdata);
59 use_lchan(lchan);
60 break;
61 case GSM_PAGING_EXPIRED:
62 DEBUGP(DSMS, "expired\n");
63 dispatch_signal(SS_SCALL, S_SCALL_EXPIRED, &sigdata);
64 break;
65 default:
66 rc = -EINVAL;
67 break;
68 }
69
70 return rc;
71}
72
73int gsm_silent_call_start(struct gsm_subscriber *subscr, void *data)
74{
75 int rc;
76
77 rc = paging_request(subscr->net, subscr, RSL_CHANNEED_TCH_F,
78 paging_cb_silent, data);
79 return rc;
80}
81
82int gsm_silent_call_stop(struct gsm_subscriber *subscr)
83{
84 struct gsm_lchan *lchan;
85
86 lchan = lchan_for_subscr(subscr);
87 if (!lchan)
88 return -EINVAL;
89
Harald Welte83579ca2009-12-29 11:17:18 +010090 /* did we actually establish a silent call for this guy? */
91 if (!lchan->silent_call)
92 return -EINVAL;
93
Harald Weltea1482332009-11-14 10:08:40 +010094 put_lchan(lchan);
95
96 return 0;
97}