blob: bc6f3cf55fe7ae8250012408937d434f4088aca6 [file] [log] [blame]
Holger Hans Peter Freyther9a23af62009-06-12 07:08:13 +02001/* The concept of a subscriber for the MSC, roughly HLR/VLR functionality */
Harald Welte59b04682009-06-10 05:40:52 +08002
3/* (C) 2008 by Harald Welte <laforge@gnumonks.org>
Holger Hans Peter Freytherc25021f2013-06-30 15:30:47 +02004 * (C) 2009,2013 by Holger Hans Peter Freyther <zecke@selfish.org>
Harald Welte59b04682009-06-10 05:40:52 +08005 *
6 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
Harald Welte0e3e88e2011-01-01 15:25:50 +01009 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
Harald Welte59b04682009-06-10 05:40:52 +080011 * (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
Harald Welte0e3e88e2011-01-01 15:25:50 +010016 * GNU Affero General Public License for more details.
Harald Welte59b04682009-06-10 05:40:52 +080017 *
Harald Welte0e3e88e2011-01-01 15:25:50 +010018 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Harald Welte59b04682009-06-10 05:40:52 +080020 *
21 */
22
23#include <unistd.h>
24#include <stdlib.h>
25#include <stdio.h>
26#include <string.h>
Holger Freyther8bdf7622009-04-18 13:48:55 +020027#include <assert.h>
Jan Luebbefe7cc1e2012-12-27 00:27:16 +010028#include <time.h>
Harald Welte59b04682009-06-10 05:40:52 +080029
Pablo Neira Ayusodd5fff42011-03-22 16:47:59 +010030#include <osmocom/core/talloc.h>
Sylvain Munaut34619752010-12-01 21:07:29 +010031
Holger Hans Peter Freyther0fe0c8c2010-12-29 11:07:22 +010032#include <osmocom/vty/vty.h>
33
Harald Welte59b04682009-06-10 05:40:52 +080034#include <openbsc/gsm_subscriber.h>
Sylvain Munaut65c51b62010-12-01 22:38:03 +010035#include <openbsc/gsm_04_08.h>
Harald Welte59b04682009-06-10 05:40:52 +080036#include <openbsc/debug.h>
Sylvain Munaut34619752010-12-01 21:07:29 +010037#include <openbsc/paging.h>
Harald Welteb7799832009-07-29 23:14:15 +020038#include <openbsc/signal.h>
Harald Welte59b04682009-06-10 05:40:52 +080039#include <openbsc/db.h>
Holger Hans Peter Freytherc25021f2013-06-30 15:30:47 +020040#include <openbsc/chan_alloc.h>
Harald Welte59b04682009-06-10 05:40:52 +080041
Sylvain Munaut34619752010-12-01 21:07:29 +010042void *tall_sub_req_ctx;
43
Jan Luebbe8f7f1d12012-12-25 18:58:34 +010044extern struct llist_head *subscr_bsc_active_subscribers(void);
Harald Welte59b04682009-06-10 05:40:52 +080045
Sylvain Munaut65c51b62010-12-01 22:38:03 +010046int gsm48_secure_channel(struct gsm_subscriber_connection *conn, int key_seq,
47 gsm_cbfn *cb, void *cb_data);
48
Sylvain Munaut34619752010-12-01 21:07:29 +010049
50/*
51 * Struct for pending channel requests. This is managed in the
52 * llist_head requests of each subscriber. The reference counting
53 * should work in such a way that a subscriber with a pending request
54 * remains in memory.
55 */
56struct subscr_request {
57 struct llist_head entry;
58
59 /* back reference */
60 struct gsm_subscriber *subscr;
61
62 /* the requested channel type */
63 int channel_type;
64
Holger Hans Peter Freytherc45f0a62010-12-29 09:33:34 +010065 /* what did we do */
66 int state;
67
Sylvain Munaut34619752010-12-01 21:07:29 +010068 /* the callback data */
69 gsm_cbfn *cbfn;
70 void *param;
71};
72
Holger Hans Peter Freytherc45f0a62010-12-29 09:33:34 +010073enum {
74 REQ_STATE_INITIAL,
75 REQ_STATE_QUEUED,
76 REQ_STATE_PAGED,
77 REQ_STATE_FAILED_START,
78 REQ_STATE_DISPATCHED,
79};
80
Holger Hans Peter Freytherabe587d2013-10-04 08:35:11 +020081static struct gsm_subscriber *get_subscriber(struct gsm_network *net,
82 int type, const char *ident)
83{
84 struct gsm_subscriber *subscr = db_get_subscriber(type, ident);
85 if (subscr)
86 subscr->net = net;
87 return subscr;
88}
89
Sylvain Munaut34619752010-12-01 21:07:29 +010090/*
91 * We got the channel assigned and can now hand this channel
92 * over to one of our callbacks.
93 */
Sylvain Munaut65c51b62010-12-01 22:38:03 +010094static int subscr_paging_dispatch(unsigned int hooknum, unsigned int event,
95 struct msgb *msg, void *data, void *param)
Sylvain Munaut34619752010-12-01 21:07:29 +010096{
97 struct subscr_request *request;
Sylvain Munaut7a8f8812010-12-01 23:04:03 +010098 struct gsm_subscriber_connection *conn = data;
Sylvain Munaut65c51b62010-12-01 22:38:03 +010099 struct gsm_subscriber *subscr = param;
Sylvain Munaut7a8f8812010-12-01 23:04:03 +0100100 struct paging_signal_data sig_data;
Sylvain Munaut34619752010-12-01 21:07:29 +0100101
102 /* There is no request anymore... */
103 if (llist_empty(&subscr->requests))
104 return -1;
105
Sylvain Munaut7a8f8812010-12-01 23:04:03 +0100106 /* Dispatch signal */
107 sig_data.subscr = subscr;
108 sig_data.bts = conn ? conn->bts : NULL;
109 sig_data.conn = conn;
Holger Hans Peter Freytherab2a9332010-12-23 18:19:17 +0100110 sig_data.paging_result = event;
Pablo Neira Ayusoef717c62011-05-06 12:12:31 +0200111 osmo_signal_dispatch(
Sylvain Munaut7a8f8812010-12-01 23:04:03 +0100112 SS_PAGING,
113 event == GSM_PAGING_SUCCEEDED ?
114 S_PAGING_SUCCEEDED : S_PAGING_EXPIRED,
115 &sig_data
116 );
117
Sylvain Munaut34619752010-12-01 21:07:29 +0100118 /*
119 * FIXME: What to do with paging requests coming during
120 * this callback? We must be sure to not start paging when
121 * we have an active connection to a subscriber and to make
122 * the subscr_put_channel work as required...
123 */
124 request = (struct subscr_request *)subscr->requests.next;
Holger Hans Peter Freytherc45f0a62010-12-29 09:33:34 +0100125 request->state = REQ_STATE_DISPATCHED;
Sylvain Munaut34619752010-12-01 21:07:29 +0100126 llist_del(&request->entry);
127 subscr->in_callback = 1;
128 request->cbfn(hooknum, event, msg, data, request->param);
129 subscr->in_callback = 0;
130
Holger Hans Peter Freythera32e9c12010-12-28 17:47:43 +0100131 if (event != GSM_PAGING_SUCCEEDED) {
132 /*
133 * This is a workaround for a bigger issue. We have
134 * issued paging that might involve multiple BTSes
135 * and one of them have failed now. We will stop the
136 * other paging requests as well as the next timeout
137 * would work on the next paging request and the queue
138 * will do bad things. This should be fixed by counting
139 * the outstanding results.
140 */
141 paging_request_stop(NULL, subscr, NULL, NULL);
Holger Hans Peter Freytherbffd4852010-12-28 17:27:05 +0100142 subscr_put_channel(subscr);
Holger Hans Peter Freythera32e9c12010-12-28 17:47:43 +0100143 }
Holger Hans Peter Freytherbffd4852010-12-28 17:27:05 +0100144
Sylvain Munaut34619752010-12-01 21:07:29 +0100145 subscr_put(subscr);
146 talloc_free(request);
147 return 0;
148}
149
Sylvain Munaut65c51b62010-12-01 22:38:03 +0100150static int subscr_paging_sec_cb(unsigned int hooknum, unsigned int event,
151 struct msgb *msg, void *data, void *param)
152{
153 int rc;
154
155 switch (event) {
156 case GSM_SECURITY_AUTH_FAILED:
157 /* Dispatch as paging failure */
158 rc = subscr_paging_dispatch(
159 GSM_HOOK_RR_PAGING, GSM_PAGING_EXPIRED,
160 msg, data, param);
161 break;
162
163 case GSM_SECURITY_NOAVAIL:
164 case GSM_SECURITY_SUCCEEDED:
165 /* Dispatch as paging failure */
166 rc = subscr_paging_dispatch(
167 GSM_HOOK_RR_PAGING, GSM_PAGING_SUCCEEDED,
168 msg, data, param);
169 break;
170
171 default:
172 rc = -EINVAL;
173 }
174
175 return rc;
176}
177
178static int subscr_paging_cb(unsigned int hooknum, unsigned int event,
179 struct msgb *msg, void *data, void *param)
180{
181 struct gsm_subscriber_connection *conn = data;
182 struct gsm48_hdr *gh;
183 struct gsm48_pag_resp *pr;
184
185 /* Other cases mean problem, dispatch direclty */
186 if (event != GSM_PAGING_SUCCEEDED)
187 return subscr_paging_dispatch(hooknum, event, msg, data, param);
188
189 /* Get paging response */
190 gh = msgb_l3(msg);
191 pr = (struct gsm48_pag_resp *)gh->data;
192
193 /* We _really_ have a channel, secure it now ! */
194 return gsm48_secure_channel(conn, pr->key_seq, subscr_paging_sec_cb, param);
195}
196
197
Sylvain Munaut34619752010-12-01 21:07:29 +0100198static void subscr_send_paging_request(struct gsm_subscriber *subscr)
199{
200 struct subscr_request *request;
201 int rc;
202
203 assert(!llist_empty(&subscr->requests));
204
205 request = (struct subscr_request *)subscr->requests.next;
Holger Hans Peter Freytherc45f0a62010-12-29 09:33:34 +0100206 request->state = REQ_STATE_PAGED;
Sylvain Munaut34619752010-12-01 21:07:29 +0100207 rc = paging_request(subscr->net, subscr, request->channel_type,
208 subscr_paging_cb, subscr);
209
210 /* paging failed, quit now */
211 if (rc <= 0) {
Holger Hans Peter Freytherc45f0a62010-12-29 09:33:34 +0100212 request->state = REQ_STATE_FAILED_START;
Holger Hans Peter Freytherab2a9332010-12-23 18:19:17 +0100213 subscr_paging_cb(GSM_HOOK_RR_PAGING, GSM_PAGING_BUSY,
Sylvain Munaut34619752010-12-01 21:07:29 +0100214 NULL, NULL, subscr);
215 }
216}
217
218void subscr_get_channel(struct gsm_subscriber *subscr,
219 int type, gsm_cbfn *cbfn, void *param)
220{
221 struct subscr_request *request;
222
223 request = talloc(tall_sub_req_ctx, struct subscr_request);
224 if (!request) {
225 if (cbfn)
226 cbfn(GSM_HOOK_RR_PAGING, GSM_PAGING_OOM,
227 NULL, NULL, param);
228 return;
229 }
230
231 memset(request, 0, sizeof(*request));
232 request->subscr = subscr_get(subscr);
233 request->channel_type = type;
234 request->cbfn = cbfn;
235 request->param = param;
Holger Hans Peter Freytherc45f0a62010-12-29 09:33:34 +0100236 request->state = REQ_STATE_INITIAL;
Sylvain Munaut34619752010-12-01 21:07:29 +0100237
238 /*
239 * FIXME: We might be able to assign more than one
240 * channel, e.g. voice and SMS submit at the same
241 * time.
242 */
243 if (!subscr->in_callback && llist_empty(&subscr->requests)) {
244 /* add to the list, send a request */
245 llist_add_tail(&request->entry, &subscr->requests);
246 subscr_send_paging_request(subscr);
247 } else {
248 /* this will be picked up later, from subscr_put_channel */
249 llist_add_tail(&request->entry, &subscr->requests);
Holger Hans Peter Freytherc45f0a62010-12-29 09:33:34 +0100250 request->state = REQ_STATE_QUEUED;
Sylvain Munaut34619752010-12-01 21:07:29 +0100251 }
252}
253
Holger Hans Peter Freyther000571f2010-12-27 22:43:28 +0100254void subscr_put_channel(struct gsm_subscriber *subscr)
Sylvain Munaut34619752010-12-01 21:07:29 +0100255{
256 /*
257 * FIXME: Continue with other requests now... by checking
258 * the gsm_subscriber inside the gsm_lchan. Drop the ref count
259 * of the lchan after having asked the next requestee to handle
260 * the channel.
261 */
262 /*
263 * FIXME: is the lchan is of a different type we could still
264 * issue an immediate assignment for another channel and then
265 * close this one.
266 */
267 /*
268 * Currently we will drop the last ref of the lchan which
269 * will result in a channel release on RSL and we will start
270 * the paging. This should work most of the time as the MS
271 * will listen to the paging requests before we timeout
272 */
273
Holger Hans Peter Freyther000571f2010-12-27 22:43:28 +0100274 if (subscr && !llist_empty(&subscr->requests))
275 subscr_send_paging_request(subscr);
Sylvain Munaut34619752010-12-01 21:07:29 +0100276}
277
Holger Hans Peter Freytherabe587d2013-10-04 08:35:11 +0200278struct gsm_subscriber *subscr_create_subscriber(struct gsm_network *net,
279 const char *imsi)
280{
281 struct gsm_subscriber *subscr = db_create_subscriber(imsi);
282 if (subscr)
283 subscr->net = net;
284 return subscr;
285}
Sylvain Munaut34619752010-12-01 21:07:29 +0100286
Harald Welte75350412009-07-23 18:46:00 +0200287struct gsm_subscriber *subscr_get_by_tmsi(struct gsm_network *net,
Holger Hans Peter Freyther7eb8a9a2011-04-18 17:04:00 +0200288 uint32_t tmsi)
Harald Welte59b04682009-06-10 05:40:52 +0800289{
Holger Hans Peter Freythercd8bacf2009-08-19 12:53:57 +0200290 char tmsi_string[14];
Harald Welte59b04682009-06-10 05:40:52 +0800291 struct gsm_subscriber *subscr;
292
293 /* we might have a record in memory already */
Jan Luebbe8f7f1d12012-12-25 18:58:34 +0100294 llist_for_each_entry(subscr, subscr_bsc_active_subscribers(), entry) {
Holger Hans Peter Freythercd8bacf2009-08-19 12:53:57 +0200295 if (tmsi == subscr->tmsi)
Harald Welte59b04682009-06-10 05:40:52 +0800296 return subscr_get(subscr);
297 }
298
Holger Hans Peter Freythercd8bacf2009-08-19 12:53:57 +0200299 sprintf(tmsi_string, "%u", tmsi);
Holger Hans Peter Freytherabe587d2013-10-04 08:35:11 +0200300 return get_subscriber(net, GSM_SUBSCRIBER_TMSI, tmsi_string);
Harald Welte59b04682009-06-10 05:40:52 +0800301}
302
Harald Welte75350412009-07-23 18:46:00 +0200303struct gsm_subscriber *subscr_get_by_imsi(struct gsm_network *net,
304 const char *imsi)
Harald Welte59b04682009-06-10 05:40:52 +0800305{
306 struct gsm_subscriber *subscr;
307
Jan Luebbe8f7f1d12012-12-25 18:58:34 +0100308 llist_for_each_entry(subscr, subscr_bsc_active_subscribers(), entry) {
Harald Welte59b04682009-06-10 05:40:52 +0800309 if (strcmp(subscr->imsi, imsi) == 0)
310 return subscr_get(subscr);
311 }
312
Holger Hans Peter Freytherabe587d2013-10-04 08:35:11 +0200313 return get_subscriber(net, GSM_SUBSCRIBER_IMSI, imsi);
Harald Welte59b04682009-06-10 05:40:52 +0800314}
315
Harald Welte75350412009-07-23 18:46:00 +0200316struct gsm_subscriber *subscr_get_by_extension(struct gsm_network *net,
317 const char *ext)
Harald Welte59b04682009-06-10 05:40:52 +0800318{
319 struct gsm_subscriber *subscr;
320
Jan Luebbe8f7f1d12012-12-25 18:58:34 +0100321 llist_for_each_entry(subscr, subscr_bsc_active_subscribers(), entry) {
Harald Welte59b04682009-06-10 05:40:52 +0800322 if (strcmp(subscr->extension, ext) == 0)
323 return subscr_get(subscr);
324 }
325
Holger Hans Peter Freytherabe587d2013-10-04 08:35:11 +0200326 return get_subscriber(net, GSM_SUBSCRIBER_EXTENSION, ext);
Harald Welte59b04682009-06-10 05:40:52 +0800327}
328
Harald Welte68b7df22009-08-08 16:03:15 +0200329struct gsm_subscriber *subscr_get_by_id(struct gsm_network *net,
330 unsigned long long id)
331{
332 struct gsm_subscriber *subscr;
333 char buf[32];
334 sprintf(buf, "%llu", id);
335
Jan Luebbe8f7f1d12012-12-25 18:58:34 +0100336 llist_for_each_entry(subscr, subscr_bsc_active_subscribers(), entry) {
Harald Welte68b7df22009-08-08 16:03:15 +0200337 if (subscr->id == id)
338 return subscr_get(subscr);
339 }
340
Holger Hans Peter Freytherabe587d2013-10-04 08:35:11 +0200341 return get_subscriber(net, GSM_SUBSCRIBER_ID, buf);
Harald Welte68b7df22009-08-08 16:03:15 +0200342}
343
Holger Hans Peter Freytherc25021f2013-06-30 15:30:47 +0200344int subscr_update_expire_lu(struct gsm_subscriber *s, struct gsm_bts *bts)
345{
346 int rc;
347
348 /* Table 10.5.33: The T3212 timeout value field is coded as the
349 * binary representation of the timeout value for
350 * periodic updating in decihours. Mark the subscriber as
351 * inactive if it missed two consecutive location updates.
352 * Timeout is twice the t3212 value plus one minute */
Holger Hans Peter Freyther2fb8ebf2013-07-27 21:07:57 +0200353
354 /* Is expiration handling enabled? */
355 if (bts->si_common.chan_desc.t3212 == 0)
356 s->expire_lu = GSM_SUBSCRIBER_NO_EXPIRATION;
357 else
358 s->expire_lu = time(NULL) +
Holger Hans Peter Freytherc25021f2013-06-30 15:30:47 +0200359 (bts->si_common.chan_desc.t3212 * 60 * 6 * 2) + 60;
Holger Hans Peter Freyther2fb8ebf2013-07-27 21:07:57 +0200360
Holger Hans Peter Freytherc25021f2013-06-30 15:30:47 +0200361 rc = db_sync_subscriber(s);
362 db_subscriber_update(s);
363 return rc;
364}
Harald Welte68b7df22009-08-08 16:03:15 +0200365
Harald Welte59b04682009-06-10 05:40:52 +0800366int subscr_update(struct gsm_subscriber *s, struct gsm_bts *bts, int reason)
367{
Holger Hans Peter Freyther52a63752010-12-25 19:40:14 +0100368 int rc;
369
Harald Welte59b04682009-06-10 05:40:52 +0800370 /* FIXME: Migrate pending requests from one BSC to another */
371 switch (reason) {
372 case GSM_SUBSCRIBER_UPDATE_ATTACHED:
Harald Weltec2189a62009-07-23 18:56:43 +0200373 s->net = bts->network;
Harald Welte59b04682009-06-10 05:40:52 +0800374 /* Indicate "attached to LAC" */
375 s->lac = bts->location_area_code;
Jan Luebbefe7cc1e2012-12-27 00:27:16 +0100376
Holger Hans Peter Freytherc25021f2013-06-30 15:30:47 +0200377 LOGP(DMM, LOGL_INFO, "Subscriber %s ATTACHED LAC=%u\n",
378 subscr_name(s), s->lac);
379
Holger Hans Peter Freytherc25021f2013-06-30 15:30:47 +0200380 /*
381 * The below will set a new expire_lu but as a side-effect
382 * the new lac will be saved in the database.
383 */
384 rc = subscr_update_expire_lu(s, bts);
Pablo Neira Ayusoef717c62011-05-06 12:12:31 +0200385 osmo_signal_dispatch(SS_SUBSCR, S_SUBSCR_ATTACHED, s);
Harald Welte59b04682009-06-10 05:40:52 +0800386 break;
387 case GSM_SUBSCRIBER_UPDATE_DETACHED:
388 /* Only detach if we are currently in this area */
389 if (bts->location_area_code == s->lac)
Holger Hans Peter Freyther6c6ab862009-10-01 04:07:15 +0200390 s->lac = GSM_LAC_RESERVED_DETACHED;
Harald Welte0747c6a2009-12-24 14:50:24 +0100391 LOGP(DMM, LOGL_INFO, "Subscriber %s DETACHED\n", subscr_name(s));
Holger Hans Peter Freyther52a63752010-12-25 19:40:14 +0100392 rc = db_sync_subscriber(s);
393 db_subscriber_update(s);
Pablo Neira Ayusoef717c62011-05-06 12:12:31 +0200394 osmo_signal_dispatch(SS_SUBSCR, S_SUBSCR_DETACHED, s);
Harald Welte59b04682009-06-10 05:40:52 +0800395 break;
396 default:
397 fprintf(stderr, "subscr_update with unknown reason: %d\n",
398 reason);
Holger Hans Peter Freyther52a63752010-12-25 19:40:14 +0100399 rc = db_sync_subscriber(s);
400 db_subscriber_update(s);
Harald Welte59b04682009-06-10 05:40:52 +0800401 break;
402 };
Holger Hans Peter Freyther52a63752010-12-25 19:40:14 +0100403
404 return rc;
Harald Welte59b04682009-06-10 05:40:52 +0800405}
406
Holger Hans Peter Freyther0c29e5f2010-12-22 18:12:11 +0100407void subscr_update_from_db(struct gsm_subscriber *sub)
408{
409 db_subscriber_update(sub);
410}
Holger Hans Peter Freyther5b72b302010-12-28 22:12:30 +0100411
Jan Luebbefe7cc1e2012-12-27 00:27:16 +0100412static void subscr_expire_callback(void *data, long long unsigned int id)
413{
414 struct gsm_network *net = data;
Holger Hans Peter Freytherc25021f2013-06-30 15:30:47 +0200415 struct gsm_subscriber *s = subscr_get_by_id(net, id);
416 struct gsm_subscriber_connection *conn = connection_for_subscr(s);
417
418 /*
419 * The subscriber is active and the phone stopped the timer. As
420 * we don't want to periodically update the database for active
421 * subscribers we will just do it when the subscriber was selected
422 * for expiration. This way on the next around another subscriber
423 * will be selected.
424 */
425 if (conn && conn->expire_timer_stopped) {
426 LOGP(DMM, LOGL_DEBUG, "Not expiring subscriber %s (ID %llu)\n",
427 subscr_name(s), id);
428 subscr_update_expire_lu(s, conn->bts);
429 return;
430 }
431
Jan Luebbefe7cc1e2012-12-27 00:27:16 +0100432
Holger Hans Peter Freyther274e93e2013-07-04 20:22:27 +0200433 LOGP(DMM, LOGL_NOTICE, "Expiring inactive subscriber %s (ID %llu)\n",
Jan Luebbefe7cc1e2012-12-27 00:27:16 +0100434 subscr_name(s), id);
435 s->lac = GSM_LAC_RESERVED_DETACHED;
436 db_sync_subscriber(s);
437
438 subscr_put(s);
439}
440
441void subscr_expire(struct gsm_network *net)
442{
443 db_subscriber_expire(net, subscr_expire_callback);
444}
445
Holger Hans Peter Freyther5b72b302010-12-28 22:12:30 +0100446int subscr_pending_requests(struct gsm_subscriber *sub)
447{
448 struct subscr_request *req;
449 int pending = 0;
450
451 llist_for_each_entry(req, &sub->requests, entry)
452 pending += 1;
453
454 return pending;
455}
Holger Hans Peter Freytherce69aec2010-12-28 22:21:55 +0100456
457int subscr_pending_clear(struct gsm_subscriber *sub)
458{
459 int deleted = 0;
460 struct subscr_request *req, *tmp;
461
462 llist_for_each_entry_safe(req, tmp, &sub->requests, entry) {
463 subscr_put(req->subscr);
464 llist_del(&req->entry);
465 talloc_free(req);
466 deleted += 1;
467 }
468
469 return deleted;
470}
Holger Hans Peter Freyther0fe0c8c2010-12-29 11:07:22 +0100471
472int subscr_pending_dump(struct gsm_subscriber *sub, struct vty *vty)
473{
474 struct subscr_request *req;
475
476 vty_out(vty, "Pending Requests for Subscriber %llu.%s", sub->id, VTY_NEWLINE);
477 llist_for_each_entry(req, &sub->requests, entry) {
478 vty_out(vty, "Channel type: %d State: %d Sub: %llu.%s",
479 req->channel_type, req->state, req->subscr->id, VTY_NEWLINE);
480 }
481
482 return 0;
483}
Holger Hans Peter Freythere5d806e2010-12-29 13:45:49 +0100484
485int subscr_pending_kick(struct gsm_subscriber *sub)
486{
487 subscr_put_channel(sub);
488 return 0;
489}