aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openbsc/include/openbsc/gsm_data.h11
-rw-r--r--openbsc/src/gsm_data.c23
-rw-r--r--openbsc/src/vty_interface.c16
3 files changed, 50 insertions, 0 deletions
diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index e995c1751..dd501d7cf 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -349,12 +349,19 @@ struct gsm_bts {
struct llist_head trx_list;
};
+enum gsm_auth_policy {
+ GSM_AUTH_POLICY_CLOSED, /* only subscribers authorized in DB */
+ GSM_AUTH_POLICY_ACCEPT_ALL, /* accept everyone, even if not authorized in DB */
+ GSM_AUTH_POLICY_TOKEN, /* accept first, send token per sms, then revoke authorization */
+};
+
struct gsm_network {
/* global parameters */
u_int16_t country_code;
u_int16_t network_code;
char *name_long;
char *name_short;
+ enum gsm_auth_policy auth_policy;
/* layer 4 */
int (*mncc_recv) (struct gsm_network *net, int msg_type, void *arg);
@@ -444,4 +451,8 @@ static inline int is_siemens_bts(struct gsm_bts *bts)
return 0;
}
+
+enum gsm_auth_policy gsm_auth_policy_parse(const char *arg);
+const char *gsm_auth_policy_name(enum gsm_auth_policy policy);
+
#endif
diff --git a/openbsc/src/gsm_data.c b/openbsc/src/gsm_data.c
index edf1b3d05..22e842280 100644
--- a/openbsc/src/gsm_data.c
+++ b/openbsc/src/gsm_data.c
@@ -320,3 +320,26 @@ enum gsm_band gsm_band_parse(const char* mhz)
}
}
+static const char *gsm_auth_policy_names[] = {
+ [GSM_AUTH_POLICY_CLOSED] = "closed",
+ [GSM_AUTH_POLICY_ACCEPT_ALL] = "accept-all",
+ [GSM_AUTH_POLICY_TOKEN] = "token",
+};
+
+enum gsm_auth_policy gsm_auth_policy_parse(const char *arg)
+{
+ int i;
+ for (i = 0; i < ARRAY_SIZE(gsm_auth_policy_names); i++) {
+ if (!strcmp(arg, gsm_auth_policy_names[i]))
+ return i;
+ }
+ return GSM_AUTH_POLICY_CLOSED;
+}
+
+const char *gsm_auth_policy_name(enum gsm_auth_policy policy)
+{
+ if (policy > ARRAY_SIZE(gsm_auth_policy_names))
+ return "undefined";
+ return gsm_auth_policy_names[policy];
+}
+
diff --git a/openbsc/src/vty_interface.c b/openbsc/src/vty_interface.c
index 1e0951a0c..9b35e6ba5 100644
--- a/openbsc/src/vty_interface.c
+++ b/openbsc/src/vty_interface.c
@@ -91,6 +91,8 @@ static void net_dump_vty(struct vty *vty, struct gsm_network *net)
net->name_long, VTY_NEWLINE);
vty_out(vty, " Short network name: '%s'%s",
net->name_short, VTY_NEWLINE);
+ vty_out(vty, " Authentication policy: %s%s",
+ gsm_auth_policy_name(net->auth_policy), VTY_NEWLINE);
}
DEFUN(show_net, show_net_cmd, "show network",
@@ -261,6 +263,7 @@ static int config_write_net(struct vty *vty)
vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE);
vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE);
vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE);
+ vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE);
return CMD_SUCCESS;
}
@@ -771,6 +774,18 @@ DEFUN(cfg_net_name_long,
return CMD_SUCCESS;
}
+DEFUN(cfg_net_auth_policy,
+ cfg_net_auth_policy_cmd,
+ "auth policy (closed|accept-all|token)",
+ "Set the GSM network authentication policy\n")
+{
+ enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]);
+
+ gsmnet->auth_policy = policy;
+
+ return CMD_SUCCESS;
+}
+
/* per-BTS configuration */
DEFUN(cfg_bts,
cfg_bts_cmd,
@@ -1320,6 +1335,7 @@ int bsc_vty_init(struct gsm_network *net)
install_element(GSMNET_NODE, &cfg_net_mnc_cmd);
install_element(GSMNET_NODE, &cfg_net_name_short_cmd);
install_element(GSMNET_NODE, &cfg_net_name_long_cmd);
+ install_element(GSMNET_NODE, &cfg_net_auth_policy_cmd);
install_element(GSMNET_NODE, &cfg_bts_cmd);
install_node(&bts_node, config_write_bts);