OSDN Git Service

Inline BNEP security
authorZach Johnson <zachoverflow@google.com>
Wed, 26 Aug 2020 00:22:37 +0000 (17:22 -0700)
committerZach Johnson <zachoverflow@google.com>
Wed, 26 Aug 2020 00:24:21 +0000 (17:24 -0700)
Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I11c768ec7e281fc4a751bae7a890c93f5144ff81

stack/bnep/bnep_api.cc
stack/bnep/bnep_main.cc
stack/pan/pan_utils.cc

index 21e8154..ba63722 100644 (file)
@@ -25,6 +25,7 @@
 #include "bnep_api.h"
 #include <string.h>
 #include "bnep_int.h"
+#include "bta/include/bta_api.h"
 #include "stack/btm/btm_sec.h"
 
 using bluetooth::Uuid;
@@ -168,8 +169,8 @@ tBNEP_RESULT BNEP_Connect(const RawAddress& p_rem_bda, const Uuid& src_uuid,
      */
     p_bcb->con_state = BNEP_STATE_CONN_START;
 
-    BTM_SetOutService(p_rem_bda, BTM_SEC_SERVICE_BNEP_PANU, mx_chan_id);
-    cid = L2CA_ConnectReq(BT_PSM_BNEP, p_bcb->rem_bda);
+    cid = L2CA_ConnectReq2(BT_PSM_BNEP, p_bcb->rem_bda,
+                           BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT);
     if (cid != 0) {
       p_bcb->l2cap_cid = cid;
 
index 92b5fa1..16444c7 100644 (file)
@@ -43,6 +43,7 @@
 #include "bnep_int.h"
 #include "bt_utils.h"
 
+#include "bta/include/bta_api.h"
 #include "device/include/controller.h"
 #include "osi/include/osi.h"
 
@@ -94,8 +95,9 @@ tBNEP_RESULT bnep_register_with_l2cap(void) {
   bnep_cb.reg_info.pL2CA_CongestionStatus_Cb = bnep_congestion_ind;
 
   /* Now, register with L2CAP */
-  if (!L2CA_Register(BT_PSM_BNEP, &bnep_cb.reg_info, false /* enable_snoop */,
-                     nullptr, bnep_cb.l2cap_my_cfg.mtu)) {
+  if (!L2CA_Register2(BT_PSM_BNEP, &bnep_cb.reg_info, false /* enable_snoop */,
+                      nullptr, bnep_cb.l2cap_my_cfg.mtu,
+                      BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT)) {
     BNEP_TRACE_ERROR("BNEP - Registration failed");
     return BNEP_SECURITY_FAIL;
   }
index 9699e18..f2edcc8 100644 (file)
@@ -125,34 +125,6 @@ uint32_t pan_register_with_sdp(uint16_t uuid, const char* p_name,
     UINT32_TO_BE_STREAM(p, NetAccessRate);
     SDP_AddAttribute(sdp_handle, ATTR_ID_MAX_NET_ACCESS_RATE, UINT_DESC_TYPE, 4,
                      array);
-
-    /* Register with Security Manager for the specific security level */
-    if (!BTM_SimpleSetSecurityLevel(
-            BTM_SEC_SERVICE_BNEP_NAP,
-            BTM_SEC_IN_AUTHENTICATE | BTM_SEC_IN_ENCRYPT |
-                BTM_SEC_OUT_AUTHENTICATE | BTM_SEC_OUT_ENCRYPT,
-            BT_PSM_BNEP)) {
-      PAN_TRACE_ERROR("PAN Security Registration failed for PANU");
-    }
-  }
-#endif
-#if (PAN_SUPPORTS_ROLE_GN == TRUE)
-  if (uuid == UUID_SERVCLASS_GN) {
-    if (!BTM_SimpleSetSecurityLevel(BTM_SEC_SERVICE_BNEP_GN, BTM_SEC_NONE,
-                                    BT_PSM_BNEP)) {
-      PAN_TRACE_ERROR("PAN Security Registration failed for GN");
-    }
-  }
-#endif
-#if (PAN_SUPPORTS_ROLE_PANU == TRUE)
-  if (uuid == UUID_SERVCLASS_PANU) {
-    if (!BTM_SimpleSetSecurityLevel(
-            BTM_SEC_SERVICE_BNEP_PANU,
-            BTM_SEC_IN_AUTHENTICATE | BTM_SEC_IN_ENCRYPT |
-                BTM_SEC_OUT_AUTHENTICATE | BTM_SEC_OUT_ENCRYPT,
-            BT_PSM_BNEP)) {
-      PAN_TRACE_ERROR("PAN Security Registration failed for PANU");
-    }
   }
 #endif