diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-01-21 20:54:55 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-01-22 16:22:18 +0100 |
commit | c5d897e8474e99f2b42202b8ec323484225796ec (patch) | |
tree | 74655a98d58910ad1958adae39f09bb12d0c626a | |
parent | aafa7c788e25070e7bd25430c1939d5de128df26 (diff) |
stats: Collect statistics on the linkset
Collect incoming, in sccp, in isup, out isup, out sccp packets.
This does not yet work for out in total.
-rw-r--r-- | include/mtp_data.h | 4 | ||||
-rw-r--r-- | src/links.c | 5 | ||||
-rw-r--r-- | src/mtp_layer3.c | 24 |
3 files changed, 28 insertions, 5 deletions
diff --git a/include/mtp_data.h b/include/mtp_data.h index f04c07d..9a076d0 100644 --- a/include/mtp_data.h +++ b/include/mtp_data.h @@ -27,6 +27,7 @@ struct bsc_data; struct mtp_link; struct mtp_level_3_mng *mng; +struct rate_ctr_group; /* MTP Level3 timers */ @@ -61,6 +62,9 @@ struct mtp_link_set { /* special handling */ int pass_all_isup; + /* statistics */ + struct rate_ctr_group *ctrg; + /* custom data */ struct bsc_data *bsc; }; diff --git a/src/links.c b/src/links.c index 4342447..9bd202b 100644 --- a/src/links.c +++ b/src/links.c @@ -72,11 +72,6 @@ void mtp_link_up(struct mtp_link *link) mtp_link_start_link_test(link); } -void mtp_link_set_submit(struct mtp_link *link, struct msgb *msg) -{ - link->write(link, msg); -} - void mtp_link_restart(struct mtp_link *link) { LOGP(DINP, LOGL_ERROR, "Need to restart the SS7 link.\n"); diff --git a/src/mtp_layer3.c b/src/mtp_layer3.c index 67ae70e..6dee90f 100644 --- a/src/mtp_layer3.c +++ b/src/mtp_layer3.c @@ -23,6 +23,7 @@ #include <bsc_data.h> #include <cellmgr_debug.h> #include <isup_types.h> +#include <counter.h> #include <osmocore/talloc.h> @@ -36,6 +37,13 @@ static void *tall_mtp_ctx = NULL; static int mtp_int_submit(struct mtp_link_set *link, int pc, int sls, int type, const uint8_t *data, unsigned int length); +void mtp_link_set_submit(struct mtp_link *link, struct msgb *msg) +{ + rate_ctr_inc(&link->set->ctrg->ctr[MTP_LSET_TOTA_OUT_MSG]); + link->write(link, msg); +} + + struct msgb *mtp_msg_alloc(struct mtp_link_set *link) { struct mtp_level_3_hdr *hdr; @@ -182,12 +190,22 @@ void mtp_link_set_init(void) struct mtp_link_set *mtp_link_set_alloc(void) { + static int linkset_no = 0; struct mtp_link_set *link; link = talloc_zero(tall_mtp_ctx, struct mtp_link_set); if (!link) return NULL; + link->ctrg = rate_ctr_group_alloc(link, + mtp_link_set_rate_ctr_desc(), + linkset_no++); + if (!link->ctrg) { + LOGP(DINP, LOGL_ERROR, "Failed to allocate counter.\n"); + return NULL; + } + + link->ni = MTP_NI_NATION_NET; INIT_LLIST_HEAD(&link->links); @@ -429,6 +447,7 @@ static int mtp_link_sccp_data(struct mtp_link_set *link, struct mtp_level_3_hdr return 0; } + rate_ctr_inc(&link->ctrg->ctr[MTP_LSET_SCCP_IN_MSG]); mtp_link_set_forward_sccp(link, msg, MTP_LINK_SLS(hdr->addr)); return 0; } @@ -450,6 +469,8 @@ int mtp_link_set_data(struct mtp_link *link, struct msgb *msg) hdr = (struct mtp_level_3_hdr *) msg->l2h; l3_len = msgb_l2len(msg) - sizeof(*hdr); + rate_ctr_inc(&link->set->ctrg->ctr[MTP_LSET_TOTA_IN_MSG]); + switch (hdr->ser_ind) { case MTP_SI_MNT_SNM_MSG: rc = mtp_link_sign_msg(link->set, hdr, l3_len); @@ -462,6 +483,7 @@ int mtp_link_set_data(struct mtp_link *link, struct msgb *msg) break; case MTP_SI_MNT_ISUP: msg->l3h = &hdr->data[0]; + rate_ctr_inc(&link->set->ctrg->ctr[MTP_LSET_IUSP_IN_MSG]); rc = mtp_link_set_isup(link->set, msg, MTP_LINK_SLS(hdr->addr)); break; default: @@ -485,12 +507,14 @@ int mtp_link_set_submit_sccp_data(struct mtp_link_set *link, int sls, const uint link->last_sls = (link->last_sls + 1) % 16; } + rate_ctr_inc(&link->ctrg->ctr[MTP_LSET_SCCP_OUT_MSG]); return mtp_int_submit(link, link->sccp_opc, sls, MTP_SI_MNT_SCCP, data, length); } int mtp_link_set_submit_isup_data(struct mtp_link_set *link, int sls, const uint8_t *data, unsigned int length) { + rate_ctr_inc(&link->ctrg->ctr[MTP_LSET_ISUP_OUT_MSG]); return mtp_int_submit(link, link->isup_opc, sls, MTP_SI_MNT_ISUP, data, length); } |