blob: 82b656327348cb27ebd962d0b1253a45e0842b58 [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);
56 /* increment lchan reference count */
57 dispatch_signal(SS_SCALL, S_SCALL_SUCCESS, &sigdata);
58 use_lchan(lchan);
59 break;
60 case GSM_PAGING_EXPIRED:
61 DEBUGP(DSMS, "expired\n");
62 dispatch_signal(SS_SCALL, S_SCALL_EXPIRED, &sigdata);
63 break;
64 default:
65 rc = -EINVAL;
66 break;
67 }
68
69 return rc;
70}
71
72int gsm_silent_call_start(struct gsm_subscriber *subscr, void *data)
73{
74 int rc;
75
76 rc = paging_request(subscr->net, subscr, RSL_CHANNEED_TCH_F,
77 paging_cb_silent, data);
78 return rc;
79}
80
81int gsm_silent_call_stop(struct gsm_subscriber *subscr)
82{
83 struct gsm_lchan *lchan;
84
85 lchan = lchan_for_subscr(subscr);
86 if (!lchan)
87 return -EINVAL;
88
89 /* FIXME: did we actually establish a silent call for this guy? */
90 put_lchan(lchan);
91
92 return 0;
93}