svn commit: r298376 - head/sys/net80211

Andriy Voskoboinyk avos at FreeBSD.org
Wed Apr 20 21:15:57 UTC 2016


Author: avos
Date: Wed Apr 20 21:15:55 2016
New Revision: 298376
URL: https://svnweb.freebsd.org/changeset/base/298376

Log:
  net80211: hide subtype mask & shift in function call.
  
  Hide subtype mask/shift (which is used for index calculation
  in ieee80211_mgt_subtype_name[] array) in function call.
  
  Tested with RTL8188CUS, STA mode.
  
  Reviewed by:	adrian
  Differential Revision:	https://reviews.freebsd.org/D5369

Modified:
  head/sys/net80211/ieee80211_adhoc.c
  head/sys/net80211/ieee80211_hostap.c
  head/sys/net80211/ieee80211_input.c
  head/sys/net80211/ieee80211_input.h
  head/sys/net80211/ieee80211_mesh.c
  head/sys/net80211/ieee80211_output.c
  head/sys/net80211/ieee80211_proto.c
  head/sys/net80211/ieee80211_proto.h
  head/sys/net80211/ieee80211_scan.c
  head/sys/net80211/ieee80211_sta.c
  head/sys/net80211/ieee80211_tdma.c
  head/sys/net80211/ieee80211_wds.c

Modified: head/sys/net80211/ieee80211_adhoc.c
==============================================================================
--- head/sys/net80211/ieee80211_adhoc.c	Wed Apr 20 21:13:24 2016	(r298375)
+++ head/sys/net80211/ieee80211_adhoc.c	Wed Apr 20 21:15:55 2016	(r298376)
@@ -613,8 +613,7 @@ adhoc_input(struct ieee80211_node *ni, s
 		if ((ieee80211_msg_debug(vap) && doprint(vap, subtype)) ||
 		    ieee80211_msg_dumppkts(vap)) {
 			if_printf(ifp, "received %s from %s rssi %d\n",
-			    ieee80211_mgt_subtype_name[subtype >>
-				IEEE80211_FC0_SUBTYPE_SHIFT],
+			    ieee80211_mgt_subtype_name(subtype),
 			    ether_sprintf(wh->i_addr2), rssi);
 		}
 #endif

Modified: head/sys/net80211/ieee80211_hostap.c
==============================================================================
--- head/sys/net80211/ieee80211_hostap.c	Wed Apr 20 21:13:24 2016	(r298375)
+++ head/sys/net80211/ieee80211_hostap.c	Wed Apr 20 21:15:55 2016	(r298376)
@@ -831,8 +831,7 @@ hostap_input(struct ieee80211_node *ni, 
 		if ((ieee80211_msg_debug(vap) && doprint(vap, subtype)) ||
 		    ieee80211_msg_dumppkts(vap)) {
 			if_printf(ifp, "received %s from %s rssi %d\n",
-			    ieee80211_mgt_subtype_name[subtype >>
-				IEEE80211_FC0_SUBTYPE_SHIFT],
+			    ieee80211_mgt_subtype_name(subtype),
 			    ether_sprintf(wh->i_addr2), rssi);
 		}
 #endif
@@ -2184,8 +2183,7 @@ hostap_recv_mgmt(struct ieee80211_node *
 		}
 		IEEE80211_NOTE(vap, IEEE80211_MSG_AUTH, ni,
 		    "recv %s (reason: %d (%s))",
-		    ieee80211_mgt_subtype_name[subtype >>
-		        IEEE80211_FC0_SUBTYPE_SHIFT],
+		    ieee80211_mgt_subtype_name(subtype),
 		    reason, ieee80211_reason_to_string(reason));
 		if (ni != vap->iv_bss)
 			ieee80211_node_leave(ni);

Modified: head/sys/net80211/ieee80211_input.c
==============================================================================
--- head/sys/net80211/ieee80211_input.c	Wed Apr 20 21:13:24 2016	(r298375)
+++ head/sys/net80211/ieee80211_input.c	Wed Apr 20 21:15:55 2016	(r298376)
@@ -930,12 +930,8 @@ ieee80211_discard_frame(const struct iee
 
 	if_printf(vap->iv_ifp, "[%s] discard ",
 		ether_sprintf(ieee80211_getbssid(vap, wh)));
-	if (type == NULL) {
-		printf("%s frame, ", ieee80211_mgt_subtype_name[
-			(wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) >>
-			IEEE80211_FC0_SUBTYPE_SHIFT]);
-	} else
-		printf("%s frame, ", type);
+	printf("%s frame, ", type != NULL ? type :
+	    ieee80211_mgt_subtype_name(wh->i_fc[0]));
 	va_start(ap, fmt);
 	vprintf(fmt, ap);
 	va_end(ap);

Modified: head/sys/net80211/ieee80211_input.h
==============================================================================
--- head/sys/net80211/ieee80211_input.h	Wed Apr 20 21:13:24 2016	(r298375)
+++ head/sys/net80211/ieee80211_input.h	Wed Apr 20 21:15:55 2016	(r298376)
@@ -62,8 +62,7 @@ void	ieee80211_ssid_mismatch(struct ieee
 	    memcmp((_ssid) + 2, (_ni)->ni_essid, (_ssid)[1]) != 0)) {	\
 		if (ieee80211_msg_input(vap))				\
 			ieee80211_ssid_mismatch(vap, 			\
-			    ieee80211_mgt_subtype_name[subtype >>	\
-				IEEE80211_FC0_SUBTYPE_SHIFT],		\
+			    ieee80211_mgt_subtype_name(subtype),	\
 				wh->i_addr2, _ssid);			\
 		vap->iv_stats.is_rx_ssidmismatch++;			\
 		_action;						\

Modified: head/sys/net80211/ieee80211_mesh.c
==============================================================================
--- head/sys/net80211/ieee80211_mesh.c	Wed Apr 20 21:13:24 2016	(r298375)
+++ head/sys/net80211/ieee80211_mesh.c	Wed Apr 20 21:15:55 2016	(r298376)
@@ -1793,8 +1793,7 @@ mesh_input(struct ieee80211_node *ni, st
 		    (vap->iv_ic->ic_flags & IEEE80211_F_SCAN)) ||
 		    ieee80211_msg_dumppkts(vap)) {
 			if_printf(ifp, "received %s from %s rssi %d\n",
-			    ieee80211_mgt_subtype_name[subtype >>
-			    IEEE80211_FC0_SUBTYPE_SHIFT],
+			    ieee80211_mgt_subtype_name(subtype),
 			    ether_sprintf(wh->i_addr2), rssi);
 		}
 #endif

Modified: head/sys/net80211/ieee80211_output.c
==============================================================================
--- head/sys/net80211/ieee80211_output.c	Wed Apr 20 21:13:24 2016	(r298375)
+++ head/sys/net80211/ieee80211_output.c	Wed Apr 20 21:15:55 2016	(r298376)
@@ -804,9 +804,7 @@ ieee80211_mgmt_output(struct ieee80211_n
 	if (vap->iv_state == IEEE80211_S_CAC) {
 		IEEE80211_NOTE(vap, IEEE80211_MSG_OUTPUT | IEEE80211_MSG_DOTH,
 		    ni, "block %s frame in CAC state",
-			ieee80211_mgt_subtype_name[
-			    (type & IEEE80211_FC0_SUBTYPE_MASK) >>
-				IEEE80211_FC0_SUBTYPE_SHIFT]);
+			ieee80211_mgt_subtype_name(type));
 		vap->iv_stats.is_tx_badstate++;
 		ieee80211_free_node(ni);
 		m_freem(m);
@@ -841,9 +839,7 @@ ieee80211_mgmt_output(struct ieee80211_n
 	    ieee80211_msg_dumppkts(vap)) {
 		printf("[%s] send %s on channel %u\n",
 		    ether_sprintf(wh->i_addr1),
-		    ieee80211_mgt_subtype_name[
-			(type & IEEE80211_FC0_SUBTYPE_MASK) >>
-				IEEE80211_FC0_SUBTYPE_SHIFT],
+		    ieee80211_mgt_subtype_name(type),
 		    ieee80211_chan2ieee(ic, ic->ic_curchan));
 	}
 #endif

Modified: head/sys/net80211/ieee80211_proto.c
==============================================================================
--- head/sys/net80211/ieee80211_proto.c	Wed Apr 20 21:13:24 2016	(r298375)
+++ head/sys/net80211/ieee80211_proto.c	Wed Apr 20 21:15:55 2016	(r298376)
@@ -63,13 +63,13 @@ __FBSDID("$FreeBSD$");
 #define	AGGRESSIVE_MODE_SWITCH_HYSTERESIS	3	/* pkts / 100ms */
 #define	HIGH_PRI_SWITCH_THRESH			10	/* pkts / 100ms */
 
-const char *ieee80211_mgt_subtype_name[] = {
+const char *mgt_subtype_name[] = {
 	"assoc_req",	"assoc_resp",	"reassoc_req",	"reassoc_resp",
 	"probe_req",	"probe_resp",	"timing_adv",	"reserved#7",
 	"beacon",	"atim",		"disassoc",	"auth",
 	"deauth",	"action",	"action_noack",	"reserved#15"
 };
-const char *ieee80211_ctl_subtype_name[] = {
+const char *ctl_subtype_name[] = {
 	"reserved#0",	"reserved#1",	"reserved#2",	"reserved#3",
 	"reserved#4",	"reserved#5",	"reserved#6",	"control_wrap",
 	"bar",		"ba",		"ps_poll",	"rts",
@@ -574,9 +574,7 @@ ieee80211_dump_pkt(struct ieee80211com *
 		printf(" data");
 		break;
 	case IEEE80211_FC0_TYPE_MGT:
-		printf(" %s", ieee80211_mgt_subtype_name[
-		    (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK)
-		    >> IEEE80211_FC0_SUBTYPE_SHIFT]);
+		printf(" %s", ieee80211_mgt_subtype_name(wh->i_fc[0]));
 		break;
 	default:
 		printf(" type#%d", wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK);

Modified: head/sys/net80211/ieee80211_proto.h
==============================================================================
--- head/sys/net80211/ieee80211_proto.h	Wed Apr 20 21:13:24 2016	(r298375)
+++ head/sys/net80211/ieee80211_proto.h	Wed Apr 20 21:15:55 2016	(r298376)
@@ -47,10 +47,25 @@ enum ieee80211_state {
 #define	IEEE80211_SEND_MGMT(_ni,_type,_arg) \
 	((*(_ni)->ni_ic->ic_send_mgmt)(_ni, _type, _arg))
 
-extern	const char *ieee80211_mgt_subtype_name[];
+extern	const char *mgt_subtype_name[];
+extern	const char *ctl_subtype_name[];
 extern	const char *ieee80211_phymode_name[IEEE80211_MODE_MAX];
 extern	const int ieee80211_opcap[IEEE80211_OPMODE_MAX];
 
+static __inline const char *
+ieee80211_mgt_subtype_name(uint8_t subtype)
+{
+	return mgt_subtype_name[(subtype & IEEE80211_FC0_SUBTYPE_MASK) >>
+		   IEEE80211_FC0_SUBTYPE_SHIFT];
+}
+
+static __inline const char *
+ieee80211_ctl_subtype_name(uint8_t subtype)
+{
+	return ctl_subtype_name[(subtype & IEEE80211_FC0_SUBTYPE_MASK) >>
+		   IEEE80211_FC0_SUBTYPE_SHIFT];
+}
+
 const char *ieee80211_reason_to_string(uint16_t);
 
 void	ieee80211_proto_attach(struct ieee80211com *);

Modified: head/sys/net80211/ieee80211_scan.c
==============================================================================
--- head/sys/net80211/ieee80211_scan.c	Wed Apr 20 21:13:24 2016	(r298375)
+++ head/sys/net80211/ieee80211_scan.c	Wed Apr 20 21:15:55 2016	(r298376)
@@ -539,8 +539,7 @@ ieee80211_scan_dump_probe_beacon(uint8_t
 
 	printf("[%s] %s%s on chan %u (bss chan %u) ",
 	    ether_sprintf(mac), isnew ? "new " : "",
-	    ieee80211_mgt_subtype_name[subtype >> IEEE80211_FC0_SUBTYPE_SHIFT],
-	    sp->chan, sp->bchan);
+	    ieee80211_mgt_subtype_name(subtype), sp->chan, sp->bchan);
 	ieee80211_print_essid(sp->ssid + 2, sp->ssid[1]);
 	printf(" rssi %d\n", rssi);
 

Modified: head/sys/net80211/ieee80211_sta.c
==============================================================================
--- head/sys/net80211/ieee80211_sta.c	Wed Apr 20 21:13:24 2016	(r298375)
+++ head/sys/net80211/ieee80211_sta.c	Wed Apr 20 21:15:55 2016	(r298376)
@@ -880,8 +880,7 @@ sta_input(struct ieee80211_node *ni, str
 		if ((ieee80211_msg_debug(vap) && doprint(vap, subtype)) ||
 		    ieee80211_msg_dumppkts(vap)) {
 			if_printf(ifp, "received %s from %s rssi %d\n",
-			    ieee80211_mgt_subtype_name[subtype >>
-				IEEE80211_FC0_SUBTYPE_SHIFT],
+			    ieee80211_mgt_subtype_name(subtype),
 			    ether_sprintf(wh->i_addr2), rssi);
 		}
 #endif
@@ -892,8 +891,7 @@ sta_input(struct ieee80211_node *ni, str
 				 * should be encrypted, discard all others.
 				 */
 				IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT,
-				    wh, ieee80211_mgt_subtype_name[subtype >>
-					IEEE80211_FC0_SUBTYPE_SHIFT],
+				    wh, ieee80211_mgt_subtype_name(subtype),
 				    "%s", "WEP set but not permitted");
 				vap->iv_stats.is_rx_mgtdiscard++; /* XXX */
 				goto out;

Modified: head/sys/net80211/ieee80211_tdma.c
==============================================================================
--- head/sys/net80211/ieee80211_tdma.c	Wed Apr 20 21:13:24 2016	(r298375)
+++ head/sys/net80211/ieee80211_tdma.c	Wed Apr 20 21:15:55 2016	(r298376)
@@ -343,8 +343,7 @@ tdma_recv_mgmt(struct ieee80211_node *ni
 			 */
 			IEEE80211_DISCARD(vap,
 			    IEEE80211_MSG_ELEMID | IEEE80211_MSG_INPUT,
-			    wh, ieee80211_mgt_subtype_name[subtype >>
-				IEEE80211_FC0_SUBTYPE_SHIFT],
+			    wh, ieee80211_mgt_subtype_name(subtype),
 			    "%s", "no TDMA ie");
 			vap->iv_stats.is_rx_mgtdiscard++;
 			return;

Modified: head/sys/net80211/ieee80211_wds.c
==============================================================================
--- head/sys/net80211/ieee80211_wds.c	Wed Apr 20 21:13:24 2016	(r298375)
+++ head/sys/net80211/ieee80211_wds.c	Wed Apr 20 21:15:55 2016	(r298376)
@@ -693,8 +693,7 @@ wds_input(struct ieee80211_node *ni, str
 #ifdef IEEE80211_DEBUG
 		if (ieee80211_msg_debug(vap) || ieee80211_msg_dumppkts(vap)) {
 			if_printf(ifp, "received %s from %s rssi %d\n",
-			    ieee80211_mgt_subtype_name[subtype >>
-				IEEE80211_FC0_SUBTYPE_SHIFT],
+			    ieee80211_mgt_subtype_name(subtype),
 			    ether_sprintf(wh->i_addr2), rssi);
 		}
 #endif


More information about the svn-src-all mailing list