📄 pppmuxadapter.c
字号:
void * pSpare ) { if (pSpare == NULL || cookie == NULL) return ; muxAdptrErrorRtn(pSpare,endErr); }/******************************************************************************** destAddrAndProtocolSet - set the currently sending protocol and destination**/LOCAL STATUS destAddrAndProtocolSet ( PFW_PLUGIN_OBJ_STATE * pComponentState, char * destAddr, UINT32 addrLength, char * protocol, UINT32 protocolLength ) { 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; int slot; UINT32 setProtocol; UINT32 nboProtocol; /* network byte order protocol */ int i; /* * when using L2SvcType we always send Layer 2 frames using the bind cookie * obtained upon binding L2SvcType so we do not need Layer 2 destination * address and Layer 3 protocol type */ if (pMuxAdptrProfileData->muxL2SvcType != 0x0) { return ERROR; } if (protocolLength == sizeof(UINT16)) { setProtocol = *(UINT16 *)protocol; nboProtocol = htons(setProtocol); } else if (protocolLength == sizeof(UINT32)) { setProtocol = *(UINT32*)protocol; nboProtocol = htonl(setProtocol); } else return ERROR; for (i = 0; i < pMuxAdptrProfileData->muxNumSvcs; i++) { if (setProtocol == pMuxAdptrProfileData->muxSvcType[i]) break; } if (i >= pMuxAdptrProfileData->muxNumSvcs) return ERROR; slot = pMuxAdptrStackData->bindInfoIndex[i]; pMuxAdptrStackData->bindInfoCache = &pComponent->bindInfo[slot]; pMuxAdptrStackData->nboProtocol = nboProtocol; if (addrLength == pMuxAdptrStackData->destAddrLen) { if (pMuxAdptrStackData->destAddr == NULL) pMuxAdptrStackData->destAddr = pfwMalloc(pComponentState->pluginObj->pfwObj, addrLength); } else { if (pMuxAdptrStackData->destAddr) pfwFree(pMuxAdptrStackData->destAddr); pMuxAdptrStackData->destAddr = pfwMalloc(pComponentState->pluginObj->pfwObj, addrLength); pMuxAdptrStackData->destAddrLen = addrLength; } bcopy(destAddr,pMuxAdptrStackData->destAddr,addrLength); return OK; }/******************************************************************************** adapterPortIdGet - get the portId from the stackData**/LOCAL STATUS adapterPortIdGet ( PFW_PLUGIN_OBJ_STATE * pAdapterState, /* pointer to plugin-obj state */ ULONG * pPortId /* pointer to portId */ ) { MUX_ADPTR_STACK_DATA * pMuxAdptrStackData = (MUX_ADPTR_STACK_DATA *)pAdapterState->stackData; (*pPortId) = pMuxAdptrStackData->portId; return OK; }/******************************************************************************** muxAdptr_muxDevName - muxDevName profile parameter handler*** RETURNS: OK on success and ERROR otherwise*/LOCAL STATUS muxAdptr_muxDevName ( PFW_OBJ * pfw, PFW_PARAMETER_OPERATION_TYPE operType, /* operation type */ void * pProfileData, /* profile data bucket */ char * value /* value for this parameter */ ) { MUX_ADPTR_PROFILE_DATA * pMuxAdptrData = (MUX_ADPTR_PROFILE_DATA *)pProfileData; if (operType == PFW_PARAMETER_SET) { /* simply copy the value */ strcpy(pMuxAdptrData->muxDevName,value); return OK; } else if (operType == PFW_PARAMETER_GET) { strcpy (value,pMuxAdptrData->muxDevName); return OK; } return ERROR; }/******************************************************************************** muxAdptr_muxDevUnit - muxDevUnit profile parameter handler*** RETURNS: OK on success and ERROR otherwise*/LOCAL STATUS muxAdptr_muxDevUnit ( PFW_OBJ *pfw, PFW_PARAMETER_OPERATION_TYPE operType, /* operation type */ void * pProfileData, /* profile data bucket */ char * value /* value for this parameter */ ) { MUX_ADPTR_PROFILE_DATA * pMuxAdptrData = (MUX_ADPTR_PROFILE_DATA *)pProfileData; if (operType == PFW_PARAMETER_SET) { /* convert from ascii */ pMuxAdptrData->muxDevUnit = atoi((const char *)value); return OK; } else if (operType == PFW_PARAMETER_GET) { sprintf(value,"%d",pMuxAdptrData->muxDevUnit); return OK; } return ERROR; }/******************************************************************************** muxAdptr_muxSvcType - muxSvcType profile parameter handler*** RETURNS: OK on success and ERROR otherwise*/LOCAL STATUS muxAdptr_muxSvcType ( PFW_OBJ * pfw, PFW_PARAMETER_OPERATION_TYPE operType, /* operation type */ void * pProfileData, /* profile data bucket */ char * value /* value for this parameter */ ) { MUX_ADPTR_PROFILE_DATA * pMuxAdptrData = (MUX_ADPTR_PROFILE_DATA *)pProfileData; int protocols; char * tok; /* token */ char * holder=NULL; /* points to fragment beyond tok */ char valueString[128]; if (operType == PFW_PARAMETER_SET) { /* * parse the string and retrieve protocol numbers separated by ':' and * associated flags separated by "," */ bzero(valueString,sizeof(valueString)); strcpy (valueString, value); /* get the service numbers upto a maximum of MAX_MUX_ADPTR_SERVICES */ for (protocols = 0; protocols < MAX_MUX_ADPTR_SERVICES;) { /* get the protocol type */ tok = strtok_r(((protocols == 0) ? valueString : NULL), ":", &holder); if (tok == NULL) {#ifdef OK_TO_HAVE_NO_PROTOCOLS if (protocols == 0) { /* must have atleast one protocol */ return ERROR; } else#endif /* OK_TO_HAVE_NO_PROTOCOLS */ break; } else { pMuxAdptrData->muxSvcType[protocols++] = strtoul(tok, NULL, 16); } } /* record the number of protocols */ pMuxAdptrData->muxNumSvcs = protocols; return OK; } else if (operType == PFW_PARAMETER_GET) { for (protocols = 0; protocols < pMuxAdptrData->muxNumSvcs; protocols ++) { sprintf (value, "0x%x:", pMuxAdptrData->muxSvcType[protocols]); value += strlen(value); } return OK; } return ERROR; }/******************************************************************************** muxAdptr_muxL2SvcType - muxL2SvcType parameter handler*** RETURNS: OK on success and ERROR otherwise*/LOCAL STATUS muxAdptr_muxL2SvcType ( PFW_OBJ * pfw, PFW_PARAMETER_OPERATION_TYPE operType, /* operation type */ void * pProfileData, /* profile data bucket */ char * value /* value for this parameter */ ) { MUX_ADPTR_PROFILE_DATA * pMuxAdptrData = (MUX_ADPTR_PROFILE_DATA *)pProfileData; if (operType == PFW_PARAMETER_SET) { if (value == NULL) return ERROR; pMuxAdptrData->muxL2SvcType= strtoul(value, NULL, 16); return OK; } else if (operType == PFW_PARAMETER_GET) { sprintf (value, "0x%x",pMuxAdptrData->muxL2SvcType); return OK; } return ERROR; }/******************************************************************************** muxAdptrBindInfoFind - reserve a slot for bind information ** This routine reserves a slot in the bindInfo table if the said protocol* is not already bound to the specified device and unit number.** If no previous bind record exists this routine returns the next available* slot** RETURNS: index to the entry if successful and -1 otherwise*/LOCAL int muxAdptrBindInfoFind ( MUX_ADPTR_COMPONENT * pComponent, char * devName, int unit, int netSvcType ) { int i; int freeSlot = -1; void * cookie; if (devName == NULL) return ERROR; /* * search the list for an existing entry; save the index for the * first available slot in the list */ for (i = 0; i < pComponent->muxMaxBinds; i++) { /* match device name, unit # and svc type */ if ((cookie = pComponent->bindInfo[i].cookie) == NULL) { if (freeSlot == -1) { /* * Save this slot for now. Continue searching in case * there is already an existing entry elsewhere in the * table. * */ freeSlot = i; } continue; } /* * we dont want to rely on the mux cookie to provide the devName, * unitNo and the netSvcType information, hence commenting the * two lines below. */ /* if (muxId->pEnd == NULL) continue; */ if ( !strcmp (pComponent->bindInfo[i].devName, devName) && (pComponent->bindInfo[i].unitNo == unit) && (pComponent->bindInfo[i].netSvcType == netSvcType)) { /* already exists */ return (i); } } /* return an index to the free slot if it is available */ if (freeSlot == -1) { /* no available slots */ freeSlot = pComponent->muxMaxBinds; } return (freeSlot); }/******************************************************************************** muxAdptrBindInfoClear - clear the bind information** This routine decrements the ref count for said bind info entry and marks* the slot available when ref count reaches 0** RETURNS: OK when successful and error if no entry exists */LOCAL STATUS muxAdptrBindInfoClear ( MUX_ADPTR_BIND_INFO * pBindInfo, MUX_ADPTR_STACK_DATA * pMuxAdptrStackData ) { BOOL nptDrv; MUX_ADPTR_STACK_DATA * pNextStackData; SL_NODE * previous; if (pBindInfo == NULL) return ERROR; /* remove reference to stack from txBlocked list */ pNextStackData = (MUX_ADPTR_STACK_DATA *) SLL_FIRST(&pBindInfo->txBlockedList); previous = NULL; while (pNextStackData != NULL && pNextStackData != pMuxAdptrStackData) { previous = &pNextStackData->node; pNextStackData =(MUX_ADPTR_STACK_DATA *)SLL_NEXT(&pNextStackData->node); } if (pNextStackData != NULL) sllRemove(&pBindInfo->txBlockedList, &pNextStackData->node,previous); if (--pBindInfo->refCount == 0) { nptDrv = muxTkDrvCheck(pBindInfo->devName); if (nptDrv) muxAdptrShutdownRtn((void *)pBindInfo); else muxAdptrEndShutdownRtn(NULL,(void *)pBindInfo); bzero((void *)pBindInfo, sizeof (MUX_ADPTR_BIND_INFO)); } return OK; }#if 0/******************************************************************************** muxAdptrCtrlJobRtn - submit a receive ***/LOCAL void muxAdptrCtrlJobRtn ( void * data ) { }#endif/******************************************************************************** muxPPPAttributesEventHandler -** This routine collects ppp attriubtes**/LOCAL STATUS muxPPPAttributesEventHandler ( PFW_PLUGIN_OBJ_STATE * state, void *eventData ) { int id; PFW_INTERFACE_STATE_PAIR phyPortStatePair; PHY_PORT_INTERFACE *phyPortInterface; PPP_ATTRIBUTES *pEventData = (PPP_ATTRIBUTES *) eventData; if ((id = pfwInterfaceIdGet(state->pluginObj->pfwObj, "PHY_PORT_INTERFACE")) > 0) { if (pfwInterfaceObjAndStateGetViaStackObj(state->stackObj, id, &phyPortStatePair) != OK) return ERROR; } phyPortInterface = (PHY_PORT_INTERFACE *) phyPortStatePair.interfaceObj; if (phyPortInterface != NULL) pEventData->nasPort = phyPortInterface->portNumberGet(phyPortStatePair.state); if (phyPortStatePair.interfaceObj != NULL) pfwInterfaceReferenceDelete(phyPortStatePair.interfaceObj); /* Currently the following attriubtes are not available so the default * values are filled in */ memset (pEventData->calledNumber, 0, PPP_MAX_PHONE_NUMBER_LENGTH); pEventData->calledNumberLength = 0; memset (pEventData->callingNumber, 0, PPP_MAX_PHONE_NUMBER_LENGTH); pEventData->callingNumberLength = 0; memset (pEventData->subAddress, 0, PPP_MAX_SUB_ADDRESS_LENGTH); pEventData->subAddressLength = 0; pEventData->txConnectSpeed = 0; pEventData->rxConnectSpeed = 0; pEventData->physicalChannelID = 0; pEventData->nasIpAddress = 0; return OK; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -