From patchwork Thu Jun 13 11:59:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chin-Ran Lo X-Patchwork-Id: 1947365 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Bw4NauLl; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.a=rsa-sha256 header.s=selector2 header.b=Ppq3Vpyt; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W0LZV0Ls5z20Xd for ; Thu, 13 Jun 2024 22:00:18 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=9AS+ExQOOz0zGkL0mpBl4OrtAoVFzQexU5YUErHdyGs=; b=Bw4NauLlarcT0O +Y2tVerUsw7RLSv2y34Q2mgaDqzr3vGZWlsZyy5tDBMOF7M2PlWeGEkp9EhBAYiIayagO0LFu7RYn wu6QVYP6k8IZgmw/VWg/rZQYKJwdQdbWYjO3Rog40PnzHttP9c37TkdDZbaxnBNfiPGHtJ3Sk7pPm L/gvkSmGKEwfOS3hS+DWjDfLeBWu6yg1ij6EKASUTtZRy5Bviomc/fo42OsbIwriijeUWErJoXFSR MDftq1lT44cfGHdveu4EAr7BzfOcU0ZH9QcyuOQi5XL88hODMJvbvzcH6Jt2h2/kDqgyP7EhzUT5S gUlXTrVScpA/HlwVyHqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sHj7J-0000000GPiI-00uU; Thu, 13 Jun 2024 11:59:45 +0000 Received: from mail-db8eur05on20615.outbound.protection.outlook.com ([2a01:111:f400:7e1a::615] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sHj7E-0000000GPg8-2SKq for hostap@lists.infradead.org; Thu, 13 Jun 2024 11:59:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AlZymUFmoTiHbgA0pp3dJu2GyjCZJXlUYqr/vEted1+7+FHPmvK3foyjdxumy3vUcG+XoNsI/eP0ueLxG7G181Ie8ahjUOZXpEU+dkHgBLi63JTgJC+V41ZqeHjC11kldWrwPkf3Hs+h6TxFrAmMjVm1jFeY1ROi/gel45BidYbbenHg2rVDnBoXD6Cpx2PnPwSKJFaMm+tUJMQ2ENypL1BWjvjtRHb6xE2oFCQXpKqkb0N4QZ9KV5lQWFEOVwV9jidNNGpg4dodwATUQTpnFiqDooMjF43Z6kayhy8uKCxpbl2ikGCUxlnAWSxHLGwz6QK9M6+5TIU7NiBL0yPBPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=813/V9+jH8iiMiW+xH4as63/7kL57m9jIcFGRGprk/U=; b=O8WXsrdLZT7zIM0MOGlsIO8dKIjO4aWVr/A0nJCCtnatqP7saEbDx8W/B4b/KYbnTuRQQswrTBpjfXbZzd9jei8fbb0q1UlohLu5M0WzBPhm06DRxpxRUAo57B75yOmP3lN+SCeSD3wTTksE9OzOZwqWtD7ZAc+m1BhMY7QLfStcctoIJAFBC9TZOnPxO23XMUahD3RqV3uel81yRpesSUVhEoukQw21Ey8dpiDLhZK0HEHQDVZX/8A93tJAWY31yYOF1POt5lvtvRuBGRfnW8XDL323ev+KHxowXKCNR2UP37oJcL1p2cjI0NAlDBBUFcoonwIsYwSqqFAGS5H1ZQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=813/V9+jH8iiMiW+xH4as63/7kL57m9jIcFGRGprk/U=; b=Ppq3VpytBQu6tI+8N9x5FtKUpO4x5x4RZE+jVXHOzmHQ68H/Zd/zcs9dzP2jrHy5S668viCrar9KJwzfIzs7WLngyNPJ1WlgwRlY9/lfzpNhhbq6CNcEV11SlEgplfQUGLYrefJfhKGjWiwPKv9ivTKWtGdSC80nEnhsxSccFZs= Received: from DU0PR04MB9396.eurprd04.prod.outlook.com (2603:10a6:10:35b::9) by PA4PR04MB9685.eurprd04.prod.outlook.com (2603:10a6:102:26e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.36; Thu, 13 Jun 2024 11:59:26 +0000 Received: from DU0PR04MB9396.eurprd04.prod.outlook.com ([fe80::34a2:5975:cf64:a72c]) by DU0PR04MB9396.eurprd04.prod.outlook.com ([fe80::34a2:5975:cf64:a72c%4]) with mapi id 15.20.7633.036; Thu, 13 Jun 2024 11:59:26 +0000 From: Chin-Ran Lo To: "hostap@lists.infradead.org" CC: Chin-Ran Lo , Pete Hsieh Subject: [PATCH] Add the similar USD APIs to dbus control interface that other apps can use the functions Thread-Topic: [PATCH] Add the similar USD APIs to dbus control interface that other apps can use the functions Thread-Index: Adq9hhFpz2TFNchcRAuzsCWveYBfCw== Date: Thu, 13 Jun 2024 11:59:26 +0000 Message-ID: Accept-Language: zh-TW, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DU0PR04MB9396:EE_|PA4PR04MB9685:EE_ x-ms-office365-filtering-correlation-id: 91a9ccc1-5a98-4d9a-3462-08dc8ba045cd x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230034|376008|1800799018|366010|38070700012; x-microsoft-antispam-message-info: XyDZi2RYP+CdSQUqhzdR/oxHiJYY2GmibiJV+TRv4ECvaYBNSWKmQwRiUsJwK9veoa46hUC4lyAi0o9O2KJiQAkdiU/Jv8DLEQR2Z1wyX+qEiOprCYTBYpZMZU/TFlUBSl0QSnlRrbrq86pLLA88A6YtPdFO9ZbOypUxX4WZ+fnGYo98xjnD24Rn1oAev0OqeErtF2LP+z/unJeqyTc/n6oKfnTi5Fk/hXPy9sFUrR+bFFBJP28XS5SZe/RqNSF481CqIUvNO5ssdwg2nfHkJIzUYOcGQGTlKip6Sv/F4jliP9Ud+z3dUerqcYJm866VPsjW+Vx0jq5+l+KbuEXKJbmgEvZomFdycqKr11UqHalxgunRkdWJknddiiSudfheLtOkpdqDjhrPKmKDtayjkwYdwsRBNQZvJ9OSCsxqEfUbBYb7796cOEM8a1Vp4U20cjXx6U8lst+mmpJ1FrBd25QtBN2YoJsHoMEkmE3EP41dFQv/oClBpCo7aN0YGj53J5HQ1b90TXefs097mmczylTQsdGZXp6ktPQtCPMXFUmT74omXlB/1FmW7tbfDW0PY5OzQvErSJmTPH9Y1l9mcU6SdaDVxIHll5AGk7Wmim1REnf/747puFQQU3XauIgGBenblAsJ6ifcK2KuKv4XbYQFKG7PRNFVHD7O7/OWf9f0aodAIgun47WwnfNSSm6MbEJbff5YYU5hD66kPZJISIc1cQl81TgCf4tbsmRadTVs9IEeU6hUQjXYseTSYGOz3XZhzN63Pzt6g70/Oyj/mc6a8QNzxljm/Hu4Ojg5HN5IcamDPj4OuFZ076jknPF108HKjwWZeVac+F4E5P+/FL40IrZa/no7f17AlKAm4RF/IN6UOjK7Vqtwt18XHsuixpDu8cdyw9ippVbAvswQn0FGn3znQGu9Uq+4Y3A/7J3XbpBXnJ87oCSWkmUuHsGxAkAGz5GwOYaQJryADZrfF3fT+Fv+xVfiExp4Fe4CD3D0lS/bq6jZHv8afuZ5prfAsXFBbyNhuKxEbUsQOyyVRqoxVEHukvfPaFjyt4DiC4kEq+Ko89nDFHmmxWQ9NlR4iV1+JLkuqgaThRH7ywgPdGEB7SqFRQFXPIMXsQ8i7l7/ftEXTcnlh05ubHzzSTCgMArlh/v5JJOWZ86kLNmj+SUTxfVjs7bI0HZnojimIi+7aK7J7ajucNf5RmEIngNUk8KneGWQyPEnMrLf63UIUHn/TQGwuz6XtUfca1c6qG9oSZqXzOWcwExRDOB+5W3gvAaCXRSMVzySia4AsCkPbFYH3s1h05gbBAIj2FtgvQhKLfDkh6n/6GVMYjP5n/njWo7C3oXvsa/RL1B2tyQDgXolDcjaaWSPcHgagu/9YMY= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9396.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230034)(376008)(1800799018)(366010)(38070700012);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: WkAludPW6/YGkj42tbomH9SRY7iCuYpeknbFhiTOgRhrwp8E/Pac1ebvavVUe3TrDRqENwyKOH3SR4i4+hiFCTeeBJgGIaB5zXAmtvhltp6e0nCOyvMykep62UOZ/pedjN31jJOaSvxfLmnyZ0AX+aKCXkieIPUZ1DkS8kFdxMkGyjLHZUxsUhgVVbyLh3zYrVlyFAzkYDJvCz21bvvDTlNhtuS2fWqY8NW6GpyOl6iuoVTtifPL9Mkri8CSktfSWVoTQpwUlKKYwA+kIJoLL3keyxsix1gZ3KPwvTUcG4AU2nsMGaQBSWdSoi2BxzPZiswouLlRfyPPnNV3bHiJO/lqYtMQnB+kXRBA4W59OoBBB5rrZTduYnLJ5wPUCPMDhFDBIt86tL7wKnX9ezs+RcFVUv1TlZtsxelqrjYicqH9P4w5bWHqVbY8SPgjUjkOUEPOQsfe6EiU/YStEpWDcMmsuQUjHD0CxLAIik5/gBBAoR4zQsbCwMShSyoviYJVfEVagLQ4O1Y36O5+Y8pdtiJvoshFCVUBf/k7zjp0MpsF+8GSUCYWTWp2i3u1ZBhZqZkPfa4UPjQDaeCdkta1m3AYzh9aaSgB+hJYGnuLZ05Rk2IVG1KKvRTuBNWUplUmP2b2rtRTLW4/pNF0m1qV+YppRAF51jGJjtekNhfLrbzYi1RHerebRoAbrYu9W28E6IAsBhs2N5R12k0EqBoagU/APA5pQstvn2GpSSwVcPUrnRUE8zT3O+d+TUOjBxOouKlYXwAbBC7qTY/hgoBeVhzLdMFCt7RHOWO8FHoIn/RWxtc1ulLB0zcP9fRIYmO/udMfxUn/cu2LVV3CuxlfzpiCCP35INQbBe/wZUup0Aiyg6RNZCdVKPZ+ojsa5mE6s9EM6cR9pWjCYUAADHVeqJn00EFTIsj/V7bDpIZBGdeE2CSZVdj+FzMjQsu/p4besuXaXOZgqkjs1IYxiU/bkLUaG6R2KsAw59amzJPEr0LxuxpfBm0+7+8e422QZsc5QFcZ5ErUEEVg/XsbHikr8l5krbNAtdQxk96JPMI+LrL28bFbQ/QtALNa/7ftMz723A6LLg8WSiyLGo/hfekshKlRxnF2xd/HgxK1neySU8jrlxLsDTzIuclHstfKSOzBuppchYOpW4UxdUqlfyfCyuTw3+y480Qy+AtMX5M7ULBqutScssRpNYFq5fMRchlB7iS1M+RwPdH0o4fdQIIFZ/WuMqEFPoPHxVDsw2cp1HBnsG3xFq7ZSqHzCC1nVuG2rWjEOhwkiRO5jcAsZOosNAJr5EiYGO1acRXEYX7YapTn4dV3X6fgGLzXO8OWdEer+bDtfJUNInowy9qg/oEdbo+b37AmxO5Xdj0EeWYj+sLJiwYY3KSYmToXNyc6O3lSU71y5cC/OyvsaGwqu9o0WhXEwDKmpfLixmPrgE3e6Nb1S+X9XQ7iDavAGmC/rgromzkHjeH97ipMbbPT2taak7N2uDSTqgLs0PToRJpQHHiW0aQAM1DaGX4cdIrXSgcVnv37QSG1pR7cpzfSs1aQE+7dOZQyguqMBFnl5npucF/wqQQhvVUN+/LYVLDNtvqk MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9396.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 91a9ccc1-5a98-4d9a-3462-08dc8ba045cd X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Jun 2024 11:59:26.1501 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 4Li2ucXj9OLe3P7Q4cVN6fp6dt9m+8cwNFKI6Ux14at7VA6to18x/sqosDwWsfOKSTv1+UYH/dI5EAn27DQ+jQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB9685 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240613_045941_382838_927C0CC8 X-CRM114-Status: GOOD ( 17.44 ) X-Spam-Score: 0.8 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From 6d912819f83520cc3f7961bbd6435f4460687d58 Mon Sep 17 00:00:00 2001 From: "Lo,Chin-Ran" Date: Thu, 13 Jun 2024 19:19:57 +0800 Subject: [PATCH] Add the similar USD APIs to dbus [...] Content analysis details: (0.8 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 T_SPF_PERMERROR SPF: test of record failed (permerror) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 ARC_SIGNED Message has a ARC signature -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 ARC_VALID Message has a valid ARC signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a01:111:f400:7e1a:0:0:0:615 listed in] [list.dnswl.org] 1.0 FORGED_SPF_HELO No description available. -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From 6d912819f83520cc3f7961bbd6435f4460687d58 Mon Sep 17 00:00:00 2001 From: "Lo,Chin-Ran" Date: Thu, 13 Jun 2024 19:19:57 +0800 Subject: [PATCH] Add the similar USD APIs to dbus control interface that other apps can use the functions Signed-off-by: Lo,Chin-Ran --- wpa_supplicant/dbus/dbus_new.c | 132 +++++++++++ wpa_supplicant/dbus/dbus_new.h | 19 ++ wpa_supplicant/dbus/dbus_new_handlers.c | 293 ++++++++++++++++++++++++ wpa_supplicant/dbus/dbus_new_handlers.h | 9 +- wpa_supplicant/dbus/dbus_new_helpers.h | 13 ++ wpa_supplicant/nan_usd.c | 6 +- wpa_supplicant/notify.c | 11 + wpa_supplicant/notify.h | 4 + 8 files changed, 485 insertions(+), 2 deletions(-) -- 2.34.1 diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index 00b38edf5..78c455562 100644 --- a/wpa_supplicant/dbus/dbus_new.c +++ b/wpa_supplicant/dbus/dbus_new.c @@ -220,6 +220,98 @@ void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s, int success) dbus_message_unref(msg); } +/** + * wpas_dbus_signal_discovery_result - send discovery result signal + * @wpa_s: %wpa_supplicant network interface data + * @success: indicates if scanning succeed or failed + * + * Notify listeners about finishing a scan + */ +void wpas_dbus_signal_discovery_result(struct wpa_supplicant *wpa_s, int success, int subscribe_id, int peer_publish_id, const u8 *peer_addr) +{ + struct wpas_dbus_priv *iface; + DBusMessage *msg; + DBusMessageIter iter, dict_iter; + dbus_bool_t succ; + struct wpa_dbus_discov_info disc_info; + + iface = wpa_s->global->dbus; + + /* Do nothing if the control interface is not turned on */ + if (iface == NULL || !wpa_s->dbus_new_path) + return; + + msg = dbus_message_new_signal(wpa_s->dbus_new_path, + WPAS_DBUS_NEW_IFACE_INTERFACE, + "DiscoveryResult"); + if (msg == NULL) + return; + + dbus_message_iter_init_append(msg, &iter); + succ = success ? TRUE : FALSE; + disc_info.subscribe_id = subscribe_id; + disc_info.peer_publish_id = peer_publish_id; + memcpy(disc_info.peer_addr, peer_addr, ETH_ALEN); + + if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_BOOLEAN, &succ) || + !wpa_dbus_dict_open_write(&iter, &dict_iter) || + !wpa_dbus_dict_append_byte_array(&dict_iter, "discov_info", + (const char *) &disc_info, + sizeof(disc_info)) || + !wpa_dbus_dict_close_write(&iter, &dict_iter)) + wpa_printf(MSG_ERROR, "dbus: Failed to construct signal"); + else + dbus_connection_send(iface->con, msg, NULL); + dbus_message_unref(msg); +} + +/** + * wpas_dbus_signal_nan_receive - send receive nan-usd packet signal + * @wpa_s: %wpa_supplicant network interface data + * @success: indicates if scanning succeed or failed + * + * Notify listeners about finishing a scan + */ +void wpas_dbus_signal_nan_receive(struct wpa_supplicant *wpa_s, int id, int peer_id, const u8 *peer_addr, size_t ssi_len, const u8 *ssi) +{ + struct wpas_dbus_priv *iface; + DBusMessage *msg; + DBusMessageIter iter, dict_iter; + struct wpa_dbus_nanrx_info nanrx_info; + + iface = wpa_s->global->dbus; + + /* Do nothing if the control interface is not turned on */ + if (iface == NULL || !wpa_s->dbus_new_path) + return; + + msg = dbus_message_new_signal(wpa_s->dbus_new_path, + WPAS_DBUS_NEW_IFACE_INTERFACE, + "NanReceive"); + if (msg == NULL) + return; + + dbus_message_iter_init_append(msg, &iter); + nanrx_info.id = id; + nanrx_info.peer_id = peer_id; + memcpy(nanrx_info.peer_addr, peer_addr, ETH_ALEN); + nanrx_info.ssi_len = ssi_len; + + if (!wpa_dbus_dict_open_write(&iter, &dict_iter) || + !wpa_dbus_dict_append_byte_array(&dict_iter, "nanrx_info", + (const char *) &nanrx_info, + sizeof(nanrx_info)) || + !wpa_dbus_dict_append_byte_array(&dict_iter, "ssi", + (const char *) ssi, + ssi_len) || + !wpa_dbus_dict_close_write(&iter, &dict_iter)) + wpa_printf(MSG_ERROR, "dbus: Failed to construct signal"); + else + dbus_connection_send(iface->con, msg, NULL); + dbus_message_unref(msg); +} + + /** * wpas_dbus_signal_bss - Send a BSS related event signal @@ -3605,6 +3697,30 @@ static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = { } }, #endif /* CONFIG_AUTOSCAN */ +#ifdef CONFIG_NAN_USD + { "NANPublish", WPAS_DBUS_NEW_IFACE_INTERFACE, + (WPADBusMethodHandler) wpas_dbus_handler_nan_publish, + { + { "nan_args", "s", ARG_IN }, + { "publish_id", "i", ARG_OUT }, + END_ARGS + } + }, + { "NANSubscribe", WPAS_DBUS_NEW_IFACE_INTERFACE, + (WPADBusMethodHandler) wpas_dbus_handler_nan_subscribe, + { + { "nan_args", "s", ARG_IN }, + END_ARGS + } + }, + { "NANTransmit", WPAS_DBUS_NEW_IFACE_INTERFACE, + (WPADBusMethodHandler) wpas_dbus_handler_nan_transmit, + { + { "nan_args", "s", ARG_IN }, + END_ARGS + } + }, +#endif /* CONFIG_NAN_USD */ #ifdef CONFIG_TDLS { "TDLSDiscover", WPAS_DBUS_NEW_IFACE_INTERFACE, (WPADBusMethodHandler) wpas_dbus_handler_tdls_discover, @@ -3983,6 +4099,22 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = { END_ARGS } }, +#ifdef CONFIG_NAN_USD + { "DiscoveryResult", WPAS_DBUS_NEW_IFACE_INTERFACE, + { + { "success", "b", ARG_OUT }, + { "discov_info", "a{sv}", ARG_OUT }, + END_ARGS + } + }, + { "NANReceive", WPAS_DBUS_NEW_IFACE_INTERFACE, + { + { "nanrx_info", "a{sv}", ARG_OUT }, + { "ssi", "a{sv}", ARG_OUT }, + END_ARGS + } + }, +#endif /* CONFIG_NAN_USD */ { "BSSAdded", WPAS_DBUS_NEW_IFACE_INTERFACE, { { "path", "o", ARG_OUT }, diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h index b653f10f9..d58ede9c1 100644 --- a/wpa_supplicant/dbus/dbus_new.h +++ b/wpa_supplicant/dbus/dbus_new.h @@ -21,6 +21,9 @@ struct wpa_bss; struct wps_event_m2d; struct wps_event_fail; struct wps_credential; +#ifdef CONFIG_NAN_USD +struct wpa_dbus_discov_info; +#endif /* CONFIG_NAN_USD */ enum wpas_dbus_prop { WPAS_DBUS_PROP_AP_SCAN, @@ -168,6 +171,10 @@ void wpas_dbus_signal_network_request(struct wpa_supplicant *wpa_s, enum wpa_ctrl_req_type rtype, const char *default_text); void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s, int success); +#ifdef CONFIG_NAN_USD +void wpas_dbus_signal_discovery_result(struct wpa_supplicant *wpa_s, int success, int subscribe_id, int peer_publish_id, const u8 *peer_addr); +void wpas_dbus_signal_nan_receive(struct wpa_supplicant *wpa_s, int id, int peer_id, const u8 *peer_addr, size_t ssi_len, const u8 *ssi); +#endif /* CONFIG_NAN_USD */ void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s, const struct wps_credential *cred); void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s, @@ -328,6 +335,18 @@ static inline void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s, { } +#ifdef CONFIG_NAN_USD +static inline void wpas_dbus_signal_discovery_result(struct wpa_supplicant *wpa_s, + int success, int subscribe_id, int peer_publish_id, const u8 *peer_addr) +{ +} + +static inline void wpas_dbus_signal_nan_receive(struct wpa_supplicant *wpa_s, + int id, int peer_id, const u8 *peer_addr, size_t ssi_len, const u8 *ssi) +{ +} +#endif /* CONFIG_NAN_USD */ + static inline void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s, const struct wps_credential *cred) { diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c index 6ad49a136..a0100602c 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.c +++ b/wpa_supplicant/dbus/dbus_new_handlers.c @@ -12,6 +12,9 @@ #include "common.h" #include "common/ieee802_11_defs.h" +#ifdef CONFIG_NAN_USD +#include "common/nan_de.h" +#endif /* CONFIG_NAN_USD */ #include "eap_peer/eap_methods.h" #include "eapol_supp/eapol_supp_sm.h" #include "rsn_supp/wpa.h" @@ -27,6 +30,9 @@ #include "../autoscan.h" #include "../ap.h" #include "../interworking.h" +#ifdef CONFIG_NAN_USD +#include "../nan_usd.h" +#endif /* CONFIG_NAN_USD */ #include "dbus_new_helpers.h" #include "dbus_new.h" #include "dbus_new_handlers.h" @@ -2705,6 +2711,293 @@ DBusMessage * wpas_dbus_handler_eap_logon(DBusMessage *message, return NULL; } +#ifdef CONFIG_NAN_USD +/* + * wpas_dbus_handler_nan_publish - Send out nan-publish packets + * @message: Pointer to incoming dbus message + * @wpa_s: wpa_supplicant structure for a network interface + * Returns: NULL indicating success or DBus error message on failure + * + * Handler function for "NANPublish" method call of network interface. + */ +DBusMessage * wpas_dbus_handler_nan_publish(DBusMessage *message, + struct wpa_supplicant *wpa_s) +{ + const char *cmd; + char cmdbuf[128]; + + char *token, *context = NULL; + int publish_id; + struct nan_publish_params params; + const char *service_name = NULL; + struct wpabuf *ssi = NULL; + enum nan_service_protocol_type srv_proto_type = 3; + int *freq_list = NULL; + + wpa_printf(MSG_INFO, "DBUS NAN_PUBLISH:"); + if (!dbus_message_get_args(message, NULL, + DBUS_TYPE_STRING, &cmd, + DBUS_TYPE_INVALID)) { + wpa_printf(MSG_DEBUG, " DBUS NAN_PUBLISH, failed to get args "); + return NULL; + } + wpa_printf(MSG_DEBUG, "DBUS NAN_PUBLISH: args: [%s]", cmd); + + os_memset(¶ms, 0, sizeof(params)); + /* USD shall use both solicited and unsolicited transmissions */ + params.unsolicited = true; + params.solicited = true; + /* USD shall require FSD without GAS */ + params.fsd = true; + params.freq = NAN_USD_DEFAULT_FREQ; + strcpy(cmdbuf, cmd); + + while ((token = str_token(cmdbuf, " ", &context))) { + if (os_strncmp(token, "service_name=", 13) == 0) { + service_name = token + 13; + wpa_printf(MSG_DEBUG, "DBUS NAN_PUBLISH, service_name=[%s]", service_name); + continue; + } + + if (os_strncmp(token, "ttl=", 4) == 0) { + params.ttl = atoi(token + 4); + wpa_printf(MSG_DEBUG, "DBUS NAN_PUBLISH, ttl=[%d]", params.ttl); + continue; + } + + if (os_strncmp(token, "freq=", 5) == 0) { + params.freq = atoi(token + 5); + wpa_printf(MSG_DEBUG, "DBUS NAN_PUBLISH, freq=[%d]", params.ttl); + continue; + } + + if (os_strncmp(token, "freq_list=", 10) == 0) { + char *pos = token + 10; + if (os_strcmp(pos, "all") == 0) { + os_free(freq_list); + freq_list = wpas_nan_usd_all_freqs(wpa_s); + params.freq_list = freq_list; + continue; + } + + while (pos && pos[0]) { + int_array_add_unique(&freq_list, atoi(pos)); + pos = os_strchr(pos, ','); + if (pos) + pos++; + } + + params.freq_list = freq_list; + continue; + } + + if (os_strncmp(token, "srv_proto_type=", 15) == 0) { + srv_proto_type = atoi(token + 15); + wpa_printf(MSG_DEBUG, " DBUS NAN_PUBLISH, srv_proto_type=[%d]", srv_proto_type); + continue; + } + + if (os_strncmp(token, "ssi=", 4) == 0) { + if (ssi) + goto fail; + ssi = wpabuf_parse_bin(token + 4); + if (!ssi) + goto fail; + continue; + } + + if (os_strcmp(token, "solicited=0") == 0) { + params.solicited = false; + continue; + } + + if (os_strcmp(token, "unsolicited=0") == 0) { + params.unsolicited = false; + continue; + } + + if (os_strcmp(token, "fsd=0") == 0) { + params.fsd = false; + continue; + } + + wpa_printf(MSG_DEBUG, "CTRL: Invalid NAN_PUBLISH parameter: %s", + token); + goto fail; + } + publish_id = wpas_nan_usd_publish(wpa_s, service_name, srv_proto_type, + ssi, ¶ms); + if (publish_id > 0) { + DBusMessage *reply; + reply = dbus_message_new_method_return(message); + dbus_message_append_args(reply, DBUS_TYPE_INT32, + &publish_id, DBUS_TYPE_INVALID); + return reply; + } +fail: + wpabuf_free(ssi); + os_free(freq_list); + return NULL; +} +/* + * wpas_dbus_handler_nan_subscribe - Send out nan-subscribe packets + * @message: Pointer to incoming dbus message + * @wpa_s: wpa_supplicant structure for a network interface + * Returns: NULL indicating success or DBus error message on failure + * + * Handler function for "NANSubscribe" method call of network interface. + */ +DBusMessage * wpas_dbus_handler_nan_subscribe(DBusMessage *message, + struct wpa_supplicant *wpa_s) +{ + const char *cmd; + char cmdbuf[128]; + char *token, *context = NULL; + struct nan_subscribe_params params; + const char *service_name = NULL; + struct wpabuf *ssi = NULL; + enum nan_service_protocol_type srv_proto_type = 3; + + wpa_printf(MSG_INFO, "DBUS NAN_SUBSCRIBE: "); + if (!dbus_message_get_args(message, NULL, + DBUS_TYPE_STRING, &cmd, + DBUS_TYPE_INVALID)) { + wpa_printf(MSG_DEBUG, "DBUS NAN_SUBSCRIBE, failed to get args "); + return NULL; + } + wpa_printf(MSG_DEBUG, "DBUS NAN_SUBSCRIBE, args: [%s]", cmd); + os_memset(¶ms, 0, sizeof(params)); + params.freq = NAN_USD_DEFAULT_FREQ; + + strcpy(cmdbuf, cmd); + while ((token = str_token(cmdbuf, " ", &context))) { + if (os_strncmp(token, "service_name=", 13) == 0) { + service_name = token + 13; + continue; + } + + if (os_strcmp(token, "active=1") == 0) { + params.active = true; + continue; + } + + if (os_strncmp(token, "ttl=", 4) == 0) { + params.ttl = atoi(token + 4); + continue; + } + + if (os_strncmp(token, "freq=", 5) == 0) { + params.freq = atoi(token + 5); + continue; + } + + if (os_strncmp(token, "srv_proto_type=", 15) == 0) { + srv_proto_type = atoi(token + 15); + continue; + } + + if (os_strncmp(token, "ssi=", 4) == 0) { + if (ssi) + goto fail; + ssi = wpabuf_parse_bin(token + 4); + if (!ssi) + goto fail; + continue; + } + wpa_printf(MSG_INFO, + "CTRL: Invalid NAN_SUBSCRIBE parameter: %s", + token); + goto fail; + } + + wpas_nan_usd_subscribe(wpa_s, service_name, + srv_proto_type, ssi, + ¶ms); +fail: + wpabuf_free(ssi); + return NULL; +} + +/* + * wpas_dbus_handler_nan_transmit - Send out nan-followup packets + * @message: Pointer to incoming dbus message + * @wpa_s: wpa_supplicant structure for a network interface + * Returns: NULL indicating success or DBus error message on failure + * + * Handler function for "NANTransmit" method call of network interface. + */ +#define TX_CMD_DAT_BUFLEN 2048 +DBusMessage * wpas_dbus_handler_nan_transmit(DBusMessage *message, + struct wpa_supplicant *wpa_s) +{ + const char *cmd; + char cmdbuf[TX_CMD_DAT_BUFLEN]; + char *token, *context = NULL; + int handle = 0; + int req_instance_id = 0; + struct wpabuf *ssi = NULL; + u8 peer_addr[ETH_ALEN]; + int ret = -1; + + wpa_printf(MSG_INFO, "DBUS NAN_TRANSMIT:"); + os_memset(cmdbuf, 0, TX_CMD_DAT_BUFLEN); + if (!dbus_message_get_args(message, NULL, + DBUS_TYPE_STRING, &cmd, + DBUS_TYPE_INVALID)) { + wpa_printf(MSG_DEBUG, "DBUS NAN_TRANSMIT, failed to get args "); + return NULL; + } + wpa_printf(MSG_DEBUG, "DBUS NAN_TRANSMIT, args: [%s]", cmd); + os_memset(peer_addr, 0, ETH_ALEN); + strcpy(cmdbuf, cmd); + while ((token = str_token(cmdbuf, " ", &context))) { + if (sscanf(token, "handle=%i", &handle) == 1) + continue; + + if (sscanf(token, "req_instance_id=%i", &req_instance_id) == 1) + continue; + + if (os_strncmp(token, "address=", 8) == 0) { + if (hwaddr_aton(token + 8, peer_addr) < 0) + return NULL; + continue; + } + + if (os_strncmp(token, "ssi=", 4) == 0) { + if (ssi) + goto fail; + ssi = wpabuf_parse_bin(token + 4); + if (!ssi) + goto fail; + continue; + } + + wpa_printf(MSG_INFO, + "CTRL: Invalid NAN_TRANSMIT parameter: %s", + token); + goto fail; + } + + if (handle <= 0) { + wpa_printf(MSG_INFO, + "CTRL: Invalid or missing NAN_TRANSMIT handle"); + goto fail; + } + + if (is_zero_ether_addr(peer_addr)) { + wpa_printf(MSG_INFO, + "CTRL: Invalid or missing NAN_TRANSMIT address"); + goto fail; + } + + ret = wpas_nan_usd_transmit(wpa_s, handle, ssi, NULL, peer_addr, + req_instance_id); +fail: + wpa_printf(MSG_INFO, "DBUS NAN_TRANSMIT Done, %d", ret); + wpabuf_free(ssi); + return NULL; +} +#endif /* CONFIG_NAN_USD */ #ifdef CONFIG_TDLS diff --git a/wpa_supplicant/dbus/dbus_new_handlers.h b/wpa_supplicant/dbus/dbus_new_handlers.h index 97fa337bd..aef27ea38 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.h +++ b/wpa_supplicant/dbus/dbus_new_handlers.h @@ -248,7 +248,14 @@ DECLARE_ACCESSOR(wpas_dbus_getter_mesh_peers); DECLARE_ACCESSOR(wpas_dbus_getter_mesh_group); DECLARE_ACCESSOR(wpas_dbus_getter_signal_change); - +#ifdef CONFIG_NAN_USD +DBusMessage * wpas_dbus_handler_nan_publish(DBusMessage *message, + struct wpa_supplicant *wpa_s); +DBusMessage * wpas_dbus_handler_nan_subscribe(DBusMessage *message, + struct wpa_supplicant *wpa_s); +DBusMessage * wpas_dbus_handler_nan_transmit(DBusMessage *message, + struct wpa_supplicant *wpa_s); +#endif /* CONFIG_NAN_USD */ DBusMessage * wpas_dbus_handler_tdls_discover(DBusMessage *message, struct wpa_supplicant *wpa_s); DBusMessage * wpas_dbus_handler_tdls_setup(DBusMessage *message, diff --git a/wpa_supplicant/dbus/dbus_new_helpers.h b/wpa_supplicant/dbus/dbus_new_helpers.h index c8d44a00b..87ef31000 100644 --- a/wpa_supplicant/dbus/dbus_new_helpers.h +++ b/wpa_supplicant/dbus/dbus_new_helpers.h @@ -98,7 +98,20 @@ struct wpa_dbus_property_desc { /* other data */ const char *data; }; +#ifdef CONFIG_NAN_USD +struct wpa_dbus_discov_info { + u32 subscribe_id; + u32 peer_publish_id; + u8 peer_addr[ETH_ALEN]; +}; +struct wpa_dbus_nanrx_info { + u32 id; + u32 peer_id; + u8 peer_addr[ETH_ALEN]; + u32 ssi_len; +}; +#endif /* CONFIG_NAN_USD */ #define WPAS_DBUS_OBJECT_PATH_MAX 150 #define WPAS_DBUS_INTERFACE_MAX 150 diff --git a/wpa_supplicant/nan_usd.c b/wpa_supplicant/nan_usd.c index 657b302c1..04a564580 100644 --- a/wpa_supplicant/nan_usd.c +++ b/wpa_supplicant/nan_usd.c @@ -14,7 +14,7 @@ #include "offchannel.h" #include "driver_i.h" #include "nan_usd.h" - +#include "notify.h" static const char * tx_status_result_txt(enum offchannel_send_action_result result) @@ -254,6 +254,8 @@ wpas_nan_de_discovery_result(void *ctx, int subscribe_id, subscribe_id, peer_publish_id, MAC2STR(peer_addr), fsd, fsd_gas, srv_proto_type, ssi_hex); os_free(ssi_hex); + + wpas_notify_discovery_result(wpa_s, 1, subscribe_id, peer_publish_id, peer_addr); } @@ -331,6 +333,8 @@ static void wpas_nan_de_receive(void *ctx, int id, int peer_instance_id, wpa_msg(wpa_s, MSG_INFO, NAN_RECEIVE "id=%d peer_instance_id=%d address=" MACSTR " ssi=%s", id, peer_instance_id, MAC2STR(peer_addr), ssi_hex); + + wpas_notify_nan_receive(wpa_s, id, peer_instance_id, peer_addr, ssi_len, ssi); os_free(ssi_hex); } diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c index 745234dda..3d868f61c 100644 --- a/wpa_supplicant/notify.c +++ b/wpa_supplicant/notify.c @@ -281,6 +281,17 @@ void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success) wpas_dbus_signal_scan_done(wpa_s, success); } +#ifdef CONFIG_NAN_USD +void wpas_notify_discovery_result(struct wpa_supplicant *wpa_s, int success, int subscribe_id, int peer_publish_id, const u8 *peer_addr) +{ + wpas_dbus_signal_discovery_result(wpa_s, success, subscribe_id, peer_publish_id, peer_addr); +} + +void wpas_notify_nan_receive(struct wpa_supplicant *wpa_s, int id, int peer_id, const u8 *peer_addr, size_t ssi_len, const u8 *ssi) +{ + wpas_dbus_signal_nan_receive(wpa_s, id, peer_id, peer_addr, ssi_len, ssi); +} +#endif /* CONFIG_NAN_USD */ void wpas_notify_scan_results(struct wpa_supplicant *wpa_s) { diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h index 2a0cf097a..105bf9dcd 100644 --- a/wpa_supplicant/notify.h +++ b/wpa_supplicant/notify.h @@ -47,6 +47,10 @@ void wpas_notify_network_request(struct wpa_supplicant *wpa_s, const char *default_txt); void wpas_notify_scanning(struct wpa_supplicant *wpa_s); void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success); +#ifdef CONFIG_NAN_USD +void wpas_notify_discovery_result(struct wpa_supplicant *wpa_s, int success, int subscribe_id, int peer_publish_id, const u8 *peer_addr); +void wpas_notify_nan_receive(struct wpa_supplicant *wpa_s, int id, int peer_id, const u8 *peer_addr, size_t ssi_len, const u8 *ssi); +#endif /* CONFIG_NAN_USD */ void wpas_notify_scan_results(struct wpa_supplicant *wpa_s); void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s, const struct wps_credential *cred);