Holger Hans Peter Freyther | 973dbae | 2015-04-04 20:47:03 +0200 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <osmocom/core/msgb.h> |
| 4 | #include <osmocom/core/msgfile.h> |
| 5 | #include <osmocom/core/linuxrbtree.h> |
| 6 | #include <osmocom/core/linuxlist.h> |
| 7 | |
| 8 | #include <regex.h> |
| 9 | |
| 10 | /* TODO: remove */ |
Holger Hans Peter Freyther | 4579bb1 | 2015-04-04 21:55:08 +0200 | [diff] [blame^] | 11 | struct bsc_nat; |
Holger Hans Peter Freyther | 973dbae | 2015-04-04 20:47:03 +0200 | [diff] [blame] | 12 | struct bsc_nat_parsed; |
| 13 | struct bsc_connection; |
| 14 | struct nat_sccp_connection; |
| 15 | |
| 16 | struct bsc_nat_reject_cause { |
| 17 | int lu_reject_cause; |
| 18 | int cm_reject_cause; |
| 19 | }; |
| 20 | |
| 21 | struct bsc_nat_barr_entry { |
| 22 | struct rb_node node; |
| 23 | |
| 24 | char *imsi; |
| 25 | int cm_reject_cause; |
| 26 | int lu_reject_cause; |
| 27 | }; |
| 28 | |
| 29 | enum bsc_nat_acc_ctr { |
| 30 | ACC_LIST_BSC_FILTER, |
| 31 | ACC_LIST_NAT_FILTER, |
| 32 | }; |
| 33 | |
| 34 | struct bsc_nat_acc_lst { |
| 35 | struct llist_head list; |
| 36 | |
| 37 | /* counter */ |
| 38 | struct rate_ctr_group *stats; |
| 39 | |
| 40 | /* the name of the list */ |
| 41 | const char *name; |
| 42 | struct llist_head fltr_list; |
| 43 | }; |
| 44 | |
| 45 | struct bsc_nat_acc_lst_entry { |
| 46 | struct llist_head list; |
| 47 | |
| 48 | /* the filter */ |
| 49 | char *imsi_allow; |
| 50 | regex_t imsi_allow_re; |
| 51 | char *imsi_deny; |
| 52 | regex_t imsi_deny_re; |
| 53 | |
| 54 | /* reject reasons for the access lists */ |
| 55 | int cm_reject_cause; |
| 56 | int lu_reject_cause; |
| 57 | }; |
| 58 | |
| 59 | |
| 60 | int bsc_nat_barr_adapt(void *ctx, struct rb_root *rbtree, const struct osmo_config_list *); |
| 61 | int bsc_nat_barr_find(struct rb_root *root, const char *imsi, int *cm, int *lu); |
| 62 | |
| 63 | /** |
| 64 | * Content filtering. |
| 65 | */ |
| 66 | int bsc_nat_filter_sccp_cr(struct bsc_connection *bsc, struct msgb *msg, |
| 67 | struct bsc_nat_parsed *, int *con_type, char **imsi, |
| 68 | struct bsc_nat_reject_cause *cause); |
| 69 | int bsc_nat_filter_dt(struct bsc_connection *bsc, struct msgb *msg, |
| 70 | struct nat_sccp_connection *con, struct bsc_nat_parsed *parsed, |
| 71 | struct bsc_nat_reject_cause *cause); |
| 72 | |
Holger Hans Peter Freyther | 4579bb1 | 2015-04-04 21:55:08 +0200 | [diff] [blame^] | 73 | /* IMSI allow/deny handling */ |
| 74 | struct bsc_nat_acc_lst *bsc_nat_acc_lst_find(struct bsc_nat *nat, const char *name); |
| 75 | struct bsc_nat_acc_lst *bsc_nat_acc_lst_get(struct bsc_nat *nat, const char *name); |
| 76 | void bsc_nat_acc_lst_delete(struct bsc_nat_acc_lst *lst); |
| 77 | |
| 78 | struct bsc_nat_acc_lst_entry *bsc_nat_acc_lst_entry_create(struct bsc_nat_acc_lst *); |
| 79 | int bsc_nat_lst_check_allow(struct bsc_nat_acc_lst *lst, const char *imsi); |
| 80 | |