aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/osmo-bsc_nat
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-04-16 17:01:47 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-04-18 17:32:40 +0200
commit91b9a45be42202738d3435425f97887d320f88a7 (patch)
treebfe1c0a311039b6ec2be1c6a1d61f5e61582700d /openbsc/src/osmo-bsc_nat
parente5d324981d6378306d3e492cc8c04d4cf8f3d589 (diff)
nat: Inform the USSD Provider about lost connections
Diffstat (limited to 'openbsc/src/osmo-bsc_nat')
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat.c43
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_ussd.c8
2 files changed, 36 insertions, 15 deletions
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c
index e395ba516..c9c9b7bfe 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c
@@ -195,15 +195,15 @@ static void send_id_req(struct bsc_connection *bsc)
bsc_send_data(bsc, id_req, sizeof(id_req), IPAC_PROTO_IPACCESS);
}
-static void nat_send_rlsd_msc(struct sccp_connections *conn)
+static struct msgb *nat_create_rlsd(struct sccp_connections *conn)
{
struct sccp_connection_released *rel;
struct msgb *msg;
msg = msgb_alloc_headroom(4096, 128, "rlsd");
if (!msg) {
- LOGP(DNAT, LOGL_ERROR, "Failed to allocate clear command.\n");
- return;
+ LOGP(DNAT, LOGL_ERROR, "Failed to allocate released.\n");
+ return NULL;
}
msg->l2h = msgb_put(msg, sizeof(*rel));
@@ -213,15 +213,39 @@ static void nat_send_rlsd_msc(struct sccp_connections *conn)
rel->destination_local_reference = conn->remote_ref;
rel->source_local_reference = conn->patched_ref;
- ipaccess_prepend_header(msg, IPAC_PROTO_SCCP);
+ return msg;
+}
+
+static void nat_send_rlsd_ussd(struct bsc_nat *nat, struct sccp_connections *conn)
+{
+ struct msgb *msg;
+
+ if (!nat->ussd_con)
+ return;
+
+ msg = nat_create_rlsd(conn);
+ if (!msg)
+ return;
+ bsc_do_write(&nat->ussd_con->queue, msg, IPAC_PROTO_SCCP);
+}
+
+static void nat_send_rlsd_msc(struct sccp_connections *conn)
+{
+ struct msgb *msg;
+
+ msg = nat_create_rlsd(conn);
+ if (!msg)
+ return;
+
+ ipaccess_prepend_header(msg, IPAC_PROTO_SCCP);
queue_for_msc(conn->msc_con, msg);
}
static void nat_send_rlsd_bsc(struct sccp_connections *conn)
{
- struct sccp_connection_released *rel;
struct msgb *msg;
+ struct sccp_connection_released *rel;
msg = msgb_alloc_headroom(4096, 128, "rlsd");
if (!msg) {
@@ -793,8 +817,13 @@ void bsc_close_connection(struct bsc_connection *connection)
if (ctr)
rate_ctr_inc(ctr);
- if (sccp_patch->has_remote_ref && !sccp_patch->con_local)
- nat_send_rlsd_msc(sccp_patch);
+ if (sccp_patch->has_remote_ref) {
+ if (sccp_patch->con_local == NAT_CON_END_MSC)
+ nat_send_rlsd_msc(sccp_patch);
+ else if (sccp_patch->con_local == NAT_CON_END_USSD)
+ nat_send_rlsd_ussd(nat, sccp_patch);
+ }
+
sccp_connection_destroy(sccp_patch);
}
diff --git a/openbsc/src/osmo-bsc_nat/bsc_ussd.c b/openbsc/src/osmo-bsc_nat/bsc_ussd.c
index 48ecad57f..8c8963e47 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_ussd.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_ussd.c
@@ -36,14 +36,6 @@
#include <string.h>
#include <unistd.h>
-struct bsc_nat_ussd_con {
- struct write_queue queue;
- struct bsc_nat *nat;
- int authorized;
-
- struct timer_list auth_timeout;
-};
-
static void ussd_auth_con(struct tlv_parsed *, struct bsc_nat_ussd_con *);
static struct bsc_nat_ussd_con *bsc_nat_ussd_alloc(struct bsc_nat *nat)