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

Commit 5f91fe62 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "stack::l2cap Conventionally name structs without typedef" into main am: 407d2aa3

parents e7eb0aca 407d2aa3
Loading
Loading
Loading
Loading
+16 −17
Original line number Diff line number Diff line
@@ -60,16 +60,16 @@ enum class tL2CAP_DW_RESULT : uint8_t {
};

/* Values for priority parameter to L2CA_SetAclPriority */
typedef enum : uint8_t {
enum tL2CAP_PRIORITY : uint8_t {
  L2CAP_PRIORITY_NORMAL = 0,
  L2CAP_PRIORITY_HIGH = 1,
} tL2CAP_PRIORITY;
};

/* Values for priority parameter to L2CA_SetAclLatency */
typedef enum : uint8_t {
enum tL2CAP_LATENCY : uint8_t {
  L2CAP_LATENCY_NORMAL = 0,
  L2CAP_LATENCY_LOW = 1,
} tL2CAP_LATENCY;
};

/* Values for priority parameter to L2CA_SetTxPriority */
#define L2CAP_CHNL_PRIORITY_HIGH 0
@@ -115,7 +115,7 @@ typedef uint8_t tL2CAP_CHNL_DATA_RATE;
 *  Type Definitions
 ****************************************************************************/

typedef struct {
struct tL2CAP_FCR_OPTS {
#define L2CAP_FCR_BASIC_MODE 0x00
#define L2CAP_FCR_ERTM_MODE 0x03
#define L2CAP_FCR_LE_COC_MODE 0x05
@@ -127,7 +127,7 @@ typedef struct {
  uint16_t rtrans_tout;
  uint16_t mon_tout;
  uint16_t mps;
} tL2CAP_FCR_OPTS;
};

/* default options for ERTM mode */
constexpr tL2CAP_FCR_OPTS kDefaultErtmOptions = {
@@ -139,7 +139,7 @@ constexpr tL2CAP_FCR_OPTS kDefaultErtmOptions = {
    1010   /* MPS segment size */
};

typedef struct {
struct FLOW_SPEC {
  uint8_t qos_flags;          /* TBD */
  uint8_t service_type;       /* see below */
  uint32_t token_rate;        /* bytes/second */
@@ -147,7 +147,7 @@ typedef struct {
  uint32_t peak_bandwidth;    /* bytes/second */
  uint32_t latency;           /* microseconds */
  uint32_t delay_variation;   /* microseconds */
} FLOW_SPEC;
};

/* Values for service_type */
#define SVC_TYPE_BEST_EFFORT 1
@@ -157,7 +157,7 @@ typedef struct {
 * parameters are optional, for each parameter there is a boolean to
 * use to signify its presence or absence.
 */
typedef struct {
struct tL2CAP_CFG_INFO {
  uint16_t result; /* Only used in confirm messages */
  bool mtu_present;
  uint16_t mtu;
@@ -172,7 +172,7 @@ typedef struct {
  bool ext_flow_spec_present;
  tHCI_EXT_FLOW_SPEC ext_flow_spec;
  uint16_t flags; /* bit 0: 0-no continuation, 1-continuation */
} tL2CAP_CFG_INFO;
};

/* LE credit based L2CAP connection parameters */
constexpr uint16_t L2CAP_LE_MIN_MTU = 23;  // Minimum SDU size
@@ -332,7 +332,7 @@ typedef void(tL2CA_CREDIT_BASED_RECONFIG_COMPLETED_CB)(
 * MUST be provided, with the exception of the "connect pending"
 * callback and "congestion status" callback.
 */
typedef struct {
struct tL2CAP_APPL_INFO {
  tL2CA_CONNECT_IND_CB* pL2CA_ConnectInd_Cb;
  tL2CA_CONNECT_CFM_CB* pL2CA_ConnectCfm_Cb;
  tL2CA_CONFIG_IND_CB* pL2CA_ConfigInd_Cb;
@@ -348,14 +348,14 @@ typedef struct {
  tL2CA_CREDIT_BASED_RECONFIG_COMPLETED_CB*
      pL2CA_CreditBasedReconfigCompleted_Cb;
  tL2CA_CREDIT_BASED_COLLISION_IND_CB* pL2CA_CreditBasedCollisionInd_Cb;
} tL2CAP_APPL_INFO;
};

/* Define the structure that applications use to create or accept
 * connections with enhanced retransmission mode.
 */
typedef struct {
struct tL2CAP_ERTM_INFO {
  uint8_t preferred_mode;
} tL2CAP_ERTM_INFO;
};

/*****************************************************************************
 *  External Function Declarations
@@ -522,7 +522,6 @@ void L2CA_DeregisterLECoc(uint16_t psm);
 *  Return value:    true if peer is connected
 *
 ******************************************************************************/

[[nodiscard]] bool L2CA_ReconfigCreditBasedConnsReq(
    const RawAddress& bd_addr, std::vector<uint16_t>& lcids,
    tL2CAP_LE_CFG_INFO* p_cfg);
@@ -756,7 +755,7 @@ typedef void(tL2CA_FIXED_CONGESTION_STATUS_CB)(const RawAddress&, bool);

/* Fixed channel registration info (the callback addresses and channel config)
 */
typedef struct {
struct tL2CAP_FIXED_CHNL_REG {
  tL2CA_FIXED_CHNL_CB* pL2CA_FixedConn_Cb;
  tL2CA_FIXED_DATA_CB* pL2CA_FixedData_Cb;
  tL2CA_FIXED_CONGESTION_STATUS_CB* pL2CA_FixedCong_Cb;
@@ -764,7 +763,7 @@ typedef struct {
  uint16_t default_idle_tout;
  tL2CA_TX_COMPLETE_CB*
      pL2CA_FixedTxComplete_Cb; /* fixed channel tx complete callback */
} tL2CAP_FIXED_CHNL_REG;
};

/*******************************************************************************
 *
+31 −32
Original line number Diff line number Diff line
@@ -218,7 +218,7 @@ typedef enum : uint16_t {

typedef uint8_t tL2C_BLE_FIXED_CHNLS_MASK;

typedef struct {
struct tL2C_FCRB {
  uint8_t next_tx_seq;       /* Next sequence number to be Tx'ed */
  uint8_t last_rx_ack;       /* Last sequence number ack'ed by the peer */
  uint8_t next_seq_expected; /* Next peer sequence number expected */
@@ -244,10 +244,9 @@ typedef struct {

  alarm_t* ack_timer;         /* Timer delaying RR */
  alarm_t* mon_retrans_timer; /* Timer Monitor or Retransmission */
};

} tL2C_FCRB;

typedef struct {
struct tL2C_RCB {
  bool in_use;
  bool log_packets;
  uint16_t psm;
@@ -255,29 +254,31 @@ typedef struct {
                     /* this is the real PSM that we need to connect to */
  tL2CAP_APPL_INFO api;
  tL2CAP_ERTM_INFO ertm_info;
  tL2CAP_LE_CFG_INFO coc_cfg;
  tL2CAP_LE_CFG_INFO coc_cfg{};
  uint16_t my_mtu;
  uint16_t required_remote_mtu;
} tL2C_RCB;
};

#ifndef L2CAP_CBB_DEFAULT_DATA_RATE_BUFF_QUOTA
#define L2CAP_CBB_DEFAULT_DATA_RATE_BUFF_QUOTA 100
#endif

typedef struct {
struct tL2CAP_SEC_DATA {
  uint16_t psm;
  tBT_TRANSPORT transport;
  bool is_originator;
  tBTM_SEC_CALLBACK* p_callback;
  void* p_ref_data;
} tL2CAP_SEC_DATA;
};

struct tL2C_LCB;

/* Define a channel control block (CCB). There may be many channel control
 * blocks between the same two Bluetooth devices (i.e. on the same link).
 * Each CCB has unique local and remote CIDs. All channel control blocks on
 * the same physical link and are chained together.
*/
typedef struct t_l2c_ccb {
struct tL2C_CCB {
  bool in_use;                /* true when in use, false when not */
  tL2C_CHNL_STATE chnl_state; /* Channel state */
  tL2CAP_LE_CFG_INFO
@@ -288,9 +289,9 @@ typedef struct t_l2c_ccb {
                              segment or not */
  BT_HDR* ble_sdu;         /* Buffer for storing unassembled sdu*/
  uint16_t ble_sdu_length; /* Length of unassembled sdu length*/
  struct t_l2c_ccb* p_next_ccb; /* Next CCB in the chain */
  struct t_l2c_ccb* p_prev_ccb; /* Previous CCB in the chain */
  struct t_l2c_linkcb* p_lcb;   /* Link this CCB is assigned to */
  tL2C_CCB* p_next_ccb;    /* Next CCB in the chain */
  tL2C_CCB* p_prev_ccb;    /* Previous CCB in the chain */
  tL2C_LCB* p_lcb;         /* Link this CCB is assigned to */

  uint16_t local_cid;  /* Local CID */
  uint16_t remote_cid; /* Remote CID */
@@ -368,16 +369,15 @@ typedef struct t_l2c_ccb {
      } rx, tx;
    } dropped;
  } metrics;

} tL2C_CCB;
};

/***********************************************************************
 * Define a queue of linked CCBs.
*/
typedef struct {
struct tL2C_CCB_Q {
  tL2C_CCB* p_first_ccb; /* The first channel in this queue */
  tL2C_CCB* p_last_ccb;  /* The last  channel in this queue */
} tL2C_CCB_Q;
};

/* Round-Robin service for the same priority channels */
#define L2CAP_NUM_CHNL_PRIORITY \
@@ -393,14 +393,14 @@ typedef struct {
 * channel) is congested.
 */

typedef struct {
struct tL2C_RR_SERV {
  tL2C_CCB* p_serve_ccb; /* current serving ccb within priority group */
  tL2C_CCB* p_first_ccb; /* first ccb of priority group */
  uint8_t num_ccb;       /* number of channels in priority group */
  uint8_t quota;         /* burst transmission quota */
} tL2C_RR_SERV;
};

typedef enum : uint8_t {
enum tCONN_UPDATE_MASK : uint8_t {
  /* disable update connection parameters */
  L2C_BLE_CONN_UPDATE_DISABLE = (1u << 0),
  /* new connection parameter to be set */
@@ -409,12 +409,12 @@ typedef enum : uint8_t {
  L2C_BLE_UPDATE_PENDING = (1u << 2),
  /* not using default connection parameters */
  L2C_BLE_NOT_DEFAULT_PARAM = (1u << 3),
} tCONN_UPDATE_MASK;
};

/* Define a link control block. There is one link control block between
 * this device and any other device (i.e. BD ADDR).
*/
typedef struct t_l2c_linkcb {
struct tL2C_LCB {
  bool in_use; /* true when in use, false when not */
  tL2C_LINK_STATE link_state;

@@ -428,7 +428,7 @@ typedef struct t_l2c_linkcb {

 private:
  uint16_t handle_; /* The handle used with LM */
  friend void l2cu_set_lcb_handle(struct t_l2c_linkcb& p_lcb, uint16_t handle);
  friend void l2cu_set_lcb_handle(tL2C_LCB& p_lcb, uint16_t handle);
  void SetHandle(uint16_t handle) { handle_ = handle; }

 public:
@@ -577,11 +577,11 @@ typedef struct t_l2c_linkcb {
    }
    return cnt;
  }
} tL2C_LCB;
};

/* Define the L2CAP control structure
*/
typedef struct {
struct tL2C_CB {
  uint16_t controller_xmit_window; /* Total ACL window for all links */

  uint16_t round_robin_quota;   /* Round-robin link quota */
@@ -646,14 +646,13 @@ typedef struct {

  uint16_t le_dyn_psm; /* Next LE dynamic PSM value to try to assign */
  bool le_dyn_psm_assigned[LE_DYNAMIC_PSM_RANGE]; /* Table of assigned LE PSM */

} tL2C_CB;
};

/* Define a structure that contains the information about a connection.
 * This structure is used to pass between functions, and not all the
 * fields will always be filled in.
*/
typedef struct {
struct tL2C_CONN_INFO {
  RawAddress bd_addr;    /* Remote BD address */
  uint8_t status;        /* Connection status */
  uint16_t psm;          /* PSM of the connection */
@@ -662,23 +661,23 @@ typedef struct {
  uint16_t remote_cid;   /* Remote CID */
  std::vector<uint16_t> lcids; /* Used when credit based is used*/
  uint16_t peer_mtu;     /* Peer MTU */
} tL2C_CONN_INFO;
};

typedef struct {
struct tL2C_AVDT_CHANNEL_INFO {
  bool is_active;     /* is channel active */
  uint16_t local_cid; /* Remote CID */
  tL2C_CCB* p_ccb;    /* CCB */
} tL2C_AVDT_CHANNEL_INFO;
};

typedef void(tL2C_FCR_MGMT_EVT_HDLR)(uint8_t, tL2C_CCB*);

/* Necessary info for postponed TX completion callback
 */
typedef struct {
struct tL2C_TX_COMPLETE_CB_INFO {
  uint16_t local_cid;
  uint16_t num_sdu;
  tL2CA_TX_COMPLETE_CB* cb;
} tL2C_TX_COMPLETE_CB_INFO;
};

/* The offset in a buffer that L2CAP will use when building commands.
*/
+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ tL2C_LCB* l2cu_allocate_lcb(const RawAddress& p_bd_addr, bool is_bonding,
  return (NULL);
}

void l2cu_set_lcb_handle(struct t_l2c_linkcb& p_lcb, uint16_t handle) {
void l2cu_set_lcb_handle(tL2C_LCB& p_lcb, uint16_t handle) {
  if (p_lcb.Handle() != HCI_INVALID_HANDLE) {
    log::warn("Should not replace active handle:{} with new handle:{}",
              p_lcb.Handle(), handle);