]> Git Repo - esp-hosted.git/commitdiff
hosted_ng: initial changes for AP mode support
authorKapil Gupta <[email protected]>
Thu, 27 Jun 2024 20:13:39 +0000 (04:13 +0800)
committerYogesh Mantri <[email protected]>
Thu, 27 Jun 2024 20:13:39 +0000 (04:13 +0800)
58 files changed:
esp_hosted_ng/esp/esp_driver/esp_wifi_libs/lib.tgz
esp_hosted_ng/esp/esp_driver/esp_wifi_libs/md5sum.txt
esp_hosted_ng/esp/esp_driver/lib/esp32/libcore.a
esp_hosted_ng/esp/esp_driver/lib/esp32/libespnow.a
esp_hosted_ng/esp/esp_driver/lib/esp32/libmesh.a
esp_hosted_ng/esp/esp_driver/lib/esp32/libnet80211.a
esp_hosted_ng/esp/esp_driver/lib/esp32/libpp.a
esp_hosted_ng/esp/esp_driver/lib/esp32/libsmartconfig.a
esp_hosted_ng/esp/esp_driver/lib/esp32/libwapi.a
esp_hosted_ng/esp/esp_driver/lib/esp32c2/libcore.a
esp_hosted_ng/esp/esp_driver/lib/esp32c2/libespnow.a
esp_hosted_ng/esp/esp_driver/lib/esp32c2/libnet80211.a
esp_hosted_ng/esp/esp_driver/lib/esp32c2/libpp.a
esp_hosted_ng/esp/esp_driver/lib/esp32c2/libsmartconfig.a
esp_hosted_ng/esp/esp_driver/lib/esp32c3/libcore.a
esp_hosted_ng/esp/esp_driver/lib/esp32c3/libespnow.a
esp_hosted_ng/esp/esp_driver/lib/esp32c3/libmesh.a
esp_hosted_ng/esp/esp_driver/lib/esp32c3/libnet80211.a
esp_hosted_ng/esp/esp_driver/lib/esp32c3/libpp.a
esp_hosted_ng/esp/esp_driver/lib/esp32c3/libsmartconfig.a
esp_hosted_ng/esp/esp_driver/lib/esp32c3/libwapi.a
esp_hosted_ng/esp/esp_driver/lib/esp32c6/libcore.a
esp_hosted_ng/esp/esp_driver/lib/esp32c6/libespnow.a
esp_hosted_ng/esp/esp_driver/lib/esp32c6/libmesh.a
esp_hosted_ng/esp/esp_driver/lib/esp32c6/libnet80211.a
esp_hosted_ng/esp/esp_driver/lib/esp32c6/libpp.a
esp_hosted_ng/esp/esp_driver/lib/esp32c6/libsmartconfig.a
esp_hosted_ng/esp/esp_driver/lib/esp32c6/libwapi.a
esp_hosted_ng/esp/esp_driver/lib/esp32s2/libcore.a
esp_hosted_ng/esp/esp_driver/lib/esp32s2/libespnow.a
esp_hosted_ng/esp/esp_driver/lib/esp32s2/libmesh.a
esp_hosted_ng/esp/esp_driver/lib/esp32s2/libnet80211.a
esp_hosted_ng/esp/esp_driver/lib/esp32s2/libpp.a
esp_hosted_ng/esp/esp_driver/lib/esp32s2/libsmartconfig.a
esp_hosted_ng/esp/esp_driver/lib/esp32s2/libwapi.a
esp_hosted_ng/esp/esp_driver/lib/esp32s3/libcore.a
esp_hosted_ng/esp/esp_driver/lib/esp32s3/libespnow.a
esp_hosted_ng/esp/esp_driver/lib/esp32s3/libmesh.a
esp_hosted_ng/esp/esp_driver/lib/esp32s3/libnet80211.a
esp_hosted_ng/esp/esp_driver/lib/esp32s3/libpp.a
esp_hosted_ng/esp/esp_driver/lib/esp32s3/libsmartconfig.a
esp_hosted_ng/esp/esp_driver/lib/esp32s3/libwapi.a
esp_hosted_ng/esp/esp_driver/lib/esp_wifi_driver.h
esp_hosted_ng/esp/esp_driver/network_adapter/main/app_main.c
esp_hosted_ng/esp/esp_driver/network_adapter/main/cmd.c
esp_hosted_ng/esp/esp_driver/network_adapter/main/esp_wifi_driver.h
esp_hosted_ng/esp/esp_driver/network_adapter/main/include/adapter.h
esp_hosted_ng/esp/esp_driver/network_adapter/main/include/cmd.h
esp_hosted_ng/esp/esp_driver/network_adapter/main/include/wifi_defs.h [new file with mode: 0644]
esp_hosted_ng/host/esp_cfg80211.c
esp_hosted_ng/host/esp_cmd.c
esp_hosted_ng/host/esp_stats.c
esp_hosted_ng/host/include/adapter.h
esp_hosted_ng/host/include/esp_api.h
esp_hosted_ng/host/include/esp_cmd.h
esp_hosted_ng/host/main.c
esp_hosted_ng/host/sdio/esp_sdio.c
esp_hosted_ng/host/spi/esp_spi.c

index 369e0f890cfcefebf3512835990afc8165977649..45362ad33216e8e7d3233641351084fe92fac99d 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/esp_wifi_libs/lib.tgz and b/esp_hosted_ng/esp/esp_driver/esp_wifi_libs/lib.tgz differ
index 15e05d65402e19eebc9ef9af4d35dfb74183d6d3..7dec8bc489848933563700af17734e71e2b30b78 100644 (file)
@@ -8,44 +8,44 @@ commit: e7771c75
 
 md5sums
 -------
-445028197cc9e0c03fb0b4ba432cc230  esp32s2/libnet80211.a
-c1d75a134d0c9e0d934c79403deb168a  esp32s2/libwapi.a
-35441d446b320dae127d8beab5b5e879  esp32s2/libsmartconfig.a
-aae062a9cbba4c93c4d8997b4f5e78fb  esp32s2/libpp.a
-c1b974454407bbf2d7ea9f3098a9a833  esp32s2/libcore.a
-d3dba8252ca200daa77be18401a5b2fc  esp32s2/libmesh.a
-5f3afdf82d066152fcb94343ae2ccd18  esp32s2/libespnow.a
-1bd20886f37dc035b2b25738a2a5cf4c  esp32s3/libnet80211.a
-7ba23ff1663f9398527eadbca8c9a1c7  esp32s3/libwapi.a
-fe7a62183ba6d2116a91ad4b48d3debb  esp32s3/libsmartconfig.a
-a4d1d3073fbcc5e557c01b1648cec3c0  esp32s3/libpp.a
-c0752ced16b131a50586d9dfc1ddac1a  esp32s3/libcore.a
-5c3b93a6def256843e231632b7b6725d  esp32s3/libmesh.a
-f14eeccecc4be98eb2abe6147fb3f3ba  esp32s3/libespnow.a
-ee199019bd41ed3b144be24269475c0a  esp32/libnet80211.a
-39e6e9d7e31f3195d5359e7e4334fe94  esp32/libwapi.a
-89eb6fccb6599d50243698614138e2d8  esp32/libsmartconfig.a
-b9ff0455dbc208e811fcfd8ce5dc504d  esp32/libpp.a
-ae27e8fa312480259f0fc7109588832d  esp32/libcore.a
-93f1c3d6be5891582d7a3937535fb6b1  esp32/libmesh.a
-56741d4786340784d4c6663108c54770  esp32/libespnow.a
-0824aadaaccbe2dee83d1478fe32ee9c  esp32c3/libnet80211.a
-1662dcd62ccc31a2ff0040250b52145b  esp32c3/libwapi.a
-f881b19feaed314a0e1c7ab0f6b9e665  esp32c3/libsmartconfig.a
-4eb255416b9e79fceaf0b46ac9d060bf  esp32c3/libpp.a
-e5642dbdbfacbd8264d1f53bcdae7472  esp32c3/libcore.a
-6c992ba79582767fa17a308d0eecde8c  esp32c3/libmesh.a
-1bbc2f0b0ec86c085a33b9efcbea690f  esp32c3/libespnow.a
-446c84499ff7ddf8a5ae233053fa1ef7  esp32c2/libnet80211.a
-cef1bd13565c7a10ef33b22a20bd77de  esp32c2/libsmartconfig.a
-58ca4c4de41b6fecfdb3c470bcaebc86  esp32c2/libpp.a
-a069a2159147333854a79abd59f204c6  esp32c2/libcore.a
-bd7ca20272dd04299e73dd2407850579  esp32c2/libespnow.a
-f6ab45c03453a4ebf579688ffa5ec8cb  esp32c6/libnet80211.a
-0672b61452eb56d100b74ea29b6a6bc0  esp32c6/libwapi.a
-033bc223fdba47f2b5cdd471b66f40d9  esp32c6/libsmartconfig.a
-d8c00162e6ff20bbf3ad2c156254eb6a  esp32c6/libpp.a
-cfff5f74317b1e9014e0da39ae360bde  esp32c6/libcore.a
-9b4f0b5950bc867a4b4f518e478d3e0f  esp32c6/libmesh.a
-c8b351bcb74664c88c29a200fd90dbc8  esp32c6/libespnow.a
-be8547b4544fd1826a4d033af4e089f3  esp_wifi_driver.h
+4b4fa75b186ab306754b17685c38c28e  esp32s2/libnet80211.a
+239e5e3fea66ff60da451621aeb52942  esp32s2/libwapi.a
+fa8173d85112a5b7bceb8f145d6bd10a  esp32s2/libsmartconfig.a
+f0c58577dda25e8025039659433ced10  esp32s2/libpp.a
+f73d77e858c8e04e6db84a35a54ffe18  esp32s2/libcore.a
+9aac0fbed6df5d60078cb0ad42c55174  esp32s2/libmesh.a
+55c9fb1839ec2e87893abd6c0b2064ec  esp32s2/libespnow.a
+9d6d23a887df0af9175200e3f2d770fc  esp32s3/libnet80211.a
+add928217043b7da402e77f10f4e6637  esp32s3/libwapi.a
+c85fbad1536bfbe95fe5f7c9bb267dee  esp32s3/libsmartconfig.a
+fbfd4512c5967928ffcf591673d7d6fd  esp32s3/libpp.a
+8ceecb97c149919e1ae19d2b7bb4424c  esp32s3/libcore.a
+99280514d0b1801e6423af616b1b5d44  esp32s3/libmesh.a
+4ccd038a08e4b5256c641a31eaf5f38f  esp32s3/libespnow.a
+ebe2d94453bc46567a3f5584f5974592  esp32/libnet80211.a
+94a0d3ee079ded17bd061a15bedec7c3  esp32/libwapi.a
+6dfd8ab98b39a1196ac032b42a0f8fe6  esp32/libsmartconfig.a
+bbb26a7c9cbd2e8931dd6e6c8996dbcb  esp32/libpp.a
+15d91b212501064dcb4242a9f7aaac1a  esp32/libcore.a
+7c6fd15e506d0fa81e6da3a4cbf63e57  esp32/libmesh.a
+b3bdfca40b22570e23a2108c10d27582  esp32/libespnow.a
+bbbd6de792e2e115ba7d5cfdfa65cb59  esp32c3/libnet80211.a
+9daadf1f23160d4a30763ca9d14a192f  esp32c3/libwapi.a
+a2aa55845fa3b6622df2438dee958608  esp32c3/libsmartconfig.a
+bae69c18f72ac8120488a51a3f94a896  esp32c3/libpp.a
+a8b8afba25c8d0b991bd1662a4fe3516  esp32c3/libcore.a
+4bdd28677d5a84d5bb09a989e45b70e8  esp32c3/libmesh.a
+00b24217f8db76e23f7b22b355f067f7  esp32c3/libespnow.a
+6e4e725162331c90028c73c0e64ca1c4  esp32c2/libnet80211.a
+ff4205508465099a4f655e641cb80b31  esp32c2/libsmartconfig.a
+db5d857bda008e48276e5c40ae97f3a2  esp32c2/libpp.a
+ee5d7dfdf1083d24a7ff2f2b60bfde7c  esp32c2/libcore.a
+e16ef4762b360eae35fd6fb6cebb545a  esp32c2/libespnow.a
+77f4f9e1880293ba0ee0accc0addcb26  esp32c6/libnet80211.a
+239e314fac82dbb0e2cee739901de4a2  esp32c6/libwapi.a
+a8f1cdadd34d12d3e450150a48e764bb  esp32c6/libsmartconfig.a
+68a0edb7bedb1750fb67edb8241f8103  esp32c6/libpp.a
+a8b8afba25c8d0b991bd1662a4fe3516  esp32c6/libcore.a
+d00340f9d06eb617a3571284480b14e7  esp32c6/libmesh.a
+a928c57cc605c237c71a61574c70b5e7  esp32c6/libespnow.a
+3d5252d89bf93d5d6a831479b10d707d  esp_wifi_driver.h
index 562b99a7cf71cfe9777a6f4ad3a0763177adedf7..1723943cb6c89d419210f5e01aff17fffceca976 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32/libcore.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32/libcore.a differ
index 2b813f132f3aa91e0fc997ddf5afe523c7e28b6f..f99d9ef5a134f5fd97a34e8703d20bccab937fe2 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32/libespnow.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32/libespnow.a differ
index 41149e7009d75e4b5f4274485e5edba01ee49166..dd784a3b78ef7538321a9e19f778074fc334a3d5 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32/libmesh.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32/libmesh.a differ
index 6e5c9fcc8807bdf7e124af729d1a74ac8edc5ef6..7d518f1fcad99f29febc499e257afa89e3e87c20 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32/libnet80211.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32/libnet80211.a differ
index 0d2cd5807a95777c374ac3b256631077e85f2218..33363f3cb378efd598ace55abd8aaf5e48ecb8a6 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32/libpp.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32/libpp.a differ
index 8db56753f9c7fe783c0cf60113cfbb8fcd7ccc55..bd6a9a4aa6055cadd9da92c578e9025ddfa3811f 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32/libsmartconfig.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32/libsmartconfig.a differ
index 86f5d2f12ff9e55b30779d3d8dda03424a6a6214..b65d5d69d3e8d0db1b3f7587328d3deab5e2d6d0 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32/libwapi.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32/libwapi.a differ
index a6a8656ef13facbd4ef8fa2cfeb35ea3f46cba3d..c3bb97f72e42c6620ba4f5bffe5daa6c9d7d07b0 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32c2/libcore.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32c2/libcore.a differ
index 87751fc7a0797947610b7870e20abb7c819928d9..dcad5ed448395ce43ca4797d10f29fd033173739 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32c2/libespnow.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32c2/libespnow.a differ
index 244265978b092b917a0c5687319c1d13ba1314e1..d342e89b941b54165e0226842f1bb142c16c59d3 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32c2/libnet80211.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32c2/libnet80211.a differ
index 785ef7c5d76652ba229a62bd55a274bb35d4296e..e3b98613d882acb421c0322a691f4e9b4d7c320f 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32c2/libpp.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32c2/libpp.a differ
index dc7c1665ce554359cee8e25b1126cbc340d579a6..4c81fe9c644009c2d55bc33ae694c312c6a567c0 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32c2/libsmartconfig.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32c2/libsmartconfig.a differ
index 9261df926bfa1ee9e429ea9ae6e0f64dc3625a04..30b4c3b7e3540c7df3926d285af17b6a2d20f1f9 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32c3/libcore.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32c3/libcore.a differ
index 02b99ff0e58f8b83056ba40bf7cb44952c0cb8e1..d16a3f1a9b1fc01a10aeef43149c70cccce18f70 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32c3/libespnow.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32c3/libespnow.a differ
index 26e31380abc575ebd32f522e4696b590e6eaaf0c..349401845fa7ec00e99d02118ec5e0a926943c8e 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32c3/libmesh.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32c3/libmesh.a differ
index f358964d8d3964e112162f22aa283f429e4e1f60..063db2c32d987b914fe65bc13c27e5c41c8d5104 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32c3/libnet80211.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32c3/libnet80211.a differ
index 26617bdf5c67ba208f04e31d85c66e61972cdc9a..6760c35cdcaa04ce644d094f057ee39afd30ac57 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32c3/libpp.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32c3/libpp.a differ
index b54bf7ead1c347d5a5c95d62454490b847f52d14..f1cd8fee40876791c1317573acd56be2600f9dc0 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32c3/libsmartconfig.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32c3/libsmartconfig.a differ
index c4539f19709ece57177622d57daf7b3b9cf60729..16af1104c64892de0b706947bc62d56a73540dec 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32c3/libwapi.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32c3/libwapi.a differ
index 22e8a0f38d30b8998e2ea0df0560b0ceae629fba..30b4c3b7e3540c7df3926d285af17b6a2d20f1f9 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32c6/libcore.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32c6/libcore.a differ
index 70c8782bd702238252e4784c5d34cd936f98e63e..a579499dfc36090d31b336dba2191c141cabed24 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32c6/libespnow.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32c6/libespnow.a differ
index 8402422d1c7ddb6888add2b1ee0f4c1b35a4a5c4..dc6c1b89548dbedb4ff683bab5dfd8f6d3222eec 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32c6/libmesh.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32c6/libmesh.a differ
index 42efd1c4dc643ea4940afd234fec04f952e9751e..e94d3e30ca16d9511529bea945785ef8da874874 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32c6/libnet80211.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32c6/libnet80211.a differ
index 1f2600c9fe6c99045d40abd2a8e2473f3454182b..1d947bf551a1fdd2033b7b0afc53e09391bc2e74 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32c6/libpp.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32c6/libpp.a differ
index 397d58fedde0cb259ce17041a6161763a7096956..392ff05914bea378ac648035d09c7c2c6ab7af35 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32c6/libsmartconfig.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32c6/libsmartconfig.a differ
index bca538a5131991da931e12768652a5ecd392a2c0..1005b565402d7a045d7eb99518cea7993f38277d 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32c6/libwapi.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32c6/libwapi.a differ
index e00ffca0a53d125f6d43e2f124f53d2c3d5d51fc..391b763b24edf6d40e6802c70df30d5384c63451 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32s2/libcore.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32s2/libcore.a differ
index dbb8a3bb553aec3e8ee7853c91516c30fa6edc58..bbc79666c9c9ce392bfd903c9bf29ff1f86fc5f0 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32s2/libespnow.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32s2/libespnow.a differ
index b15d20ff0380a89a1522482cfcfffdab214073cf..5769aa63fe4eb037a2ef8d4200fef06132a52892 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32s2/libmesh.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32s2/libmesh.a differ
index 98f46269b90d090ef646a76775caffdf43d61bf8..700f3a8cffa682932d482bee92b4711df0aff71a 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32s2/libnet80211.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32s2/libnet80211.a differ
index 5354bc771fc55e80a57c93be350264dba0c9429e..ac9c8c02b554440b6ae3e7ddf010a9a1bb10ba25 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32s2/libpp.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32s2/libpp.a differ
index 84cf24b61c43ac57ceb92f8a9c94e137370615b9..8dc9b69e79a660f79fe19ae8bafc1967cd5bc0b4 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32s2/libsmartconfig.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32s2/libsmartconfig.a differ
index d11cadcfee075a4c725052b8edc5b2fd9b5f339c..3b0f549aeadf409029202592309f21c0d5e7768c 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32s2/libwapi.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32s2/libwapi.a differ
index 1426d88036f606577339a2ccc6d4d139492d14bc..8e2b50fc85d452de4731a00f9c84588d55aa6d57 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32s3/libcore.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32s3/libcore.a differ
index 0c7a3f98d1b46b14c93f5f15fe8bf71480d22813..eee1e09040fe7ed73a0bd4b718f160dff9707d90 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32s3/libespnow.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32s3/libespnow.a differ
index 5c44c38eebcc5abf22d8922b5e176e42b12df860..d7fe67b5a4b4efc32e772ca2c4a17e0150db5fc5 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32s3/libmesh.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32s3/libmesh.a differ
index 9e7de9fd2dfe9ff9e24a2a8aa4df280b4c4c8064..6df0de63ac0165da057d92db13ddd661aeac2732 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32s3/libnet80211.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32s3/libnet80211.a differ
index 586732845c63900d4d4a25929ee86178cf20dc8b..b9476cb671f9ca9bdab48fcb9dd3e0e72944a267 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32s3/libpp.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32s3/libpp.a differ
index 73794ae7da1d7c803b7f91bff1886d2ec5aee23e..bb998eac50cc034c7ff05d444ee3e2d49b1361eb 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32s3/libsmartconfig.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32s3/libsmartconfig.a differ
index 4ee0fa1cdc017de873ecbadbc33f258ad519fb9a..2facafb1164ae662c07745c812cbbf50b9cf0983 100644 (file)
Binary files a/esp_hosted_ng/esp/esp_driver/lib/esp32s3/libwapi.a and b/esp_hosted_ng/esp/esp_driver/lib/esp32s3/libwapi.a differ
index a384b367b41ccd642d38b9326fcfe06c312ee11d..c885fc66d5adc6d09e2b6a2b02cb1274da68692c 100644 (file)
@@ -133,14 +133,13 @@ struct wpa_funcs {
     int (*wpa_parse_wpa_ie)(const uint8_t *wpa_ie, size_t wpa_ie_len, wifi_wpa_ie_t *data);
     int (*wpa_config_bss)(uint8_t *bssid);
     int (*wpa_michael_mic_failure)(uint16_t is_unicast);
-    uint8_t *(*wpa3_build_sae_msg)(uint8_t *bssid, uint32_t type, size_t *len);
-    int (*wpa3_parse_sae_msg)(uint8_t *buf, size_t len, uint32_t type, uint16_t status);
     int (*wpa3_hostap_handle_auth)(uint8_t *buf, size_t len, uint32_t type, uint16_t status, uint8_t *bssid);
     int (*wpa_sta_rx_mgmt)(uint8_t type, uint8_t *frame, size_t len, uint8_t *sender, uint32_t rssi, uint8_t channel, uint64_t current_tsf);
     void (*wpa_config_done)(void);
     uint8_t *(*owe_build_dhie)(uint16_t group);
     int (*owe_process_assoc_resp)(const uint8_t *rsn_ie, size_t rsn_len, const uint8_t *dh_ie, size_t dh_len);
     int (*wpa_sta_set_ap_rsnxe)(const uint8_t *rsnxe, size_t rsnxe_ie_len);
+    int (*wpa_ap_rx_mgmt)(void *pkt, uint32_t pkt_len, uint8_t chan, int rssi, int nf);
 };
 
 struct wpa2_funcs {
@@ -296,8 +295,9 @@ bool esp_wifi_ap_notify_node_sae_auth_done(uint8_t *mac);
 bool esp_wifi_ap_is_sta_sae_reauth_node(uint8_t *mac);
 uint8_t* esp_wifi_sta_get_sae_identifier_internal(void);
 bool esp_wifi_eb_tx_status_success_internal(void *eb);
-esp_err_t esp_wifi_connect_internal(const uint8_t *bssid);
-esp_err_t esp_wifi_issue_auth_internal(uint8_t status);
-esp_err_t esp_wifi_issue_assoc_internal(uint8_t status);
+void esp_wifi_sta_toggle_wpa3_security(bool disable);
+esp_err_t esp_wifi_sta_connect_internal(const uint8_t *bssid);
+esp_err_t esp_wifi_send_auth_internal(uint8_t ifx, uint8_t *bssid, uint8_t algo, uint8_t seq, uint32_t status);
+esp_err_t esp_wifi_send_assoc_internal(uint8_t ifx, uint8_t *bssid, uint8_t type, uint8_t status);
 
 #endif /* _ESP_WIFI_DRIVER_H_ */
index acad7b9aac7e14529a2ac76ae478d68dfa061f69..54589d7cd5fcda4ef22233798a2a7b3e620b920b 100644 (file)
@@ -46,6 +46,7 @@
 
 #include "slave_bt.c"
 #include "stats.h"
+#include "esp_mac.h"
 
 static const char TAG[] = "FW_MAIN";
 
@@ -223,7 +224,6 @@ esp_err_t wlan_ap_rx_callback(void *buffer, uint16_t len, void *eb)
 {
        esp_err_t ret = ESP_OK;
        interface_buffer_handle_t buf_handle = {0};
-       uint8_t * ap_buf = buffer;
 
        if (!buffer || !eb || !datapath || ota_ongoing) {
                if (eb) {
@@ -232,13 +232,6 @@ esp_err_t wlan_ap_rx_callback(void *buffer, uint16_t len, void *eb)
                return ESP_OK;
        }
 
-       /* Check destination address against self address */
-       if (memcmp(ap_buf, ap_mac, MAC_ADDR_LEN)) {
-               /* Check for multicast or broadcast address */
-               if (!(ap_buf[0] & 1))
-                       goto DONE;
-       }
-
        buf_handle.if_type = ESP_AP_IF;
        buf_handle.if_num = 0;
        buf_handle.payload_len = len;
@@ -247,6 +240,8 @@ esp_err_t wlan_ap_rx_callback(void *buffer, uint16_t len, void *eb)
        buf_handle.free_buf_handle = esp_wifi_internal_free_rx_buffer;
        buf_handle.pkt_type = PACKET_TYPE_DATA;
 
+       /* ESP_LOGI(TAG, "Slave -> Host: AP data packet\n"); */
+       /* ESP_LOG_BUFFER_HEXDUMP("RX", buffer, len, ESP_LOG_INFO); */
        ret = xQueueSend(to_host_queue[PRIO_Q_LOW], &buf_handle, portMAX_DELAY);
 
        if (ret != pdTRUE) {
@@ -419,9 +414,9 @@ void process_priv_commamd(uint8_t if_type, uint8_t *payload, uint16_t payload_le
                        process_sta_connect(if_type, payload, payload_len);
                        break;
 
-               case CMD_STA_DISCONNECT:
-                       ESP_LOGI(TAG, "STA disconnect request\n");
-                       process_sta_disconnect(if_type, payload, payload_len);
+               case CMD_DISCONNECT:
+                       ESP_LOGI(TAG, "disconnect request\n");
+                       process_disconnect(if_type, payload, payload_len);
                        break;
 
                case CMD_ADD_KEY:
@@ -455,6 +450,31 @@ void process_priv_commamd(uint8_t if_type, uint8_t *payload, uint16_t payload_le
                        process_tx_power(if_type, payload, payload_len, header->cmd_code);
                        break;
 
+               case CMD_SET_MODE:
+                       ESP_LOGI(TAG, "Set MODE command\n");
+                       process_set_mode(if_type, payload, payload_len);
+                       break;
+
+               case CMD_SET_IE:
+                       ESP_LOGI(TAG, "Set IE command\n");
+                       process_set_ie(if_type, payload, payload_len);
+                       break;
+
+               case CMD_AP_CONFIG:
+                       ESP_LOGI(TAG, "Set AP config command\n");
+                       process_set_ap_config(if_type, payload, payload_len);
+                       break;
+
+               case CMD_MGMT_TX:
+                       //ESP_LOGI(TAG, "Send mgmt tx command\n");
+                       process_mgmt_tx(if_type, payload, payload_len);
+                       break;
+
+               case CMD_AP_STATION:
+                       ESP_LOGI(TAG, "AP station command\n");
+                       process_ap_station(if_type, payload, payload_len);
+                       break;
+
                case CMD_SET_REG_DOMAIN:
                        ESP_LOGI(TAG, "REG set command");
                        process_reg_set(if_type, payload, payload_len);
@@ -503,7 +523,7 @@ void process_rx_pkt(interface_buffer_handle_t *buf_handle)
 
        } else if (header->packet_type == PACKET_TYPE_DATA) {
 
-               /*ESP_LOGI(TAG, "Data packet\n");*/
+               /* ESP_LOGI(TAG, "Data packet on iface=%d\n", buf_handle->if_type); */
                /* Data Path */
                if (buf_handle->if_type == ESP_STA_IF) {
                        /*ESP_LOGI(TAG, "Station IF\n");*/
@@ -517,7 +537,10 @@ void process_rx_pkt(interface_buffer_handle_t *buf_handle)
                } else if (buf_handle->if_type == ESP_AP_IF && softap_started) {
 
                        /* Forward packet over soft AP interface */
-                       esp_wifi_internal_tx(ESP_IF_WIFI_AP, payload, payload_len);
+                       /* ESP_LOGI(TAG, "Send data pkt over wlan\n"); */
+                       int ret = esp_wifi_internal_tx(ESP_IF_WIFI_AP, payload, payload_len);
+                       if (ret)
+                               ESP_LOGE(TAG, "Sending data failed=%d\n", ret);
                }
 #if defined(CONFIG_BT_ENABLED) && BLUETOOTH_HCI
                else if (buf_handle->if_type == ESP_HCI_IF) {
index 5c9ecbde6d6258fc2c811b53180ce99dab243bba..0773559fbfbdca187b92ee7f2429511b5a4003c8 100644 (file)
@@ -1,22 +1,14 @@
-// SPDX-License-Identifier: Apache-2.0
-// Copyright 2015-2022 Espressif Systems (Shanghai) PTE LTD
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
+/*
+ * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
 
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
+#include <inttypes.h>
 #include "esp_log.h"
 #include "interface.h"
 #include "esp.h"
 #include "esp_wifi_driver.h"
 #include "esp_event.h"
 #include "esp_mac.h"
+#include "wifi_defs.h"
 
 #define TAG "FW_CMD"
 
-/* management */
-#define WLAN_FC_STYPE_ASSOC_REQ     0
-#define WLAN_FC_STYPE_ASSOC_RESP    1
-#define WLAN_FC_STYPE_REASSOC_REQ   2
-#define WLAN_FC_STYPE_REASSOC_RESP  3
-#define WLAN_FC_STYPE_PROBE_REQ     4
-#define WLAN_FC_STYPE_PROBE_RESP    5
-#define WLAN_FC_STYPE_BEACON        8
-#define WLAN_FC_STYPE_ATIM          9
-#define WLAN_FC_STYPE_DISASSOC      10
-#define WLAN_FC_STYPE_AUTH          11
-#define WLAN_FC_STYPE_DEAUTH        12
-#define WLAN_FC_STYPE_ACTION        13
-
-#define IE_POS_ASSOC_RESP_STATUS    2
-
 /* This is limitation of ESP WiFi lib.
  * It needs the password field updated to understand
  * we are triggering non-open connection */
 #define DUMMY_PASSPHRASE            "12345678"
-#define IEEE_HEADER_SIZE            24
-#define DEFAULT_SCAN_LIST_SIZE      20
-
 extern volatile uint8_t station_connected;
 extern volatile uint8_t association_ongoing;
+extern volatile uint8_t softap_started;
 
 volatile uint8_t sta_init_flag;
 
 static struct wpa_funcs wpa_cb;
 static esp_event_handler_instance_t instance_any_id;
 static uint8_t *ap_bssid;
+
 extern uint32_t ip_address;
 extern struct macfilter_list mac_list;
 extern uint8_t sta_mac[MAC_ADDR_LEN];
 extern uint8_t ap_mac[MAC_ADDR_LEN];
 
-esp_err_t esp_wifi_register_mgmt_frame_internal(uint32_t type, uint32_t subtype);
+uint8_t *ap_rsn_ie;
+uint8_t ap_rsn_ie_len;
+
 int esp_wifi_register_wpa_cb_internal(struct wpa_funcs *cb);
 int esp_wifi_unregister_wpa_cb_internal(void);
 extern esp_err_t wlan_sta_rx_callback(void *buffer, uint16_t len, void *eb);
@@ -77,6 +55,12 @@ extern volatile uint8_t power_save_on;
 extern void wake_host();
 extern struct wow_config wow;
 
+#ifdef CONFIG_IDF_TARGET_ESP32C6
+       #define TX_DONE_PREFIX 8
+#else
+       #define TX_DONE_PREFIX 0
+#endif
+
 extern int wpa_parse_wpa_ie(const u8 *wpa_ie, size_t wpa_ie_len, wifi_wpa_ie_t *data);
 static inline void WPA_PUT_LE16(u8 *a, u16 val)
 {
@@ -101,6 +85,68 @@ static void esp_wifi_set_debug_log()
        esp_wifi_internal_set_log_level(WIFI_LOG_VERBOSE);
 }
 
+static int send_command_resp(uint8_t if_type,
+                            uint8_t cmd_code, uint8_t cmd_status,
+                            uint8_t *data, uint32_t len, uint32_t offset)
+{
+       int ret;
+       struct command_header *header;
+       interface_buffer_handle_t buf_handle = {0};
+
+       ESP_LOGD(TAG , "Sending response of cmd=%d status=%d\n", cmd_code, cmd_status);
+
+       buf_handle.payload_len = sizeof(struct command_header) +
+               sizeof (struct esp_payload_header) +
+               len;
+       buf_handle.payload = heap_caps_malloc(buf_handle.payload_len, MALLOC_CAP_DMA);
+       if (!buf_handle.payload) {
+               ESP_LOGE(TAG , "Malloc send buffer fail!");
+               return ESP_FAIL;
+       }
+       memset(buf_handle.payload, 0, buf_handle.payload_len);
+
+       if (data && len) {
+               memcpy(buf_handle.payload + offset, data, len);
+       }
+
+       header = (struct command_header *) buf_handle.payload;
+
+       header->cmd_status = cmd_status;
+       header->cmd_code = cmd_code;
+       header->len = len;
+
+       buf_handle.if_type = if_type;
+       buf_handle.if_num = 0;
+       buf_handle.pkt_type = PACKET_TYPE_COMMAND_RESPONSE;
+
+       buf_handle.priv_buffer_handle = buf_handle.payload;
+       buf_handle.free_buf_handle = free;
+
+       /* Send command response */
+       ret = send_command_response(&buf_handle);
+       if (ret != pdTRUE) {
+               ESP_LOGE(TAG, "Slave -> Host: Failed to send command response\n");
+               goto cleanup;
+       }
+
+       return ESP_OK;
+cleanup:
+       if (buf_handle.payload) {
+               free(buf_handle.payload);
+               buf_handle.payload = NULL;
+       }
+
+       return ret;
+}
+
+static void deinitialize_wifi(void)
+{
+       /*esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_SCAN_DONE,
+         &esp_scan_done_event_handler);*/
+       esp_wifi_stop();
+       esp_wifi_deinit();
+}
+
 static void cleanup_ap_bssid(void)
 {
        ESP_LOGI(TAG, "%s", __func__);
@@ -131,7 +177,7 @@ int sta_connection(uint8_t *bssid)
                return ESP_FAIL;
        }
        memcpy(ap_bssid, bssid, MAC_ADDR_LEN);
-       esp_wifi_connect_internal(ap_bssid);
+       esp_wifi_sta_connect_internal(ap_bssid);
 
        return ESP_OK;
 }
@@ -144,7 +190,7 @@ int station_rx_eapol(uint8_t *src_addr, uint8_t *buf, uint32_t len)
        u8 own_mac[MAC_ADDR_LEN] = {0};
 
        if (!src_addr || !buf || !len) {
-               ESP_LOGI(TAG, "eapol err - src_addr: %p buf: %p len: %ld\n",
+               ESP_LOGI(TAG, "eapol err - src_addr: %p buf: %p len: %lu\n",
                                src_addr, buf, len);
                //TODO : free buf using esp_wifi_internal_free_rx_buffer?
                return ESP_FAIL;
@@ -191,12 +237,6 @@ int station_rx_eapol(uint8_t *src_addr, uint8_t *buf, uint32_t len)
 
        memcpy((char *)tx_buf, buf, len);
 
-#if 0
-       if (len)
-               ESP_LOG_BUFFER_HEXDUMP("tx_buf", tx_buf, len, ESP_LOG_INFO);
-#endif
-
-
        buf_handle.if_type = ESP_STA_IF;
        buf_handle.if_num = 0;
        buf_handle.payload_len = len;
@@ -233,31 +273,12 @@ static int sta_michael_mic_failure(uint16_t is_unicast)
        return ESP_OK;
 }
 
-static uint8_t *build_sae_msg(uint8_t *bssid, uint32_t sae_msg_type, size_t *sae_msg_len)
-{
-       return ESP_OK;
-}
-
-static int rx_sae_msg(uint8_t *data, size_t len, uint32_t sae_msg_type, uint16_t status)
-{
-       return ESP_OK;
-}
-
-static void sta_connected_cb(uint8_t *bssid)
-{
-       ESP_LOGI(TAG, "STA connected with:" MACSTR "\n", MAC2STR(bssid));
-}
-
 void disconnected_cb(uint8_t reason_code)
 {
        ESP_LOGI(TAG, "STA disconnected [%u]\n", reason_code);
 }
 
-void config_done(void)
-{
-}
-
-int prepare_event(uint8_t if_type, interface_buffer_handle_t *buf_handle, uint16_t event_len)
+static int prepare_event(uint8_t if_type, interface_buffer_handle_t *buf_handle, uint16_t event_len)
 {
        esp_err_t ret = ESP_OK;
 
@@ -279,6 +300,9 @@ int prepare_event(uint8_t if_type, interface_buffer_handle_t *buf_handle, uint16
        return ret;
 }
 
+void config_done(void)
+{
+}
 
 static void handle_scan_event(void)
 {
@@ -287,7 +311,7 @@ static void handle_scan_event(void)
        struct event_header *header;
        esp_err_t ret = ESP_OK;
 
-    /*type = ~(1 << WLAN_FC_STYPE_BEACON) & ~(1 << WLAN_FC_STYPE_PROBE_RESP);*/
+       /*type = ~(1 << WLAN_FC_STYPE_BEACON) & ~(1 << WLAN_FC_STYPE_PROBE_RESP);*/
        /*esp_wifi_register_mgmt_frame_internal(type, 0);*/
 
        ret = prepare_event(ESP_STA_IF, &buf_handle, sizeof(struct event_header));
@@ -441,7 +465,7 @@ static void wifi_event_handler(void* arg, esp_event_base_t event_base,
        bool wakeup_flag = false;
 
        if (event_base != WIFI_EVENT) {
-               ESP_LOGI(TAG, "Received unregistered event %s[%ld]\n", event_base, event_id);
+               ESP_LOGI(TAG, "Received unregistered event %s[%lu]\n", event_base, event_id);
                return;
        }
 
@@ -453,7 +477,7 @@ static void wifi_event_handler(void* arg, esp_event_base_t event_base,
                break;
 
        case WIFI_EVENT_STA_CONNECTED:
-               ESP_LOGI(TAG, "Wifi Station Connected event!!\n");
+               ESP_LOGI(TAG, "Wifi Station Connected event!! \n");
                association_ongoing = 0;
                station_connected = 1;
 
@@ -492,11 +516,29 @@ static void wifi_event_handler(void* arg, esp_event_base_t event_base,
                handle_scan_event();
                break;
 
+       case WIFI_EVENT_AP_START:
+               softap_started = 1;
+               break;
+
+       case WIFI_EVENT_AP_STOP:
+               softap_started = 0;
+               break;
+
        default:
-               ESP_LOGI(TAG, "Unregistered event: %ld\n", event_id);
+               ESP_LOGI(TAG, "Unregistered event: %lu\n", event_id);
        }
 }
 
+void esp_create_wifi_event_loop(void)
+{
+       ESP_ERROR_CHECK(esp_event_loop_create_default());
+       ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT,
+                               ESP_EVENT_ANY_ID,
+                               &wifi_event_handler,
+                               NULL,
+                               &instance_any_id));
+}
+
 static int sta_rx_auth(uint8_t type, uint8_t *frame, size_t len, uint8_t *sender,
                uint32_t rssi, uint8_t channel, uint64_t current_tsf)
 {
@@ -565,7 +607,7 @@ static int sta_rx_probe(uint8_t type, uint8_t *frame, size_t len, uint8_t *sende
        esp_err_t ret = ESP_OK;
        interface_buffer_handle_t buf_handle = {0};
 
-       /*ESP_LOGI(TAG, "SCAN# Type: %d, Channel: %d, Len: %d\n", type, channel, len);
+       /*ESP_LOGI(TAG, "SCAN# Type: %d, Channel: %d, Len: %lu\n", type, channel, len);
        ESP_LOG_BUFFER_HEXDUMP("Frame", frame, len, ESP_LOG_INFO);
        ESP_LOG_BUFFER_HEXDUMP("MAC", sender, MAC_ADDR_LEN, ESP_LOG_INFO);
        */
@@ -688,7 +730,160 @@ static int handle_wpa_sta_rx_mgmt(uint8_t type, uint8_t *frame, size_t len, uint
        return ESP_OK;
 }
 
+static int hostap_sta_join(uint8_t *bssid, uint8_t *wpa_ie, uint8_t wpa_ie_len,
+                       uint8_t* rsnxe, uint8_t rsnxe_len, bool *pmf_enable, int subtype)
+{
+       return true;
+}
+
+
+static int wpa_ap_remove(uint8_t* bssid)
+{
+       return true;
+}
+
+static uint8_t  *wpa_ap_get_wpa_ie(uint8_t *ie_len)
+{
+       if (ap_rsn_ie) {
+               *ie_len = ap_rsn_ie_len;
+               return ap_rsn_ie;
+       }
+
+       *ie_len = 0;
+
+       return NULL;
+}
+
+static int wpa_ap_rx_eapol(uint8_t *addr, uint8_t *buf, size_t len)
+{
+       esp_err_t ret = ESP_OK;
+       interface_buffer_handle_t buf_handle = {0};
+       uint8_t * tx_buf = NULL;
+
+       if (!buf || !len) {
+               ESP_LOGI(TAG, "eapol err - buf: %p len: %zu\n",
+                               buf, len);
+               //TODO : free buf using esp_wifi_internal_free_rx_buffer?
+               return ESP_FAIL;
+       }
+
+       tx_buf = (uint8_t *)malloc(len);
+       if (!tx_buf) {
+               ESP_LOGE(TAG, "%s:%u malloc failed\n",__func__, __LINE__);
+               return ESP_FAIL;
+       }
+
+       memcpy((char *)tx_buf, buf, len);
+
+#if 0
+       if (len)
+               ESP_LOG_BUFFER_HEXDUMP("tx_buf", tx_buf, len, ESP_LOG_INFO);
+#endif
+
+
+       buf_handle.if_type = ESP_AP_IF;
+       buf_handle.if_num = 0;
+       buf_handle.payload_len = len;
+       buf_handle.payload = tx_buf;
+       buf_handle.wlan_buf_handle = tx_buf;
+       buf_handle.free_buf_handle = free;
+       buf_handle.pkt_type = PACKET_TYPE_EAPOL;
+
+       ESP_LOGD(TAG, "Sending eapol to host on AP iface\n");
+       ret = send_frame_to_host(&buf_handle);
+
+       if (ret != pdTRUE) {
+               ESP_LOGE(TAG, "Slave -> Host: Failed to send buffer\n");
+               goto DONE;
+       }
+
+       return true;
+
+DONE:
+       free(tx_buf);
+       tx_buf = NULL;
+
+       return false;
+}
+
+static int wpa_ap_get_peer_spp_msg(void *sm_data, bool *spp_cap, bool *spp_req)
+{
+    return 0;
+}
+
+char hostapd;
+static int *hostap_init(void)
+{
+       return NULL;
+}
+
+
+static int hostap_deinit(void *data)
+{
+       return true;
+}
+
+static int handle_wpa_ap_rx_mgmt(void *pkt, uint32_t pkt_len, uint8_t chan, int rssi, int nf)
+{
+       struct mgmt_frm_event *event;
+       esp_err_t ret = ESP_OK;
+       interface_buffer_handle_t buf_handle = {0};
+       pkt_len = pkt_len + 24;
+
+       //ESP_LOG_BUFFER_HEXDUMP(TAG, pkt, pkt_len, ESP_LOG_INFO);
+       ret = prepare_event(ESP_AP_IF, &buf_handle, sizeof(struct mgmt_frm_event)
+                       + pkt_len);
+       if (ret) {
+               ESP_LOGE(TAG, "%s: Failed to prepare event buffer\n", __func__);
+               return ESP_FAIL;
+       }
+
+       event = (struct mgmt_frm_event *) buf_handle.payload;
+
+       /* Populate event header */
+       event->header.event_code = EVENT_AP_MGMT_RX;
+       event->header.len = htole16(buf_handle.payload_len - sizeof(struct event_header));
+       /*event->header.status = 1;*/
+
+       memcpy(event->frame, pkt, pkt_len);
+       event->frame_len = pkt_len;
+       event->chan = chan;
+       event->rssi = rssi;
+       event->nf = nf;
+
+       if (event->frame[0] != 0x40) {
+               ESP_LOGE(TAG, "%s: Got packet type as %x \n", __func__, event->frame[0]);
+       }
+
+       /*ESP_LOG_BUFFER_HEXDUMP(TAG, event->frame, event->frame_len, ESP_LOG_INFO);*/
+
+       ret = send_command_event(&buf_handle);
+       if (ret != pdTRUE) {
+               ESP_LOGE(TAG, "Slave -> Host: Failed to send mgmt frames\n");
+               goto DONE;
+       }
+
+       return ESP_OK;
+
+DONE:
+       if (buf_handle.payload) {
+               free(buf_handle.payload);
+               buf_handle.payload = NULL;
+       }
+       return ret;
+
+       return 0;
+}
+
+static void sta_connected(uint8_t *bssid)
+{
+}
+
 extern char * wpa_config_parse_string(const char *value, size_t *len);
+static void sta_disconnected(uint8_t reason_code)
+{
+}
+
 esp_err_t initialise_wifi(void)
 {
        wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
@@ -708,17 +903,25 @@ esp_err_t initialise_wifi(void)
        wpa_cb.wpa_sta_init = sta_init;
        wpa_cb.wpa_sta_deinit = sta_deinit;
        wpa_cb.wpa_sta_connect = sta_connection;
-       wpa_cb.wpa_sta_connected_cb = sta_connected_cb;
+       wpa_cb.wpa_sta_connected_cb = sta_connected;
+       wpa_cb.wpa_sta_disconnected_cb = sta_disconnected;
        wpa_cb.wpa_sta_disconnected_cb = disconnected_cb;
        wpa_cb.wpa_sta_rx_eapol = station_rx_eapol;
        wpa_cb.wpa_sta_in_4way_handshake = in_4way;
        wpa_cb.wpa_parse_wpa_ie = wpa_parse_wpa_ie;
        wpa_cb.wpa_michael_mic_failure = sta_michael_mic_failure;
-       wpa_cb.wpa3_build_sae_msg = build_sae_msg;
-       wpa_cb.wpa3_parse_sae_msg = rx_sae_msg;
        wpa_cb.wpa_config_done = config_done;
        wpa_cb.wpa_config_parse_string  = wpa_config_parse_string;
 
+       wpa_cb.wpa_ap_join       = hostap_sta_join;
+       wpa_cb.wpa_ap_remove     = wpa_ap_remove;
+       wpa_cb.wpa_ap_get_wpa_ie = wpa_ap_get_wpa_ie;
+       wpa_cb.wpa_ap_rx_eapol   = wpa_ap_rx_eapol;
+       wpa_cb.wpa_ap_get_peer_spp_msg  = wpa_ap_get_peer_spp_msg;
+       wpa_cb.wpa_ap_init       = hostap_init;
+       wpa_cb.wpa_ap_deinit     = hostap_deinit;
+       wpa_cb.wpa_ap_rx_mgmt    = handle_wpa_ap_rx_mgmt;
+
        esp_wifi_register_wpa_cb_internal(&wpa_cb);
 
        result = esp_wifi_set_mode(WIFI_MODE_NULL);
@@ -729,21 +932,13 @@ esp_err_t initialise_wifi(void)
        return result;
 }
 
-static void deinitialize_wifi(void)
-{
-       /*esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_SCAN_DONE,
-         &esp_scan_done_event_handler);*/
-       esp_wifi_stop();
-       esp_wifi_deinit();
-}
+
 
 int process_start_scan(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
 {
        uint32_t type = 0;
        wifi_scan_config_t params = {0};
        esp_err_t ret = ESP_OK;
-       struct command_header *header;
-       interface_buffer_handle_t buf_handle = {0};
        uint8_t cmd_status = CMD_RESPONSE_SUCCESS;
        struct scan_request *scan_req;
        bool config_present = false;
@@ -784,53 +979,20 @@ int process_start_scan(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
                        esp_wifi_register_mgmt_frame_internal(0, 0);
                }
        } else {
-                       ESP_LOGI(TAG, "Scan not permited as WiFi is not yet up");
-                       cmd_status = CMD_RESPONSE_FAIL;
-
-                       /* Reset frame registration */
-                       esp_wifi_register_mgmt_frame_internal(0, 0);
-       }
-
-       buf_handle.if_type = ESP_STA_IF;
-       buf_handle.if_num = 0;
-       buf_handle.payload_len = sizeof(struct command_header);
-       buf_handle.pkt_type = PACKET_TYPE_COMMAND_RESPONSE;
-
-       buf_handle.payload = heap_caps_malloc(buf_handle.payload_len, MALLOC_CAP_DMA);
-       assert(buf_handle.payload);
-       memset(buf_handle.payload, 0, buf_handle.payload_len);
-
-       header = (struct command_header *) buf_handle.payload;
-
-       header->cmd_code = CMD_SCAN_REQUEST;
-       header->len = 0;
-       header->cmd_status = cmd_status;
-
-       buf_handle.priv_buffer_handle = buf_handle.payload;
-       buf_handle.free_buf_handle = free;
+               ESP_LOGI(TAG, "Scan not permited as WiFi is not yet up");
+               cmd_status = CMD_RESPONSE_FAIL;
 
-       /* Send command response */
-       ret = send_command_response(&buf_handle);
-       if (ret != pdTRUE) {
-               ESP_LOGE(TAG, "Slave -> Host: Failed to send command response\n");
-               goto DONE;
+               /* Reset frame registration */
+               esp_wifi_register_mgmt_frame_internal(0, 0);
        }
 
-       return ESP_OK;
-
-DONE:
-       if (buf_handle.payload) {
-               free(buf_handle.payload);
-               buf_handle.payload = NULL;
-       }
+       ret = send_command_resp(if_type, CMD_SCAN_REQUEST, cmd_status, NULL, 0, 0);
 
        return ret;
 }
 
 int process_set_mcast_mac_list(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
 {
-       struct command_header *header;
-       interface_buffer_handle_t buf_handle = {0};
        esp_err_t ret = ESP_OK;
        struct cmd_set_mcast_mac_addr *cmd_mcast_mac_list;
 
@@ -842,89 +1004,16 @@ int process_set_mcast_mac_list(uint8_t if_type, uint8_t *payload, uint16_t paylo
 
        /*ESP_LOG_BUFFER_HEXDUMP("MAC Filter", (uint8_t *) &mac_list, sizeof(mac_list), ESP_LOG_INFO);*/
 
-       buf_handle.if_type = if_type;
-       buf_handle.if_num = 0;
-       buf_handle.payload_len = sizeof(struct command_header);
-       buf_handle.pkt_type = PACKET_TYPE_COMMAND_RESPONSE;
-
-       buf_handle.payload = heap_caps_malloc(buf_handle.payload_len, MALLOC_CAP_DMA);
-       assert(buf_handle.payload);
-       memset(buf_handle.payload, 0, buf_handle.payload_len);
+       ret = send_command_resp(if_type, CMD_SET_MCAST_MAC_ADDR, CMD_RESPONSE_SUCCESS, NULL, 0, 0);
 
-       header = (struct command_header *) buf_handle.payload;
-
-       header->cmd_code = CMD_SET_MCAST_MAC_ADDR;
-       header->len = 0;
-       header->cmd_status = CMD_RESPONSE_SUCCESS;
-
-       buf_handle.priv_buffer_handle = buf_handle.payload;
-       buf_handle.free_buf_handle = free;
-
-       ret = send_command_response(&buf_handle);
-       if (ret != pdTRUE) {
-               ESP_LOGE(TAG, "Slave -> Host: Failed to send command response\n");
-               goto DONE;
-       }
-
-       return ESP_OK;
-
-DONE:
-       if (buf_handle.payload)
-               free(buf_handle.payload);
-
-       return ret;
-}
-
-int process_set_ip(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
-{
-       struct command_header *header;
-       interface_buffer_handle_t buf_handle = {0};
-       esp_err_t ret = ESP_OK;
-       struct cmd_set_ip_addr *cmd_set_ip;
-
-       cmd_set_ip = (struct cmd_set_ip_addr *) payload;
-
-       ip_address = le32toh(cmd_set_ip->ip);
-
-       buf_handle.if_type = if_type;
-       buf_handle.if_num = 0;
-       buf_handle.payload_len = sizeof(struct command_header);
-       buf_handle.pkt_type = PACKET_TYPE_COMMAND_RESPONSE;
-
-       buf_handle.payload = heap_caps_malloc(buf_handle.payload_len, MALLOC_CAP_DMA);
-       assert(buf_handle.payload);
-       memset(buf_handle.payload, 0, buf_handle.payload_len);
-
-       header = (struct command_header *) buf_handle.payload;
-
-       header->cmd_code = CMD_SET_IP_ADDR;
-       header->len = 0;
-       header->cmd_status = CMD_RESPONSE_SUCCESS;
-
-       buf_handle.priv_buffer_handle = buf_handle.payload;
-       buf_handle.free_buf_handle = free;
-
-       ret = send_command_response(&buf_handle);
-       if (ret != pdTRUE) {
-               ESP_LOGE(TAG, "Slave -> Host: Failed to send command response\n");
-               goto DONE;
-       }
-
-       return ESP_OK;
-
-DONE:
-       if (buf_handle.payload)
-               free(buf_handle.payload);
-
-       return ret;
-}
+       return ret;
+}
 
 int process_tx_power(uint8_t if_type, uint8_t *payload, uint16_t payload_len, uint8_t cmd)
 {
-       interface_buffer_handle_t buf_handle = {0};
        esp_err_t ret = ESP_OK;
        struct cmd_set_get_val *val;
-       int8_t max_tx_power;
+       uint8_t max_tx_power;
 
        if (cmd == CMD_SET_TXPOWER) {
                val = (struct cmd_set_get_val *)payload;
@@ -932,38 +1021,21 @@ int process_tx_power(uint8_t if_type, uint8_t *payload, uint16_t payload_len, ui
                esp_wifi_set_max_tx_power(max_tx_power);
        }
 
-       /*ESP_LOG_BUFFER_HEXDUMP("MAC Filter", (uint8_t *) &mac_list, sizeof(mac_list), ESP_LOG_INFO);*/
-
-       buf_handle.if_type = if_type;
-       buf_handle.if_num = 0;
-       buf_handle.payload_len = sizeof(struct cmd_set_get_val);
-       buf_handle.pkt_type = PACKET_TYPE_COMMAND_RESPONSE;
-
-       buf_handle.payload = heap_caps_malloc(buf_handle.payload_len, MALLOC_CAP_DMA);
-       esp_wifi_get_max_tx_power(&max_tx_power);
-       assert(buf_handle.payload);
-       memset(buf_handle.payload, 0, buf_handle.payload_len);
+       ret = send_command_resp(if_type, cmd, CMD_RESPONSE_SUCCESS, &max_tx_power, sizeof(int8_t), 0);
 
-       val = (struct cmd_set_get_val *)(buf_handle.payload);
-       val->value = max_tx_power;
-       val->header.cmd_code = cmd;
-       val->header.len = 0;
-       val->header.cmd_status = CMD_RESPONSE_SUCCESS;
+       return ret;
+}
 
-       buf_handle.priv_buffer_handle = buf_handle.payload;
-       buf_handle.free_buf_handle = free;
+int process_set_ip(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
+{
+       esp_err_t ret = ESP_OK;
+       struct cmd_set_ip_addr *cmd_set_ip;
 
-       ret = send_command_response(&buf_handle);
-       if (ret != pdTRUE) {
-               ESP_LOGE(TAG, "Slave -> Host: Failed to send command response\n");
-               goto DONE;
-       }
+       cmd_set_ip = (struct cmd_set_ip_addr *) payload;
 
-       return ESP_OK;
+       ip_address = le32toh(cmd_set_ip->ip);
 
-DONE:
-       if (buf_handle.payload)
-               free(buf_handle.payload);
+       ret = send_command_resp(if_type, CMD_SET_IP_ADDR, CMD_RESPONSE_SUCCESS, NULL, 0, 0);
 
        return ret;
 }
@@ -1105,61 +1177,30 @@ DONE:
 }
 
 
-int process_sta_disconnect(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
+int process_disconnect(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
 {
-       struct command_header *header;
-       interface_buffer_handle_t buf_handle = {0};
        esp_err_t ret = ESP_OK;
-       struct cmd_sta_disconnect *cmd_disconnect;
+       struct cmd_disconnect *cmd_disconnect;
        wifi_mode_t wifi_mode = {0};
 
-       cmd_disconnect = (struct cmd_sta_disconnect *) payload;
-
-       ESP_LOGI(TAG, "STA Disconnect request: reason [%d]\n", cmd_disconnect->reason_code);
-
-       if (sta_init_flag && esp_wifi_get_mode(&wifi_mode)==0)
-               esp_wifi_deauthenticate_internal(cmd_disconnect->reason_code);
-
-       buf_handle.if_type = if_type;
-       buf_handle.if_num = 0;
-       buf_handle.payload_len = sizeof(struct command_header);
-       buf_handle.pkt_type = PACKET_TYPE_COMMAND_RESPONSE;
-
-       buf_handle.payload = heap_caps_malloc(buf_handle.payload_len, MALLOC_CAP_DMA);
-       assert(buf_handle.payload);
-       memset(buf_handle.payload, 0, buf_handle.payload_len);
-
-       header = (struct command_header *) buf_handle.payload;
-
-       header->cmd_code = CMD_STA_DISCONNECT;
-       header->len = 0;
-       header->cmd_status = CMD_RESPONSE_SUCCESS;
+       cmd_disconnect = (struct cmd_disconnect *) payload;
 
-       buf_handle.priv_buffer_handle = buf_handle.payload;
-       buf_handle.free_buf_handle = free;
+       ESP_LOGI(TAG, "Disconnect request: reason [%d], interface=%d\n", cmd_disconnect->reason_code, if_type);
 
-       /* Send command response */
-       ret = send_command_response(&buf_handle);
-       if (ret != pdTRUE) {
-               ESP_LOGE(TAG, "Slave -> Host: Failed to send command response\n");
-               goto DONE;
+       if (if_type == ESP_STA_IF) {
+               if (sta_init_flag && esp_wifi_get_mode(&wifi_mode)==0)
+                       esp_wifi_deauthenticate_internal(cmd_disconnect->reason_code);
+       } else if (if_type == ESP_AP_IF) {
+               esp_wifi_ap_deauth_internal(cmd_disconnect->mac, cmd_disconnect->reason_code);
        }
 
-       return ESP_OK;
-
-DONE:
-       if (buf_handle.payload) {
-               free(buf_handle.payload);
-               buf_handle.payload = NULL;
-       }
+       ret = send_command_resp(if_type, CMD_DISCONNECT, CMD_RESPONSE_SUCCESS, NULL, 0, 0);
 
        return ret;
 }
 
 int process_auth_request(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
 {
-       struct command_header *header;
-       interface_buffer_handle_t buf_handle = {0};
        esp_err_t ret = ESP_OK;
        struct cmd_sta_auth *cmd_auth;
        wifi_config_t wifi_config = {0};
@@ -1188,21 +1229,19 @@ int process_auth_request(uint8_t if_type, uint8_t *payload, uint16_t payload_len
        }
 
        if (msg_type == 2) {
-
+#define WLAN_AUTH_FT 2
                /* WPA3 specific */
                ESP_LOGI(TAG, "AUTH Confirm\n");
-               esp_wifi_issue_auth_internal(0);
+               esp_wifi_send_auth_internal(0, cmd_auth->bssid, WLAN_AUTH_FT, 2, 0);
 
        } else {
                wifi_scan_config_t params = {0};
 
-               if (memcmp(cmd_auth->bssid, (uint8_t[MAC_ADDR_LEN]) {0}, MAC_ADDR_LEN) != 0) {
-                       params.bssid = malloc(sizeof(cmd_auth->bssid));
-                       assert(params.bssid);
+               params.bssid = malloc(sizeof(cmd_auth->bssid));
+               assert(params.bssid);
 
-                       memcpy(params.bssid, cmd_auth->bssid, sizeof(cmd_auth->bssid));
-                       params.scan_type = WIFI_SCAN_TYPE_ACTIVE;
-               }
+               memcpy(params.bssid, cmd_auth->bssid, sizeof(cmd_auth->bssid));
+               params.scan_type = 1;
 
                if (cmd_auth->channel) {
                        params.channel = cmd_auth->channel;
@@ -1210,6 +1249,7 @@ int process_auth_request(uint8_t if_type, uint8_t *payload, uint16_t payload_len
 
                esp_wifi_scan_start(&params, true);
 
+               free(params.bssid);
                ret = esp_wifi_scan_get_ap_records(&number, ap_info);
                if (ret)
                        ESP_LOGI (TAG, "Err: esp_wifi_scan_get_ap_records: %d\n", ret);
@@ -1242,7 +1282,7 @@ int process_auth_request(uint8_t if_type, uint8_t *payload, uint16_t payload_len
                if (!found_ssid) {
                        ESP_LOGI(TAG, "AP not found to connect.");
                        cmd_status = CMD_RESPONSE_FAIL;
-                       goto SEND_RESP;
+                       goto send_resp;
                }
 
                /* ESP_LOGI(TAG, "ssid_found:%u Auth type scanned[%u], exp[%u] for ssid %s", found_ssid, auth_type, cmd_auth->auth_type, wifi_config.sta.ssid); */
@@ -1271,7 +1311,7 @@ int process_auth_request(uint8_t if_type, uint8_t *payload, uint16_t payload_len
                if (ret) {
                        ESP_LOGE(TAG, "Failed to set wifi config: %d\n", ret);
                        cmd_status = CMD_RESPONSE_FAIL;
-                       goto SEND_RESP;
+                       goto send_resp;
                }
 
                /* This API sends auth commit to AP */
@@ -1279,53 +1319,22 @@ int process_auth_request(uint8_t if_type, uint8_t *payload, uint16_t payload_len
                if (ret) {
                        ESP_LOGE(TAG, "Failed to connect wifi\n");
                        cmd_status = CMD_RESPONSE_FAIL;
-                       goto SEND_RESP;
+                       goto send_resp;
                }
        }
        association_ongoing = 1;
 
-SEND_RESP:
-       buf_handle.if_type = if_type;
-       buf_handle.if_num = 0;
-       buf_handle.payload_len = sizeof(struct command_header);
-       buf_handle.pkt_type = PACKET_TYPE_COMMAND_RESPONSE;
-
-       buf_handle.payload = heap_caps_malloc(buf_handle.payload_len, MALLOC_CAP_DMA);
-       assert(buf_handle.payload);
-       memset(buf_handle.payload, 0, buf_handle.payload_len);
-
-       header = (struct command_header *) buf_handle.payload;
-
-       header->cmd_code = CMD_STA_AUTH;
-       header->len = 0;
-       header->cmd_status = cmd_status;
-
-       buf_handle.priv_buffer_handle = buf_handle.payload;
-       buf_handle.free_buf_handle = free;
-
-       ret = send_command_response(&buf_handle);
-       if (ret != pdTRUE) {
-               ESP_LOGE(TAG, "Slave -> Host: Failed to send command response\n");
-               goto DONE;
-       }
-
-       return ESP_OK;
-DONE:
-
-       if (buf_handle.payload) {
-               free(buf_handle.payload);
-               buf_handle.payload = NULL;
-       }
+send_resp:
+       ret = send_command_resp(if_type, CMD_STA_AUTH, cmd_status, NULL, 0, 0);
 
        return ret;
 }
 
 int process_assoc_request(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
 {
-       struct command_header *header;
-       interface_buffer_handle_t buf_handle = {0};
        esp_err_t ret = ESP_OK;
        struct cmd_sta_assoc *cmd_assoc;
+       uint16_t cmd_status = CMD_RESPONSE_SUCCESS;
 
        cmd_assoc = (struct cmd_sta_assoc *) payload;
 
@@ -1334,40 +1343,14 @@ int process_assoc_request(uint8_t if_type, uint8_t *payload, uint16_t payload_le
                esp_wifi_set_appie_internal(WIFI_APPIE_ASSOC_REQ, cmd_assoc->assoc_ie,
                                cmd_assoc->assoc_ie_len, 0);
        }
+#define WLAN_FC_STYPE_ASSOC_REQ         0
+#define WLAN_STATUS_SUCCESS 0
+       esp_wifi_send_assoc_internal(WIFI_IF_STA, NULL, WLAN_FC_STYPE_ASSOC_REQ, WLAN_STATUS_SUCCESS);
 
-       esp_wifi_issue_assoc_internal(0);
-
-       buf_handle.if_type = if_type;
-       buf_handle.if_num = 0;
-       buf_handle.payload_len = sizeof(struct command_header);
-       buf_handle.pkt_type = PACKET_TYPE_COMMAND_RESPONSE;
-
-       buf_handle.payload = heap_caps_malloc(buf_handle.payload_len, MALLOC_CAP_DMA);
-       assert(buf_handle.payload);
-       memset(buf_handle.payload, 0, buf_handle.payload_len);
-
-       header = (struct command_header *) buf_handle.payload;
-
-       header->cmd_code = CMD_STA_ASSOC;
-       header->len = 0;
-       header->cmd_status = CMD_RESPONSE_SUCCESS;
-
-       buf_handle.priv_buffer_handle = buf_handle.payload;
-       buf_handle.free_buf_handle = free;
-
-       ret = send_command_response(&buf_handle);
-       if (ret != pdTRUE) {
-               ESP_LOGE(TAG, "Slave -> Host: Failed to send command response\n");
-               goto DONE;
-       }
-       association_ongoing = 1;
-
-       return ESP_OK;
-DONE:
+       ret = send_command_resp(if_type, CMD_STA_ASSOC, cmd_status, NULL, 0, 0);
 
-       if (buf_handle.payload) {
-               free(buf_handle.payload);
-               buf_handle.payload = NULL;
+       if (!ret) {
+               association_ongoing = 1;
        }
 
        return ret;
@@ -1375,12 +1358,11 @@ DONE:
 
 int process_sta_connect(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
 {
-       struct command_header *header;
-       interface_buffer_handle_t buf_handle = {0};
        esp_err_t ret = ESP_OK;
        struct cmd_sta_connect *cmd_connect;
        wifi_config_t wifi_config = {0};
        uint32_t type = 0;
+       uint16_t cmd_status = CMD_RESPONSE_FAIL;
 
        type = (1 << WLAN_FC_STYPE_ASSOC_RESP)
                | (1 << WLAN_FC_STYPE_REASSOC_RESP)
@@ -1408,50 +1390,27 @@ int process_sta_connect(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
        ret = esp_wifi_set_config(WIFI_IF_STA, &wifi_config);
        if (ret) {
                ESP_LOGE(TAG, "Failed to set wifi config: %d\n", ret);
+               goto send_resp;
        }
 
        ret = esp_wifi_start();
        if (ret) {
                ESP_LOGE(TAG, "Failed to start wifi\n");
+               goto send_resp;
        }
 
        ret = esp_wifi_connect();
        if (ret) {
                ESP_LOGE(TAG, "Failed to connect wifi\n");
+               goto send_resp;
        }
 
-       buf_handle.if_type = if_type;
-       buf_handle.if_num = 0;
-       buf_handle.payload_len = sizeof(struct command_header);
-       buf_handle.pkt_type = PACKET_TYPE_COMMAND_RESPONSE;
-
-       buf_handle.payload = heap_caps_malloc(buf_handle.payload_len, MALLOC_CAP_DMA);
-       assert(buf_handle.payload);
-       memset(buf_handle.payload, 0, buf_handle.payload_len);
-
-       header = (struct command_header *) buf_handle.payload;
-
-       header->cmd_code = CMD_STA_CONNECT;
-       header->len = 0;
-       header->cmd_status = CMD_RESPONSE_SUCCESS;
-
-       buf_handle.priv_buffer_handle = buf_handle.payload;
-       buf_handle.free_buf_handle = free;
-
-       /* Send command response */
-       ret = send_command_response(&buf_handle);
-       if (ret != pdTRUE) {
-               ESP_LOGE(TAG, "Slave -> Host: Failed to send command response\n");
-               goto DONE;
-       }
-       association_ongoing = 1;
-
-       return ESP_OK;
+       cmd_status = CMD_RESPONSE_SUCCESS;
+send_resp:
+       ret = send_command_resp(if_type, CMD_STA_CONNECT, cmd_status, NULL, 0, 0);
 
-DONE:
-       if (buf_handle.payload) {
-               free(buf_handle.payload);
-               buf_handle.payload = NULL;
+       if (!ret) {
+               association_ongoing = 1;
        }
 
        return ret;
@@ -1459,10 +1418,9 @@ DONE:
 
 int process_deinit_interface(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
 {
-       struct command_header *header;
        esp_err_t ret = ESP_OK;
-       interface_buffer_handle_t buf_handle = {0};
        wifi_mode_t wifi_mode = {0};
+       uint16_t cmd_status = CMD_RESPONSE_SUCCESS;
 
        if (if_type == ESP_STA_IF) {
                if (sta_init_flag && esp_wifi_get_mode(&wifi_mode)==0)
@@ -1472,59 +1430,21 @@ int process_deinit_interface(uint8_t if_type, uint8_t *payload, uint16_t payload
        esp_wifi_scan_stop();
        esp_wifi_stop();
 
-       buf_handle.if_type = if_type;
-       buf_handle.if_num = 0;
-       buf_handle.payload_len = sizeof(struct command_header);
-       buf_handle.pkt_type = PACKET_TYPE_COMMAND_RESPONSE;
-
-       buf_handle.payload = heap_caps_malloc(buf_handle.payload_len, MALLOC_CAP_DMA);
-       assert(buf_handle.payload);
-       memset(buf_handle.payload, 0, buf_handle.payload_len);
-
-       header = (struct command_header *) buf_handle.payload;
-
-       header->cmd_code = CMD_DEINIT_INTERFACE;
-       header->len = 0;
-       header->cmd_status = CMD_RESPONSE_SUCCESS;
-
-       buf_handle.priv_buffer_handle = buf_handle.payload;
-       buf_handle.free_buf_handle = free;
-
-       /* Send command response */
-       ret = send_command_response(&buf_handle);
-       if (ret != pdTRUE) {
-               ESP_LOGE(TAG, "Slave -> Host: Failed to send command response\n");
-               goto DONE;
-       }
-
-       return ESP_OK;
-
-DONE:
-       if (buf_handle.payload) {
-               free(buf_handle.payload);
-               buf_handle.payload = NULL;
-       }
+       ret = send_command_resp(if_type, CMD_DEINIT_INTERFACE, cmd_status, NULL, 0, 0);
 
        return ret;
 }
 
 int process_init_interface(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
 {
-       struct command_header *header;
-       interface_buffer_handle_t buf_handle = {0};
        esp_err_t ret = ESP_OK;
        wifi_mode_t mode = 0;
+       uint16_t cmd_status = CMD_RESPONSE_FAIL;
 
        if (!sta_init_flag) {
 
                /* Register to get events from wifi driver */
-               ESP_ERROR_CHECK(esp_event_loop_create_default());
-               ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT,
-                                       ESP_EVENT_ANY_ID,
-                                       &wifi_event_handler,
-                                       NULL,
-                                       &instance_any_id));
-
+               esp_create_wifi_event_loop();
                ret = esp_wifi_get_mode(&mode);
                if (ret) {
                        ESP_LOGE(TAG,"Failed to get wifi mode");
@@ -1549,42 +1469,14 @@ int process_init_interface(uint8_t if_type, uint8_t *payload, uint16_t payload_l
                        goto DONE;
                }
        }
+       cmd_status = CMD_RESPONSE_SUCCESS;
+DONE:
+       ret = send_command_resp(if_type, CMD_INIT_INTERFACE, cmd_status, NULL, 0, 0);
+       if (ret) {
+               deinitialize_wifi();
+       }
 
-       buf_handle.if_type = if_type;
-       buf_handle.if_num = 0;
-       buf_handle.payload_len = sizeof(struct command_header);
-       buf_handle.pkt_type = PACKET_TYPE_COMMAND_RESPONSE;
-
-       buf_handle.payload = heap_caps_malloc(buf_handle.payload_len, MALLOC_CAP_DMA);
-       assert(buf_handle.payload);
-       memset(buf_handle.payload, 0, buf_handle.payload_len);
-
-       header = (struct command_header *) buf_handle.payload;
-
-       header->cmd_code = CMD_INIT_INTERFACE;
-       header->len = 0;
-       header->cmd_status = CMD_RESPONSE_SUCCESS;
-
-       buf_handle.priv_buffer_handle = buf_handle.payload;
-       buf_handle.free_buf_handle = free;
-
-       /* Send command response */
-       ret = send_command_response(&buf_handle);
-       if (ret != pdTRUE) {
-               ESP_LOGE(TAG, "Slave -> Host: Failed to send command response\n");
-               goto DONE;
-       }
-
-       return ESP_OK;
-
-DONE:
-       if (buf_handle.payload) {
-               free(buf_handle.payload);
-               buf_handle.payload = NULL;
-       }
-       deinitialize_wifi();
-
-       return ret;
+       return ret;
 
 }
 
@@ -1592,8 +1484,6 @@ int process_get_mac(uint8_t if_type)
 {
        esp_err_t ret = ESP_OK;
        wifi_interface_t wifi_if_type = 0;
-       interface_buffer_handle_t buf_handle = {0};
-       struct cmd_config_mac_address *header;
        uint8_t cmd_status = CMD_RESPONSE_SUCCESS;
        uint8_t mac[MAC_ADDR_LEN];
 
@@ -1618,44 +1508,8 @@ int process_get_mac(uint8_t if_type)
 
 
        /*ESP_LOG_BUFFER_HEXDUMP(TAG, mac, MAC_ADDR_LEN, ESP_LOG_INFO);*/
-
-       buf_handle.if_type = if_type;
-       buf_handle.if_num = 0;
-       buf_handle.payload_len = sizeof(struct cmd_config_mac_address);
-       buf_handle.pkt_type = PACKET_TYPE_COMMAND_RESPONSE;
-
-       buf_handle.payload = heap_caps_malloc(buf_handle.payload_len, MALLOC_CAP_DMA);
-       assert(buf_handle.payload);
-       memset(buf_handle.payload, 0, buf_handle.payload_len);
-
-       header = (struct cmd_config_mac_address *) buf_handle.payload;
-
-       header->header.cmd_code = CMD_GET_MAC;
-       header->header.len = 0;
-       header->header.cmd_status = cmd_status;
-
-       if (cmd_status == CMD_RESPONSE_SUCCESS) {
-               memcpy(header->mac_addr, mac, sizeof(header->mac_addr));
-               header->header.len = htole16(sizeof(header->mac_addr));
-       }
-
-       buf_handle.priv_buffer_handle = buf_handle.payload;
-       buf_handle.free_buf_handle = free;
-
-       ret = send_command_response(&buf_handle);
-       if (ret != pdTRUE) {
-               ESP_LOGE(TAG, "Slave -> Host: Failed to send command response\n");
-               goto DONE;
-       }
-
-       return ESP_OK;
-
-DONE:
-       if (buf_handle.payload) {
-               free(buf_handle.payload);
-               buf_handle.payload = NULL;
-       }
-
+       ret = send_command_resp(if_type, CMD_GET_MAC, cmd_status, (uint8_t *)mac,
+                               MAC_ADDR_LEN, sizeof(struct command_header));
        return ret;
 }
 
@@ -1663,8 +1517,6 @@ int process_set_mac(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
 {
        esp_err_t ret = ESP_OK;
        wifi_interface_t wifi_if_type = 0;
-       interface_buffer_handle_t buf_handle = {0};
-       struct cmd_config_mac_address *header;
        uint8_t cmd_status = CMD_RESPONSE_SUCCESS;
        struct cmd_config_mac_address *mac = (struct cmd_config_mac_address *) payload;
 
@@ -1676,237 +1528,99 @@ int process_set_mac(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
                memcpy(ap_mac, mac->mac_addr, MAC_ADDR_LEN);
        }
 
-
-       ESP_LOGE(TAG, "Setting mac address \n");
-       ESP_LOG_BUFFER_HEXDUMP(TAG, mac->mac_addr, MAC_ADDR_LEN, ESP_LOG_INFO);
+       ESP_LOGI(TAG, "Setting mac address \n");
        ret = esp_wifi_set_mac(wifi_if_type, mac->mac_addr);
 
        if (ret) {
                ESP_LOGE(TAG, "Failed to set mac address\n");
                cmd_status = CMD_RESPONSE_FAIL;
        }
-
-
-       buf_handle.if_type = if_type;
-       buf_handle.if_num = 0;
-       buf_handle.payload_len = sizeof(struct cmd_config_mac_address);
-       buf_handle.pkt_type = PACKET_TYPE_COMMAND_RESPONSE;
-
-       buf_handle.payload = heap_caps_malloc(buf_handle.payload_len, MALLOC_CAP_DMA);
-       assert(buf_handle.payload);
-       memset(buf_handle.payload, 0, buf_handle.payload_len);
-
-       header = (struct cmd_config_mac_address *) buf_handle.payload;
-
-       header->header.cmd_code = CMD_SET_MAC;
-       header->header.len = 0;
-       header->header.cmd_status = cmd_status;
-
-       if (cmd_status == CMD_RESPONSE_SUCCESS) {
-               memcpy(header->mac_addr, mac->mac_addr, sizeof(header->mac_addr));
-               header->header.len = htole16(sizeof(header->mac_addr));
-       }
-
-       buf_handle.priv_buffer_handle = buf_handle.payload;
-       buf_handle.free_buf_handle = free;
-
-       ret = send_command_response(&buf_handle);
-       if (ret != pdTRUE) {
-               ESP_LOGE(TAG, "Slave -> Host: Failed to send command response\n");
-               goto DONE;
-       }
-
-       return ESP_OK;
-
-DONE:
-       if (buf_handle.payload) {
-               free(buf_handle.payload);
-               buf_handle.payload = NULL;
-       }
-
+       ret = send_command_resp(if_type, CMD_SET_MAC, cmd_status, (uint8_t *)mac->mac_addr,
+                               MAC_ADDR_LEN, sizeof(struct command_header));
        return ret;
 }
 
-
-
 int process_set_default_key(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
 {
-       struct command_header *header = NULL;
-       interface_buffer_handle_t buf_handle = {0};
        esp_err_t ret = ESP_OK;
-       struct wifi_sec_key * key = NULL;
        struct cmd_key_operation *cmd = NULL;
+       uint16_t cmd_status;
 
        /*ESP_LOGI(TAG, "%s:%u\n", __func__, __LINE__);*/
 
-       buf_handle.payload_len = sizeof(struct command_header) + sizeof (struct esp_payload_header);
-       buf_handle.payload = heap_caps_malloc(buf_handle.payload_len, MALLOC_CAP_DMA);
-       if (!buf_handle.payload) {
-               ESP_LOGE(TAG , "Malloc send buffer fail!");
-               return ESP_FAIL;
-       }
-       memset(buf_handle.payload, 0, buf_handle.payload_len);
-
-       header = (struct command_header *) buf_handle.payload;
-       header->cmd_code = CMD_SET_DEFAULT_KEY;
-       header->len = 0;
-
        cmd = (struct cmd_key_operation *) payload;
-
        if (!cmd) {
                ESP_LOGE(TAG, "%s:%u command failed\n", __func__, __LINE__);
-               header->cmd_status = CMD_RESPONSE_FAIL;
-               goto SEND_CMD;
-       }
-
-       key = &cmd->key;
-
-       if (!key || !key->set_cur) {
-               ESP_LOGE(TAG, "%s:%u command failed\n", __func__, __LINE__);
-               header->cmd_status = CMD_RESPONSE_FAIL;
+               cmd_status = CMD_RESPONSE_FAIL;
                goto SEND_CMD;
        }
 
        /* Firmware just responds to this request as success. */
-       header->cmd_status = CMD_RESPONSE_SUCCESS;
+       cmd_status = CMD_RESPONSE_SUCCESS;
 
 SEND_CMD:
-       buf_handle.if_type = if_type;
-       buf_handle.if_num = 0;
-       buf_handle.payload_len = sizeof(struct command_header);
-       buf_handle.pkt_type = PACKET_TYPE_COMMAND_RESPONSE;
-
-       buf_handle.priv_buffer_handle = buf_handle.payload;
-       buf_handle.free_buf_handle = free;
-
-       /* Send command response */
-       ret = send_command_response(&buf_handle);
-       if (ret != pdTRUE) {
-               ESP_LOGE(TAG, "Slave -> Host: Failed to send command response\n");
-               goto DONE;
-       }
-
-       return ESP_OK;
-
-DONE:
-       if (buf_handle.payload) {
-               free(buf_handle.payload);
-               buf_handle.payload = NULL;
-       }
+       ret = send_command_resp(if_type, CMD_SET_DEFAULT_KEY, cmd_status, NULL, 0, 0);
 
        return ret;
 }
 
 int process_del_key(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
 {
-       struct command_header *header = NULL;
-       interface_buffer_handle_t buf_handle = {0};
        esp_err_t ret = ESP_OK;
        struct wifi_sec_key * key = NULL;
        struct cmd_key_operation *cmd = NULL;
+       uint16_t cmd_status = CMD_RESPONSE_SUCCESS;
 
        /*ESP_LOGI(TAG, "%s:%u\n", __func__, __LINE__);*/
 
-       buf_handle.payload_len = sizeof(struct command_header) + sizeof (struct esp_payload_header);
-       buf_handle.payload = heap_caps_malloc(buf_handle.payload_len, MALLOC_CAP_DMA);
-       if (!buf_handle.payload) {
-               ESP_LOGE(TAG , "Malloc send buffer fail!");
-               return ESP_FAIL;
-       }
-       memset(buf_handle.payload, 0, buf_handle.payload_len);
-
-       header = (struct command_header *) buf_handle.payload;
-       header->cmd_code = CMD_DEL_KEY;
-       header->len = 0;
-
        cmd = (struct cmd_key_operation *) payload;
 
        if (!cmd) {
                ESP_LOGE(TAG, "%s:%u command failed\n", __func__, __LINE__);
-               header->cmd_status = CMD_RESPONSE_FAIL;
-               goto SEND_CMD;
+               cmd_status = CMD_RESPONSE_FAIL;
+               goto send_resp;
        }
 
        key = &cmd->key;
 
-       if (!key || !key->del) {
+       if (!key->del) {
                ESP_LOGE(TAG, "%s:%u command failed\n", __func__, __LINE__);
-               header->cmd_status = CMD_RESPONSE_FAIL;
-               goto SEND_CMD;
-       }
-
-       /* Firmware just responds to this request as success */
-       header->cmd_status = CMD_RESPONSE_SUCCESS;
-
-SEND_CMD:
-       buf_handle.if_type = if_type;
-       buf_handle.if_num = 0;
-       buf_handle.payload_len = sizeof(struct command_header);
-       buf_handle.pkt_type = PACKET_TYPE_COMMAND_RESPONSE;
-
-       buf_handle.priv_buffer_handle = buf_handle.payload;
-       buf_handle.free_buf_handle = free;
-
-       /* Send command response */
-       ret = send_command_response(&buf_handle);
-       if (ret != pdTRUE) {
-               ESP_LOGE(TAG, "Slave -> Host: Failed to send command response\n");
-               goto DONE;
+               cmd_status = CMD_RESPONSE_FAIL;
+               goto send_resp;
        }
 
-       return ESP_OK;
-
-DONE:
-       if (buf_handle.payload) {
-               free(buf_handle.payload);
-               buf_handle.payload = NULL;
-       }
+send_resp:
+       ret = send_command_resp(if_type, CMD_DEL_KEY, cmd_status, NULL, 0, 0);
 
        return ret;
 }
 
-int process_add_key(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
+static int set_key_internal(void *data)
 {
-       struct command_header *header = NULL;
-       interface_buffer_handle_t buf_handle = {0};
-       esp_err_t ret = ESP_OK;
-       struct wifi_sec_key * key = NULL;
+       wifi_interface_t iface = WIFI_IF_STA;
        struct cmd_key_operation *cmd = NULL;
+       struct wifi_sec_key * key = NULL;
+       uint8_t if_type;
+       int ret;
 
        ESP_LOGI(TAG, "%s:%u\n", __func__, __LINE__);
 
-       buf_handle.payload_len = sizeof(struct command_header) + sizeof (struct esp_payload_header);
-       buf_handle.payload = heap_caps_malloc(buf_handle.payload_len, MALLOC_CAP_DMA);
-       if (!buf_handle.payload) {
-               ESP_LOGE(TAG , "Malloc send buffer fail!");
-               return ESP_FAIL;
-       }
-       memset(buf_handle.payload, 0, buf_handle.payload_len);
-
-       header = (struct command_header *) buf_handle.payload;
-       header->cmd_code = CMD_ADD_KEY;
-       header->len = 0;
-
-       cmd = (struct cmd_key_operation *) payload;
+       cmd = (struct cmd_key_operation *) data;
 
+       if_type = cmd->header.reserved1;
+       if (if_type == ESP_AP_IF) {
+               iface = WIFI_IF_AP;
+       }
        if (!cmd) {
                ESP_LOGE(TAG, "%s:%u command failed\n", __func__, __LINE__);
-               header->cmd_status = CMD_RESPONSE_FAIL;
-               goto SEND_CMD;
+               return -1;
        }
 
        key = &cmd->key;
 
-       if (!key) {
-               ESP_LOGE(TAG, "%s:%u command failed\n", __func__, __LINE__);
-               header->cmd_status = CMD_RESPONSE_FAIL;
-               goto SEND_CMD;
-       }
-
        if (key->algo == WIFI_WPA_ALG_WEP40 || key->algo == WIFI_WPA_ALG_WEP104) {
-               header->cmd_status = CMD_RESPONSE_SUCCESS;
-               goto SEND_CMD;
-       }
+           return 0;
+    }
        if (key->index) {
                if (key->algo == WIFI_WPA_ALG_IGTK) {
                        wifi_wpa_igtk_t igtk = {0};
@@ -1916,42 +1630,263 @@ int process_add_key(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
                        memcpy(igtk.igtk, key->data, key->len);
                        memcpy(igtk.pn, key->seq, key->seq_len);
                        WPA_PUT_LE16(igtk.keyid, key->index);
-                       ret = esp_wifi_set_igtk_internal(0, &igtk);
+                       ret = esp_wifi_set_igtk_internal(iface, &igtk);
                } else {
                        /* GTK */
                        ESP_LOGI(TAG, "Setting GTK [%ld]\n", key->index);
-                       ret = esp_wifi_set_sta_key_internal(key->algo, key->mac_addr, key->index,
+                       if (iface == WIFI_IF_AP) {
+                               ret = esp_wifi_set_ap_key_internal(key->algo, key->mac_addr, key->index,
+                                               key->data, key->len);
+                       } else {
+                               ret = esp_wifi_set_sta_key_internal(key->algo, key->mac_addr, key->index,
                                        0, key->seq, key->seq_len, key->data, key->len, 
                                        KEY_FLAG_GROUP | KEY_FLAG_RX);
+                               esp_wifi_auth_done_internal();
+                       }
                }
        } else {
                /* PTK */
-               ret = esp_wifi_set_sta_key_internal(key->algo, key->mac_addr, key->index,
+               ESP_LOGI(TAG, "Setting PTK \n");
+               if (iface == WIFI_IF_AP) {
+                       ret = esp_wifi_set_ap_key_internal(key->algo, key->mac_addr, key->index,
+                                               key->data, key->len);
+                       esp_wifi_wpa_ptk_init_done_internal(key->mac_addr);
+               } else {
+                       ret = esp_wifi_set_sta_key_internal(key->algo, key->mac_addr, key->index,
                                1, key->seq, key->seq_len, key->data, key->len, 
                                KEY_FLAG_PAIRWISE | KEY_FLAG_RX | KEY_FLAG_TX);
+               }
        }
        if (ret) {
                ESP_LOGE(TAG, "%s:%u driver key set failed\n", __func__, __LINE__);
-               header->cmd_status = CMD_RESPONSE_FAIL;
-               goto SEND_CMD;
        }
 
-       if (key->index) {
-               esp_wifi_auth_done_internal();
-               ESP_LOGI(TAG, "%s:%u auth done\n", __func__, __LINE__);
+       return ret;
+}
+
+static int wifi_set_keys(void *args)
+{
+        wifi_ipc_config_t cfg;
+
+        cfg.fn = set_key_internal;
+        cfg.arg = args;
+        cfg.arg_size = 0;
+        return esp_wifi_ipc_internal(&cfg, true);
+}
+
+int process_add_key(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
+{
+       esp_err_t ret = ESP_OK;
+       struct cmd_key_operation *cmd = NULL;
+       uint8_t cmd_status;
+
+       cmd = (struct cmd_key_operation *) payload;
+       if (!cmd) {
+               ESP_LOGE(TAG, "%s:%u command failed\n", __func__, __LINE__);
+               cmd_status = CMD_RESPONSE_FAIL;
+               goto SEND_CMD;
        }
+       cmd->header.reserved1 = if_type;
 
-       header->cmd_status = CMD_RESPONSE_SUCCESS;
+       cmd_status = CMD_RESPONSE_SUCCESS;
+       ret = wifi_set_keys(cmd);
+       if (ret)
+               cmd_status = CMD_RESPONSE_FAIL;
 
 SEND_CMD:
-       buf_handle.if_type = if_type;
+       ret = send_command_resp(if_type, CMD_ADD_KEY, cmd_status, NULL, 0, 0);
+       return ret;
+}
+
+int process_set_mode(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
+{
+       esp_err_t ret = ESP_OK;
+       uint8_t cmd_status = CMD_RESPONSE_SUCCESS;
+       struct cmd_config_mode *mode = (struct cmd_config_mode *) payload;
+
+       ESP_LOGE(TAG, "Setting mode=%d \n", mode->mode);
+       ret = esp_wifi_stop();
+       ret = esp_wifi_set_mode(mode->mode);
+       ESP_ERROR_CHECK(esp_wifi_start());
+
+       if (ret) {
+               ESP_LOGE(TAG, "Failed to set mode\n");
+               cmd_status = CMD_RESPONSE_FAIL;
+               goto send_resp;
+       }
+
+send_resp:
+       ret = send_command_resp(if_type, CMD_SET_MODE, cmd_status, (uint8_t *)&mode->mode,
+                               sizeof(uint16_t), sizeof(struct command_header));
+
+       return ret;
+}
+
+int process_set_ie(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
+{
+       esp_err_t ret = ESP_OK;
+       uint8_t cmd_status = CMD_RESPONSE_SUCCESS;
+       struct cmd_config_ie *ie = (struct cmd_config_ie *) payload;
+       int type = 0;
+
+       ESP_LOGI(TAG, "Setting %d IEs len=%d\n", ie->ie_type, ie->ie_len);
+
+       if (if_type != ESP_AP_IF) {
+               cmd_status = CMD_RESPONSE_INVALID;
+               goto send_resp;
+       }
+       if (ie->ie_type == IE_BEACON) {
+               type = WIFI_APPIE_RAM_BEACON;
+               ESP_LOG_BUFFER_HEXDUMP("BEACON", (uint8_t *) ie->ie, ie->ie_len, ESP_LOG_INFO);
+       } else if (ie->ie_type == IE_PROBE_RESP) {
+               type = WIFI_APPIE_RAM_PROBE_RSP;
+               ESP_LOG_BUFFER_HEXDUMP("PROBE", (uint8_t *) ie->ie, ie->ie_len, ESP_LOG_INFO);
+       } else if (ie->ie_type == IE_ASSOC_RESP) {
+               type = WIFI_APPIE_ASSOC_RESP;
+       } else if (ie->ie_type == IE_RSN) {
+               if (ap_rsn_ie)
+                       free(ap_rsn_ie);
+               ap_rsn_ie = malloc(ie->ie_len);
+               memcpy(ap_rsn_ie, ie->ie, ie->ie_len);
+               ap_rsn_ie_len = ie->ie_len;
+               /* ESP_LOG_BUFFER_HEXDUMP("RSN IE", (uint8_t *) ie->ie, ie->ie_len, ESP_LOG_INFO); */
+       } else {
+               cmd_status = CMD_RESPONSE_INVALID;
+               goto send_resp;
+       }
+
+       if (ie->ie_type != IE_RSN) {
+               ret = esp_wifi_set_appie_internal(type, ie->ie, ie->ie_len, 0);
+       }
+       if (ret) {
+               cmd_status = CMD_RESPONSE_INVALID;
+       }
+send_resp:
+       ret = send_command_resp(if_type, CMD_SET_IE, cmd_status, NULL, 0, 0);
+
+       return ret;
+}
+
+static int send_mgmt_tx_done(uint8_t cmd_status, wifi_interface_t wifi_if_type, uint8_t *data, uint32_t len);
+
+
+uint8_t *esp_wifi_get_eb_data(void *eb);
+uint32_t esp_wifi_get_eb_data_len(void *eb);
+
+void ieee80211_tx_mgt_cb(void *eb);
+
+static void mgmt_txcb(void *eb)
+{
+       uint8_t cmd_status = CMD_RESPONSE_FAIL;
+
+       if (esp_wifi_eb_tx_status_success_internal(eb)) {
+               cmd_status = CMD_RESPONSE_SUCCESS;
+       }
+
+       uint8_t *data = esp_wifi_get_eb_data(eb);
+       uint32_t len = esp_wifi_get_eb_data_len(eb);
+
+       ieee80211_tx_mgt_cb(eb);
+       //printf("tx cb status=%d data_len=%ld\n", cmd_status, len);
+       //ESP_LOG_BUFFER_HEXDUMP(TAG, data, len, ESP_LOG_INFO);
+       send_mgmt_tx_done(cmd_status, WIFI_IF_AP, data, len);
+}
+
+typedef enum {
+    ETS_OK     = 0, /**< return successful in ets*/
+    ETS_FAILED = 1, /**< return failed in ets*/
+    ETS_PENDING = 2,
+    ETS_BUSY = 3,
+    ETS_CANCEL = 4,
+} ETS_STATUS;
+ETS_STATUS pp_unregister_tx_cb(uint8_t id);
+
+esp_err_t wlan_ap_rx_callback(void *buffer, uint16_t len, void *eb);
+int process_set_ap_config(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
+{
+       esp_err_t ret = ESP_OK;
+       uint8_t cmd_status = CMD_RESPONSE_SUCCESS;
+       struct cmd_ap_config *ap_config = (struct cmd_ap_config *) payload;
+
+       if (if_type != ESP_AP_IF) {
+               cmd_status = CMD_RESPONSE_INVALID;
+               goto send_resp;
+       }
+
+       wifi_config_t wifi_config = {0};
+
+       memcpy(wifi_config.ap.ssid, ap_config->ap_config.ssid, ap_config->ap_config.ssid_len);
+       wifi_config.ap.ssid_len = ap_config->ap_config.ssid_len;
+       wifi_config.ap.channel = ap_config->ap_config.channel;
+       wifi_config.ap.authmode = ap_config->ap_config.authmode;
+       wifi_config.ap.ssid_hidden = ap_config->ap_config.ssid_hidden;
+       wifi_config.ap.beacon_interval = ap_config->ap_config.beacon_interval;
+//     wifi_config.ap.pairwise_cipher = ap_config->ap_config.pairwise_cipher;
+       if (ap_config->ap_config.authmode != WIFI_AUTH_OPEN) {
+               strcpy((char *)wifi_config.ap.password, "1234567890");
+       } else {
+               ap_rsn_ie_len = 0;
+               if (ap_rsn_ie) {
+                       free(ap_rsn_ie);
+                       ap_rsn_ie = NULL;
+               }
+       }
+
+       ESP_LOGI(TAG, "ap config ssid=%s ssid_len=%d, pass=%s channel=%d authmode=%d hidden=%d bi=%d cipher=%d\n",
+                       wifi_config.ap.ssid, wifi_config.ap.ssid_len,
+                       wifi_config.ap.password,
+                       wifi_config.ap.channel, wifi_config.ap.authmode,
+                       wifi_config.ap.ssid_hidden, wifi_config.ap.beacon_interval,
+                       wifi_config.ap.pairwise_cipher);
+
+       wifi_config.ap.max_connection = 8;
+       ret = esp_wifi_stop();
+       esp_wifi_set_config(WIFI_IF_AP, &wifi_config);
+
+#define WIFI_TXCB_MGMT_ID 2
+       /* register for mgmt tx done */
+       ret = pp_unregister_tx_cb(WIFI_TXCB_MGMT_ID);
+       ESP_LOGI(TAG, "tx cb unregister ret=%d\n", ret);
+       ret = esp_wifi_register_tx_cb_internal(mgmt_txcb, WIFI_TXCB_MGMT_ID);
+       ESP_LOGI(TAG, "tx cb register ret=%d\n", ret);
+       ret = esp_wifi_internal_reg_rxcb(ESP_IF_WIFI_AP, (wifi_rxcb_t)wlan_ap_rx_callback);
+#undef WIFI_TXCB_MGMT_ID
+       ESP_ERROR_CHECK(esp_wifi_start());
+send_resp:
+       ret = send_command_resp(if_type, CMD_AP_CONFIG, cmd_status, NULL, 0, 0);
+
+       return ret;
+}
+
+static int send_mgmt_tx_done(uint8_t cmd_status, wifi_interface_t wifi_if_type, uint8_t *data, uint32_t len)
+{
+       interface_buffer_handle_t buf_handle = {0};
+       struct cmd_mgmt_tx *header;
+       esp_err_t ret = ESP_OK;
+
+       if (wifi_if_type == WIFI_IF_AP)
+               buf_handle.if_type = ESP_AP_IF;
+       else
+               buf_handle.if_type = ESP_STA_IF;
        buf_handle.if_num = 0;
+       buf_handle.payload_len = sizeof(struct cmd_mgmt_tx) + len;
        buf_handle.pkt_type = PACKET_TYPE_COMMAND_RESPONSE;
 
+       buf_handle.payload = heap_caps_malloc(buf_handle.payload_len, MALLOC_CAP_DMA);
+       assert(buf_handle.payload);
+       memset(buf_handle.payload, 0, buf_handle.payload_len);
+
+       header = (struct cmd_mgmt_tx *) buf_handle.payload;
+
+       header->header.cmd_code = CMD_MGMT_TX;
+       header->header.len = 0;
+       header->header.cmd_status = cmd_status;
+       header->len = len - TX_DONE_PREFIX;
+       memcpy(header->buf, data + TX_DONE_PREFIX, header->len);
+
        buf_handle.priv_buffer_handle = buf_handle.payload;
        buf_handle.free_buf_handle = free;
 
-       /* Send command response */
        ret = send_command_response(&buf_handle);
        if (ret != pdTRUE) {
                ESP_LOGE(TAG, "Slave -> Host: Failed to send command response\n");
@@ -1959,11 +1894,103 @@ SEND_CMD:
        }
 
        return ESP_OK;
-
 DONE:
        if (buf_handle.payload) {
                free(buf_handle.payload);
                buf_handle.payload = NULL;
        }
+
        return ret;
 }
+
+int ieee80211_send_mgmt_internal(wifi_interface_t wifi_if_type, uint8_t *buf, size_t len);
+
+static uint8_t broadcast_mac[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
+#define IS_BROADCAST_ADDR(addr) (memcmp(addr, broadcast_mac, ETH_ALEN) == 0)
+
+int process_mgmt_tx(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
+{
+       esp_err_t ret = ESP_OK;
+       wifi_interface_t wifi_if_type = WIFI_IF_AP;
+       uint8_t cmd_status = CMD_RESPONSE_SUCCESS;
+       struct cmd_mgmt_tx *mgmt_tx = (struct cmd_mgmt_tx *) payload;
+
+       if (if_type != ESP_AP_IF) {
+               ESP_LOGE(TAG, "%s: err on wrong interface=%d\n", __func__, if_type);
+               cmd_status = CMD_RESPONSE_INVALID;
+               wifi_if_type = ESP_STA_IF;
+               goto send_resp;
+       }
+
+       /* ESP_LOG_BUFFER_HEXDUMP("sending frame", mgmt_tx->buf, mgmt_tx->len, ESP_LOG_INFO); */
+
+       ret = ieee80211_send_mgmt_internal(WIFI_IF_AP, mgmt_tx->buf, mgmt_tx->len);
+
+       if (ret) {
+               cmd_status = CMD_RESPONSE_INVALID;
+               goto send_resp;
+       }
+
+       if (IS_BROADCAST_ADDR(mgmt_tx->buf + 4)) {
+               ESP_LOGI(TAG, "%s: broadcast address, sending response immediately\n", __func__);
+               goto send_resp;
+       }
+       /* send response in seperate ctx once done */
+       return 0;
+send_resp:
+       return send_mgmt_tx_done(cmd_status, wifi_if_type, NULL, 0);
+}
+
+int ieee80211_add_node(wifi_interface_t wifi_if_type, uint8_t *mac, uint16_t aid,
+                       uint8_t *rates, uint8_t *htcap, uint8_t *vhtcap, uint8_t *hecap);
+
+
+int add_station_node_ap(void *data)
+{
+       struct cmd_ap_add_sta_config *sta = (struct cmd_ap_add_sta_config *) data;
+
+       ESP_LOG_BUFFER_HEXDUMP("mac", sta->sta_param.mac, 6, ESP_LOG_INFO);
+       ESP_LOGI(TAG,"aid=%d\n", sta->sta_param.aid);
+
+       ESP_LOG_BUFFER_HEXDUMP("supported_rates", sta->sta_param.supported_rates, 12, ESP_LOG_INFO);
+       ESP_LOG_BUFFER_HEXDUMP("ht_rates", sta->sta_param.ht_caps, 28, ESP_LOG_INFO);
+       ESP_LOG_BUFFER_HEXDUMP("vht_rates", sta->sta_param.vht_caps, 14, ESP_LOG_INFO);
+       ESP_LOG_BUFFER_HEXDUMP("he_rates", sta->sta_param.he_caps, 27, ESP_LOG_INFO);
+       if (sta->sta_param.cmd != ADD_STA) {
+               ESP_LOGI(TAG, "%s: not station add cmd, handle later\n", __func__);
+               return 0;
+       }
+       return ieee80211_add_node(WIFI_IF_AP, sta->sta_param.mac, sta->sta_param.aid,
+                       sta->sta_param.supported_rates[0] ? sta->sta_param.supported_rates : NULL,
+                       sta->sta_param.ht_caps[0] ? sta->sta_param.ht_caps : NULL,
+                       sta->sta_param.vht_caps[0] ? sta->sta_param.vht_caps : NULL,
+                       sta->sta_param.he_caps[0] ? sta->sta_param.he_caps : NULL);
+}
+
+static int add_node_ap(void *args)
+{
+        wifi_ipc_config_t cfg;
+
+        cfg.fn = add_station_node_ap;
+        cfg.arg = args;
+        cfg.arg_size = 0;
+        return esp_wifi_ipc_internal(&cfg, true);
+}
+
+int process_ap_station(uint8_t if_type, uint8_t *payload, uint16_t payload_len)
+{
+       uint8_t cmd_status = CMD_RESPONSE_SUCCESS;
+
+       if (if_type != ESP_AP_IF) {
+               ESP_LOGE(TAG, "%s: err on wrong interface=%d\n", __func__, if_type);
+               cmd_status = CMD_RESPONSE_INVALID;
+               goto send_resp;
+       }
+
+       ESP_LOGI(TAG, "%s:got station add command\n", __func__);
+       /* ESP_LOG_BUFFER_HEXDUMP("sending frame", mgmt_tx->buf, mgmt_tx->len, ESP_LOG_INFO); */
+       add_node_ap(payload);
+       //esp_wifi_add_node(WIFI_IF_AP, );
+send_resp:
+       return send_command_resp(if_type, CMD_AP_STATION, cmd_status, NULL, 0, 0);
+}
index dc6841655777e8155bf16e31566e8846bd854fbb..c885fc66d5adc6d09e2b6a2b02cb1274da68692c 100644 (file)
@@ -124,9 +124,7 @@ struct wpa_funcs {
     bool (*wpa_sta_in_4way_handshake)(void);
     int *(*wpa_ap_init)(void);
     int (*wpa_ap_deinit)(void *data);
-    int (*wpa_ap_join)(uint8_t *bssid, uint8_t *wpa_ie, uint8_t wpa_ie_len,
-                       uint8_t* rsnxe, uint8_t rsnxe_len, bool *pmf_enable,
-                       int subtype);
+    int (*wpa_ap_join)(uint8_t *bssid, uint8_t *wpa_ie, uint8_t wpa_ie_len, uint8_t* rsnxe, uint8_t rsnxe_len, bool *pmf_enable, int subtype);
     int (*wpa_ap_remove)(uint8_t *addr);
     uint8_t *(*wpa_ap_get_wpa_ie)(uint8_t *len);
     int (*wpa_ap_rx_eapol)(uint8_t *addr, uint8_t *data, size_t data_len);
@@ -135,17 +133,13 @@ struct wpa_funcs {
     int (*wpa_parse_wpa_ie)(const uint8_t *wpa_ie, size_t wpa_ie_len, wifi_wpa_ie_t *data);
     int (*wpa_config_bss)(uint8_t *bssid);
     int (*wpa_michael_mic_failure)(uint16_t is_unicast);
-    uint8_t *(*wpa3_build_sae_msg)(uint8_t *bssid, uint32_t type, size_t *len);
-    int (*wpa3_parse_sae_msg)(uint8_t *buf, size_t len, uint32_t type, uint16_t status);
-    int (*wpa3_hostap_handle_auth)(uint8_t *buf, size_t len, uint32_t type, uint16_t status,
-                                   uint8_t *bssid);
-    int (*wpa_sta_rx_mgmt)(uint8_t type, uint8_t *frame, size_t len, uint8_t *sender,
-                           uint32_t rssi, uint8_t channel, uint64_t current_tsf);
+    int (*wpa3_hostap_handle_auth)(uint8_t *buf, size_t len, uint32_t type, uint16_t status, uint8_t *bssid);
+    int (*wpa_sta_rx_mgmt)(uint8_t type, uint8_t *frame, size_t len, uint8_t *sender, uint32_t rssi, uint8_t channel, uint64_t current_tsf);
     void (*wpa_config_done)(void);
     uint8_t *(*owe_build_dhie)(uint16_t group);
-    int (*owe_process_assoc_resp)(const uint8_t *rsn_ie, size_t rsn_len,
-                                  const uint8_t *dh_ie, size_t dh_len);
+    int (*owe_process_assoc_resp)(const uint8_t *rsn_ie, size_t rsn_len, const uint8_t *dh_ie, size_t dh_len);
     int (*wpa_sta_set_ap_rsnxe)(const uint8_t *rsnxe, size_t rsnxe_ie_len);
+    int (*wpa_ap_rx_mgmt)(void *pkt, uint32_t pkt_len, uint8_t chan, int rssi, int nf);
 };
 
 struct wpa2_funcs {
@@ -301,8 +295,9 @@ bool esp_wifi_ap_notify_node_sae_auth_done(uint8_t *mac);
 bool esp_wifi_ap_is_sta_sae_reauth_node(uint8_t *mac);
 uint8_t* esp_wifi_sta_get_sae_identifier_internal(void);
 bool esp_wifi_eb_tx_status_success_internal(void *eb);
-esp_err_t esp_wifi_connect_internal(const uint8_t *bssid);
-esp_err_t esp_wifi_issue_auth_internal(uint8_t status);
-esp_err_t esp_wifi_issue_assoc_internal(uint8_t status);
+void esp_wifi_sta_toggle_wpa3_security(bool disable);
+esp_err_t esp_wifi_sta_connect_internal(const uint8_t *bssid);
+esp_err_t esp_wifi_send_auth_internal(uint8_t ifx, uint8_t *bssid, uint8_t algo, uint8_t seq, uint32_t status);
+esp_err_t esp_wifi_send_assoc_internal(uint8_t ifx, uint8_t *bssid, uint8_t type, uint8_t status);
 
 #endif /* _ESP_WIFI_DRIVER_H_ */
index 9103e52e61b63fa1eafc319303e779e8e17f0482..309d0e239e3feb5eb6f396d1f40927e00ae44867 100644 (file)
@@ -4,8 +4,6 @@
 #ifndef __ESP_NETWORK_ADAPTER__H
 #define __ESP_NETWORK_ADAPTER__H
 
-#include <sys/cdefs.h>
-
 #define PRIO_Q_HIGH                     0
 #define PRIO_Q_MID                      1
 #define PRIO_Q_LOW                      2
@@ -39,7 +37,7 @@ struct esp_payload_header {
                uint8_t      priv_pkt_type;   /* Packet type for priv interface */
        };
        /* Do no add anything here */
-} __packed;
+} __attribute__((packed));
 
 struct ieee_mgmt_header {
        uint16_t   frame_control;
@@ -48,9 +46,9 @@ struct ieee_mgmt_header {
        uint8_t    sa[MAC_ADDR_LEN];
        uint8_t    bssid[MAC_ADDR_LEN];
        uint16_t   seq_ctrl;
-} __packed;
+}__attribute__((packed));
 
-enum ESP_INTERFACE_TYPE {
+enum ESP_INTERFACE_TYPE{
        ESP_STA_IF,
        ESP_AP_IF,
        ESP_HCI_IF,
@@ -59,6 +57,13 @@ enum ESP_INTERFACE_TYPE {
        ESP_MAX_IF,
 };
 
+enum ESP_IE_TYPE{
+        IE_BEACON,
+        IE_PROBE_RESP,
+        IE_ASSOC_RESP,
+       IE_RSN,
+};
+
 enum ESP_PACKET_TYPE {
        PACKET_TYPE_DATA,
        PACKET_TYPE_COMMAND_REQUEST,
@@ -109,7 +114,7 @@ enum COMMAND_CODE {
        CMD_GET_MAC,
        CMD_SCAN_REQUEST,
        CMD_STA_CONNECT,
-       CMD_STA_DISCONNECT,
+       CMD_DISCONNECT,
        CMD_DEINIT_INTERFACE,
        CMD_ADD_KEY,
        CMD_DEL_KEY,
@@ -125,6 +130,11 @@ enum COMMAND_CODE {
        CMD_RAW_TP_ESP_TO_HOST,
        CMD_RAW_TP_HOST_TO_ESP,
        CMD_SET_WOW_CONFIG,
+       CMD_SET_MODE,
+       CMD_SET_IE,
+       CMD_AP_CONFIG,
+       CMD_MGMT_TX,
+       CMD_AP_STATION,
        CMD_MAX,
 };
 
@@ -134,6 +144,7 @@ enum EVENT_CODE {
        EVENT_STA_DISCONNECT,
        EVENT_AUTH_RX,
        EVENT_ASSOC_RX,
+       EVENT_AP_MGMT_RX,
 };
 
 enum COMMAND_RESPONSE_TYPE {
@@ -161,13 +172,38 @@ struct scan_request {
        char       ssid[MAX_SSID_LEN+1];
        uint8_t    channel;
        uint8_t    pad[2];
-} __packed;
+}__attribute__((packed));
 
 struct cmd_config_mac_address {
        struct     command_header header;
        uint8_t    mac_addr[MAC_ADDR_LEN];
        uint8_t    pad[2];
-} __packed;
+}__attribute__((packed));
+
+#define ADD_STA 0
+#define CHANGE_STA 1
+#define DEL_STA 2
+
+struct cmd_ap_sta_param {
+       uint8_t mac[6];
+       uint16_t cmd;
+       uint32_t sta_flags_mask, sta_flags_set;
+       uint32_t sta_modify_mask;
+       int32_t listen_interval;
+       uint16_t aid;
+       uint8_t ext_capab[6];
+       uint8_t supported_rates[12];
+       uint8_t ht_caps[28];
+       uint8_t vht_caps[14];
+       uint8_t pad1[2];
+       uint8_t he_caps[27];
+       uint8_t pad2;
+}__attribute__((packed));
+
+struct cmd_ap_add_sta_config {
+       struct command_header header;
+       struct cmd_ap_sta_param sta_param;
+}__attribute__((packed));
 
 struct cmd_sta_auth {
        struct     command_header header;
@@ -180,14 +216,25 @@ struct cmd_sta_auth {
        uint8_t    auth_data_len;
        uint8_t    pad[2];
        uint8_t    auth_data[];
-} __packed;
+}__attribute__((packed));
+
+struct cmd_mgmt_tx {
+       struct     command_header header;
+       uint8_t    channel;
+       uint8_t    offchan;
+       uint32_t   wait;
+       uint8_t    no_cck;
+       uint8_t    dont_wait_for_ack;
+       uint32_t   len;
+       uint8_t    buf[];
+}__attribute__((packed));
 
 struct cmd_sta_assoc {
        struct     command_header header;
        uint8_t    assoc_ie_len;
        uint8_t    pad[3];
        uint8_t    assoc_ie[];
-} __packed;
+}__attribute__((packed));
 
 struct cmd_sta_connect {
        struct     command_header header;
@@ -198,24 +245,24 @@ struct cmd_sta_connect {
        uint8_t    is_auth_open;
        uint8_t    assoc_ie_len;
        uint8_t    assoc_ie[];
-} __packed;
+}__attribute__((packed));
 
-struct cmd_sta_disconnect {
+struct cmd_disconnect {
        struct     command_header header;
        uint16_t   reason_code;
-       uint8_t    pad[2];
-} __packed;
+       uint8_t    mac[MAC_ADDR_LEN];
+}__attribute__((packed));
 
 struct cmd_set_ip_addr {
        struct command_header header;
        uint32_t ip;
-} __packed;
+}__attribute__((packed));
 
 struct cmd_set_mcast_mac_addr {
        struct command_header header;
        uint8_t count;
        uint8_t mcast_addr[MAX_MULTICAST_ADDR_COUNT][MAC_ADDR_LEN];
-} __packed;
+}__attribute__((packed));
 
 struct wifi_sec_key {
        uint32_t   algo;
@@ -228,12 +275,12 @@ struct wifi_sec_key {
        uint8_t    del;
        uint8_t    set_cur;
        uint8_t    pad[2];
-} __packed;
+}__attribute__((packed));
 
 struct cmd_set_get_val {
        struct     command_header header;
        uint32_t   value;
-} __packed;
+}__attribute__((packed));
 
 struct cmd_wow_config {
        struct command_header header;
@@ -242,28 +289,28 @@ struct cmd_wow_config {
        uint8_t magic_pkt;
        uint8_t four_way_handshake;
        uint8_t eap_identity_req;
-} __packed;
+}__attribute__((packed));
 
 struct cmd_raw_tp {
        struct     command_header header;
        uint32_t   value;
-} __packed;
+}__attribute__((packed));
 
 struct cmd_reg_domain {
        struct     command_header header;
        char       country_code[4];  /* 4 for padding */
-} __packed;
+}__attribute__((packed));
 
 struct cmd_key_operation {
        struct     command_header header;
        struct     wifi_sec_key key;
-} __packed;
+}__attribute__((packed));
 
 struct event_header {
        uint8_t    event_code;
        uint8_t    status;
        uint16_t   len;
-} __packed;
+}__attribute__((packed));
 
 struct scan_event {
        struct     event_header header;
@@ -275,7 +322,7 @@ struct scan_event {
        uint16_t   frame_len;
        uint8_t    pad[2];
        uint8_t    frame[0];
-} __packed;
+}__attribute__((packed));
 
 struct auth_event {
        struct     event_header header;
@@ -287,7 +334,7 @@ struct auth_event {
        uint16_t   frame_len;
        uint8_t    pad[2];
        uint8_t    frame[0];
-} __packed;
+}__attribute__((packed));
 
 struct assoc_event {
        struct     event_header header;
@@ -300,32 +347,74 @@ struct assoc_event {
        uint32_t   rssi;
        uint64_t   tsf;
        uint8_t    frame[0];
-} __packed;
+}__attribute__((packed));
+
+struct mgmt_frm_event {
+       struct     event_header header;
+       int32_t    nf;
+       int32_t    rssi;
+       int32_t    chan;
+       uint32_t   frame_len;
+       uint8_t    frame[0];
+}__attribute__((packed));
 
 struct disconnect_event {
        struct     event_header header;
        uint8_t    bssid[MAC_ADDR_LEN];
        char       ssid[MAX_SSID_LEN+1];
        uint8_t    reason;
-} __packed;
+}__attribute__((packed));
+
+struct cmd_config_mode {
+       struct     command_header header;
+       uint16_t    mode;
+       uint8_t    pad[2];
+}__attribute__((packed));
+
+struct cmd_config_ie {
+       struct     command_header header;
+       uint8_t    ie_type;
+       uint8_t    pad;
+       uint16_t   ie_len;
+       uint8_t    ie[];
+}__attribute__((packed));
+
+struct esp_ap_config {
+       uint8_t ssid[32];
+       uint8_t ssid_len;
+       uint8_t channel;
+       uint8_t authmode;
+       uint8_t ssid_hidden;
+       uint8_t max_connection;
+       uint8_t pairwise_cipher;
+       uint8_t pmf_cfg;
+       uint8_t sae_pwe_h2e;
+       uint16_t beacon_interval;
+       uint16_t inactivity_timeout;
+}__attribute__((packed));
+
+struct cmd_ap_config {
+       struct command_header header;
+       struct esp_ap_config ap_config;
+}__attribute__((packed));
 
 struct esp_internal_bootup_event {
        struct     event_header header;
        uint8_t    len;
        uint8_t    pad[3];
        uint8_t    data[0];
-} __packed;
+}__attribute__((packed));
 
 struct fw_version {
        uint8_t    major1;
        uint8_t    major2;
        uint8_t    minor;
-} __packed;
+}__attribute__((packed));
 
 struct fw_data {
        struct     fw_version version;
        uint32_t   last_reset_reason;
-} __packed;
+}__attribute__((packed));
 
 
 
index 4ccf6d3bb5fdbf71824a97e5be3e2c41162ad0fc..843dd17fd4e8fb0e621f3b99651e30245751af68 100644 (file)
@@ -39,7 +39,7 @@ int process_start_scan(uint8_t if_type, uint8_t *payload, uint16_t payload_len);
 int process_get_mac(uint8_t if_type);
 int process_set_mac(uint8_t if_type, uint8_t *payload, uint16_t payload_len);
 int process_sta_connect(uint8_t if_type, uint8_t *payload, uint16_t payload_len);
-int process_sta_disconnect(uint8_t if_type, uint8_t *payload, uint16_t payload_len);
+int process_disconnect(uint8_t if_type, uint8_t *payload, uint16_t payload_len);
 int process_add_key(uint8_t if_type, uint8_t *payload, uint16_t payload_len);
 int process_del_key(uint8_t if_type, uint8_t *payload, uint16_t payload_len);
 int process_set_default_key(uint8_t if_type, uint8_t *payload, uint16_t payload_len);
@@ -51,9 +51,17 @@ int process_tx_power(uint8_t if_type, uint8_t *payload, uint16_t payload_len, ui
 int process_reg_set(uint8_t if_type, uint8_t *payload, uint16_t payload_len);
 int process_reg_get(uint8_t if_type, uint8_t *payload, uint16_t payload_len);
 int process_wow_set(uint8_t if_type, uint8_t *payload, uint16_t payload_len);
+int process_set_mode(uint8_t if_type, uint8_t *payload, uint16_t payload_len);
+int process_set_ie(uint8_t if_type, uint8_t *payload, uint16_t payload_len);
+int process_set_ap_config(uint8_t if_type, uint8_t *payload, uint16_t payload_len);
+int process_mgmt_tx(uint8_t if_type, uint8_t *payload, uint16_t payload_len);
+int process_ap_station(uint8_t if_type, uint8_t *payload, uint16_t payload_len);
+int process_tx_power(uint8_t if_type, uint8_t *payload, uint16_t payload_len, uint8_t cmd);
 
 esp_err_t initialise_wifi(void);
 
+void esp_create_wifi_event_loop(void);
+
 inline esp_err_t send_command_response(interface_buffer_handle_t *buf_handle)
 {
        return send_to_host(PRIO_Q_HIGH, buf_handle);
diff --git a/esp_hosted_ng/esp/esp_driver/network_adapter/main/include/wifi_defs.h b/esp_hosted_ng/esp/esp_driver/network_adapter/main/include/wifi_defs.h
new file mode 100644 (file)
index 0000000..b6b1214
--- /dev/null
@@ -0,0 +1,35 @@
+#define WLAN_FC_STYPE_ASSOC_REQ     0
+
+#define WLAN_FC_STYPE_ASSOC_RESP    1
+
+#define WLAN_FC_STYPE_REASSOC_REQ   2
+
+#define WLAN_FC_STYPE_REASSOC_RESP  3
+
+#define WLAN_FC_STYPE_PROBE_REQ     4
+
+#define WLAN_FC_STYPE_PROBE_RESP    5
+
+#define WLAN_FC_STYPE_BEACON        8
+
+#define WLAN_FC_STYPE_ATIM          9
+
+#define WLAN_FC_STYPE_DISASSOC      10
+
+#define WLAN_FC_STYPE_AUTH          11
+
+#define WLAN_FC_STYPE_DEAUTH        12
+
+#define WLAN_FC_STYPE_ACTION        13
+
+
+
+
+#define IEEE_HEADER_SIZE            24
+
+#define DEFAULT_SCAN_LIST_SIZE      20
+
+
+
+
+#define IE_POS_ASSOC_RESP_STATUS    2
index 2a201136845b868d364902de79d042f8c60b6339..62a70ec6982be5fbfac002f3df035c150e9c41e1 100644 (file)
@@ -4,6 +4,7 @@
  *
  * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
  *
+ * SPDX-License-Identifier: GPL-2.0-only
  */
 #include "utils.h"
 #include "esp.h"
@@ -105,6 +106,19 @@ static const u32 esp_cipher_suites[] = {
        WLAN_CIPHER_SUITE_AES_CMAC,
 };
 
+static const u32 esp_cipher_suites_new[] = {
+       WLAN_CIPHER_SUITE_WEP40,
+       WLAN_CIPHER_SUITE_WEP104,
+       WLAN_CIPHER_SUITE_TKIP,
+       WLAN_CIPHER_SUITE_SMS4,
+       WLAN_CIPHER_SUITE_GCMP,
+       WLAN_CIPHER_SUITE_CCMP,
+       WLAN_CIPHER_SUITE_GCMP_256,
+       WLAN_CIPHER_SUITE_AES_CMAC,
+       WLAN_CIPHER_SUITE_BIP_GMAC_128,
+       WLAN_CIPHER_SUITE_BIP_GMAC_256,
+};
+
 static const struct wiphy_wowlan_support esp_wowlan_support = {
        .flags = WIPHY_WOWLAN_ANY | WIPHY_WOWLAN_MAGIC_PKT | WIPHY_WOWLAN_DISCONNECT | WIPHY_WOWLAN_4WAY_HANDSHAKE,
        .n_patterns = 0,
@@ -146,18 +160,13 @@ static int esp_inetaddr_event(struct notifier_block *nb,
 
        esp_verbose("------- IP event -------\n");
 
-       if (!strstr(netdev->name, "espsta")) {
-               return 0;
-       }
-
        switch (event) {
 
        case NETDEV_UP:
-               if (priv && (priv->if_type == ESP_STA_IF)) {
+               esp_info("NETDEV_UP interface %s ip changed to  %pi4\n",
+                               netdev->name, &ifa->ifa_local);
+               if (priv && (priv->if_type == ESP_STA_IF))
                        cmd_set_ip_address(priv, ifa->ifa_local);
-                       esp_info("NETDEV_UP interface %s ip changed to  %pi4\n",
-                                       netdev->name, &ifa->ifa_local);
-               }
                break;
 
        case NETDEV_DOWN:
@@ -247,7 +256,6 @@ struct wireless_dev *esp_cfg80211_add_iface(struct wiphy *wiphy,
 
 
        set_bit(ESP_NETWORK_UP, &esp_wdev->priv_flags);
-       clear_bit(ESP_CLEANUP_IN_PROGRESS, &esp_dev->adapter->state_flags);
 
        esp_wdev->nb.notifier_call = esp_inetaddr_event;
        register_inetaddr_notifier(&esp_wdev->nb);
@@ -270,15 +278,74 @@ static int esp_cfg80211_del_iface(struct wiphy *wiphy,
 {
        return 0;
 }
+#endif
+
+static int esp_nl_mode_to_esp_iface(enum nl80211_iftype type)
+{
+       if (type == NL80211_IFTYPE_STATION) {
+               return ESP_STA_IF;
+       } else if (type == NL80211_IFTYPE_AP) {
+               return ESP_AP_IF;
+       }
+
+       return ESP_MAX_IF;
+}
+
+static int8_t esp_get_mode_from_iface_type(int iface_type) {
+       if (iface_type == ESP_AP_IF) {
+               return 2;
+       }
+
+       return 1;
+}
 
 static int esp_cfg80211_change_iface(struct wiphy *wiphy,
-                                                         struct net_device *ndev,
-                                                         enum nl80211_iftype type,
-                                                         struct vif_params *params)
+                                       struct net_device *dev,
+                                       enum nl80211_iftype type,
+                                       struct vif_params *params)
 {
-       return 0;
+       struct esp_wifi_device *priv = NULL;
+       enum ESP_INTERFACE_TYPE esp_if_type;
+       int ret;
+
+       if (!wiphy || !dev) {
+               esp_err("%u invalid params\n", __LINE__);
+               return -EINVAL;
+       }
+
+       priv = netdev_priv(dev);
+       if (!priv) {
+               esp_err("empty priv\n");
+               return -EINVAL;
+       }
+
+       esp_if_type = esp_nl_mode_to_esp_iface(type);
+       esp_info("current iface type=%d new iface type=%d\n", priv->if_type, esp_if_type);
+       if (esp_if_type == ESP_MAX_IF) {
+               esp_err("%u invalid params\n", __LINE__);
+               return -EINVAL;
+       }
+
+       if (esp_if_type == priv->if_type) {
+               esp_info("%u operating in same mode\n", __LINE__);
+               return 0;
+       }
+       ret = cmd_set_mode(priv, esp_get_mode_from_iface_type(esp_if_type));
+
+       if (ret == 0) {
+               priv->if_type = esp_if_type;
+               priv->wdev.iftype = type;
+               /* update Mac address of interface */
+               cmd_get_mac(priv);
+               eth_hw_addr_set(dev, priv->mac_address/*mac_addr->sa_data*/);
+       }
+
+       esp_info("wdev iftype=%d, ret=%d\n", priv->wdev.iftype, ret);
+       if (esp_if_type == ESP_AP_IF)
+               esp_port_open(priv);
+
+       return ret;
 }
-#endif
 
 static int esp_cfg80211_scan(struct wiphy *wiphy,
                struct cfg80211_scan_request *request)
@@ -286,6 +353,7 @@ static int esp_cfg80211_scan(struct wiphy *wiphy,
 
        struct net_device *ndev = NULL;
        struct esp_wifi_device *priv = NULL;
+
        if (!wiphy || !request || !request->wdev || !request->wdev->netdev) {
                esp_info("%u invalid input\n", __LINE__);
                return -EINVAL;
@@ -319,9 +387,31 @@ static int esp_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
 }
 #endif
 
-static ESP_MGMT_TX_PROTOTYPE()
+int esp_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0))
+               struct ieee80211_channel *chan,
+               bool offchan, unsigned int wait, const u8 *buf, size_t len,
+               bool no_cck, bool dont_wait_for_ack,
+#else
+               struct cfg80211_mgmt_tx_params *params,
+#endif
+               u64 *cookie)
 {
-       return 0;
+       struct esp_wifi_device *priv = NULL;
+
+       if (!wiphy || !wdev || !params) {
+               esp_info("%u invalid input\n", __LINE__);
+               return -EINVAL;
+       }
+
+       priv = netdev_priv(wdev->netdev);
+
+       if (!priv) {
+               esp_err("empty priv\n");
+               return 0;
+       }
+
+       return cmd_mgmt_request(priv, params);
 }
 
 static int esp_cfg80211_set_default_key(struct wiphy *wiphy,
@@ -344,6 +434,12 @@ static int esp_cfg80211_set_default_key(struct wiphy *wiphy,
        return cmd_set_default_key(priv, key_index);
 }
 
+static int esp_cfg80211_set_default_mgmt_key(struct wiphy *wiphy,
+                                            struct net_device *ndev, INT_LINK_ID u8 key_index)
+{
+       return 0;
+}
+
 static int esp_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev,
                                INT_LINK_ID u8 key_index, bool pairwise,
                                const u8 *mac_addr)
@@ -393,7 +489,7 @@ static int esp_cfg80211_disconnect(struct wiphy *wiphy,
        }
        esp_dbg("\n");
 
-       return cmd_disconnect_request(priv, reason_code);
+       return cmd_disconnect_request(priv, reason_code, NULL);
 }
 
 static int esp_cfg80211_authenticate(struct wiphy *wiphy, struct net_device *dev,
@@ -459,7 +555,7 @@ static int esp_cfg80211_deauth(struct wiphy *wiphy, struct net_device *dev,
                return 0;
        }
 
-       return cmd_disconnect_request(priv, req->reason_code);
+       return cmd_disconnect_request(priv, req->reason_code, req->bssid);
 }
 
 static int esp_cfg80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
@@ -480,7 +576,11 @@ static int esp_cfg80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
                return 0;
        }
 
-       return cmd_disconnect_request(priv, req->reason_code);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0))
+       return cmd_disconnect_request(priv, req->reason_code, req->ap_addr);
+#else
+       return cmd_disconnect_request(priv, req->reason_code, req->bss->bssid);
+#endif
 }
 
 static int esp_cfg80211_suspend(struct wiphy *wiphy,
@@ -641,18 +741,271 @@ static int esp_cfg80211_get_tx_power(struct wiphy *wiphy,
        return 0;
 }
 
+static int esp_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
+{
+       esp_dbg("\n");
+       return 0;
+}
+
+static int esp_cfg80211_set_txq_params(struct wiphy *wiphy, struct net_device *ndev,
+                             struct ieee80211_txq_params *params)
+{
+       esp_dbg("\n");
+       return 0;
+}
+
+static int esp_set_ies(struct esp_wifi_device *priv, struct cfg80211_beacon_data *info)
+{
+       int ret;
+
+       ret = cmd_set_ie(priv, IE_BEACON, info->beacon_ies, info->beacon_ies_len);
+
+       if (!ret)
+               ret = cmd_set_ie(priv, IE_PROBE_RESP, info->proberesp_ies, info->proberesp_ies_len);
+
+       if (!ret)
+               ret = cmd_set_ie(priv, IE_ASSOC_RESP, info->assocresp_ies, info->assocresp_ies_len);
+
+       return ret;
+}
+
+static int esp_cfg80211_change_beacon(struct wiphy *wiphy, struct net_device *ndev,
+                                  struct cfg80211_beacon_data *info)
+
+{
+       struct esp_wifi_device *priv = NULL;
+
+       if (!wiphy || !ndev) {
+               esp_err("%u invalid params\n", __LINE__);
+               return -EINVAL;
+       }
+
+       priv = netdev_priv(ndev);
+       if (!priv) {
+               esp_err("empty priv\n");
+               return -EINVAL;
+       }
+
+       if (priv->if_type != ESP_AP_IF) {
+               esp_err("Interface type is not AP\n");
+               return -EINVAL;
+       }
+
+       return esp_set_ies(priv, info);
+}
+
+static const uint8_t *esp_get_rsn_ie(struct cfg80211_beacon_data *beacon, size_t *rsn_ie_len)
+{
+        const u8 *rsn_ie;
+
+        if (!beacon->tail)
+                return NULL;
+
+        rsn_ie = cfg80211_find_ie(WLAN_EID_RSN, beacon->tail, beacon->tail_len);
+        if (!rsn_ie)
+                return NULL;
+
+        *rsn_ie_len = *(rsn_ie + 1);
+       *rsn_ie_len += 2;
+
+        return rsn_ie;
+}
+
+static int esp_cfg80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
+                                struct cfg80211_ap_settings *info)
+{
+       struct esp_wifi_device *priv = NULL;
+       struct ieee80211_mgmt *mgmt;
+       u8 *ies;
+       struct esp_ap_config ap_config = {0};
+       int res;
+       int i;
+       size_t rsn_ie_len = 0;
+       const uint8_t *rsn_ie;
+
+       if (!wiphy || !dev) {
+               esp_err("%u invalid params\n", __LINE__);
+               return -EINVAL;
+       }
+
+       priv = netdev_priv(dev);
+       if (!priv) {
+               esp_err("empty priv\n");
+               return -EINVAL;
+       }
+
+       if (priv->if_type != ESP_AP_IF) {
+               esp_err("Interface type is not AP\n");
+               return -EINVAL;
+       }
+
+       esp_dbg("\n");
+
+       res = esp_set_ies(priv, &info->beacon);
+
+       ap_config.beacon_interval = info->beacon_interval;
+       //ap_config.dtim_period = info->dtim_period;
+
+       if (info->beacon.head == NULL)
+               return -EINVAL;
+       mgmt = (struct ieee80211_mgmt *) info->beacon.head;
+       ies = mgmt->u.beacon.variable;
+       if (ies > info->beacon.head + info->beacon.head_len)
+               return -EINVAL;
+
+       if (info->ssid == NULL)
+               return -EINVAL;
+       memcpy(ap_config.ssid, info->ssid, info->ssid_len);
+       ap_config.ssid_len = info->ssid_len;
+       if (info->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
+               ap_config.ssid_hidden = 1;
+
+       //TODO set in vnc
+       if (info->inactivity_timeout) {
+               ap_config.inactivity_timeout = info->inactivity_timeout;
+       }
+
+       if (info->chandef.chan) {
+               for (i = 0; i < ARRAY_SIZE(esp_channels_2ghz); i++) {
+                       if (esp_channels_2ghz[i].center_freq == info->chandef.chan->center_freq) {
+                               ap_config.channel = esp_channels_2ghz[i].hw_value;
+                               break;
+                       }
+               }
+       }
+       if (!ap_config.channel)
+               ap_config.channel = 6;
+
+       //TODO ht and vht caps
+       rsn_ie = esp_get_rsn_ie(&info->beacon, &rsn_ie_len);
+       if (rsn_ie && (rsn_ie_len != 0)) {
+               res = cmd_set_ie(priv, IE_RSN, rsn_ie, rsn_ie_len);
+               /* Dummy mode set set security */
+               ap_config.authmode = WIFI_AUTH_WPA2_PSK;
+               if (res < 0)
+                       return res;
+       }
+       res = cmd_set_ap_config(priv, &ap_config);
+       if (res < 0)
+               return res;
+
+       return 0;
+}
+
+static int esp_cfg80211_stop_ap(struct wiphy *wiphy, struct net_device *dev
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0))
+                               , unsigned int link_id
+#endif
+                                )
+{
+       if (!wiphy || !dev) {
+               esp_err("%u invalid params\n", __LINE__);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0))
+static void esp_cfg80211_mgmt_frame_registrations(struct wiphy *wiphy,
+                                                 struct wireless_dev *wdev,
+                                                 struct mgmt_frame_regs *upd)
+{
+       /* We will forward all the mgmt frame to userspace by default */
+}
+#endif
+
+static int esp_cfg80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
+                                  const u8 *peer, u64 *cookie)
+{
+
+       if (!wiphy || !dev) {
+               esp_err("%u invalid params\n", __LINE__);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static int esp_cfg80211_del_station(struct wiphy *wiphy, struct net_device *dev,
+                                       struct station_del_parameters *params)
+{
+       struct esp_wifi_device *priv = NULL;
+
+       if (!wiphy || !dev) {
+               esp_err("%u invalid params\n", __LINE__);
+               return -EINVAL;
+       }
+
+       priv = netdev_priv(dev);
+       if (!priv) {
+               esp_err("empty priv\n");
+               return -EINVAL;
+       }
+       if (priv->if_type == ESP_AP_IF)
+               return cmd_disconnect_request(priv, params->reason_code, params->mac);
+
+       return 0;
+}
+
+static int esp_cfg80211_add_station(struct wiphy *wiphy, struct net_device *dev,
+                                   const u8 *mac,
+                                   struct station_parameters *params)
+{
+       struct esp_wifi_device *priv = NULL;
+
+       if (!wiphy || !dev) {
+               esp_err("%u invalid params\n", __LINE__);
+               return -EINVAL;
+       }
+
+       priv = netdev_priv(dev);
+       if (!priv) {
+               esp_err("empty priv\n");
+               return -EINVAL;
+       }
+
+       if (priv->if_type == ESP_AP_IF)
+               cmd_add_station(priv, mac, params, false);
+
+       return 0;
+}
+
+static int esp_cfg80211_change_station(struct wiphy *wiphy,
+                                      struct net_device *dev, const u8 *mac,
+                                      struct station_parameters *params)
+{
+       struct esp_wifi_device *priv = NULL;
+
+       if (!wiphy || !dev) {
+               esp_err("%u invalid params\n", __LINE__);
+               return -EINVAL;
+       }
+
+       priv = netdev_priv(dev);
+       if (!priv) {
+               esp_err("empty priv\n");
+               return -EINVAL;
+       }
+       if (priv->if_type == ESP_AP_IF)
+               return cmd_add_station(priv, mac, params, true);
+
+       return 0;
+}
+
 static struct cfg80211_ops esp_cfg80211_ops = {
 #if 0
        .add_virtual_intf = esp_cfg80211_add_iface,
        .del_virtual_intf = esp_cfg80211_del_iface,
-       .change_virtual_intf = esp_cfg80211_change_iface,
 #endif
+       .change_virtual_intf = esp_cfg80211_change_iface,
        .scan = esp_cfg80211_scan,
        /*.connect = esp_cfg80211_connect,*/
        .disconnect = esp_cfg80211_disconnect,
        .add_key = esp_cfg80211_add_key,
        .del_key = esp_cfg80211_del_key,
        .set_default_key = esp_cfg80211_set_default_key,
+       .set_default_mgmt_key = esp_cfg80211_set_default_mgmt_key,
        .mgmt_tx = esp_cfg80211_mgmt_tx,
        .auth = esp_cfg80211_authenticate,
        .deauth = esp_cfg80211_deauth,
@@ -663,9 +1016,35 @@ static struct cfg80211_ops esp_cfg80211_ops = {
        .set_wakeup = esp_cfg80211_set_wakeup,
        .set_tx_power = esp_cfg80211_set_tx_power,
        .get_tx_power = esp_cfg80211_get_tx_power,
+       .set_wiphy_params = esp_cfg80211_set_wiphy_params,
+       .set_txq_params = esp_cfg80211_set_txq_params,
+       .change_beacon = esp_cfg80211_change_beacon,
+       .start_ap = esp_cfg80211_start_ap,
+       .stop_ap = esp_cfg80211_stop_ap,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0))
+       .update_mgmt_frame_registrations = esp_cfg80211_mgmt_frame_registrations,
+#endif
+       .probe_client = esp_cfg80211_probe_client,
+       .del_station = esp_cfg80211_del_station,
+       .add_station = esp_cfg80211_add_station,
+       .change_station = esp_cfg80211_change_station,
        .get_station = esp_cfg80211_get_station,
 };
 
+static const struct ieee80211_txrx_stypes
+esp_default_mgmt_stypes[NUM_NL80211_IFTYPES] = {
+       [NL80211_IFTYPE_AP] = {
+               .tx = 0xffff,
+               .rx = BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) |
+                       BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) |
+                       BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
+                       BIT(IEEE80211_STYPE_DISASSOC >> 4) |
+                       BIT(IEEE80211_STYPE_AUTH >> 4) |
+                       BIT(IEEE80211_STYPE_DEAUTH >> 4) |
+                       BIT(IEEE80211_STYPE_ACTION >> 4),
+       },
+};
+
 static void esp_reg_notifier(struct wiphy *wiphy,
                             struct regulatory_request *request)
 {
@@ -750,11 +1129,21 @@ int esp_add_wiphy(struct esp_adapter *adapter)
        set_wiphy_dev(wiphy, esp_dev->dev);
 
        wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
+#ifdef CONFIG_AP_MODE
+       wiphy->interface_modes |= BIT(NL80211_IFTYPE_AP);
+#endif
        wiphy->bands[NL80211_BAND_2GHZ] = &esp_wifi_bands;
 
        /* Initialize cipher suits */
-       wiphy->cipher_suites = esp_cipher_suites;
-       wiphy->n_cipher_suites = ARRAY_SIZE(esp_cipher_suites);
+       if (adapter->chipset == ESP_FIRMWARE_CHIP_ESP32C3 ||
+           adapter->chipset == ESP_FIRMWARE_CHIP_ESP32S3 ||
+           adapter->chipset == ESP_FIRMWARE_CHIP_ESP32C6) {
+               wiphy->cipher_suites = esp_cipher_suites_new;
+               wiphy->n_cipher_suites = ARRAY_SIZE(esp_cipher_suites_new);
+       } else {
+               wiphy->cipher_suites = esp_cipher_suites;
+               wiphy->n_cipher_suites = ARRAY_SIZE(esp_cipher_suites);
+       }
 
        /* TODO: check and finalize the numbers */
        wiphy->max_scan_ssids = 10;
@@ -765,12 +1154,19 @@ int esp_add_wiphy(struct esp_adapter *adapter)
 #ifdef CONFIG_PM
        wiphy->wowlan = &esp_wowlan_support;
 #endif
+       wiphy->mgmt_stypes = esp_default_mgmt_stypes;
 
        /* Advertise SAE support */
        wiphy->features |= NL80211_FEATURE_SAE;
 
        wiphy->reg_notifier = esp_reg_notifier;
 
+       /* set caps */
+       wiphy->flags |= WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD;
+       wiphy->flags |= WIPHY_FLAG_REPORTS_OBSS;
+       //wiphy->features |= NL80211_CMD_PROBE_CLIENT;
+       wiphy->features |= NL80211_FEATURE_SK_TX_STATUS;
+
        ret = wiphy_register(wiphy);
 
        return ret;
index 4b8bab3d067553f0b402b671bd50957c32754de5..48c5cc513fa620ad3ed77e0422b15c83e0091907 100644 (file)
@@ -18,6 +18,9 @@
 u8 ap_bssid[MAC_ADDR_LEN];
 extern u32 raw_tp_mode;
 
+static int handle_mgmt_tx_done(struct esp_wifi_device *priv,
+                               struct command_node *cmd_node);
+
 int internal_scan_request(struct esp_wifi_device *priv, char *ssid,
                uint8_t channel, uint8_t is_blocking);
 
@@ -263,8 +266,13 @@ static int wait_and_decode_cmd_resp(struct esp_wifi_device *priv,
        case CMD_STA_AUTH:
        case CMD_STA_ASSOC:
        case CMD_STA_CONNECT:
+       case CMD_DISCONNECT:
        case CMD_ADD_KEY:
        case CMD_DEL_KEY:
+       case CMD_SET_MODE:
+       case CMD_SET_IE:
+       case CMD_AP_CONFIG:
+       case CMD_AP_STATION:
        case CMD_SET_DEFAULT_KEY:
        case CMD_SET_IP_ADDR:
        case CMD_SET_MCAST_MAC_ADDR:
@@ -277,10 +285,6 @@ static int wait_and_decode_cmd_resp(struct esp_wifi_device *priv,
                if (ret == 0)
                        ret = decode_common_resp(cmd_node);
                break;
-       case CMD_STA_DISCONNECT:
-               if (ret == 0)
-                       ret = decode_disconnect_resp(priv, cmd_node);
-               break;
 
        case CMD_GET_MAC:
        case CMD_SET_MAC:
@@ -293,7 +297,10 @@ static int wait_and_decode_cmd_resp(struct esp_wifi_device *priv,
                if (ret == 0)
                        ret = decode_tx_power(priv, cmd_node);
                break;
-
+       case CMD_MGMT_TX:
+               if (ret == 0)
+                       ret = handle_mgmt_tx_done(priv, cmd_node);
+               break;
        default:
                esp_info("Resp for [0x%x] ignored\n", cmd_node->cmd_code);
                ret = -EINVAL;
@@ -463,6 +470,7 @@ struct command_node *prepare_command_request(struct esp_adapter *adapter, u8 cmd
        struct command_header *cmd;
        struct esp_payload_header *payload_header;
        struct command_node *node = NULL;
+       struct esp_wifi_device *priv = adapter->priv[0];
 
        if (!adapter) {
                esp_info("%u null adapter\n", __LINE__);
@@ -492,7 +500,7 @@ struct command_node *prepare_command_request(struct esp_adapter *adapter, u8 cmd
        payload_header = (struct esp_payload_header *)skb_put(node->cmd_skb, len);
        memset(payload_header, 0, len);
 
-       payload_header->if_type = ESP_STA_IF;
+       payload_header->if_type = priv->if_type;
        payload_header->len = cpu_to_le16(len - sizeof(struct esp_payload_header));
        payload_header->offset = cpu_to_le16(sizeof(struct esp_payload_header));
        payload_header->packet_type = PACKET_TYPE_COMMAND_REQUEST;
@@ -517,7 +525,8 @@ int process_cmd_resp(struct esp_adapter *adapter, struct sk_buff *skb)
 
        spin_lock_bh(&adapter->cmd_lock);
        if (!adapter->cur_cmd) {
-               esp_err("Command response not expected\n");
+               struct command_header *header = (struct command_header *) skb->data;
+               esp_err("Command response not expected=%d\n", header->cmd_code);
                dev_kfree_skb_any(skb);
                spin_unlock_bh(&adapter->cmd_lock);
                return -1;
@@ -533,6 +542,39 @@ int process_cmd_resp(struct esp_adapter *adapter, struct sk_buff *skb)
        return 0;
 }
 
+static void process_mgmt_tx_status(struct esp_wifi_device * priv,
+                                  int status, uint8_t *data, uint32_t len);
+static int handle_mgmt_tx_done(struct esp_wifi_device *priv,
+                               struct command_node *cmd_node)
+{
+       int ret = 0;
+       struct cmd_mgmt_tx *header;
+
+       if (!priv || !cmd_node ||
+           !cmd_node->resp_skb ||
+           !cmd_node->resp_skb->data) {
+               esp_info("invalid arg\n");
+               return -1;
+       }
+
+       header = (struct cmd_mgmt_tx *) (cmd_node->resp_skb->data);
+
+       if (header->header.cmd_status != CMD_RESPONSE_SUCCESS) {
+               esp_dbg("Command failed\n");
+               ret = 0;
+       }
+
+       if (header->len == 0) {
+               esp_dbg("len is zero, nothing to do...");
+               return ret;
+       }
+
+       process_mgmt_tx_status(priv, header->header.cmd_status == CMD_RESPONSE_SUCCESS,
+                         header->buf, header->len);
+
+       return ret;
+}
+
 static void process_scan_result_event(struct esp_wifi_device *priv,
                struct scan_event *scan_evt)
 {
@@ -632,6 +674,29 @@ static void process_deauth_event(struct esp_wifi_device *priv, struct disconnect
        cfg80211_rx_mlme_mgmt(priv->ndev, frame_buf, IEEE80211_DEAUTH_FRAME_LEN);
 }
 
+static int chan_to_freq_24ghz(u8 chan)
+{
+       if (chan > 1 && chan < 15)
+               return (2407 + 5 * chan) * 1000;
+       else
+               return -1;
+}
+
+static void process_mgmt_tx_status(struct esp_wifi_device * priv,
+                                  int ack, uint8_t *data, uint32_t len)
+{
+        u64 cookie = 0;
+
+       cfg80211_mgmt_tx_status(&priv->wdev, cookie, data, len,
+                               ack, GFP_ATOMIC);
+}
+
+static void process_ap_mgmt_rx(struct esp_wifi_device * priv, struct mgmt_event *event)
+{
+        cfg80211_rx_mgmt(&priv->wdev, chan_to_freq_24ghz(event->chan),
+                event->rssi, event->frame, event->frame_len, 0);
+}
+
 static void process_disconnect_event(struct esp_wifi_device *priv,
                struct disconnect_event *event)
 {
@@ -728,6 +793,11 @@ int process_cmd_event(struct esp_wifi_device *priv, struct sk_buff *skb)
                process_auth_event(priv, (struct auth_event *)(skb->data));
                break;
 
+       case EVENT_AP_MGMT_RX:
+               process_ap_mgmt_rx(priv,
+                               (struct mgmt_event *)(skb->data));
+               break;
+
        default:
                esp_info("%u unhandled event[%u]\n",
                                __LINE__, header->event_code);
@@ -806,10 +876,10 @@ int cmd_set_ip_address(struct esp_wifi_device *priv, u32 ip)
        return 0;
 }
 
-int cmd_disconnect_request(struct esp_wifi_device *priv, u16 reason_code)
+int cmd_disconnect_request(struct esp_wifi_device *priv, u16 reason_code, const uint8_t *mac)
 {
        struct command_node *cmd_node = NULL;
-       struct cmd_sta_disconnect *cmd_disconnect;
+       struct cmd_disconnect *cmd_disconnect;
 
        if (!priv || !priv->adapter) {
                esp_err("Invalid argument\n");
@@ -819,18 +889,20 @@ int cmd_disconnect_request(struct esp_wifi_device *priv, u16 reason_code)
        if (test_bit(ESP_CLEANUP_IN_PROGRESS, &priv->adapter->state_flags))
                return 0;
 
-       cmd_node = prepare_command_request(priv->adapter, CMD_STA_DISCONNECT,
-                       sizeof(struct cmd_sta_disconnect));
+       cmd_node = prepare_command_request(priv->adapter, CMD_DISCONNECT,
+                       sizeof(struct cmd_disconnect));
 
        if (!cmd_node) {
                esp_err("Failed to get command node\n");
                return -ENOMEM;
        }
 
-       cmd_disconnect = (struct cmd_sta_disconnect *)
+       cmd_disconnect = (struct cmd_disconnect *)
                (cmd_node->cmd_skb->data + sizeof(struct esp_payload_header));
 
        cmd_disconnect->reason_code = reason_code;
+       if (mac)
+               memcpy(cmd_disconnect->mac, mac, ETH_ALEN);
 
        queue_cmd_node(priv->adapter, cmd_node, ESP_CMD_DFLT_PRIO);
        queue_work(priv->adapter->cmd_wq, &priv->adapter->cmd_work);
@@ -1065,6 +1137,54 @@ int cmd_auth_request(struct esp_wifi_device *priv,
        return 0;
 }
 
+int cmd_mgmt_request(struct esp_wifi_device *priv,
+                    struct cfg80211_mgmt_tx_params *req)
+{
+       struct command_node *cmd_node = NULL;
+       struct cmd_mgmt_tx *cmd;
+       struct esp_adapter *adapter = NULL;
+       u16 cmd_len;
+
+       if (!priv || !req || !priv->adapter) {
+               esp_err("Invalid argument\n");
+               return -EINVAL;
+       }
+
+       if (test_bit(ESP_CLEANUP_IN_PROGRESS, &priv->adapter->state_flags)) {
+               esp_err("%u cleanup in progress, return failure", __LINE__);
+               return -EFAULT;
+       }
+       adapter = priv->adapter;
+
+       cmd_len = sizeof(struct cmd_mgmt_tx) + req->len;
+
+       cmd_node = prepare_command_request(adapter, CMD_MGMT_TX, cmd_len);
+
+       if (!cmd_node) {
+               esp_err("Failed to get command node\n");
+               return -ENOMEM;
+       }
+       cmd = (struct cmd_mgmt_tx *) (cmd_node->cmd_skb->data + sizeof(struct esp_payload_header));
+
+       memcpy(cmd->buf, req->buf, req->len);
+       cmd->len = req->len;
+       cmd->offchan = req->offchan;
+       cmd->wait = req->wait;
+       cmd->no_cck = req->no_cck;
+       cmd->dont_wait_for_ack = req->dont_wait_for_ack;
+
+       //esp_info("Sending mgmt Tx request of len=%d\n", req->len);
+
+       queue_cmd_node(adapter, cmd_node, ESP_CMD_DFLT_PRIO);
+       queue_work(adapter->cmd_wq, &adapter->cmd_work);
+
+       RET_ON_FAIL(wait_and_decode_cmd_resp(priv, cmd_node));
+
+       return 0;
+}
+
+
+
 int cmd_set_default_key(struct esp_wifi_device *priv, u8 key_index)
 {
        u16 cmd_len;
@@ -1186,7 +1306,7 @@ int cmd_add_key(struct esp_wifi_device *priv, u8 key_index, bool pairwise,
                      key_index, pairwise, params->key_len, params->seq_len,
                      params->mode, params->cipher);
        if (!priv || !priv->adapter || !params ||
-           !params->key || !params->key_len || !params->seq_len) {
+           !params->key || !params->key_len) {
                esp_err("Invalid argument\n");
                return -EINVAL;
        }
@@ -1431,13 +1551,6 @@ int cmd_scan_request(struct esp_wifi_device *priv, struct cfg80211_scan_request
                memcpy(scan_req->ssid, request->ssids[0].ssid, MAX_SSID_LEN);
        }
 
-#if 0
-       if (request->n_channels) {
-               chan = request->channels[0];
-               scan_req->channel = chan->hw_value;
-       }
-#endif
-
 #if LINUX_VERSION_CODE > KERNEL_VERSION(4, 8, 0)
        scan_req->duration = request->duration;
 #endif
@@ -1529,19 +1642,136 @@ int cmd_set_mac(struct esp_wifi_device *priv, uint8_t *mac_addr)
 
        cmd_node = prepare_command_request(priv->adapter, CMD_SET_MAC, cmd_len);
 
+       cmd = (struct cmd_config_mac_address *) (cmd_node->cmd_skb->data +
+                               sizeof(struct esp_payload_header));
+
+       memcpy(cmd->mac_addr, mac_addr, MAC_ADDR_LEN);
+       queue_cmd_node(priv->adapter, cmd_node, ESP_CMD_DFLT_PRIO);
+       queue_work(priv->adapter->cmd_wq, &priv->adapter->cmd_work);
+
+       RET_ON_FAIL(wait_and_decode_cmd_resp(priv, cmd_node));
+       return 0;
+}
+
+int cmd_set_mode(struct esp_wifi_device *priv, uint8_t mode)
+{
+       struct command_node *cmd_node = NULL;
+       struct cmd_config_mode *cmd_mode;
+
+       if (!priv || !priv->adapter) {
+               esp_err("Invalid argument\n");
+               return -EINVAL;
+       }
+
+       if (test_bit(ESP_CLEANUP_IN_PROGRESS, &priv->adapter->state_flags))
+               return 0;
+
+       cmd_node = prepare_command_request(priv->adapter, CMD_SET_MODE,
+                       sizeof(struct cmd_config_mode));
+
        if (!cmd_node) {
                esp_err("Failed to get command node\n");
                return -ENOMEM;
        }
 
-       cmd = (struct cmd_config_mac_address *) (cmd_node->cmd_skb->data +
-                               sizeof(struct esp_payload_header));
+       cmd_mode = (struct cmd_config_mode *)
+               (cmd_node->cmd_skb->data + sizeof(struct esp_payload_header));
+
+       cmd_mode->mode = mode;
 
-       memcpy(cmd->mac_addr, mac_addr, MAC_ADDR_LEN);
        queue_cmd_node(priv->adapter, cmd_node, ESP_CMD_DFLT_PRIO);
        queue_work(priv->adapter->cmd_wq, &priv->adapter->cmd_work);
 
        RET_ON_FAIL(wait_and_decode_cmd_resp(priv, cmd_node));
+       return 0;
+}
+
+int cmd_set_ie(struct esp_wifi_device *priv, enum ESP_IE_TYPE type, const uint8_t *ie, size_t ie_len)
+{
+       struct command_node *cmd_node = NULL;
+       struct cmd_config_ie *cmd_ie;
+       size_t cmd_len;
+
+       if (!priv || !priv->adapter) {
+               esp_err("Invalid argument\n");
+               return -EINVAL;
+       }
+
+       if (test_bit(ESP_CLEANUP_IN_PROGRESS, &priv->adapter->state_flags))
+               return 0;
+
+       cmd_len = sizeof(struct cmd_config_ie) + ie_len;
+       cmd_node = prepare_command_request(priv->adapter, CMD_SET_IE, cmd_len);
+
+       if (!cmd_node) {
+               esp_err("Failed to get command node\n");
+               return -ENOMEM;
+       }
+
+       cmd_ie = (struct cmd_config_ie *)
+               (cmd_node->cmd_skb->data + sizeof(struct esp_payload_header));
+
+       cmd_ie->ie_type = type;
+       cmd_ie->ie_len = ie_len;
+       memcpy(cmd_ie->ie, ie, ie_len);
+
+       queue_cmd_node(priv->adapter, cmd_node, ESP_CMD_DFLT_PRIO);
+       queue_work(priv->adapter->cmd_wq, &priv->adapter->cmd_work);
+
+       RET_ON_FAIL(wait_and_decode_cmd_resp(priv, cmd_node));
+       return 0;
+}
+
+
+int cmd_set_ap_config(struct esp_wifi_device *priv, struct esp_ap_config *ap_config)
+{
+       struct command_node *cmd_node = NULL;
+       struct cmd_ap_config *cmd_config;
+       size_t cmd_len;
+
+       if (!priv || !priv->adapter) {
+               esp_err("Invalid argument\n");
+               return -EINVAL;
+       }
+
+       if (test_bit(ESP_CLEANUP_IN_PROGRESS, &priv->adapter->state_flags))
+               return 0;
+
+       cmd_len = sizeof(struct cmd_ap_config);
+       cmd_node = prepare_command_request(priv->adapter, CMD_AP_CONFIG, cmd_len);
+
+       if (!cmd_node) {
+               esp_err("Failed to get command node\n");
+               return -ENOMEM;
+       }
+
+       cmd_config = (struct cmd_ap_config *)
+               (cmd_node->cmd_skb->data + sizeof(struct esp_payload_header));
+
+       memcpy(&cmd_config->ap_config, ap_config, sizeof(struct esp_ap_config));
+
+       queue_cmd_node(priv->adapter, cmd_node, ESP_CMD_DFLT_PRIO);
+       queue_work(priv->adapter->cmd_wq, &priv->adapter->cmd_work);
+
+       RET_ON_FAIL(wait_and_decode_cmd_resp(priv, cmd_node));
+       return 0;
+}
+
+int esp_cfg_cleanup(struct esp_adapter *adapter)
+{
+       struct esp_wifi_device *priv = NULL;
+       uint8_t iface_idx = 0;
+
+       for (iface_idx = 0; iface_idx < ESP_MAX_INTERFACE; iface_idx++) {
+               priv = adapter->priv[iface_idx];
+               if (!priv)
+                       continue;
+
+               if (priv->wdev.iftype == NL80211_IFTYPE_STATION)
+                       esp_mark_scan_done_and_disconnect(priv, false);
+
+               esp_port_close(priv);
+       }
 
        return 0;
 }
@@ -1552,6 +1782,9 @@ int esp_commands_teardown(struct esp_adapter *adapter)
                return -EINVAL;
        }
 
+       if (!test_bit(ESP_CMD_INIT_DONE, &adapter->state_flags))
+               return 0;
+
        set_bit(ESP_CLEANUP_IN_PROGRESS, &adapter->state_flags);
        clear_bit(ESP_CMD_INIT_DONE, &adapter->state_flags);
        destroy_cmd_wq(adapter);
@@ -1632,16 +1865,16 @@ int cmd_set_tx_power(struct esp_wifi_device *priv, int power)
                esp_err("Invalid argument\n");
                return -EINVAL;
        }
+       if (test_bit(ESP_CLEANUP_IN_PROGRESS, &priv->adapter->state_flags))
+               return 0;
 
        cmd_len = sizeof(struct cmd_set_get_val);
 
        cmd_node = prepare_command_request(priv->adapter, CMD_SET_TXPOWER, cmd_len);
-
        if (!cmd_node) {
                esp_err("Failed to get command node\n");
                return -ENOMEM;
        }
-
        val = (struct cmd_set_get_val *) (cmd_node->cmd_skb->data +
                                sizeof(struct esp_payload_header));
 
@@ -1655,6 +1888,82 @@ int cmd_set_tx_power(struct esp_wifi_device *priv, int power)
        return 0;
 }
 
+int cmd_add_station(struct esp_wifi_device *priv, const uint8_t *mac,
+                   struct station_parameters *sta, bool is_changed)
+{
+       struct command_node *cmd_node = NULL;
+       struct cmd_ap_add_sta_config *cmd_config;
+       size_t cmd_len;
+
+       if (!priv || !priv->adapter) {
+               esp_err("Invalid argument\n");
+               return -EINVAL;
+       }
+
+       if (test_bit(ESP_CLEANUP_IN_PROGRESS, &priv->adapter->state_flags))
+               return 0;
+
+       cmd_len = sizeof(struct cmd_ap_add_sta_config);
+       cmd_node = prepare_command_request(priv->adapter, CMD_AP_STATION, cmd_len);
+
+       if (!cmd_node) {
+               esp_err("Failed to get command node\n");
+               return -ENOMEM;
+       }
+
+       cmd_config = (struct cmd_ap_add_sta_config *)
+               (cmd_node->cmd_skb->data + sizeof(struct esp_payload_header));
+
+       memcpy(cmd_config->sta_param.mac, mac, 6);
+       if (is_changed)
+               cmd_config->sta_param.cmd = CHANGE_STA;
+       else
+               cmd_config->sta_param.cmd = ADD_STA;
+       cmd_config->sta_param.sta_flags_mask = sta->sta_flags_mask;
+       cmd_config->sta_param.sta_flags_set = sta->sta_flags_set;
+       cmd_config->sta_param.sta_modify_mask = sta->sta_modify_mask;
+       cmd_config->sta_param.listen_interval = sta->listen_interval;
+       cmd_config->sta_param.aid = sta->aid;
+
+       if (sta->ext_capab_len && sta->ext_capab) {
+               if (sta->ext_capab_len > 4)
+                       sta->ext_capab_len = 4;
+               memcpy(cmd_config->sta_param.ext_capab, sta->ext_capab, sta->ext_capab_len);
+       }
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0))
+       if (sta->link_sta_params.supported_rates_len && sta->link_sta_params.supported_rates) {
+               cmd_config->sta_param.supported_rates[0] = WLAN_EID_SUPP_RATES;
+               cmd_config->sta_param.supported_rates[1] = 10;
+               memcpy(&cmd_config->sta_param.supported_rates[2], sta->link_sta_params.supported_rates, 10);
+       }
+
+       if (sta->link_sta_params.ht_capa) {
+               cmd_config->sta_param.ht_caps[0] = WLAN_EID_HT_CAPABILITY;
+               cmd_config->sta_param.ht_caps[1] = 26;
+               memcpy(&cmd_config->sta_param.ht_caps[2], sta->link_sta_params.ht_capa, 26);
+       }
+       if (sta->link_sta_params.vht_capa) {
+               cmd_config->sta_param.vht_caps[0] = WLAN_EID_VHT_CAPABILITY;
+               cmd_config->sta_param.vht_caps[1] = 12;
+               memcpy(&cmd_config->sta_param.vht_caps[2], sta->link_sta_params.vht_capa, 12);
+       }
+       if (sta->link_sta_params.he_capa) {
+               cmd_config->sta_param.he_caps[0] = WLAN_EID_EXTENSION;
+               cmd_config->sta_param.he_caps[1] = 25;
+               cmd_config->sta_param.he_caps[2] = WLAN_EID_EXT_HE_CAPABILITY;
+               memcpy(&cmd_config->sta_param.he_caps[3], sta->link_sta_params.he_capa, 24);
+       }
+#endif
+
+       queue_cmd_node(priv->adapter, cmd_node, ESP_CMD_DFLT_PRIO);
+       queue_work(priv->adapter->cmd_wq, &priv->adapter->cmd_work);
+
+       RET_ON_FAIL(wait_and_decode_cmd_resp(priv, cmd_node));
+
+       return 0;
+}
+
 int cmd_get_tx_power(struct esp_wifi_device *priv)
 {
        u16 cmd_len;
index 5817da00966259eb15ac7699d56788c4f94e658f..82eff7b0a605eee36e7adff9750e5981825510d7 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "esp_api.h"
 #include <linux/timer.h>
+#include <linux/kthread.h>
 
 static struct task_struct *raw_tp_tx_thread;
 static int test_raw_tp;
index 581554cc5baa43e3cfb576cc7db036a1000b30f8..b4e92dcece77bb2831b9216f2cc15bdb6f032f56 100644 (file)
@@ -57,6 +57,44 @@ enum ESP_INTERFACE_TYPE {
        ESP_MAX_IF,
 };
 
+enum ESP_IE_TYPE{
+       IE_BEACON,
+       IE_PROBE_RESP,
+       IE_ASSOC_RESP,
+       IE_RSN,
+       IE_BEACON_PROBE,
+};
+
+enum esp_auth_mode {
+       WIFI_AUTH_OPEN = 0,
+       WIFI_AUTH_WEP,
+       WIFI_AUTH_WPA_PSK,
+       WIFI_AUTH_WPA2_PSK,
+       WIFI_AUTH_WPA_WPA2_PSK,
+       WIFI_AUTH_WPA2_ENTERPRISE,
+       WIFI_AUTH_WPA3_PSK,
+       WIFI_AUTH_WPA2_WPA3_PSK,
+       WIFI_AUTH_WAPI_PSK,
+       WIFI_AUTH_OWE,
+       WIFI_AUTH_MAX
+};
+
+enum esp_cipher_type {
+       WIFI_CIPHER_TYPE_NONE = 0,
+       WIFI_CIPHER_TYPE_WEP40,
+       WIFI_CIPHER_TYPE_WEP104,
+       WIFI_CIPHER_TYPE_TKIP,
+       WIFI_CIPHER_TYPE_CCMP,
+       WIFI_CIPHER_TYPE_TKIP_CCMP,
+       WIFI_CIPHER_TYPE_AES_CMAC128,
+       WIFI_CIPHER_TYPE_SMS4,
+       WIFI_CIPHER_TYPE_GCMP,
+       WIFI_CIPHER_TYPE_GCMP256,
+       WIFI_CIPHER_TYPE_AES_GMAC128,
+       WIFI_CIPHER_TYPE_AES_GMAC256,
+       WIFI_CIPHER_TYPE_UNKNOWN,
+};
+
 enum ESP_PACKET_TYPE {
        PACKET_TYPE_DATA,
        PACKET_TYPE_COMMAND_REQUEST,
@@ -107,7 +145,7 @@ enum COMMAND_CODE {
        CMD_GET_MAC,
        CMD_SCAN_REQUEST,
        CMD_STA_CONNECT,
-       CMD_STA_DISCONNECT,
+       CMD_DISCONNECT,
        CMD_DEINIT_INTERFACE,
        CMD_ADD_KEY,
        CMD_DEL_KEY,
@@ -123,6 +161,11 @@ enum COMMAND_CODE {
        CMD_RAW_TP_ESP_TO_HOST,
        CMD_RAW_TP_HOST_TO_ESP,
        CMD_SET_WOW_CONFIG,
+       CMD_SET_MODE,
+       CMD_SET_IE,
+       CMD_AP_CONFIG,
+       CMD_MGMT_TX,
+       CMD_AP_STATION,
        CMD_MAX,
 };
 
@@ -132,6 +175,7 @@ enum EVENT_CODE {
        EVENT_STA_DISCONNECT,
        EVENT_AUTH_RX,
        EVENT_ASSOC_RX,
+       EVENT_AP_MGMT_RX,
 };
 
 enum COMMAND_RESPONSE_TYPE {
@@ -167,6 +211,58 @@ struct cmd_config_mac_address {
        uint8_t    pad[2];
 } __packed;
 
+struct cmd_config_ie {
+       struct     command_header header;
+       uint8_t    ie_type;
+       uint8_t    pad;
+       uint16_t   ie_len;
+       uint8_t    ie[];
+}__attribute__((packed));
+
+struct esp_ap_config {
+    uint8_t ssid[32];
+    uint8_t ssid_len;
+    uint8_t channel;
+    uint8_t authmode;
+    uint8_t ssid_hidden;
+    uint8_t max_connection;
+    uint8_t pairwise_cipher;
+    uint8_t pmf_cfg;
+    uint8_t sae_pwe_h2e;
+    uint16_t beacon_interval;
+    uint16_t inactivity_timeout;
+}__attribute__((packed));
+
+struct cmd_ap_config {
+       struct command_header header;
+       struct esp_ap_config ap_config;
+}__attribute__((packed));
+
+#define ADD_STA 0
+#define CHANGE_STA 1
+#define DEL_STA 2
+
+struct cmd_ap_sta_param {
+       uint8_t mac[6];
+       uint16_t cmd;
+       uint32_t sta_flags_mask, sta_flags_set;
+       uint32_t sta_modify_mask;
+       int32_t listen_interval;
+       uint16_t aid;
+       uint8_t ext_capab[6];
+       uint8_t supported_rates[12];
+       uint8_t ht_caps[28];
+       uint8_t vht_caps[14];
+       uint8_t pad1[2];
+       uint8_t he_caps[27];
+       uint8_t pad2;
+}__attribute__((packed));
+
+struct cmd_ap_add_sta_config {
+       struct command_header header;
+       struct cmd_ap_sta_param sta_param;
+}__attribute__((packed));
+
 struct cmd_sta_auth {
        struct     command_header header;
        uint8_t    bssid[MAC_ADDR_LEN];
@@ -180,6 +276,17 @@ struct cmd_sta_auth {
        uint8_t    auth_data[];
 } __packed;
 
+struct cmd_mgmt_tx {
+        struct     command_header header;
+        uint8_t    channel;
+        uint8_t    offchan;
+        uint32_t   wait;
+        uint8_t    no_cck;
+        uint8_t    dont_wait_for_ack;
+        uint32_t   len;
+        uint8_t    buf[];
+}__attribute__((packed));
+
 struct cmd_sta_assoc {
        struct     command_header header;
        uint8_t    assoc_ie_len;
@@ -198,10 +305,10 @@ struct cmd_sta_connect {
        uint8_t    assoc_ie[];
 } __packed;
 
-struct cmd_sta_disconnect {
+struct cmd_disconnect {
        struct     command_header header;
        uint16_t   reason_code;
-       uint8_t    pad[2];
+       uint8_t    mac[MAC_ADDR_LEN];
 } __packed;
 
 struct cmd_set_ip_addr {
@@ -295,6 +402,15 @@ struct assoc_event {
        uint8_t    frame[0];
 } __packed;
 
+struct mgmt_event {
+        struct     event_header header;
+        int32_t    nf;
+        int32_t    rssi;
+        int32_t    chan;
+        uint32_t   frame_len;
+        uint8_t    frame[0];
+}__attribute__((packed));
+
 struct disconnect_event {
        struct     event_header header;
        uint8_t    bssid[MAC_ADDR_LEN];
@@ -302,6 +418,12 @@ struct disconnect_event {
        uint8_t    reason;
 } __packed;
 
+struct cmd_config_mode {
+       struct     command_header header;
+       uint16_t   mode;
+       uint8_t    pad[2];
+}__attribute__((packed));
+
 struct esp_internal_bootup_event {
        struct     event_header header;
        uint8_t    len;
index 737524b5e584dc7b3ee27fc3bbf14aaf3d5bcbc2..7fa55f2f2ca6f3722f6fa2c13b74c93259920c09 100644 (file)
@@ -41,4 +41,6 @@ int esp_validate_chipset(struct esp_adapter *adapter, u8 chipset);
 int esp_adjust_spi_clock(struct esp_adapter *adapter, u8 spi_clk_mhz);
 void process_test_capabilities(u32 raw_tp_mode);
 int esp_init_raw_tp(struct esp_adapter *adapter);
+bool esp_is_valid_hardware_id(int hardware_id);
+char *esp_get_hardware_name(int hardware_id);
 #endif
index c2e70a8acbb8c55f18a4f7a7fb541172ec3392cc..9b3db91515881bfc20ae884b7706c280fb0d3a09 100644 (file)
@@ -25,6 +25,7 @@ struct multicast_list {
 
 int esp_commands_setup(struct esp_adapter *adapter);
 int esp_commands_teardown(struct esp_adapter *adapter);
+int esp_cfg_cleanup(struct esp_adapter *adapter);
 int cmd_init_interface(struct esp_wifi_device *priv);
 int cmd_deinit_interface(struct esp_wifi_device *priv);
 int process_cmd_resp(struct esp_adapter *adapter, struct sk_buff *skb);
@@ -39,7 +40,9 @@ int cmd_auth_request(struct esp_wifi_device *priv,
                struct cfg80211_auth_request *req);
 int cmd_assoc_request(struct esp_wifi_device *priv,
                struct cfg80211_assoc_request *req);
-int cmd_disconnect_request(struct esp_wifi_device *priv, u16 reason_code);
+int cmd_disconnect_request(struct esp_wifi_device *priv, u16 reason_code, const uint8_t *mac);
+int cmd_add_station(struct esp_wifi_device *priv, const uint8_t *mac,
+                   struct station_parameters *sta, bool is_changed);
 int cmd_add_key(struct esp_wifi_device *priv, u8 key_index, bool pairwise,
                const u8 *mac_addr, struct key_params *params);
 int cmd_del_key(struct esp_wifi_device *priv, u8 key_index, bool pairwise,
@@ -53,4 +56,12 @@ int cmd_get_tx_power(struct esp_wifi_device *priv);
 int cmd_set_reg_domain(struct esp_wifi_device *priv);
 int cmd_get_reg_domain(struct esp_wifi_device *priv);
 int cmd_init_raw_tp_task_timer(struct esp_wifi_device *priv);
+int cmd_set_mac(struct esp_wifi_device *priv, uint8_t *mac_addr);
+int cmd_set_mode(struct esp_wifi_device *priv, uint8_t mode);
+int cmd_set_ie(struct esp_wifi_device *priv, enum ESP_IE_TYPE type, const uint8_t *ie, size_t ie_len);
+int cmd_set_ap_config(struct esp_wifi_device *priv, struct esp_ap_config *ap_config);
+int cmd_mgmt_request(struct esp_wifi_device *priv,
+                    struct cfg80211_mgmt_tx_params *req);
+int cmd_sta_change(struct esp_wifi_device *priv,
+                    struct station_parameters *sta_info);
 #endif
index 258d2bddef1d89623eb31de1c8bdb1412a923594..8d295134f5a454ca2dc17bfcc2207a41d7ec4dc6 100644 (file)
@@ -450,7 +450,7 @@ static int esp_add_network_ifaces(struct esp_adapter *adapter)
        }
 
        rtnl_lock();
-       wdev = esp_cfg80211_add_iface(adapter->wiphy, "espsta%d", 1, NL80211_IFTYPE_STATION, NULL);
+       wdev = esp_cfg80211_add_iface(adapter->wiphy, "wlan%d", 1, NL80211_IFTYPE_STATION, NULL);
        rtnl_unlock();
 
        /* Return success if network added successfully */
@@ -471,6 +471,7 @@ int esp_add_card(struct esp_adapter *adapter)
        RET_ON_FAIL(esp_commands_setup(adapter));
        RET_ON_FAIL(esp_add_wiphy(adapter));
        RET_ON_FAIL(esp_add_network_ifaces(adapter));
+       clear_bit(ESP_CLEANUP_IN_PROGRESS, &adapter->state_flags);
 
        return 0;
 }
@@ -561,6 +562,7 @@ int esp_remove_card(struct esp_adapter *adapter)
        }
 
        esp_stop_network_ifaces(adapter);
+       esp_cfg_cleanup(adapter);
        /* BT may have been initialized after fw bootup event, deinit it */
        esp_deinit_bt(adapter);
        esp_commands_teardown(adapter);
@@ -646,8 +648,6 @@ static void process_rx_packet(struct esp_adapter *adapter, struct sk_buff *skb)
        u16 rx_checksum = 0, checksum = 0;
        struct hci_dev *hdev = adapter->hcidev;
        u8 *type = NULL;
-       struct sk_buff *eap_skb = NULL;
-       struct ethhdr *eth = NULL;
 
        if (!skb)
                return;
@@ -689,31 +689,11 @@ static void process_rx_packet(struct esp_adapter *adapter, struct sk_buff *skb)
                }
 
                if (payload_header->packet_type == PACKET_TYPE_EAPOL) {
-                       esp_info("Rx PACKET_TYPE_EAPOL!!!!\n");
+                       esp_dbg("Rx PACKET_TYPE_EAPOL!!!!\n");
                        esp_port_open(priv);
-
-                       eap_skb = alloc_skb(skb->len + ETH_HLEN, GFP_KERNEL);
-                       if (!eap_skb) {
-                               esp_info("%u memory alloc failed\n", __LINE__);
-                               dev_kfree_skb_any(skb);
-                               return;
-                       }
-                       eap_skb->dev = priv->ndev;
-
-                       if (!IS_ALIGNED((unsigned long) eap_skb->data, SKB_DATA_ADDR_ALIGNMENT)) {
-                               esp_info("%u eap skb unaligned\n", __LINE__);
-                       }
-
-                       eth = (struct ethhdr *) skb_put(eap_skb, ETH_HLEN);
-                       ether_addr_copy(eth->h_dest, /*skb->data*/priv->ndev->dev_addr);
-                       ether_addr_copy(eth->h_source, /*skb->data+6*/ ap_bssid);
-                       eth->h_proto = cpu_to_be16(ETH_P_PAE);
-
-                       skb_put_data(eap_skb, skb->data, skb->len);
-                       eap_skb->protocol = eth_type_trans(eap_skb, eap_skb->dev);
-                       dev_kfree_skb_any(skb);
-
-                       netif_rx(eap_skb);
+                       skb->dev = priv->ndev;
+                       skb->protocol = eth_type_trans(skb, priv->ndev);
+                       netif_rx(skb);
 
                } else if (payload_header->packet_type == PACKET_TYPE_DATA) {
 
@@ -771,6 +751,39 @@ static void process_rx_packet(struct esp_adapter *adapter, struct sk_buff *skb)
        }
 }
 
+char *esp_get_hardware_name(int hardware_id)
+{
+       if(hardware_id == ESP_FIRMWARE_CHIP_ESP32)
+               return "ESP32";
+       else if(hardware_id == ESP_FIRMWARE_CHIP_ESP32S2)
+               return "ESP32S2";
+       else if(hardware_id == ESP_FIRMWARE_CHIP_ESP32C3)
+               return "ESP32C3";
+       else if(hardware_id == ESP_FIRMWARE_CHIP_ESP32S3)
+               return "ESP32S3";
+       else if(hardware_id == ESP_FIRMWARE_CHIP_ESP32C2)
+               return "ESP32C2";
+       else if(hardware_id == ESP_FIRMWARE_CHIP_ESP32C6)
+               return "ESP32C6";
+       else
+               return "N/A";
+}
+
+bool esp_is_valid_hardware_id(int hardware_id)
+{
+       switch(hardware_id) {
+       case ESP_FIRMWARE_CHIP_ESP32:
+       case ESP_FIRMWARE_CHIP_ESP32S2:
+       case ESP_FIRMWARE_CHIP_ESP32C3:
+       case ESP_FIRMWARE_CHIP_ESP32S3:
+       case ESP_FIRMWARE_CHIP_ESP32C2:
+       case ESP_FIRMWARE_CHIP_ESP32C6:
+               return true;
+       default:
+               return false;
+       }
+}
+
 int esp_is_tx_queue_paused(struct esp_wifi_device *priv)
 {
        if (!priv || !priv->ndev)
index 90db366271b4d34525995493d5c4cad2d37a76ca..427aab3880989f19b02134f01cae02777e5d7ebe 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/mmc/sdio_ids.h>
 #include <linux/mmc/card.h>
 #include <linux/mmc/host.h>
+#include <linux/module.h>
 #include "esp_if.h"
 #include "esp_sdio_api.h"
 #include "esp_api.h"
index d0bd513bd6aee74c9e0bf010ab8a06beced9c9f0..a39169d612f95761cbf4e78f40b0d9812b9ca303 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/gpio.h>
 #include <linux/mutex.h>
 #include <linux/delay.h>
+#include <linux/module.h>
 #include "esp_spi.h"
 #include "esp_if.h"
 #include "esp_api.h"
This page took 0.420077 seconds and 4 git commands to generate.