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

📄 pppcontrollayer.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
    /* TO DO - call execute statemachine with CLOSE_EVENT for LCP here */    status = tearDownConnection(layerState);    pfwPluginObjStateRelease(layerState);    return (status);    }/******************************************************************************** pppLinkIdGet - returns the PPP Link number(ifIndex) for the stackObj** Application interface for obtaining the link or interface ID for the given* stackObj which is created using pfwStackAdd().** RETURNS: Link ID in the range 0 - 2^31  or  -1 for ERROR.* Zero implies that no PPP_LINK_ID_INTERFACE is available in the stack.** SEE ALSO: pfwStackAdd() */int  pppLinkIdGet    (    PFW_STACK_OBJ *        stackObj    /*  PPP stack */    )    {    PFW_OBJ * pfw;     PFW_STACK_STATUS stackStatus;    PFW_INTERFACE_STATE_PAIR   pppLinkIdInterface;    int linkId;    int id;    if ((pfwStackStatusGet(stackObj,&stackStatus) != OK) ||        (stackStatus != PFW_STACK_READY))        {        printf("PPP: Invalid OR Incomplete stackObj 0x%x\n", (UINT32)stackObj);        return ERROR;        }    if ((pfw = pfwStackObjPfwGet(stackObj)) == NULL)        {        printf("PPP: Invalid stackObj 0x%x\n", (UINT32)stackObj);        return ERROR;        }    /* get PPP link Id for this stack */    if ((id = pfwInterfaceIdGet(pfw, "PPP_LINK_ID_INTERFACE")) > 0)        {        if (pfwInterfaceObjAndStateGetViaStackObj(stackObj, id,                &pppLinkIdInterface) != OK)            {#ifdef PPP_DEBUG            printf ("PPP:Failed to get PPP_LINK_ID_INTERFACE;Stack 0x%x\n",                    (int)stackObj);#endif /* PPP_DEBUG  */            linkId = 0;             }        else            {            linkId = (*((PPP_LINK_ID_INTERFACE *)                      pppLinkIdInterface.interfaceObj)->pppLinkIdGet)                      (pppLinkIdInterface.state);            pfwInterfaceReferenceDelete (pppLinkIdInterface.interfaceObj);            }        }    else        {#ifdef PPP_DEBUG        printf ("PPP: WARNING! No PPP_LINK_ID_INTERFACE; Stack 0x%x\n",                (int)stackObj);#endif /* PPP_DEBUG  */        linkId = 0;        }    return (linkId);    }#ifdef OLD_SECRETS_DATABASE_INTERFACES/******************************************************************************** pppLocalSecretAdd - Add a Name and Password pair for the local system** Application interface for adding a Name and Password pair for use during* authentication with a peer. This database is used if the Control Layer* profile parameter "ppp_secretsDatabase" is set to LOCAL_SECRETS_DATABASE** When connecting to a peer the "localUserName" profile parameter for CHAP* or PAP components must be set to a value that is available in this database.** RETURNS: OK on success and ERROR otherwise** SEE ALSO: pppPeerSecretAdd() pppLocalSecretDatabaseShow() * NOMANUAL*/STATUS pppLocalSecretAdd     (    PFW_OBJ * pfwObj,	/* framework to which the database belongs */    char * localName,	/* local name to add secret for */    char * localSecret  /* password or secret for local name */    )    {    LOCAL_SECRET_TABLE_ENTRY * compareItem;     LOCAL_SECRET_TABLE_ENTRY * existingItem;     CONTROL_LAYER_OBJ * controlLayer;    unsigned int key;    if (localName == NULL || localSecret == NULL || pfwObj == NULL)	return ERROR;    if ((controlLayer = (CONTROL_LAYER_OBJ *)			    pfwPluginObjGet(pfwObj,"CONTROL_LAYER")) == NULL)	{	printf("PPP: Could not find Control Layer plugin Obj\n");	return ERROR;	}    if ((compareItem = pfwMalloc(pfwObj,sizeof(LOCAL_SECRET_TABLE_ENTRY)))	== NULL)	return ERROR;    strcpy(compareItem->name,localName);    compareItem->password[0] = 0;    if ((key = pfwTableTraverse(controlLayer->localSecretsTable,				compareLocalSecretTableEntry,compareItem)) > 0)	{	if (compareItem->password[0] != '\0')	    {	    existingItem = (LOCAL_SECRET_TABLE_ENTRY *)			pfwTableItemGet(controlLayer->localSecretsTable,key);	    strcpy(existingItem->password, localSecret);	    return OK;	    }	else	    {	    strcpy(compareItem->password,localSecret);	    pfwTableItemInsertBefore(controlLayer->localSecretsTable,							compareItem, key);	    return OK;	    }	}    strcpy(compareItem->password,localSecret);    pfwTableItemAdd(controlLayer->localSecretsTable,compareItem);    return OK;    }/******************************************************************************** pppLocalSecretDelete - delete the password and name pair indexed by localName** Application interface for deleting a Name and Password pair added to the* local secrets database using pppLocalSecretAdd().** RETURNS: OK on success and ERROR otherwise** SEE ALSO: pppLocalSecretAdd() pppLocalSecretDatabaseShow()* NOMANUAL*/STATUS pppLocalSecretDelete     (    PFW_OBJ * pfwObj,	/* framework to which the database belongs */    char * localName	/* local name to delete secret for */    )    {    LOCAL_SECRET_TABLE_ENTRY compareItem;     LOCAL_SECRET_TABLE_ENTRY * existingItem;     CONTROL_LAYER_OBJ * controlLayer;    unsigned int key;    if (localName == NULL || pfwObj == NULL)	return ERROR;    if ((controlLayer = (CONTROL_LAYER_OBJ *)			    pfwPluginObjGet(pfwObj,"CONTROL_LAYER")) == NULL)	{	printf("PPP: Could not find Control Layer plugin Obj\n");	return ERROR;	}    strcpy(compareItem.name,localName);    if ((key = pfwTableTraverse(controlLayer->localSecretsTable,				compareLocalSecretTableEntry,&compareItem)) > 0)	{	if (compareItem.password[0] != '\0')	    {	    existingItem = (LOCAL_SECRET_TABLE_ENTRY *)			pfwTableItemGet(controlLayer->localSecretsTable,key);	    pfwTableItemDelete(controlLayer->localSecretsTable,key);        if (existingItem != NULL)            {            pfwFree(existingItem);            existingItem = NULL;            }	    }	}    return OK;    }/******************************************************************************** pppLocalSecretDatabaseShow - Show the contents of the local secrets database** Show the list of Names and associated passwords available to the local system* for authenticating with a peer.* * RETURNS: OK or ERROR* NOMANUAL*/STATUS pppLocalSecretDatabaseShow    (    PFW_OBJ * pfwObj	/* framework to which the database belongs */    )    {    CONTROL_LAYER_OBJ * controlLayer;    UINT32 count = 0;    if (pfwObj == NULL)	return ERROR;    if ((controlLayer = (CONTROL_LAYER_OBJ *)			    pfwPluginObjGet(pfwObj,"CONTROL_LAYER")) == NULL)	{	printf("PPP: Could not find Control Layer plugin Obj\n");	return ERROR;	}    pfwTableTraverse(controlLayer->localSecretsTable,showLocalSecretTableEntry,									&count);    return OK;    }/******************************************************************************** pppPeerSecretAdd - add a secret for the peer ** Application interface for adding Name and Secret pairs for the peers that* the local system will authencitate. Each peer Name and secret pair is added* for one or more local names for the local system.** RETURNS: OK or ERROR** SEE ALSO: pppPeerSecretDelete() pppPeerSecretDatabaseShow()* NOMANUAL*/STATUS pppPeerSecretAdd     (    PFW_OBJ * pfwObj,	/* framework to which the database belongs */    char * localName,	/* local system name */    char * peerName, 	/* peer name */    char * peerSecret	/* secret for the peer */    )    {    PEER_SECRET_TABLE_ENTRY * compareItem;     PEER_SECRET_TABLE_ENTRY * existingItem;     CONTROL_LAYER_OBJ * controlLayer;    unsigned int key;    if (localName == NULL || peerName == NULL || peerSecret == NULL || 								pfwObj == NULL)	{	return ERROR;	}    if ((controlLayer = (CONTROL_LAYER_OBJ *)			    pfwPluginObjGet(pfwObj,"CONTROL_LAYER")) == NULL)	{	printf("PPP: Could not find Control Layer plugin Obj\n");	return ERROR;	}    if ((compareItem = pfwMalloc(pfwObj,sizeof(PEER_SECRET_TABLE_ENTRY)))	== NULL)	return ERROR;    strcpy(compareItem->localName,localName);    strcpy(compareItem->peerName,peerName);    compareItem->secret[0] = 0;    if ((key = pfwTableTraverse(controlLayer->peerSecretsTable,				comparePeerSecretTableEntry,compareItem)) > 0)	{	if (compareItem->secret[0] != '\0')	    {	    existingItem = (PEER_SECRET_TABLE_ENTRY *)			pfwTableItemGet(controlLayer->peerSecretsTable,key);	    strcpy(existingItem->secret, peerSecret);	    return OK;	    }	else	    {	    strcpy(compareItem->secret,peerSecret);	    pfwTableItemInsertBefore(controlLayer->peerSecretsTable,compareItem,									key);	    return OK;	    }	}    strcpy(compareItem->secret,peerSecret);    pfwTableItemAdd(controlLayer->peerSecretsTable,compareItem);    return OK;    }/******************************************************************************** pppPeerSecretDelete - delete a secret for the peer** Application interface for deleting name and secret pairs added using* pppPeerSecretAdd()** RETURNS: OK or ERROR** NOMANUAL*/STATUS pppPeerSecretDelete     (    PFW_OBJ * pfwObj,	/* framework to which the database belongs */    char * localName,	/* Local system name */    char * peerName	/* peer name */    )    {    PEER_SECRET_TABLE_ENTRY compareItem;     PEER_SECRET_TABLE_ENTRY * existingItem;     CONTROL_LAYER_OBJ * controlLayer;    unsigned int key;    if (localName == NULL || peerName == NULL || pfwObj == NULL)	{	return ERROR;	}    if ((controlLayer = (CONTROL_LAYER_OBJ *)			    pfwPluginObjGet(pfwObj,"CONTROL_LAYER")) == NULL)	{	printf("PPP: Could not find Control Layer plugin Obj\n");	return ERROR;	}    strcpy(compareItem.localName,localName);    strcpy(compareItem.peerName,peerName);    if ((key = pfwTableTraverse(controlLayer->peerSecretsTable,				comparePeerSecretTableEntry,&compareItem)) > 0)	{	if (compareItem.secret[0] != '\0')	    {	    existingItem = (PEER_SECRET_TABLE_ENTRY *)			pfwTableItemGet(controlLayer->peerSecretsTable,key);	    pfwTableItemDelete(controlLayer->peerSecretsTable,key);	    if (existingItem != NULL)            {            pfwFree(existingItem);            existingItem = NULL;            }        }	}    return OK;    }/******************************************************************************** pppPeerSecretDatabaseShow - show the contents of the peer secrets database** RETURNS: OK or ERROR* NOMANUAL*/STATUS pppPeerSecretDatabaseShow     (    PFW_OBJ * pfwObj    )    {    CONTROL_LAYER_OBJ * controlLayer;    UINT32 count = 0;    if (pfwObj == NULL)	return ERROR;    if ((controlLayer = (CONTROL_LAYER_OBJ *)			    pfwPluginObjGet(pfwObj,"CONTROL_LAYER")) == NULL)	{	printf("PPP: Could not find Control Layer plugin Obj\n");	return ERROR;	}    pfwTableTraverse(controlLayer->peerSecretsTable,showPeerSecretTableEntry,									&count);    return OK;    }#endif  /* OLD_SECRETS_DATABASE_INTERFACES *//******************************************************************************** clProtocolItemFree -*/LOCAL BOOLEAN clProtocolItemFree    (    CL_PROTOCOL_ITEM * clProtocolItem,    int arg    )    {    pfwInterfaceReferenceDelete((PFW_INTERFACE_OBJ *)clProtocolItem->interface);    if (clProtocolItem != NULL)        {        pfwFree((void *)clProtocolItem);        clProtocolItem = NULL;        }    return TRUE;    }/******************************************************************************** findProtocolItem -*/LOCAL CL_PROTOCOL_ITEM * findProtocolItem    (    PFW_PLUGIN_OBJ_STATE * layerState,    PPP_CONTROL_PHASE      protocolPhase,    UINT16                 protocol

⌨️ 快捷键说明

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