From 1b5b3bbfdb349104450bc16611509d4f50892901 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Wed, 7 Apr 2010 10:46:30 +0200 Subject: 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. --- openbsc/src/nat/bsc_nat.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'openbsc/src') 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); -- cgit v1.2.3