From patchwork Thu Sep 5 13:43:38 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: 1981280 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=cwQvf8NR; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.a=rsa-sha256 header.s=selector1 header.b=Uqy44YqX; 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 4X00vr1yjGz1yfv for ; Thu, 5 Sep 2024 23:44:22 +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:In-Reply-To:References: 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: List-Owner; bh=U2lqCJqhlxm3BkCSnsPcwaI3okJJraSumCSDDYcAhzc=; b=cwQvf8NR3yLPIL DphtwVIAXMlkIaX5yl0Do3KjciObIbosOdf4JF0sZgxjT7YkBDJSKDZi/Lk60VDL/h8Cc1FWwCSK0 RthAJ5XkNsT2kro7YqT6sjMOD9k2G5WNaVikePXoJUvkuKlTO7WmkPTbuyfsLce/S0VMLvQ+B5+Dw dFkF5ZEkZpW16ZZ8kufl+TTfv4oBvgtQ8tEguYKjk6ViP23Pzlg8u+h6I90GiTxnlcFXGuSGY8rnF sm9MdRFeAVCUES0Lmd2gliY5/SWklijnpx2CESAdkyLHQZeP6yQkQzBhETTbSMAGDUj5G4vdCJBH5 fT3A5X9NqlzBBtJTL0vQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smCm8-00000008Zff-2nWu; Thu, 05 Sep 2024 13:43:52 +0000 Received: from mail-vi1eur05on20630.outbound.protection.outlook.com ([2a01:111:f403:2613::630] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smCm4-00000008Ze9-03RH for hostap@lists.infradead.org; Thu, 05 Sep 2024 13:43:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ky0y5wpIHeFDGvVblF1KDUW3AE+DE/6CwpXN3KoeU//rb4C7E/Kd8MtPnYkmuZ6RHAfQP3/NON2ga14x/DbczVATjCsl1bXdGRQVescEpaQqpUkjVUDeeeR1Mt8oEv3fDgTQhwOJqALUmfte9BGjAUSJyHg5VEhvPEa0+AwdPY1NdGfIC7UCkmiahCoew7uamyCsw/xVIibBJ1jbzk4ljf0cq0aOVLBRRalLqo5CqlbV5H11Iuyx201xsKQxsvV/ZuMg5UCM/1KWyYhoY5kQ5BGO/mcQ8y/d64js2jB1uAgZP7xzWVElGLyBleKRjnjqZ/KxXGlvPx+7BmKlN097NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=2UT6xGFQahflFu7gPEgk7l2eQP0ycCpmt+aIlfC5Vk4=; b=Pq+80b01wVKxvihUMKEu1d4EcCr8cGU9DV0XT+zJdMt5GfdollABV9FER3msyrwXBlO9Lh42h3ozu98+M0bFqAoQTlKKpl8vHpGsrB5f2dKOLSihMBJWp5HoX1wY60iffMZAl5GZ0vW3VClB6lSb34MXNyKFmW2epB+A4d8cuCCWQxgS0R+N3ZzXVjWIhUlOsfXOIxwdADD2iwIaJWoREaGo7w/MzA9qAV9r5iTiBwriHq1YMJxwTrZL4qcWDm+eerEDERfkGlQk3xKkQD7mhCOIAQHHeFq59IdT4k5CNlg+LcNcf1juNWs7qyab4XSwltYPGAkAPOJytAx/FpXD+Q== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2UT6xGFQahflFu7gPEgk7l2eQP0ycCpmt+aIlfC5Vk4=; b=Uqy44YqXdxb8KmaO+WOLSShlGz1YBqo2t7wl0vqSiXx6geie75A5Sy39SIk+0nVZMjysfzarnH9YpOWvpHbyeD79w/6zAq3pOba52+vM2dl4+702dep2gaXqqtCf6P6uvFBVWKYab0r+sHxtyiZuNEWs6MWvQDhbUxTzZlfbHNNVtR7QbQf2Ecq4BTCcneMrF1Mcj+Go3jdMCyiWcZyvr/Y3DWUBL9wIgP4DILn1t68/LoaUvfBLpSJMhNPQrO4v60TcUlNF0mf9fsZzQt5CARKUcyxZ1ZYqYPedzeTYhXIu61YbbRrlG7JNjU9q/Lc90ijND0oVsSUZ/yOoAp2jAw== Received: from DU0PR04MB9396.eurprd04.prod.outlook.com (2603:10a6:10:35b::9) by DB9PR04MB8445.eurprd04.prod.outlook.com (2603:10a6:10:2cf::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.28; Thu, 5 Sep 2024 13:43:38 +0000 Received: from DU0PR04MB9396.eurprd04.prod.outlook.com ([fe80::34a2:5975:cf64:a72c]) by DU0PR04MB9396.eurprd04.prod.outlook.com ([fe80::34a2:5975:cf64:a72c%7]) with mapi id 15.20.7918.024; Thu, 5 Sep 2024 13:43:38 +0000 From: Chin-Ran Lo To: "hostap@lists.infradead.org" CC: Pete Hsieh , Chin-Ran Lo Subject: [PATCH v9 1/2] Add the similar USD APIs to dbus control interface that other apps can use the functions Thread-Topic: [PATCH v9 1/2] Add the similar USD APIs to dbus control interface that other apps can use the functions Thread-Index: AQHa/5mchhmFUzZzR0q43ymyn7aPfw== Date: Thu, 5 Sep 2024 13:43:38 +0000 Message-ID: References: In-Reply-To: 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_|DB9PR04MB8445:EE_ x-ms-office365-filtering-correlation-id: 2690cb51-fb0c-42ac-0ea8-08dccdb0bef6 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|4022899009|366016|376014|38070700018; x-microsoft-antispam-message-info: 3Hh4AHquaDUhYg8mbKYH39R4NDJMcuxqfF18H+jHZOHYuai0+fMZq1J/dwdLAKqJhPo4nlIctdXri4vh2Wby1POwMzalMiE/r29kJRs1WbSQ0/L4bz1WvDSNOt5NhX/6CWEAGQUvJK2t3TmzCXed9vXpof8VWixcKVG1KXaFZ4yTTOssjy0eUElEasFL5K7UHl+D9HMA3wUhjVFdJ2/6yxS5HT0/66esaFzfKxc8iDxPy5nDykBNyUc3q0da5fq61Y85kQ0DKWCGaG8utkSOwH1U3qQUlCh+tx+XxaDXXFWbgQeMgRz7yM/9b4OAKnnWNslXwvXiwg9TbTHEujTd3AJ+1yArjIM1plYmK9lUSfhjmuDuoE2fg2AeVdQN+PAEZ6tr0B9vcMOwblX432yTQNzFaL4E7jG9eH1YkbYurcnGtLIuhiXP2lniiIKH4O4VmyZXMIp8fFrBboaGF0dcbE4hBsfD5Kz9vV7H4t6IfqmN9V6INIDyFiYkkiuvEqc+4YZS2YsRA7SmBhs9LhKoTw6WmbOID0Milpp5KnOFBfjIfC4NCLj1uu845MAslBgvhUBIQc6RMW9efvfbkTFnalGWaIWyyyZ8z1+6Rxde4wyj5ZVwwxs8ZNGHYB/ilbgi/Ft1tmIxkaewxL7czi7GUp2IUHvmtqdhENwNf3onhBOIhSOyx73DYpe/UGdKOM8hnHgPjhlQfonR30ZGi08CuTfYSDgrBVYKaXp6RGCOr4v1la4xzwGIKVmHqOLizv18AmWJlW68yDVFVzIM8HLi3h8cLBXLtI0/5haFvTeBHPFPncBrmwBHM9oNVVmOqRXrUK505EGX08DCl94hFFdnVxcgAaY1/ODTvOSFSiLu8noi5PnHh8IQGGZ7syBnk7JXZDbFCoMXBGwkXZ+sYaYqOMpKJQpv1FodYSspb+6i9Ta/hmCUr9YxNERTdHp5jz5kAvuZ92rWDcJie1M32uH2nc7ws/O7eTxzgUGNQKxXaL20Ek9b6QBnjFZzHA7vOGVleMBjRY5SKVXpG6X99WiBrqr5Q/jUX1DN8OzMSiJpxV5ycueqrCUs8xdQvf74PdSpNVZFnB/yjqQsH8DN5JouzasemTUwvs0dmq47yJbik49kirHZQ4x209ab79sgUUpqysTKXHu1QR9/FzGzsDm7CJ6jLhVLVFQUh+TE14NtjEc1S+Vd8x7hGxy8bINaCe62elE8/mvZf2J0P5QvgrJ2gxiR1QpAPH+hfjUTDojcvNu8WtRfEYU9YwsMnY/hHy/+j2RnC67vgYFXy8aOoUoT1x489hPoiPcA/plKc2vhS094zjYD4lZ427CT1o26V5dLjd9X7f+/9z3swauW9iflhWFp5F57iRh0IDox5EFrq+tHmlvdSIBdlXoAXqekjV0GGUVfZ8AVFnAMjPHm7G0kgg== 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:(13230040)(1800799024)(4022899009)(366016)(376014)(38070700018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: SjNlWm+j1cek5FuoQh8qaDS4H//RH3hEs1p2EgrMXlAWwV3PnHTHs45pGsxQYmWWiv/WuvXZ3GMtUQm5AnBqlmUoLWxJ1FmMa82PlGj1hY28ljS0FoSkQQSFFZyk4WQz2xSu/iEQgzyaArqGVbAw5JWYBYkOxtEAz0mJlwZbQE+n9MGr4qrHGcYf4hhWsD6xGQHNVbzYWAUVsG8ipcKlA1q6a1sDUKcJndoD9iLitrA3hINFFCQJVSmoLxw/hDmKiV1rg49Wn78/j4zDfHrtdHz7yAU9PHXTROvyExVkXVJgZ7BJp3lIZ/fqSCia0hfQe3biLfm5MXT5fkwdMfdLWN2YMbla7xohnYxYpjJPRvNWc7+4m+ddsesfGX+O6T2+GretF1x+G/6SDY7F9IB8Zh7n2QBBHru/1/UtZz/MmTrtrJoXj1Avwe23soIHa4bc/tJbRu11jVDFm9tag9fimVelkiAlFzcabFNeyNRSBatdg5CGXUvnMs7B9J2yPNfx49AjEQG+BP6VAeam28wMfLRSoSGGSvPL8kZ2gAKXBsgbwe8g7Udaf254+omyYpa2Hdfgz28nI4JF7pkLQAtiLDVPJiPQi/tsi1pwMxGnZUqHOWrk3VgJwHY21xGuwjrphvR7KMYrMsxLn80f6leQvQ/Xuwref9qerUsOSJfhMzhNIL/0OwM8lvISOEB/dfwFo1kOW8quNQCT1rbQHtVgzIldz3QYIu/D47g/1MfX/aGyh4fvjxu6cIG4eMgaoYyFrS1bkw00Y0dIbewn5NwPLpI+rAbVW87vy04TRDOET480uaOBN47foFBzcCnuHuPNyvndADwTyQs1BuHfzZ1U/OCMp1YDyYKfgclki8GXrJ2X1q8sjdIvEr55d86EpzNw0o6qvJHyf/wDYRvkBE/mF70YR/AkeoVEDhl9s5dYCCbieDi/ibEW994oQY9z724eHRvZ4q6F2RZdicHlQndWjyJuCGS6UGtuiyQ7km7A7mps8j1N55LHtY/SYMcD1EXFrZLs9Ws6kH0MZxMBlsGpXIjzP4U2ZxNygvX4D0EPZOdosSXAV6w3NeL/DmBwDPft0EN155CYBvAAOsWmdDHviLl5xQHwj/ZbO5h5PZ1xR4fe+X+/iRNPU73dOrnIx0/Of8ny7FnjzD5oLK8yfYQrFk/NqOWHk5o5Pn2bZ/Z/Z0AoRp8uk1gVbRYwo6aEb+Z86T3S1Ct/iEZ8TVBpd5HyKCLxqt29nIHXWcXvqFdDMU3XSDaoALQcGIyNXgKVLh0r5JtgSWzb1dYdWjpmZDI6hPcD5rH3SQTzXVYMAiBTVIFiCMeRAaVgSTSDKY4rK4QYWAi7u+Ij8ga9WHM6qOhELl+Jgnfu1njyyQh2/b6CmpNqRkGyja/LPJkyzIKx9sCZ2HilttwVFcvSKE9hmw7Bqii+ZVzJ31Yk2tB/Eqs7hi7p/V2tSdu21Yi1pyu0NFCcq2UV0g9msMGvjZp7Fc1nfjw9As40i6Ea5q6l1jPZNkY+fpzG3nIcpsaEm62SeK/ZZMM4jK4THRq7JNX/MmoBFyn4g5b1j434KaVEdJaqkQM1wdW3KzbjvMpo7rbJkjlD 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: 2690cb51-fb0c-42ac-0ea8-08dccdb0bef6 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Sep 2024 13:43:38.1238 (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: PZJ9OLD8qzI8ZhqnSQQdCQzmH+ptz8UnEg/mZR8iaeTXCxdtpDXBvo+w5+QrCM7/nc7HybmVbgzsWUf/9/mMAA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8445 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240905_064348_459138_6BB127D4 X-CRM114-Status: GOOD ( 17.91 ) X-Spam-Score: -1.1 (-) 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 21d54563ae8d2282b799319f797463f69f6e3ed3 Mon Sep 17 00:00:00 2001 From: "Lo,Chin-Ran" Date: Mon, 15 Jul 2024 14:01:11 +0800 Subject: [v9 1/2] dbus: Add API for USD USD had a control interface commands and events defined for it. Extend this by providing similar USD APIs through the dbus control interface. Content analysis details: (-1.1 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_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.0 ARC_SIGNED Message has a ARC signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 ARC_VALID Message has a valid ARC signature -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 T_SCC_BODY_TEXT_LINE No description available. 1.0 FORGED_SPF_HELO 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 21d54563ae8d2282b799319f797463f69f6e3ed3 Mon Sep 17 00:00:00 2001 From: "Lo,Chin-Ran" Date: Mon, 15 Jul 2024 14:01:11 +0800 Subject: [v9 1/2] dbus: Add API for USD USD had a control interface commands and events defined for it. Extend this by providing similar USD APIs through the dbus control interface. Signed-off-by: Lo,Chin-Ran --- Changed since v8: * Rectify the series Changed since v7: * Change the function name by the rule: "NANWord1Word2.." * Change the parameters by using the dictionary of named arguments * Miscellaneous fix * Add the signal functions to dbus.doxygen and separate the patch because of the size limitation wpa_supplicant/dbus/dbus_new.c | 329 ++++++++++++ wpa_supplicant/dbus/dbus_new.h | 55 ++ wpa_supplicant/dbus/dbus_new_handlers.c | 636 ++++++++++++++++++++++++ wpa_supplicant/dbus/dbus_new_handlers.h | 14 + wpa_supplicant/dbus/dbus_new_helpers.h | 23 + wpa_supplicant/notify.c | 16 + 6 files changed, 1073 insertions(+) diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index 5ad5bcd74..1c92d55e7 100644 --- a/wpa_supplicant/dbus/dbus_new.c +++ b/wpa_supplicant/dbus/dbus_new.c @@ -3652,6 +3652,52 @@ 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", "a{sv}", ARG_IN }, + { "publish_id", "i", ARG_OUT }, + END_ARGS + } + }, + { "NANCancelPublish", WPAS_DBUS_NEW_IFACE_INTERFACE, + (WPADBusMethodHandler) wpas_dbus_handler_nan_cancel_publish, + { + { "nan_args", "i", ARG_IN }, + END_ARGS + } + }, + { "NANUpdatePublish", WPAS_DBUS_NEW_IFACE_INTERFACE, + (WPADBusMethodHandler) wpas_dbus_handler_nan_update_publish, + { + { "nan_args", "a{sv}", ARG_IN }, + END_ARGS + } + }, + { "NANSubscribe", WPAS_DBUS_NEW_IFACE_INTERFACE, + (WPADBusMethodHandler) wpas_dbus_handler_nan_subscribe, + { + { "nan_args", "a{sv}", ARG_IN }, + { "subscribe_id", "i", ARG_OUT }, + END_ARGS + } + }, + { "NANCancelSubscribe", WPAS_DBUS_NEW_IFACE_INTERFACE, + (WPADBusMethodHandler) wpas_dbus_handler_nan_cancel_subscribe, + { + { "nan_args", "i", ARG_IN }, + END_ARGS + } + }, + { "NANTransmit", WPAS_DBUS_NEW_IFACE_INTERFACE, + (WPADBusMethodHandler) wpas_dbus_handler_nan_transmit, + { + { "nan_args", "a{sv}", ARG_IN }, + END_ARGS + } + }, +#endif /* CONFIG_NAN_USD */ #ifdef CONFIG_TDLS { "TDLSDiscover", WPAS_DBUS_NEW_IFACE_INTERFACE, (WPADBusMethodHandler) wpas_dbus_handler_tdls_discover, @@ -4048,6 +4094,43 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = { END_ARGS } }, +#ifdef CONFIG_NAN_USD + { "NANDiscoveryResult", WPAS_DBUS_NEW_IFACE_INTERFACE, + { + { "success", "b", ARG_OUT }, + { "args", "a{sv}", ARG_OUT }, + END_ARGS + } + }, + { "NANReplied", WPAS_DBUS_NEW_IFACE_INTERFACE, + { + { "success", "b", ARG_OUT }, + { "args", "a{sv}", ARG_OUT }, + END_ARGS + } + }, + { "NANReceive", WPAS_DBUS_NEW_IFACE_INTERFACE, + { + { "nanrx", "a{sv}", ARG_OUT }, + END_ARGS + } + }, + { "NANPublishTerminated", WPAS_DBUS_NEW_IFACE_INTERFACE, + { + { "publish_id", "i", ARG_OUT }, + { "reason", "i", ARG_OUT }, + END_ARGS + } + }, + { "NANSubscribeTerminated", WPAS_DBUS_NEW_IFACE_INTERFACE, + { + { "subscribe_id", "i", ARG_OUT }, + { "reason", "i", ARG_OUT }, + END_ARGS + } + }, + +#endif /* CONFIG_NAN_USD */ { "BSSAdded", WPAS_DBUS_NEW_IFACE_INTERFACE, { { "path", "o", ARG_OUT }, @@ -5253,3 +5336,249 @@ void wpas_dbus_signal_hs20_t_c_acceptance(struct wpa_supplicant *wpa_s, dbus_message_unref(msg); } #endif /* CONFIG_HS20 */ + + +#ifdef CONFIG_NAN_USD +/** + * wpas_dbus_signal_nan_discoveryresult - Send NAN discovery result signal + * @wpa_s: %wpa_supplicant network interface data + * @subscribe_id: Subscribe id of the session + * @peer_publish_id: Publish id of the sender + * @peer_addr: MAC address of the peer device + * @ssi: Service specific information payload + * @ssi_len: Length of the SSI field + * + * Notify the discovery-result + */ +void wpas_dbus_signal_nan_discovery_result(struct wpa_supplicant *wpa_s, + int subscribe_id, + int peer_publish_id, + const u8 *peer_addr, + bool fsd, bool fsd_gas, + const u8 *ssi, size_t ssi_len) +{ + 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 interface is not turned on */ + if (!iface || !wpa_s->dbus_new_path) + return; + msg = dbus_message_new_signal(wpa_s->dbus_new_path, + WPAS_DBUS_NEW_IFACE_INTERFACE, + "NANDiscoveryResult"); + if (!msg) + return; + + dbus_message_iter_init_append(msg, &iter); + succ = TRUE; + disc_info.subscribe_id = subscribe_id; + disc_info.peer_publish_id = peer_publish_id; + os_memcpy(disc_info.peer_addr, peer_addr, ETH_ALEN); + disc_info.fsd = fsd; + disc_info.fsd_gas = fsd_gas; + disc_info.ssi_len = ssi_len; + + 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_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_nan_replied - Send NAN Replied signal + * @wpa_s: %wpa_supplicant network interface data + * @publish_id: Publish id of the session + * @peer_subscribe_id: Subscribe id of the sender + * @peer_addr: MAC address of the peer device + * @ssi: Service specific information payload + * @ssi_len: Length of the SSI field + * + * Notify the nan-reply + */ +void wpas_dbus_signal_nan_replied(struct wpa_supplicant *wpa_s, + int publish_id, + int peer_subscribe_id, + const u8 *peer_addr, + const u8 *ssi, size_t ssi_len) +{ + struct wpas_dbus_priv *iface; + DBusMessage *msg; + DBusMessageIter iter, dict_iter; + dbus_bool_t succ; + struct wpa_dbus_reply_info reply_info; + + iface = wpa_s->global->dbus; + /* Do nothing if the interface is not turned on */ + if (!iface || !wpa_s->dbus_new_path) + return; + + msg = dbus_message_new_signal(wpa_s->dbus_new_path, + WPAS_DBUS_NEW_IFACE_INTERFACE, + "NANReplied"); + if (!msg) + return; + + dbus_message_iter_init_append(msg, &iter); + succ = TRUE; + reply_info.publish_id = publish_id; + reply_info.peer_subscribe_id = peer_subscribe_id; + os_memcpy(reply_info.peer_addr, peer_addr, ETH_ALEN); + reply_info.ssi_len = ssi_len; + + 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, "reply_info", + (const char *) &reply_info, + sizeof(reply_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_nan_receive - Send receive NAN USD packet signal + * @wpa_s: %wpa_supplicant network interface data + * @id: Subscribe id + * @peer_id: Id of the sender + * @peer_addr: address of the sender + * @ssi: Service specific information payload + * @ssi_len: Length of the SSID + * + * Notify while getting the follow-up packet + */ +void wpas_dbus_signal_nan_receive(struct wpa_supplicant *wpa_s, + int id, int peer_id, const u8 *peer_addr, + const u8 *ssi, size_t ssi_len) +{ + 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 interface is not turned on */ + if (!iface || !wpa_s->dbus_new_path) + return; + + msg = dbus_message_new_signal(wpa_s->dbus_new_path, + WPAS_DBUS_NEW_IFACE_INTERFACE, + "NANReceive"); + if (!msg) + return; + + dbus_message_iter_init_append(msg, &iter); + nanrx_info.id = id; + nanrx_info.peer_id = peer_id; + os_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_nan_publish_terminated - Send publish-terminated signal + * @wpa_s: %wpa_supplicant network interface data + * @publish_id: The publish_id of the session + * @reason: The reason of the termination + * + * Notify while the session is expired + */ +void wpas_dbus_signal_nan_publish_terminated(struct wpa_supplicant *wpa_s, + int publish_id, int reason) +{ + struct wpas_dbus_priv *iface; + DBusMessage *msg; + dbus_int32_t dpub_id = publish_id; + dbus_int32_t dreason = reason; + + iface = wpa_s->global->dbus; + /* Do nothing if the interface is not turned on */ + if (!iface || !wpa_s->dbus_new_path) + return; + + msg = dbus_message_new_signal(wpa_s->dbus_new_path, + WPAS_DBUS_NEW_IFACE_INTERFACE, + "NANPublishTerminated"); + if (!msg) + return; + + if (!dbus_message_append_args(msg, DBUS_TYPE_INT32, &dpub_id, + DBUS_TYPE_INVALID) || + !dbus_message_append_args(msg, DBUS_TYPE_INT32, &dreason, + DBUS_TYPE_INVALID)) + 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_subscribe_terminated - Send subscribe-terminated signal + * @wpa_s: %wpa_supplicant network interface data + * @subscribe_id: The subscribe_id of the session + * @reason: The reason of the termination + * + * Notify while the session is expired. + */ +void wpas_dbus_signal_nan_subscribe_terminated(struct wpa_supplicant *wpa_s, + int subscribe_id, int reason) +{ + struct wpas_dbus_priv *iface; + DBusMessage *msg; + dbus_int32_t dsub_id = subscribe_id; + dbus_int32_t dreason = reason; + + iface = wpa_s->global->dbus; + /* Do nothing if the interface is not turned on */ + if (!iface || !wpa_s->dbus_new_path) + return; + + msg = dbus_message_new_signal(wpa_s->dbus_new_path, + WPAS_DBUS_NEW_IFACE_INTERFACE, + "NANSubscribeTerminated"); + if (!msg) + return; + + if (!dbus_message_append_args(msg, DBUS_TYPE_INT32, &dsub_id, + DBUS_TYPE_INVALID) || + !dbus_message_append_args(msg, DBUS_TYPE_INT32, &dreason, + DBUS_TYPE_INVALID)) + wpa_printf(MSG_ERROR, "dbus: Failed to construct signal"); + else + dbus_connection_send(iface->con, msg, NULL); + dbus_message_unref(msg); +} + +#endif /* CONFIG_NAN_USD */ diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h index 1db5fe8ae..9751eef80 100644 --- a/wpa_supplicant/dbus/dbus_new.h +++ b/wpa_supplicant/dbus/dbus_new.h @@ -285,6 +285,24 @@ void wpas_dbus_signal_anqp_query_done(struct wpa_supplicant *wpa_s, const u8 *dst, const char *result); void wpas_dbus_signal_hs20_t_c_acceptance(struct wpa_supplicant *wpa_s, const char *url); +void wpas_dbus_signal_nan_discovery_result(struct wpa_supplicant *wpa_s, + int subscribe_id, + int peer_publish_id, + const u8 *peer_addr, + bool fsd, bool fsd_gas, + const u8 *ssi, size_t ssi_len); +void wpas_dbus_signal_nan_replied(struct wpa_supplicant *wpa_s, + int publish_id, + int peer_subscribe_id, + const u8 *peer_addr, + const u8 *ssi, size_t ssi_len); +void wpas_dbus_signal_nan_receive(struct wpa_supplicant *wpa_s, + int id, int peer_id, const u8 *peer_addr, + const u8 *ssi, size_t ssi_len); +void wpas_dbus_signal_nan_publish_terminated(struct wpa_supplicant *wpa_s, + int publish_id, int reason); +void wpas_dbus_signal_nan_subscribe_terminated(struct wpa_supplicant *wpa_s, + int subscribe_id, int reason); #else /* CONFIG_CTRL_IFACE_DBUS_NEW */ @@ -668,6 +686,43 @@ void wpas_dbus_signal_hs20_t_c_acceptance(struct wpa_supplicant *wpa_s, { } +static inline void +wpas_dbus_signal_nan_discovery_result(struct wpa_supplicant *wpa_s, + int subscribe_id, + int peer_publish_id, const u8 *peer_addr, + bool fsd, bool fsd_gas, + const u8 *ssi, size_t ssi_len) +{ +} + +static inline void +wpas_dbus_signal_nan_replied(struct wpa_supplicant *wpa_s, + int publish_id, + int peer_subscribe_id, const u8 *peer_addr, + const u8 *ssi, size_t ssi_len) +{ +} + + +static inline void +wpas_dbus_signal_nan_receive(struct wpa_supplicant *wpa_s, + int id, int peer_id, const u8 *peer_addr, + const u8 *ssi, size_t ssi_len) +{ +} + +static inline void +wpas_dbus_signal_nan_publish_terminated(struct wpa_supplicant *wpa_s, + int publish_id, int reason) +{ +} + +static inline void +wpas_dbus_signal_nan_subscribe_terminated(struct wpa_supplicant *wpa_s, + int subscribe_id, int reason) +{ +} + #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */ #endif /* CTRL_IFACE_DBUS_H_NEW */ diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c index 52e35a770..cc5119313 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.c +++ b/wpa_supplicant/dbus/dbus_new_handlers.c @@ -12,6 +12,7 @@ #include "common.h" #include "common/ieee802_11_defs.h" +#include "common/nan_de.h" #include "eap_peer/eap_methods.h" #include "eapol_supp/eapol_supp_sm.h" #include "rsn_supp/wpa.h" @@ -27,6 +28,7 @@ #include "../autoscan.h" #include "../ap.h" #include "../interworking.h" +#include "../nan_usd.h" #include "dbus_new_helpers.h" #include "dbus_new.h" #include "dbus_new_handlers.h" @@ -2814,6 +2816,640 @@ DBusMessage * wpas_dbus_handler_eap_logon(DBusMessage *message, } +#ifdef CONFIG_NAN_USD +#define MAX_NAN_FREQS 255 + +static int wpas_dbus_get_nan_items_vary(DBusMessage *message, DBusMessageIter *var, + void* pitem, DBusMessage **reply, int itype, u32 dat_buf_len, u16 ilen) +{ + int rtype = dbus_message_iter_get_arg_type(var); + if (rtype == DBUS_TYPE_VARIANT) { + DBusMessageIter subiter; + dbus_message_iter_recurse(var, &subiter); + dbus_message_iter_next(var); + return wpas_dbus_get_nan_items_vary(message, &subiter, pitem, reply, itype, dat_buf_len, ilen); + } else if (rtype == DBUS_TYPE_ARRAY) { + DBusMessageIter array_iter; + int offset=0; + int arytype; + dbus_message_iter_recurse(var, &array_iter); + dbus_message_iter_next(var); + // Loop through the array + arytype = dbus_message_iter_get_arg_type(&array_iter); + if (arytype != itype) { + wpa_printf(MSG_ERROR, "Item type: (exp, get)=(%c, %c)", itype, arytype); + return false; + } + while ((arytype = dbus_message_iter_get_arg_type(&array_iter)) != DBUS_TYPE_INVALID) { + if (arytype != itype) { + wpa_printf(MSG_ERROR, "Item type: (exp, get)=(%c, %c)", itype, arytype); + return false; + } + dbus_message_iter_get_basic(&array_iter, (pitem+offset)); + dbus_message_iter_next(&array_iter); + offset+= ilen; + if ((offset+ilen) > dat_buf_len) { + wpa_printf(MSG_WARNING, "end_of_buffer(%d, %d, %u)", offset, ilen, dat_buf_len); + break; + } + } + } + return 0; +} + +static int wpas_dbus_get_nan_items(DBusMessage *message, + DBusMessageIter *var, + void *pitem, + DBusMessage **reply, + int itype) +{ + int rtype = dbus_message_iter_get_arg_type(var); + if (rtype != itype) { + wpa_printf(MSG_DEBUG, "%s[dbus]: Incorrect Type, exp: %d, got: %d", + __func__, itype, rtype); + *reply = wpas_dbus_error_invalid_args( + message, "Wrong Type value type. Boolean required"); + return -1; + } + dbus_message_iter_get_basic(var, pitem); + return 0; +} + +/* + * 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) +{ + int publish_id; + /* Parameters from DBUS */ + struct wpabuf *service_name = NULL; + char *psrv_name; + enum nan_service_protocol_type srv_proto_type=0; + u16 freq_list_len=0; + u16 ssi_len=0; + bool p2p=false; + + DBusMessage *reply = NULL; + DBusMessageIter iter, dict_iter, entry_iter, variant_iter; + char *key = NULL; + + struct nan_publish_params params = { + .unsolicited = true, + .solicited = true, + .solicited_multicast = false, + .disable_events = false, + .fsd = true, + .fsd_gas = false, + .announcement_period = 0, + }; + struct wpabuf *freq_list = NULL; + struct wpabuf *ssi = NULL; + + wpa_printf(MSG_INFO, "DBUS NAN_PUBLISH:"); + // Get the parameters from dbus + dbus_message_iter_init(message, &iter); + dbus_message_iter_recurse(&iter, &dict_iter); + while (dbus_message_iter_get_arg_type(&dict_iter) == DBUS_TYPE_DICT_ENTRY) { + dbus_message_iter_recurse(&dict_iter, &entry_iter); + dbus_message_iter_get_basic(&entry_iter, &key); + dbus_message_iter_next(&entry_iter); + dbus_message_iter_recurse(&entry_iter, &variant_iter); + if (os_strcmp(key, "srv_name") == 0) { + if (wpas_dbus_get_nan_items(message, &variant_iter, + (void*)&psrv_name, &reply, DBUS_TYPE_STRING) < 0) + goto fail; + service_name = wpabuf_alloc(os_strlen(psrv_name)+1); + if (service_name == NULL) + goto fail; + os_strlcpy((char*)service_name->buf, psrv_name, service_name->size); + service_name->used = os_strlen((char*)service_name->buf); + } else if (os_strcmp(key, "proto_type") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + &srv_proto_type, + &reply, DBUS_TYPE_BYTE) < 0) + goto fail; + } else if (os_strcmp(key, "solicited") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + ¶ms.solicited, + &reply, DBUS_TYPE_BOOLEAN) < 0) + goto fail; + } else if (os_strcmp(key, "unsolicited") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + ¶ms.unsolicited, + &reply, DBUS_TYPE_BOOLEAN) < 0) + goto fail; + } else if (os_strcmp(key, "solicited_mcast") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + ¶ms.solicited_multicast, + &reply, DBUS_TYPE_BOOLEAN) < 0) + goto fail; + } else if (os_strcmp(key, "ttl") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + ¶ms.ttl, + &reply, DBUS_TYPE_UINT16) < 0) + goto fail; + } else if (os_strcmp(key, "disable_event") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + ¶ms.disable_events, + &reply, DBUS_TYPE_BOOLEAN) < 0) + goto fail; + } else if (os_strcmp(key, "fsd") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + ¶ms.fsd, + &reply, DBUS_TYPE_BOOLEAN) < 0) + goto fail; + } else if (os_strcmp(key, "fsd_gas") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + ¶ms.fsd_gas, + &reply, DBUS_TYPE_BOOLEAN) < 0) + goto fail; + } else if (os_strcmp(key, "freq") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + ¶ms.freq, + &reply, DBUS_TYPE_UINT16) < 0) + goto fail; + } else if (os_strcmp(key, "announce_period") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + ¶ms.announcement_period, + &reply, DBUS_TYPE_UINT32) < 0) + goto fail; + } else if (os_strcmp(key, "p2p") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + &p2p, + &reply, DBUS_TYPE_BOOLEAN) < 0) + goto fail; + } else if (os_strcmp(key, "ssi_len") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + &ssi_len, + &reply, DBUS_TYPE_UINT16) < 0) + goto fail; + } else if (os_strcmp(key, "freq_list_len") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + &freq_list_len, + &reply, DBUS_TYPE_UINT16) < 0) + goto fail; + } + else if (os_strcmp(key, "ssi") == 0) { + if (ssi_len > 0) { + ssi = wpabuf_alloc(ssi_len); + if (ssi == NULL) { + goto fail; + } + if (wpas_dbus_get_nan_items_vary(message, &variant_iter, + ssi->buf, &reply, DBUS_TYPE_BYTE, + ssi_len, 1) < 0) { + wpa_printf(MSG_ERROR, "Error while fetching ssi"); + goto fail; + } + ssi->used = ssi_len; + } + } + else if (os_strcmp(key, "freq_list") == 0) { + if (freq_list_len > 0) { + if (freq_list_len == MAX_NAN_FREQS) { + params.freq_list = wpas_nan_usd_all_freqs(wpa_s); + } else if (freq_list_len > 0) { + freq_list = wpabuf_alloc(freq_list_len); + if (freq_list == NULL) { + goto fail; + } + if (wpas_dbus_get_nan_items_vary(message, &variant_iter, + freq_list->buf, &reply, DBUS_TYPE_UINT16, + (sizeof(u16)*freq_list_len), + sizeof(u16)) < 0) { + wpa_printf(MSG_ERROR, "Error while fetching freq_list"); + goto fail; + } + params.freq_list = (int *)freq_list->buf; + } + } + } + dbus_message_iter_next(&dict_iter); + } + + publish_id = wpas_nan_usd_publish(wpa_s, (char*)service_name->buf, srv_proto_type, + ssi, ¶ms, p2p); + 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); + wpabuf_free(ssi); + wpabuf_free(freq_list); + wpabuf_free(service_name); + return reply; + } +fail: + wpabuf_free(ssi); + wpabuf_free(freq_list); + wpabuf_free(service_name); + return wpas_dbus_error_unknown_error( + message, "error publishing nan-usd"); +} + +/* + * wpas_dbus_handler_nan_cancel_publish - Cancel the publish + * @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 "NANCancelPublish" method call of network interface. + */ +DBusMessage * wpas_dbus_handler_nan_cancel_publish(DBusMessage *message, + struct wpa_supplicant *wpa_s) +{ + int publish_id = -1; + + wpa_printf(MSG_INFO, "DBUS NAN_CANCEL_PUBLISH:"); + if (!dbus_message_get_args(message, NULL, + DBUS_TYPE_INT32, &publish_id, + DBUS_TYPE_INVALID)) { + wpa_printf(MSG_DEBUG, " DBUS NAN_CANCEL_PUBLISH, failed to get args "); + return NULL; + } + + if ((!wpa_s->nan_de) || (publish_id == -1)) + return NULL; + wpa_printf(MSG_INFO, "DBUS NAN_CANCEL_PUBLISH: %d", publish_id); + nan_de_cancel_publish(wpa_s->nan_de, publish_id); + return NULL; +} + +/* + * wpas_dbus_handler_nan_update_publish - Update the publish ssi + * @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 "NANUpdatePublish" method call of network interface. + */ +DBusMessage * wpas_dbus_handler_nan_update_publish(DBusMessage *message, + struct wpa_supplicant *wpa_s) +{ + int publish_id = -1; + u16 ssi_len; + struct wpabuf *ssi = NULL; + DBusMessage *reply = NULL; + DBusMessageIter iter, dict_iter, entry_iter, variant_iter; + char *key = NULL; + + wpa_printf(MSG_INFO, "DBUS NAN_UPDATE_PUBLISH:"); + // Get the parameters from dbus + dbus_message_iter_init(message, &iter); + dbus_message_iter_recurse(&iter, &dict_iter); + while (dbus_message_iter_get_arg_type(&dict_iter) == + DBUS_TYPE_DICT_ENTRY) { + dbus_message_iter_recurse(&dict_iter, &entry_iter); + dbus_message_iter_get_basic(&entry_iter, &key); + dbus_message_iter_next(&entry_iter); + dbus_message_iter_recurse(&entry_iter, &variant_iter); + if (os_strcmp(key, "publish_id") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + &publish_id, + &reply, DBUS_TYPE_INT32) < 0) + goto fail; + } else if (os_strcmp(key, "ssi_len") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + &ssi_len, + &reply, DBUS_TYPE_UINT16) < 0) + goto fail; + } else if (os_strcmp(key, "ssi") == 0) { + if (ssi_len > 0) { + ssi = wpabuf_alloc(ssi_len); + if (ssi == NULL) { + goto fail; + } + if (wpas_dbus_get_nan_items_vary(message, &variant_iter, + ssi->buf, &reply, DBUS_TYPE_BYTE, + ssi_len, 1) < 0) { + wpa_printf(MSG_ERROR, "Error while fetching ssi"); + goto fail; + } + ssi->used = ssi_len; + } + } + dbus_message_iter_next(&dict_iter); + } + if ((!wpa_s->nan_de) || (publish_id == -1)) + return NULL; + wpa_printf(MSG_INFO, "DBUS NAN_UPDATE_PUBLISH: %d", publish_id); + nan_de_update_publish(wpa_s->nan_de, publish_id, ssi); + + return NULL; +fail: + wpabuf_free(ssi); + return wpas_dbus_error_unknown_error( + message, "error updating nan-usd publish ssi"); +} + +/* + * 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) +{ + int subscribe_id; + struct nan_subscribe_params params = { + .active = true, + .query_period = 0, + }; + struct wpabuf *service_name = NULL; + char *psrv_name; + enum nan_service_protocol_type srv_proto_type=0; + bool p2p=false; + u16 ssi_len=0; + u16 freq_list_len=0; + struct wpabuf *ssi = NULL; + struct wpabuf *freq_list = NULL; + DBusMessage *reply = NULL; + DBusMessageIter iter, dict_iter, entry_iter, variant_iter; + char *key = NULL; + + wpa_printf(MSG_INFO, "DBUS NAN_SUBSCRIBE: "); + os_memset(¶ms, 0, sizeof(params)); + + // Get the parameters from dbus + dbus_message_iter_init(message, &iter); + dbus_message_iter_recurse(&iter, &dict_iter); + while (dbus_message_iter_get_arg_type(&dict_iter) == + DBUS_TYPE_DICT_ENTRY) { + dbus_message_iter_recurse(&dict_iter, &entry_iter); + dbus_message_iter_get_basic(&entry_iter, &key); + dbus_message_iter_next(&entry_iter); + dbus_message_iter_recurse(&entry_iter, &variant_iter); + if (os_strcmp(key, "srv_name") == 0) { + if (wpas_dbus_get_nan_items(message, &variant_iter, + (void*)&psrv_name, &reply, DBUS_TYPE_STRING) < 0) + goto fail; + service_name = wpabuf_alloc(os_strlen(psrv_name)+1); + wpa_printf(MSG_INFO, "psrv_name len: %lu, %lu", os_strlen(psrv_name), + service_name->size); + if (service_name == NULL) { + goto fail; + } + os_strlcpy((char*)service_name->buf, psrv_name, service_name->size); + service_name->used = os_strlen((char*)service_name->buf); + wpa_printf(MSG_INFO, "service_name:[%s], %lu, %lu", service_name->buf, + service_name->used, os_strlen(psrv_name)); + } else if (os_strcmp(key, "proto_type") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + &srv_proto_type, + &reply, DBUS_TYPE_BYTE) < 0) + goto fail; + } else if (os_strcmp(key, "is_active") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + ¶ms.active, + &reply, DBUS_TYPE_BOOLEAN) < 0) + goto fail; + } else if (os_strcmp(key, "p2p") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + &p2p, + &reply, DBUS_TYPE_BOOLEAN) < 0) + goto fail; + } else if (os_strcmp(key, "ttl") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + ¶ms.ttl, + &reply, DBUS_TYPE_UINT16) < 0) + goto fail; + } else if (os_strcmp(key, "freq") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + ¶ms.freq, + &reply, DBUS_TYPE_UINT16) < 0) + goto fail; + } else if (os_strcmp(key, "query_period") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + ¶ms.query_period, + &reply, DBUS_TYPE_UINT32) < 0) + goto fail; + } else if (os_strcmp(key, "ssi_len") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + &ssi_len, + &reply, DBUS_TYPE_UINT16) < 0) + goto fail; + } else if (os_strcmp(key, "freq_list_len") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + &freq_list_len, + &reply, DBUS_TYPE_UINT16) < 0) + goto fail; + } else if (os_strcmp(key, "ssi") == 0) { + if (ssi_len > 0) { + ssi = wpabuf_alloc(ssi_len); + if (ssi == NULL) { + goto fail; + } + if (wpas_dbus_get_nan_items_vary(message, &variant_iter, ssi->buf, + &reply, DBUS_TYPE_BYTE, ssi_len, 1) < 0) { + wpa_printf(MSG_ERROR, "Error while fetching ssi"); + goto fail; + } + ssi->used = ssi_len; + } + } else if (os_strcmp(key, "freq_list") == 0) { + if (freq_list_len > 0) { + if (freq_list_len == MAX_NAN_FREQS) { + params.freq_list = wpas_nan_usd_all_freqs(wpa_s); + } else if (freq_list_len > 0) { + freq_list = wpabuf_alloc(freq_list_len); + if (freq_list == NULL) { + goto fail; + } + if (wpas_dbus_get_nan_items_vary(message, &variant_iter, freq_list->buf, + &reply, DBUS_TYPE_UINT16, (sizeof(u16)*freq_list_len), + sizeof(u16)) < 0) { + wpa_printf(MSG_ERROR, "Error while fetching freq_list"); + goto fail; + } + params.freq_list = (int *)freq_list->buf; + } + } + } + dbus_message_iter_next(&dict_iter); + } + + subscribe_id = wpas_nan_usd_subscribe(wpa_s, (char*)service_name->buf, + srv_proto_type, ssi, + ¶ms, p2p); + if (subscribe_id > 0) { + DBusMessage *reply; + reply = dbus_message_new_method_return(message); + dbus_message_append_args(reply, DBUS_TYPE_INT32, + &subscribe_id, DBUS_TYPE_INVALID); + wpabuf_free(ssi); + wpabuf_free(freq_list); + wpabuf_free(service_name); + return reply; + } +fail: + wpabuf_free(ssi); + wpabuf_free(freq_list); + wpabuf_free(service_name); + return wpas_dbus_error_unknown_error( + message, "error subscribing nan-usd"); +} + + +/* + * wpas_dbus_handler_nan_cancel_subscribe - Cancel the subscription + * @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 "NANCancelSubscribe" method call of network interface. + */ +DBusMessage * +wpas_dbus_handler_nan_cancel_subscribe(DBusMessage *message, + struct wpa_supplicant *wpa_s) +{ + int subscribe_id = -1; + wpa_printf(MSG_INFO, "DBUS NAN_CANCEL_SUBSCRIBE:"); + + if (!dbus_message_get_args(message, NULL, + DBUS_TYPE_INT32, &subscribe_id, + DBUS_TYPE_INVALID)) { + wpa_printf(MSG_DEBUG, " DBUS NAN_CANCEL_SUBSCRIBE, failed to get args "); + return NULL; + } + + if ((!wpa_s->nan_de)||(subscribe_id == -1)) + return NULL; + nan_de_cancel_subscribe(wpa_s->nan_de, subscribe_id); + 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. + */ +DBusMessage * wpas_dbus_handler_nan_transmit(DBusMessage *message, + struct wpa_supplicant *wpa_s) +{ + int handle = 0; + int req_instance_id = 0; + struct wpabuf *ssi = NULL; + u8 peer_addr[ETH_ALEN]; + char* paddr_msg; + int ret = -1; + u16 ssi_len; + + DBusMessage *reply = NULL; + DBusMessageIter iter, dict_iter, entry_iter, variant_iter; + char *key = NULL; + + wpa_printf(MSG_INFO, "DBUS NAN_TRANSMIT:"); + // Get the parameters from dbus + dbus_message_iter_init(message, &iter); + dbus_message_iter_recurse(&iter, &dict_iter); + while (dbus_message_iter_get_arg_type(&dict_iter) == + DBUS_TYPE_DICT_ENTRY) { + dbus_message_iter_recurse(&dict_iter, &entry_iter); + dbus_message_iter_get_basic(&entry_iter, &key); + dbus_message_iter_next(&entry_iter); + dbus_message_iter_recurse(&entry_iter, &variant_iter); + if (os_strcmp(key, "handle") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + &handle, + &reply, DBUS_TYPE_BYTE) < 0) + goto fail; + } else if (os_strcmp(key, "req_instance_id") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + &req_instance_id, + &reply, DBUS_TYPE_BYTE) < 0) + goto fail; + } else if (os_strcmp(key, "peer_addr") == 0) { + if (wpas_dbus_get_nan_items(message, &variant_iter, + (void*)&paddr_msg, &reply, DBUS_TYPE_STRING) < 0) + goto fail; + if (hwaddr_aton(paddr_msg, peer_addr) < 0) { + wpa_printf(MSG_ERROR, "Error while converting peer address"); + goto fail; + } + } else if (os_strcmp(key, "ssi_len") == 0) { + if (wpas_dbus_get_nan_items(message, + &variant_iter, + &ssi_len, + &reply, DBUS_TYPE_UINT16) < 0) + goto fail; + } else if (os_strcmp(key, "ssi") == 0) { + if (ssi_len > 0) { + ssi = wpabuf_alloc(ssi_len); + if (ssi == NULL) { + goto fail; + } + if (wpas_dbus_get_nan_items_vary(message, &variant_iter, ssi->buf, + &reply, DBUS_TYPE_BYTE, ssi_len, 1) < 0) { + wpa_printf(MSG_ERROR, "Error while fetching ssi"); + goto fail; + } + ssi->used = ssi_len; + } + } + dbus_message_iter_next(&dict_iter); + } + + 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 wpas_dbus_error_unknown_error( + message, "error sending follow-up packets"); +} + +#endif /* CONFIG_NAN_USD */ + + #ifdef CONFIG_TDLS static int get_peer_hwaddr_helper(DBusMessage *message, const char *func_name, diff --git a/wpa_supplicant/dbus/dbus_new_handlers.h b/wpa_supplicant/dbus/dbus_new_handlers.h index 7faf70a77..a5260907a 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.h +++ b/wpa_supplicant/dbus/dbus_new_handlers.h @@ -290,4 +290,18 @@ DBusMessage * wpas_dbus_handler_subscribe_preq( DBusMessage * wpas_dbus_handler_unsubscribe_preq( DBusMessage *message, struct wpa_supplicant *wpa_s); +DBusMessage * wpas_dbus_handler_nan_publish(DBusMessage *message, + struct wpa_supplicant *wpa_s); +DBusMessage * wpas_dbus_handler_nan_cancel_publish( + DBusMessage *message, struct wpa_supplicant *wpa_s); +DBusMessage * wpas_dbus_handler_nan_update_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_cancel_subscribe(DBusMessage *message, + struct wpa_supplicant *wpa_s); +DBusMessage * wpas_dbus_handler_nan_transmit(DBusMessage *message, + struct wpa_supplicant *wpa_s); + #endif /* CTRL_IFACE_DBUS_HANDLERS_NEW_H */ diff --git a/wpa_supplicant/dbus/dbus_new_helpers.h b/wpa_supplicant/dbus/dbus_new_helpers.h index c8d44a00b..82681dd56 100644 --- a/wpa_supplicant/dbus/dbus_new_helpers.h +++ b/wpa_supplicant/dbus/dbus_new_helpers.h @@ -112,6 +112,29 @@ struct wpa_dbus_property_desc { #define WPA_DBUS_PROPERTIES_SET "Set" #define WPA_DBUS_PROPERTIES_GETALL "GetAll" +struct wpa_dbus_discov_info { + u32 subscribe_id; + u32 peer_publish_id; + u8 peer_addr[ETH_ALEN]; + bool fsd; + bool fsd_gas; + u32 ssi_len; +}; + +struct wpa_dbus_reply_info { + u32 publish_id; + u32 peer_subscribe_id; + u8 peer_addr[ETH_ALEN]; + u32 ssi_len; +}; + +struct wpa_dbus_nanrx_info { + u32 id; + u32 peer_id; + u8 peer_addr[ETH_ALEN]; + u32 ssi_len; +}; + void free_dbus_object_desc(struct wpa_dbus_object_desc *obj_dsc); int wpa_dbus_ctrl_iface_init(struct wpas_dbus_priv *iface, char *dbus_path, diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c index 8c1a817f9..205be1c8a 100644 --- a/wpa_supplicant/notify.c +++ b/wpa_supplicant/notify.c @@ -1094,6 +1094,11 @@ void wpas_notify_nan_discovery_result(struct wpa_supplicant *wpa_s, subscribe_id, peer_publish_id, MAC2STR(peer_addr), fsd, fsd_gas, srv_proto_type, ssi_hex); os_free(ssi_hex); + + wpas_dbus_signal_nan_discovery_result(wpa_s, subscribe_id, + peer_publish_id, peer_addr, + fsd, fsd_gas, + ssi, ssi_len); } @@ -1116,6 +1121,10 @@ void wpas_notify_nan_replied(struct wpa_supplicant *wpa_s, publish_id, MAC2STR(peer_addr), peer_subscribe_id, srv_proto_type, ssi_hex); os_free(ssi_hex); + + wpas_dbus_signal_nan_replied(wpa_s, publish_id, + peer_subscribe_id, peer_addr, + ssi, ssi_len); } @@ -1134,6 +1143,9 @@ void wpas_notify_nan_receive(struct wpa_supplicant *wpa_s, int id, "id=%d peer_instance_id=%d address=" MACSTR " ssi=%s", id, peer_instance_id, MAC2STR(peer_addr), ssi_hex); os_free(ssi_hex); + + wpas_dbus_signal_nan_receive(wpa_s, id, peer_instance_id, peer_addr, + ssi, ssi_len); } @@ -1159,6 +1171,8 @@ void wpas_notify_nan_publish_terminated(struct wpa_supplicant *wpa_s, wpa_msg(wpa_s, MSG_INFO, NAN_PUBLISH_TERMINATED "publish_id=%d reason=%s", publish_id, nan_reason_txt(reason)); + + wpas_dbus_signal_nan_publish_terminated(wpa_s, publish_id, reason); } @@ -1169,6 +1183,8 @@ void wpas_notify_nan_subscribe_terminated(struct wpa_supplicant *wpa_s, wpa_msg(wpa_s, MSG_INFO, NAN_SUBSCRIBE_TERMINATED "subscribe_id=%d reason=%s", subscribe_id, nan_reason_txt(reason)); + + wpas_dbus_signal_nan_subscribe_terminated(wpa_s, subscribe_id, reason); } #endif /* CONFIG_NAN_USD */