aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-04-21 10:47:25 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-04-21 10:47:25 +0800
commit2a554bfcc45b4def1fb61edc285bd555be53ff55 (patch)
tree47493d5c6fe8f90b1df3308720974f4f56c7dc02 /openbsc
parenta12dea66ca7ebeba020c04d25e87729edbf70069 (diff)
[nat] Cope with a bad BSC reassigning in use SRC REF
Some closed source BSC like to assign the SRC REF from a small static pool and might reuses one we have not yet given up on.
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/src/nat/bsc_sccp.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/openbsc/src/nat/bsc_sccp.c b/openbsc/src/nat/bsc_sccp.c
index 59d0cd574..2edfc5983 100644
--- a/openbsc/src/nat/bsc_sccp.c
+++ b/openbsc/src/nat/bsc_sccp.c
@@ -85,6 +85,28 @@ int create_sccp_src_ref(struct bsc_connection *bsc, struct msgb *msg, struct bsc
{
struct sccp_connections *conn;
+ /* Some commercial BSCs like to reassign there SRC ref */
+ llist_for_each_entry(conn, &bsc->nat->sccp_connections, list_entry) {
+ if (conn->bsc != bsc)
+ continue;
+ if (memcmp(&conn->real_ref, parsed->src_local_ref, sizeof(conn->real_ref)) != 0)
+ continue;
+
+ /* the BSC has reassigned the SRC ref and we failed to keep track */
+ memset(&conn->remote_ref, 0, sizeof(conn->remote_ref));
+ if (assign_src_local_reference(&conn->patched_ref, bsc->nat) != 0) {
+ LOGP(DNAT, LOGL_ERROR, "BSC %d reused src ref: %d and we failed to generate a new id.\n",
+ bsc->cfg->nr, sccp_src_ref_to_int(parsed->src_local_ref));
+ llist_del(&conn->list_entry);
+ talloc_free(conn);
+ return -1;
+ } else {
+ bsc_mgcp_clear(conn);
+ return 0;
+ }
+ }
+
+
conn = talloc_zero(bsc->nat, struct sccp_connections);
if (!conn) {
LOGP(DNAT, LOGL_ERROR, "Memory allocation failure.\n");