aboutsummaryrefslogtreecommitdiffstats
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-16 17:01:47 +0200
commit55ef2d362a043082280a5012707ae2d7b5e2cb1b (patch)
tree4011632a3d6dd3db4191d59ebbedfd737d403da0
parent00eeb1b842ca248c02f1c2865c881dcfbc102751 (diff)
nat: Inform the USSD Provider about lost connections
-rw-r--r--openbsc/include/openbsc/bsc_nat.h8
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat.c43
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_ussd.c8
3 files changed, 44 insertions, 15 deletions
diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h
index 574f367a4..40244b9a2 100644
--- a/openbsc/include/openbsc/bsc_nat.h
+++ b/openbsc/include/openbsc/bsc_nat.h
@@ -269,6 +269,14 @@ struct bsc_nat {
struct bsc_nat_statistics stats;
};
+struct bsc_nat_ussd_con {
+ struct write_queue queue;
+ struct bsc_nat *nat;
+ int authorized;
+
+ struct timer_list auth_timeout;
+};
+
/* create and init the structures */
struct bsc_config *bsc_config_alloc(struct bsc_nat *nat, const char *token);
struct bsc_config *bsc_config_num(struct bsc_nat *nat, int num);
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c
index 89eebd23c..4a6e36d91 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 8f0d5721d..0392e9b10 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)