Beispiel #1
0
struct wlanstatfoo *
wlanstats_new(const char *ifname, const char *fmtstring)
{
	struct wlanstatfoo_p *wf;

	wf = calloc(1, sizeof(struct wlanstatfoo_p));
	if (wf != NULL) {
		bsdstat_init(&wf->base.base, "wlanstats", wlanstats,
		    nitems(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 */
		BSDSTAT_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;
}
Beispiel #2
0
struct athstatfoo *
athstats_new(const char *ifname, const char *fmtstring)
{
#define	N(a)	(sizeof(a) / sizeof(a[0]))
	struct athstatfoo_p *wf;

	wf = calloc(1, sizeof(struct athstatfoo_p));
	if (wf != NULL) {
		bsdstat_init(&wf->base.base, "athstats", athstats, N(athstats));
		/* override base methods */
		wf->base.base.collect_cur = ath_collect_cur;
		wf->base.base.collect_tot = ath_collect_tot;
		wf->base.base.get_curstat = ath_get_curstat;
		wf->base.base.get_totstat = ath_get_totstat;
		wf->base.base.update_tot = ath_update_tot;
		wf->base.base.print_verbose = ath_print_verbose;

		/* setup bounce functions for public methods */
		BSDSTAT_BOUNCE(wf, athstatfoo);

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

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