From c3455dcb7951069dab99effae71aac2a14961823 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Fri, 19 Aug 2016 17:31:01 +0200 Subject: client: Additional counters for the statistics Add more counters and start counting them when reading from the PCAP library and when trying to write to the socket. Change-Id: I52d3064a265b402ac849d8578a14f718156c0805 --- include/osmo-pcap/osmo_pcap_client.h | 2 ++ src/osmo_client_core.c | 7 +++++-- src/osmo_client_main.c | 2 ++ src/osmo_client_network.c | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/osmo-pcap/osmo_pcap_client.h b/include/osmo-pcap/osmo_pcap_client.h index 3cc3080..90cd5ad 100644 --- a/include/osmo-pcap/osmo_pcap_client.h +++ b/include/osmo-pcap/osmo_pcap_client.h @@ -36,6 +36,8 @@ enum { CLIENT_CTR_2BIG, CLIENT_CTR_NOMEM, CLIENT_CTR_QERR, + CLIENT_CTR_PERR, + CLIENT_CTR_WERR, }; struct osmo_pcap_client { diff --git a/src/osmo_client_core.c b/src/osmo_client_core.c index 653d310..4455c95 100644 --- a/src/osmo_client_core.c +++ b/src/osmo_client_core.c @@ -1,7 +1,7 @@ /* * osmo-pcap-client code * - * (C) 2011 by Holger Hans Peter Freyther + * (C) 2011-2016 by Holger Hans Peter Freyther * (C) 2011 by On-Waves * All Rights Reserved * @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -158,8 +159,10 @@ static int pcap_read_cb(struct osmo_fd *fd, unsigned int what) const u_char *data; data = pcap_next(client->handle, &hdr); - if (!data) + if (!data) { + rate_ctr_inc(&client->ctrg->ctr[CLIENT_CTR_PERR]); return -1; + } if (!forward_packet(client, &hdr, data)) return 0; diff --git a/src/osmo_client_main.c b/src/osmo_client_main.c index 945a871..0b53939 100644 --- a/src/osmo_client_main.c +++ b/src/osmo_client_main.c @@ -60,6 +60,8 @@ static const struct rate_ctr_desc pcap_client_ctr_desc[] = { [CLIENT_CTR_2BIG] = { "bpf.too_big", "Captured data too big " }, [CLIENT_CTR_NOMEM] = { "client.no_mem", "No memory available " }, [CLIENT_CTR_QERR] = { "client.queue_err", "Can not queue data " }, + [CLIENT_CTR_PERR] = { "client.pcap_err", "libpcap error " }, + [CLIENT_CTR_WERR] = { "client.write_err", "Write error " }, }; static const struct rate_ctr_group_desc pcap_client_ctr_group_desc = { diff --git a/src/osmo_client_network.c b/src/osmo_client_network.c index 7812ff6..2400f3a 100644 --- a/src/osmo_client_network.c +++ b/src/osmo_client_network.c @@ -92,6 +92,7 @@ static int write_cb(struct osmo_fd *fd, struct msgb *msg) if (rc < 0) { struct osmo_pcap_client *client = fd->data; LOGP(DCLIENT, LOGL_ERROR, "Lost connection on write.\n"); + rate_ctr_inc(&client->ctrg->ctr[CLIENT_CTR_WERR]); lost_connection(client); return -1; } -- cgit v1.2.3