From 415cd2eebb5313f044612385e09d8b8af9cfe674 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 20 Jan 2014 09:55:46 +0100 Subject: nat: Introduce reject cause to bsc_nat_acc_lst_entry The filtering architecture already allowed to specify a reject reason but this has not been used for the access-lists. Extend the access-list to include a reject reason and extend the test case to honor it. --- openbsc/src/osmo-bsc_nat/bsc_nat_filter.c | 16 ++++++++++++---- openbsc/src/osmo-bsc_nat/bsc_nat_utils.c | 2 ++ 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'openbsc/src/osmo-bsc_nat') diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_filter.c b/openbsc/src/osmo-bsc_nat/bsc_nat_filter.c index 8ccc26259..d29ea9c16 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_filter.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_filter.c @@ -122,15 +122,19 @@ 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_nat_acc_lst *lst, const char *mi_string, + int *cm_cause, int *lu_cause) { struct bsc_nat_acc_lst_entry *entry; llist_for_each_entry(entry, &lst->fltr_list, list) { if (!entry->imsi_deny) continue; - if (regexec(&entry->imsi_deny_re, mi_string, 0, NULL, 0) == 0) + if (regexec(&entry->imsi_deny_re, mi_string, 0, NULL, 0) == 0) { + *cm_cause = entry->cm_reject_cause; + *lu_cause = entry->lu_reject_cause; return 0; + } } return 1; @@ -173,10 +177,12 @@ static int auth_imsi(struct bsc_connection *bsc, const char *imsi, return 1; /* 3. BSC deny */ - if (lst_check_deny(bsc_lst, imsi) == 0) { + if (lst_check_deny(bsc_lst, imsi, &cm, &lu) == 0) { LOGP(DNAT, LOGL_ERROR, "Filtering %s by imsi_deny on bsc nr: %d.\n", imsi, bsc->cfg->nr); rate_ctr_inc(&bsc_lst->stats->ctr[ACC_LIST_BSC_FILTER]); + cause->cm_reject_cause = cm; + cause->lu_reject_cause = lu; return -2; } @@ -184,10 +190,12 @@ static int auth_imsi(struct bsc_connection *bsc, const char *imsi, /* 4. NAT deny */ if (nat_lst) { - if (lst_check_deny(nat_lst, imsi) == 0) { + if (lst_check_deny(nat_lst, imsi, &cm, &lu) == 0) { LOGP(DNAT, LOGL_ERROR, "Filtering %s by nat imsi_deny on bsc nr: %d.\n", imsi, bsc->cfg->nr); rate_ctr_inc(&nat_lst->stats->ctr[ACC_LIST_NAT_FILTER]); + cause->cm_reject_cause = cm; + cause->lu_reject_cause = lu; return -3; } } diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c index bc8c4c1f3..236a0fb05 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c @@ -468,6 +468,8 @@ struct bsc_nat_acc_lst_entry *bsc_nat_acc_lst_entry_create(struct bsc_nat_acc_ls if (!entry) return NULL; + entry->cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED; + entry->lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED; llist_add_tail(&entry->list, &lst->fltr_list); return entry; } -- cgit v1.2.3