filter: More renaming and remove of "NAT" from it

This commit is contained in:
Holger Hans Peter Freyther
2015-04-05 16:55:28 +02:00
parent 14b2cd9f32
commit c36a6d5705
5 changed files with 41 additions and 41 deletions

View File

@@ -14,12 +14,12 @@ struct bsc_nat_parsed;
struct bsc_connection; struct bsc_connection;
struct nat_sccp_connection; struct nat_sccp_connection;
struct bsc_nat_reject_cause { struct bsc_filter_reject_cause {
int lu_reject_cause; int lu_reject_cause;
int cm_reject_cause; int cm_reject_cause;
}; };
struct bsc_nat_barr_entry { struct bsc_filter_barr_entry {
struct rb_node node; struct rb_node node;
char *imsi; char *imsi;
@@ -27,7 +27,7 @@ struct bsc_nat_barr_entry {
int lu_reject_cause; int lu_reject_cause;
}; };
enum bsc_nat_acc_ctr { enum bsc_filter_acc_ctr {
ACC_LIST_LOCAL_FILTER, ACC_LIST_LOCAL_FILTER,
ACC_LIST_GLOBAL_FILTER, ACC_LIST_GLOBAL_FILTER,
}; };
@@ -58,18 +58,18 @@ struct bsc_msg_acc_lst_entry {
}; };
int bsc_nat_barr_adapt(void *ctx, struct rb_root *rbtree, const struct osmo_config_list *); int bsc_filter_barr_adapt(void *ctx, struct rb_root *rbtree, const struct osmo_config_list *);
int bsc_nat_barr_find(struct rb_root *root, const char *imsi, int *cm, int *lu); int bsc_filter_barr_find(struct rb_root *root, const char *imsi, int *cm, int *lu);
/** /**
* Content filtering. * Content filtering.
*/ */
int bsc_nat_filter_sccp_cr(struct bsc_connection *bsc, struct msgb *msg, int bsc_nat_filter_sccp_cr(struct bsc_connection *bsc, struct msgb *msg,
struct bsc_nat_parsed *, int *con_type, char **imsi, struct bsc_nat_parsed *, int *con_type, char **imsi,
struct bsc_nat_reject_cause *cause); struct bsc_filter_reject_cause *cause);
int bsc_nat_filter_dt(struct bsc_connection *bsc, struct msgb *msg, int bsc_nat_filter_dt(struct bsc_connection *bsc, struct msgb *msg,
struct nat_sccp_connection *con, struct bsc_nat_parsed *parsed, struct nat_sccp_connection *con, struct bsc_nat_parsed *parsed,
struct bsc_nat_reject_cause *cause); struct bsc_filter_reject_cause *cause);
/* IMSI allow/deny handling */ /* IMSI allow/deny handling */
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_find(struct llist_head *lst, const char *name);

View File

