📄 wdbendpktdrv.c
字号:
wdbEndIntError: { /* * drop all non wdb packets received through the poll routine * When call from muxReceive pMode is actually the spare pointer * which is initialized in the NET_PROTOCOL structure, the spare * pointer is passed as the last argument to the stackRcvRtn. * When called from wdbEndPoll it passes a mode in the void pointer * This mode is used to find out whether this routine is called from * wdbEndPoll or muxReceive. You will not be happy camper if the * spare pointer is removed from NET_PROTOCOL or if the stackRcvRtn's * API is changed. */ if (pMode != NULL) if (*((int *)pMode) == WDB_COMM_MODE_POLL) netMblkClFree (pMblk); DRIVER_RESET_INPUT(pPktDev); return (FALSE); } }/******************************************************************************** wdbEndTx - transmit a packet.** The packet is realy a chain of mbufs. We may have to just queue up* this packet is we are already transmitting.** RETURNS: OK or ERROR** NOMANUAL*/STATUS wdbEndTx ( void * pDev, struct mbuf * pMbuf ) { WDB_END_PKT_DEV *pPktDev = pDev; struct mbuf* pFirstMbuf = pMbuf; int len = 0; END_OBJ* pEnd; if (wdbEndDebug) logMsg ("entering send\n", 1, 2, 3, 4, 5, 6); if (pMbuf == NULL) return (ERROR); if (pPktDev->outputBusy) { wdbMbufChainFree(pFirstMbuf); return (EAGAIN); } else pPktDev->outputBusy = TRUE; if (wdbEndDebug) logMsg ("About to enter the copy loop!\n", 1, 2, 3, 4, 5, 6); /* Make sure we know that the outgoing buffer is clean/empty */ pPktDev->pOutBlk->mBlkHdr.mLen = 0; pPktDev->pOutBlk->mBlkHdr.mData = pPktDev->pOutBlk->pClBlk->clNode.pClBuf; /* increment the data pointer so that muxAddressForm can prepend header */ pPktDev->pOutBlk->mBlkHdr.mData += SIZEOF_ETHERHEADER; /* First place the addressing information into the packet. */ muxAddressForm (pPktDev->pCookie, pPktDev->pOutBlk, pPktDev->srcAddr, pPktDev->lastHAddr); len = pPktDev->pOutBlk->mBlkHdr.mLen; if (wdbEndDebug) logMsg ("About to check length!\n", 1, 2, 3, 4, 5, 6); if (len == 0) { wdbMbufChainFree(pFirstMbuf); pPktDev->outputBusy = FALSE; if (wdbEndDebug) logMsg ("Wrong length!\n", 1, 2, 3, 4, 5, 6); return (EAGAIN); } if (wdbEndDebug) logMsg ("hdr length:%d\n", len, 2, 3, 4, 5, 6); pPktDev->pOutBlk->mBlkHdr.mLen = len + netMblkToBufCopy (pMbuf, pPktDev->pOutBlk->mBlkHdr.mData + len, NULL); pPktDev->pOutBlk->mBlkPktHdr.len = pPktDev->pOutBlk->mBlkHdr.mLen; if (wdbEndDebug) logMsg ("OutBlk: %x:%x:%x:%x:%x:%x\n", pPktDev->pOutBlk->mBlkHdr.mData[0], pPktDev->pOutBlk->mBlkHdr.mData[1], pPktDev->pOutBlk->mBlkHdr.mData[2], pPktDev->pOutBlk->mBlkHdr.mData[3], pPktDev->pOutBlk->mBlkHdr.mData[4], pPktDev->pOutBlk->mBlkHdr.mData[5]); if (wdbEndDebug) logMsg ("Data copied !\n", 1, 2, 3, 4, 5, 6); wdbMbufChainFree(pFirstMbuf); if (wdbEndDebug) logMsg("About to send a packet!\n", 1, 2, 3, 4, 5, 6); /* if we are in polled mode, transmit the packet in a loop */ if (pPktDev->mode == WDB_COMM_MODE_POLL) { muxPollSend(pPktDev->pCookie, pPktDev->pOutBlk); if (wdbEndDebug) logMsg("Sent polled packet!\n", 1, 2, 3, 4, 5, 6); } else { if (muxSend(pPktDev->pCookie, pPktDev->pOutBlk) == OK) { if (wdbEndDebug) logMsg("Sent regular packet!\n", 1, 2, 3, 4, 5, 6); pEnd = (END_OBJ *)pPktDev->pCookie; if ((pPktDev->pOutBlk = wdbEndMblkClGet (pEnd, pEnd->mib2Tbl.ifMtu)) == NULL) return (ERROR); } else { if (wdbEndDebug) logMsg("Could not send regular packet!\n", 1, 2, 3, 4, 5, 6); } } wdbEndOutputFree(pPktDev); return (OK); }/******************************************************************************** wdbEndOutputFree - free the output buffer** This is the callback used to let us know the that the device is done with the* output buffer we loaned it.** RETURNS: N/A** NOMANUAL*/LOCAL void wdbEndOutputFree ( void * pDev ) { WDB_END_PKT_DEV * pPktDev = pDev; DRIVER_RESET_OUTPUT(pPktDev); }/******************************************************************************** wdbEndInputFree- free the input buffer** This is the callback used to let us know the agent is done with the* input buffer we loaded it.** RETURNS: N/A** NOMANUAL*/LOCAL void wdbEndInputFree ( void * pDev ) { WDB_END_PKT_DEV * pPktDev = pDev; DRIVER_RESET_INPUT(pPktDev); }/******************************************************************************** wdbEndModeSet - switch driver modes** RETURNS: OK for a supported mode, else ERROR** NOMANUAL*/LOCAL STATUS wdbEndModeSet ( void * pDev, uint_t newMode ) { WDB_END_PKT_DEV * pPktDev = pDev; if (newMode == WDB_COMM_MODE_INT) { muxIoctl (pPktDev->pCookie, EIOCPOLLSTOP, NULL); pPktDev->mode = newMode; return(OK); } else if (newMode == WDB_COMM_MODE_POLL) { muxIoctl (pPktDev->pCookie, EIOCPOLLSTART, NULL); pPktDev->mode = newMode; return(OK); } else return (ERROR); return (ERROR); }/******************************************************************************** wdbEndPoll - poll for a packet** This routine polls for a packet. If a packet has arrived it invokes* the agents callback.** RETURNS: OK if a packet has arrived, else ERROR.** NOMANUAL*/ LOCAL STATUS wdbEndPoll ( void * pDev ) { long type; M_BLK_ID pMblk; WDB_END_PKT_DEV * pPktDev = pDev; LL_HDR_INFO llHdrInfo; int mode = WDB_COMM_MODE_POLL; END_OBJ * pEnd = (END_OBJ*)pPktDev->pCookie; /* Reset the size to the maximum. */ pPktDev->pInBlk->mBlkHdr.mLen = pPktDev->pInBlk->pClBlk->clSize; pPktDev->pInBlk->mBlkHdr.mData = pPktDev->pInBlk->pClBlk->clNode.pClBuf; if (muxPollReceive(pEnd, pPktDev->pInBlk) == OK) { if ((pMblk = mBlkGet(pEnd->pNetPool, M_DONTWAIT, MT_DATA)) == NULL) return (ERROR); /* duplicate the received mBlk so that wdbEndInt can free it */ pMblk = netMblkDup (pPktDev->pInBlk, pMblk); if (muxPacketDataGet(pPktDev->pCookie, pMblk, &llHdrInfo) == ERROR) { return (ERROR); } type = llHdrInfo.pktType; if (wdbEndInt (pPktDev->pCookie, type, pMblk, &llHdrInfo,(void *)&mode) == TRUE) return (OK); return (ERROR); } else { return (ERROR); } }/******************************************************************************** wdbEndMblkClGet - get an mBlk/clBlk/cluster ** This routine returns an mBlk which points to a clBlk which points to a* cluster. This routine allocates the triplet from the pNetPool in the* end object.** RETURNS: M_BLK_ID / NULL** NOMANUAL*/ LOCAL M_BLK_ID wdbEndMblkClGet ( END_OBJ * pEnd, /* endobject in which the netpool belongs */ int size /* size of the cluster */ ) { M_BLK_ID pMblk; if ((pMblk = netTupleGet (pEnd->pNetPool, size, M_DONTWAIT, MT_DATA, FALSE)) == NULL) { if (wdbEndDebug) logMsg("wdbEndMblkClGet:Could not get mBlk...\n", 1, 2, 3, 4, 5, 6); } return (pMblk); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -