aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/nat/bsc_sccp.c
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-06-15 20:24:08 +0800
commit58a56797a89c24dec2960de85f5168297d61a98f (patch)
treee081e0ba5ed2ad49f115de4c03bf50f080b44592 /openbsc/src/nat/bsc_sccp.c
parent0dc569abc208149d5d566f4b25bb464ccb947cbb (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/src/nat/bsc_sccp.c')
-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 8c14aa892..226e2e0d8 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;