示例#1
0
void etherOutputHookDelete
(
    FUNCPTR outputHook
)
{

    HOOK_ENTRY *pHookEnt;
    extern LIST outputHookList;
    NODE index;

    for (pHookEnt = (HOOK_ENTRY *)lstFirst(&outputHookList);
            pHookEnt != NULL;
            pHookEnt = (HOOK_ENTRY *)lstNext(&index))
    {
        index = pHookEnt->node;
        if (pHookEnt->routine == outputHook)
        {
            lstDelete(&outputHookList, &pHookEnt->node);
            free(pHookEnt);
        }
    }

    if (lstCount(&outputHookList) <= 0)
    {
        etherOutputHookRtn = NULL;
        lstFree(&outputHookList);
    }

}
示例#2
0
int etherMultiDel
    (
    LIST *pList,    /* pointer to list of multicast addresses */
    char* pAddress  /* address you want to add to list */
    )
    {
    ETHER_MULTI* pCurr;
    /*
     * Look up the address in our list.
     */
    for (pCurr = (ETHER_MULTI *)lstFirst(pList); pCurr != NULL && 
	    (bcmp(pCurr->addr, pAddress, 6) != 0); 
	    pCurr = (ETHER_MULTI *)lstNext(&pCurr->node)); 
    
    if (pCurr == NULL) {
	    return (ENXIO);
    }
    if (--pCurr->refcount != 0) {
	    /*
	     * Still some claims to this record.
	     */
	    return (0);
    }
    /*
     * No remaining claims to this record; unlink and free it.
     */
    lstDelete(pList, &pCurr->node);
    KHEAP_FREE((char *)pCurr);

    /*
     * Return ENETRESET to inform the driver that the list has changed
     * and its reception filter should be adjusted accordingly.
     */
    return (ENETRESET);
    }
/*lint -e438*/
BST_VOID BST_CTaskSchdler::Detach ( BST_CORE_CPTask *pC_PTask )
{
    BST_CORE_PTASK_NODE_STRU   *pstPtaskNode;

    if ( !BST_OS_IsTimerValid (m_ulTimerId) )
    {
        BST_RLS_LOG1( "BST_CTaskSchdler::Detach m_ulTimerId=%u is invalid",
                      m_ulTimerId );
        return;
    }
    if ( BST_NULL_PTR == pC_PTask )
    {
        BST_RLS_LOG( "BST_CTaskSchdler::Detach pC_PTask=NULL" );
        return;
    }
    /*
     * 遍历列表,找到pctask相符的任务,从链表删除,释放资源
     */
    for ( pstPtaskNode = (BST_CORE_PTASK_NODE_STRU *)lstFirst( &g_stPTaskList );
          pstPtaskNode!= BST_NULL_PTR;
          pstPtaskNode = (BST_CORE_PTASK_NODE_STRU *)lstNext((NODE *)pstPtaskNode) )
    {
        if( pstPtaskNode->pcTask != pC_PTask )
        {
            continue;
        }
        lstDelete( &g_stPTaskList, (NODE *)pstPtaskNode );
        BST_OS_FREE( pstPtaskNode );
        break;
    }
    /*
     * 注销后,如果认为列表为空,则直接关闭定时器,不进行任何调度
     */
    if ( 0 == lstCount( &g_stPTaskList ) )
    {
        BST_DBG_LOG( "BST_CTaskSchdler::Detach Stop Scheduler Timer" );
        BST_OS_TimerStop ( m_ulTimerId );
    }
}
BST_VOID BST_SYS_MntnRemoveTask(
    BST_UINT16  usType,
    BST_UINT16  usTaskId )
{
    BST_SYS_MNTN_APP_NODE_STRU             *pstAppNode;
    BST_OS_LOCKCNT_T                    tThreadLockCnt;

    if ( !BST_SYS_MNTN_IsMntnInited() )
    {
        return;
    }
    tThreadLockCnt                      = BST_OS_ThreadLock();
    /* 查找链表中是否已经存在该Task信息 */
    for ( pstAppNode = ( BST_SYS_MNTN_APP_NODE_STRU *)lstFirst(BST_SYS_MNTN_GetAppListHead());
          pstAppNode != BST_NULL_PTR;
          pstAppNode = ( BST_SYS_MNTN_APP_NODE_STRU *)lstNext( (NODE *)pstAppNode ) )
    {
        if ( ( usTaskId == pstAppNode->stAppInfo.usTaskId )
          && ( usType == pstAppNode->stAppInfo.usAppType ) )
        {
            break;
        }
    }

    if ( BST_NULL_PTR == pstAppNode )
    {
        BST_OS_ThreadUnLock( tThreadLockCnt );
        return;
    }

    lstDelete( BST_SYS_MNTN_GetAppListHead(), (NODE *)pstAppNode );
    BST_OS_FREE( pstAppNode );
    BST_RLS_LOG3( "[Mntn] Remove Task: TypeId=, TaskId=, Total=",
                  usType, usTaskId, BST_SYS_MNTN_GetAppNumber() );
    BST_SYS_MntnChangedInd();
    BST_OS_ThreadUnLock( tThreadLockCnt );
/*lint -e438*/
}
示例#5
0
int logPushMsg( HLOG hLog, char *pszModule, char *pszFunctionName, int nLine, int nSeverity, int nCode, char *pszMessage )
{
	HLOGMSG		hMsg;
	FILE 		*hFile;

	if ( !hLog ) return LOG_ERROR;
	if ( !hLog->hMessages ) return LOG_ERROR;
	if ( !hLog->bOn ) return LOG_SUCCESS;

	if ( !pszModule ) return LOG_ERROR;
	if ( !pszFunctionName ) return LOG_ERROR;
	if ( !pszMessage ) return LOG_ERROR;


	/* allocate msg */
        if ( hLog->nMaxMsgs > 0 )
	{
		/* check for, and handle, max msg */
		if ( hLog->hMessages->nItems == hLog->nMaxMsgs )
		{
			lstFirst( hLog->hMessages );
			lstDelete( hLog->hMessages );
		}

		hMsg 					= malloc( sizeof(LOGMSG) );
                if (!hMsg) goto error_abort0;

		hMsg->pszModuleName		= (char *)strdup( pszModule );
                if (!hMsg->pszModuleName) goto error_abort1;

		hMsg->pszFunctionName	= (char *)strdup( pszFunctionName );
		if (!hMsg->pszFunctionName) goto error_abort2;

		hMsg->pszMessage		= (char *)strdup( pszMessage );
		if (!hMsg->pszMessage) goto error_abort3;

		hMsg->nLine				= nLine;
		hMsg->nSeverity			= nSeverity;
		hMsg->nCode				= nCode;

		/* append to  list */
		lstAppend( hLog->hMessages, hMsg );
	}

	/* append to file */
	if ( hLog->pszLogFile )
	{
		hFile = uo_fopen( hLog->pszLogFile, "a" );
		if ( !hFile ) return LOG_ERROR;

		uo_fprintf( hFile, "[%s][%s][%s][%d]%s\n", hLog->pszProgramName, pszModule, pszFunctionName, nLine, pszMessage );

		uo_fclose( hFile );
	}

	return LOG_SUCCESS;

        error_abort3:
		free(hMsg->pszFunctionName);
        error_abort2:
		free(hMsg->pszModuleName);
        error_abort1:
		free(hMsg);
        error_abort0:
		return LOG_ERROR;
}
示例#6
0
int logvPushMsgf( HLOG hLog, char *pszModule, char *pszFunctionName, int nLine, int nSeverity, int nCode, char *pszMessageFormat, va_list args )
{
	HLOGMSG		hMsg=NULL;
	FILE 		*hFile;
        int             mlen=0;

	if ( !hLog ) return LOG_ERROR;
	if ( !hLog->hMessages ) return LOG_ERROR;
	if ( !hLog->bOn ) return LOG_SUCCESS;

	if ( !pszModule ) return LOG_ERROR;
	if ( !pszFunctionName ) return LOG_ERROR;
	if ( !pszMessageFormat ) return LOG_ERROR;


	/* allocate msg */
        if ( hLog->nMaxMsgs > 0 )
	{
		/* check for, and handle, max msg */
		if ( hLog->hMessages->nItems == hLog->nMaxMsgs )
		{
			lstFirst( hLog->hMessages );
			lstDelete( hLog->hMessages );
		}

		hMsg 					= malloc( sizeof(LOGMSG) );
                if (!hMsg) goto error_abort0;

		hMsg->pszModuleName		= (char *)strdup( pszModule );
                if (!hMsg->pszModuleName) goto error_abort1;

		hMsg->pszFunctionName	= (char *)strdup( pszFunctionName );
		if (!hMsg->pszFunctionName) goto error_abort2;

#if defined( HAVE_VSNPRINTF )
		mlen=vsnprintf(NULL,0,pszMessageFormat,args);
#else
		mlen=uodbc_vsnprintf(NULL,0,pszMessageFormat,args);
#endif
                mlen++;
		hMsg->pszMessage		= malloc(mlen);
		if (!hMsg->pszMessage) goto error_abort3;

#if defined( HAVE_VSNPRINTF )
		vsnprintf(hMsg->pszMessage,mlen,pszMessageFormat,args);
#else
		uodbc_vsnprintf(hMsg->pszMessage,mlen,pszMessageFormat,args);
#endif

		hMsg->nLine				= nLine;
		hMsg->nSeverity			= nSeverity;
		hMsg->nCode				= nCode;

		/* append to  list */
		lstAppend( hLog->hMessages, hMsg );
	}

	/* append to file */
	if ( hLog->pszLogFile )
	{
		hFile = uo_fopen( hLog->pszLogFile, "a" );
		if ( !hFile ) return LOG_ERROR;

		if (hMsg)
		{
			uo_fprintf( hFile, "[%s][%s][%s][%d]%s\n", hLog->pszProgramName, pszModule, pszFunctionName, nLine, hMsg->pszMessage );
		}
		else
		{
			uo_fprintf( hFile, "[%s][%s][%s][%d]", hLog->pszProgramName, pszModule, pszFunctionName, nLine );
			uo_vfprintf( hFile, pszMessageFormat, args );
			uo_fprintf( hFile, "\n" );
		}

		uo_fclose( hFile );
	}

	return LOG_SUCCESS;

        error_abort3:
		free(hMsg->pszFunctionName);
        error_abort2:
		free(hMsg->pszModuleName);
        error_abort1:
		free(hMsg);
        error_abort0:
		return LOG_ERROR;
}
示例#7
0
void etherInputHookDelete
(
    FUNCPTR inputHook,
    char *pName,
    int unit
)
{
    HOOK_ENTRY *pHookEnt;
    HOOK_ENTRY *pTarget = NULL;

    BOOL unbindFlag = TRUE;    /* Remove handler if hook found? */

    if (pName != NULL)                       /* END case */
    {
        for (pHookEnt = (HOOK_ENTRY *)lstFirst(&inputHookList);
                pHookEnt != NULL;
                pHookEnt = (HOOK_ENTRY *)lstNext(&pHookEnt->node))
        {
            /* Ignore BSD device hook entries. */

            if (pHookEnt->pCookie == NULL)
                continue;

            if (STREQ(pHookEnt->name, pName) && (pHookEnt->unit == unit))
            {
                if (pHookEnt->routine == inputHook)
                {
                    /*
                     * Found matching hook entry to remove. Keep searching
                     * for other hooks on this device if needed.
                     */

                    pTarget = pHookEnt;
                    if (!unbindFlag)    /* Another hook already found? */
                        break;
                }
                else
                {
                    /*
                     * Different hook on same driver - do not unbind.
                     * Stop searching if target hook entry already found.
                     */

                    unbindFlag = FALSE;
                    if (pTarget)
                        break;
                }
            }
        }

        if (pTarget)    /* Remove hook entry if match found. */
        {
            if (unbindFlag)   /* Remove binding if last hook for device. */
            {
                if (muxTkDrvCheck (pName))
                {
                    muxUnbind (pTarget->pCookie, MUX_PROTO_SNARF,
                               nptEtherInputHookRtn);
                }
                else
                {
                    muxUnbind (pTarget->pCookie, MUX_PROTO_SNARF,
                               endEtherInputHookRtn);
                }
            }
            lstDelete (&inputHookList, &pTarget->node);
            free (pTarget);
        }
    }
    else                                     /* 4.4 case */
    {
        for (pHookEnt = (HOOK_ENTRY *)lstFirst(&inputHookList);
                pHookEnt != NULL; pHookEnt = pTarget)
        {
            if (pHookEnt->pCookie)    /* Ignore END device hook entries. */
                continue;

            pTarget = (HOOK_ENTRY *)lstNext(&pHookEnt->node);
            if (pHookEnt->routine == inputHook)
            {
                lstDelete(&inputHookList, &pHookEnt->node);
                free(pHookEnt);
            }
        }
    }

    if (lstCount(&inputHookList) <= 0)
    {
        etherInputHookActive = FALSE;     /* No END driver hooks installed. */
        etherInputHookRtn = NULL;         /* No BSD driver hooks installed. */
        lstFree (&inputHookList);
    }
}
示例#8
0
STATUS hostDelete
    (
    char *name, /* host name or alias */
    char *addr  /* host addr in standard Internet format */
    )
    {
    HOSTNAME *pHostNamePrev;	/* pointer to previous host name entry */
    HOSTNAME *pHostNameNext;	/* pointer to next host name entry */
    FAST HOSTNAME *pHostName;
    FAST HOSTENTRY *pHostEntry;
    struct in_addr netAddr;

    if (name == NULL || addr == NULL)
        {
        errnoSet (S_hostLib_INVALID_PARAMETER);
        return (ERROR);
        }

    /* convert from string to int format */

    if ((netAddr.s_addr = inet_addr (addr)) == ERROR)
	return ERROR;

    semTake (hostListSem, WAIT_FOREVER);

    /* search inet address */

    for (pHostEntry = (HOSTENTRY *)lstFirst (&hostList);
	 pHostEntry != NULL;
	 pHostEntry = (HOSTENTRY *)lstNext (&pHostEntry->node))
        {

	if (pHostEntry->netAddr.s_addr != netAddr.s_addr)
	    continue;

	if (strcmp (pHostEntry->hostName.name, name) == 0)	/* given name is exact match */
	    {
	    FAST HOSTNAME * pAlias = pHostEntry->hostName.link;
	    FAST HOSTNAME * pNext = NULL;

	    /* free all associated alias(es) 1st if any, then free itself */

	    for ( ; pAlias != NULL; pAlias = pNext)
		{
		pNext = pAlias->link;
		KHEAP_FREE(pAlias->name);
		KHEAP_FREE((char *) pAlias);
		}

	    lstDelete (&hostList, &pHostEntry->node);
	    semGive (hostListSem);
	    KHEAP_FREE(pHostEntry->hostName.name);
	    KHEAP_FREE((char *) pHostEntry);
	    return (OK);
	    }
        else 	    /* given name is an alias */
	    {
	    for (pHostNamePrev = pHostName = &pHostEntry->hostName;
		 pHostName != NULL;
		 pHostNamePrev = pHostName, pHostName = pHostName->link)
		{
		pHostNameNext = pHostName->link;

		if (strcmp (pHostName->name, name) == 0)	/* found alias */
		    {
		    pHostNamePrev->link = pHostNameNext;
		    semGive (hostListSem);
		    KHEAP_FREE(pHostName->name);
		    KHEAP_FREE((char *) pHostName);
		    return (OK);
		    }
		}
	    }
	}

    errnoSet (S_hostLib_UNKNOWN_HOST);
    semGive (hostListSem);
    return (ERROR);
    }