📄 muxlib.c
字号:
) { int error; END_OBJ * pEnd; LL_HDR_INFO llHdrInfo; long type; NET_PROTOCOL * pOut; pEnd = PCOOKIE_TO_ENDOBJ (pCookie); if (pEnd == NULL) { errnoSet (S_muxLib_NO_DEVICE); error = ENETDOWN; } else { if (pEnd->outputFilter) { pOut = pEnd->outputFilter; if (muxPacketDataGet (pCookie, pNBuff, &llHdrInfo) == ERROR) return (ERROR); type = llHdrInfo.pktType; if (pOut->stackRcvRtn (pOut->pNptCookie, type, pNBuff, &llHdrInfo, pEnd->pOutputFilterSpare) == TRUE) { return (OK); } } error = pEnd->pFuncTable->pollSend (pEnd, pNBuff); } return (error); }/****************************************************************************** * muxPollReceive - now 'deprecated', see muxTkPollReceive()** NOTE: This routine has been deprecated in favor of muxTkPollReceive()** Upper layers can call this routine to poll for a packet.** .IP <pCookie>* Expects the cookie that was returned from muxBind().* This cookie indicates which driver to query for available data.** .IP <pNBuff>* Expects a pointer to a buffer chain into which to receive data.** VXWORKS AE PROTECTION DOMAINS* Under VxWorks AE, you can call muxPollReceive() from within the kernel * protection domain only, and the data referenced in the <pCookie> and * <pNBuff> parameters must reside in the kernel protection domain. * This restriction does not apply under non-AE versions of VxWorks. ** RETURNS: OK; ENETDOWN, if the <pCookie> argument does not represent a * loaded driver; or an error value returned from the driver's registered * endPollReceive() function.** ERRNO: S_muxLib_NO_DEVICE*/STATUS muxPollReceive ( void * pCookie, /* binding instance from muxBind() */ M_BLK_ID pNBuff /* a vector of buffers passed to us */ ) { int error; END_OBJ * pEnd; pEnd = PCOOKIE_TO_ENDOBJ (pCookie); if (pEnd == NULL) { errnoSet(S_muxLib_NO_DEVICE); error = ENETDOWN; } else { error = pEnd->pFuncTable->pollRcv (pEnd, pNBuff); } return (error); }/******************************************************************************** muxIoctl - send control information to the MUX or to a device** This routine gives the service access to the network driver's control * functions. The MUX itself can implement some of the standard control* functions, so not all commands necessarily pass down to the device. * Otherwise, both command and data pass to the device without modification.** Typical uses of muxIoctl() include commands to start, stop, or reset the* network interface, or to add or configure MAC and network addresses.** .IP <pCookie>* Expects the cookie returned from muxBind() or muxTkBind(). This* cookie indicates the device to which this service is bound. * .IP <cmd>* Expects a value indicating the control command you want to execute. * For valid <cmd> values, see the description of the endIoctl() and* nptIoctl() routines provided in the* .I "Network Protocol Toolkit Programmer's Guide".* .IP <data>* Expects the data or a pointer to the data needed to carry out the command* specified in <cmd>. * * VXWORKS AE PROTECTION DOMAINS* Under VxWorks AE, you can call muxIoctl() from within the kernel * protection domain only, and the data referenced in the <pCookie> and * <data> parameters must reside in the kernel protection domain. * This restriction does not apply under non-AE versions of VxWorks. ** RETURNS: OK; ENETDOWN, if <pCookie> does not represent a bound device;* or ERROR, if the command fails.** ERRNO: S_muxLib_NO_DEVICE*/STATUS muxIoctl ( void * pCookie, /* service/device binding from muxBind()/muxTkBind() */ int cmd, /* command to pass to ioctl */ caddr_t data /* data need for command in cmd */ ) { int error; END_OBJ * pEnd; IF_SETENTRY * pIfSetentry; UINT32 endFlags = 0; /* Current flag settings (before any change). */ pEnd = PCOOKIE_TO_ENDOBJ (pCookie); if (pEnd == NULL) { errnoSet (S_muxLib_NO_DEVICE); error = ENETDOWN; } else { switch ((u_int) cmd) { case EIOCMULTIADD: error = pEnd->pFuncTable->mCastAddrAdd (pEnd, (char *)data); break; case EIOCMULTIDEL: error = pEnd->pFuncTable->mCastAddrDel (pEnd, (char *)data); break; case EIOCMULTIGET: error = pEnd->pFuncTable->mCastAddrGet (pEnd, (MULTI_TABLE *)data); break; case EIOCGMCASTLIST: *(LIST **)data = &pEnd->multiList; error = OK; break; case EIOCSMIB2233: { pIfSetentry = (IF_SETENTRY *)data; /* check the four possible IF variable to set */ if (pIfSetentry->varToSet & M2_varId_ifAdminStatus) { if (pEnd->flags & END_MIB_2233) { if ((pEnd->pMib2Tbl != NULL) && (pEnd->pMib2Tbl->m2VarUpdateRtn != NULL)) { pEnd->pMib2Tbl->m2VarUpdateRtn(pEnd->pMib2Tbl, M2_varId_ifAdminStatus, (void *)pIfSetentry->ifAdminStatus); pEnd->pMib2Tbl->m2VarUpdateRtn(pEnd->pMib2Tbl, M2_varId_ifOperStatus, (void *)pIfSetentry->ifAdminStatus); } } else /* (RFC1213 style of counters supported) XXX */ { pEnd->mib2Tbl.ifAdminStatus = pIfSetentry->ifAdminStatus; pEnd->mib2Tbl.ifOperStatus = pIfSetentry->ifAdminStatus; } } if ((pEnd->flags & END_MIB_2233) && (pEnd->pMib2Tbl != NULL) && (pEnd->pMib2Tbl->m2VarUpdateRtn != NULL) && (pIfSetentry->varToSet & M2_varId_ifLinkUpDownTrapEnable)) { pEnd->pMib2Tbl->m2VarUpdateRtn(pEnd->pMib2Tbl, M2_varId_ifLinkUpDownTrapEnable, (void *)pIfSetentry->ifLinkUpDownTrapEnable); } if ((pEnd->flags & END_MIB_2233) && (pEnd->pMib2Tbl != NULL) && (pEnd->pMib2Tbl->m2VarUpdateRtn != NULL) && (pIfSetentry->varToSet & M2_varId_ifPromiscuousMode)) { pEnd->pMib2Tbl->m2VarUpdateRtn(pEnd->pMib2Tbl, M2_varId_ifLinkUpDownTrapEnable, (void *)pIfSetentry->ifLinkUpDownTrapEnable); } if ((pEnd->flags & END_MIB_2233) && (pEnd->pMib2Tbl != NULL) && (pEnd->pMib2Tbl->m2VarUpdateRtn != NULL) && (pIfSetentry->varToSet & M2_varId_ifAlias)) { pEnd->pMib2Tbl->m2VarUpdateRtn(pEnd->pMib2Tbl, M2_varId_ifAlias, (void *)pIfSetentry->ifAlias); } error = OK; break; } case EIOCSFLAGS: endFlags = pEnd->flags; /* fall-through */ default: error = pEnd->pFuncTable->ioctl (pEnd, cmd, data); break; } /* All services must be notified if the device flags change. */ if (cmd == (int) EIOCSFLAGS && error == OK && (endFlags ^ pEnd->flags)) { netJobAdd ( (FUNCPTR)muxEndFlagsNotify, (int)pCookie, (int)pEnd->flags, 0, 0, 0); } } return (error); }#ifndef STANDALONE_AGENT/******************************************************************************** muxMCastAddrAdd - add a multicast address to a device's multicast table ** This routine adds an address to the multicast table maintained by a device. * This routine calls the driver's endMCastAddrAdd() or nptMCastAddrAdd()* routine to accomplish this.* * If the device does not support multicasting, muxMCastAddrAdd() will return* ERROR and 'errno' will be set to ENOTSUP (assuming the driver has been* written properly).** .IP <pCookie> 13* Expects the cookie returned from the muxBind() or muxTkBind() call. This* cookie identifies the device to which the MUX has bound this service. ** .IP <pAddress>* Expects a pointer to a character string containing the address you * want to add. * * VXWORKS AE PROTECTION DOMAINS* Under VxWorks AE, you can call muxMCastAddrAdd() from within the kernel * protection domain only, and the data referenced in the <pCookie> * parameter must reside in the kernel protection domain. * This restriction does not apply under non-AE versions of VxWorks. ** RETURNS: OK; ENETDOWN, if <pCookie> does not represent a valid device;* or ERROR, if the device's endMCastAddrAdd() function fails.** ERRNO: S_muxLib_NO_DEVICE**/STATUS muxMCastAddrAdd ( void * pCookie, /* binding instance from muxBind() or muxTkBind() */ char * pAddress /* address to add to the table */ ) { int error; END_OBJ * pEnd; pEnd = PCOOKIE_TO_ENDOBJ (pCookie); if (pEnd == NULL) { errnoSet (S_muxLib_NO_DEVICE); error = ENETDOWN; } else { error = pEnd->pFuncTable->mCastAddrAdd (pEnd, pAddress); } return (error); }/******************************************************************************** muxMCastAddrDel - delete a multicast address from a device's multicast table** This routine deletes an address from the multicast table maintained by a * device by calling that device's endMCastAddrDel() or nptMCastAddrDel()* routine.** If the device does not support multicasting, muxMCastAddrAdd() will return* ERROR and 'errno' will be set to ENOTSUP (assuming the driver has been* written properly).** .IP <pCookie> 13* Expects the cookie returned from muxBind() or muxTkBind() call. This* cookie identifies the device to which the MUX bound this service. * .IP <pAddress>* Expects a pointer to a character string containing the address you * want to delete. ** VXWORKS AE PROTECTION DOMAINS* Under VxWorks AE, you can call muxMCastAddrDell() from within the kernel * protection domain only, and the data referenced in the <pCookie> * parameter must reside in the kernel protection domain. * This restriction does not apply under non-AE versions of VxWorks. ** RETURNS: OK; ENETDOWN, if <pCookie> does not represent a valid driver;* or ERROR, if the driver's registered endMCastAddrDel() or nptMCastAddrDel() * functions fail.** ERRNO: S_muxLib_NO_DEVICE*/STATUS muxMCastAddrDel ( void * pCookie, /* binding instance from muxBind() or muxTkBind() */ char * pAddress /* Address to delete from the table. */ ) { int error; END_OBJ * pEnd; pEnd = PCOOKIE_TO_ENDOBJ (pCookie); if (pEnd == NULL) { errnoSet (S_muxLib_NO_DEVICE); error = ENETDOWN; } else { error = pEnd->pFuncTable->mCastAddrDel (pEnd, pAddress); } return (error); }/******************************************************************************** muxMCastAddrGet - get the multicast address table from the MUX/Driver** This routine writes the list of multicast addresses for a specified* device into a buffer. To get this list, it calls the driver's own* endMCastAddrGet() or nptMCastAddrGet() routine. ** .IP <pCookie>* Expects the cookie returned from muxBind() or muxTkBind()* call. This cookie indicates the device to which the MUX* has bound this service. * .IP <pTable>* Expects a pointer to a MULTI_TABLE structure. You must have allocated * this structure at some time before the call to muxMCastAddrGet(). * The MULTI_TABLE structure is defined in end.h as: * * .CS* typedef struct multi_table* {* int tableLen; /@ length of table in bytes @/* char * pTable; /@ pointer to entries @/* } MULTI_TABLE;* .CE** VXWORKS AE PROTECTION DOMAINS* Under VxWorks AE, you can call muxMCastAddrGet() from within the kernel * protection domain only, and the data referenced in the <pCookie> * parameter must reside in the kernel protection domain. * This restriction does not apply under non-AE versions of VxWorks. *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -