| 1 | /******************************************************************************************** |
|---|
| 2 | * (c)2004-2011 Broadcom Corporation * |
|---|
| 3 | * * |
|---|
| 4 | * This program is the proprietary software of Broadcom Corporation and/or its licensors, * |
|---|
| 5 | * and may only be used, duplicated, modified or distributed pursuant to the terms and * |
|---|
| 6 | * conditions of a separate, written license agreement executed between you and Broadcom * |
|---|
| 7 | * (an "Authorized License"). Except as set forth in an Authorized License, Broadcom grants* |
|---|
| 8 | * no license (express or implied), right to use, or waiver of any kind with respect to the * |
|---|
| 9 | * Software, and Broadcom expressly reserves all rights in and to the Software and all * |
|---|
| 10 | * intellectual property rights therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU * |
|---|
| 11 | * HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY * |
|---|
| 12 | * NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE. * |
|---|
| 13 | * |
|---|
| 14 | * Except as expressly set forth in the Authorized License, * |
|---|
| 15 | * |
|---|
| 16 | * 1. This program, including its structure, sequence and organization, constitutes * |
|---|
| 17 | * the valuable trade secrets of Broadcom, and you shall use all reasonable efforts to * |
|---|
| 18 | * protect the confidentiality thereof,and to use this information only in connection * |
|---|
| 19 | * with your use of Broadcom integrated circuit products. * |
|---|
| 20 | * * |
|---|
| 21 | * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" * |
|---|
| 22 | * AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR * |
|---|
| 23 | * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO * |
|---|
| 24 | * THE SOFTWARE. BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES * |
|---|
| 25 | * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, * |
|---|
| 26 | * LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION * |
|---|
| 27 | * OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF * |
|---|
| 28 | * USE OR PERFORMANCE OF THE SOFTWARE. * |
|---|
| 29 | * * |
|---|
| 30 | * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS * |
|---|
| 31 | * LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR * |
|---|
| 32 | * EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR * |
|---|
| 33 | * USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF * |
|---|
| 34 | * THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT * |
|---|
| 35 | * ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE * |
|---|
| 36 | * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF * |
|---|
| 37 | * ANY LIMITED REMEDY. |
|---|
| 38 | * |
|---|
| 39 | * $brcm_Workfile: b_dtcp_stack.h $ |
|---|
| 40 | * $brcm_Revision: 4 $ |
|---|
| 41 | * $brcm_Date: 2/11/11 5:37p $ |
|---|
| 42 | * |
|---|
| 43 | * Module Description: |
|---|
| 44 | * |
|---|
| 45 | * Revision History: |
|---|
| 46 | * |
|---|
| 47 | * $brcm_Log: /nexus/lib/dtcp_ip/include/b_dtcp_stack.h $ |
|---|
| 48 | * |
|---|
| 49 | * 4 2/11/11 5:37p leisun |
|---|
| 50 | * SWSECURITY-32: Updated lib to V1SE1.3 conformance. |
|---|
| 51 | * |
|---|
| 52 | * 3 7/13/09 11:23a leisun |
|---|
| 53 | * PR 55693: Re-design interfaces, and other cleanups |
|---|
| 54 | * |
|---|
| 55 | * 2 6/30/09 10:37p leisun |
|---|
| 56 | * PR 55693: Added exchange key expiration timer |
|---|
| 57 | * |
|---|
| 58 | * 1 6/5/09 4:06p leisun |
|---|
| 59 | * PR 55693: checking in DTCP-IP lib |
|---|
| 60 | * |
|---|
| 61 | * Description: |
|---|
| 62 | * DTCP base stack data definitions. |
|---|
| 63 | * |
|---|
| 64 | *********************************************************************************************/ |
|---|
| 65 | /*! \file b_dtcp_stack.h |
|---|
| 66 | * \brief Define DTCP base stack data structure. |
|---|
| 67 | */ |
|---|
| 68 | #ifndef B_DTCP_STACK_H |
|---|
| 69 | #define B_DTCP_STACK_H |
|---|
| 70 | |
|---|
| 71 | #include "b_dtcp_ake_msg.h" |
|---|
| 72 | #include "b_dtcp_transport.h" |
|---|
| 73 | |
|---|
| 74 | #ifdef __cplusplus |
|---|
| 75 | extern "C" { |
|---|
| 76 | #endif |
|---|
| 77 | |
|---|
| 78 | /*! \skipline forward declaration |
|---|
| 79 | */ |
|---|
| 80 | struct __b_dtcp_stack; |
|---|
| 81 | typedef struct __b_dtcp_stack * B_DTCP_StackHandle_T; |
|---|
| 82 | |
|---|
| 83 | /*! \brief function pointer to start a sink device, to be implemented by protocol specific stack layer |
|---|
| 84 | * \param[in] pStack The stack handle. |
|---|
| 85 | * \param[in] pData procotol specified data pointer. |
|---|
| 86 | * \param[out] AkeHandle result AKE session handle pointer, if AKE succeeded, dereferencing this pointer to obtain handle. |
|---|
| 87 | * \retval BERR_SUCCESS or other error code. |
|---|
| 88 | */ |
|---|
| 89 | typedef BERR_Code (* B_DTCP_AkeStartSink_Ptr)(B_DTCP_StackHandle_T pStack, void * pData, B_AkeHandle_T * AkeHandle); |
|---|
| 90 | |
|---|
| 91 | /*! \brief function pointer to stop sink function and close AKE session. |
|---|
| 92 | * \param[in] pStack The stack handle. |
|---|
| 93 | * \param[in] AkeHandle Ake handle obtained from AkeStartSink function. |
|---|
| 94 | * \retval BERR_SUCCESS or other error code. |
|---|
| 95 | */ |
|---|
| 96 | typedef BERR_Code (* B_DTCP_AkeStopSink_Ptr)(B_DTCP_StackHandle_T pStack, B_AkeHandle_T AkeHandle); |
|---|
| 97 | |
|---|
| 98 | /*! \brief function pointer to start a source device, to be implemented by protocol specific stack layer. |
|---|
| 99 | * \param[in] pStack The stack handle. |
|---|
| 100 | * \param[in] pData protocol specified data pointer. |
|---|
| 101 | * \retval BERR_SUCCESS or other error code |
|---|
| 102 | */ |
|---|
| 103 | typedef BERR_Code (* B_DTCP_AkeStartSource_Ptr)(B_DTCP_StackHandle_T pStack, void * pData); |
|---|
| 104 | |
|---|
| 105 | /*! \brief function pointer to stop source function. |
|---|
| 106 | * \param[in] pStack The stack handle. |
|---|
| 107 | * \retval BERR_SUCCESS or other error code. |
|---|
| 108 | */ |
|---|
| 109 | typedef BERR_Code (* B_DTCP_AkeStopSource_Ptr)(B_DTCP_StackHandle_T pStack); |
|---|
| 110 | |
|---|
| 111 | /*! \brief function pointer to update SRM |
|---|
| 112 | * \param[in] pSrm pointer to SRM message buffer. |
|---|
| 113 | * \param[in] aSrmSize size of the SRM message. |
|---|
| 114 | * \retval implementation defined. |
|---|
| 115 | * The method of update/store SRM is implementation dependent, The high level application software should implemnent this function. |
|---|
| 116 | */ |
|---|
| 117 | typedef int (*B_DTCP_UpdateSRM_Ptr)(unsigned char * pSrm, unsigned int aSrmSize); |
|---|
| 118 | |
|---|
| 119 | /*! \brief function pointer for internal error handling |
|---|
| 120 | * \param[in] pStack The stack handle. |
|---|
| 121 | * \param[in] AkeHandle current AKE session Handle. |
|---|
| 122 | */ |
|---|
| 123 | typedef void (* B_DTCP_OnInternalError_Ptr)(B_DTCP_StackHandle_T pStack, B_AkeHandle_T AkeHandle); |
|---|
| 124 | |
|---|
| 125 | /*! \brief function pointer to verify current exchange key is valid. for sink device only. |
|---|
| 126 | * \param[in] pStack The stack handle. |
|---|
| 127 | * \param[in] AkeHandle current Ake session handle. |
|---|
| 128 | * \param[in,out] Valid boolean variable indicate if the session's exchange key is valid or not. |
|---|
| 129 | * \retval BERR_SUCCESS or error code. |
|---|
| 130 | */ |
|---|
| 131 | typedef BERR_Code (* B_DTCP_VerifyExchKey)(B_DTCP_StackHandle_T pStack, B_AkeHandle_T AkeHandle, bool * Valid); |
|---|
| 132 | |
|---|
| 133 | /*! \struct __b_dtcp_stack |
|---|
| 134 | * \brief DTCP stack control data. |
|---|
| 135 | * |
|---|
| 136 | * The DTCP base stack state machine is implemented around this data structure |
|---|
| 137 | */ |
|---|
| 138 | typedef struct __b_dtcp_stack |
|---|
| 139 | { |
|---|
| 140 | B_AkeCoreData_T * pAkeCoreData; /*!< DTCP Ake core data pointer */ |
|---|
| 141 | B_DeviceParams_T * DeviceParams; /*!< device's parameters. */ |
|---|
| 142 | B_DTCP_AkeMessageInterface_T * Messenger; /*!< AKE message interface pointer */ |
|---|
| 143 | B_DTCP_AkeTransportInterface_T * Transporter; /*!< AKE transport interface pointer */ |
|---|
| 144 | |
|---|
| 145 | /* Functions to be implemented by specific protocol.*/ |
|---|
| 146 | B_DTCP_AkeStartSink_Ptr StartSink_Func; /*!< function pointer to start sink device.*/ |
|---|
| 147 | B_DTCP_AkeStopSink_Ptr StopSink_Func; /*!< function pointer to perform AKE procedure for sink */ |
|---|
| 148 | B_DTCP_AkeStartSource_Ptr StartSource_Func; /*!< function pointer to start a source device */ |
|---|
| 149 | B_DTCP_AkeStopSource_Ptr StopSource_Func; |
|---|
| 150 | B_DTCP_UpdateSRM_Ptr UpdateSrm_Func; /*!< function pointer to udpate SRM if needed */ |
|---|
| 151 | B_DTCP_OnInternalError_Ptr OnInternalError; /*!< Internal error handling function pointer */ |
|---|
| 152 | B_DTCP_VerifyExchKey VerifyExchKey_Func; /*!> function poniter to verify session's exchange key */ |
|---|
| 153 | B_StackId_T StackId; |
|---|
| 154 | |
|---|
| 155 | |
|---|
| 156 | void * pProtocolData; /*!< protocol specific data. */ |
|---|
| 157 | }B_DTCP_Stack_T; |
|---|
| 158 | |
|---|
| 159 | /* --------------------------DTCP base stack implemented function prototypes--------------------------- */ |
|---|
| 160 | |
|---|
| 161 | /*! \brief initialize DTCP stack based on stack id, (IP, USB, 1394, etc). |
|---|
| 162 | * \param[in] DeviceParams device parameter pointer. |
|---|
| 163 | * \param[in] UpdateSrm_Func application provided update SRM function pointer. |
|---|
| 164 | * \param[in] StackId id specify which stack to initialize, currently only DTCP_STACK_IP is supported. |
|---|
| 165 | * \retval A handle to the stack if success, or NULL if failed. |
|---|
| 166 | */ |
|---|
| 167 | B_DTCP_StackHandle_T B_DTCP_Stack_Init(B_DeviceParams_T * DeviceParams, |
|---|
| 168 | B_DTCP_UpdateSRM_Ptr UpdateSrm_Func, B_StackId_T StackId); |
|---|
| 169 | |
|---|
| 170 | /*! \brief function pointer to cleanup dtcp stack |
|---|
| 171 | * \param[in] pStack The stack handle. |
|---|
| 172 | * \retval none. |
|---|
| 173 | */ |
|---|
| 174 | void B_DTCP_Stack_UnInit(B_DTCP_StackHandle_T pStack); |
|---|
| 175 | |
|---|
| 176 | /*! \brief base stack implemented utility function, send AKE command and wait for response |
|---|
| 177 | * \param[in] pStack The stack handle. |
|---|
| 178 | * \param[in] Session AKE session data pointer. |
|---|
| 179 | * \param[in] NoResponseData if true, the response frame has no data field, so the API only read AKE message header size bytes of data. |
|---|
| 180 | * if false, the API will read all available data for reponse frame from socket. |
|---|
| 181 | * \param[in] TimeOut time to wait (in msec) before receiving response from other device. |
|---|
| 182 | * \param[in,out] Cmd command to send, after received response, it will store the received command of response message. |
|---|
| 183 | * \param[out] Response received response code. |
|---|
| 184 | * \retval BERR_SUCCESS or other error code. |
|---|
| 185 | */ |
|---|
| 186 | BERR_Code B_DTCP_AkeSendCmdWaitForResponse(B_DTCP_StackHandle_T pStack, B_AkeCoreSessionData_T * Session, bool NoResponseData, |
|---|
| 187 | int TimeOut, int * Cmd, int * Response); |
|---|
| 188 | |
|---|
| 189 | /*!\brief base stack implemented utility function, wait for , receive and process AKE commands. |
|---|
| 190 | * \param[in] pStack The stack handle. |
|---|
| 191 | * \param[in] Session AKE session data pointer. |
|---|
| 192 | * \param[in] TimeOut time to wait (in msec) before receiving response from other device. |
|---|
| 193 | * \param[out] Cmd received command from other device. |
|---|
| 194 | * \retval BERR_SUCCESS or other error code. |
|---|
| 195 | * |
|---|
| 196 | * This function will block waiting for specified TimeOut value, if it didn't receive command during this period, |
|---|
| 197 | * it will return with BERR_TIMEOUT. |
|---|
| 198 | */ |
|---|
| 199 | BERR_Code B_DTCP_AkeReceiveCmd(B_DTCP_StackHandle_T pStack, B_AkeCoreSessionData_T * Session, int TimeOut, int * Cmd); |
|---|
| 200 | /*! \brief send capability exchange command. |
|---|
| 201 | * |
|---|
| 202 | * \param[in] Session current AKE session pointer. |
|---|
| 203 | * \param[in] Stack DTCP stack pointer. |
|---|
| 204 | */ |
|---|
| 205 | BERR_Code B_DTCP_SendCapabilityExchangeCmd(B_DTCP_Stack_T * Stack, B_AkeCoreSessionData_T * Session); |
|---|
| 206 | |
|---|
| 207 | /*! \brief Send a AKE challenge command. |
|---|
| 208 | * \param[in] pStack The stack handle. |
|---|
| 209 | * \param[in] pStack The stack handle. |
|---|
| 210 | * \param[in] Session pointer to AKE session data. |
|---|
| 211 | * \retval BERR_SUCCESS or other error code. |
|---|
| 212 | * |
|---|
| 213 | * protocol specific stack layer use this function to start a sink device AKE session. |
|---|
| 214 | */ |
|---|
| 215 | BERR_Code B_DTCP_SendChallengeCmd(B_DTCP_StackHandle_T pStack, B_AkeCoreSessionData_T * Session); |
|---|
| 216 | |
|---|
| 217 | /*! \brief process base AKE commands. |
|---|
| 218 | * \param[in] pStack the stack handle. |
|---|
| 219 | * \param[in] Stack DTCP base stack pointer. |
|---|
| 220 | * \param[in] Session AKE session data pointer. |
|---|
| 221 | * \param[in] Cmd command to be processed. |
|---|
| 222 | * \retval BERR_SUCCESS or other error code. |
|---|
| 223 | * |
|---|
| 224 | * This function only process the base AKE command (defined in b_dtcp_ake.h), protocol dependent commands are processed in |
|---|
| 225 | * seperate function implmented in protocol specific stack layer. |
|---|
| 226 | */ |
|---|
| 227 | |
|---|
| 228 | BERR_Code B_DTCP_ProcessAkeCommands(B_DTCP_StackHandle_T pStack, B_AkeCoreSessionData_T * Session, int Cmd); |
|---|
| 229 | |
|---|
| 230 | #ifdef __cplusplus |
|---|
| 231 | } |
|---|
| 232 | #endif |
|---|
| 233 | #endif /* B_DTCP_STACK_H */ |
|---|