constexpr uint16_t kUnusedResult = 0;
} // namespace
-bool bluetooth::legacy::shim::PsmManager::IsPsmRegistered(uint16_t psm) const {
+bool bluetooth::shim::legacy::PsmManager::IsPsmRegistered(uint16_t psm) const {
return psm_to_callback_map_.find(psm) != psm_to_callback_map_.end();
}
-bool bluetooth::legacy::shim::PsmManager::HasClient(uint16_t psm) const {
+bool bluetooth::shim::legacy::PsmManager::HasClient(uint16_t psm) const {
return IsPsmRegistered(psm) && psm_to_callback_map_.at(psm) != nullptr;
}
-void bluetooth::legacy::shim::PsmManager::RegisterPsm(
+void bluetooth::shim::legacy::PsmManager::RegisterPsm(
uint16_t psm, const tL2CAP_APPL_INFO* callbacks) {
CHECK(!HasClient(psm));
psm_to_callback_map_[psm] = callbacks;
}
-void bluetooth::legacy::shim::PsmManager::RegisterPsm(uint16_t psm) {
+void bluetooth::shim::legacy::PsmManager::RegisterPsm(uint16_t psm) {
RegisterPsm(psm, nullptr);
}
-void bluetooth::legacy::shim::PsmManager::UnregisterPsm(uint16_t psm) {
+void bluetooth::shim::legacy::PsmManager::UnregisterPsm(uint16_t psm) {
CHECK(IsPsmRegistered(psm));
psm_to_callback_map_.erase(psm);
}
-const tL2CAP_APPL_INFO* bluetooth::legacy::shim::PsmManager::Callbacks(
+const tL2CAP_APPL_INFO* bluetooth::shim::legacy::PsmManager::Callbacks(
uint16_t psm) {
CHECK(HasClient(psm));
return psm_to_callback_map_[psm];
}
-bluetooth::legacy::shim::L2cap::L2cap()
+bluetooth::shim::legacy::L2cap::L2cap()
: classic_dynamic_psm_(kInitialClassicDynamicPsm),
le_dynamic_psm_(kInitialLeDynamicPsm),
classic_virtual_psm_(kInitialClassicVirtualPsm) {
[this](int fd) { Dump(fd); });
}
-bluetooth::legacy::shim::L2cap::~L2cap() {
+bluetooth::shim::legacy::L2cap::~L2cap() {
bluetooth::shim::UnregisterDumpsysFunction(static_cast<void*>(this));
}
-bluetooth::legacy::shim::PsmManager& bluetooth::legacy::shim::L2cap::Le() {
+bluetooth::shim::legacy::PsmManager& bluetooth::shim::legacy::L2cap::Le() {
return le_;
}
-bluetooth::legacy::shim::PsmManager& bluetooth::legacy::shim::L2cap::Classic() {
+bluetooth::shim::legacy::PsmManager& bluetooth::shim::legacy::L2cap::Classic() {
return classic_;
}
-bool bluetooth::legacy::shim::L2cap::ConnectionExists(uint16_t cid) const {
+bool bluetooth::shim::legacy::L2cap::ConnectionExists(uint16_t cid) const {
return cid_to_psm_map_.find(cid) != cid_to_psm_map_.end();
}
-uint16_t bluetooth::legacy::shim::L2cap::CidToPsm(uint16_t cid) const {
+uint16_t bluetooth::shim::legacy::L2cap::CidToPsm(uint16_t cid) const {
CHECK(ConnectionExists(cid));
return cid_to_psm_map_.at(cid);
}
-uint16_t bluetooth::legacy::shim::L2cap::ConvertClientToRealPsm(
+uint16_t bluetooth::shim::legacy::L2cap::ConvertClientToRealPsm(
uint16_t client_psm, bool is_outgoing_only_connection) {
if (!is_outgoing_only_connection) {
return client_psm;
return GetNextVirtualPsm(client_psm);
}
-uint16_t bluetooth::legacy::shim::L2cap::ConvertClientToRealPsm(
+uint16_t bluetooth::shim::legacy::L2cap::ConvertClientToRealPsm(
uint16_t client_psm) {
if (client_psm_to_real_psm_map_.find(client_psm) ==
client_psm_to_real_psm_map_.end()) {
return client_psm_to_real_psm_map_.at(client_psm);
}
-void bluetooth::legacy::shim::L2cap::RemoveClientPsm(uint16_t client_psm) {
+void bluetooth::shim::legacy::L2cap::RemoveClientPsm(uint16_t client_psm) {
if (client_psm_to_real_psm_map_.find(client_psm) !=
client_psm_to_real_psm_map_.end()) {
client_psm_to_real_psm_map_.erase(client_psm);
}
}
-uint16_t bluetooth::legacy::shim::L2cap::GetNextVirtualPsm(uint16_t real_psm) {
+uint16_t bluetooth::shim::legacy::L2cap::GetNextVirtualPsm(uint16_t real_psm) {
if (real_psm < kInitialClassicDynamicPsm) {
return real_psm;
}
return classic_virtual_psm_;
}
-uint16_t bluetooth::legacy::shim::L2cap::GetNextDynamicLePsm() {
+uint16_t bluetooth::shim::legacy::L2cap::GetNextDynamicLePsm() {
while (Le().IsPsmRegistered(le_dynamic_psm_)) {
le_dynamic_psm_++;
if (le_dynamic_psm_ > kFinalLeDynamicPsm) {
return le_dynamic_psm_;
}
-uint16_t bluetooth::legacy::shim::L2cap::GetNextDynamicClassicPsm() {
+uint16_t bluetooth::shim::legacy::L2cap::GetNextDynamicClassicPsm() {
while (Classic().IsPsmRegistered(classic_dynamic_psm_)) {
classic_dynamic_psm_ += 2;
if (classic_dynamic_psm_ > kFinalClassicDynamicPsm) {
return classic_dynamic_psm_;
}
-void bluetooth::legacy::shim::L2cap::RegisterService(
+void bluetooth::shim::legacy::L2cap::RegisterService(
uint16_t psm, const tL2CAP_APPL_INFO* callbacks, bool enable_snoop,
tL2CAP_ERTM_INFO* p_ertm_info) {
LOG_DEBUG(LOG_TAG, "Registering service on psm:%hd", psm);
bluetooth::shim::GetL2cap()->RegisterService(
psm, use_ertm, mtu,
std::bind(
- &bluetooth::legacy::shim::L2cap::OnRemoteInitiatedConnectionCreated,
+ &bluetooth::shim::legacy::L2cap::OnRemoteInitiatedConnectionCreated,
this, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3),
std::move(register_completed));
LOG_DEBUG(LOG_TAG, "Successfully registered service on psm:%hd", psm);
}
-void bluetooth::legacy::shim::L2cap::OnRemoteInitiatedConnectionCreated(
+void bluetooth::shim::legacy::L2cap::OnRemoteInitiatedConnectionCreated(
std::string string_address, uint16_t psm, uint16_t cid) {
RawAddress raw_address;
RawAddress::FromString(string_address, raw_address);
kUnusedId);
}
-void bluetooth::legacy::shim::L2cap::UnregisterService(uint16_t psm) {
+void bluetooth::shim::legacy::L2cap::UnregisterService(uint16_t psm) {
if (!Classic().IsPsmRegistered(psm)) {
LOG_WARN(LOG_TAG,
"Service must be registered in order to unregister psm:%hd", psm);
Classic().UnregisterPsm(psm);
}
-uint16_t bluetooth::legacy::shim::L2cap::CreateConnection(
+uint16_t bluetooth::shim::legacy::L2cap::CreateConnection(
uint16_t psm, const RawAddress& raw_address) {
if (!Classic().IsPsmRegistered(psm)) {
LOG_WARN(LOG_TAG, "Service must be registered in order to connect psm:%hd",
bluetooth::shim::GetL2cap()->CreateConnection(
psm, raw_address.ToString(),
std::bind(
- &bluetooth::legacy::shim::L2cap::OnLocalInitiatedConnectionCreated,
+ &bluetooth::shim::legacy::L2cap::OnLocalInitiatedConnectionCreated,
this, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3),
std::move(connect_completed));
return cid;
}
-void bluetooth::legacy::shim::L2cap::OnLocalInitiatedConnectionCreated(
+void bluetooth::shim::legacy::L2cap::OnLocalInitiatedConnectionCreated(
std::string string_address, uint16_t psm, uint16_t cid) {
LOG_DEBUG(LOG_TAG,
"Sending connection confirm to the upper stack but really "
Classic().Callbacks(psm)->pL2CA_ConnectCfm_Cb(cid, status);
}
-bool bluetooth::legacy::shim::L2cap::Write(uint16_t cid, BT_HDR* bt_hdr) {
+bool bluetooth::shim::legacy::L2cap::Write(uint16_t cid, BT_HDR* bt_hdr) {
CHECK(bt_hdr != nullptr);
const uint8_t* data = bt_hdr->data + bt_hdr->offset;
size_t len = bt_hdr->len;
return true;
}
-void bluetooth::legacy::shim::L2cap::SetDownstreamCallbacks(uint16_t cid) {
+void bluetooth::shim::legacy::L2cap::SetDownstreamCallbacks(uint16_t cid) {
bluetooth::shim::GetL2cap()->SetReadDataReadyCallback(
cid, [this](uint16_t cid, std::vector<const uint8_t> data) {
LOG_DEBUG(LOG_TAG, "OnDataReady cid:%hd len:%zd", cid, data.size());
});
}
-bool bluetooth::legacy::shim::L2cap::ConnectResponse(
+bool bluetooth::shim::legacy::L2cap::ConnectResponse(
const RawAddress& raw_address, uint8_t signal_id, uint16_t cid,
uint16_t result, uint16_t status, tL2CAP_ERTM_INFO* ertm_info) {
CHECK(ConnectionExists(cid));
return true;
}
-bool bluetooth::legacy::shim::L2cap::ConfigRequest(
+bool bluetooth::shim::legacy::L2cap::ConfigRequest(
uint16_t cid, const tL2CAP_CFG_INFO* config_info) {
LOG_INFO(LOG_TAG, "Received config request from upper layer cid:%hd", cid);
CHECK(ConnectionExists(cid));
return true;
}
-bool bluetooth::legacy::shim::L2cap::ConfigResponse(
+bool bluetooth::shim::legacy::L2cap::ConfigResponse(
uint16_t cid, const tL2CAP_CFG_INFO* config_info) {
CHECK(ConnectionExists(cid));
LOG_DEBUG(
return true;
}
-bool bluetooth::legacy::shim::L2cap::DisconnectRequest(uint16_t cid) {
+bool bluetooth::shim::legacy::L2cap::DisconnectRequest(uint16_t cid) {
CHECK(ConnectionExists(cid));
if (cid_closing_set_.find(cid) != cid_closing_set_.end()) {
LOG_WARN(LOG_TAG, "%s Channel already in closing state cid:%hu", __func__,
return true;
}
-bool bluetooth::legacy::shim::L2cap::DisconnectResponse(uint16_t cid) {
+bool bluetooth::shim::legacy::L2cap::DisconnectResponse(uint16_t cid) {
LOG_DEBUG(LOG_TAG,
"%s Silently dropping client disconnect response as channel is "
"already disconnected",
return true;
}
-void bluetooth::legacy::shim::L2cap::Dump(int fd) {
+void bluetooth::shim::legacy::L2cap::Dump(int fd) {
if (cid_to_psm_map_.empty()) {
dprintf(fd, "%s No active l2cap channels\n", kModuleName);
} else {