aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/osmo-bsc/osmo_bsc_msc.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-09-02 17:28:40 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-09-05 12:25:32 +0200
commit56cb7299071c8472a240a293036be3074f3eb4e0 (patch)
tree062373e9fa982a75bd088584360e65806baac230 /openbsc/src/osmo-bsc/osmo_bsc_msc.c
parent0169971a59e9822c094e82f3e4a28f2763ea0f34 (diff)
bsc: Add a "IPA PING" to the SCCP CR messages
We want to reduce the background traffic and might set the ping interval to be in the range of minutes. But this means that if the TCP connection is frozen several "SCCP CR CM Service Requests" will be stuck in the send queue without ever being answered. I could have used the logic of not receiving the "SCCP CC" to close the connection but instead I am introducing an overload to schedule the ping as part of the normal SCCP connection establishment. The VTY write case has been manually verified, I have also looked at a single trace to see that the SCCP CR and the IPA PING is transfered in the same ethernet frame.
Diffstat (limited to 'openbsc/src/osmo-bsc/osmo_bsc_msc.c')
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_msc.c44
1 files changed, 36 insertions, 8 deletions
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_msc.c b/openbsc/src/osmo-bsc/osmo_bsc_msc.c
index aebe84741..5f2c1c52f 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_msc.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_msc.c
@@ -1,8 +1,8 @@
/*
* Handle the connection to the MSC. This include ping/timeout/reconnect
* (C) 2008-2009 by Harald Welte <laforge@gnumonks.org>
- * (C) 2009-2011 by Holger Hans Peter Freyther <zecke@selfish.org>
- * (C) 2009-2011 by On-Waves
+ * (C) 2009-2014 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2009-2014 by On-Waves
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
@@ -46,6 +46,7 @@ static void initialize_if_needed(struct bsc_msc_connection *conn);
static void send_lacs(struct gsm_network *net, struct bsc_msc_connection *conn);
static void send_id_get_response(struct osmo_msc_data *data, int fd);
static void send_ping(struct osmo_msc_data *data);
+static void schedule_ping_pong(struct osmo_msc_data *data);
/*
* MGCP forwarding code
@@ -181,6 +182,29 @@ int msc_queue_write(struct bsc_msc_connection *conn, struct msgb *msg, int proto
return 0;
}
+int msc_queue_write_with_ping(struct bsc_msc_connection *conn,
+ struct msgb *msg, int proto)
+{
+ struct osmo_msc_data *data;
+ uint8_t val;
+
+ /* prepend the header */
+ ipa_prepend_header(msg, proto);
+ if (osmo_wqueue_enqueue(&conn->write_queue, msg) != 0) {
+ LOGP(DMSC, LOGL_FATAL, "Failed to queue IPA/%d\n", proto);
+ msgb_free(msg);
+ return -1;
+ }
+
+ /* add the ping as the other message */
+ val = IPAC_MSGT_PING;
+ msgb_l16tv_put(msg, 1, IPAC_PROTO_IPACCESS, &val);
+
+ data = (struct osmo_msc_data *) conn->write_queue.bfd.data;
+ schedule_ping_pong(data);
+ return 0;
+}
+
static int msc_alink_do_write(struct osmo_fd *fd, struct msgb *msg)
{
int ret;
@@ -310,6 +334,15 @@ static void send_ping(struct osmo_msc_data *data)
msc_queue_write(data->msc_con, msg, IPAC_PROTO_IPACCESS);
}
+static void schedule_ping_pong(struct osmo_msc_data *data)
+{
+ /* send another ping in 20 seconds */
+ osmo_timer_schedule(&data->ping_timer, data->ping_timeout, 0);
+
+ /* also start a pong timer */
+ osmo_timer_schedule(&data->pong_timer, data->pong_timeout, 0);
+}
+
static void msc_ping_timeout_cb(void *_data)
{
struct osmo_msc_data *data = (struct osmo_msc_data *) _data;
@@ -317,12 +350,7 @@ static void msc_ping_timeout_cb(void *_data)
return;
send_ping(data);
-
- /* send another ping in 20 seconds */
- osmo_timer_schedule(&data->ping_timer, data->ping_timeout, 0);
-
- /* also start a pong timer */
- osmo_timer_schedule(&data->pong_timer, data->pong_timeout, 0);
+ schedule_ping_pong(data);
}
static void msc_pong_timeout_cb(void *_data)