From ffb70fb66a0dc25794d8e9db38d84760bc5cb779 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sun, 16 Jan 2011 17:26:40 +0100 Subject: [PATCH] stats: Start handling stats for a mtp_link --- include/bsc_data.h | 2 ++ src/link_udp.c | 4 ++++ src/links.c | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/include/bsc_data.h b/include/bsc_data.h index fa04c3a..992e55b 100644 --- a/include/bsc_data.h +++ b/include/bsc_data.h @@ -37,6 +37,7 @@ struct bsc_data; struct snmp_mtp_session; +struct rate_ctr_group; /** * A link to the underlying MTP2 library or such @@ -62,6 +63,7 @@ struct link_data { int pcap_fd; struct bsc_data *bsc; struct mtp_link_set *the_link; + struct rate_ctr_group *ctrg; int available; diff --git a/src/link_udp.c b/src/link_udp.c index e05bd17..ef75f41 100644 --- a/src/link_udp.c +++ b/src/link_udp.c @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -91,11 +92,13 @@ static int udp_read_cb(struct bsc_fd *fd) if (hdr->data_type == UDP_DATA_RETR_COMPL || hdr->data_type == UDP_DATA_RETR_IMPOS) { LOGP(DINP, LOGL_ERROR, "Link retrieval done. Restarting the link.\n"); + rate_ctr_inc(&link->ctrg->ctr[MTP_LNK_ERROR]); mtp_link_down(link); mtp_link_up(link); goto exit; } else if (hdr->data_type > UDP_DATA_MSU_PRIO_3) { LOGP(DINP, LOGL_ERROR, "Link failure. retrieved message.\n"); + rate_ctr_inc(&link->ctrg->ctr[MTP_LNK_ERROR]); mtp_link_down(link); goto exit; } @@ -113,6 +116,7 @@ static int udp_read_cb(struct bsc_fd *fd) LOGP(DINP, LOGL_DEBUG, "MSU data on: %p data %s.\n", link, hexdump(msg->data, msg->len)); if (link->pcap_fd >= 0) mtp_pcap_write_msu(link->pcap_fd, msg->l2h, msgb_l2len(msg)); + rate_ctr_inc(&link->ctrg->ctr[MTP_LNK_IN]); mtp_link_set_data(link->the_link, msg); exit: diff --git a/src/links.c b/src/links.c index 016542d..4889135 100644 --- a/src/links.c +++ b/src/links.c @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -73,6 +74,7 @@ void mtp_link_set_sccp_down(struct mtp_link_set *link) void mtp_link_submit(struct link_data *link, struct msgb *msg) { + rate_ctr_inc(&link->ctrg->ctr[MTP_LNK_OUT]); link->write(link, msg); } @@ -110,6 +112,8 @@ int link_init(struct bsc_data *bsc) bsc->link_set->bsc = bsc; lnk = talloc_zero(bsc->link_set, struct link_data); + lnk->ctrg = rate_ctr_group_alloc(lnk, + mtp_link_rate_ctr_desc(), 1); lnk->bsc = bsc; lnk->udp.link_index = 1; lnk->pcap_fd = bsc->pcap_fd;