@@ -38,10 +38,10 @@
#include <osmocom/sccp/sccp.h> #include <osmocom/sccp/sccp.h>
int bsc_nat_barr_find(struct rb_root *root, const char *imsi, int *cm, int *lu) int bsc_filter_barr_find(struct rb_root *root, const char *imsi, int *cm, int *lu)
{ {
struct bsc_nat_barr_entry *n; struct bsc_filter_barr_entry *n;
n = rb_entry(root->rb_node, struct bsc_nat_barr_entry, node); n = rb_entry(root->rb_node, struct bsc_filter_barr_entry, node);
while (n) { while (n) {
int rc = strcmp(imsi, n->imsi); int rc = strcmp(imsi, n->imsi);
@@ -53,20 +53,20 @@ int bsc_nat_barr_find(struct rb_root *root, const char *imsi, int *cm, int *lu)
n = rb_entry( n = rb_entry(
(rc < 0) ? n->node.rb_left : n->node.rb_right, (rc < 0) ? n->node.rb_left : n->node.rb_right,
struct bsc_nat_barr_entry, node); struct bsc_filter_barr_entry, node);
}; };
return 0; return 0;
} }
static int insert_barr_node(struct bsc_nat_barr_entry *entry, struct rb_root *root) static int insert_barr_node(struct bsc_filter_barr_entry *entry, struct rb_root *root)
{ {
struct rb_node **new = &root->rb_node, *parent = NULL; struct rb_node **new = &root->rb_node, *parent = NULL;
while (*new) { while (*new) {
int rc; int rc;
struct bsc_nat_barr_entry *this; struct bsc_filter_barr_entry *this;
this = rb_entry(*new, struct bsc_nat_barr_entry, node); this = rb_entry(*new, struct bsc_filter_barr_entry, node);
parent = *new; parent = *new;
rc = strcmp(entry->imsi, this->imsi); rc = strcmp(entry->imsi, this->imsi);
@@ -87,7 +87,7 @@ static int insert_barr_node(struct bsc_nat_barr_entry *entry, struct rb_root *ro
return 0; return 0;
} }
int bsc_nat_barr_adapt(void *ctx, struct rb_root *root, int bsc_filter_barr_adapt(void *ctx, struct rb_root *root,
const struct osmo_config_list *list) const struct osmo_config_list *list)
{ {
struct osmo_config_entry *cfg_entry; struct osmo_config_entry *cfg_entry;
@@ -105,8 +105,8 @@ int bsc_nat_barr_adapt(void *ctx, struct rb_root *root,
/* now adapt the new list */ /* now adapt the new list */
llist_for_each_entry(cfg_entry, &list->entry, list) { llist_for_each_entry(cfg_entry, &list->entry, list) {
struct bsc_nat_barr_entry *entry; struct bsc_filter_barr_entry *entry;
entry = talloc_zero(ctx, struct bsc_nat_barr_entry); entry = talloc_zero(ctx, struct bsc_filter_barr_entry);
if (!entry) { if (!entry) {
LOGP(DNAT, LOGL_ERROR, LOGP(DNAT, LOGL_ERROR,
"Allocation of the barr entry failed.\n"); "Allocation of the barr entry failed.\n");
@@ -143,7 +143,7 @@ static int lst_check_deny(struct bsc_msg_acc_lst *lst, const char *mi_string,
/* apply white/black list */ /* apply white/black list */
static int auth_imsi(struct bsc_connection *bsc, const char *imsi, static int auth_imsi(struct bsc_connection *bsc, const char *imsi,
struct bsc_nat_reject_cause *cause) struct bsc_filter_reject_cause *cause)
{ {
/* /*
* Now apply blacklist/whitelist of the BSC and the NAT. * Now apply blacklist/whitelist of the BSC and the NAT.
@@ -158,7 +158,7 @@ static int auth_imsi(struct bsc_connection *bsc, const char *imsi,
struct bsc_msg_acc_lst *bsc_lst = NULL; struct bsc_msg_acc_lst *bsc_lst = NULL;
/* 1. global check for barred imsis */ /* 1. global check for barred imsis */
if (bsc_nat_barr_find(&bsc->nat->imsi_black_list, imsi, &cm, &lu)) { if (bsc_filter_barr_find(&bsc->nat->imsi_black_list, imsi, &cm, &lu)) {
cause->cm_reject_cause = cm; cause->cm_reject_cause = cm;
cause->lu_reject_cause = lu; cause->lu_reject_cause = lu;
LOGP(DNAT, LOGL_DEBUG, LOGP(DNAT, LOGL_DEBUG,
@@ -300,7 +300,7 @@ static int _cr_check_pag_resp(struct bsc_connection *bsc,
static int _dt_check_id_resp(struct bsc_connection *bsc, static int _dt_check_id_resp(struct bsc_connection *bsc,
uint8_t *data, unsigned int length, uint8_t *data, unsigned int length,
struct nat_sccp_connection *con, struct nat_sccp_connection *con,
struct bsc_nat_reject_cause *cause) struct bsc_filter_reject_cause *cause)
{ {
char mi_string[GSM48_MI_SIZE]; char mi_string[GSM48_MI_SIZE];
uint8_t mi_type; uint8_t mi_type;
@@ -330,7 +330,7 @@ static int _dt_check_id_resp(struct bsc_connection *bsc,
/* Filter out CR data... */ /* Filter out CR data... */
int bsc_nat_filter_sccp_cr(struct bsc_connection *bsc, struct msgb *msg, int bsc_nat_filter_sccp_cr(struct bsc_connection *bsc, struct msgb *msg,
struct bsc_nat_parsed *parsed, int *con_type, struct bsc_nat_parsed *parsed, int *con_type,
char **imsi, struct bsc_nat_reject_cause *cause) char **imsi, struct bsc_filter_reject_cause *cause)
{ {
struct tlv_parsed tp; struct tlv_parsed tp;
struct gsm48_hdr *hdr48; struct gsm48_hdr *hdr48;
@@ -414,7 +414,7 @@ int bsc_nat_filter_sccp_cr(struct bsc_connection *bsc, struct msgb *msg,
int bsc_nat_filter_dt(struct bsc_connection *bsc, struct msgb *msg, int bsc_nat_filter_dt(struct bsc_connection *bsc, struct msgb *msg,
struct nat_sccp_connection *con, struct bsc_nat_parsed *parsed, struct nat_sccp_connection *con, struct bsc_nat_parsed *parsed,
struct bsc_nat_reject_cause *cause) struct bsc_filter_reject_cause *cause)
{ {
uint32_t len; uint32_t len;
uint8_t msg_type, proto; uint8_t msg_type, proto;

View File

@@ -426,7 +426,7 @@ static void bsc_stat_reject(int filter, struct bsc_connection *bsc, int normal)
*/ */
static void bsc_send_con_release(struct bsc_connection *bsc, static void bsc_send_con_release(struct bsc_connection *bsc,
struct nat_sccp_connection *con, struct nat_sccp_connection *con,
struct bsc_nat_reject_cause *cause) struct bsc_filter_reject_cause *cause)
{ {
struct msgb *rlsd; struct msgb *rlsd;
/* 1. release the network */ /* 1. release the network */
@@ -476,7 +476,7 @@ static void bsc_send_con_release(struct bsc_connection *bsc,
static void bsc_send_con_refuse(struct bsc_connection *bsc, static void bsc_send_con_refuse(struct bsc_connection *bsc,
struct bsc_nat_parsed *parsed, int con_type, struct bsc_nat_parsed *parsed, int con_type,
struct bsc_nat_reject_cause *cause) struct bsc_filter_reject_cause *cause)
{ {
struct msgb *payload; struct msgb *payload;
struct msgb *refuse; struct msgb *refuse;
@@ -1026,7 +1026,7 @@ static int forward_sccp_to_msc(struct bsc_connection *bsc, struct msgb *msg)
struct bsc_connection *con_bsc = NULL; struct bsc_connection *con_bsc = NULL;
int con_type; int con_type;
struct bsc_nat_parsed *parsed; struct bsc_nat_parsed *parsed;
struct bsc_nat_reject_cause cause; struct bsc_filter_reject_cause cause;
/* Parse and filter messages */ /* Parse and filter messages */
parsed = bsc_nat_parse(msg); parsed = bsc_nat_parse(msg);

View File

@@ -503,7 +503,7 @@ DEFUN(cfg_nat_imsi_black_list_fn,
int rc; int rc;
struct osmo_config_list *rewr = NULL; struct osmo_config_list *rewr = NULL;
rewr = osmo_config_list_parse(_nat, _nat->imsi_black_list_fn); rewr = osmo_config_list_parse(_nat, _nat->imsi_black_list_fn);
rc = bsc_nat_barr_adapt(_nat, &_nat->imsi_black_list, rewr); rc = bsc_filter_barr_adapt(_nat, &_nat->imsi_black_list, rewr);
if (rc != 0) { if (rc != 0) {
vty_out(vty, "%%There was an error parsing the list." vty_out(vty, "%%There was an error parsing the list."
" Please see the error log.%s", VTY_NEWLINE); " Please see the error log.%s", VTY_NEWLINE);
@@ -513,7 +513,7 @@ DEFUN(cfg_nat_imsi_black_list_fn,
return CMD_SUCCESS; return CMD_SUCCESS;
} }
bsc_nat_barr_adapt(_nat, &_nat->imsi_black_list, NULL); bsc_filter_barr_adapt(_nat, &_nat->imsi_black_list, NULL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@@ -524,7 +524,7 @@ DEFUN(cfg_nat_no_imsi_black_list_fn,
{ {
talloc_free(_nat->imsi_black_list_fn); talloc_free(_nat->imsi_black_list_fn);
_nat->imsi_black_list_fn = NULL; _nat->imsi_black_list_fn = NULL;
bsc_nat_barr_adapt(_nat, &_nat->imsi_black_list, NULL); bsc_filter_barr_adapt(_nat, &_nat->imsi_black_list, NULL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@@ -862,8 +862,8 @@ DEFUN(show_bar_lst,
vty_out(vty, "IMSIs barred from the network:%s", VTY_NEWLINE); vty_out(vty, "IMSIs barred from the network:%s", VTY_NEWLINE);
for (node = rb_first(&_nat->imsi_black_list); node; node = rb_next(node)) { for (node = rb_first(&_nat->imsi_black_list); node; node = rb_next(node)) {
struct bsc_nat_barr_entry *entry; struct bsc_filter_barr_entry *entry;
entry = rb_entry(node, struct bsc_nat_barr_entry, node); entry = rb_entry(node, struct bsc_filter_barr_entry, node);
vty_out(vty, " IMSI(%s) CM-Reject-Cause(%d) LU-Reject-Cause(%d)%s", vty_out(vty, " IMSI(%s) CM-Reject-Cause(%d) LU-Reject-Cause(%d)%s",
entry->imsi, entry->cm_reject_cause, entry->lu_reject_cause, entry->imsi, entry->cm_reject_cause, entry->lu_reject_cause,

View File

@@ -870,7 +870,7 @@ static void test_cr_filter()
struct bsc_nat_parsed *parsed; struct bsc_nat_parsed *parsed;
struct bsc_msg_acc_lst *nat_lst, *bsc_lst; struct bsc_msg_acc_lst *nat_lst, *bsc_lst;
struct bsc_msg_acc_lst_entry *nat_entry, *bsc_entry; struct bsc_msg_acc_lst_entry *nat_entry, *bsc_entry;
struct bsc_nat_reject_cause cause; struct bsc_filter_reject_cause cause;
struct bsc_nat *nat = bsc_nat_alloc(); struct bsc_nat *nat = bsc_nat_alloc();
struct bsc_connection *bsc = bsc_connection_alloc(nat); struct bsc_connection *bsc = bsc_connection_alloc(nat);
@@ -947,7 +947,7 @@ static void test_dt_filter()
int i; int i;
struct msgb *msg = msgb_alloc(4096, "test_dt_filter"); struct msgb *msg = msgb_alloc(4096, "test_dt_filter");
struct bsc_nat_parsed *parsed; struct bsc_nat_parsed *parsed;
struct bsc_nat_reject_cause cause; struct bsc_filter_reject_cause cause;
struct bsc_nat *nat = bsc_nat_alloc(); struct bsc_nat *nat = bsc_nat_alloc();
struct bsc_connection *bsc = bsc_connection_alloc(nat); struct bsc_connection *bsc = bsc_connection_alloc(nat);
@@ -1454,21 +1454,21 @@ static void test_barr_list_parsing(void)
if (lst == NULL) if (lst == NULL)
abort(); abort();
rc = bsc_nat_barr_adapt(NULL, &root, lst); rc = bsc_filter_barr_adapt(NULL, &root, lst);
if (rc != 0) if (rc != 0)
abort(); abort();
talloc_free(lst); talloc_free(lst);
for (node = rb_first(&root); node; node = rb_next(node)) { for (node = rb_first(&root); node; node = rb_next(node)) {
struct bsc_nat_barr_entry *entry; struct bsc_filter_barr_entry *entry;
entry = rb_entry(node, struct bsc_nat_barr_entry, node); entry = rb_entry(node, struct bsc_filter_barr_entry, node);
printf("IMSI: %s CM: %d LU: %d\n", entry->imsi, printf("IMSI: %s CM: %d LU: %d\n", entry->imsi,
entry->cm_reject_cause, entry->lu_reject_cause); entry->cm_reject_cause, entry->lu_reject_cause);
} }
/* do the look up now.. */ /* do the look up now.. */
rc = bsc_nat_barr_find(&root, "12123119", &cm, &lu); rc = bsc_filter_barr_find(&root, "12123119", &cm, &lu);
if (!rc) { if (!rc) {
printf("Failed to find the IMSI.\n"); printf("Failed to find the IMSI.\n");
abort(); abort();
@@ -1480,7 +1480,7 @@ static void test_barr_list_parsing(void)
} }
/* empty and check that it is empty */ /* empty and check that it is empty */
bsc_nat_barr_adapt(NULL, &root, NULL); bsc_filter_barr_adapt(NULL, &root, NULL);
if (!RB_EMPTY_ROOT(&root)) { if (!RB_EMPTY_ROOT(&root)) {
printf("Failed to empty the list.\n"); printf("Failed to empty the list.\n");
abort(); abort();
@@ -1493,7 +1493,7 @@ static void test_barr_list_parsing(void)
abort(); abort();
} }
rc = bsc_nat_barr_adapt(NULL, &root, lst); rc = bsc_filter_barr_adapt(NULL, &root, lst);
if (rc != -1) { if (rc != -1) {
printf("It should have failed due dup\n"); printf("It should have failed due dup\n");
abort(); abort();
@@ -1502,13 +1502,13 @@ static void test_barr_list_parsing(void)
/* dump for reference */ /* dump for reference */
for (node = rb_first(&root); node; node = rb_next(node)) { for (node = rb_first(&root); node; node = rb_next(node)) {
struct bsc_nat_barr_entry *entry; struct bsc_filter_barr_entry *entry;
entry = rb_entry(node, struct bsc_nat_barr_entry, node); entry = rb_entry(node, struct bsc_filter_barr_entry, node);
printf("IMSI: %s CM: %d LU: %d\n", entry->imsi, printf("IMSI: %s CM: %d LU: %d\n", entry->imsi,
entry->cm_reject_cause, entry->lu_reject_cause); entry->cm_reject_cause, entry->lu_reject_cause);
} }
rc = bsc_nat_barr_adapt(NULL, &root, NULL); rc = bsc_filter_barr_adapt(NULL, &root, NULL);
} }
static void test_nat_extract_lac() static void test_nat_extract_lac()