diff --git a/system/Android.mk b/system/Android.mk index 4d35c3c5072f15bc004e772d6f569029082a625a..259502c7105297ec89892cf01869548624112ac6 100644 --- a/system/Android.mk +++ b/system/Android.mk @@ -21,6 +21,9 @@ LOCAL_host_executables := \ LOCAL_host_python_hci_packets_library := \ $(SOONG_OUT_DIR)/.intermediates/packages/modules/Bluetooth/system/gd/gd_hci_packets_python3_gen/gen/hci_packets.py +LOCAL_host_python_smp_packets_library := \ + $(SOONG_OUT_DIR)/.intermediates/packages/modules/Bluetooth/system/gd/gd_smp_packets_python3_gen/gen/smp_packets.py + LOCAL_host_python_extension_libraries := \ $(HOST_OUT_SHARED_LIBRARIES)/bluetooth_packets_python3.so @@ -94,16 +97,19 @@ $(bluetooth_cert_src_and_bin_zip): PRIVATE_host_executables := $(LOCAL_host_exec $(bluetooth_cert_src_and_bin_zip): PRIVATE_host_libraries := $(LOCAL_host_libraries) $(bluetooth_cert_src_and_bin_zip): PRIVATE_host_python_extension_libraries := $(LOCAL_host_python_extension_libraries) $(bluetooth_cert_src_and_bin_zip): PRIVATE_host_python_hci_packets_library := $(LOCAL_host_python_hci_packets_library) +$(bluetooth_cert_src_and_bin_zip): PRIVATE_host_python_smp_packets_library := $(LOCAL_host_python_smp_packets_library) $(bluetooth_cert_src_and_bin_zip): PRIVATE_target_executables := $(LOCAL_target_executables) $(bluetooth_cert_src_and_bin_zip): PRIVATE_target_libraries := $(LOCAL_target_libraries) $(bluetooth_cert_src_and_bin_zip): $(SOONG_ZIP) $(LOCAL_cert_test_sources) \ $(LOCAL_host_executables) $(LOCAL_host_libraries) $(LOCAL_host_python_libraries) \ $(LOCAL_host_python_extension_libraries) \ $(LOCAL_host_python_hci_packets_library) \ + $(LOCAL_host_python_smp_packets_library) \ $(LOCAL_target_executables) $(LOCAL_target_libraries) $(hide) $(SOONG_ZIP) -d -o $@ \ -C $(PRIVATE_bluetooth_project_dir) $(addprefix -f ,$(PRIVATE_cert_test_sources)) \ -C $(dir $(PRIVATE_host_python_hci_packets_library)) -f $(PRIVATE_host_python_hci_packets_library) \ + -C $(dir $(PRIVATE_host_python_smp_packets_library)) -f $(PRIVATE_host_python_smp_packets_library) \ -C $(HOST_OUT_EXECUTABLES) $(addprefix -f ,$(PRIVATE_host_executables)) \ -C $(HOST_OUT_SHARED_LIBRARIES) $(addprefix -f ,$(PRIVATE_host_python_extension_libraries)) \ -P lib64 \ diff --git a/system/blueberry/tests/gd/security/le_security_test.py b/system/blueberry/tests/gd/security/le_security_test.py index 824c39bbda4cc8bfb6b5ed0fd3764fae17ab129c..6368c30f43407901faf34ba630de59f8dd76b8ae 100644 --- a/system/blueberry/tests/gd/security/le_security_test.py +++ b/system/blueberry/tests/gd/security/le_security_test.py @@ -14,7 +14,7 @@ # limitations under the License. import hci_packets as hci -from bluetooth_packets_python3.security_packets import PairingFailedReason +import smp_packets as smp from blueberry.tests.gd.cert.matchers import SecurityMatchers from blueberry.tests.gd.cert.metadata import metadata from blueberry.tests.gd.cert.py_hci import PyHci @@ -585,7 +585,7 @@ class LeSecurityTest(gd_base_test.GdBaseTestClass): # 3. IUT transmits the Pairing Failed command. assertThat(self.dut_security.get_bond_stream()).emits( SecurityMatchers.BondMsg(BondMsgType.DEVICE_BOND_FAILED, self.cert_address, - int(PairingFailedReason.ENCRYPTION_KEY_SIZE))) + int(smp.PairingFailedReason.ENCRYPTION_KEY_SIZE))) @metadata(pts_test_id="SM/SLA/EKS/BI-02-C", pts_test_name="IUT Responder, Lower Tester Maximum Encryption Key Size < Min_Encryption_Key_Length") @@ -622,7 +622,7 @@ class LeSecurityTest(gd_base_test.GdBaseTestClass): #3. IUT transmits the Pairing Failed command. assertThat(self.cert_security.get_bond_stream()).emits( SecurityMatchers.BondMsg(BondMsgType.DEVICE_BOND_FAILED, self.dut_address, - int(PairingFailedReason.ENCRYPTION_KEY_SIZE))) + int(smp.PairingFailedReason.ENCRYPTION_KEY_SIZE))) @metadata(pts_test_id="SM/MAS/SCPK/BV-01-C", pts_test_name="Passkey Entry, IUT Initiator, Secure Connections – Success") diff --git a/system/gd/Android.bp b/system/gd/Android.bp index 0df2a1af8e5e0a040759e08fcd8a6a7c35de3f82..2631e87108ae63e47adebb32ef7d7a6daaa9d112 100644 --- a/system/gd/Android.bp +++ b/system/gd/Android.bp @@ -701,7 +701,6 @@ genrule { cmd: "$(location bluetooth_packetgen) --include=packages/modules/Bluetooth/system/gd --out=$(genDir) --num_shards=10 $(in)", srcs: [ "l2cap/l2cap_packets.pdl", - "security/smp_packets.pdl", ], out: [ "l2cap/l2cap_packets_python3.cc", @@ -715,17 +714,6 @@ genrule { "l2cap/l2cap_packets_python3_shard_7.cc", "l2cap/l2cap_packets_python3_shard_8.cc", "l2cap/l2cap_packets_python3_shard_9.cc", - "security/smp_packets_python3.cc", - "security/smp_packets_python3_shard_0.cc", - "security/smp_packets_python3_shard_1.cc", - "security/smp_packets_python3_shard_2.cc", - "security/smp_packets_python3_shard_3.cc", - "security/smp_packets_python3_shard_4.cc", - "security/smp_packets_python3_shard_5.cc", - "security/smp_packets_python3_shard_6.cc", - "security/smp_packets_python3_shard_7.cc", - "security/smp_packets_python3_shard_8.cc", - "security/smp_packets_python3_shard_9.cc", ], } @@ -847,3 +835,19 @@ genrule { "hci_packets.py", ], } + +// Generate the python parser+serializer backend for +// smp_packets.pdl. +genrule { + name: "gd_smp_packets_python3_gen", + defaults: ["pdl_python_generator_defaults"], + cmd: "$(location :pdlc) $(in) |" + + " $(location :pdl_python_generator)" + + " --output $(out) --custom-type-location blueberry.utils.bluetooth", + srcs: [ + "security/smp_packets.pdl", + ], + out: [ + "smp_packets.py", + ], +} diff --git a/system/gd/cert/bluetooth_packets_python3_setup.py b/system/gd/cert/bluetooth_packets_python3_setup.py index 6e3657b07090a237225aff69ae65a70fbf1a53f3..66f52ee84cfcc8f37df5bd533718d44414fbbb56 100644 --- a/system/gd/cert/bluetooth_packets_python3_setup.py +++ b/system/gd/cert/bluetooth_packets_python3_setup.py @@ -52,7 +52,6 @@ BT_PACKETS_BASE_SRCS = [ BT_PACKETS_PY3_SRCs = \ [os.path.join(GD_DIR, "packet/python3_module.cc")] \ + glob.glob(os.path.join(BT_PACKETS_PY3_GEN_DIR, "l2cap", "*.cc")) \ - + glob.glob(os.path.join(BT_PACKETS_PY3_GEN_DIR, "security", "*.cc")) bluetooth_packets_python3_module = Extension( 'bluetooth_packets_python3', diff --git a/system/gd/cert/run b/system/gd/cert/run index 8fcf22b5161cb7356487b9d255d389d3dfa12c07..51b10076aef4b7614b5f10d5166aa67ec89aff4a 100755 --- a/system/gd/cert/run +++ b/system/gd/cert/run @@ -82,8 +82,8 @@ OUT_TARGET="${ANDROID_BUILD_TOP}/out/target" TEST_CONFIG="${ANDROID_BUILD_TOP}/packages/modules/Bluetooth/system/blueberry/tests/gd/host_config.yaml" TEST_FILTER="--presubmit" TEST_RUNNER="blueberry/tests/gd/gd_test_runner.py" -CPP_BUILD_TARGET="bluetooth_stack_with_facade root-canal bluetooth_packets_python3 gd_hci_packets_python3_gen" -RUST_BUILD_TARGET="bluetooth_with_facades root-canal bluetooth_packets_python3 bt_topshim_facade gd_hci_packets_python3_gen" +CPP_BUILD_TARGET="bluetooth_stack_with_facade root-canal bluetooth_packets_python3 gd_hci_packets_python3_gen gd_smp_packets_python3_gen" +RUST_BUILD_TARGET="bluetooth_with_facades root-canal bluetooth_packets_python3 bt_topshim_facade gd_hci_packets_python3_gen gd_smp_packets_python3_gen" BUILD_TARGET=$CPP_BUILD_TARGET CLEAN_VENV=false diff --git a/system/gd/packet/python3_module.cc b/system/gd/packet/python3_module.cc index 743d7544dbe94a548bf865faaf99497023845728..3059114d191b104b3383fa9132f9e621b5adba28 100644 --- a/system/gd/packet/python3_module.cc +++ b/system/gd/packet/python3_module.cc @@ -19,8 +19,6 @@ #include <cstring> #include <memory> -#include "hci/address.h" -#include "hci/class_of_device.h" #include "packet/base_packet_builder.h" #include "packet/bit_inserter.h" #include "packet/checksum_type_checker.h" @@ -38,14 +36,9 @@ namespace bluetooth { namespace l2cap { void define_l2cap_packets_submodule(py::module&); } -namespace security { -void define_smp_packets_submodule(py::module&); -} namespace packet { -using ::bluetooth::hci::Address; -using ::bluetooth::hci::ClassOfDevice; using ::bluetooth::packet::BasePacketBuilder; using ::bluetooth::packet::BaseStruct; using ::bluetooth::packet::BitInserter; @@ -104,8 +97,6 @@ PYBIND11_MODULE(bluetooth_packets_python3, m) { py::module l2cap_m = m.def_submodule("l2cap_packets", "A submodule of l2cap_packets"); bluetooth::l2cap::define_l2cap_packets_submodule(l2cap_m); - py::module security_m = m.def_submodule("security_packets", "A submodule of security_packets"); - bluetooth::security::define_smp_packets_submodule(security_m); } } // namespace packet