aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/nat/bsc_nat.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-09-29 01:19:42 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-10-21 12:22:50 +0200
commit749497eeb3cae13fa2252abcf93468ecd415f063 (patch)
tree02d6719db109aaf697e28f74a0c2d4ee3b40606d /openbsc/src/nat/bsc_nat.c
parent8c78b480f9d1dbb0461f9294891687d43080abf5 (diff)
nat: Copy the IMSI, then free it or move the context to the connection
Extract the IMSI from the first message as well and safe it in the connection structure. The problem is that we do not have this structure at this point, so we will allocate the imsi as child of the bsc_connection and then move/steal it.
Diffstat (limited to 'openbsc/src/nat/bsc_nat.c')
-rw-r--r--openbsc/src/nat/bsc_nat.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c
index b8a6cfc7b..b82c4ef25 100644
--- a/openbsc/src/nat/bsc_nat.c
+++ b/openbsc/src/nat/bsc_nat.c
@@ -784,6 +784,7 @@ static void handle_con_stats(struct sccp_connections *con)
static int forward_sccp_to_msc(struct bsc_connection *bsc, struct msgb *msg)
{
int con_filter = 0;
+ char *imsi = NULL;
struct bsc_msc_connection *con_msc = NULL;
struct bsc_connection *con_bsc = NULL;
int con_type;
@@ -818,7 +819,7 @@ static int forward_sccp_to_msc(struct bsc_connection *bsc, struct msgb *msg)
struct sccp_connections *con;
switch (parsed->sccp_type) {
case SCCP_MSG_TYPE_CR:
- filter = bsc_nat_filter_sccp_cr(bsc, msg, parsed, &con_type);
+ filter = bsc_nat_filter_sccp_cr(bsc, msg, parsed, &con_type, &imsi);
if (filter < 0) {
bsc_stat_reject(filter, bsc, 0);
goto exit3;
@@ -831,6 +832,9 @@ static int forward_sccp_to_msc(struct bsc_connection *bsc, struct msgb *msg)
con_msc = con->msc_con;
con->con_type = con_type;
con->imsi_checked = filter;
+ if (imsi)
+ con->imsi = talloc_steal(con, imsi);
+ imsi = NULL;
con_bsc = con->bsc;
handle_con_stats(con);
break;
@@ -927,12 +931,16 @@ exit:
}
exit2:
+ if (imsi)
+ talloc_free(imsi);
talloc_free(parsed);
msgb_free(msg);
return -1;
exit3:
/* send a SCCP Connection Refused */
+ if (imsi)
+ talloc_free(imsi);
bsc_send_con_refuse(bsc, parsed, con_type);
talloc_free(parsed);
msgb_free(msg);