aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-05-02 15:02:32 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-05-02 16:30:10 +0200
commit00007897d42232db0c29ebe543b2483311e56785 (patch)
tree6d4ceea507f42c5049f63c06d6423bb7c706d215 /openbsc
parent5c4386c6928d65252eaf327044aae63b5dfbc01e (diff)
gsm_04_08: factor out subscr authorization check
Add function subscr_authorized(), absorbing the guts of static authorize_subscriber() from gsm_04_08.c, except the parts specific to Location Updating. subscr_authorized() is a check that is to be added to validation of a paging response.
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/include/openbsc/gsm_subscriber.h4
-rw-r--r--openbsc/src/libmsc/gsm_04_08.c32
-rw-r--r--openbsc/src/libmsc/gsm_subscriber.c27
3 files changed, 36 insertions, 27 deletions
diff --git a/openbsc/include/openbsc/gsm_subscriber.h b/openbsc/include/openbsc/gsm_subscriber.h
index 151f3dd0e..56c72a246 100644
--- a/openbsc/include/openbsc/gsm_subscriber.h
+++ b/openbsc/include/openbsc/gsm_subscriber.h
@@ -1,6 +1,8 @@
#ifndef _GSM_SUBSCR_H
#define _GSM_SUBSCR_H
+#include <stdbool.h>
+
#include "gsm_data.h"
#include <osmocom/core/linuxlist.h>
@@ -130,6 +132,8 @@ void subscr_update_from_db(struct gsm_subscriber *subscr);
void subscr_expire(struct gsm_subscriber_group *sgrp);
int subscr_update_expire_lu(struct gsm_network *network, struct gsm_subscriber *subscr);
+bool subscr_authorized(struct gsm_subscriber *subsc);
+
/*
* Paging handling with authentication
*/
diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c
index e6746ccd6..0bfd42c1f 100644
--- a/openbsc/src/libmsc/gsm_04_08.c
+++ b/openbsc/src/libmsc/gsm_04_08.c
@@ -272,12 +272,12 @@ int gsm48_secure_channel(struct gsm_subscriber_connection *conn, int key_seq,
return -EINVAL; /* not reached */
}
-static int authorize_subscriber(struct gsm_loc_updating_operation *loc,
- struct gsm_subscriber *subscriber)
+static bool authorize_subscriber(struct gsm_loc_updating_operation *loc,
+ struct gsm_subscriber *subscriber)
{
if (!subscriber) {
LOGP(DMM, LOGL_DEBUG, "authorize_subscriber() on NULL subscriber\n");
- return 0;
+ return false;
}
/*
@@ -291,32 +291,10 @@ static int authorize_subscriber(struct gsm_loc_updating_operation *loc,
loc->waiting_for_imsi? " IMSI": "",
loc->waiting_for_imei? " IMEI": "",
subscr_name(subscriber));
- return 0;
+ return false;
}
- switch (subscriber->group->net->auth_policy) {
- case GSM_AUTH_POLICY_CLOSED:
- LOGP(DMM, LOGL_DEBUG, "subscriber %s authorized = %d\n",
- subscr_name(subscriber), subscriber->authorized);
- return subscriber->authorized;
- case GSM_AUTH_POLICY_TOKEN:
- if (subscriber->authorized) {
- LOGP(DMM, LOGL_DEBUG,
- "subscriber %s authorized = %d\n",
- subscr_name(subscriber), subscriber->authorized);
- return subscriber->authorized;
- }
- LOGP(DMM, LOGL_DEBUG, "subscriber %s first contact = %d\n",
- subscr_name(subscriber),
- (int)(subscriber->flags & GSM_SUBSCRIBER_FIRST_CONTACT));
- return (subscriber->flags & GSM_SUBSCRIBER_FIRST_CONTACT);
- case GSM_AUTH_POLICY_ACCEPT_ALL:
- return 1;
- default:
- LOGP(DMM, LOGL_DEBUG, "unknown auth_policy, rejecting"
- " subscriber %s\n", subscr_name(subscriber));
- return 0;
- }
+ return subscr_authorized(subscriber);
}
static void release_loc_updating_req(struct gsm_subscriber_connection *conn, int release)
diff --git a/openbsc/src/libmsc/gsm_subscriber.c b/openbsc/src/libmsc/gsm_subscriber.c
index 76b32a278..428fad847 100644
--- a/openbsc/src/libmsc/gsm_subscriber.c
+++ b/openbsc/src/libmsc/gsm_subscriber.c
@@ -405,3 +405,30 @@ void msc_subscr_con_free(struct gsm_subscriber_connection *conn)
llist_del(&conn->entry);
talloc_free(conn);
}
+
+bool subscr_authorized(struct gsm_subscriber *subscriber)
+{
+ switch (subscriber->group->net->auth_policy) {
+ case GSM_AUTH_POLICY_CLOSED:
+ LOGP(DMM, LOGL_DEBUG, "subscriber %s authorized = %d\n",
+ subscr_name(subscriber), subscriber->authorized);
+ return subscriber->authorized ? true : false;
+ case GSM_AUTH_POLICY_TOKEN:
+ if (subscriber->authorized) {
+ LOGP(DMM, LOGL_DEBUG,
+ "subscriber %s authorized = %d\n",
+ subscr_name(subscriber), subscriber->authorized);
+ return subscriber->authorized;
+ }
+ LOGP(DMM, LOGL_DEBUG, "subscriber %s first contact = %d\n",
+ subscr_name(subscriber),
+ (int)(subscriber->flags & GSM_SUBSCRIBER_FIRST_CONTACT));
+ return (subscriber->flags & GSM_SUBSCRIBER_FIRST_CONTACT);
+ case GSM_AUTH_POLICY_ACCEPT_ALL:
+ return true;
+ default:
+ LOGP(DMM, LOGL_DEBUG, "unknown auth_policy, rejecting"
+ " subscriber %s\n", subscr_name(subscriber));
+ return false;
+ }
+}