From bd886d47c58253a08638dd36c4aa5159b29d333d Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 24 Oct 2015 21:43:32 +0300 Subject: [PATCH] tests: P2P protocol tests for service discovery messages Signed-off-by: Jouni Malinen --- tests/hwsim/test_p2p_messages.py | 169 ++++++++++++++++++++++++++++++- 1 file changed, 168 insertions(+), 1 deletion(-) diff --git a/tests/hwsim/test_p2p_messages.py b/tests/hwsim/test_p2p_messages.py index 3cd333df9..3c6ba9837 100644 --- a/tests/hwsim/test_p2p_messages.py +++ b/tests/hwsim/test_p2p_messages.py @@ -1,5 +1,5 @@ # P2P protocol tests for various messages -# Copyright (c) 2014, Jouni Malinen +# Copyright (c) 2014-2015, Jouni Malinen # # This software may be distributed under the terms of the BSD license. # See README for more details. @@ -13,6 +13,7 @@ logger = logging.getLogger() import hostapd from test_p2p_persistent import form from test_p2p_persistent import invite +from test_gas import anqp_adv_proto MGMT_SUBTYPE_PROBE_REQ = 4 MGMT_SUBTYPE_ACTION = 13 @@ -1978,3 +1979,169 @@ def _test_p2p_msg_group_info(dev): if 'p2p_group_client' in bss: raise Exception("Unexpected p2p_group_client") dev[0].remove_group() + +MGMT_SUBTYPE_ACTION = 13 +ACTION_CATEG_PUBLIC = 4 + +GAS_INITIAL_REQUEST = 10 +GAS_INITIAL_RESPONSE = 11 +GAS_COMEBACK_REQUEST = 12 +GAS_COMEBACK_RESPONSE = 13 + +def gas_hdr(dst, src, type, req=True, dialog_token=0): + msg = {} + msg['fc'] = MGMT_SUBTYPE_ACTION << 4 + msg['da'] = dst + msg['sa'] = src + if req: + msg['bssid'] = dst + else: + msg['bssid'] = src + if dialog_token is None: + msg['payload'] = struct.pack("L', 0x506f9a00) + msg['payload'] += struct.pack('L', 0x506f9a09) + msg['payload'] += struct.pack('L', 0x506f9a09) + req += struct.pack('L', 0x506f9a09) + req += struct.pack('