15738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/****************************************************************************** 25738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 35738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Copyright (C) 2002-2012 Broadcom Corporation 45738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 55738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License"); 65738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * you may not use this file except in compliance with the License. 75738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * You may obtain a copy of the License at: 85738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 95738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0 105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Unless required by applicable law or agreed to in writing, software 125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS, 135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * See the License for the specific language governing permissions and 155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * limitations under the License. 165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ******************************************************************************/ 185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/****************************************************************************** 205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * This module contains functions for parsing and building AVDTP signaling 225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * messages. It also contains functions called by the SCB or CCB state 235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * machines for sending command, response, and reject messages. It also 245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * contains a function that processes incoming messages and dispatches them 255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * to the appropriate SCB or CCB. 265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ******************************************************************************/ 285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include <string.h> 305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "data_types.h" 315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bt_target.h" 325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "avdt_api.h" 335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "avdtc_api.h" 345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "avdt_int.h" 355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "gki.h" 365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "btu.h" 375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/***************************************************************************** 395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** constants 405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*****************************************************************************/ 415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* mask of all psc values */ 435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define AVDT_MSG_PSC_MASK (AVDT_PSC_TRANS | AVDT_PSC_REPORT | AVDT_PSC_DELAY_RPT | \ 445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_PSC_RECOV | AVDT_PSC_HDRCMP | AVDT_PSC_MUX) 455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define AVDT_PSC_PROTECT (1<<4) /* Content Protection */ 465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define AVDT_PSC_CODEC (1<<7) /* codec */ 475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/***************************************************************************** 505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** type definitions 515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*****************************************************************************/ 525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* type for message building functions */ 545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projecttypedef void (*tAVDT_MSG_BLD)(UINT8 **p, tAVDT_MSG *p_msg); 555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* type for message parsing functions */ 575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projecttypedef UINT8 (*tAVDT_MSG_PRS)(tAVDT_MSG *p_msg, UINT8 *p, UINT16 len); 585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/***************************************************************************** 615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** local function declarations 625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*****************************************************************************/ 635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void avdt_msg_bld_none(UINT8 **p, tAVDT_MSG *p_msg); 655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void avdt_msg_bld_single(UINT8 **p, tAVDT_MSG *p_msg); 665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void avdt_msg_bld_setconfig_cmd(UINT8 **p, tAVDT_MSG *p_msg); 675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void avdt_msg_bld_reconfig_cmd(UINT8 **p, tAVDT_MSG *p_msg); 685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void avdt_msg_bld_multi(UINT8 **p, tAVDT_MSG *p_msg); 695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void avdt_msg_bld_security_cmd(UINT8 **p, tAVDT_MSG *p_msg); 705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void avdt_msg_bld_discover_rsp(UINT8 **p, tAVDT_MSG *p_msg); 715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void avdt_msg_bld_svccap(UINT8 **p, tAVDT_MSG *p_msg); 725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void avdt_msg_bld_security_rsp(UINT8 **p, tAVDT_MSG *p_msg); 735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void avdt_msg_bld_all_svccap(UINT8 **p, tAVDT_MSG *p_msg); 745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void avdt_msg_bld_delay_rpt(UINT8 **p, tAVDT_MSG *p_msg); 755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_none(tAVDT_MSG *p_msg, UINT8 *p, UINT16 len); 775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_single(tAVDT_MSG *p_msg, UINT8 *p, UINT16 len); 785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_setconfig_cmd(tAVDT_MSG *p_msg, UINT8 *p, UINT16 len); 795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_reconfig_cmd(tAVDT_MSG *p_msg, UINT8 *p, UINT16 len); 805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_multi(tAVDT_MSG *p_msg, UINT8 *p, UINT16 len); 815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_security_cmd(tAVDT_MSG *p_msg, UINT8 *p, UINT16 len); 825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_discover_rsp(tAVDT_MSG *p_msg, UINT8 *p, UINT16 len); 835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_svccap(tAVDT_MSG *p_msg, UINT8 *p, UINT16 len); 845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_all_svccap(tAVDT_MSG *p_msg, UINT8 *p, UINT16 len); 855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_security_rsp(tAVDT_MSG *p_msg, UINT8 *p, UINT16 len); 865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_delay_rpt (tAVDT_MSG *p_msg, UINT8 *p, UINT16 len); 875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/***************************************************************************** 895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** constants 905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*****************************************************************************/ 915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* table of information element minimum lengths used for parsing */ 935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectconst UINT8 avdt_msg_ie_len_min[] = { 945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 0, /* unused */ 955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_LEN_TRANS_MIN, /* media transport */ 965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_LEN_REPORT_MIN, /* reporting */ 975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_LEN_RECOV_MIN, /* recovery */ 985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_LEN_PROTECT_MIN, /* content protection */ 995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_LEN_HDRCMP_MIN, /* header compression */ 1005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_LEN_MUX_MIN, /* multiplexing */ 1015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_LEN_CODEC_MIN, /* codec */ 1025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_LEN_DELAY_RPT_MIN /* delay report */ 1035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}; 1045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* table of information element minimum lengths used for parsing */ 1065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectconst UINT8 avdt_msg_ie_len_max[] = { 1075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 0, /* unused */ 1085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_LEN_TRANS_MAX, /* media transport */ 1095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_LEN_REPORT_MAX, /* reporting */ 1105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_LEN_RECOV_MAX, /* recovery */ 1115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_LEN_PROTECT_MAX, /* content protection */ 1125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_LEN_HDRCMP_MAX, /* header compression */ 1135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_LEN_MUX_MAX, /* multiplexing */ 1145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_LEN_CODEC_MAX, /* codec */ 1155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_LEN_DELAY_RPT_MAX /* delay report */ 1165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}; 1175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* table of error codes used when decoding information elements */ 1195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectconst UINT8 avdt_msg_ie_err[] = { 1205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 0, /* unused */ 1215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_ERR_MEDIA_TRANS, /* media transport */ 1225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_ERR_LENGTH, /* reporting */ 1235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_ERR_RECOV_FMT, /* recovery */ 1245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_ERR_CP_FMT, /* content protection */ 1255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_ERR_ROHC_FMT, /* header compression */ 1265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_ERR_MUX_FMT, /* multiplexing */ 1275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_ERR_SERVICE, /* codec */ 1285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_ERR_SERVICE /* delay report ?? */ 1295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}; 1305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* table of packet type minimum lengths */ 1325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic const UINT8 avdt_msg_pkt_type_len[] = { 1335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_LEN_TYPE_SINGLE, 1345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_LEN_TYPE_START, 1355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_LEN_TYPE_CONT, 1365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_LEN_TYPE_END 1375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}; 1385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* function table for building command messages */ 1405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectconst tAVDT_MSG_BLD avdt_msg_bld_cmd[] = { 1415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_none, /* discover */ 1425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_single, /* get capabilities */ 1435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_setconfig_cmd, /* set configuration */ 1445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_single, /* get configuration */ 1455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_reconfig_cmd, /* reconfigure */ 1465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_single, /* open */ 1475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_multi, /* start */ 1485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_single, /* close */ 1495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_multi, /* suspend */ 1505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_single, /* abort */ 1515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_security_cmd, /* security control */ 1525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_single, /* get all capabilities */ 1535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_delay_rpt /* delay report */ 1545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}; 1555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* function table for building response messages */ 1575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectconst tAVDT_MSG_BLD avdt_msg_bld_rsp[] = { 1585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_discover_rsp, /* discover */ 1595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_svccap, /* get capabilities */ 1605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_none, /* set configuration */ 1615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_all_svccap, /* get configuration */ 1625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_none, /* reconfigure */ 1635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_none, /* open */ 1645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_none, /* start */ 1655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_none, /* close */ 1665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_none, /* suspend */ 1675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_none, /* abort */ 1685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_security_rsp, /* security control */ 1695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_all_svccap, /* get all capabilities */ 1705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_none /* delay report */ 1715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}; 1725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* function table for parsing command messages */ 1745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectconst tAVDT_MSG_PRS avdt_msg_prs_cmd[] = { 1755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_none, /* discover */ 1765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_single, /* get capabilities */ 1775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_setconfig_cmd, /* set configuration */ 1785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_single, /* get configuration */ 1795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_reconfig_cmd, /* reconfigure */ 1805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_single, /* open */ 1815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_multi, /* start */ 1825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_single, /* close */ 1835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_multi, /* suspend */ 1845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_single, /* abort */ 1855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_security_cmd, /* security control */ 1865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_single, /* get all capabilities */ 1875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_delay_rpt /* delay report */ 1885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}; 1895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* function table for parsing response messages */ 1915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectconst tAVDT_MSG_PRS avdt_msg_prs_rsp[] = { 1925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_discover_rsp, /* discover */ 1935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_svccap, /* get capabilities */ 1945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_none, /* set configuration */ 1955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_all_svccap, /* get configuration */ 1965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_none, /* reconfigure */ 1975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_none, /* open */ 1985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_none, /* start */ 1995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_none, /* close */ 2005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_none, /* suspend */ 2015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_none, /* abort */ 2025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_security_rsp, /* security control */ 2035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_all_svccap, /* get all capabilities */ 2045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_prs_none /* delay report */ 2055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}; 2065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* command message-to-event lookup table */ 2085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectconst UINT8 avdt_msg_cmd_2_evt[] = { 2095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_CCB_MSG_DISCOVER_CMD_EVT + AVDT_CCB_MKR, /* discover */ 2105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_CCB_MSG_GETCAP_CMD_EVT + AVDT_CCB_MKR, /* get capabilities */ 2115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_SCB_MSG_SETCONFIG_CMD_EVT, /* set configuration */ 2125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_SCB_MSG_GETCONFIG_CMD_EVT, /* get configuration */ 2135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_SCB_MSG_RECONFIG_CMD_EVT, /* reconfigure */ 2145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_SCB_MSG_OPEN_CMD_EVT, /* open */ 2155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_CCB_MSG_START_CMD_EVT + AVDT_CCB_MKR, /* start */ 2165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_SCB_MSG_CLOSE_CMD_EVT, /* close */ 2175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_CCB_MSG_SUSPEND_CMD_EVT + AVDT_CCB_MKR, /* suspend */ 2185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_SCB_MSG_ABORT_CMD_EVT, /* abort */ 2195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_SCB_MSG_SECURITY_CMD_EVT, /* security control */ 2205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_CCB_MSG_GETCAP_CMD_EVT + AVDT_CCB_MKR, /* get all capabilities */ 2215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_SCB_MSG_DELAY_RPT_CMD_EVT /* delay report */ 2225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}; 2235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* response message-to-event lookup table */ 2255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectconst UINT8 avdt_msg_rsp_2_evt[] = { 2265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_CCB_MSG_DISCOVER_RSP_EVT + AVDT_CCB_MKR, /* discover */ 2275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_CCB_MSG_GETCAP_RSP_EVT + AVDT_CCB_MKR, /* get capabilities */ 2285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_SCB_MSG_SETCONFIG_RSP_EVT, /* set configuration */ 2295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_SCB_MSG_GETCONFIG_RSP_EVT, /* get configuration */ 2305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_SCB_MSG_RECONFIG_RSP_EVT, /* reconfigure */ 2315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_SCB_MSG_OPEN_RSP_EVT, /* open */ 2325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_CCB_MSG_START_RSP_EVT + AVDT_CCB_MKR, /* start */ 2335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_SCB_MSG_CLOSE_RSP_EVT, /* close */ 2345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_CCB_MSG_SUSPEND_RSP_EVT + AVDT_CCB_MKR, /* suspend */ 2355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_SCB_MSG_ABORT_RSP_EVT, /* abort */ 2365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_SCB_MSG_SECURITY_RSP_EVT, /* security control */ 2375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_CCB_MSG_GETCAP_RSP_EVT + AVDT_CCB_MKR, /* get all capabilities */ 2385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_SCB_MSG_DELAY_RPT_RSP_EVT /* delay report */ 2395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}; 2405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* reject message-to-event lookup table */ 2425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectconst UINT8 avdt_msg_rej_2_evt[] = { 2435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_CCB_MSG_DISCOVER_RSP_EVT + AVDT_CCB_MKR, /* discover */ 2445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_CCB_MSG_GETCAP_RSP_EVT + AVDT_CCB_MKR, /* get capabilities */ 2455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_SCB_MSG_SETCONFIG_REJ_EVT, /* set configuration */ 2465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_SCB_MSG_GETCONFIG_RSP_EVT, /* get configuration */ 2475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_SCB_MSG_RECONFIG_RSP_EVT, /* reconfigure */ 2485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_SCB_MSG_OPEN_REJ_EVT, /* open */ 2495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_CCB_MSG_START_RSP_EVT + AVDT_CCB_MKR, /* start */ 2505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_SCB_MSG_CLOSE_RSP_EVT, /* close */ 2515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_CCB_MSG_SUSPEND_RSP_EVT + AVDT_CCB_MKR, /* suspend */ 2525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_SCB_MSG_ABORT_RSP_EVT, /* abort */ 2535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_SCB_MSG_SECURITY_RSP_EVT, /* security control */ 2545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_CCB_MSG_GETCAP_RSP_EVT + AVDT_CCB_MKR, /* get all capabilities */ 2555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 0 /* delay report */ 2565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}; 2575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 2595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_bld_cfg 2615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This function builds the configuration parameters contained 2635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** in a command or response message. 2645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void. 2675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 2695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void avdt_msg_bld_cfg(UINT8 **p, tAVDT_CFG *p_cfg) 2705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 2715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 len; 2725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* for now, just build media transport, codec, and content protection, and multiplexing */ 2745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* media transport */ 2765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_cfg->psc_mask & AVDT_PSC_TRANS) 2775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(*p)++ = AVDT_CAT_TRANS; 2795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(*p)++ = 0; /* length */ 2805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if AVDT_REPORTING == TRUE 2835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* reporting transport */ 2845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_cfg->psc_mask & AVDT_PSC_REPORT) 2855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(*p)++ = AVDT_CAT_REPORT; 2875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(*p)++ = 0; /* length */ 2885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 2905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* codec */ 2925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_cfg->num_codec != 0) 2935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(*p)++ = AVDT_CAT_CODEC; 2955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project len = p_cfg->codec_info[0] + 1; 2965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if( len > AVDT_CODEC_SIZE ) 2975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project len = AVDT_CODEC_SIZE; 2985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(*p, p_cfg->codec_info, len); 3005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *p += len; 3015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* content protection */ 3045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_cfg->num_protect != 0) 3055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(*p)++ = AVDT_CAT_PROTECT; 3075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project len = p_cfg->protect_info[0] + 1; 3085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if( len > AVDT_PROTECT_SIZE ) 3095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project len = AVDT_PROTECT_SIZE; 3105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(*p, p_cfg->protect_info, len); 3125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *p += len; 3135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if AVDT_MULTIPLEXING == TRUE 3165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* multiplexing */ 3175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_cfg->psc_mask & AVDT_PSC_MUX) 3185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(*p)++ = AVDT_CAT_MUX; 3205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* length */ 3215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_cfg->psc_mask & AVDT_PSC_RECOV) 3225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(*p)++ = 7; /* frag (1) + media + report + recovery */ 3235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if (p_cfg->psc_mask & AVDT_PSC_REPORT) 3245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(*p)++ = 5; /* frag (1) + media + report */ 3255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 3265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(*p)++ = 3; /* frag (1) + media */ 3275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* allow fragmentation */ 3295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_cfg->mux_mask & AVDT_MUX_FRAG) 3305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(*p)++ = 0x80; 3315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 3325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(*p)++ = 0; 3335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* media transport session */ 3355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(*p)++ = p_cfg->mux_tsid_media<<3; /* TSID */ 3365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(*p)++ = p_cfg->mux_tcid_media<<3; /* TCID */ 3375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_cfg->psc_mask & AVDT_PSC_RECOV) 3395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* reporting transport session */ 3415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(*p)++ = p_cfg->mux_tsid_report<<3; /* TSID */ 3425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(*p)++ = p_cfg->mux_tcid_report<<3; /* TCID */ 3435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* recovery transport session */ 3445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(*p)++ = p_cfg->mux_tsid_recov<<3; /* TSID */ 3455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(*p)++ = p_cfg->mux_tcid_recov<<3; /* TCID */ 3465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if (p_cfg->psc_mask & AVDT_PSC_REPORT) 3485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* reporting transport session */ 3505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(*p)++ = p_cfg->mux_tsid_report<<3; /* TSID */ 3515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(*p)++ = p_cfg->mux_tcid_report<<3; /* TCID */ 3525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 3555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* delay report */ 3575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_cfg->psc_mask & AVDT_PSC_DELAY_RPT) 3585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(*p)++ = AVDT_CAT_DELAY_RPT; 3605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(*p)++ = 0; /* length */ 3615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 3655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_bld_none 3675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This message building function builds an empty message. 3695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void. 3725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 3745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void avdt_msg_bld_none(UINT8 **p, tAVDT_MSG *p_msg) 3755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 3765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return; 3775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 3805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_bld_single 3825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This message building function builds a message containing 3845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** a single SEID. 3855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void. 3885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 3905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void avdt_msg_bld_single(UINT8 **p, tAVDT_MSG *p_msg) 3915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 3925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_BLD_SEID(*p, p_msg->single.seid); 3935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 3965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_bld_setconfig_cmd 3985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This message building function builds a set configuration 4005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** command message. 4015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void. 4045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 4065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void avdt_msg_bld_setconfig_cmd(UINT8 **p, tAVDT_MSG *p_msg) 4075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 4085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_BLD_SEID(*p, p_msg->config_cmd.hdr.seid); 4095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_BLD_SEID(*p, p_msg->config_cmd.int_seid); 4105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_cfg(p, p_msg->config_cmd.p_cfg); 4115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 4125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 4145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_bld_reconfig_cmd 4165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This message building function builds a reconfiguration 4185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** command message. 4195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void. 4225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 4245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void avdt_msg_bld_reconfig_cmd(UINT8 **p, tAVDT_MSG *p_msg) 4255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 4265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_BLD_SEID(*p, p_msg->reconfig_cmd.hdr.seid); 4275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* force psc mask zero to build only codec and security */ 4295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->reconfig_cmd.p_cfg->psc_mask = 0; 4305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_cfg(p, p_msg->reconfig_cmd.p_cfg); 4315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 4325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 4345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_bld_multi 4365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This message building function builds a message containing 4385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** multiple SEID's. 4395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void. 4425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 4445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void avdt_msg_bld_multi(UINT8 **p, tAVDT_MSG *p_msg) 4455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 4465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project int i; 4475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for (i = 0; i < p_msg->multi.num_seps; i++) 4495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 4505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_BLD_SEID(*p, p_msg->multi.seid_list[i]); 4515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 4525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 4535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 4555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_bld_security_cmd 4575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This message building function builds a security 4595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** command message. 4605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void. 4625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 4645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void avdt_msg_bld_security_cmd(UINT8 **p, tAVDT_MSG *p_msg) 4655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 4665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_BLD_SEID(*p, p_msg->security_cmd.hdr.seid); 4675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(*p, p_msg->security_cmd.p_data, p_msg->security_cmd.len); 4685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *p += p_msg->security_cmd.len; 4695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 4705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 4725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_bld_delay_rpt 4745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This message building function builds a delay report 4765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** command message. 4775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void. 4795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 4815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void avdt_msg_bld_delay_rpt(UINT8 **p, tAVDT_MSG *p_msg) 4825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 4835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_BLD_SEID(*p, p_msg->delay_rpt_cmd.hdr.seid); 4845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16_TO_BE_STREAM(*p, p_msg->delay_rpt_cmd.delay); 4855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 4865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 4885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_bld_discover_rsp 4905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This message building function builds a discover 4925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** response message. 4935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void. 4965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 4985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void avdt_msg_bld_discover_rsp(UINT8 **p, tAVDT_MSG *p_msg) 4995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 5005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project int i; 5015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for (i = 0; i < p_msg->discover_rsp.num_seps; i++) 5035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 5045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* build discover rsp info */ 5055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_BLD_DISC(*p, p_msg->discover_rsp.p_sep_info[i].seid, 5065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->discover_rsp.p_sep_info[i].in_use, 5075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->discover_rsp.p_sep_info[i].media_type, 5085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->discover_rsp.p_sep_info[i].tsep); 5095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 5105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 5115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 5135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_bld_svccap 5155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This message building function builds a message containing 5175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** service capabilities parameters. 5185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void. 5215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 5235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void avdt_msg_bld_svccap(UINT8 **p, tAVDT_MSG *p_msg) 5245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 5255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tAVDT_CFG cfg; 5265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* make sure the delay report category is not reported */ 5285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy (&cfg, p_msg->svccap.p_cfg, sizeof(tAVDT_CFG)); 5295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project cfg.psc_mask &= ~AVDT_PSC_DELAY_RPT; 5305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_cfg(p, &cfg); 5315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 5325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 5345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_bld_all_svccap 5365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This message building function builds a message containing 5385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** service capabilities parameters. 5395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void. 5425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 5445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void avdt_msg_bld_all_svccap(UINT8 **p, tAVDT_MSG *p_msg) 5455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 5465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_bld_cfg(p, p_msg->svccap.p_cfg); 5475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 5485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 5505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_bld_security_rsp 5525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This message building function builds a security 5545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** response message. 5555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void. 5585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 5605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void avdt_msg_bld_security_rsp(UINT8 **p, tAVDT_MSG *p_msg) 5615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 5625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(*p, p_msg->security_rsp.p_data, p_msg->security_rsp.len); 5635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *p += p_msg->security_rsp.len; 5645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 5655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 5675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_prs_cfg 5695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This message parsing function parses the configuration 5715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** parameters field of a message. 5725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns Error code or zero if no error, and element that failed 5755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** in p_elem. 5765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 5785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_cfg(tAVDT_CFG *p_cfg, UINT8 *p, UINT16 len, UINT8* p_elem, UINT8 sig_id) 5795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 5805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p_end; 5815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 elem = 0; 5825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 elem_len; 5835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 tmp; 5845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 err = 0; 5855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 protect_offset = 0; 5865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (!p_cfg) 5885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 5895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_TRACE_ERROR0 ("not expecting this cfg"); 5905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return AVDT_ERR_BAD_STATE; 5915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 5925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cfg->psc_mask = 0; 5945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cfg->num_codec = 0; 5955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cfg->num_protect = 0; 5965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if AVDT_MULTIPLEXING == TRUE 5975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cfg->mux_mask = 0; 5985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 5995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* while there is still data to parse */ 6015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_end = p + len; 6025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project while ((p < p_end) && (err == 0)) 6035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 6045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* verify overall length */ 6055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_end - p) < AVDT_LEN_CFG_MIN) 6065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 6075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = AVDT_ERR_PAYLOAD; 6085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 6095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 6105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* get and verify info elem id, length */ 6125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project elem = *p++; 6135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project elem_len = *p++; 6145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((elem == 0) || (elem > AVDT_CAT_MAX_CUR)) 6165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 6175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* this may not be really bad. 6185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * It may be a service category that is too new for us. 6195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * allow these to be parsed without reporting an error. 6205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * If this is a "capability" (as in GetCapRsp & GetConfigRsp), this is filtered out. 6215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * If this is a Configuration (as in SetConfigCmd & ReconfigCmd), 6225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * this will be marked as an error in the caller of this function */ 6235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((sig_id == AVDT_SIG_SETCONFIG) || (sig_id == AVDT_SIG_RECONFIG)) 6245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 6255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Cannot accept unknown category. */ 6265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = AVDT_ERR_CATEGORY; 6275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 6285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 6295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else /* GETCAP or GET_ALLCAP */ 6305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 6315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Skip unknown categories. */ 6325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p += elem_len; 6335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_TRACE_DEBUG2("skipping unknown service category=%d len: %d", elem, elem_len); 6345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project continue; 6355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 6365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 6375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((elem_len > avdt_msg_ie_len_max[elem]) || 6395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (elem_len < avdt_msg_ie_len_min[elem])) 6405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 6415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = avdt_msg_ie_err[elem]; 6425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 6435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 6445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* add element to psc mask, but mask out codec or protect */ 6465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cfg->psc_mask |= (1 << elem); 6475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_TRACE_DEBUG3("elem=%d elem_len: %d psc_mask=0x%x", elem, elem_len, p_cfg->psc_mask); 6485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* parse individual information elements with additional parameters */ 6505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project switch (elem) 6515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 6525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case AVDT_CAT_RECOV: 6535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cfg->recov_type = *p++; 6545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cfg->recov_mrws = *p++; 6555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cfg->recov_mnmp = *p++; 6565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_cfg->recov_type != AVDT_RECOV_RFC2733) 6575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 6585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = AVDT_ERR_RECOV_TYPE; 6595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 6605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if ((p_cfg->recov_mrws < AVDT_RECOV_MRWS_MIN) || 6615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (p_cfg->recov_mrws > AVDT_RECOV_MRWS_MAX) || 6625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (p_cfg->recov_mnmp < AVDT_RECOV_MNMP_MIN) || 6635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (p_cfg->recov_mnmp > AVDT_RECOV_MNMP_MAX)) 6645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 6655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = AVDT_ERR_RECOV_FMT; 6665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 6675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 6685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case AVDT_CAT_PROTECT: 6705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cfg->psc_mask &= ~AVDT_PSC_PROTECT; 6715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((elem_len + protect_offset) < AVDT_PROTECT_SIZE) 6725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 6735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cfg->num_protect++; 6745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cfg->protect_info[protect_offset] = elem_len; 6755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project protect_offset++; 6765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(&p_cfg->protect_info[protect_offset], p, elem_len); 6775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project protect_offset += elem_len; 6785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 6795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p += elem_len; 6805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 6815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case AVDT_CAT_HDRCMP: 6835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cfg->hdrcmp_mask = *p++; 6845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 6855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if AVDT_MULTIPLEXING == TRUE 6875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case AVDT_CAT_MUX: 6885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* verify length */ 6895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_TRACE_WARNING2("psc_mask=0x%x elem_len=%d", p_cfg->psc_mask, elem_len); 6905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if( ((0 == (p_cfg->psc_mask & (AVDT_PSC_RECOV|AVDT_PSC_REPORT))) && (elem_len != 3)) 6915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project || ((p_cfg->psc_mask & AVDT_PSC_RECOV) && (elem_len != 7)) 6925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project || ((p_cfg->psc_mask & AVDT_PSC_REPORT) && (elem_len != 5)) ) 6935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 6945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = AVDT_ERR_MUX_FMT; 6955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 6965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 6975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* parse fragmentation */ 6995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cfg->mux_mask = *p++ & (UINT8)AVDT_MUX_FRAG; 7005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* parse TSIDs and TCIDs */ 7025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(--elem_len) 7035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cfg->mux_tsid_media = (*p++)>>3; 7045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 7055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 7065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(--elem_len) 7085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cfg->mux_tcid_media = (*p++)>>3; 7095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 7105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 7115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(--elem_len) 7135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cfg->mux_tsid_report = (*p++)>>3; 7145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 7155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 7165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(--elem_len) 7185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cfg->mux_tcid_report = (*p++)>>3; 7195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 7205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 7215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(--elem_len) 7235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cfg->mux_tsid_recov = (*p++)>>3; 7245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 7255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 7265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(--elem_len) 7285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cfg->mux_tcid_recov = (*p++)>>3; 7295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 7305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 7315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 7325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 7335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case AVDT_CAT_CODEC: 7355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cfg->psc_mask &= ~AVDT_PSC_CODEC; 7365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tmp = elem_len; 7375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (elem_len >= AVDT_CODEC_SIZE) 7385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 7395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tmp = AVDT_CODEC_SIZE - 1; 7405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cfg->num_codec++; 7425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cfg->codec_info[0] = elem_len; 7435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(&p_cfg->codec_info[1], p, tmp); 7445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p += elem_len; 7455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 7465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case AVDT_CAT_DELAY_RPT: 7485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 7495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project default: 7515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p += elem_len; 7525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 7535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } /* switch */ 7545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } /* while ! err, !end*/ 7555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *p_elem = elem; 7565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_TRACE_DEBUG3("err=0x%x, elem:0x%x psc_mask=0x%x", err, elem, p_cfg->psc_mask); 7575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return err; 7595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 7605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 7625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_prs_none 7645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This message parsing function parses a message with no parameters. 7665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns Error code or zero if no error. 7705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 7725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_none(tAVDT_MSG *p_msg, UINT8 *p, UINT16 len) 7735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 7745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return 0; 7755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 7765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 7785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_prs_single 7805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This message parsing function parses a message with a 7825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** single SEID. 7835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns Error code or zero if no error. 7865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 7885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_single(tAVDT_MSG *p_msg, UINT8 *p, UINT16 len) 7895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 7905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 err = 0; 7915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* verify len */ 7935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (len != AVDT_LEN_SINGLE) 7945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 7955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = AVDT_ERR_LENGTH; 7965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 7985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 7995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_PRS_SEID(p, p_msg->single.seid); 8005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (avdt_scb_by_hdl(p_msg->single.seid) == NULL) 8025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = AVDT_ERR_SEID; 8045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return err; 8075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 8085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 8105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 8115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_prs_setconfig_cmd 8125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 8135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This message parsing function parses a set configuration 8145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** command message. 8155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 8165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 8175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns Error code or zero if no error. 8185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 8195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 8205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_setconfig_cmd(tAVDT_MSG *p_msg, UINT8 *p, UINT16 len) 8215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 8225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 err = 0; 8235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->hdr.err_param = 0; 8255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* verify len */ 8275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (len < AVDT_LEN_SETCONFIG_MIN) 8285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = AVDT_ERR_LENGTH; 8305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 8325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* get seids */ 8345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_PRS_SEID(p, p_msg->config_cmd.hdr.seid); 8355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (avdt_scb_by_hdl(p_msg->config_cmd.hdr.seid) == NULL) 8365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = AVDT_ERR_SEID; 8385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_PRS_SEID(p, p_msg->config_cmd.int_seid); 8415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_msg->config_cmd.int_seid < AVDT_SEID_MIN) || 8425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (p_msg->config_cmd.int_seid > AVDT_SEID_MAX)) 8435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = AVDT_ERR_SEID; 8455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (!err) 8495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* parse configuration parameters */ 8515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project len -= 2; 8525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = avdt_msg_prs_cfg(p_msg->config_cmd.p_cfg, p, len, &p_msg->hdr.err_param, AVDT_SIG_SETCONFIG); 8535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (!err) 8555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* verify protocol service capabilities are supported */ 8575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (((p_msg->config_cmd.p_cfg->psc_mask & (~AVDT_PSC)) != 0) || 8585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (p_msg->config_cmd.p_cfg->num_codec == 0)) 8595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = AVDT_ERR_INVALID_CAP; 8615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return err; 8665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 8675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 8695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 8705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_prs_reconfig_cmd 8715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 8725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This message parsing function parses a reconfiguration 8735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** command message. 8745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 8755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 8765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns Error code or zero if no error. 8775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 8785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 8795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_reconfig_cmd(tAVDT_MSG *p_msg, UINT8 *p, UINT16 len) 8805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 8815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 err = 0; 8825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->hdr.err_param = 0; 8845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* verify len */ 8865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (len < AVDT_LEN_RECONFIG_MIN) 8875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = AVDT_ERR_LENGTH; 8895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 8915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* get seid */ 8935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_PRS_SEID(p, p_msg->reconfig_cmd.hdr.seid); 8945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (avdt_scb_by_hdl(p_msg->reconfig_cmd.hdr.seid) == NULL) 8955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = AVDT_ERR_SEID; 8975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 8995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* parse config parameters */ 9015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project len--; 9025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = avdt_msg_prs_cfg(p_msg->config_cmd.p_cfg, p, len, &p_msg->hdr.err_param, AVDT_SIG_RECONFIG); 9035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* verify no protocol service capabilities in parameters */ 9055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (!err) 9065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_TRACE_DEBUG2("avdt_msg_prs_reconfig_cmd psc_mask=0x%x/0x%x", p_msg->config_cmd.p_cfg->psc_mask, AVDT_MSG_PSC_MASK); 9085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_msg->config_cmd.p_cfg->psc_mask != 0) || 9095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (p_msg->config_cmd.p_cfg->num_codec == 0 && p_msg->config_cmd.p_cfg->num_protect == 0)) 9105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = AVDT_ERR_INVALID_CAP; 9125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return err; 9175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 9185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 9205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 9215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_prs_multi 9225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 9235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This message parsing function parses a message containing 9245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** multiple SEID's. 9255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 9265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 9275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns Error code or zero if no error. 9285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 9295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 9305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_multi(tAVDT_MSG *p_msg, UINT8 *p, UINT16 len) 9315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 9325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project int i; 9335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 err = 0; 9345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->hdr.err_param = 0; 9365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* verify len */ 9385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (len < AVDT_LEN_MULTI_MIN || (len > AVDT_NUM_SEPS)) 9395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = AVDT_ERR_LENGTH; 9415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 9435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* get and verify all seps */ 9455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for (i = 0; i < len; i++) 9465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_PRS_SEID(p, p_msg->multi.seid_list[i]); 9485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (avdt_scb_by_hdl(p_msg->multi.seid_list[i]) == NULL) 9495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = AVDT_ERR_SEID; 9515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->hdr.err_param = p_msg->multi.seid_list[i]; 9525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 9535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->multi.num_seps = (UINT8)i; 9565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return err; 9595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 9605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 9625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 9635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_prs_security_cmd 9645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 9655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This message parsing function parses a security 9665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** command message. 9675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 9685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 9695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns Error code or zero if no error. 9705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 9715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 9725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_security_cmd(tAVDT_MSG *p_msg, UINT8 *p, UINT16 len) 9735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 9745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 err = 0; 9755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* verify len */ 9775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (len < AVDT_LEN_SECURITY_MIN) 9785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = AVDT_ERR_LENGTH; 9805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 9825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* get seid */ 9845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_PRS_SEID(p, p_msg->security_cmd.hdr.seid); 9855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (avdt_scb_by_hdl(p_msg->security_cmd.hdr.seid) == NULL) 9865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = AVDT_ERR_SEID; 9885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 9905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->security_cmd.p_data = p; 9925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->security_cmd.len = len - 1; 9935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return err; 9965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 9975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 9995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_prs_discover_rsp 10015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This message parsing function parses a discover 10035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** response message. 10045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns Error code or zero if no error. 10075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 10095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_discover_rsp(tAVDT_MSG *p_msg, UINT8 *p, UINT16 len) 10105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 10115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project int i; 10125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 err = 0; 10135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* determine number of seps; seps in msg is len/2, but set to minimum 10155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** of seps app has supplied memory for and seps in msg 10165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project */ 10175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_msg->discover_rsp.num_seps > (len / 2)) 10185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 10195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->discover_rsp.num_seps = (len / 2); 10205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 10215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* parse out sep info */ 10235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for (i = 0; i < p_msg->discover_rsp.num_seps; i++) 10245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 10255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* parse discover rsp info */ 10265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_PRS_DISC(p, p_msg->discover_rsp.p_sep_info[i].seid, 10275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->discover_rsp.p_sep_info[i].in_use, 10285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->discover_rsp.p_sep_info[i].media_type, 10295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->discover_rsp.p_sep_info[i].tsep); 10305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* verify that seid is valid */ 10325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_msg->discover_rsp.p_sep_info[i].seid < AVDT_SEID_MIN) || 10335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (p_msg->discover_rsp.p_sep_info[i].seid > AVDT_SEID_MAX)) 10345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 10355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = AVDT_ERR_SEID; 10365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 10375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 10385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 10395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return err; 10415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 10425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 10445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_prs_svccap 10465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This message parsing function parses a message containing 10485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** service capabilities parameters. 10495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns Error code or zero if no error. 10525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 10545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_svccap(tAVDT_MSG *p_msg, UINT8 *p, UINT16 len) 10555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 10565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* parse parameters */ 10575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 err = avdt_msg_prs_cfg(p_msg->svccap.p_cfg, p, len, &p_msg->hdr.err_param, AVDT_SIG_GETCAP); 10585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_msg->svccap.p_cfg) 10595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 10605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->svccap.p_cfg->psc_mask &= AVDT_LEG_PSC; 10615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 10625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return (err); 10645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 10655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 10675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_prs_all_svccap 10695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This message parsing function parses a message containing 10715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** service capabilities parameters. 10725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns Error code or zero if no error. 10755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 10775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_all_svccap(tAVDT_MSG *p_msg, UINT8 *p, UINT16 len) 10785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 10795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 err = avdt_msg_prs_cfg(p_msg->svccap.p_cfg, p, len, &p_msg->hdr.err_param, AVDT_SIG_GET_ALLCAP); 10805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_msg->svccap.p_cfg) 10815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 10825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->svccap.p_cfg->psc_mask &= AVDT_MSG_PSC_MASK; 10835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 10845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return (err); 10855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 10865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 10885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_prs_security_rsp 10905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This message parsing function parsing a security 10925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** response message. 10935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns Error code or zero if no error. 10965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 10985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_security_rsp(tAVDT_MSG *p_msg, UINT8 *p, UINT16 len) 10995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 11005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->security_rsp.p_data = p; 11015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->security_rsp.len = len; 11025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return 0; 11045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 11055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 11075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 11085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_prs_rej 11095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 11105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description 11115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 11125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 11135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns Error code or zero if no error. 11145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 11155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 11165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_rej(tAVDT_MSG *p_msg, UINT8 *p, UINT8 sig) 11175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 11185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((sig == AVDT_SIG_SETCONFIG) || (sig == AVDT_SIG_RECONFIG)) 11195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->hdr.err_param = *p++; 11215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->hdr.err_code = *p; 11225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if ((sig == AVDT_SIG_START) || (sig == AVDT_SIG_SUSPEND)) 11245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_PRS_SEID(p, p_msg->hdr.err_param); 11265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->hdr.err_code = *p; 11275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 11295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->hdr.err_code = *p; 11315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return 0; 11345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 11355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 11375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 11385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_prs_delay_rpt 11395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 11405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This message parsing function parses a security 11415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** command message. 11425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 11435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 11445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns Error code or zero if no error. 11455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 11465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 11475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 avdt_msg_prs_delay_rpt (tAVDT_MSG *p_msg, UINT8 *p, UINT16 len) 11485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 11495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 err = 0; 11505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* verify len */ 11525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (len != AVDT_LEN_DELAY_RPT) 11535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_TRACE_WARNING2("avdt_msg_prs_delay_rpt expected len: %u got: %u", AVDT_LEN_DELAY_RPT, len); 11555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = AVDT_ERR_LENGTH; 11565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 11585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* get seid */ 11605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_PRS_SEID (p, p_msg->delay_rpt_cmd.hdr.seid); 11615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (avdt_scb_by_hdl(p_msg->delay_rpt_cmd.hdr.seid) == NULL) 11635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = AVDT_ERR_SEID; 11655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 11675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BE_STREAM_TO_UINT16 (p_msg->delay_rpt_cmd.delay, p); 11695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_TRACE_DEBUG1("avdt_msg_prs_delay_rpt delay: %u", p_msg->delay_rpt_cmd.delay); 11705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return err; 11735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 11745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 11775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 11785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_send 11795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 11805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Send, and if necessary fragment the next message. 11815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 11825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 11835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns Congested state; TRUE if CCB congested, FALSE if not. 11845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 11855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 11865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjectBOOLEAN avdt_msg_send(tAVDT_CCB *p_ccb, BT_HDR *p_msg) 11875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 11885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 curr_msg_len; 11895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 pkt_type; 11905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 hdr_len; 11915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tAVDT_TC_TBL *p_tbl; 11925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_buf; 11935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p; 11945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 label; 11955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 msg; 11965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 sig; 11975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 nosp = 0; /* number of subsequent packets */ 11985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* look up transport channel table entry to get peer mtu */ 12005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_tbl = avdt_ad_tc_tbl_by_type(AVDT_CHAN_SIG, p_ccb, NULL); 12015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* set the current message if there is a message passed in */ 12035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_msg != NULL) 12045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ccb->p_curr_msg = p_msg; 12065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* store copy of curr_msg->len */ 12095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project curr_msg_len = p_ccb->p_curr_msg->len; 12105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* while not congested and we haven't sent it all */ 12125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project while ((!p_ccb->cong) && (p_ccb->p_curr_msg != NULL)) 12135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* check what kind of message we've got here; we are using the offset 12155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** to indicate that a message is being fragmented 12165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project */ 12175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if message isn't being fragmented and it fits in mtu */ 12195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_ccb->p_curr_msg->offset == AVDT_MSG_OFFSET) && 12205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (p_ccb->p_curr_msg->len <= p_tbl->peer_mtu - AVDT_LEN_TYPE_SINGLE)) 12215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pkt_type = AVDT_PKT_TYPE_SINGLE; 12235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project hdr_len = AVDT_LEN_TYPE_SINGLE; 12245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf = p_ccb->p_curr_msg; 12255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if message isn't being fragmented and it doesn't fit in mtu */ 12275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if ((p_ccb->p_curr_msg->offset == AVDT_MSG_OFFSET) && 12285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (p_ccb->p_curr_msg->len > p_tbl->peer_mtu - AVDT_LEN_TYPE_SINGLE)) 12295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pkt_type = AVDT_PKT_TYPE_START; 12315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project hdr_len = AVDT_LEN_TYPE_START; 12325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project nosp = (p_ccb->p_curr_msg->len + AVDT_LEN_TYPE_START - p_tbl->peer_mtu) / 12335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (p_tbl->peer_mtu - 1) + 2; 12345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* get a new buffer for fragment we are sending */ 12365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID)) == NULL) 12375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* do we even want to try and recover from this? could do so 12395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project by setting retransmission timer */ 12405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return TRUE; 12415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* copy portion of data from current message to new buffer */ 12445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->offset = L2CAP_MIN_OFFSET + hdr_len; 12455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->len = p_tbl->peer_mtu - hdr_len; 12465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy((UINT8 *)(p_buf + 1) + p_buf->offset, 12475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (UINT8 *)(p_ccb->p_curr_msg + 1) + p_ccb->p_curr_msg->offset, p_buf->len); 12485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if message is being fragmented and remaining bytes don't fit in mtu */ 12505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if ((p_ccb->p_curr_msg->offset > AVDT_MSG_OFFSET) && 12515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (p_ccb->p_curr_msg->len > (p_tbl->peer_mtu - AVDT_LEN_TYPE_CONT))) 12525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pkt_type = AVDT_PKT_TYPE_CONT; 12545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project hdr_len = AVDT_LEN_TYPE_CONT; 12555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* get a new buffer for fragment we are sending */ 12575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID)) == NULL) 12585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* do we even want to try and recover from this? could do so 12605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project by setting retransmission timer */ 12615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return TRUE; 12625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* copy portion of data from current message to new buffer */ 12655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->offset = L2CAP_MIN_OFFSET + hdr_len; 12665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->len = p_tbl->peer_mtu - hdr_len; 12675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy((UINT8 *)(p_buf + 1) + p_buf->offset, 12685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (UINT8 *)(p_ccb->p_curr_msg + 1) + p_ccb->p_curr_msg->offset, p_buf->len); 12695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if message is being fragmented and remaining bytes do fit in mtu */ 12715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 12725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pkt_type = AVDT_PKT_TYPE_END; 12745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project hdr_len = AVDT_LEN_TYPE_END; 12755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf = p_ccb->p_curr_msg; 12765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* label, sig id, msg type are in hdr of p_curr_msg */ 12795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project label = AVDT_LAYERSPEC_LABEL(p_ccb->p_curr_msg->layer_specific); 12805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project msg = AVDT_LAYERSPEC_MSG(p_ccb->p_curr_msg->layer_specific); 12815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project sig = (UINT8) p_ccb->p_curr_msg->event; 12825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_TRACE_DEBUG3("avdt_msg_send label:%d, msg:%d, sig:%d", label, msg, sig); 12835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* keep track of how much of msg we've sent */ 12855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project curr_msg_len -= p_buf->len; 12865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (curr_msg_len == 0) 12875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* entire message sent; mark as finished */ 12895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ccb->p_curr_msg = NULL; 12905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* start timer here for commands */ 12925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (msg == AVDT_MSG_TYPE_CMD) 12935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if retransmit timeout set to zero, sig doesn't use retransmit */ 12955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((sig == AVDT_SIG_DISCOVER) || (sig == AVDT_SIG_GETCAP) || 12965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (sig == AVDT_SIG_SECURITY) || (avdt_cb.rcb.ret_tout == 0)) 12975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btu_start_timer(&p_ccb->timer_entry, BTU_TTYPE_AVDT_CCB_RSP, avdt_cb.rcb.sig_tout); 12995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if (sig != AVDT_SIG_DELAY_RPT) 13015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btu_start_timer(&p_ccb->timer_entry, BTU_TTYPE_AVDT_CCB_RET, avdt_cb.rcb.ret_tout); 13035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 13075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* message being fragmented and not completely sent */ 13095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ccb->p_curr_msg->len -= p_buf->len; 13105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ccb->p_curr_msg->offset += p_buf->len; 13115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* set up to build header */ 13145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->len += hdr_len; 13155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->offset -= hdr_len; 13165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p = (UINT8 *)(p_buf + 1) + p_buf->offset; 13175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* build header */ 13195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_BLD_HDR(p, label, pkt_type, msg); 13205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (pkt_type == AVDT_PKT_TYPE_START) 13215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_BLD_NOSP(p, nosp); 13235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((pkt_type == AVDT_PKT_TYPE_START) || (pkt_type == AVDT_PKT_TYPE_SINGLE)) 13255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_BLD_SIG(p, sig); 13275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* send msg buffer down */ 13305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_ad_write_req(AVDT_CHAN_SIG, p_ccb, NULL, p_buf); 13315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return (p_ccb->cong); 13335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 13345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 13365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 13375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_asmbl 13385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 13395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Reassemble incoming message. 13405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 13415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 13425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns Pointer to reassembled message; NULL if no message 13435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** available. 13445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 13455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 13465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjectBT_HDR *avdt_msg_asmbl(tAVDT_CCB *p_ccb, BT_HDR *p_buf) 13475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 13485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p; 13495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 pkt_type; 13505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_ret; 13515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 buf_len; 13525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* parse the message header */ 13545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p = (UINT8 *)(p_buf + 1) + p_buf->offset; 13555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_PRS_PKT_TYPE(p, pkt_type); 13565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* quick sanity check on length */ 13585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_buf->len < avdt_msg_pkt_type_len[pkt_type]) 13595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project GKI_freebuf(p_buf); 13615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_TRACE_WARNING0("Bad length during reassembly"); 13625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ret = NULL; 13635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* single packet */ 13655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if (pkt_type == AVDT_PKT_TYPE_SINGLE) 13665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if reassembly in progress drop message and process new single */ 13685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_ccb->p_rx_msg != NULL) 13695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project GKI_freebuf(p_ccb->p_rx_msg); 13715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ccb->p_rx_msg = NULL; 13725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_TRACE_WARNING0("Got single during reassembly"); 13735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ret = p_buf; 13755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* start packet */ 13775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if (pkt_type == AVDT_PKT_TYPE_START) 13785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if reassembly in progress drop message and process new single */ 13805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_ccb->p_rx_msg != NULL) 13815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project GKI_freebuf(p_ccb->p_rx_msg); 13835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_TRACE_WARNING0("Got start during reassembly"); 13845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ccb->p_rx_msg = p_buf; 13865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* copy first header byte over nosp */ 13885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(p + 1) = *p; 13895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* set offset to point to where to copy next */ 13915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ccb->p_rx_msg->offset += p_ccb->p_rx_msg->len; 13925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* adjust length for packet header */ 13945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ccb->p_rx_msg->len -= 1; 13955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ret = NULL; 13975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* continue or end */ 13995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 14005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 14015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if no reassembly in progress drop message */ 14025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_ccb->p_rx_msg == NULL) 14035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 14045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project GKI_freebuf(p_buf); 14055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_TRACE_WARNING1("Pkt type=%d out of order", pkt_type); 14065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ret = NULL; 14075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 14085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 14095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 14105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* get size of buffer holding assembled message */ 14115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project buf_len = GKI_get_buf_size(p_ccb->p_rx_msg) - sizeof(BT_HDR); 14125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 14135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* adjust offset and len of fragment for header byte */ 14145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->offset += AVDT_LEN_TYPE_CONT; 14155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->len -= AVDT_LEN_TYPE_CONT; 14165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 14175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* verify length */ 14185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_ccb->p_rx_msg->offset + p_buf->len) > buf_len) 14195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 14205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* won't fit; free everything */ 14215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project GKI_freebuf(p_ccb->p_rx_msg); 14225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ccb->p_rx_msg = NULL; 14235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project GKI_freebuf(p_buf); 14245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ret = NULL; 14255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 14265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 14275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 14285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* copy contents of p_buf to p_rx_msg */ 14295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy((UINT8 *)(p_ccb->p_rx_msg + 1) + p_ccb->p_rx_msg->offset, 14305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (UINT8 *)(p_buf + 1) + p_buf->offset, p_buf->len); 14315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 14325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (pkt_type == AVDT_PKT_TYPE_END) 14335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 14345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ccb->p_rx_msg->offset -= p_ccb->p_rx_msg->len; 14355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ccb->p_rx_msg->len += p_buf->len; 14365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ret = p_ccb->p_rx_msg; 14375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ccb->p_rx_msg = NULL; 14385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 14395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 14405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 14415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ccb->p_rx_msg->offset += p_buf->len; 14425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ccb->p_rx_msg->len += p_buf->len; 14435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ret = NULL; 14445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 14455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project GKI_freebuf(p_buf); 14465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 14475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 14485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 14495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return p_ret; 14505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 14515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 14525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 14535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 14545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_send_cmd 14555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 14565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This function is called to send a command message. The 14575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** sig_id parameter indicates the message type, p_params 14585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** points to the message parameters, if any. It gets a buffer 14595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** from the AVDTP command pool, executes the message building 14605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** function for this message type. It then queues the message 14615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** in the command queue for this CCB. 14625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 14635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 14645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns Nothing. 14655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 14665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 14675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid avdt_msg_send_cmd(tAVDT_CCB *p_ccb, void *p_scb, UINT8 sig_id, tAVDT_MSG *p_params) 14685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 14695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_buf; 14705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p; 14715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p_start; 14725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 14735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* get a buffer */ 14745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID); 14755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_buf == NULL) 14765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 14775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_TRACE_ERROR0("avdt_msg_send_cmd out of buffer!!"); 14785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return; 14795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 14805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 14815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* set up gki buf pointer and offset */ 14825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->offset = AVDT_MSG_OFFSET; 14835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_start = p = (UINT8 *)(p_buf + 1) + p_buf->offset; 14845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 14855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* execute parameter building function to build message */ 14865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (*avdt_msg_bld_cmd[sig_id - 1])(&p, p_params); 14875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 14885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* set len */ 14895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->len = (UINT16) (p - p_start); 14905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 14915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* now store scb hdls, if any, in buf */ 14925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_scb != NULL) 14935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 14945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p = (UINT8 *)(p_buf + 1); 14955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 14965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* for start and suspend, p_scb points to array of handles */ 14975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((sig_id == AVDT_SIG_START) || (sig_id == AVDT_SIG_SUSPEND)) 14985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 14995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(p, (UINT8 *) p_scb, p_buf->len); 15005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 15015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* for all others, p_scb points to scb as usual */ 15025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 15035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 15045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *p = avdt_scb_to_hdl((tAVDT_SCB *) p_scb); 15055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 15065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 15075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* stash sig, label, and message type in buf */ 15095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->event = sig_id; 15105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_BLD_LAYERSPEC(p_buf->layer_specific, AVDT_MSG_TYPE_CMD, p_ccb->label); 15115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* increment label */ 15135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ccb->label = (p_ccb->label + 1) % 16; 15145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* queue message and trigger ccb to send it */ 15165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project GKI_enqueue(&p_ccb->cmd_q, p_buf); 15175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_ccb_event(p_ccb, AVDT_CCB_SENDMSG_EVT, NULL); 15185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 15195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 15225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 15235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_send_rsp 15245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 15255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This function is called to send a response message. The 15265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** sig_id parameter indicates the message type, p_params 15275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** points to the message parameters, if any. It gets a buffer 15285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** from the AVDTP command pool, executes the message building 15295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** function for this message type. It then queues the message 15305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** in the response queue for this CCB. 15315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 15325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 15335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns Nothing. 15345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 15355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 15365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid avdt_msg_send_rsp(tAVDT_CCB *p_ccb, UINT8 sig_id, tAVDT_MSG *p_params) 15375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 15385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_buf; 15395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p; 15405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p_start; 15415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* get a buffer */ 15435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID); 15445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_buf == NULL) return; 15455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* set up gki buf pointer and offset */ 15475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->offset = AVDT_MSG_OFFSET; 15485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_start = p = (UINT8 *)(p_buf + 1) + p_buf->offset; 15495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* execute parameter building function to build message */ 15515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (*avdt_msg_bld_rsp[sig_id - 1])(&p, p_params); 15525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* set length */ 15545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->len = (UINT16) (p - p_start); 15555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* stash sig, label, and message type in buf */ 15575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->event = sig_id; 15585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_BLD_LAYERSPEC(p_buf->layer_specific, AVDT_MSG_TYPE_RSP, p_params->hdr.label); 15595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* queue message and trigger ccb to send it */ 15615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project GKI_enqueue(&p_ccb->rsp_q, p_buf); 15625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_ccb_event(p_ccb, AVDT_CCB_SENDMSG_EVT, NULL); 15635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 15645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 15675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 15685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_send_rej 15695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 15705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This function is called to send a reject message. The 15715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** sig_id parameter indicates the message type. It gets 15725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** a buffer from the AVDTP command pool and builds the 15735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** message based on the message type and the error code. 15745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** It then queues the message in the response queue for 15755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** this CCB. 15765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 15775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 15785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns Nothing. 15795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 15805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 15815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid avdt_msg_send_rej(tAVDT_CCB *p_ccb, UINT8 sig_id, tAVDT_MSG *p_params) 15825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 15835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_buf; 15845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p; 15855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p_start; 15865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* get a buffer */ 15885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID); 15895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_buf == NULL) return; 15905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* set up gki buf pointer and offset */ 15925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->offset = AVDT_MSG_OFFSET; 15935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_start = p = (UINT8 *)(p_buf + 1) + p_buf->offset; 15945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if sig id included, build into message */ 15965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (sig_id != AVDT_SIG_NONE) 15975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 15985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if this sig has a parameter, add the parameter */ 15995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((sig_id == AVDT_SIG_SETCONFIG) || 16005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (sig_id == AVDT_SIG_RECONFIG)) 16015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 16025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_BLD_PARAM(p, p_params->hdr.err_param); 16035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 16045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if ((sig_id == AVDT_SIG_START) || 16055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (sig_id == AVDT_SIG_SUSPEND)) 16065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 16075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_BLD_SEID(p, p_params->hdr.err_param); 16085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 16095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* add the error code */ 16115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_BLD_ERR(p, p_params->hdr.err_code); 16125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 16135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_TRACE_DEBUG0("avdt_msg_send_rej"); 16145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* calculate length */ 16165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->len = (UINT16) (p - p_start); 16175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* stash sig, label, and message type in buf */ 16195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->event = sig_id; 16205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_BLD_LAYERSPEC(p_buf->layer_specific, AVDT_MSG_TYPE_REJ, p_params->hdr.label); 16215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* queue message and trigger ccb to send it */ 16235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project GKI_enqueue(&p_ccb->rsp_q, p_buf); 16245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_ccb_event(p_ccb, AVDT_CCB_SENDMSG_EVT, NULL); 16255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 16265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 16285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_send_grej 16305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This function is called to send a general reject message. The 16325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** sig_id parameter indicates the message type. It gets 16335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** a buffer from the AVDTP command pool and builds the 16345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** message based on the message type and the error code. 16355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** It then queues the message in the response queue for 16365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** this CCB. 16375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns Nothing. 16405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 16425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid avdt_msg_send_grej(tAVDT_CCB *p_ccb, UINT8 sig_id, tAVDT_MSG *p_params) 16435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 16445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_buf; 16455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p; 16465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p_start; 16475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* get a buffer */ 16495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID); 16505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_buf == NULL) return; 16515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* set up gki buf pointer and offset */ 16535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->offset = AVDT_MSG_OFFSET; 16545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_start = p = (UINT8 *)(p_buf + 1) + p_buf->offset; 16555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* calculate length */ 16575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->len = (UINT16) (p - p_start); 16585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* stash sig, label, and message type in buf */ 16605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->event = sig_id; 16615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_BLD_LAYERSPEC(p_buf->layer_specific, AVDT_MSG_TYPE_GRJ, p_params->hdr.label); 16625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project //p_buf->event = 0; 16635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project //AVDT_BLD_LAYERSPEC(p_buf->layer_specific, 0, p_params->hdr.label); 16645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_TRACE_DEBUG0("avdt_msg_send_grej"); 16655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* queue message and trigger ccb to send it */ 16675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project GKI_enqueue(&p_ccb->rsp_q, p_buf); 16685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_ccb_event(p_ccb, AVDT_CCB_SENDMSG_EVT, NULL); 16695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 16705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 16725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function avdt_msg_ind 16745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This function is called by the adaption layer when an 16765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** incoming message is received on the signaling channel. 16775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** It parses the message and sends an event to the appropriate 16785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** SCB or CCB for the message. 16795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns Nothing. 16825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 16845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid avdt_msg_ind(tAVDT_CCB *p_ccb, BT_HDR *p_buf) 16855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 16865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tAVDT_SCB *p_scb; 16875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p; 16885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BOOLEAN ok = TRUE; 16895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BOOLEAN handle_rsp = FALSE; 16905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BOOLEAN gen_rej = FALSE; 16915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 label; 16925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 pkt_type; 16935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 msg_type; 16945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 sig = 0; 16955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tAVDT_MSG msg; 16965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tAVDT_CFG cfg; 16975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 err; 16985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 evt = 0; 16995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 scb_hdl; 17005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 17015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* reassemble message; if no message available (we received a fragment) return */ 17025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = avdt_msg_asmbl(p_ccb, p_buf)) == NULL) 17035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return; 17055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 17075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p = (UINT8 *)(p_buf + 1) + p_buf->offset; 17085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 17095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* parse the message header */ 17105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_PRS_HDR(p, label, pkt_type, msg_type); 17115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 17125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* AVDT_TRACE_DEBUG1("msg_type=%d", msg_type); */ 17135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* set up label and ccb_idx in message hdr */ 17145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project msg.hdr.label = label; 17155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project msg.hdr.ccb_idx = avdt_ccb_to_idx(p_ccb); 17165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 17175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* verify msg type */ 17185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (msg_type == AVDT_MSG_TYPE_GRJ) 17195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_TRACE_WARNING1("Dropping msg msg_type=%d", msg_type); 17215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ok = FALSE; 17225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* check for general reject */ 17245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if ((msg_type == AVDT_MSG_TYPE_REJ) && (p_buf->len == AVDT_LEN_GEN_REJ)) 17255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project gen_rej = TRUE; 17275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_ccb->p_curr_cmd != NULL) 17285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project msg.hdr.sig_id = sig = (UINT8) p_ccb->p_curr_cmd->event; 17305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project evt = avdt_msg_rej_2_evt[sig - 1]; 17315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project msg.hdr.err_code = AVDT_ERR_NSC; 17325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project msg.hdr.err_param = 0; 17335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else /* not a general reject */ 17365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* get and verify signal */ 17385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_MSG_PRS_SIG(p, sig); 17395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project msg.hdr.sig_id = sig; 17405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((sig == 0) || (sig > AVDT_SIG_MAX)) 17415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_TRACE_WARNING2("Dropping msg sig=%d msg_type:%d", sig, msg_type); 17435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ok = FALSE; 17445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 17455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* send a general reject */ 17465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (msg_type == AVDT_MSG_TYPE_CMD) 17475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_send_grej(p_ccb, sig, &msg); 17495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 17535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (ok && !gen_rej) 17545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* skip over header (msg length already verified during reassembly) */ 17565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->len -= AVDT_LEN_TYPE_SINGLE; 17575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 17585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* set up to parse message */ 17595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((msg_type == AVDT_MSG_TYPE_RSP) && (sig == AVDT_SIG_DISCOVER)) 17605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* parse discover rsp message to struct supplied by app */ 17625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project msg.discover_rsp.p_sep_info = (tAVDT_SEP_INFO *) p_ccb->p_proc_data; 17635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project msg.discover_rsp.num_seps = p_ccb->proc_param; 17645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if ((msg_type == AVDT_MSG_TYPE_RSP) && 17665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ((sig == AVDT_SIG_GETCAP) || (sig == AVDT_SIG_GET_ALLCAP))) 17675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* parse discover rsp message to struct supplied by app */ 17695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project msg.svccap.p_cfg = (tAVDT_CFG *) p_ccb->p_proc_data; 17705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if ((msg_type == AVDT_MSG_TYPE_RSP) && (sig == AVDT_SIG_GETCONFIG)) 17725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* parse get config rsp message to struct allocated locally */ 17745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project msg.svccap.p_cfg = &cfg; 17755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if ((msg_type == AVDT_MSG_TYPE_CMD) && (sig == AVDT_SIG_SETCONFIG)) 17775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* parse config cmd message to struct allocated locally */ 17795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project msg.config_cmd.p_cfg = &cfg; 17805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if ((msg_type == AVDT_MSG_TYPE_CMD) && (sig == AVDT_SIG_RECONFIG)) 17825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* parse reconfig cmd message to struct allocated locally */ 17845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project msg.reconfig_cmd.p_cfg = &cfg; 17855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 17875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* parse message; while we're at it map message sig to event */ 17885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (msg_type == AVDT_MSG_TYPE_CMD) 17895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project msg.hdr.err_code = err = (*avdt_msg_prs_cmd[sig - 1])(&msg, p, p_buf->len); 17915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project evt = avdt_msg_cmd_2_evt[sig - 1]; 17925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if (msg_type == AVDT_MSG_TYPE_RSP) 17945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project msg.hdr.err_code = err = (*avdt_msg_prs_rsp[sig - 1])(&msg, p, p_buf->len); 17965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project evt = avdt_msg_rsp_2_evt[sig - 1]; 17975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else /* msg_type == AVDT_MSG_TYPE_REJ */ 17995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project err = avdt_msg_prs_rej(&msg, p, sig); 18015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project evt = avdt_msg_rej_2_evt[sig - 1]; 18025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if parsing failed */ 18055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (err != 0) 18065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_TRACE_WARNING2("Parsing failed sig=%d err=0x%x", sig, err); 18085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if its a rsp or rej, drop it; if its a cmd, send a rej; 18105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** note special case for abort; never send abort reject 18115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project */ 18125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ok = FALSE; 18135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((msg_type == AVDT_MSG_TYPE_CMD) && (sig != AVDT_SIG_ABORT)) 18145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_msg_send_rej(p_ccb, sig, &msg); 18165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if its a rsp or rej, check sent cmd to see if we're waiting for 18215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** the rsp or rej. If we didn't send a cmd for it, drop it. If 18225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** it does match a cmd, stop timer for the cmd. 18235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project */ 18245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (ok) 18255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((msg_type == AVDT_MSG_TYPE_RSP) || (msg_type == AVDT_MSG_TYPE_REJ)) 18275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_ccb->p_curr_cmd != NULL) && 18295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (p_ccb->p_curr_cmd->event == sig) && 18305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (AVDT_LAYERSPEC_LABEL(p_ccb->p_curr_cmd->layer_specific) == label)) 18315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* stop timer */ 18335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btu_stop_timer(&p_ccb->timer_entry); 18345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* clear retransmission count */ 18365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ccb->ret_count = 0; 18375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* later in this function handle ccb event */ 18395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project handle_rsp = TRUE; 18405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 18425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ok = FALSE; 18445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_TRACE_WARNING2("Cmd not found for rsp sig=%d label=%d", sig, label); 18455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (ok) 18505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if it's a ccb event send to ccb */ 18525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (evt & AVDT_CCB_MKR) 18535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_ccb_event(p_ccb, (UINT8)(evt & ~AVDT_CCB_MKR), (tAVDT_CCB_EVT *) &msg); 18555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if it's a scb event */ 18575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 18585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Scb events always have a single seid. For cmd, get seid from 18605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** message. For rej and rsp, get seid from p_curr_cmd. 18615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project */ 18625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (msg_type == AVDT_MSG_TYPE_CMD) 18635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project scb_hdl = msg.single.seid; 18655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 18675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project scb_hdl = *((UINT8 *)(p_ccb->p_curr_cmd + 1)); 18695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Map seid to the scb and send it the event. For cmd, seid has 18725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** already been verified by parsing function. 18735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project */ 18745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (evt && (p_scb = avdt_scb_by_hdl(scb_hdl)) != NULL) 18755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_scb_event(p_scb, evt, (tAVDT_SCB_EVT *) &msg); 18775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* free message buffer */ 18825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project GKI_freebuf(p_buf); 18835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if its a rsp or rej, send event to ccb to free associated 18855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** cmd msg buffer and handle cmd queue 18865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project */ 18875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (handle_rsp) 18885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avdt_ccb_event(p_ccb, AVDT_CCB_RCVRSP_EVT, NULL); 18905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1892