-/* $OpenBSD: ieee80211.c,v 1.40 2013/11/21 16:16:08 mpi Exp $ */
+/* $OpenBSD: ieee80211.c,v 1.41 2014/08/08 15:16:39 jasper Exp $ */
/* $NetBSD: ieee80211.c,v 1.19 2004/06/06 05:45:29 dyoung Exp $ */
/*-
int
ieee80211_setmode(struct ieee80211com *ic, enum ieee80211_phymode mode)
{
-#define N(a) (sizeof(a) / sizeof(a[0]))
struct ifnet *ifp = &ic->ic_if;
static const u_int chanflags[] = {
0, /* IEEE80211_MODE_AUTO */
* Verify at least one channel is present in the available
* channel list before committing to the new mode.
*/
- if (mode >= N(chanflags))
+ if (mode >= nitems(chanflags))
panic("Unexpected mode %u", mode);
modeflags = chanflags[mode];
for (i = 0; i <= IEEE80211_CHAN_MAX; i++) {
ieee80211_reset_erp(ic); /* reset ERP state */
return 0;
-#undef N
}
enum ieee80211_phymode
ieee80211_rate2media(struct ieee80211com *ic, int rate,
enum ieee80211_phymode mode)
{
-#define N(a) (sizeof(a) / sizeof(a[0]))
static const struct {
u_int m; /* rate + mode */
u_int r; /* if_media rate */
mask |= IFM_IEEE80211_11G;
break;
}
- for (i = 0; i < N(rates); i++)
+ for (i = 0; i < nitems(rates); i++)
if (rates[i].m == mask)
return rates[i].r;
return IFM_AUTO;
-#undef N
}
int
ieee80211_media2rate(int mword)
{
-#define N(a) (sizeof(a) / sizeof(a[0]))
int i;
static const struct {
int subtype;
{ IFM_IEEE80211_OFDM54, 108 },
{ IFM_IEEE80211_OFDM72, 144 },
};
- for (i = 0; i < N(ieeerates); i++) {
+ for (i = 0; i < nitems(ieeerates); i++) {
if (ieeerates[i].subtype == IFM_SUBTYPE(mword))
return ieeerates[i].rate;
}
return 0;
-#undef N
}
/*
-/* $OpenBSD: ieee80211_node.c,v 1.81 2014/07/12 18:44:22 tedu Exp $ */
+/* $OpenBSD: ieee80211_node.c,v 1.82 2014/08/08 15:16:39 jasper Exp $ */
/* $NetBSD: ieee80211_node.c,v 1.14 2004/05/09 09:18:47 dyoung Exp $ */
/*-
int
ieee80211_iserp_sta(const struct ieee80211_node *ni)
{
-#define N(a) (sizeof (a) / sizeof (a)[0])
static const u_int8_t rates[] = { 2, 4, 11, 22, 12, 24, 48 };
const struct ieee80211_rateset *rs = &ni->ni_rates;
int i, j;
* A STA supports ERP operation if it includes all the Clause 19
* mandatory rates in its supported rate set.
*/
- for (i = 0; i < N(rates); i++) {
+ for (i = 0; i < nitems(rates); i++) {
for (j = 0; j < rs->rs_nrates; j++) {
if ((rs->rs_rates[j] & IEEE80211_RATE_VAL) == rates[i])
break;
return 0;
}
return 1;
-#undef N
}
/*
-/* $OpenBSD: ieee80211_regdomain.c,v 1.7 2006/11/26 19:46:28 deraadt Exp $ */
+/* $OpenBSD: ieee80211_regdomain.c,v 1.8 2014/08/08 15:16:39 jasper Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@openbsd.org>
const struct ieee80211_countryname key = { CTRY_DEFAULT, name }, *value;
if ((value = bsearch(&key, &ieee80211_r_ctry,
- sizeof(ieee80211_r_ctry) / sizeof(ieee80211_r_ctry[0]),
- sizeof(struct ieee80211_countryname),
+ nitems(ieee80211_r_ctry), sizeof(struct ieee80211_countryname),
ieee80211_regdomain_compare_cn)) != NULL)
return (value->cn_code);
key.rn_name = name;
if ((value = bsearch(&key, &ieee80211_r_names,
- sizeof(ieee80211_r_names) / sizeof(ieee80211_r_names[0]),
- sizeof(struct ieee80211_regdomainname),
+ nitems(ieee80211_r_names), sizeof(struct ieee80211_regdomainname),
ieee80211_regdomain_compare_rn)) != NULL)
return ((u_int32_t)value->rn_domain);
{
int i;
- for (i = 0;
- i < (sizeof(ieee80211_r_ctry) / sizeof(ieee80211_r_ctry[0])); i++)
+ for (i = 0; i < nitems(ieee80211_r_ctry); i++)
if (ieee80211_r_ctry[i].cn_code == code)
return (ieee80211_r_ctry[i].cn_domain);