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.
This commit is contained in:
Holger Hans Peter Freyther 2010-03-29 15:03:54 +02:00
parent 1df69f3c64
commit ed443e949e
1 changed files with 15 additions and 4 deletions

View File

@ -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");
/* 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;