1/******************************************************************************
2 *
3 *  Copyright (C) 2003-2012 Broadcom Corporation
4 *
5 *  Licensed under the Apache License, Version 2.0 (the "License");
6 *  you may not use this file except in compliance with the License.
7 *  You may obtain a copy of the License at:
8 *
9 *  http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 *
17 ******************************************************************************/
18
19/******************************************************************************
20 *
21 *  This contains constants definitions and other information from the AVCTP
22 *  specification.  This file is intended for use internal to AVCT only.
23 *
24 ******************************************************************************/
25#ifndef AVCT_DEFS_H
26#define AVCT_DEFS_H
27
28/*****************************************************************************
29 * constants
30 ****************************************************************************/
31
32/* packet type */
33#define AVCT_PKT_TYPE_SINGLE 0 /* single packet */
34#define AVCT_PKT_TYPE_START 1  /* start packet */
35#define AVCT_PKT_TYPE_CONT 2   /* continue packet */
36#define AVCT_PKT_TYPE_END 3    /* end packet */
37
38/* header lengths for different packet types */
39#define AVCT_HDR_LEN_SINGLE 3
40#define AVCT_HDR_LEN_START 4
41#define AVCT_HDR_LEN_CONT 1
42#define AVCT_HDR_LEN_END 1
43
44/* invalid cr+ipid value */
45#define AVCT_CR_IPID_INVALID 1
46
47/*****************************************************************************
48 * message parsing and building macros
49 ****************************************************************************/
50
51#define AVCT_BUILD_HDR(p, label, type, cr_ipid) \
52  *(p)++ = ((label) << 4) | ((type) << 2) | (cr_ipid);
53
54#define AVCT_PARSE_HDR(p, label, type, cr_ipid) \
55  do {                                          \
56    (label) = *(p) >> 4;                        \
57    (type) = (*(p) >> 2) & 3;                   \
58    (cr_ipid) = *(p)++ & 3;                     \
59  } while (0)
60
61#define AVCT_PKT_TYPE(p) ((*(p) >> 2) & 3)
62
63#endif /* AVCT_DEFS_H */
64