aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-03-29 15:03:54 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-03-29 15:03:54 +0200
commited443e949e997503e71717fb4f9cb754d90fcc28 (patch)
tree1f422dc667d4b0bef6b2579ad543e7cef8f9bcd3 /openbsc
parent1df69f3c646a6c02a920b62586188a8d6b905775 (diff)
nat: Actually add the connection to the SCCP list of active connections
Add the connection to the list of active connections. Otherwise we are not able to find the connection.
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/src/nat/bsc_sccp.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/openbsc/src/nat/bsc_sccp.c b/openbsc/src/nat/bsc_sccp.c
index dea825e63..809fe94c8 100644
--- a/openbsc/src/nat/bsc_sccp.c
+++ b/openbsc/src/nat/bsc_sccp.c
@@ -23,6 +23,8 @@
#include <openbsc/debug.h>
#include <openbsc/bsc_nat.h>
+#include <sccp/sccp.h>
+
#include <osmocore/talloc.h>
#include <string.h>
@@ -84,6 +86,7 @@ int create_sccp_src_ref(struct bsc_connection *bsc, struct msgb *msg, struct bsc
return -1;
}
+ conn->bsc = bsc;
conn->real_ref = *parsed->src_local_ref;
if (assign_src_local_reference(&conn->patched_ref, bsc->nat) != 0) {
LOGP(DNAT, LOGL_ERROR, "Failed to assign a ref.\n");
@@ -91,6 +94,12 @@ int create_sccp_src_ref(struct bsc_connection *bsc, struct msgb *msg, struct bsc
return -1;
}
+ llist_add(&conn->list_entry, &bsc->nat->sccp_connections);
+
+ LOGP(DNAT, LOGL_DEBUG, "Created 0x%x <-> 0x%x mapping for con 0x%p\n",
+ sccp_src_ref_to_int(&conn->real_ref),
+ sccp_src_ref_to_int(&conn->patched_ref), bsc);
+
return 0;
}
@@ -101,12 +110,14 @@ void remove_sccp_src_ref(struct bsc_connection *bsc, struct msgb *msg, struct bs
llist_for_each_entry(conn, &bsc->nat->sccp_connections, list_entry) {
if (memcmp(parsed->src_local_ref,
&conn->real_ref, sizeof(conn->real_ref)) == 0) {
- if (bsc != conn->bsc) {
- LOGP(DNAT, LOGL_ERROR, "Someone else...\n");
- continue;
- }
+ /* two BSCs have used the same real ref... this is why we rewrite it */
+ if (bsc != conn->bsc)
+ continue;
+ LOGP(DNAT, LOGL_DEBUG, "Destroy 0x%x <-> 0x%x mapping for con 0x%p\n",
+ sccp_src_ref_to_int(&conn->real_ref),
+ sccp_src_ref_to_int(&conn->patched_ref), bsc);
llist_del(&conn->list_entry);
talloc_free(conn);
return;