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

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

Commit Message

Max May 4, 2016, 11:02 a.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(-)

Comments

Holger Freyther May 9, 2016, 2:53 p.m. UTC | #1
> On 04 May 2016, at 13:02, msuraev@sysmocom.de wrote:
> 
> 


> +enum gsm_subscr_ext_alloc_policy {
> +	GSM_SUBSCR_DONT_CREATE = 0,
> +	GSM_SUBSCR_RANDOM_EXT = 1,
> +};


Neels reminded us to name things well. "extension alloc policy" is not the right word. The first item doesn't control the creation of the extension but the creation of the subscriber.

enum gsm_subscr_creation_mode {
	GSM_SUBSCR_DONT_CREATE
	GSM_SUBSCR_CREAT_W_RAND_EXT,
	GSM_SUBSCR_CREAT_W_NO_EXT
}>

> +
> 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;

rename variable to creation_mode? or better name?

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;
 }