Example #1
0
struct mwlstatfoo *
mwlstats_new(const char *ifname, const char *fmtstring)
{
#define	N(a)	(sizeof(a) / sizeof(a[0]))
	struct mwlstatfoo_p *wf;

	wf = calloc(1, sizeof(struct mwlstatfoo_p));
	if (wf != NULL) {
		statfoo_init(&wf->base.base, "mwlstats", mwlstats, N(mwlstats));
		/* override base methods */
		wf->base.base.collect_cur = mwl_collect_cur;
		wf->base.base.collect_tot = mwl_collect_tot;
		wf->base.base.get_curstat = mwl_get_curstat;
		wf->base.base.get_totstat = mwl_get_totstat;
		wf->base.base.update_tot = mwl_update_tot;
		wf->base.base.print_verbose = mwl_print_verbose;

		/* setup bounce functions for public methods */
		STATFOO_BOUNCE(wf, mwlstatfoo);

		/* setup our public methods */
		wf->base.setifname = mwl_setifname;
#if 0
		wf->base.setstamac = wlan_setstamac;
#endif
		wf->s = socket(AF_INET, SOCK_DGRAM, 0);
		if (wf->s < 0)
			err(1, "socket");

		mwl_setifname(&wf->base, ifname);
		wf->base.setfmt(&wf->base, fmtstring);
	}
	return &wf->base;
#undef N
}
Example #2
0
struct npestatfoo *
npestats_new(const char *ifname, const char *fmtstring)
{
#define	N(a)	(sizeof(a) / sizeof(a[0]))
	struct npestatfoo_p *wf;

	wf = calloc(1, sizeof(struct npestatfoo_p));
	if (wf != NULL) {
		statfoo_init(&wf->base.base, "npestats", npestats, N(npestats));
		/* override base methods */
		wf->base.base.collect_cur = npe_collect_cur;
		wf->base.base.collect_tot = npe_collect_tot;
		wf->base.base.get_curstat = npe_get_curstat;
		wf->base.base.get_totstat = npe_get_totstat;
		wf->base.base.update_tot = npe_update_tot;

		/* setup bounce functions for public methods */
		STATFOO_BOUNCE(wf, npestatfoo);

		/* setup our public methods */
		wf->base.setifname = npe_setifname;

		npe_setifname(&wf->base, ifname);
		wf->base.setfmt(&wf->base, fmtstring);
	}
	return &wf->base;
#undef N
}
Example #3
0
struct wlanstatfoo *
wlanstats_new(const char *ifname, const char *fmtstring)
{
#define	N(a)	(sizeof(a) / sizeof(a[0]))
	struct wlanstatfoo_p *wf;

	wf = calloc(1, sizeof(struct wlanstatfoo_p));
	if (wf != NULL) {
		statfoo_init(&wf->base.base, "wlanstats", wlanstats, N(wlanstats));
		/* override base methods */
		wf->base.base.collect_cur = wlan_collect_cur;
		wf->base.base.collect_tot = wlan_collect_tot;
		wf->base.base.get_curstat = wlan_get_curstat;
		wf->base.base.get_totstat = wlan_get_totstat;
		wf->base.base.update_tot = wlan_update_tot;

		/* setup bounce functions for public methods */
		STATFOO_BOUNCE(wf, wlanstatfoo);

		/* setup our public methods */
		wf->base.setifname = wlan_setifname;
		wf->base.getifname = wlan_getifname;
		wf->base.getopmode = wlan_getopmode;
		wf->base.setstamac = wlan_setstamac;
		wf->opmode = -1;

		wf->s = socket(AF_INET, SOCK_DGRAM, 0);
		if (wf->s < 0)
			err(1, "socket");

		wlan_setifname(&wf->base, ifname);
		wf->base.setfmt(&wf->base, fmtstring);
	}
	return &wf->base;
#undef N
}