npestats.c (262832) | npestats.c (287297) |
---|---|
1/*- 2 * Copyright (c) 2009 Sam Leffler, Errno Consulting 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 27 * THE POSSIBILITY OF SUCH DAMAGES. 28 * | 1/*- 2 * Copyright (c) 2009 Sam Leffler, Errno Consulting 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 27 * THE POSSIBILITY OF SUCH DAMAGES. 28 * |
29 * $FreeBSD: head/tools/tools/npe/npestats/npestats.c 262832 2014-03-06 07:50:54Z adrian $ | 29 * $FreeBSD: head/tools/tools/npe/npestats/npestats.c 287297 2015-08-29 19:47:20Z rodrigc $ |
30 */ 31 32/* 33 * npe statistics class. 34 */ | 30 */ 31 32/* 33 * npe statistics class. 34 */ |
35#include <sys/types.h> | 35#include <sys/param.h> |
36#include <sys/sysctl.h> 37 | 36#include <sys/sysctl.h> 37 |
38#include <err.h> 39#include <signal.h> |
|
38#include <stdio.h> 39#include <stdlib.h> | 40#include <stdio.h> 41#include <stdlib.h> |
40#include <signal.h> | |
41#include <string.h> 42#include <unistd.h> | 42#include <string.h> 43#include <unistd.h> |
43#include <err.h> | |
44 45#include "npestats.h" 46 47#define AFTER(prev) ((prev)+1) 48 49static const struct fmt npestats[] = { 50#define S_ALIGN 0 51 { 7, "align", "align", "alignment errors" }, --- 194 unchanged lines hidden (view full) --- 246#undef STAT 247} 248 249BSDSTAT_DEFINE_BOUNCE(npestatfoo) 250 251struct npestatfoo * 252npestats_new(const char *ifname, const char *fmtstring) 253{ | 44 45#include "npestats.h" 46 47#define AFTER(prev) ((prev)+1) 48 49static const struct fmt npestats[] = { 50#define S_ALIGN 0 51 { 7, "align", "align", "alignment errors" }, --- 194 unchanged lines hidden (view full) --- 246#undef STAT 247} 248 249BSDSTAT_DEFINE_BOUNCE(npestatfoo) 250 251struct npestatfoo * 252npestats_new(const char *ifname, const char *fmtstring) 253{ |
254#define N(a) (sizeof(a) / sizeof(a[0])) | |
255 struct npestatfoo_p *wf; 256 257 wf = calloc(1, sizeof(struct npestatfoo_p)); 258 if (wf != NULL) { | 254 struct npestatfoo_p *wf; 255 256 wf = calloc(1, sizeof(struct npestatfoo_p)); 257 if (wf != NULL) { |
259 bsdstat_init(&wf->base.base, "npestats", npestats, N(npestats)); | 258 bsdstat_init(&wf->base.base, "npestats", npestats, 259 nitems(npestats)); |
260 /* override base methods */ 261 wf->base.base.collect_cur = npe_collect_cur; 262 wf->base.base.collect_tot = npe_collect_tot; 263 wf->base.base.get_curstat = npe_get_curstat; 264 wf->base.base.get_totstat = npe_get_totstat; 265 wf->base.base.update_tot = npe_update_tot; 266 267 /* setup bounce functions for public methods */ 268 BSDSTAT_BOUNCE(wf, npestatfoo); 269 270 /* setup our public methods */ 271 wf->base.setifname = npe_setifname; 272 273 npe_setifname(&wf->base, ifname); 274 wf->base.setfmt(&wf->base, fmtstring); 275 } 276 return &wf->base; | 260 /* override base methods */ 261 wf->base.base.collect_cur = npe_collect_cur; 262 wf->base.base.collect_tot = npe_collect_tot; 263 wf->base.base.get_curstat = npe_get_curstat; 264 wf->base.base.get_totstat = npe_get_totstat; 265 wf->base.base.update_tot = npe_update_tot; 266 267 /* setup bounce functions for public methods */ 268 BSDSTAT_BOUNCE(wf, npestatfoo); 269 270 /* setup our public methods */ 271 wf->base.setifname = npe_setifname; 272 273 npe_setifname(&wf->base, ifname); 274 wf->base.setfmt(&wf->base, fmtstring); 275 } 276 return &wf->base; |
277#undef N | |
278} | 277} |