From ed443e949e997503e71717fb4f9cb754d90fcc28 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 29 Mar 2010 15:03:54 +0200 Subject: 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. --- openbsc/src/nat/bsc_sccp.c | 19 +++++++++++++++---- 1 file 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 #include +#include + #include #include @@ -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; -- cgit v1.2.3