diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-11-15 09:15:01 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-11-15 20:06:45 +0100 |
commit | d740b688dc33116efd12763170e1c5e6a4fdc9d4 (patch) | |
tree | 6399f1629a66c9353f97baecb6fc9aacfc79a49c /openbsc/src/gsm_subscriber_base.c | |
parent | 928ca743db057902337ca282e6a12d8a5389df4f (diff) |
subscr: Add the subscr_get_or_create from the on-waves/bsc-master branch
Create a subscriber based on a known IMSI, search the list of
active subscribers if there is already someone like this.
Diffstat (limited to 'openbsc/src/gsm_subscriber_base.c')
-rw-r--r-- | openbsc/src/gsm_subscriber_base.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/openbsc/src/gsm_subscriber_base.c b/openbsc/src/gsm_subscriber_base.c index 4027cd6e9..f5fb16c5a 100644 --- a/openbsc/src/gsm_subscriber_base.c +++ b/openbsc/src/gsm_subscriber_base.c @@ -219,3 +219,21 @@ void subscr_put_channel(struct gsm_subscriber_connection *conn) subscr_send_paging_request(conn->subscr); } +struct gsm_subscriber *subscr_get_or_create(struct gsm_network *net, + const char *imsi) +{ + struct gsm_subscriber *subscr; + + llist_for_each_entry(subscr, subscr_bsc_active_subscriber(), entry) { + if (strcmp(subscr->imsi, imsi) == 0 && subscr->net == net) + return subscr_get(subscr); + } + + subscr = subscr_alloc(); + if (!subscr) + return NULL; + + strcpy(subscr->imsi, imsi); + subscr->net = net; + return subscr; +} |