summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Willmann <dwillmann@sysmocom.de>2017-09-08 04:00:08 +0200
committerMax <msuraev@sysmocom.de>2017-09-19 18:27:25 +0200
commitc91bb04b893b42b484c3a66fdad15e2018de4869 (patch)
treeba7a8bc653cfabaf27a79c8005e78bf611d530da
parent994d89e7e8c437eddbefdea22c051bb3fbd1aa49 (diff)
osmo-bsc_nat: Handle multiple mgcp configs in SCCP conn
-rw-r--r--openbsc/include/openbsc/bsc_nat.h2
-rw-r--r--openbsc/include/openbsc/bsc_nat_sccp.h2
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c10
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat.c4
4 files changed, 12 insertions, 6 deletions
diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h
index abafd6f51..81843794a 100644
--- a/openbsc/include/openbsc/bsc_nat.h
+++ b/openbsc/include/openbsc/bsc_nat.h
@@ -406,7 +406,7 @@ void bsc_mgcp_dlcx(struct nat_sccp_connection *);
void bsc_mgcp_free_endpoints(struct bsc_nat *nat);
int bsc_mgcp_nat_init(struct bsc_nat *nat, struct llist_head* cfgs);
-struct nat_sccp_connection *bsc_mgcp_find_con(struct bsc_nat *, int endpoint_number);
+struct nat_sccp_connection *bsc_mgcp_find_con(struct bsc_nat *, struct mgcp_config *, int endpoint_number);
struct msgb *bsc_mgcp_rewrite(char *input, int length, int endp, const char *ip,
int port, int osmux, int *first_payload_type, int mode_set);
void bsc_mgcp_forward(struct bsc_connection *bsc, struct msgb *msg);
diff --git a/openbsc/include/openbsc/bsc_nat_sccp.h b/openbsc/include/openbsc/bsc_nat_sccp.h
index 082466408..750db78d6 100644
--- a/openbsc/include/openbsc/bsc_nat_sccp.h
+++ b/openbsc/include/openbsc/bsc_nat_sccp.h
@@ -72,6 +72,8 @@ struct nat_sccp_connection {
struct bsc_connection *bsc;
struct bsc_msc_connection *msc_con;
+ struct msc_config *msc_conf;
+ struct mgcp_config *mgcp_conf;
struct sccp_source_reference real_ref;
struct sccp_source_reference patched_ref;
diff --git a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
index ac1a14bc0..32e3f4f8e 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
@@ -204,7 +204,7 @@ int bsc_mgcp_assign_patch(struct nat_sccp_connection *con, struct msgb *msg)
endp = mgcp_timeslot_to_endpoint(multiplex, timeslot);
- if (endp >= con->bsc->nat->mgcp_cfg->trunk.number_endpoints) {
+ if (endp >= con->mgcp_conf->trunk.number_endpoints) {
LOGP(DNAT, LOGL_ERROR,
"MSC attempted to assign bad endpoint 0x%x\n",
endp);
@@ -336,7 +336,7 @@ static void remember_pending_dlcx(struct nat_sccp_connection *con, uint32_t tran
}
/* take the endpoint here */
- endp = &bsc->nat->mgcp_cfg->trunk.endpoints[con->msc_endp];
+ endp = &con->mgcp_conf->trunk.endpoints[con->msc_endp];
stats->remote_ref = con->remote_ref;
stats->src_ref = con->patched_ref;
@@ -638,8 +638,8 @@ static int bsc_mgcp_policy_cb(struct mgcp_trunk_config *tcfg, int endpoint, int
/*
* We do have a failure, free data downstream..
*/
-static void free_chan_downstream(struct mgcp_endpoint *endp, struct bsc_endpoint *bsc_endp,
- struct bsc_connection *bsc)
+static void free_chan_downstream(struct mgcp_config *mgcp_cfg, struct mgcp_endpoint *endp,
+ struct bsc_endpoint *bsc_endp, struct bsc_connection *bsc)
{
LOGP(DMGCP, LOGL_ERROR, "No CI, freeing endpoint 0x%x in state %d\n",
ENDPOINT_NUMBER(endp), bsc_endp->transaction_state);
@@ -662,7 +662,7 @@ static void free_chan_downstream(struct mgcp_endpoint *endp, struct bsc_endpoint
}
}
- bsc_mgcp_free_endpoint(bsc->nat, ENDPOINT_NUMBER(endp));
+ bsc_mgcp_free_endpoint(mgcp_cfg, ENDPOINT_NUMBER(endp));
mgcp_release_endp(endp);
}
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c
index 1edc3b710..98e002d8a 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c
@@ -1165,6 +1165,10 @@ static int forward_sccp_to_msc(struct bsc_connection *bsc, struct msgb *msg)
}
con_msc = con->msc_con;
+ /* Shortcuts for handling later */
+ con->msc_conf = msc_config_by_con(bsc->nat, con_msc);
+ con->mgcp_conf = mgcp_config_by_num(&bsc->nat->mgcp_cfgs, con->msc_conf->nr);
+
con->filter_state.con_type = con_type;
con->filter_state.imsi_checked = filter;
bsc_nat_extract_lac(bsc, con, parsed, msg);