📄 pppmuxadapter.c
字号:
if ((pMuxAdptrStackData->bindInfoCache == NULL) || ((cookie = pMuxAdptrStackData->bindInfoCache->cookie) == NULL)) { MUX_FREE_PKT(pMblk); RFC2233_COUNTER_UPDATE(pMuxAdptrStackData->pfwRFC2233CountTest, pMuxAdptrStackData->pfwRFC2233CountPair, M2_ctrId_ifOutDiscards, 1); return ERROR; } /* set the L2SvcType in the reserved field of the packet mBlkHdr */ if ((pMblk->mBlkHdr.reserved = htons(pMuxAdptrProfileData->muxL2SvcType)) == 0x0) status = muxTkSend(cookie, pMblk, pMuxAdptrStackData->destAddr, pMuxAdptrStackData->nboProtocol,NULL); else status = muxSend(cookie, pMblk); if (status == END_ERR_BLOCK) { if (pMuxAdptrStackData->txBlocked != TRUE) { pMuxAdptrStackData->txBlocked = TRUE; sllPutAtTail(&pMuxAdptrStackData->bindInfoCache->txBlockedList, &pMuxAdptrStackData->node); /* raise blocked event to notify INTERFACE_LAYER components */ if (pMuxAdptrStackData->txBlockedEvent != NULL) pfwEventRaise(pComponentState->stackObj, pMuxAdptrStackData->txBlockedEvent, NULL); }#ifdef PPP_DEBUG logMsg ("muxAdptrSend: END_BLOCKED for stackObj 0x%x\n", (unsigned int)pComponentState->stackObj,2,3,4,5,6);#endif MUX_FREE_PKT(pMblk); RFC2233_COUNTER_UPDATE(pMuxAdptrStackData->pfwRFC2233CountTest, pMuxAdptrStackData->pfwRFC2233CountPair, M2_ctrId_ifOutDiscards, 1); return ERROR; } else if (status != OK) { MUX_FREE_PKT(pMblk); RFC2233_COUNTER_UPDATE(pMuxAdptrStackData->pfwRFC2233CountTest, pMuxAdptrStackData->pfwRFC2233CountPair, M2_ctrId_ifOutDiscards, 1); return ERROR; } RFC2233_COUNTER_UPDATE(pMuxAdptrStackData->pfwRFC2233CountTest, pMuxAdptrStackData->pfwRFC2233CountPair, M2_ctrId_ifOutOctets, pktLength); RFC2233_COUNTER_UPDATE(pMuxAdptrStackData->pfwRFC2233CountTest, pMuxAdptrStackData->pfwRFC2233CountPair, M2_ctrId_ifHCOutOctets, pktLength); return OK; }/******************************************************************************** muxAdptrStackDataShow - show profile data** This interface is invoked by the framework in response to a pfwStackDataShow()* The purpose of this routine is to display the stack data in human* readable form** RETURNS: OK on success and ERROR otherwise*/LOCAL STATUS muxAdptrStackDataShow ( PFW_PLUGIN_OBJ_STATE * pComponentState /* our state in this stack */ ) { int i; MUX_ADPTR_BIND_INFO *pBindInfo; MUX_ADPTR_COMPONENT * pComponent = (MUX_ADPTR_COMPONENT *)pComponentState->pluginObj; MUX_ADPTR_PROFILE_DATA * pMuxAdptrProfileData = (MUX_ADPTR_PROFILE_DATA *)pComponentState->profileData; MUX_ADPTR_STACK_DATA * pMuxAdptrStackData = (MUX_ADPTR_STACK_DATA *)pComponentState->stackData; for (i = 0; i < pMuxAdptrProfileData->muxNumSvcs; i++) { pBindInfo = &pComponent->bindInfo[pMuxAdptrStackData->bindInfoIndex[i]]; printf ("%29s[%d] = 0x%x bound to Dev %s:Unit %u\n", "muxSvc",i, (unsigned int)pBindInfo->netSvcType, pBindInfo->devName, (unsigned int)pBindInfo->unitNo); } return OK; }/******************************************************************************** muxAdptrRecvRtn - MUX adapter stack recv callback ** This is the packet receive callback installed when binding to the a* NPT/END device via the mux. This routine is invoked by the MUX in* the context of "tNetTask" when a frame is received by the device* for the protocol identified by netType** RETURNS: TRUE if packet is consumed and FALSE otherwise*/LOCAL BOOL muxAdptrRecvRtn ( void * pCallbackId, /* call back Id */ long netType, /* network service type */ M_BLK_ID pMblk, /* received packet */ void * pSpare /* spare data */ ) { MUX_ADPTR_BIND_INFO * pBindInfo = (MUX_ADPTR_BIND_INFO *)pCallbackId; PFW_STACK_OBJ * stackObj; PFW_PLUGIN_OBJ * owner; PFW_PLUGIN_OBJ_STATE * myState; UINT pktLength; M_BLK_ID auxMblkId; void * cookie; FRAMING_COMPONENT_STACK_RESOLVE_INTERFACE * resolverInterface; PFW_STACK_OBJ * (*stackObjResolver)(PFW_PLUGIN_OBJ *owner, M_BLK_ID frame, ULONG portId); MUX_ADPTR_STACK_DATA * pMuxAdptrStackData; pktLength = 0; auxMblkId = pMblk; while (auxMblkId != NULL) { pktLength += auxMblkId->mBlkHdr.mLen; auxMblkId = auxMblkId->mBlkHdr.mNext; } /* the callback ID if not NULL has the resolver */ if (pBindInfo) { /* reject packets that we dont expect to receive */ cookie = pBindInfo->cookie; if (cookie == NULL || pBindInfo->netSvcType != netType) return FALSE; resolverInterface = (FRAMING_COMPONENT_STACK_RESOLVE_INTERFACE *) pBindInfo->stackObjResolver.interfaceObj; if (resolverInterface == NULL) {#ifdef CANNOT_PROCEED_WITHOUT_RESOLVER_INTERFACE stackObj = NULL;#else if (pBindInfo->stackObjResolver.state == NULL) { return FALSE; } else { /* * without a resolver interface we simply pass the frame * to the stackObj that is recorded in the bindInfo. * * In stackAdd() we've prevented the same protocol from * binding more than once when the resolver interface * is absent so there is no ambiguity here */ stackObj = pBindInfo->stackObjResolver.state->stackObj; }#endif /* CANNOT_PROCEED_WITHOUT_RESOLVER_INTERFACE */ } else { if ((stackObjResolver = resolverInterface->stackResolve) == NULL) return FALSE; owner = resolverInterface->interfaceObj.pluginObj; stackObj = (*stackObjResolver)(owner, pMblk, pBindInfo->portId); } if (stackObj != NULL) { myState = pfwPluginObjStateGet (stackObj, pBindInfo->pluginObj); if (myState != NULL) { pMuxAdptrStackData = (MUX_ADPTR_STACK_DATA *)myState->stackData; RFC2233_COUNTER_UPDATE(pMuxAdptrStackData->pfwRFC2233CountTest, pMuxAdptrStackData->pfwRFC2233CountPair, M2_ctrId_ifInOctets, pktLength); RFC2233_COUNTER_UPDATE(pMuxAdptrStackData->pfwRFC2233CountTest, pMuxAdptrStackData->pfwRFC2233CountPair, M2_ctrId_ifHCInOctets, pktLength); if (pfwReceive (myState, pMblk) == OK) return TRUE; } } } return FALSE; }/******************************************************************************** muxAdptrShutdownRtn - MUX adapter stack shutdown callback ** This is the stack shutdown callback installed when binding to the a* NPT/END device via the mux. This routine is invoked by the MUX * when a device is unloaded from the MUX. Within this routine we* unbind the protocol type contained in the callback Id from the MUX** RETURNS: OK on success and ERROR otherwise*/LOCAL STATUS muxAdptrShutdownRtn ( void * pCallbackId /* call back ID */ ) { MUX_ADPTR_BIND_INFO * pBindInfo = ( MUX_ADPTR_BIND_INFO *)pCallbackId; STATUS status; if (pBindInfo == NULL || pBindInfo->cookie == NULL) return ERROR; status = muxUnbind (pBindInfo->cookie,pBindInfo->netSvcType, muxAdptrRecvRtn); return status; }/******************************************************************************** muxAdptrTxRestartRtn - MUX adapter stack transmission restart callback** This is the transmission restart callback installed when binding to the a* NPT/END device via the mux. This routine is invoked by the MUX * when a device is is ready to transmit again after being temporarily* out of transmit buffers or other resources needed for transmission** RETURNS: OK on success and ERROR otherwise*/LOCAL STATUS muxAdptrTxRestartRtn ( void * pCallbackId /* call back Id */ ) { MUX_ADPTR_BIND_INFO * pBindInfo = ( MUX_ADPTR_BIND_INFO *)pCallbackId; MUX_ADPTR_STACK_DATA * pMuxAdptrStackData; MUX_ADPTR_STACK_DATA * pNextStackData = NULL; BOOL stateLocked; if (pBindInfo == NULL) return ERROR; /* unblock the list of stacks that are blocked on send */ pMuxAdptrStackData = (MUX_ADPTR_STACK_DATA *) SLL_FIRST(&pBindInfo->txBlockedList);#if 0 if (pMuxAdptrStackData == NULL) { logMsg ("MUX_ADPTR: missing reference for stack %p in bind info\ entry\n", (int)pMuxAdptrStackData->state->stackObj,2,3,4,5,6); return ERROR; }#endif while (pMuxAdptrStackData != NULL) { stateLocked = FALSE; if (pfwPluginObjStateLock(pMuxAdptrStackData->state) == OK) { stateLocked = TRUE; pMuxAdptrStackData->txBlocked = FALSE; if (pMuxAdptrStackData->txUnblockedEvent != NULL) pfwEventRaise(pMuxAdptrStackData->state->stackObj, pMuxAdptrStackData->txUnblockedEvent, NULL); } else logMsg("MUX_ADAPTER: Failed to lock state for blocked stack %p\n", (int)pMuxAdptrStackData->state->stackObj,2,3,4,5,6); pNextStackData = (MUX_ADPTR_STACK_DATA *)SLL_NEXT(&pMuxAdptrStackData->node); /* get off the list */ sllRemove(&pBindInfo->txBlockedList, &pMuxAdptrStackData->node,NULL); if (stateLocked == TRUE) pfwPluginObjStateRelease(pMuxAdptrStackData->state); pMuxAdptrStackData = pNextStackData; } return OK; }/******************************************************************************** muxAdptrErrorRtn - MUX adapter stack error report callback** This is the stack error callback installed when binding to the a* NPT/END device via the mux. This routine is invoked by the MUX * when a device or the MUX encounters an error or a change of state * that needs to be reported to all protocols bound to the said device** RETURNS: OK on success and ERROR otherwise*/LOCAL void muxAdptrErrorRtn ( void * pCallbackId, /* call back Id */ END_ERR * endErr /* error code and message */ ) { MUX_ADPTR_BIND_INFO * pBindInfo = (MUX_ADPTR_BIND_INFO *)pCallbackId; PFW_PLUGIN_OBJ_STATE * myState; MUX_ADPTR_PROFILE_DATA * pMuxAdptrProfileData; char * devName; int devUnit; if (pBindInfo == NULL || endErr == NULL) return; if ((myState = pBindInfo->stackObjResolver.state) == NULL) return; pMuxAdptrProfileData = (MUX_ADPTR_PROFILE_DATA *) myState->profileData; devName = pMuxAdptrProfileData->muxDevName; devUnit = pMuxAdptrProfileData->muxDevUnit; switch (endErr->errCode) { case END_ERR_INFO: if (endErr->pMesg != NULL) logMsg ("INFO: Device: %s Unit: %d Msg: %s\n", (int)devName, devUnit, (int)endErr->pMesg, 4, 5, 6); break; case END_ERR_WARN: if (endErr->pMesg != NULL) logMsg ("WARN: Device: %s Unit: %d Msg: %s\n", (int)devName, devUnit, (int)endErr->pMesg, 4, 5, 6); break; case END_ERR_RESET: if (endErr->pMesg != NULL) logMsg ("RESET: Device: %s Unit: %d Msg: %s\n", (int)devName, devUnit, (int)endErr->pMesg, 4, 5, 6); /* TO DO - keep a list of stacks bound and raise event for each */ break; case END_ERR_UP: if (endErr->pMesg != NULL) logMsg ("UP: Device: %s Unit: %d Msg: %s\n", (int)devName, devUnit, (int)endErr->pMesg, 4, 5, 6); /* TO DO - keep a list of stacks bound and raise event for each */ break; case END_ERR_DOWN: if (endErr->pMesg != NULL) logMsg ("DOWN: Device: %s Unit: %d Msg: %s\n", (int)devName, devUnit, (int)endErr->pMesg, 4, 5, 6); /* TO DO - keep a list of stacks bound and raise event for each */ break; case END_ERR_FLAGS: if (endErr->pMesg != NULL) logMsg ("FLAGS CHANGED: Device: %s Unit: %d Msg: %s\n", (int)devName, devUnit, (int)endErr->pMesg, 4, 5, 6); break; default: if (endErr->pMesg != NULL) logMsg ("MESSAGE FROM Device: %s Unit: %d Msg: %s\n", (int)devName, devUnit, (int)endErr->pMesg, 4, 5, 6); break; } }/******************************************************************************** muxAdptrEndRecvRtn - */LOCAL BOOL muxAdptrEndRecvRtn ( void * pCookie, /* EndObj * */ long type, /* network service type */ M_BLK_ID pMblk, /* MAC frame */ LL_HDR_INFO * pLinkHdrInfo, /* link level information */ void * pSpare /* pSpare supplied during muxBind */ ) { if (pSpare == NULL || pLinkHdrInfo == NULL || pCookie == NULL) return FALSE; return (muxAdptrRecvRtn(pSpare,type,pMblk,NULL)); }/******************************************************************************** muxAdptrEndShutdownRtn -*/LOCAL STATUS muxAdptrEndShutdownRtn ( void* cookie, void * pSpare ) { MUX_ADPTR_BIND_INFO * pBindInfo = ( MUX_ADPTR_BIND_INFO *)pSpare; STATUS status; if (pBindInfo == NULL || pBindInfo->cookie == NULL ) return ERROR; /* unbind the protocol */ status = muxUnbind (pBindInfo->cookie,pBindInfo->netSvcType, muxAdptrEndRecvRtn); return status; }/******************************************************************************** muxAdptrEndTxRestartRtn -*/LOCAL STATUS muxAdptrEndTxRestartRtn ( void * cookie, void * pSpare ) { if (pSpare == NULL || cookie == NULL) return ERROR; return (muxAdptrTxRestartRtn(pSpare)); }/******************************************************************************** muxAdptrEndErrorRtn -*/LOCAL void muxAdptrEndErrorRtn ( END_OBJ * cookie, END_ERR *endErr, void * pSpare ) { if (pSpare == NULL || cookie == NULL) return ; muxAdptrErrorRtn(pSpare,endErr); }/******************************************************************************** destAddrAndProtocolSet - set the currently sending protocol and destination*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -