X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=stack%2Fpan%2Fpan_main.c;h=b824b310a269add525723813b6fe534cf746828d;hb=9f58b5b92316d3e081862927f62bb4049a9a21d6;hp=5c3a36739033f56a8723bf9ffc0195fb3cd72cc7;hpb=b6d3f76f844110cf6b22d72b5704d93f3d40d553;p=android-x86%2Fsystem-bt.git diff --git a/stack/pan/pan_main.c b/stack/pan/pan_main.c index 5c3a36739..b824b310a 100644 --- a/stack/pan/pan_main.c +++ b/stack/pan/pan_main.c @@ -222,6 +222,39 @@ void pan_conn_ind_cb (UINT16 handle, return; } + /* Check for valid interactions between the three PAN profile roles */ + /* + * For reference, see Table 1 in PAN Profile v1.0 spec. + * Note: the remote is the initiator. + */ + BOOLEAN is_valid_interaction = FALSE; + switch (remote_uuid->uu.uuid16) { + case UUID_SERVCLASS_NAP: + case UUID_SERVCLASS_GN: + if (local_uuid->uu.uuid16 == UUID_SERVCLASS_PANU) + is_valid_interaction = TRUE; + break; + case UUID_SERVCLASS_PANU: + is_valid_interaction = TRUE; + break; + } + /* + * Explicitly disable connections to the local PANU if the remote is + * not PANU. + */ + if ((local_uuid->uu.uuid16 == UUID_SERVCLASS_PANU) && + (remote_uuid->uu.uuid16 != UUID_SERVCLASS_PANU)) { + is_valid_interaction = FALSE; + } + if (!is_valid_interaction) { + PAN_TRACE_ERROR( + "PAN Connection failed because of invalid PAN profile roles " + "interaction: Remote UUID 0x%x Local UUID 0x%x", + remote_uuid->uu.uuid16, local_uuid->uu.uuid16); + BNEP_ConnectResp(handle, BNEP_CONN_FAILED_SRC_UUID); + return; + } + /* Requested destination role is */ if (local_uuid->uu.uuid16 == UUID_SERVCLASS_PANU) req_role = PAN_ROLE_CLIENT; @@ -596,11 +629,8 @@ void pan_data_buf_ind_cb (UINT16 handle, if (pan_cb.pan_data_buf_ind_cb) (*pan_cb.pan_data_buf_ind_cb) (pcb->handle, src, dst, protocol, p_buf, ext, forward); else if (pan_cb.pan_data_ind_cb) - { (*pan_cb.pan_data_ind_cb) (pcb->handle, src, dst, protocol, p_data, len, ext, forward); - osi_free(p_buf); - } - + osi_free(p_buf); return; } @@ -623,13 +653,8 @@ void pan_data_buf_ind_cb (UINT16 handle, if (pan_cb.pan_data_buf_ind_cb) (*pan_cb.pan_data_buf_ind_cb) (pcb->handle, src, dst, protocol, p_buf, ext, forward); else if (pan_cb.pan_data_ind_cb) - { (*pan_cb.pan_data_ind_cb) (pcb->handle, src, dst, protocol, p_data, len, ext, forward); - osi_free(p_buf); - } - else - osi_free(p_buf); - + osi_free(p_buf); return; }