summaryrefslogtreecommitdiffstats
path: root/openbsc/src/libmsc/gsm_04_08.c
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2016-08-23 07:32:27 +0200
committerAlexander Couzens <lynxis@fe80.eu>2016-10-04 01:08:12 +0200
commit92f552f344541977d952596bd3d2eaaef4435809 (patch)
tree9f907109afbeca0f6b36b1fbb6682dfd24f2b711 /openbsc/src/libmsc/gsm_04_08.c
parent38e9ea3f7f385c6660c5958970af5c71adc1682b (diff)
msc: add counters to track call attempts/active/success/failed
active_calls describe all calls in active state. call.complete Call got terminated by disconnect requested either by MS or MSC. call.incomplete Call got terminated by any other reason. call.active Calls reached active state. Change-Id: I49b93af2e6a0ba16c2fb00b7b83974e8a6a16df3
Diffstat (limited to 'openbsc/src/libmsc/gsm_04_08.c')
-rw-r--r--openbsc/src/libmsc/gsm_04_08.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c
index aa3d78a9b..be1b26045 100644
--- a/openbsc/src/libmsc/gsm_04_08.c
+++ b/openbsc/src/libmsc/gsm_04_08.c
@@ -1299,6 +1299,39 @@ int gsm48_send_rr_app_info(struct gsm_subscriber_connection *conn, uint8_t apdu_
return gsm48_conn_sendmsg(msg, conn, NULL);
}
+/* FIXME: this count_statistics is a state machine behaviour. we should convert
+ * the complete call control into a state machine. Afterwards we can move this
+ * code into state transitions.
+ */
+static void count_statistics(struct gsm_trans *trans, int new_state)
+{
+ int old_state = trans->cc.state;
+ struct rate_ctr_group *msc = trans->net->msc_ctrs;
+
+ if (old_state == new_state)
+ return;
+
+ /* state incoming */
+ switch (new_state) {
+ case GSM_CSTATE_ACTIVE:
+ osmo_counter_inc(trans->net->active_calls);
+ rate_ctr_inc(&msc->ctr[MSC_CTR_CALL_ACTIVE]);
+ break;
+ }
+
+ /* state outgoing */
+ switch (old_state) {
+ case GSM_CSTATE_ACTIVE:
+ osmo_counter_dec(trans->net->active_calls);
+ if (new_state == GSM_CSTATE_DISCONNECT_REQ ||
+ new_state == GSM_CSTATE_DISCONNECT_IND)
+ rate_ctr_inc(&msc->ctr[MSC_CTR_CALL_COMPLETE]);
+ else
+ rate_ctr_inc(&msc->ctr[MSC_CTR_CALL_INCOMPLETE]);
+ break;
+ }
+}
+
/* Call Control */
/* The entire call control code is written in accordance with Figure 7.10c
@@ -1315,6 +1348,7 @@ static void new_cc_state(struct gsm_trans *trans, int state)
gsm48_cc_state_name(trans->cc.state),
gsm48_cc_state_name(state));
+ count_statistics(trans, state);
trans->cc.state = state;
}