aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-04-05 21:03:49 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-05-03 22:09:02 +0200
commitc652913674ecc30f8d234878a17baa623cbacf99 (patch)
tree09897c3d57db4568552461c824ad5696b5e7f704 /openbsc
parent06a88fa0ae1f86cef0a23a1462bfef950418ea36 (diff)
filter: Move the con_type into the filter_state
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/include/openbsc/bsc_msg_filter.h12
-rw-r--r--openbsc/include/openbsc/bsc_nat.h10
-rw-r--r--openbsc/include/openbsc/bsc_nat_sccp.h1
-rw-r--r--openbsc/src/libfilter/bsc_msg_filter.c12
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_api.c1
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat.c12
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_filter.c2
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_utils.c30
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_vty.c2
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_ussd.c2
-rw-r--r--openbsc/tests/bsc-nat/bsc_nat_test.c22
11 files changed, 54 insertions, 52 deletions
diff --git a/openbsc/include/openbsc/bsc_msg_filter.h b/openbsc/include/openbsc/bsc_msg_filter.h
index b09cd8aa6..a9dedf43c 100644
--- a/openbsc/include/openbsc/bsc_msg_filter.h
+++ b/openbsc/include/openbsc/bsc_msg_filter.h
@@ -53,9 +53,21 @@ struct bsc_msg_acc_lst_entry {
int lu_reject_cause;
};
+enum {
+ FLT_CON_TYPE_NONE,
+ FLT_CON_TYPE_LU,
+ FLT_CON_TYPE_CM_SERV_REQ,
+ FLT_CON_TYPE_PAG_RESP,
+ FLT_CON_TYPE_SSA,
+ FLT_CON_TYPE_LOCAL_REJECT,
+ FLT_CON_TYPE_OTHER,
+};
+
+
struct bsc_filter_state {
char *imsi;
int imsi_checked;
+ int con_type;
};
struct bsc_filter_request {
diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h
index 10f11a62b..ae940b390 100644
--- a/openbsc/include/openbsc/bsc_nat.h
+++ b/openbsc/include/openbsc/bsc_nat.h
@@ -48,16 +48,6 @@ struct bsc_nat;
struct bsc_nat_ussd_con;
struct nat_rewrite_rule;
-enum {
- NAT_CON_TYPE_NONE,
- NAT_CON_TYPE_LU,
- NAT_CON_TYPE_CM_SERV_REQ,
- NAT_CON_TYPE_PAG_RESP,
- NAT_CON_TYPE_SSA,
- NAT_CON_TYPE_LOCAL_REJECT,
- NAT_CON_TYPE_OTHER,
-};
-
/*
* Is this terminated to the MSC, to the local machine (release
* handling for IMSI filtering) or to a USSD provider?
diff --git a/openbsc/include/openbsc/bsc_nat_sccp.h b/openbsc/include/openbsc/bsc_nat_sccp.h
index d2490ca6a..082466408 100644
--- a/openbsc/include/openbsc/bsc_nat_sccp.h
+++ b/openbsc/include/openbsc/bsc_nat_sccp.h
@@ -79,7 +79,6 @@ struct nat_sccp_connection {
int has_remote_ref;
/* status */
- int con_type;
int con_local;
int authorized;
diff --git a/openbsc/src/libfilter/bsc_msg_filter.c b/openbsc/src/libfilter/bsc_msg_filter.c
index c3d1bed9d..2bbfa078e 100644
--- a/openbsc/src/libfilter/bsc_msg_filter.c
+++ b/openbsc/src/libfilter/bsc_msg_filter.c
@@ -256,7 +256,7 @@ static int _cr_check_cm_serv_req(void *ctx,
req = (struct gsm48_service_request *) data;
if (req->cm_service_type == 0x8)
- *con_type = NAT_CON_TYPE_SSA;
+ *con_type = FLT_CON_TYPE_SSA;
rc = gsm48_extract_mi((uint8_t *) &req->classmark,
length - classmark_offset, mi_string, &mi_type);
if (rc < 0) {
@@ -337,7 +337,7 @@ int bsc_msg_filter_initial(struct gsm48_hdr *hdr48, size_t hdr48_len,
int ret = 0;
uint8_t msg_type, proto;
- *con_type = NAT_CON_TYPE_NONE;
+ *con_type = FLT_CON_TYPE_NONE;
cause->cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED;
cause->lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED;
*imsi = NULL;
@@ -346,23 +346,23 @@ int bsc_msg_filter_initial(struct gsm48_hdr *hdr48, size_t hdr48_len,
msg_type = hdr48->msg_type & 0xbf;
if (proto == GSM48_PDISC_MM &&
msg_type == GSM48_MT_MM_LOC_UPD_REQUEST) {
- *con_type = NAT_CON_TYPE_LU;
+ *con_type = FLT_CON_TYPE_LU;
ret = _cr_check_loc_upd(req->ctx, &hdr48->data[0],
hdr48_len - sizeof(*hdr48), imsi);
} else if (proto == GSM48_PDISC_MM &&
msg_type == GSM48_MT_MM_CM_SERV_REQ) {
- *con_type = NAT_CON_TYPE_CM_SERV_REQ;
+ *con_type = FLT_CON_TYPE_CM_SERV_REQ;
ret = _cr_check_cm_serv_req(req->ctx, &hdr48->data[0],
hdr48_len - sizeof(*hdr48),
con_type, imsi);
} else if (proto == GSM48_PDISC_RR &&
msg_type == GSM48_MT_RR_PAG_RESP) {
- *con_type = NAT_CON_TYPE_PAG_RESP;
+ *con_type = FLT_CON_TYPE_PAG_RESP;
ret = _cr_check_pag_resp(req->ctx, &hdr48->data[0],
hdr48_len - sizeof(*hdr48), imsi);
} else {
/* We only want to filter the above, let other things pass */
- *con_type = NAT_CON_TYPE_OTHER;
+ *con_type = FLT_CON_TYPE_OTHER;
return 0;
}
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_api.c b/openbsc/src/osmo-bsc/osmo_bsc_api.c
index 18b9607a0..a90ad1689 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_api.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_api.c
@@ -210,6 +210,7 @@ static int complete_layer3(struct gsm_subscriber_connection *conn,
ci = get_ci_for_msc(conn->sccp_con->msc, conn->bts);
bsc_scan_bts_msg(conn, msg);
+
resp = gsm0808_create_layer3(msg, network_code, country_code, lac, ci);
if (!resp) {
LOGP(DMSC, LOGL_DEBUG, "Failed to create layer3 message.\n");
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c
index 3ec43b15f..4357485ff 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c
@@ -442,7 +442,7 @@ static void bsc_send_con_release(struct bsc_connection *bsc,
con->msc_con = NULL;
/* 2. release the BSC side */
- if (con->con_type == NAT_CON_TYPE_LU) {
+ if (con->filter_state.con_type == FLT_CON_TYPE_LU) {
struct msgb *payload, *udt;
payload = gsm48_create_loc_upd_rej(cause->lu_reject_cause);
@@ -470,7 +470,7 @@ static void bsc_send_con_release(struct bsc_connection *bsc,
return;
}
- con->con_type = NAT_CON_TYPE_LOCAL_REJECT;
+ con->filter_state.con_type = FLT_CON_TYPE_LOCAL_REJECT;
bsc_write(bsc, rlsd, IPAC_PROTO_SCCP);
}
@@ -481,9 +481,9 @@ static void bsc_send_con_refuse(struct bsc_connection *bsc,
struct msgb *payload;
struct msgb *refuse;
- if (con_type == NAT_CON_TYPE_LU)
+ if (con_type == FLT_CON_TYPE_LU)
payload = gsm48_create_loc_upd_rej(cause->lu_reject_cause);
- else if (con_type == NAT_CON_TYPE_CM_SERV_REQ || con_type == NAT_CON_TYPE_SSA)
+ else if (con_type == FLT_CON_TYPE_CM_SERV_REQ || con_type == FLT_CON_TYPE_SSA)
payload = gsm48_create_mm_serv_rej(cause->cm_reject_cause);
else {
LOGP(DNAT, LOGL_ERROR, "Unknown connection type: %d\n", con_type);
@@ -504,7 +504,7 @@ static void bsc_send_con_refuse(struct bsc_connection *bsc,
goto send_refuse;
/* declare it local and assign a unique remote_ref */
- con->con_type = NAT_CON_TYPE_LOCAL_REJECT;
+ con->filter_state.con_type = FLT_CON_TYPE_LOCAL_REJECT;
con->con_local = NAT_CON_END_LOCAL;
con->has_remote_ref = 1;
con->remote_ref = con->patched_ref;
@@ -1072,7 +1072,7 @@ static int forward_sccp_to_msc(struct bsc_connection *bsc, struct msgb *msg)
con = patch_sccp_src_ref_to_msc(msg, parsed, bsc);
con->msc_con = bsc->nat->msc_con;
con_msc = con->msc_con;
- con->con_type = con_type;
+ con->filter_state.con_type = con_type;
con->filter_state.imsi_checked = filter;
bsc_nat_extract_lac(bsc, con, parsed, msg);
if (imsi)
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_filter.c b/openbsc/src/osmo-bsc_nat/bsc_nat_filter.c
index 6883d6692..393aea3ce 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_filter.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_filter.c
@@ -41,7 +41,7 @@ int bsc_nat_filter_sccp_cr(struct bsc_connection *bsc, struct msgb *msg,
int hdr48_len;
int len;
- *con_type = NAT_CON_TYPE_NONE;
+ *con_type = FLT_CON_TYPE_NONE;
cause->cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED;
cause->lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED;
*imsi = NULL;
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
index 89212087c..d95227dca 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
@@ -403,13 +403,13 @@ struct gsm48_hdr *bsc_unpack_dtap(struct bsc_nat_parsed *parsed,
}
static const char *con_types [] = {
- [NAT_CON_TYPE_NONE] = "n/a",
- [NAT_CON_TYPE_LU] = "Location Update",
- [NAT_CON_TYPE_CM_SERV_REQ] = "CM Serv Req",
- [NAT_CON_TYPE_PAG_RESP] = "Paging Response",
- [NAT_CON_TYPE_SSA] = "Supplementar Service Activation",
- [NAT_CON_TYPE_LOCAL_REJECT] = "Local Reject",
- [NAT_CON_TYPE_OTHER] = "Other",
+ [FLT_CON_TYPE_NONE] = "n/a",
+ [FLT_CON_TYPE_LU] = "Location Update",
+ [FLT_CON_TYPE_CM_SERV_REQ] = "CM Serv Req",
+ [FLT_CON_TYPE_PAG_RESP] = "Paging Response",
+ [FLT_CON_TYPE_SSA] = "Supplementar Service Activation",
+ [FLT_CON_TYPE_LOCAL_REJECT] = "Local Reject",
+ [FLT_CON_TYPE_OTHER] = "Other",
};
const char *bsc_con_type_to_string(int type)
@@ -423,18 +423,18 @@ int bsc_nat_msc_is_connected(struct bsc_nat *nat)
}
static const int con_to_ctr[] = {
- [NAT_CON_TYPE_NONE] = -1,
- [NAT_CON_TYPE_LU] = BCFG_CTR_CON_TYPE_LU,
- [NAT_CON_TYPE_CM_SERV_REQ] = BCFG_CTR_CON_CMSERV_RQ,
- [NAT_CON_TYPE_PAG_RESP] = BCFG_CTR_CON_PAG_RESP,
- [NAT_CON_TYPE_SSA] = BCFG_CTR_CON_SSA,
- [NAT_CON_TYPE_LOCAL_REJECT] = -1,
- [NAT_CON_TYPE_OTHER] = BCFG_CTR_CON_OTHER,
+ [FLT_CON_TYPE_NONE] = -1,
+ [FLT_CON_TYPE_LU] = BCFG_CTR_CON_TYPE_LU,
+ [FLT_CON_TYPE_CM_SERV_REQ] = BCFG_CTR_CON_CMSERV_RQ,
+ [FLT_CON_TYPE_PAG_RESP] = BCFG_CTR_CON_PAG_RESP,
+ [FLT_CON_TYPE_SSA] = BCFG_CTR_CON_SSA,
+ [FLT_CON_TYPE_LOCAL_REJECT] = -1,
+ [FLT_CON_TYPE_OTHER] = BCFG_CTR_CON_OTHER,
};
int bsc_conn_type_to_ctr(struct nat_sccp_connection *conn)
{
- return con_to_ctr[conn->con_type];
+ return con_to_ctr[conn->filter_state.con_type];
}
int bsc_write_cb(struct osmo_fd *bfd, struct msgb *msg)
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
index 596ecaee4..821e5226a 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
@@ -189,7 +189,7 @@ DEFUN(show_sccp, show_sccp_cmd, "show sccp connections",
con->has_remote_ref,
sccp_src_ref_to_int(&con->remote_ref),
con->msc_endp, con->bsc_endp,
- bsc_con_type_to_string(con->con_type),
+ bsc_con_type_to_string(con->filter_state.con_type),
VTY_NEWLINE);
}
diff --git a/openbsc/src/osmo-bsc_nat/bsc_ussd.c b/openbsc/src/osmo-bsc_nat/bsc_ussd.c
index 224189608..108241421 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_ussd.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_ussd.c
@@ -382,7 +382,7 @@ int bsc_ussd_check(struct nat_sccp_connection *con, struct bsc_nat_parsed *parse
* decode if the connection was created for USSD, we do have a USSD access
* list, a query, a IMSI and such...
*/
- if (con->con_type != NAT_CON_TYPE_SSA)
+ if (con->filter_state.con_type != FLT_CON_TYPE_SSA)
return 0;
if (!con->filter_state.imsi)
diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c
index e883ddd43..b830eb0df 100644
--- a/openbsc/tests/bsc-nat/bsc_nat_test.c
+++ b/openbsc/tests/bsc-nat/bsc_nat_test.c
@@ -711,7 +711,7 @@ static struct cr_filter cr_filter[] = {
.data = bssmap_cr,
.length = sizeof(bssmap_cr),
.result = 1,
- .contype = NAT_CON_TYPE_CM_SERV_REQ,
+ .contype = FLT_CON_TYPE_CM_SERV_REQ,
.nat_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
.nat_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
.bsc_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
@@ -723,7 +723,7 @@ static struct cr_filter cr_filter[] = {
.data = bss_lu,
.length = sizeof(bss_lu),
.result = 1,
- .contype = NAT_CON_TYPE_LU,
+ .contype = FLT_CON_TYPE_LU,
.nat_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
.nat_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
.bsc_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
@@ -735,7 +735,7 @@ static struct cr_filter cr_filter[] = {
.data = pag_resp,
.length = sizeof(pag_resp),
.result = 1,
- .contype = NAT_CON_TYPE_PAG_RESP,
+ .contype = FLT_CON_TYPE_PAG_RESP,
.nat_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
.nat_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
.bsc_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
@@ -749,7 +749,7 @@ static struct cr_filter cr_filter[] = {
.length = sizeof(bss_lu),
.result = -3,
.nat_imsi_deny = "[0-9]*",
- .contype = NAT_CON_TYPE_LU,
+ .contype = FLT_CON_TYPE_LU,
.nat_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
.nat_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
.bsc_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
@@ -764,7 +764,7 @@ static struct cr_filter cr_filter[] = {
.result = 1,
.nat_imsi_deny = "[0-9]*",
.bsc_imsi_allow = "2440[0-9]*",
- .contype = NAT_CON_TYPE_LU,
+ .contype = FLT_CON_TYPE_LU,
.nat_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
.nat_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
.bsc_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
@@ -779,7 +779,7 @@ static struct cr_filter cr_filter[] = {
.result = 1,
.bsc_imsi_allow = "[0-9]*",
.nat_imsi_deny = "[0-9]*",
- .contype = NAT_CON_TYPE_LU,
+ .contype = FLT_CON_TYPE_LU,
.nat_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
.nat_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
.bsc_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
@@ -795,7 +795,7 @@ static struct cr_filter cr_filter[] = {
.bsc_imsi_deny = "[0-9]*",
.bsc_imsi_allow = "[0-9]*",
.nat_imsi_deny = "[0-9]*",
- .contype = NAT_CON_TYPE_LU,
+ .contype = FLT_CON_TYPE_LU,
.nat_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
.nat_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
.bsc_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
@@ -810,7 +810,7 @@ static struct cr_filter cr_filter[] = {
.result = -3,
.bsc_imsi_deny = "000[0-9]*",
.nat_imsi_deny = "[0-9]*",
- .contype = NAT_CON_TYPE_LU,
+ .contype = FLT_CON_TYPE_LU,
.nat_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
.nat_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
.bsc_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
@@ -825,7 +825,7 @@ static struct cr_filter cr_filter[] = {
.result = -3,
.bsc_imsi_deny = "000[0-9]*",
.nat_imsi_deny = "[0-9]*",
- .contype = NAT_CON_TYPE_LU,
+ .contype = FLT_CON_TYPE_LU,
.nat_cm_reject_cause = 0x23,
.nat_lu_reject_cause = 0x42,
.bsc_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
@@ -839,7 +839,7 @@ static struct cr_filter cr_filter[] = {
.length = sizeof(bss_lu),
.result = -2,
.bsc_imsi_deny = "[0-9]*",
- .contype = NAT_CON_TYPE_LU,
+ .contype = FLT_CON_TYPE_LU,
.nat_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
.nat_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
.bsc_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
@@ -853,7 +853,7 @@ static struct cr_filter cr_filter[] = {
.length = sizeof(bss_lu),
.result = -2,
.bsc_imsi_deny = "[0-9]*",
- .contype = NAT_CON_TYPE_LU,
+ .contype = FLT_CON_TYPE_LU,
.nat_cm_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
.nat_lu_reject_cause = GSM48_REJECT_PLMN_NOT_ALLOWED,
.bsc_cm_reject_cause = 0x42,