Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 056c90a7 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

PAN: Clean up sec mask

NAP and PANU require encryption and authenticated link key, and GN
requires no security.

Also update Security Description in SDP record.

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I8991b2ca8083e18c625e5e7723b419c9140dda43
parent 4ed330ff
Loading
Loading
Loading
Loading
+5 −10
Original line number Diff line number Diff line
@@ -328,19 +328,14 @@ void bta_pan_enable(tBTA_PAN_DATA* p_data) {
void bta_pan_set_role(tBTA_PAN_DATA* p_data) {
  tPAN_RESULT status;
  tBTA_PAN bta_pan;
  uint8_t sec[3];

  bta_pan_cb.app_id[0] = p_data->api_set_role.user_app_id;
  bta_pan_cb.app_id[1] = p_data->api_set_role.gn_app_id;
  bta_pan_cb.app_id[2] = p_data->api_set_role.nap_app_id;

  sec[0] = p_data->api_set_role.user_sec_mask;
  sec[1] = p_data->api_set_role.gn_sec_mask;
  sec[2] = p_data->api_set_role.nap_sec_mask;

  /* set security correctly in api and here */
  status = PAN_SetRole(
      p_data->api_set_role.role, sec, p_data->api_set_role.user_name,
  status =
      PAN_SetRole(p_data->api_set_role.role, p_data->api_set_role.user_name,
                  p_data->api_set_role.gn_name, p_data->api_set_role.nap_name);

  bta_pan.set_role.role = p_data->api_set_role.role;
@@ -364,7 +359,7 @@ void bta_pan_set_role(tBTA_PAN_DATA* p_data) {
  }
  /* if status is not success clear everything */
  else {
    PAN_SetRole(0, 0, NULL, NULL, NULL);
    PAN_SetRole(0, NULL, NULL, NULL);
    bta_sys_remove_uuid(UUID_SERVCLASS_NAP);
    bta_sys_remove_uuid(UUID_SERVCLASS_GN);
    bta_sys_remove_uuid(UUID_SERVCLASS_PANU);
@@ -390,7 +385,7 @@ void bta_pan_disable(void) {
  uint8_t i;

  /* close all connections */
  PAN_SetRole(0, NULL, NULL, NULL, NULL);
  PAN_SetRole(0, NULL, NULL, NULL);

#if (BTA_EIR_CANNED_UUID_LIST != TRUE)
  bta_sys_remove_uuid(UUID_SERVCLASS_NAP);
+0 −2
Original line number Diff line number Diff line
@@ -113,7 +113,6 @@ void BTA_PanSetRole(tBTA_PAN_ROLE role, tBTA_PAN_ROLE_INFO* p_user_info,
      strlcpy(p_buf->user_name, p_user_info->p_srv_name, BTA_SERVICE_NAME_LEN);

    p_buf->user_app_id = p_user_info->app_id;
    p_buf->user_sec_mask = PAN_SECURITY;
  }

  if (role & BTA_PAN_ROLE_NAP) {
@@ -121,7 +120,6 @@ void BTA_PanSetRole(tBTA_PAN_ROLE role, tBTA_PAN_ROLE_INFO* p_user_info,
      strlcpy(p_buf->nap_name, p_nap_info->p_srv_name, BTA_SERVICE_NAME_LEN);

    p_buf->nap_app_id = p_nap_info->app_id;
    p_buf->nap_sec_mask = PAN_SECURITY;
  }

  bta_sys_sendmsg(p_buf);
+0 −4
Original line number Diff line number Diff line
@@ -76,10 +76,6 @@ typedef struct {
  uint8_t user_app_id;
  uint8_t gn_app_id;
  uint8_t nap_app_id;
  tBTA_SEC user_sec_mask; /* Security mask */
  tBTA_SEC gn_sec_mask;   /* Security mask */
  tBTA_SEC nap_sec_mask;  /* Security mask */

} tBTA_PAN_API_SET_ROLE;

/* data type for BTA_PAN_API_OPEN_EVT */
+2 −3
Original line number Diff line number Diff line
@@ -256,9 +256,8 @@ extern void PAN_Deregister(void);
 *                  PAN_FAILURE     - if the role is not valid
 *
 ******************************************************************************/
extern tPAN_RESULT PAN_SetRole(uint8_t role, uint8_t* sec_mask,
                               const char* p_user_name, const char* p_gn_name,
                               const char* p_nap_name);
extern tPAN_RESULT PAN_SetRole(uint8_t role, const char* p_user_name,
                               const char* p_gn_name, const char* p_nap_name);

/*******************************************************************************
 *
+7 −13
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ void PAN_Deregister(void) {
  pan_cb.pan_pfilt_ind_cb = NULL;
  pan_cb.pan_mfilt_ind_cb = NULL;

  PAN_SetRole(PAN_ROLE_INACTIVE, NULL, NULL, NULL, NULL);
  PAN_SetRole(PAN_ROLE_INACTIVE, NULL, NULL, NULL);
  BNEP_Deregister();

  return;
@@ -111,10 +111,6 @@ void PAN_Deregister(void) {
 *                                      PAN_ROLE_CLIENT is for PANU role
 *                                      PAN_ROLE_GN_SERVER is for GN role
 *                                      PAN_ROLE_NAP_SERVER is for NAP role
 *                  sec_mask    - Security mask for different roles
 *                                      It is array of uint8_t. The bytes
 *                                      represent the security for roles PANU,
 *                                      GN and NAP in order
 *                  p_user_name - Service name for PANU role
 *                  p_gn_name   - Service name for GN role
 *                  p_nap_name  - Service name for NAP role
@@ -124,9 +120,8 @@ void PAN_Deregister(void) {
 *                  PAN_FAILURE     - if the role is not valid
 *
 ******************************************************************************/
tPAN_RESULT PAN_SetRole(uint8_t role, uint8_t* sec_mask,
                        const char* p_user_name, const char* p_gn_name,
                        const char* p_nap_name) {
tPAN_RESULT PAN_SetRole(uint8_t role, const char* p_user_name,
                        const char* p_gn_name, const char* p_nap_name) {
  /* Check if it is a shutdown request */
  if (role == PAN_ROLE_INACTIVE) {
    pan_close_all_connections();
@@ -135,7 +130,6 @@ tPAN_RESULT PAN_SetRole(uint8_t role, uint8_t* sec_mask,
  }

  const char* p_desc;
  uint8_t* p_sec = sec_mask;

  /* If the role is not a valid combination reject it */
  if ((!(role &
@@ -166,7 +160,7 @@ tPAN_RESULT PAN_SetRole(uint8_t role, uint8_t* sec_mask,
      SDP_DeleteRecord(pan_cb.pan_nap_sdp_handle);

    pan_cb.pan_nap_sdp_handle =
        pan_register_with_sdp(UUID_SERVCLASS_NAP, p_sec[2], p_nap_name, p_desc);
        pan_register_with_sdp(UUID_SERVCLASS_NAP, p_nap_name, p_desc);
    bta_sys_add_uuid(UUID_SERVCLASS_NAP);
  }
  /* If the NAP role is already active and now being cleared delete the record
@@ -193,7 +187,7 @@ tPAN_RESULT PAN_SetRole(uint8_t role, uint8_t* sec_mask,
      SDP_DeleteRecord(pan_cb.pan_gn_sdp_handle);

    pan_cb.pan_gn_sdp_handle =
        pan_register_with_sdp(UUID_SERVCLASS_GN, p_sec[1], p_gn_name, p_desc);
        pan_register_with_sdp(UUID_SERVCLASS_GN, p_gn_name, p_desc);
    bta_sys_add_uuid(UUID_SERVCLASS_GN);
  }
  /* If the GN role is already active and now being cleared delete the record */
@@ -217,8 +211,8 @@ tPAN_RESULT PAN_SetRole(uint8_t role, uint8_t* sec_mask,
    if (pan_cb.pan_user_sdp_handle != 0)
      SDP_DeleteRecord(pan_cb.pan_user_sdp_handle);

    pan_cb.pan_user_sdp_handle = pan_register_with_sdp(
        UUID_SERVCLASS_PANU, p_sec[0], p_user_name, p_desc);
    pan_cb.pan_user_sdp_handle =
        pan_register_with_sdp(UUID_SERVCLASS_PANU, p_user_name, p_desc);
    bta_sys_add_uuid(UUID_SERVCLASS_PANU);
  }
  /* If the PANU role is already active and now being cleared delete the record
Loading