aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-04-07 10:46:30 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-04-07 10:46:30 +0200
commit1b5b3bbfdb349104450bc16611509d4f50892901 (patch)
tree846c76de080b0edf466ff64fb895b4985e342156 /openbsc
parent3a67035411f295e193adcef45c1503c1eb99aaf5 (diff)
nat: Send a GSM0808 message to the MSC when we are reconnecting
The rest of the code should filter the reset ack msg. This should make the MSC give up all resources it had allocated for us.
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/src/nat/bsc_nat.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c
index 631d89994..5535eb52c 100644
--- a/openbsc/src/nat/bsc_nat.c
+++ b/openbsc/src/nat/bsc_nat.c
@@ -307,6 +307,33 @@ static void msc_connection_was_lost(struct bsc_msc_connection *con)
bsc_msc_schedule_connect(con);
}
+static void msc_connected(struct bsc_msc_connection *con)
+{
+ static const u_int8_t reset[] = {
+ 0x09, 0x00, 0x03, 0x05, 0x07, 0x02, 0x42, 0xfe,
+ 0x02, 0x42, 0xfe, 0x06, 0x00, 0x04, 0x30, 0x04,
+ 0x01, 0x20
+ };
+
+ struct msgb *msg;
+
+ msg = msgb_alloc_headroom(4096, 128, "08.08 reset");
+ if (!msg) {
+ LOGP(DMSC, LOGL_ERROR, "Failed to allocate reset msg.\n");
+ return;
+ }
+
+ msg->l2h = msgb_put(msg, sizeof(reset));
+ memcpy(msg->l2h, reset, msgb_l2len(msg));
+
+ if (write_queue_enqueue(&con->write_queue, msg) != 0) {
+ LOGP(DMSC, LOGL_ERROR, "Failed to enqueue reset msg.\n");
+ msgb_free(msg);
+ }
+
+ LOGP(DMSC, LOGL_NOTICE, "Scheduled GSM0808 reset msg for the MSC.\n");
+}
+
static int ipaccess_msc_read_cb(struct bsc_fd *bfd)
{
int error;
@@ -782,6 +809,7 @@ int main(int argc, char** argv)
}
msc_con->connection_loss = msc_connection_was_lost;
+ msc_con->connected = msc_connected;
msc_con->write_queue.read_cb = ipaccess_msc_read_cb;
msc_con->write_queue.write_cb = ipaccess_msc_write_cb;;
bsc_msc_connect(msc_con);