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

📄 ntend.c

📁 Tornado 2.0.2 source code!vxworks的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
    void *	pTemp;    M_BLK_ID	pFree;    M_BLK_ID	pChunk;    int 	count;    int		chunk;#endif    /*      * ETHERMTU is not enough to be the buffer size (SPR #31983).     * From the test case 1534 is the maximal value, this value is 54 + 1480     * where 54 is the header sizes and 1480 the remaining size deduced from     * the MTU (that should be constant with ULIP).      */    char 	copyBuf[1600];      /*     * This is the vector processing section.     * A vector is an array of M_BLK_IDs pointed to by the pData     * field of a lead M_BLK_ID.  The lead is what is passed down     * as pNBuff.  The length field of the head M_BLK_ID is the number     * of elements in the array.     * Each M_BLK_ID that is actually in the array has a pData field     * that points to the actual data as well as a length that gives the     * amount of data that is pointed to.     * Each M_BLK_ID in the array has its own free routine and arguments.     */#if FALSE /* XXX cym fix Me */    if (pNBuff->type & END_BUF_VECTOR)	{        if (!(pDrvCtrl->flags & NT_POLLING))            oldLevel = intLock ();     /* disable ints during update */	for (chunk = 0;chunk < pNBuff->length; chunk++)	    {	    pChunk = pChunk->m_next;            /*	     * Place packets into local structures.             * If there is an error remember to free ALL associated             * M_BLK_ID data before returning.	     */            	    /* place a transmit request */	    len = netMblkToBufCopy (pNBuff, (char *)copyBuf, NULL);	    len = max(len,ETHERSMALL);	    simUlipWrite (copyBuf, len);	    /* Advance our management index */            }        if (!(pDrvCtrl->flags & NT_POLLING))            intUnlock (oldLevel);   /* now ntInt won't get confused */        }    /* This is the normal case where all the data is in one M_BLK_ID */    else#endif /* FALSE XXX cym Fix ME */	{        /* Set pointers in local structures to point to data. */        if (!(pDrvCtrl->flags & NT_POLLING))	    {	    oldLevel = intLock ();     /* disable ints during update */	    }	/* place a transmit request */	len = netMblkToBufCopy (pNBuff, (char *)copyBuf, NULL);	len = max(len,ETHERSMALL);	simUlipWrite (copyBuf,len);        netMblkClChainFree (pNBuff);	if (!(pDrvCtrl->flags & NT_POLLING))	    {	    intUnlock (oldLevel);   /* now ntInt won't get confused */	    }	/* Advance our management index */	}    /* Bump the statistic counter. */    END_ERR_ADD (&pDrvCtrl->end, MIB2_OUT_UCAST, +1);    return (OK);    }/********************************************************************************* ntIoctl - the driver I/O control routine** Process an ioctl request.*/LOCAL int ntIoctl    (    NTEND_DEVICE *pDrvCtrl,    int cmd,    caddr_t data    )    {    int error = 0;    long value;    switch (cmd)        {        case EIOCSADDR:	    if (data == NULL)		return (EINVAL);            bcopy ((char *)data, (char *)END_HADDR(&pDrvCtrl->end),		   END_HADDR_LEN(&pDrvCtrl->end));            break;        case EIOCGADDR:	    if (data == NULL)		return (EINVAL);            bcopy ((char *)END_HADDR(&pDrvCtrl->end), (char *)data,		    END_HADDR_LEN(&pDrvCtrl->end));            break;        case EIOCSFLAGS:	    value = (long)data;	    if (value < 0)		{		value = -value;		value--;		END_FLAGS_CLR (&pDrvCtrl->end, value);		}	    else		{		END_FLAGS_SET (&pDrvCtrl->end, value);		}	    ntConfig (pDrvCtrl);            break;        case EIOCGFLAGS:	    *(int *)data = END_FLAGS_GET(&pDrvCtrl->end);            break;	case EIOCPOLLSTART:	    ntPollStart (pDrvCtrl);	    break;	case EIOCPOLLSTOP:	    ntPollStop (pDrvCtrl);	    break;        case EIOCGMIB2:            if (data == NULL)                return (EINVAL);            bcopy((char *)&pDrvCtrl->end.mib2Tbl, (char *)data,                  sizeof(pDrvCtrl->end.mib2Tbl));            break;        case EIOCGFBUF:            if (data == NULL)                return (EINVAL);            *(int *)data = 100; /* XXX cym macro-ize me */            break;        default:            error = EINVAL;        }    return (error);    }/******************************************************************************** ntConfig - reconfigure the interface under us.** Reconfigure the interface setting promiscuous mode, and changing the* multicast interface list.** NOMANUAL*/LOCAL void ntConfig    (    NTEND_DEVICE *pDrvCtrl    )    {#if FALSE    u_short stat;    void* pTemp;    int timeoutCount = 0;    int ix;#endif    /* Set promiscuous mode if it's asked for. */    if (END_FLAGS_GET(&pDrvCtrl->end) & IFF_PROMISC)	{	}    else	{	}    /* Set up address filter for multicasting. */	    if (END_MULTI_LST_CNT(&pDrvCtrl->end) > 0)	{	ntAddrFilterSet (pDrvCtrl);	}    /* TODO - shutdown device completely */    /* TODO - reset all device counters/pointers, etc. */    /* TODO - initialise the hardware according to flags */    return;    }/******************************************************************************** ntAddrFilterSet - set the address filter for multicast addresses** This routine goes through all of the multicast addresses on the list* of addresses (added with the endAddrAdd() routine) and sets the* device's filter correctly.** NOMANUAL*/void ntAddrFilterSet    (    NTEND_DEVICE *pDrvCtrl    )    {    ETHER_MULTI* pCurr;    pCurr = END_MULTI_LST_FIRST (&pDrvCtrl->end);    while (pCurr != NULL)	{        /* TODO - set up the multicast list */        	pCurr = END_MULTI_LST_NEXT(pCurr);	}    }/********************************************************************************* ntPollRcv - routine to receive a packet in polled mode.** This routine is called by a user to try and get a packet from the* device.*/LOCAL STATUS ntPollRcv    (    NTEND_DEVICE *pDrvCtrl,    M_BLK_ID pNBuff    )    {    int len;    /* TODO - If no packet is available return immediately */    /* see if any received packets haven't been read by the ISR */    if(simUlipReadCount==simUlipRcvCount) 	return(EAGAIN);    winOut ("Can't do polled mode right now \n");    return(ERROR);    /* Upper layer must provide a valid buffer. */    if (pNBuff->mBlkHdr.mData == NULL || pNBuff->mBlkHdr.mLen < len)	{	return (EAGAIN);	}    /* TODO - clear any status bits that may be set. */    /* TODO - Check packet and device for errors */    END_ERR_ADD (&pDrvCtrl->end, MIB2_IN_UCAST, +1);    /* TODO - Process device packet into net buffer */    /* TODO - Done with packet, clean up and give it to the device. */    return (OK);    }/********************************************************************************* ntPollSend - routine to send a packet in polled mode.** This routine is called by a user to try and send a packet on the* device.*/static STATUS ntPollSend    (    NTEND_DEVICE* pDrvCtrl,    M_BLK_ID pMblk     )    {    int         len;    char	copyBuf[ETHERMTU];    len = netMblkToBufCopy (pMblk, (char *)copyBuf, NULL);    len = max(len,ETHERSMALL);    simUlipWrite (copyBuf,len);    END_ERR_ADD (&pDrvCtrl->end, MIB2_OUT_UCAST, +1);    return (OK);    }/********************************************************************************* ntStop - stop the device** This function calls BSP functions to disconnect interrupts and stop* the device from operating in interrupt mode.** RETURNS: OK or ERROR*/LOCAL STATUS ntStop    (    NTEND_DEVICE *pDrvCtrl    )    {    STATUS result = OK;    /* TODO - stop/disable the device. */    /* XXX cym toggle the fake driver */    simUlipAlive = 0;    return (result);    }/******************************************************************************** ntUnload - unload a driver from the system** This function first brings down the device, and then frees any* stuff that was allocated by the driver in the load function.*/LOCAL STATUS ntUnload    (    NTEND_DEVICE* pDrvCtrl    )    {    simUlipAlive = 0;    END_OBJECT_UNLOAD (&pDrvCtrl->end); /* generic end unload functions */    /* TODO - Free any shared DMA memory */    return (OK);    }/********************************************************************************* ntPollStart - start polled mode operations** RETURNS: OK or ERROR.*/STATUS ntPollStart    (    NTEND_DEVICE* pDrvCtrl    )    {    int         oldLevel;    oldLevel = intLock ();          /* disable ints during update */    pDrvCtrl->flags |= NT_POLLING;    intUnlock (oldLevel);   /* now ntInt won't get confused */    ntConfig (pDrvCtrl);	/* reconfigure device */    return (OK);    }/********************************************************************************* ntPollStop - stop polled mode operations** This function terminates polled mode operation.  The device returns to* interrupt mode.** The device interrupts are enabled, the current mode flag is switched* to indicate interrupt mode and the device is then reconfigured for* interrupt operation.** RETURNS: OK or ERROR.*/STATUS ntPollStop    (    NTEND_DEVICE* pDrvCtrl    )    {    int         oldLevel;    oldLevel = intLock ();	/* disable ints during register updates */    /* TODO - re-enable interrupts */    pDrvCtrl->flags &= ~NT_POLLING;    intUnlock (oldLevel);    ntConfig (pDrvCtrl);    return (OK);    }/******************************************************************************* ntMCastAdd - add a multicast address for the device** This routine adds a multicast address to whatever the driver* is already listening for.  It then resets the address filter.*/LOCAL STATUS ntMCastAdd    (    NTEND_DEVICE *pDrvCtrl,    char* pAddress    )    {    int error;    if ((error = etherMultiAdd (&pDrvCtrl->end.multiList,		pAddress)) == ENETRESET)	ntConfig (pDrvCtrl);    return (OK);    }/******************************************************************************* ntMCastDel - delete a multicast address for the device** This routine removes a multicast address from whatever the driver* is listening for.  It then resets the address filter.*/LOCAL STATUS ntMCastDel    (    NTEND_DEVICE* pDrvCtrl,    char* pAddress    )    {    int error;    if ((error = etherMultiDel (&pDrvCtrl->end.multiList,	     (char *)pAddress)) == ENETRESET)	ntConfig (pDrvCtrl);    return (OK);    }/******************************************************************************* ntMCastGet - get the multicast address list for the device** This routine gets the multicast list of whatever the driver* is already listening for.*/LOCAL STATUS ntMCastGet    (    NTEND_DEVICE* pDrvCtrl,    MULTI_TABLE* pTable    )    {    int error;    error = etherMultiGet (&pDrvCtrl->end.multiList, pTable);    return (error);    }/********************************************************************************* ntInt - handle controller interrupt** This routine is called at interrupt level in response to an interrupt from* the controller.** RETURNS: N/A.*/void ntInt    (    NTEND_DEVICE  *pDrvCtrl    )    {    /* Have netTask handle any input packets */    netJobAdd ((FUNCPTR)ntHandleRcvInt, (int)pDrvCtrl,               (int)simUlipRcvBuffer, (int)simUlipRcvLen, 0, 0);    }int ntResolv   (   FUNCPTR           ipArpCallBackRtn,   struct mbuf *     pMbuf,   struct sockaddr * dstIpAddr,   struct ifnet *    ifp,   struct rtentry *  rt,   char *            dstBuff   )   {   return (ntArpResolv ((struct arpcom *)ifp, rt, pMbuf, dstIpAddr, dstBuff));   }static int ntArpResolv    (    struct arpcom *	ap,    struct rtentry *	rt,    struct mbuf *	m,    struct sockaddr *	dst,    unsigned char *	desten    )    {    * (desten) = 0;    * (desten+1) = 0;    * (desten+2) = 0;    * (desten+3) = 0;    * (desten+4) = 0;    * (desten+5) = 254;    return(1);    }

⌨️ 快捷键说明

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