avct_cb.mtu = mtu;
/* register PSM with L2CAP */
- L2CA_Register(AVCT_PSM, (tL2CAP_APPL_INFO*)&avct_l2c_appl,
- true /* enable_snoop */, nullptr, avct_cb.mtu);
+ L2CA_Register2(AVCT_PSM, (tL2CAP_APPL_INFO*)&avct_l2c_appl,
+ true /* enable_snoop */, nullptr, avct_cb.mtu,
+ BTA_SEC_AUTHENTICATE);
BTM_SimpleSetSecurityLevel(BTM_SEC_SERVICE_AVCTP, BTA_SEC_AUTHENTICATE,
AVCT_PSM);
if (mtu_br < AVCT_MIN_BROWSE_MTU) mtu_br = AVCT_MIN_BROWSE_MTU;
avct_cb.mtu_br = mtu_br;
- L2CA_Register(AVCT_BR_PSM, (tL2CAP_APPL_INFO*)&avct_l2c_br_appl,
- true /*enable_snoop*/, &ertm_info, avct_cb.mtu_br);
+ L2CA_Register2(AVCT_BR_PSM, (tL2CAP_APPL_INFO*)&avct_l2c_br_appl,
+ true /*enable_snoop*/, &ertm_info, avct_cb.mtu_br,
+ BTA_SEC_AUTHENTICATE);
/* AVCTP browsing channel uses the same security service as AVCTP control
* channel */
return (HID_ERR_NO_RESOURCES);
}
- if (!L2CA_Register(HID_PSM_CONTROL, (tL2CAP_APPL_INFO*)&dev_reg_info,
- false /* enable_snoop */, nullptr, hd_cb.l2cap_cfg.mtu)) {
+ if (!L2CA_Register2(HID_PSM_CONTROL, (tL2CAP_APPL_INFO*)&dev_reg_info,
+ false /* enable_snoop */, nullptr, hd_cb.l2cap_cfg.mtu,
+ BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT)) {
HIDD_TRACE_ERROR("HID Control (device) registration failed");
return (HID_ERR_L2CAP_FAILED);
}
- if (!L2CA_Register(HID_PSM_INTERRUPT, (tL2CAP_APPL_INFO*)&dev_reg_info,
- false /* enable_snoop */, nullptr,
- hd_cb.l2cap_intr_cfg.mtu)) {
+ if (!L2CA_Register2(HID_PSM_INTERRUPT, (tL2CAP_APPL_INFO*)&dev_reg_info,
+ false /* enable_snoop */, nullptr,
+ hd_cb.l2cap_intr_cfg.mtu, BTM_SEC_NONE)) {
L2CA_Deregister(HID_PSM_CONTROL);
HIDD_TRACE_ERROR("HID Interrupt (device) registration failed");
return (HID_ERR_L2CAP_FAILED);
* External Function Declarations
****************************************************************************/
+// Also does security for you
+uint16_t L2CA_Register2(uint16_t psm, tL2CAP_APPL_INFO* p_cb_info,
+ bool enable_snoop, tL2CAP_ERTM_INFO* p_ertm_info,
+ uint16_t required_mtu, uint16_t sec_level);
+
/*******************************************************************************
*
* Function L2CA_Register
#include <cstdint>
#include <string>
+#include "btm_sec.h"
#include "device/include/controller.h" // TODO Remove
#include "main/shim/l2c_api.h"
#include "main/shim/shim.h"
using base::StringPrintf;
+uint16_t L2CA_Register2(uint16_t psm, tL2CAP_APPL_INFO* p_cb_info,
+ bool enable_snoop, tL2CAP_ERTM_INFO* p_ertm_info,
+ uint16_t required_mtu, uint16_t sec_level) {
+ auto ret =
+ L2CA_Register(psm, p_cb_info, enable_snoop, p_ertm_info, required_mtu);
+ BTM_SetSecurityLevel(false, "", 0, sec_level, psm, 0, 0);
+ return ret;
+}
+
/*******************************************************************************
*
* Function L2CA_Register
sdp_cb.reg_info.pL2CA_TxComplete_Cb = NULL;
/* Now, register with L2CAP */
- if (!L2CA_Register(SDP_PSM, &sdp_cb.reg_info, true /* enable_snoop */,
- nullptr, sdp_cb.l2cap_my_cfg.mtu)) {
+ if (!L2CA_Register2(SDP_PSM, &sdp_cb.reg_info, true /* enable_snoop */,
+ nullptr, sdp_cb.l2cap_my_cfg.mtu, BTM_SEC_NONE)) {
SDP_TRACE_ERROR("SDP Registration failed");
}
}