From c97d9b4df1f782a86adc5cad15373b6dc4c7ebd6 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sat, 6 Nov 2010 20:23:58 +0100 Subject: [PATCH] bsc: Implement a CC timeout and the IT timeout, prepare the timers --- openbsc/src/bsc/osmo_bsc_sccp.c | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/openbsc/src/bsc/osmo_bsc_sccp.c b/openbsc/src/bsc/osmo_bsc_sccp.c index b1d128b40..f7f30e10d 100644 --- a/openbsc/src/bsc/osmo_bsc_sccp.c +++ b/openbsc/src/bsc/osmo_bsc_sccp.c @@ -32,6 +32,9 @@ #include +/* SCCP helper */ +#define SCCP_IT_TIMER 60 + static LLIST_HEAD(active_connections); static void msc_outgoing_sccp_data(struct sccp_connection *conn, @@ -43,6 +46,34 @@ static void msc_outgoing_sccp_state(struct sccp_connection *conn, int old_state) { } +static void sccp_it_timeout(void *_data) +{ + struct osmo_bsc_sccp_con *data = + (struct osmo_bsc_sccp_con *) _data; + + sccp_connection_send_it(data->sccp); + bsc_schedule_timer(&data->sccp_it_timeout, SCCP_IT_TIMER, 0); +} + +static void sccp_cc_timeout(void *_data) +{ + struct osmo_bsc_sccp_con *data = + (struct osmo_bsc_sccp_con *) _data; + + if (data->sccp->connection_state >= SCCP_CONNECTION_STATE_ESTABLISHED) + return; + + LOGP(DMSC, LOGL_ERROR, "The connection was never established.\n"); + + + if (data->conn) { + gsm0808_clear(data->conn); + subscr_con_free(data->conn); + data->conn = NULL; + } + bsc_delete_connection(data); +} + static void msc_sccp_write_ipa(struct sccp_connection *conn, struct msgb *msg, void *data) { LOGP(DMSC, LOGL_ERROR, "Writing is not implemented.\n"); @@ -124,6 +155,12 @@ int bsc_create_new_connection(struct gsm_subscriber_connection *conn) sccp->data_cb = msc_outgoing_sccp_data; sccp->data_ctx = bsc_con; + /* prepare the timers */ + bsc_con->sccp_it_timeout.cb = sccp_it_timeout; + bsc_con->sccp_it_timeout.data = bsc_con; + bsc_con->sccp_cc_timeout.cb = sccp_cc_timeout; + bsc_con->sccp_cc_timeout.data = bsc_con; + bsc_con->sccp = sccp; bsc_con->msc_con = net->msc_data->msc_con; bsc_con->conn = conn;