⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 txc_envoy_pin_valid.c

📁 TranSwitch Envoy CE2 & Envoy CE4 设备驱动及编程指南
💻 C
字号:
/*--------------------------------------------------------------------------

  *******                           ****
     *     *****     **    *    *  *       *    *   *  *****   ****   *    *
     *     *    *   *  *   **   *  *       *    *   *    *    *    *  *    *
     *     *    *  *    *  * *  *   ****   *    *   *    *    *       ******
     *     *****   ******  *  * *       *  * ** *   *    *    *       *    *
     *     *   *   *    *  *   **  *    *  **  **   *    *    *    *  *    *
     *     *    *  *    *  *    *   ****   *    *   *    *     ****   *    *

                        Proprietary and Confidential 

    This program is made available only to customers and prospective customers 
of TranSwitch Corporation under license and may be used only with TranSwitch 
semi-conductor products.

                      Copyright(c) 2004 TranSwitch Inc.

 --------------------------------------------------------------------------

             *******  **      **  **        **   ********   **      **
             *******  ***     **  **        **  **********  **      **
             **       ** *    **  **        **  **      **   **    **
             *****    **  *   **   **      **   **      **     *  *
             *****    **   *  **    **    **    **      **      **
             **       **    * **     **  **     **      **      **
             *******  **     ***      ****      **********      **
             *******  **      **       **        ********       **

 --------------------------------------------------------------------------
                           TranSwitch Envoy-CE2/CE4
                                Device Driver
 --------------------------------------------------------------------------
                                                                             
   Workfile:  txc_envoy_pin_valid.c                                             
                                                                             
   Description: Functions to check validity of pin-related calls.                                        
                                                                             
  -------------------------------------------------------------------------- 
                               Revision History                              
  -------------------------------------------------------------------------- 
    Rev #     Date          Author                Description
   -----    -------      ------------         ----------------------
   0.5.0    6/03/04      F. Giannella         Initial release (beta)

 *--------------------------------------------------------------------------*/



/****************************************************************************
 **                             Include Files                              **
 ****************************************************************************/

#include "txc_envoy_api.h"
#include "txc_envoy_pin.h"
#include "txc_envoy_database.h"



/****************************************************************************
 **                            Static Functions                            **
 ****************************************************************************/


static TXC_U16BIT ENVOY_VerifySetPinHandleAndPort (TXC_U16BIT, TXC_U16BIT);
static TXC_U16BIT ENVOY_VerifyGetPinHandleAndPort (TXC_U16BIT, TXC_U16BIT);



/****************************************************************************
 **                        Static/Global Variables                         **
 ****************************************************************************/



/****************************************************************************
 **                                  Code                                  **
 ****************************************************************************/




/*--------------------------------------------------------------------------*
                                                                             
   FUNCTION:  ENVOY_SetEthernetPortConfigValid                                           
                                                                             
   DESCRIPTION: This function validates the ENVOYSetMacIface                                          
                                                                             
   INPUTS:  Same as TXC_ENVOY_EthernetPortConfigSet                            
                                                                             
   RETURNS:  TXC_NO_ERR or an appropriate specific error code listed in      
   appendix.                                                                 
                                                                             
   CAVEATS:  The hardware default on the interface comes up in GPSI mode,    
   which is not recommended for use.                                         
                                                                             
   REVISION HISTORY:

    Rev #     Date          Author                Description
   -----    -------      ------------         ----------------------
   0.5.0    6/03/04      F. Giannella         Initial release (beta)
                                         
*--------------------------------------------------------------------------*/

TXC_U16BIT ENVOY_SetEthernetPortConfigValid 
(
TXC_U16BIT handle,
TXC_U16BIT port,
ENVOY_DEV_ETHERNET_MODE_STRUCT * ethernetPortModeDataPtr
)
{
    TXC_U16BIT error;

    /* first, check the handle & port */
    error = ENVOY_VerifySetPinHandleAndPort (handle, port);

    /* now range check the data */

    if (error == TXC_NO_ERR)
    {
        if (ethernetPortModeDataPtr->ethernetPortMode >= ENVOY_END_OF_ETHENET_PORT_MODE_ENUM)
        {
            ethernetPortModeDataPtr->ethernetPortMode = ENVOY_ETHERNET_PORT_MODE_ENUM_ERR;
            error = TXC_INVALID_PARM_ERR;
        }
    }
    /* return the error code */
    return error;
}




/*--------------------------------------------------------------------------*

   FUNCTION:  ENVOY_GetEthernetPortConfigValid

   DESCRIPTION: This function validates the TXC_ENVOY_EthernetPortConfigGet

   INPUTS:  Same as TXC_ENVOY_EthernetPortConfigGet
  
   RETURNS:  TXC_NO_ERR or an appropriate specific error code listed in appendix.

   CAVEATS:  None.

   REVISION HISTORY:

    Rev #     Date          Author                Description
   -----    -------      ------------         ----------------------
   0.5.0    6/03/04      F. Giannella         Initial release (beta)
 *--------------------------------------------------------------------------*/
TXC_U16BIT ENVOY_GetEthernetPortConfigValid 
(
TXC_U16BIT handle,
TXC_U16BIT port,
ENVOY_DEV_ETHERNET_MODE_STRUCT *ethernetPortModeDataPtr
)
{
    TXC_U16BIT error;
    
    /* only check the handle & port */
    error = ENVOY_VerifyGetPinHandleAndPort (handle, port);

    /* return the error code */
    return error;
}







/****************************************************************************
 **                             Static Function                            **
 ****************************************************************************/

/* check port and handle, in that order for valid range. 
    ON THE SET FUNCTIONS. Set function allow the port == 0xFFFF.
    Overwrite the last error, so the hierarchy is correctly followed. */

static TXC_U16BIT ENVOY_VerifySetPinHandleAndPort(TXC_U16BIT handle, 
                  TXC_U16BIT port)
{
    TXC_U16BIT maxPorts, error;

    /* first, check the handle. This may return invalid handle or driver not created */
    error = ENVOY_DbVerifyHandle (handle);

    /* if NO handle error, make sure the port value is correct, 
        allow for the all ports (0xFFFF) */
    if (error == TXC_NO_ERR)
    {
        maxPorts = ENVOY_DbGetMaxMacPorts (handle);
        if (port >= maxPorts)
        {
            if (port != ENVOY_MAC_ALL_PORTS)
                error = TXC_INVALID_CHANNEL_ERR;
        }
    }

    /* return the error */
    return error;
}




/* check port, then handle, in that order for valid range. ON THE GET
    Overwrite the last error, so the hierarchy is correctly followed. */

static TXC_U16BIT ENVOY_VerifyGetPinHandleAndPort(TXC_U16BIT handle, 
                  TXC_U16BIT port)
{
    /* TXC_U16BIT maxTerms, maxPorts, error; */
    TXC_U16BIT maxPorts, error;

    /* first, check the handle. This may return invalid handle or driver not created */
    error = ENVOY_DbVerifyHandle (handle);

    /* if NO handle error, make sure the port value is correct, 
        do not allow for the all ports (0xFFFF) */
    if (error == TXC_NO_ERR)
    {
        maxPorts = ENVOY_DbGetMaxMacPorts (handle);
        if (port >= maxPorts)
            error = TXC_INVALID_CHANNEL_ERR;
    }

    /* return the error */
    return error;

}


/****************************************************************************
 **                              End of Module                             **
 ****************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -