[PATCH 14/24] P2P: deduce if a device is indoor based on the device category

Ilan Peer ilan.peer
Mon May 19 00:06:11 PDT 2014


Use the WPS category ID in the P2P Device IE to determine if the
peer device is an indoor device, e.g., media center, server etc.

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 src/p2p/p2p.h       |    9 +++++++
 src/p2p/p2p_utils.c |   67 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+)

diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h
index bd125f3..832b083 100644
--- a/src/p2p/p2p.h
+++ b/src/p2p/p2p.h
@@ -1973,4 +1973,13 @@ void p2p_set_authorized_oob_dev_pw_id(struct p2p_data *p2p, u16 dev_pw_id,
 				      int go_intent,
 				      const u8 *own_interface_addr);
 
+/**
+ * p2p_is_indoor_device - Deduce if the peer device is an indoor device or not
+ * based on the WPS primary and secondary device types.
+ *
+ * @peer: pointer to the peer device
+ * Returns 1 if indoor device, 0 if not.
+ */
+unsigned int p2p_is_indoor_device(struct p2p_peer_info *peer);
+
 #endif /* P2P_H */
diff --git a/src/p2p/p2p_utils.c b/src/p2p/p2p_utils.c
index 8cbbc95..f8981c0 100644
--- a/src/p2p/p2p_utils.c
+++ b/src/p2p/p2p_utils.c
@@ -10,6 +10,7 @@
 
 #include "common.h"
 #include "p2p_i.h"
+#include "wps/wps_defs.h"
 #include "common/defs.h"
 #include "common/ieee802_11_common.h"
 
@@ -457,3 +458,69 @@ int p2p_channels_to_freqs(const struct p2p_channels *channels,
 	}
 	return idx;
 }
+
+
+unsigned int p2p_is_indoor_device(struct p2p_peer_info *peer)
+{
+	int cat, sub;
+	if (!peer)
+		return 0;
+
+	cat = WPA_GET_BE16(peer->pri_dev_type);
+	sub = WPA_GET_BE16(&peer->pri_dev_type[6]);
+
+	switch (cat) {
+	case WPS_DEV_COMPUTER:
+		switch (sub) {
+		case WPS_DEV_COMPUTER_SERVER:
+		case WPS_DEV_COMPUTER_MEDIA_CENTER:
+		case WPS_DEV_COMPUTER_DESKTOP:
+			return 1;
+		case WPS_DEV_COMPUTER_PC:
+		case WPS_DEV_COMPUTER_ULTRA_MOBILE:
+		case WPS_DEV_COMPUTER_NOTEBOOK:
+		case WPS_DEV_COMPUTER_MID:
+		default:
+			return 0;
+		}
+		break;
+	case WPS_DEV_MULTIMEDIA:
+		switch (sub) {
+		case WPS_DEV_MULTIMEDIA_DAR:
+		case WPS_DEV_MULTIMEDIA_PVR:
+		case WPS_DEV_MULTIMEDIA_MCX:
+		case WPS_DEV_MULTIMEDIA_SET_TOP_BOX:
+		case WPS_DEV_MULTIMEDIA_MEDIA_SERVER:
+			return 1;
+		case WPS_DEV_MULTIMEDIA_PORTABLE_VIDEO_PLAYER:
+		default:
+			return 0;
+		}
+		break;
+	case WPS_DEV_GAMING:
+		switch (sub) {
+		case WPS_DEV_GAMING_XBOX:
+		case WPS_DEV_GAMING_XBOX360:
+		case WPS_DEV_GAMING_PLAYSTATION:
+		case WPS_DEV_GAMING_GAME_CONSOLE:
+			return 1;
+		case WPS_DEV_GAMING_PORTABLE_DEVICE:
+		default:
+			return 0;
+		}
+		break;
+	case WPS_DEV_PRINTER:
+	case WPS_DEV_DISPLAY:
+	case WPS_DEV_NETWORK_INFRA:
+	case WPS_DEV_STORAGE:
+		return 1;
+	case WPS_DEV_INPUT:
+	case WPS_DEV_CAMERA:
+	case WPS_DEV_PHONE:
+	case WPS_DEV_AUDIO:
+	default:
+		return 0;
+	}
+
+	return 0;
+}
-- 
1.7.10.4




More information about the Hostap mailing list