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

📄 pppcontrollayer.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* pppControlLayer.c - PPP Control Layer Source File *//* Copyright 1999 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------03d,07aug03,rp   updating include path for message digest03c,21mar03,ijm  SPR#87027,set numberOfNetworkPhaseProtocols to 0 before                  starting network protocols03b,03mar03,ijm  in controlLayerReceive, free packet if pfwReceive                 returns ERROR, SPR# 8614803a,12dec02,ijm  merged fix for SPR# 76442,check name and password lengths02z,05nov02,ijm  use printf instead of logMsg02y,04nov02,ijm  update proxyAuthenAttributes,SPR# 7550402x,17oct02,ijm  check protocol state in protocolDown  02w,04oct02,ijm  Changed event name from MP_LINK_DOWN_EVENT to                 PPP_LINK_RESET_EVENT02v,17jul02,emr  Bring into line for PPP 2.002u,26jun02 ijm  changed header file inclusion order to support dual stack02t,28may02,rvr  fixed build warnings02s,14mar02,ak   Added MP_LINK_DOWN_EVENT02r,27feb02,ak   releasing the state locks in ERROR exits in 				 chapCallbackWrapper() and papCallbackWrapper()02q,27feb02,ak   validating the Manager Stack Obj before retrieving the value of				"mpFraming_localUserName" in protocolUp()02p,23feb02,jr	 setting the pointers to NULL after freeing02o,17feb02,ak	 support for dynamic assignment of MP Member Stack to Manager 				 Stack02n,29oct01,ijm  fixed SPR#70122: after authentication failure, cannot                 re-establish serial connection to Windows NT.02m,08oct01,ak   Merged the modifications done in the T2 file in                  the functions linkIdGet() deleteProtocolItem(),                 componentStackDelDone(), protocolUp()02l,08oct01,ak	 return ERROR if pfwEventObjGet() fails for 		 PPP_AUTH_SUCCESSFUL_EVENT in controllayerStackDataConstruct()02k,08oct01,ak   Checking for MP Manager Stack before attempting                 pfwStackParamGet() in configuring local auth protocol                 protocolUp()02j,08oct01,ak   Removed unnecesaary log message in getting the reference to                 LINK_ID_INTERFACE in protocolUp()02i,08oct01,ak   deleting reference to AUTH_INFO_INTERFACE in protocolUp()02h,08oct01,ak   changed MAX_NAME to NAME_SIZE02g,21jun01,ak   Configuring authentication information on the MP Member Stacks02f,20jun01,nts	 Handling MP Member Stack and Manager Stack interaction02e,20jun01,as	 added COMPONENT_ACCEPTABLE_PROTOCOL_INTERFACE02d,13apr01,ijm  corrected noAuthenticationRequired function removing redundant                 call to pfwLayerStateGet02c,05mar01,ijm  removed redundant peer and localSecretsTable in                 pppControlLayerCreate.  Released interfaces when stack                 is deleted (SPR#63868: pfwDelete does not delete                 framework)02b,02mar01,ijm  publish and raise LCP_CLOSE_EVENT02a,17dec00,md   publish and raise PPP_NETWORK_PHASE_UP event01z,02aug00,adb  Merging in LAC modifications01y,01aug00,md  changes to authenAttributesGet() to support PAP01x,01aug00,adb  Merging with openstack view01w,31jul00,adb  Merging with bala.tor2_pppfrmwk01v,28jul00,md  initializes proxy authen event and fixes authenAttributesGet()                 to return authenChallenge instead of authenName01u,12jul00,md  publish COLLECT_PPP_ATTRIBUTES_EVENT01t,12jul00,md  added support for l2tp proxy authentication01s,30jun00,bsn  added support for Radius Authentication and Accounting01r,29jun00,md  added authenAttributesGet() interface01q,20mar00,sj  NOMANUAL for obsolete secrets database interfaces01p,15mar00,sj  call lcpTerminationRequest upcall01o,09mar00,sj  FIX bad function definition for OBSOLETE pppLocalSecretDelete01n,25feb00,sj  apopulate lcpIdRequest and lcpIdRequestReceived in                 PPP_CONTROL_LAYER_INTERFACE01m,23feb00,sj  changed bzero to memset and bcopy to memcpy + Pedantic ANSI fix01l,17feb00,sj  in pppLinkIdGet get and use the PPP_LINK_ID_INTERFACE +                added support for PPP_INTERFACE_UP/DOWN_EVENT01k,15feb00,sj  changed m2pppSecretsSecretGet to m2pppSecretsSecretGet01j,07feb00,sj  use secrets database implemented for SNMP + fixes01i,23dec99,sj  dont send protocol reject if received in bad phase01h,14dec99,sj  added LCP_OPEN_EVENT and LCP_DOWN_EVENT01g,30nov99,sj  dont set TERMINATE phase in tearDownConnection01f,30nov99,sj  removing debug messages01e,09nov99,sj  LCP raises LCP up event 01d,16oct99,sj  modifications for RW LCP and IPCP01c,23aug99,sj   modified for generic framework01b,12jul99,koz  included new framework header files and updated interfaces                 accordingly01a,07jul99,koz  created.*//*DESCRIPTIONThis module implements the PPP phase diagram. It is the managing entity forall PPP control protocols. PPP control and authentication protocol packetsreceived from the network are dispatched to the respective protocols if theyare available within the stack instance for which the packet is received.Starting from the DEAD_PHASE this layer progresses through ESTABLISH_PHASE,to NETWORK_PHASE when bringing up the connection and through TERMINATE_PHASE,back to DEAD_PHASE during shutdown as defined in RFC 1661.In each phase only packets with protocol types belonging to the current phaseand the preceeding phases are honored. A protocol reject packet is sent out viathe LCP component for unsupported/unavailable protocols.The Control Layer publishes an interface, "PPP_CONTROL_LAYER_INTERFACE," thatis  used by all the component Control Layer protocols to communicate withthe layer. Some of these callbacks are translated into up-calls tothe user application via the PPP_UPCALL_FUNCTIONS callback mechanism definedin "$WIND_BASE/target/h/ppp/pppInterfaces.h."This layer also expects all component protocols to implement a "CONTROL_PROTOCOL_INTERFACE" which used to obtain the PPP phase to whichthe protocol belongs, to trigger OPEN, DOWN and CLOSE events and toget the current state information.The negotiated Authentication protocol information is obtained from theLCP component via the "LCP_NEGOTIATED_AUTH_PROTOCOL_INTERFACE" once it is UP.The corresponding protocols, if configured for dynamic addition, are firstadded and then started. The connection will be shutdown if the negotiatedauthentication protocols are unavailable. This module has been implemented as a LAYER plugin object and it exists inthe CONTROL PLANE of the framework instance for which it has beeninstantiated. It has a single profile parameter which is described in"$WIND_BASE/target/h/ppp/pppControlLayer.h."INCLUDE FILES pppControlLayer.h pppInterfaces.h pppControlProtocolInterface.hpppControlLayerInterface.h lcpInterfaces.h*//* includes */#include "vxWorks.h"#include "pfw/pfw.h"#include "stdio.h"#include "stdlib.h"#include "string.h"#include "logLib.h"#include "tickLib.h"#include "muxLib.h"#include "netBufLib.h"#include "pfw/pfwStack.h"#include "pfw/pfwComponent.h"#include "pfw/pfwLayer.h"#include "pfw/pfwTable.h"#include "pfw/pfwEvent.h"#include "pfw/pfwMemory.h"#include "ppp/kstart.h"#include "ppp/kppp.h"#include "private/ppp/vpppastr.h"#include "ppp/interfaces/pppControlLayerInterface.h"#include "ppp/interfaces/pppControlProtocolInterface.h"#include "ppp/interfaces/lcpInterfaces.h"#include "ppp/interfaces/pppLinkIdInterface.h"#include "ppp/interfaces/pppRadiusInterface.h"#include "ppp/pppInterfaces.h"#include "ppp/m2pppSecuritySecretsLib.h"#include "ppp/pppControlLayer.h"#include "sllLib.h"#include "wrn/util/mdLib.h"/* WindNet Multilink */#include "ppp/interfaces/componentAcceptableProtocolsInterface.h" #include "ppp/interfaces/authInfoInterface.h"/* WindNet Multilink *//* defines */#define  LOCAL_SECRETS_DATABASE  1#define  EXTERNAL_SECRETS_DATABASE 2#define  REMOTE_SECRETS_DATABASE 3#define _LCP_PROTOCOL_    0xc021  /* Link Control Protocol */#define _PAP_PROTOCOL_    0xc023  /* Password Authentication Protocol */#define _LQR_PROTOCOL_    0xc025  /* Link Quality Report */#define _SPAP_PROTOCOL_   0xc027  /* SPAP */#define _CBCP_PROTOCOL_   0xc029  /* CBCP */#define _CNCP_PROTOCOL_   0xc081  /* Container Control Protocol */#define _CHAP_PROTOCOL_   0xc223  /* CHAP */#define _PRAP_PROTOCOL_   0xc281  /* Proprietary Authentication Protocol */#define _CCP_PROTOCOL_    0x80fd  /* Compression Control Protocol */#define _ECP_PROTOCOL_    0x8053  /* single link Encryption Control Protocol */#define _ML_ECP_PROTOCOL_ 0x8055  /* Multi link Encryption Control Protocol */#define _IPCP_PROTOCOL_   0x8021  /* IP Control Protocol */#define INITIAL_SEQUENCE_NUMBER 0x0#define NUMBER_OF_PROTOCOLS_PER_PHASE 0x10#define PPP_PHASE_STARTING_PROTOCOL_SEQUENCE(phase)\	    (INITIAL_SEQUENCE_NUMBER + (NUMBER_OF_PROTOCOLS_PER_PHASE * phase))#define LOCAL_NAME_SIZE 24#define PEER_NAME_SIZE 24/* typedefs */typedef struct controlLayerComponent    {    PFW_LAYER_OBJ               layer;    PPP_CONTROL_LAYER_INTERFACE controlLayerInterface;    MP_CONTROL_LAYER_INTERFACE  mpControlLayerInterface; /* WindNet Multilink - mp interface */    UINT32                      sequence;    AUTHEN_ATTRIBUTES_INTERFACE	authenAttrGetInterface;    PFW_TABLE_OBJ             * peerSecretsTable;    PFW_TABLE_OBJ             * localSecretsTable;    } CONTROL_LAYER_OBJ;typedef struct clProtocolItem    {    struct clProtocolItem * next;    PFW_PLUGIN_OBJ_STATE * state;    CONTROL_PROTOCOL_INTERFACE *interface;    ACCEPTABLE_PROTOCOLS_ARRAY *acceptableProtocols; /* WindNet Multilink */    }CL_PROTOCOL_ITEM;typedef struct controlLayerProfileData    {    UINT32 secretsDatabase;    }CONTROL_LAYER_PROFILE_DATA;typedef enum {CLOSED,OPENED} PPP_ADMIN_STATE;typedef struct controlLayerStackData    {    PPP_CONTROL_PHASE          phase;    PPP_ADMIN_STATE            adminState;    UINT32                     pppLinkId;    SL_LIST                    protocols[TOTAL_PPP_CONTROL_PHASES];    PPP_LINK_STATUS_ENTRY_INTERFACE *        pppLinkStatusInterface;    LCP_EXTENDED_OPTIONS_INTERFACE  *        lcpExtendedOptions;    LCP_NEGOTIATED_AUTH_PROTOCOL_INTERFACE * lcpNegotiatedAuthProtocolInterface;    REMOTE_AUTHENTICATION_INTERFACE * remoteAuthInterface;    REMOTE_ACCOUNTING_INTERFACE     * remoteAcctInterface;    REMOTE_AUTHENTICATION_CALLBACKS   remotePapCallbacks;    REMOTE_AUTHENTICATION_CALLBACKS   remoteChapCallbacks;    unsigned int               numberOfAuthenticationsRequired;    unsigned int               numberOfNetworkPhaseProtocols;    CL_PROTOCOL_ITEM *         lcpProtocolItem;    PFW_PLUGIN_OBJ_CALLBACKS   componentCallbacks;    PFW_PLUGIN_OBJ_CALLBACKS * callbacks;    void                     * userHandle;    PPP_UPCALL_FUNCTIONS     * pppUpcall;    CHAP_CALLBACK              chapCallback;    PAP_CALLBACK               papCallback;    PFW_EVENT_OBJ            * networkPhaseUpEvent;    PFW_EVENT_OBJ            * lcpOpenEvent;    PFW_EVENT_OBJ            * lcpDownEvent;    PFW_EVENT_OBJ            * pppLinkResetEvent;/* WindNet Multilink */	PFW_EVENT_OBJ			 *pAuthUpEventObj;	PFW_EVENT_OBJ			 *pAuthDownEventObj;/* WindNet Multilink */    PFW_EVENT_OBJ            * lcpCloseEvent;    PFW_EVENT_OBJ            * interfaceUpEvent;    PFW_EVENT_OBJ            * interfaceDownEvent;    PFW_PLUGIN_OBJ_STATE *     lastAddedComponent;    PFW_PLUGIN_OBJ_STATE *     lastDeletedComponent;    PFW_PLUGIN_OBJ_STATE *     radiusComponent;    AUTHENTICATION_ATTRIBUTES * proxyAuthenAttributes;    BOOLEAN                      isMember;   /* WindNet Multilink - making the CONTROL_LAYER ML-PPP aware */    PFW_STACK_OBJ               *mpStackObj; /* WindNet Multilink - Manager Stack's STACK_OBJ */    }CONTROL_LAYER_STACK_DATA;/* secrets tables */typedef struct localSecretTableEntry    {    char name[LOCAL_NAME_SIZE];    char password[NAME_SIZE];    } LOCAL_SECRET_TABLE_ENTRY;typedef struct peerSecretTableEntry    {    char peerName[LOCAL_NAME_SIZE];    char localName[PEER_NAME_SIZE];    char secret[NAME_SIZE];    } PEER_SECRET_TABLE_ENTRY;/* locals *//* forwards */LOCAL STATUS controlLayerProfileDataConstruct (PFW_OBJ *,void * profileData);LOCAL STATUS controlLayerStackDataConstruct(PFW_OBJ *,  void * stackData,							void *profileData);LOCAL STATUS controlLayerStackDataDestruct(PFW_OBJ *,  void * stackData,							void *profileData);LOCAL STATUS controlLayerStackAdd (PFW_PLUGIN_OBJ_STATE *,						    PFW_PLUGIN_OBJ_CALLBACKS *);LOCAL STATUS controlLayerStackDelete (PFW_PLUGIN_OBJ_STATE *);LOCAL STATUS controlLayerReceive (PFW_PLUGIN_OBJ_STATE *, M_BLK_ID *);LOCAL STATUS controlLayerSend (PFW_PLUGIN_OBJ_STATE *, M_BLK_ID *);LOCAL STATUS controlLayerComponentAddComplete (PFW_COMPONENT_OBJ *);LOCAL void componentStackAddDone (PFW_PLUGIN_OBJ_CALLBACKS *,				    PFW_PLUGIN_OBJ_STATE *componentState);LOCAL void componentStackDelDone (PFW_PLUGIN_OBJ_CALLBACKS *,				    PFW_PLUGIN_OBJ_STATE *componentState);LOCAL STATUS componentStackDynamicAdd (PFW_PLUGIN_OBJ_STATE *layerState,				PFW_PLUGIN_OBJ_STATE *componentState);LOCAL STATUS componentStackDynamicDel (PFW_PLUGIN_OBJ_STATE *layerState,				PFW_PLUGIN_OBJ_STATE *componentState);LOCAL STATUS authenAttributesGet (PFW_PLUGIN_OBJ_STATE * controlLayerState,				  UINT16 *authenType, char *authName,				  char *authChallange, UINT8 *authenID, char *authenResponse);LOCAL void noAuthenticationRequired(PFW_PLUGIN_OBJ_STATE * layerState);LOCAL void protocolUp      (PFW_PLUGIN_OBJ_STATE * pluginState);LOCAL void protocolDown    (			    PFW_PLUGIN_OBJ_STATE * pluginState,			    PPP_STATE              endState			   );LOCAL void protocolFinished(PFW_PLUGIN_OBJ_STATE * pluginState);LOCAL void protocolRejected (			    PFW_PLUGIN_OBJ_STATE * pluginState,			    PPP_PROTOCOL_TYPE      rejectedProtocol			    );LOCAL void pppLcpTerminationRequest(PFW_PLUGIN_OBJ_STATE *pluginState);LOCAL void pppLcpIdRequest (PFW_PLUGIN_OBJ_STATE * pluginState,char * message);LOCAL void pppLcpIdRequestReceived (PFW_PLUGIN_OBJ_STATE * pluginState,								char * message);LOCAL void pppLcpTimeRemainingRequest(PFW_PLUGIN_OBJ_STATE *pluginState,				      ULONG * secondsRemaining,				      char * message);LOCAL void pppLcpTimeRemainingReceived(PFW_PLUGIN_OBJ_STATE *pluginState,				      ULONG secondsRemaining,				      char * message);LOCAL void pppAuthRequest (PFW_PLUGIN_OBJ_STATE *pluginState, char *userName,							char * userPassword);LOCAL void pppChallengeAuthVerify (PFW_PLUGIN_OBJ_STATE *pluginState,				    char * locaName, char *peerName,				    char * response, unsigned int responseLen,				    char * challenge, unsigned int challengeLen,				    BYTE id,CHAP_CALLBACK);LOCAL void pppPasswordAuthVerify (PFW_PLUGIN_OBJ_STATE *pluginState,				    char * localName, char *peerName,				    char * peerPassword, BYTE id,				    PAP_CALLBACK);LOCAL void pppAuthAckTransmitted (PFW_PLUGIN_OBJ_STATE *pluginState);LOCAL void pppAuthAckReceived (PFW_PLUGIN_OBJ_STATE *pluginState);LOCAL void pppAuthFailed (PFW_PLUGIN_OBJ_STATE *pluginState);LOCAL void pppAuthRefused (PFW_PLUGIN_OBJ_STATE *pluginState);LOCAL STATUS ppp_secretsDatabase (PFW_OBJ *,PFW_PARAMETER_OPERATION_TYPE,							    void *, char *);LOCAL STATUS proceedToNextPhase(PFW_PLUGIN_OBJ_STATE * layerState);LOCAL STATUS bringUpConnection(PFW_PLUGIN_OBJ_STATE * layerState);LOCAL STATUS tearDownConnection(PFW_PLUGIN_OBJ_STATE * layerState);LOCAL void remoteChapAcceptedWrapper (PFW_PLUGIN_OBJ_STATE *, BYTE id);LOCAL void remoteChapRejectedWrapper (PFW_PLUGIN_OBJ_STATE *, BYTE id, char *);LOCAL void remoteChapErrorWrapper (PFW_PLUGIN_OBJ_STATE *, BYTE id);LOCAL void remotePapAcceptedWrapper (PFW_PLUGIN_OBJ_STATE *, BYTE id);LOCAL void remotePapRejectedWrapper (PFW_PLUGIN_OBJ_STATE *, BYTE id, char *);LOCAL void remotePapErrorWrapper (PFW_PLUGIN_OBJ_STATE *, BYTE id);LOCAL void chapCallbackWrapper (PFW_STACK_OBJ *, BYTE id, TEST passOrFail);LOCAL void papCallbackWrapper (PFW_STACK_OBJ *, BYTE id, TEST passOrFail);LOCAL STATUS interfaceUpEventHandler (PFW_PLUGIN_OBJ_STATE *, void *eventData);LOCAL STATUS interfaceDownEventHandler(PFW_PLUGIN_OBJ_STATE *, void *eventData);/* start : WindNet Multilink */LOCAL void pppMpMemberSet (PFW_PLUGIN_OBJ_STATE *, BOOLEAN, PFW_STACK_OBJ *);LOCAL void mpProtocolRejected (PFW_PLUGIN_OBJ_STATE *, PPP_PROTOCOL_TYPE);LOCAL BOOL isMpManagerStack (PFW_STACK_OBJ *);LOCAL void mpUpCallsGet (PFW_PLUGIN_OBJ_STATE *, MP_UPCALL_FUNCTIONS **, 						void **); /* end : WindNet Multilink */#ifdef OLD_SECRETS_DATABASE_INTERFACESLOCAL BOOL compareLocalSecretTableEntry (UINT32 key, void * pItem, void * pObj);LOCAL BOOL comparePeerSecretTableEntry (UINT32 key, void * pItem, void * pObj);LOCAL BOOL showLocalSecretTableEntry (UINT32 key, void * pItem, void * pObj);LOCAL BOOL showPeerSecretTableEntry (UINT32 key, void * pItem, void * pObj);#endif /* OLD_SECRETS_DATABASE_INTERFACES*//********************************************************************************* pppControlLayerCreate - initialize the ppp control layer** The Control Layer is a layer plug-in object and is both the place holder * and manger of all PPP control protocols such as; LCP, IPCP, PAP,* CHAP, ECP etc.** This routine adds an instance of the "CONTROL_LAYER" plug-in object to * the specified framework** RETURNS: OK or ERROR** SEE ALSO: pppControlLayerDelete()*/STATUS pppControlLayerCreate    (    PFW_OBJ * pfw	/* framework we are adding this to */    )    {    int i;    CONTROL_LAYER_OBJ * controlLayer = NULL;    PPP_CONTROL_LAYER_INTERFACE * controlLayerInterface;    AUTHEN_ATTRIBUTES_INTERFACE	* authenAttrGetInterface;	MP_CONTROL_LAYER_INTERFACE  * mpControlLayerInterface; /* WindNet Multilink */    PFW_LAYER_OBJ *pControlLayer = NULL;    controlLayer = (CONTROL_LAYER_OBJ *) 				pfwMalloc (pfw,sizeof(CONTROL_LAYER_OBJ));

⌨️ 快捷键说明

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