diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2014-01-20 09:55:46 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2014-01-20 10:13:36 +0100 |
commit | 415cd2eebb5313f044612385e09d8b8af9cfe674 (patch) | |
tree | 79d354b4d4758ca3648b5d25f12e1adc0914dccc /openbsc/src/osmo-bsc_nat | |
parent | ead0529e076a1bd02b170796dc3895dabde7d2e8 (diff) |
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.
Diffstat (limited to 'openbsc/src/osmo-bsc_nat')
-rw-r--r-- | openbsc/src/osmo-bsc_nat/bsc_nat_filter.c | 16 | ||||
-rw-r--r-- | openbsc/src/osmo-bsc_nat/bsc_nat_utils.c | 2 |
2 files changed, 14 insertions, 4 deletions
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; } |