[1/5] Use enum for subscriber creation policy
diff mbox

Message ID 1462293833-29141-1-git-send-email-msuraev@sysmocom.de
State New
Headers show

Commit Message

Max May 3, 2016, 4:43 p.m. UTC
From: Max <msuraev@sysmocom.de>

This enables easier expansion of available policies in future.
---
 openbsc/include/openbsc/gsm_data.h        | 5 +++++
 openbsc/src/libbsc/net_init.c             | 2 +-
 openbsc/src/libmsc/vty_interface_layer3.c | 4 ++--
 3 files changed, 8 insertions(+), 3 deletions(-)

Patch
diff mbox

diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index 6d7aba3..593a86f 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -18,6 +18,11 @@  struct gsm_subscriber_group;
 
 #define OBSC_LINKID_CB(__msgb)	(__msgb)->cb[3]
 
+enum gsm_subscr_ext_alloc_policy {
+	GSM_SUBSCR_DONT_CREATE = 0,
+	GSM_SUBSCR_RANDOM_EXT = 1,
+};
+
 enum gsm_security_event {
 	GSM_SECURITY_NOAVAIL,
 	GSM_SECURITY_AUTH_FAILED,
diff --git a/openbsc/src/libbsc/net_init.c b/openbsc/src/libbsc/net_init.c
index 568a0b8..00a8a9b 100644
--- a/openbsc/src/libbsc/net_init.c
+++ b/openbsc/src/libbsc/net_init.c
@@ -48,7 +48,7 @@  struct gsm_network *gsm_network_init(uint16_t country_code, uint16_t network_cod
 	INIT_LLIST_HEAD(&net->bsc_data->mscs);
 
 	net->subscr_group->net = net;
-	net->create_subscriber = 1;
+	net->create_subscriber = GSM_SUBSCR_RANDOM_EXT;
 
 	net->country_code = country_code;
 	net->network_code = network_code;
diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c
index 790fedf..4dd0573 100644
--- a/openbsc/src/libmsc/vty_interface_layer3.c
+++ b/openbsc/src/libmsc/vty_interface_layer3.c
@@ -1036,7 +1036,7 @@  DEFUN(cfg_nitb_subscr_create, cfg_nitb_subscr_create_cmd,
       "Make a new record when a subscriber is first seen.\n")
 {
 	struct gsm_network *gsmnet = gsmnet_from_vty(vty);
-	gsmnet->create_subscriber = 1;
+	gsmnet->create_subscriber = GSM_SUBSCR_RANDOM_EXT;
 	return CMD_SUCCESS;
 }
 
@@ -1045,7 +1045,7 @@  DEFUN(cfg_nitb_no_subscr_create, cfg_nitb_no_subscr_create_cmd,
       NO_STR "Make a new record when a subscriber is first seen.\n")
 {
 	struct gsm_network *gsmnet = gsmnet_from_vty(vty);
-	gsmnet->create_subscriber = 0;
+	gsmnet->create_subscriber = GSM_SUBSCR_DONT_CREATE;
 	return CMD_SUCCESS;
 }