aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-04-18 02:26:16 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-04-18 02:40:33 +0800
commit7897c4446b8f4a1731f4a8755b51f2567f8cb22a (patch)
tree24b4b9e57da2ab17fb3f8c50b21ff278b8961c73
parentff9e09b2bc3fafbd752907fe93a2ed066d8e35cf (diff)
nat: Return the SCCP Connection again...
We will reset the multiplex in a DLCX message and then we can reset the multiplex as well...even if the MGCP connection is staying open. or at least this is a theory. The MSC likes to leave a connection open during CallControl when hanging up early enough in the process.
-rw-r--r--openbsc/include/openbsc/bsc_nat.h2
-rw-r--r--openbsc/src/nat/bsc_mgcp_utils.c22
-rw-r--r--openbsc/tests/bsc-nat/bsc_nat_test.c4
3 files changed, 14 insertions, 14 deletions
diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h
index a6e7544ef..64c6b8656 100644
--- a/openbsc/include/openbsc/bsc_nat.h
+++ b/openbsc/include/openbsc/bsc_nat.h
@@ -260,7 +260,7 @@ void bsc_mgcp_free_endpoint(struct bsc_nat *nat, int);
void bsc_mgcp_free_endpoints(struct bsc_nat *nat);
int bsc_mgcp_init(struct bsc_nat *nat);
-struct bsc_connection *bsc_mgcp_find_con(struct bsc_nat *, int endpoint_number);
+struct sccp_connections *bsc_mgcp_find_con(struct bsc_nat *, int endpoint_number);
struct msgb *bsc_mgcp_rewrite(char *input, int length, const char *ip, int port);
void bsc_mgcp_forward(struct bsc_connection *bsc, struct msgb *msg);
diff --git a/openbsc/src/nat/bsc_mgcp_utils.c b/openbsc/src/nat/bsc_mgcp_utils.c
index ab830e6e5..abfadb8b4 100644
--- a/openbsc/src/nat/bsc_mgcp_utils.c
+++ b/openbsc/src/nat/bsc_mgcp_utils.c
@@ -92,9 +92,9 @@ void bsc_mgcp_free_endpoints(struct bsc_nat *nat)
bsc_mgcp_free_endpoint(nat, i);
}
-struct bsc_connection *bsc_mgcp_find_con(struct bsc_nat *nat, int endpoint)
+struct sccp_connections *bsc_mgcp_find_con(struct bsc_nat *nat, int endpoint)
{
- struct bsc_connection *bsc = NULL;
+ struct sccp_connections *con = NULL;
struct sccp_connections *sccp;
llist_for_each_entry(sccp, &nat->sccp_connections, list_entry) {
@@ -103,11 +103,11 @@ struct bsc_connection *bsc_mgcp_find_con(struct bsc_nat *nat, int endpoint)
if (mgcp_timeslot_to_endpoint(0, sccp->msc_timeslot) != endpoint)
continue;
- bsc = sccp->bsc;
+ con = sccp;
}
- if (bsc)
- return bsc;
+ if (con)
+ return con;
LOGP(DMGCP, LOGL_ERROR, "Failed to find the connection.\n");
return NULL;
@@ -117,7 +117,7 @@ int bsc_mgcp_policy_cb(struct mgcp_config *cfg, int endpoint, int state, const c
{
struct bsc_nat *nat;
struct bsc_endpoint *bsc_endp;
- struct bsc_connection *bsc_con;
+ struct sccp_connections *sccp;
struct mgcp_endpoint *mgcp_endp;
struct msgb *bsc_msg;
@@ -125,9 +125,9 @@ int bsc_mgcp_policy_cb(struct mgcp_config *cfg, int endpoint, int state, const c
bsc_endp = &nat->bsc_endpoints[endpoint];
mgcp_endp = &nat->mgcp_cfg->endpoints[endpoint];
- bsc_con = bsc_mgcp_find_con(nat, endpoint);
+ sccp = bsc_mgcp_find_con(nat, endpoint);
- if (!bsc_con) {
+ if (!sccp) {
LOGP(DMGCP, LOGL_ERROR, "Did not find BSC for a new connection on 0x%x for %d\n", endpoint, state);
switch (state) {
@@ -163,14 +163,14 @@ int bsc_mgcp_policy_cb(struct mgcp_config *cfg, int endpoint, int state, const c
bsc_endp->transaction_id = talloc_strdup(nat, transaction_id);
- bsc_endp->bsc = bsc_con;
+ bsc_endp->bsc = sccp->bsc;
bsc_endp->pending_delete = 0;
/* we need to update some bits */
if (state == MGCP_ENDP_CRCX) {
struct sockaddr_in sock;
socklen_t len = sizeof(sock);
- if (getpeername(bsc_con->write_queue.bfd.fd, (struct sockaddr *) &sock, &len) != 0) {
+ if (getpeername(sccp->bsc->write_queue.bfd.fd, (struct sockaddr *) &sock, &len) != 0) {
LOGP(DMGCP, LOGL_ERROR, "Can not get the peername...%d/%s\n",
errno, strerror(errno));
} else {
@@ -182,7 +182,7 @@ int bsc_mgcp_policy_cb(struct mgcp_config *cfg, int endpoint, int state, const c
mgcp_free_endp(mgcp_endp);
}
- bsc_write(bsc_con, bsc_msg, NAT_IPAC_PROTO_MGCP);
+ bsc_write(sccp->bsc, bsc_msg, NAT_IPAC_PROTO_MGCP);
return MGCP_POLICY_DEFER;
}
diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c
index d2f6dbf26..d97a49194 100644
--- a/openbsc/tests/bsc-nat/bsc_nat_test.c
+++ b/openbsc/tests/bsc-nat/bsc_nat_test.c
@@ -432,14 +432,14 @@ static void test_mgcp_find(void)
abort();
}
- if (bsc_mgcp_find_con(nat, 12) != con) {
+ if (bsc_mgcp_find_con(nat, 12) != sccp_con) {
fprintf(stderr, "Didn't find the connection\n");
abort();
}
sccp_con->msc_timeslot = 0;
sccp_con->bsc_timeslot = 0;
- if (bsc_mgcp_find_con(nat, 1) != con) {
+ if (bsc_mgcp_find_con(nat, 1) != sccp_con) {
fprintf(stderr, "Didn't find the connection\n");
abort();
}