summaryrefslogtreecommitdiffstats
path: root/stack/rfcomm/port_rfc.c
diff options
context:
space:
mode:
authorAndre Eisenbach <andre@broadcom.com>2012-09-18 01:35:44 -0700
committerMatthew Xie <mattx@google.com>2012-09-18 16:26:28 -0700
commit6ef101187774e30ddba6b46bbedef549a42196ad (patch)
treef36eb347f03083671640fbc750171e3b951e0082 /stack/rfcomm/port_rfc.c
parentf80d3d045eab5f002be4b5e8a3d2d376fdf7581a (diff)
downloadexternal_bluetooth_bluedroid-6ef101187774e30ddba6b46bbedef549a42196ad.zip
external_bluetooth_bluedroid-6ef101187774e30ddba6b46bbedef549a42196ad.tar.gz
external_bluetooth_bluedroid-6ef101187774e30ddba6b46bbedef549a42196ad.tar.bz2
Initual Bluetooth open source release
First release under Apache source license with updated header files and whitespace cleanups. Also fixed file permission to remove executable bit from source files. Change-Id: I7155903edfc2f491c1cbbd0db108f207852caaa0
Diffstat (limited to 'stack/rfcomm/port_rfc.c')
-rw-r--r--stack/rfcomm/port_rfc.c93
1 files changed, 53 insertions, 40 deletions
diff --git a/stack/rfcomm/port_rfc.c b/stack/rfcomm/port_rfc.c
index ef84fef..8980330 100644
--- a/stack/rfcomm/port_rfc.c
+++ b/stack/rfcomm/port_rfc.c
@@ -1,14 +1,27 @@
-/*****************************************************************************
-**
-** Name: port_rfc.c
-**
-** Description: This module contains functions for port emulation entity
-** and RFCOMM communications
-**
-**
-** Copyright (c) 1999-2009, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-******************************************************************************/
+/******************************************************************************
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This module contains functions for port emulation entity and RFCOMM
+ * communications
+ *
+ ******************************************************************************/
#include <string.h>
#include "bt_target.h"
@@ -20,7 +33,7 @@
#include "port_int.h"
#include "rfc_int.h"
-/*
+/*
** Local function definitions
*/
UINT32 port_rfc_send_tx_data (tPORT *p_port);
@@ -85,7 +98,7 @@ int port_open_continue (tPORT *p_port)
**
** Function port_start_control
**
-** Description This function is called in the BTU_TASK context to
+** Description This function is called in the BTU_TASK context to
** send control information
**
** Returns void
@@ -106,7 +119,7 @@ void port_start_control (tPORT *p_port)
**
** Function port_start_par_neg
**
-** Description This function is called in the BTU_TASK context to
+** Description This function is called in the BTU_TASK context to
** send configuration information
**
** Returns void
@@ -127,7 +140,7 @@ void port_start_par_neg (tPORT *p_port)
**
** Function port_start_close
**
-** Description This function is called in the BTU_TASK context to
+** Description This function is called in the BTU_TASK context to
** release DLC
**
** Returns void
@@ -240,7 +253,7 @@ void PORT_StartCnf (tRFC_MCB *p_mcb, UINT16 result)
** Function PORT_StartInd
**
** Description This function is called from the RFCOMM layer when
-** some peer device wants to establish a multiplexer
+** some peer device wants to establish a multiplexer
** connection. Check if there are any ports open with this
** or not assigned multiplexer.
**
@@ -292,9 +305,9 @@ void PORT_ParNegInd (tRFC_MCB *p_mcb, UINT8 dlci, UINT16 mtu, UINT8 cl, UINT8 k)
{
/* If the port cannot be opened, send a DM. Per Errata 1205 */
rfc_send_dm(p_mcb, dlci, FALSE);
- /* check if this is the last port open, some headsets have
+ /* check if this is the last port open, some headsets have
problem, they don't disconnect if we send DM */
- rfc_check_mcb_active( p_mcb );
+ rfc_check_mcb_active( p_mcb );
RFCOMM_TRACE_EVENT0( "PORT_ParNegInd: port not found" );
return;
}
@@ -315,7 +328,7 @@ void PORT_ParNegInd (tRFC_MCB *p_mcb, UINT8 dlci, UINT16 mtu, UINT8 cl, UINT8 k)
/* use that. Otherwise both must want credit based, so use that. If flow is */
/* already defined for this mux, we respond with that value. */
if (p_mcb->flow == PORT_FC_UNDEFINED)
- {
+ {
if ((PORT_FC_DEFAULT == PORT_FC_TS710) || (cl == RFCOMM_PN_CONV_LAYER_TYPE_1))
{
p_mcb->flow = PORT_FC_TS710;
@@ -376,11 +389,11 @@ void PORT_ParNegCnf (tRFC_MCB *p_mcb, UINT8 dlci, UINT16 mtu, UINT8 cl, UINT8 k)
if (!p_port)
return;
- /* Flow control mechanism not set yet. Negotiate flow control mechanism. */
+ /* Flow control mechanism not set yet. Negotiate flow control mechanism. */
if (p_mcb->flow == PORT_FC_UNDEFINED)
{
/* Our stack is configured for TS07.10 and they responded with credit-based. */
- /* This is illegal-- negotiation fails. */
+ /* This is illegal-- negotiation fails. */
if ((PORT_FC_DEFAULT == PORT_FC_TS710) && (cl == RFCOMM_PN_CONV_LAYER_CBFC_R))
{
rfc_send_disc (p_mcb, p_port->dlci);
@@ -420,10 +433,10 @@ void PORT_ParNegCnf (tRFC_MCB *p_mcb, UINT8 dlci, UINT16 mtu, UINT8 cl, UINT8 k)
** Function PORT_DlcEstablishInd
**
** Description This function is called from the RFCOMM layer when peer
-** device wants to establish a new DLC. If this is not the
-** first message in the establishment procedure port_handle
+** device wants to establish a new DLC. If this is not the
+** first message in the establishment procedure port_handle
** has a handle to the port control block otherwise the control
-** block should be found based on the muliplexer channel and
+** block should be found based on the muliplexer channel and
** dlci. The block should be allocated allocated before
** meaning that application already made open.
**
@@ -473,7 +486,7 @@ void PORT_DlcEstablishInd (tRFC_MCB *p_mcb, UINT8 dlci, UINT16 mtu)
**
** Description This function is called from the RFCOMM layer when peer
** acknowledges establish procedure (SABME/UA). Send reply
-** to the user and set state to OPENED if result was
+** to the user and set state to OPENED if result was
** successfull.
**
*******************************************************************************/
@@ -509,7 +522,7 @@ void PORT_DlcEstablishCnf (tRFC_MCB *p_mcb, UINT8 dlci, UINT16 mtu, UINT16 resul
p_port->state = PORT_STATE_OPENED;
/* RPN is required only if we want to tell DTE how the port should be opened */
- if ((p_port->uuid == UUID_SERVCLASS_DIALUP_NETWORKING)
+ if ((p_port->uuid == UUID_SERVCLASS_DIALUP_NETWORKING)
|| (p_port->uuid == UUID_SERVCLASS_FAX))
RFCOMM_PortNegReq (p_port->rfc.p_mcb, p_port->dlci, NULL);
else
@@ -523,8 +536,8 @@ void PORT_DlcEstablishCnf (tRFC_MCB *p_mcb, UINT8 dlci, UINT16 mtu, UINT16 resul
**
** Description This function is called from the RFCOMM layer when peer
** device wants to set parameters of the port. As per the spec
-** this message has to be sent before the first data packet
-** and can be sent before establish. The block should be
+** this message has to be sent before the first data packet
+** and can be sent before establish. The block should be
** allocated before meaning that application already made open.
**
*******************************************************************************/
@@ -763,7 +776,7 @@ void PORT_CloseInd (tRFC_MCB *p_mcb)
p_port = &rfc_cb.port.port[0];
for (i = 0; i < MAX_RFC_PORTS; i++, p_port++)
{
- if (p_port->rfc.p_mcb == p_mcb)
+ if (p_port->rfc.p_mcb == p_mcb)
{
port_rfc_closed (p_port, PORT_PEER_CONNECTION_FAILED);
}
@@ -775,7 +788,7 @@ void PORT_CloseInd (tRFC_MCB *p_mcb)
**
** Function Port_TimeOutCloseMux
**
-** Description This function is called when RFCOMM timesout on a command
+** Description This function is called when RFCOMM timesout on a command
** as a result multiplexer connection is closed.
**
*******************************************************************************/
@@ -789,7 +802,7 @@ void Port_TimeOutCloseMux (tRFC_MCB *p_mcb)
p_port = &rfc_cb.port.port[0];
for (i = 0; i < MAX_RFC_PORTS; i++, p_port++)
{
- if (p_port->rfc.p_mcb == p_mcb)
+ if (p_port->rfc.p_mcb == p_mcb)
{
port_rfc_closed (p_port, PORT_PEER_TIMEOUT);
}
@@ -802,7 +815,7 @@ void Port_TimeOutCloseMux (tRFC_MCB *p_mcb)
** Function PORT_DataInd
**
** Description This function is called from the RFCOMM layer when data
-** buffer is received from the peer.
+** buffer is received from the peer.
**
*******************************************************************************/
void PORT_DataInd (tRFC_MCB *p_mcb, UINT8 dlci, BT_HDR *p_buf)
@@ -901,7 +914,7 @@ void PORT_DataInd (tRFC_MCB *p_mcb, UINT8 dlci, BT_HDR *p_buf)
**
** Function PORT_FlowInd
**
-** Description This function is called from the RFCOMM layer on the flow
+** Description This function is called from the RFCOMM layer on the flow
** control signal change. Propagate change to the user.
**
*******************************************************************************/
@@ -931,13 +944,13 @@ void PORT_FlowInd (tRFC_MCB *p_mcb, UINT8 dlci, BOOLEAN enable_data)
if (dlci == 0)
{
p_port = &rfc_cb.port.port[i];
- if (!p_port->in_use
+ if (!p_port->in_use
|| (p_port->rfc.p_mcb != p_mcb)
|| (p_port->rfc.state != RFC_STATE_OPENED))
continue;
}
events = 0;
-
+
/* Check if flow of data is still enabled */
events |= port_flow_control_user (p_port);
@@ -988,14 +1001,14 @@ UINT32 port_rfc_send_tx_data (tPORT *p_port)
RFCOMM_TRACE_DEBUG1 ("Sending RFCOMM_DataReq tx.queue_size=%d", p_port->tx.queue_size);
RFCOMM_DataReq (p_port->rfc.p_mcb, p_port->dlci, p_buf);
-
+
events |= PORT_EV_TXCHAR;
if (p_port->tx.queue_size == 0)
{
events |= PORT_EV_TXEMPTY;
break;
- }
+ }
}
/* queue is empty-- all data sent */
else
@@ -1083,9 +1096,9 @@ void port_rfc_closed (tPORT *p_port, UINT8 res)
** Function port_get_credits
**
** Description Set initial values for credits.
-** Adjust max number of rx credits based on negotiated MTU.
-** Check max allowed num of bytes, max allowed num buffers,
-** should be less then 255
+** Adjust max number of rx credits based on negotiated MTU.
+** Check max allowed num of bytes, max allowed num buffers,
+** should be less then 255
**
*******************************************************************************/
void port_get_credits (tPORT *p_port, UINT8 k)