aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-04-04 22:40:12 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-05-03 21:42:28 +0200
commita1e6bd6768e61828823da3ba774e55b6f89559fc (patch)
tree87bd7eb5267144fd4030ebcfd7319f47bbc037a2 /openbsc
parentd7e04b9956bb7d579697604fff6ba67fc6b9e52d (diff)
filter: Remove nat from bsc_nat_acc_lst and replace with msg
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/include/openbsc/bsc_msg_filter.h18
-rw-r--r--openbsc/src/libfilter/bsc_msg_acc.c24
-rw-r--r--openbsc/src/libfilter/bsc_msg_filter.c14
-rw-r--r--openbsc/src/libfilter/bsc_msg_vty.c32
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c10
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_utils.c4
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_vty.c6
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_ussd.c6
-rw-r--r--openbsc/tests/bsc-nat/bsc_nat_test.c12
9 files changed, 63 insertions, 63 deletions
diff --git a/openbsc/include/openbsc/bsc_msg_filter.h b/openbsc/include/openbsc/bsc_msg_filter.h
index 80dc37abf..8420e48af 100644
--- a/openbsc/include/openbsc/bsc_msg_filter.h
+++ b/openbsc/include/openbsc/bsc_msg_filter.h
@@ -32,7 +32,7 @@ enum bsc_nat_acc_ctr {
ACC_LIST_NAT_FILTER,
};
-struct bsc_nat_acc_lst {
+struct bsc_msg_acc_lst {
struct llist_head list;
/* counter */
@@ -43,7 +43,7 @@ struct bsc_nat_acc_lst {
struct llist_head fltr_list;
};
-struct bsc_nat_acc_lst_entry {
+struct bsc_msg_acc_lst_entry {
struct llist_head list;
/* the filter */
@@ -72,12 +72,12 @@ int bsc_nat_filter_dt(struct bsc_connection *bsc, struct msgb *msg,
struct bsc_nat_reject_cause *cause);
/* IMSI allow/deny handling */
-struct bsc_nat_acc_lst *bsc_nat_acc_lst_find(struct llist_head *lst, const char *name);
-struct bsc_nat_acc_lst *bsc_nat_acc_lst_get(void *ctx, struct llist_head *lst, const char *name);
-void bsc_nat_acc_lst_delete(struct bsc_nat_acc_lst *lst);
+struct bsc_msg_acc_lst *bsc_msg_acc_lst_find(struct llist_head *lst, const char *name);
+struct bsc_msg_acc_lst *bsc_msg_acc_lst_get(void *ctx, struct llist_head *lst, const char *name);
+void bsc_msg_acc_lst_delete(struct bsc_msg_acc_lst *lst);
-struct bsc_nat_acc_lst_entry *bsc_nat_acc_lst_entry_create(struct bsc_nat_acc_lst *);
-int bsc_nat_lst_check_allow(struct bsc_nat_acc_lst *lst, const char *imsi);
+struct bsc_msg_acc_lst_entry *bsc_msg_acc_lst_entry_create(struct bsc_msg_acc_lst *);
+int bsc_msg_acc_lst_check_allow(struct bsc_msg_acc_lst *lst, const char *imsi);
-void bsc_nat_lst_vty_init(void *ctx, struct llist_head *lst, int node);
-void bsc_nat_acc_lst_write(struct vty *vty, struct bsc_nat_acc_lst *lst);
+void bsc_msg_lst_vty_init(void *ctx, struct llist_head *lst, int node);
+void bsc_msg_acc_lst_write(struct vty *vty, struct bsc_msg_acc_lst *lst);
diff --git a/openbsc/src/libfilter/bsc_msg_acc.c b/openbsc/src/libfilter/bsc_msg_acc.c
index cc6c44405..d2f45b36f 100644
--- a/openbsc/src/libfilter/bsc_msg_acc.c
+++ b/openbsc/src/libfilter/bsc_msg_acc.c
@@ -38,9 +38,9 @@ static const struct rate_ctr_group_desc bsc_cfg_acc_list_desc = {
};
-int bsc_nat_lst_check_allow(struct bsc_nat_acc_lst *lst, const char *mi_string)
+int bsc_msg_acc_lst_check_allow(struct bsc_msg_acc_lst *lst, const char *mi_string)
{
- struct bsc_nat_acc_lst_entry *entry;
+ struct bsc_msg_acc_lst_entry *entry;
llist_for_each_entry(entry, &lst->fltr_list, list) {
if (!entry->imsi_allow)
@@ -52,9 +52,9 @@ int bsc_nat_lst_check_allow(struct bsc_nat_acc_lst *lst, const char *mi_string)
return 1;
}
-struct bsc_nat_acc_lst *bsc_nat_acc_lst_find(struct llist_head *head, const char *name)
+struct bsc_msg_acc_lst *bsc_msg_acc_lst_find(struct llist_head *head, const char *name)
{
- struct bsc_nat_acc_lst *lst;
+ struct bsc_msg_acc_lst *lst;
if (!name)
return NULL;
@@ -66,15 +66,15 @@ struct bsc_nat_acc_lst *bsc_nat_acc_lst_find(struct llist_head *head, const char
return NULL;
}
-struct bsc_nat_acc_lst *bsc_nat_acc_lst_get(void *ctx, struct llist_head *head, const char *name)
+struct bsc_msg_acc_lst *bsc_msg_acc_lst_get(void *ctx, struct llist_head *head, const char *name)
{
- struct bsc_nat_acc_lst *lst;
+ struct bsc_msg_acc_lst *lst;
- lst = bsc_nat_acc_lst_find(head, name);
+ lst = bsc_msg_acc_lst_find(head, name);
if (lst)
return lst;
- lst = talloc_zero(ctx, struct bsc_nat_acc_lst);
+ lst = talloc_zero(ctx, struct bsc_msg_acc_lst);
if (!lst) {
LOGP(DNAT, LOGL_ERROR, "Failed to allocate access list");
return NULL;
@@ -93,18 +93,18 @@ struct bsc_nat_acc_lst *bsc_nat_acc_lst_get(void *ctx, struct llist_head *head,
return lst;
}
-void bsc_nat_acc_lst_delete(struct bsc_nat_acc_lst *lst)
+void bsc_msg_acc_lst_delete(struct bsc_msg_acc_lst *lst)
{
llist_del(&lst->list);
rate_ctr_group_free(lst->stats);
talloc_free(lst);
}
-struct bsc_nat_acc_lst_entry *bsc_nat_acc_lst_entry_create(struct bsc_nat_acc_lst *lst)
+struct bsc_msg_acc_lst_entry *bsc_msg_acc_lst_entry_create(struct bsc_msg_acc_lst *lst)
{
- struct bsc_nat_acc_lst_entry *entry;
+ struct bsc_msg_acc_lst_entry *entry;
- entry = talloc_zero(lst, struct bsc_nat_acc_lst_entry);
+ entry = talloc_zero(lst, struct bsc_msg_acc_lst_entry);
if (!entry)
return NULL;
diff --git a/openbsc/src/libfilter/bsc_msg_filter.c b/openbsc/src/libfilter/bsc_msg_filter.c
index 1f7a14e63..19367a013 100644
--- a/openbsc/src/libfilter/bsc_msg_filter.c
+++ b/openbsc/src/libfilter/bsc_msg_filter.c
@@ -123,10 +123,10 @@ int bsc_nat_barr_adapt(void *ctx, struct rb_root *root,
}
-static int lst_check_deny(struct bsc_nat_acc_lst *lst, const char *mi_string,
+static int lst_check_deny(struct bsc_msg_acc_lst *lst, const char *mi_string,
int *cm_cause, int *lu_cause)
{
- struct bsc_nat_acc_lst_entry *entry;
+ struct bsc_msg_acc_lst_entry *entry;
llist_for_each_entry(entry, &lst->fltr_list, list) {
if (!entry->imsi_deny)
@@ -154,8 +154,8 @@ static int auth_imsi(struct bsc_connection *bsc, const char *imsi,
* 5.) Allow directly if the IMSI is allowed at the global level
*/
int cm, lu;
- struct bsc_nat_acc_lst *nat_lst = NULL;
- struct bsc_nat_acc_lst *bsc_lst = NULL;
+ struct bsc_msg_acc_lst *nat_lst = NULL;
+ struct bsc_msg_acc_lst *bsc_lst = NULL;
/* 1. global check for barred imsis */
if (bsc_nat_barr_find(&bsc->nat->imsi_black_list, imsi, &cm, &lu)) {
@@ -168,13 +168,13 @@ static int auth_imsi(struct bsc_connection *bsc, const char *imsi,
}
- bsc_lst = bsc_nat_acc_lst_find(&bsc->nat->access_lists, bsc->cfg->acc_lst_name);
- nat_lst = bsc_nat_acc_lst_find(&bsc->nat->access_lists, bsc->nat->acc_lst_name);
+ bsc_lst = bsc_msg_acc_lst_find(&bsc->nat->access_lists, bsc->cfg->acc_lst_name);
+ nat_lst = bsc_msg_acc_lst_find(&bsc->nat->access_lists, bsc->nat->acc_lst_name);
if (bsc_lst) {
/* 2. BSC allow */
- if (bsc_nat_lst_check_allow(bsc_lst, imsi) == 0)
+ if (bsc_msg_acc_lst_check_allow(bsc_lst, imsi) == 0)
return 1;
/* 3. BSC deny */
diff --git a/openbsc/src/libfilter/bsc_msg_vty.c b/openbsc/src/libfilter/bsc_msg_vty.c
index 79cf03db1..c342fdca0 100644
--- a/openbsc/src/libfilter/bsc_msg_vty.c
+++ b/openbsc/src/libfilter/bsc_msg_vty.c
@@ -32,12 +32,12 @@ DEFUN(cfg_lst_no,
NO_STR "Remove an access-list by name\n"
"The access-list to remove\n")
{
- struct bsc_nat_acc_lst *acc;
- acc = bsc_nat_acc_lst_find(_acc_lst, argv[0]);
+ struct bsc_msg_acc_lst *acc;
+ acc = bsc_msg_acc_lst_find(_acc_lst, argv[0]);
if (!acc)
return CMD_WARNING;
- bsc_nat_acc_lst_delete(acc);
+ bsc_msg_acc_lst_delete(acc);
return CMD_SUCCESS;
}
@@ -46,8 +46,8 @@ DEFUN(show_acc_lst,
"show access-list NAME",
SHOW_STR "IMSI access list\n" "Name of the access list\n")
{
- struct bsc_nat_acc_lst *acc;
- acc = bsc_nat_acc_lst_find(_acc_lst, argv[0]);
+ struct bsc_msg_acc_lst *acc;
+ acc = bsc_msg_acc_lst_find(_acc_lst, argv[0]);
if (!acc)
return CMD_WARNING;
@@ -65,14 +65,14 @@ DEFUN(cfg_lst_imsi_allow,
"Add allowed IMSI to the list\n"
"Regexp for IMSIs\n")
{
- struct bsc_nat_acc_lst *acc;
- struct bsc_nat_acc_lst_entry *entry;
+ struct bsc_msg_acc_lst *acc;
+ struct bsc_msg_acc_lst_entry *entry;
- acc = bsc_nat_acc_lst_get(_ctx, _acc_lst, argv[0]);
+ acc = bsc_msg_acc_lst_get(_ctx, _acc_lst, argv[0]);
if (!acc)
return CMD_WARNING;
- entry = bsc_nat_acc_lst_entry_create(acc);
+ entry = bsc_msg_acc_lst_entry_create(acc);
if (!entry)
return CMD_WARNING;
@@ -91,14 +91,14 @@ DEFUN(cfg_lst_imsi_deny,
"CM Service Reject reason\n"
"LU Reject reason\n")
{
- struct bsc_nat_acc_lst *acc;
- struct bsc_nat_acc_lst_entry *entry;
+ struct bsc_msg_acc_lst *acc;
+ struct bsc_msg_acc_lst_entry *entry;
- acc = bsc_nat_acc_lst_get(_ctx, _acc_lst, argv[0]);
+ acc = bsc_msg_acc_lst_get(_ctx, _acc_lst, argv[0]);
if (!acc)
return CMD_WARNING;
- entry = bsc_nat_acc_lst_entry_create(acc);
+ entry = bsc_msg_acc_lst_entry_create(acc);
if (!entry)
return CMD_WARNING;
@@ -111,9 +111,9 @@ DEFUN(cfg_lst_imsi_deny,
return CMD_SUCCESS;
}
-void bsc_nat_acc_lst_write(struct vty *vty, struct bsc_nat_acc_lst *lst)
+void bsc_msg_acc_lst_write(struct vty *vty, struct bsc_msg_acc_lst *lst)
{
- struct bsc_nat_acc_lst_entry *entry;
+ struct bsc_msg_acc_lst_entry *entry;
llist_for_each_entry(entry, &lst->fltr_list, list) {
if (entry->imsi_allow)
@@ -127,7 +127,7 @@ void bsc_nat_acc_lst_write(struct vty *vty, struct bsc_nat_acc_lst *lst)
}
}
-void bsc_nat_lst_vty_init(void *ctx, struct llist_head *lst, int node)
+void bsc_msg_lst_vty_init(void *ctx, struct llist_head *lst, int node)
{
_ctx = ctx;
_acc_lst = lst;
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c b/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c
index 439bf3344..f3ca92400 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c
@@ -405,19 +405,19 @@ static int get_net_cfg_acc_cmd(struct ctrl_cmd *cmd, void *data)
static int set_net_cfg_acc_cmd(struct ctrl_cmd *cmd, void *data)
{
const char *access_name = extract_acc_name(cmd->variable);
- struct bsc_nat_acc_lst *acc;
- struct bsc_nat_acc_lst_entry *entry;
+ struct bsc_msg_acc_lst *acc;
+ struct bsc_msg_acc_lst_entry *entry;
const char *value = cmd->value;
int rc;
/* Should have been caught by verify_net_cfg_acc_cmd */
- acc = bsc_nat_acc_lst_find(g_nat, access_name);
+ acc = bsc_msg_acc_lst_find(&g_nat->access_lists, access_name);
if (!acc) {
cmd->reply = "Access list not found";
return CTRL_CMD_ERROR;
}
- entry = bsc_nat_acc_lst_entry_create(acc);
+ entry = bsc_msg_acc_lst_entry_create(acc);
if (!entry) {
cmd->reply = "OOM";
return CTRL_CMD_ERROR;
@@ -436,7 +436,7 @@ static int set_net_cfg_acc_cmd(struct ctrl_cmd *cmd, void *data)
static int verify_net_cfg_acc_cmd(struct ctrl_cmd *cmd, const char *value, void *data)
{
const char *access_name = extract_acc_name(cmd->variable);
- struct bsc_nat_acc_lst *acc = bsc_nat_acc_lst_find(g_nat, access_name);
+ struct bsc_msg_acc_lst *acc = bsc_msg_acc_lst_find(&g_nat->access_lists, access_name);
if (!acc) {
cmd->reply = "Access list not known";
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
index 33582ffe1..89212087c 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
@@ -112,12 +112,12 @@ struct bsc_nat *bsc_nat_alloc(void)
void bsc_nat_free(struct bsc_nat *nat)
{
struct bsc_config *cfg, *tmp;
- struct bsc_nat_acc_lst *lst, *tmp_lst;
+ struct bsc_msg_acc_lst *lst, *tmp_lst;
llist_for_each_entry_safe(cfg, tmp, &nat->bsc_configs, entry)
bsc_config_free(cfg);
llist_for_each_entry_safe(lst, tmp_lst, &nat->access_lists, list)
- bsc_nat_acc_lst_delete(lst);
+ bsc_msg_acc_lst_delete(lst);
bsc_nat_num_rewr_entry_adapt(nat, &nat->num_rewr, NULL);
bsc_nat_num_rewr_entry_adapt(nat, &nat->num_rewr_post, NULL);
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
index 3a53dd402..502bdddd4 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
@@ -87,7 +87,7 @@ static void write_pgroup_lst(struct vty *vty, struct bsc_nat_paging_group *pgrou
static int config_write_nat(struct vty *vty)
{
- struct bsc_nat_acc_lst *lst;
+ struct bsc_msg_acc_lst *lst;
struct bsc_nat_paging_group *pgroup;
vty_out(vty, "nat%s", VTY_NEWLINE);
@@ -136,7 +136,7 @@ static int config_write_nat(struct vty *vty)
_nat->num_rewr_trie_name, VTY_NEWLINE);
llist_for_each_entry(lst, &_nat->access_lists, list)
- bsc_nat_acc_lst_write(vty, lst);
+ bsc_msg_acc_lst_write(vty, lst);
llist_for_each_entry(pgroup, &_nat->paging_groups, entry)
write_pgroup_lst(vty, pgroup);
if (_nat->mgcp_ipa)
@@ -1171,7 +1171,7 @@ int bsc_nat_vty_init(struct bsc_nat *nat)
install_element(NAT_NODE, &cfg_nat_ussd_local_cmd);
install_element(NAT_NODE, &cfg_nat_use_ipa_for_mgcp_cmd);
- bsc_nat_lst_vty_init(nat, &nat->access_lists, NAT_NODE);
+ bsc_msg_lst_vty_init(nat, &nat->access_lists, NAT_NODE);
/* number rewriting */
install_element(NAT_NODE, &cfg_nat_number_rewrite_cmd);
diff --git a/openbsc/src/osmo-bsc_nat/bsc_ussd.c b/openbsc/src/osmo-bsc_nat/bsc_ussd.c
index f27453bc3..968456b95 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_ussd.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_ussd.c
@@ -374,7 +374,7 @@ int bsc_ussd_check(struct nat_sccp_connection *con, struct bsc_nat_parsed *parse
uint8_t proto;
uint8_t ti;
struct gsm48_hdr *hdr48;
- struct bsc_nat_acc_lst *lst;
+ struct bsc_msg_acc_lst *lst;
struct ussd_request req;
/*
@@ -416,12 +416,12 @@ int bsc_ussd_check(struct nat_sccp_connection *con, struct bsc_nat_parsed *parse
if (msg_type == GSM0480_MTYPE_REGISTER) {
/* now check if it is a IMSI we care about */
- lst = bsc_nat_acc_lst_find(&con->bsc->nat->access_lists,
+ lst = bsc_msg_acc_lst_find(&con->bsc->nat->access_lists,
con->bsc->nat->ussd_lst_name);
if (!lst)
return 0;
- if (bsc_nat_lst_check_allow(lst, con->imsi) != 0)
+ if (bsc_msg_acc_lst_check_allow(lst, con->imsi) != 0)
return 0;
/* now decode the message and see if we really want to handle it */
diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c
index 8ee8e3945..61b3bd161 100644
--- a/openbsc/tests/bsc-nat/bsc_nat_test.c
+++ b/openbsc/tests/bsc-nat/bsc_nat_test.c
@@ -868,8 +868,8 @@ static void test_cr_filter()
int i, res, contype;
struct msgb *msg = msgb_alloc(4096, "test_cr_filter");
struct bsc_nat_parsed *parsed;
- struct bsc_nat_acc_lst *nat_lst, *bsc_lst;
- struct bsc_nat_acc_lst_entry *nat_entry, *bsc_entry;
+ struct bsc_msg_acc_lst *nat_lst, *bsc_lst;
+ struct bsc_msg_acc_lst_entry *nat_entry, *bsc_entry;
struct bsc_nat_reject_cause cause;
struct bsc_nat *nat = bsc_nat_alloc();
@@ -879,11 +879,11 @@ static void test_cr_filter()
bsc->cfg->acc_lst_name = "bsc";
nat->acc_lst_name = "nat";
- nat_lst = bsc_nat_acc_lst_get(nat, &nat->access_lists, "nat");
- bsc_lst = bsc_nat_acc_lst_get(nat, &nat->access_lists, "bsc");
+ nat_lst = bsc_msg_acc_lst_get(nat, &nat->access_lists, "nat");
+ bsc_lst = bsc_msg_acc_lst_get(nat, &nat->access_lists, "bsc");
- bsc_entry = bsc_nat_acc_lst_entry_create(bsc_lst);
- nat_entry = bsc_nat_acc_lst_entry_create(nat_lst);
+ bsc_entry = bsc_msg_acc_lst_entry_create(bsc_lst);
+ nat_entry = bsc_msg_acc_lst_entry_create(nat_lst);
/* test the default value as we are going to overwrite it */
OSMO_ASSERT(bsc_entry->cm_reject_cause == GSM48_REJECT_PLMN_NOT_ALLOWED);