blob: 248a0828b1a6f7fe405d5dd0c1e456e3967f49b8 [file] [log] [blame]
Holger Hans Peter Freyther973dbae2015-04-04 20:47:03 +02001#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 Freyther4579bb12015-04-04 21:55:08 +020011struct bsc_nat;
Holger Hans Peter Freyther973dbae2015-04-04 20:47:03 +020012struct bsc_nat_parsed;
13struct bsc_connection;
14struct nat_sccp_connection;
15
16struct bsc_nat_reject_cause {
17 int lu_reject_cause;
18 int cm_reject_cause;
19};
20
21struct 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
29enum bsc_nat_acc_ctr {
30 ACC_LIST_BSC_FILTER,
31 ACC_LIST_NAT_FILTER,
32};
33
34struct 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
45struct 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
60int bsc_nat_barr_adapt(void *ctx, struct rb_root *rbtree, const struct osmo_config_list *);
61int bsc_nat_barr_find(struct rb_root *root, const char *imsi, int *cm, int *lu);
62
63/**
64 * Content filtering.
65 */
66int 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);
69int 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 Freyther4579bb12015-04-04 21:55:08 +020073/* IMSI allow/deny handling */
74struct bsc_nat_acc_lst *bsc_nat_acc_lst_find(struct bsc_nat *nat, const char *name);
75struct bsc_nat_acc_lst *bsc_nat_acc_lst_get(struct bsc_nat *nat, const char *name);
76void bsc_nat_acc_lst_delete(struct bsc_nat_acc_lst *lst);
77
78struct bsc_nat_acc_lst_entry *bsc_nat_acc_lst_entry_create(struct bsc_nat_acc_lst *);
79int bsc_nat_lst_check_allow(struct bsc_nat_acc_lst *lst, const char *imsi);
80