Harald Welte | a148233 | 2009-11-14 10:08:40 +0100 | [diff] [blame] | 1 | /* 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> |
| 35 | |
| 36 | static int paging_cb_silent(unsigned int hooknum, unsigned int event, |
| 37 | struct msgb *msg, void *_lchan, void *_data) |
| 38 | { |
| 39 | struct gsm_lchan *lchan = _lchan; |
| 40 | struct scall_signal_data sigdata; |
| 41 | int rc; |
| 42 | |
| 43 | if (hooknum != GSM_HOOK_RR_PAGING) |
| 44 | return -EINVAL; |
| 45 | |
| 46 | DEBUGP(DSMS, "paging_cb_silent: "); |
| 47 | |
| 48 | sigdata.lchan = lchan; |
| 49 | sigdata.data = _data; |
| 50 | |
| 51 | switch (event) { |
| 52 | case GSM_PAGING_SUCCEEDED: |
| 53 | DEBUGPC(DSMS, "success, using Timeslot %u on ARFCN %u\n", |
| 54 | lchan->ts->nr, lchan->ts->trx->arfcn); |
| 55 | /* increment lchan reference count */ |
| 56 | dispatch_signal(SS_SCALL, S_SCALL_SUCCESS, &sigdata); |
| 57 | use_lchan(lchan); |
| 58 | break; |
| 59 | case GSM_PAGING_EXPIRED: |
| 60 | DEBUGP(DSMS, "expired\n"); |
| 61 | dispatch_signal(SS_SCALL, S_SCALL_EXPIRED, &sigdata); |
| 62 | break; |
| 63 | default: |
| 64 | rc = -EINVAL; |
| 65 | break; |
| 66 | } |
| 67 | |
| 68 | return rc; |
| 69 | } |
| 70 | |
| 71 | int gsm_silent_call_start(struct gsm_subscriber *subscr, void *data) |
| 72 | { |
| 73 | int rc; |
| 74 | |
| 75 | rc = paging_request(subscr->net, subscr, RSL_CHANNEED_TCH_F, |
| 76 | paging_cb_silent, data); |
| 77 | return rc; |
| 78 | } |
| 79 | |
| 80 | int gsm_silent_call_stop(struct gsm_subscriber *subscr) |
| 81 | { |
| 82 | struct gsm_lchan *lchan; |
| 83 | |
| 84 | lchan = lchan_for_subscr(subscr); |
| 85 | if (!lchan) |
| 86 | return -EINVAL; |
| 87 | |
| 88 | /* FIXME: did we actually establish a silent call for this guy? */ |
| 89 | put_lchan(lchan); |
| 90 | |
| 91 | return 0; |
| 92 | } |