Loading system/gd/facade/common.proto +5 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,11 @@ enum BluetoothAddressTypeEnum { RANDOM_IDENTITY_ADDRESS = 0x3; } message BluetoothAddressWithType { BluetoothAddress address = 1; BluetoothAddressTypeEnum type = 2; } enum BluetoothPeerAddressTypeEnum { PUBLIC_DEVICE_OR_IDENTITY_ADDRESS = 0x0; RANDOM_DEVICE_OR_IDENTITY_ADDRESS = 0x1; Loading system/gd/security/facade.cc +35 −2 Original line number Diff line number Diff line Loading @@ -24,16 +24,49 @@ namespace bluetooth { namespace security { class SecurityModuleFacadeService : public SecurityModuleFacade::Service { class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public ISecurityManagerListener { public: SecurityModuleFacadeService(SecurityModule* security_module, l2cap::le::L2capLeModule* l2cap_le_module, l2cap::classic::L2capClassicModule* l2cap_classic_module, hci::HciLayer* hci_layer, ::bluetooth::os::Handler* security_handler) : security_module_(security_module), l2cap_le_module_(l2cap_le_module), l2cap_classic_module_(l2cap_classic_module), security_handler_(security_handler) { // TODO(optedoblivion): Register callback listener security_module_->GetSecurityManager()->RegisterCallbackListener(this, security_handler_); } ::grpc::Status CreateBond(::grpc::ServerContext* context, const facade::BluetoothAddressWithType* request, ::google::protobuf::Empty* response) override { hci::Address peer; ASSERT(hci::Address::FromString(request->address().address(), peer)); hci::AddressType peer_type = hci::AddressType::PUBLIC_DEVICE_ADDRESS; security_module_->GetSecurityManager()->CreateBond(hci::AddressWithType(peer, peer_type)); return ::grpc::Status::OK; } ::grpc::Status CancelBond(::grpc::ServerContext* context, const facade::BluetoothAddressWithType* request, ::google::protobuf::Empty* response) override { hci::Address peer; ASSERT(hci::Address::FromString(request->address().address(), peer)); hci::AddressType peer_type = hci::AddressType::PUBLIC_DEVICE_ADDRESS; security_module_->GetSecurityManager()->CancelBond(hci::AddressWithType(peer, peer_type)); return ::grpc::Status::OK; } ::grpc::Status RemoveBond(::grpc::ServerContext* context, const facade::BluetoothAddressWithType* request, ::google::protobuf::Empty* response) override { hci::Address peer; ASSERT(hci::Address::FromString(request->address().address(), peer)); hci::AddressType peer_type = hci::AddressType::PUBLIC_DEVICE_ADDRESS; security_module_->GetSecurityManager()->RemoveBond(hci::AddressWithType(peer, peer_type)); return ::grpc::Status::OK; } void OnDeviceBonded(hci::AddressWithType device) {} void OnDeviceUnbonded(hci::AddressWithType device) {} void OnDeviceBondFailed(hci::AddressWithType device) {} private: SecurityModule* security_module_ __attribute__((unused)); l2cap::le::L2capLeModule* l2cap_le_module_ __attribute__((unused)); Loading system/gd/security/facade.h +1 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <grpc++/grpc++.h> #include "grpc/grpc_module.h" #include "hci/address_with_type.h" namespace bluetooth { namespace security { Loading system/gd/security/facade.proto +3 −3 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ import "google/protobuf/empty.proto"; import "facade/common.proto"; service SecurityModuleFacade { rpc CreateBond(facade.BluetoothAddress) returns (google.protobuf.Empty) {} rpc CancelBond(facade.BluetoothAddress) returns (google.protobuf.Empty) {} rpc RemoveBond(facade.BluetoothAddress) returns (google.protobuf.Empty) {} rpc CreateBond(facade.BluetoothAddressWithType) returns (google.protobuf.Empty) {} rpc CancelBond(facade.BluetoothAddressWithType) returns (google.protobuf.Empty) {} rpc RemoveBond(facade.BluetoothAddressWithType) returns (google.protobuf.Empty) {} } Loading
system/gd/facade/common.proto +5 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,11 @@ enum BluetoothAddressTypeEnum { RANDOM_IDENTITY_ADDRESS = 0x3; } message BluetoothAddressWithType { BluetoothAddress address = 1; BluetoothAddressTypeEnum type = 2; } enum BluetoothPeerAddressTypeEnum { PUBLIC_DEVICE_OR_IDENTITY_ADDRESS = 0x0; RANDOM_DEVICE_OR_IDENTITY_ADDRESS = 0x1; Loading
system/gd/security/facade.cc +35 −2 Original line number Diff line number Diff line Loading @@ -24,16 +24,49 @@ namespace bluetooth { namespace security { class SecurityModuleFacadeService : public SecurityModuleFacade::Service { class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public ISecurityManagerListener { public: SecurityModuleFacadeService(SecurityModule* security_module, l2cap::le::L2capLeModule* l2cap_le_module, l2cap::classic::L2capClassicModule* l2cap_classic_module, hci::HciLayer* hci_layer, ::bluetooth::os::Handler* security_handler) : security_module_(security_module), l2cap_le_module_(l2cap_le_module), l2cap_classic_module_(l2cap_classic_module), security_handler_(security_handler) { // TODO(optedoblivion): Register callback listener security_module_->GetSecurityManager()->RegisterCallbackListener(this, security_handler_); } ::grpc::Status CreateBond(::grpc::ServerContext* context, const facade::BluetoothAddressWithType* request, ::google::protobuf::Empty* response) override { hci::Address peer; ASSERT(hci::Address::FromString(request->address().address(), peer)); hci::AddressType peer_type = hci::AddressType::PUBLIC_DEVICE_ADDRESS; security_module_->GetSecurityManager()->CreateBond(hci::AddressWithType(peer, peer_type)); return ::grpc::Status::OK; } ::grpc::Status CancelBond(::grpc::ServerContext* context, const facade::BluetoothAddressWithType* request, ::google::protobuf::Empty* response) override { hci::Address peer; ASSERT(hci::Address::FromString(request->address().address(), peer)); hci::AddressType peer_type = hci::AddressType::PUBLIC_DEVICE_ADDRESS; security_module_->GetSecurityManager()->CancelBond(hci::AddressWithType(peer, peer_type)); return ::grpc::Status::OK; } ::grpc::Status RemoveBond(::grpc::ServerContext* context, const facade::BluetoothAddressWithType* request, ::google::protobuf::Empty* response) override { hci::Address peer; ASSERT(hci::Address::FromString(request->address().address(), peer)); hci::AddressType peer_type = hci::AddressType::PUBLIC_DEVICE_ADDRESS; security_module_->GetSecurityManager()->RemoveBond(hci::AddressWithType(peer, peer_type)); return ::grpc::Status::OK; } void OnDeviceBonded(hci::AddressWithType device) {} void OnDeviceUnbonded(hci::AddressWithType device) {} void OnDeviceBondFailed(hci::AddressWithType device) {} private: SecurityModule* security_module_ __attribute__((unused)); l2cap::le::L2capLeModule* l2cap_le_module_ __attribute__((unused)); Loading
system/gd/security/facade.h +1 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <grpc++/grpc++.h> #include "grpc/grpc_module.h" #include "hci/address_with_type.h" namespace bluetooth { namespace security { Loading
system/gd/security/facade.proto +3 −3 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ import "google/protobuf/empty.proto"; import "facade/common.proto"; service SecurityModuleFacade { rpc CreateBond(facade.BluetoothAddress) returns (google.protobuf.Empty) {} rpc CancelBond(facade.BluetoothAddress) returns (google.protobuf.Empty) {} rpc RemoveBond(facade.BluetoothAddress) returns (google.protobuf.Empty) {} rpc CreateBond(facade.BluetoothAddressWithType) returns (google.protobuf.Empty) {} rpc CancelBond(facade.BluetoothAddressWithType) returns (google.protobuf.Empty) {} rpc RemoveBond(facade.BluetoothAddressWithType) returns (google.protobuf.Empty) {} }