📄 pppipcpcomponent.c
字号:
return ERROR; bzero ((char *)pIpcpData->pIpcpConfigStrings, sizeof (IPCP_CONFIG_STRINGS) * (NUMBER_OF_IPCP_OPTIONS + 1)); return (OK); }/******************************************************************************** ipcpProfileDataCopy - profileData object copy constructor***/LOCAL STATUS ipcpProfileDataCopy ( PFW_OBJ * pfw, void * srcProfileData, void * dstProfileData ) { IPCP_PROFILE_DATA * pSrcProfileData = (IPCP_PROFILE_DATA *) srcProfileData; IPCP_PROFILE_DATA * pDstProfileData = (IPCP_PROFILE_DATA *) dstProfileData; IPCP_CONFIG_STRINGS * srcOption = NULL; IPCP_CONFIG_STRINGS * dstOption = NULL; ALTERNATE_OPTION_STRING * alternateConfigString = NULL; ALTERNATE_OPTION_STRING * newAlternateString = NULL; unsigned int options = 0; unsigned int stringLength = 0; bzero (dstProfileData, sizeof(IPCP_PROFILE_DATA)); bcopy(srcProfileData,dstProfileData, sizeof(IPCP_PROFILE_DATA)); if (!pSrcProfileData->pIpcpConfigStrings) { return OK; } pDstProfileData->pIpcpConfigStrings = pfwMalloc (pfw, sizeof (IPCP_CONFIG_STRINGS) * (NUMBER_OF_IPCP_OPTIONS + 1)); if (pDstProfileData->pIpcpConfigStrings == NULL) return ERROR; bzero ((char *)pDstProfileData->pIpcpConfigStrings, sizeof (IPCP_CONFIG_STRINGS) * (NUMBER_OF_IPCP_OPTIONS + 1)); /* Obsolete option IP_ADDRESSES_OPTION_TYPE = 0x01 is not supported */ for (options = IP_COMPRESSION_OPTION_TYPE; options <= NUMBER_OF_IPCP_OPTIONS; options++) { srcOption = &pSrcProfileData->pIpcpConfigStrings[options]; dstOption = &pDstProfileData->pIpcpConfigStrings[options]; if (srcOption->remoteConfigString != NULL) { stringLength = strlen(srcOption->remoteConfigString)+1; /* make a copy of the remote string */ if ((dstOption->remoteConfigString = pfwMalloc(pfw,stringLength)) == NULL) { profileDataDestruct (pfw,pDstProfileData); return ERROR; } bzero(dstOption->remoteConfigString,stringLength); strcpy(dstOption->remoteConfigString,srcOption->remoteConfigString); } if (srcOption->configString != NULL) { stringLength = strlen(srcOption->configString)+1; /* make a copy of the remote string */ if ((dstOption->configString = pfwMalloc(pfw,stringLength)) == NULL) { profileDataDestruct (pfw,pDstProfileData); return ERROR; } bzero(dstOption->configString,stringLength); strcpy(dstOption->configString,srcOption->configString); } alternateConfigString = srcOption->alternateConfigString; newAlternateString = NULL; while (alternateConfigString != NULL) { stringLength = strlen(alternateConfigString->configString) + 1; /* make a copy of the alternate config string */ if (newAlternateString != NULL) { if((newAlternateString->next = pfwMalloc(pfw,stringLength + sizeof(ALTERNATE_OPTION_STRING))) == NULL) { profileDataDestruct(pfw,pDstProfileData); return ERROR; } else newAlternateString = newAlternateString->next; } else { if((newAlternateString = pfwMalloc(pfw,stringLength + sizeof(ALTERNATE_OPTION_STRING))) == NULL) { profileDataDestruct(pfw,pDstProfileData); return ERROR; } else dstOption->alternateConfigString = newAlternateString; } bzero ((void *)newAlternateString, (stringLength + sizeof(ALTERNATE_OPTION_STRING))); strcpy (newAlternateString->configString, alternateConfigString->configString); alternateConfigString = alternateConfigString->next; } } return OK; }/******************************************************************************** profileDataDestruct - clean up profile data***/LOCAL STATUS profileDataDestruct ( PFW_OBJ * pfw, void * profileData ) { int options = 0; IPCP_PROFILE_DATA * pProfileData = (IPCP_PROFILE_DATA *) profileData; if (!pProfileData->pIpcpConfigStrings) return OK; /* Obsolete option IP_ADDRESSES_OPTION_TYPE = 0x01 is not supported */ for (options = IP_COMPRESSION_OPTION_TYPE; options <= NUMBER_OF_IPCP_OPTIONS; options++) { ipcpOptionConfigStringsFree (&pProfileData->pIpcpConfigStrings[options]); } if (pProfileData->pIpcpConfigStrings != NULL) { pfwFree (pProfileData->pIpcpConfigStrings); pProfileData->pIpcpConfigStrings = NULL; } return OK; }/********************************************************************************* stackDataDestruct -*/LOCAL STATUS stackDataDestruct ( PFW_OBJ *pfw, void * stackData, void * profileData ) { NCP_STACK_DATA * pNcpStackData = (NCP_STACK_DATA *) stackData; free_ppp_option_lists (&pNcpStackData->option_lists); return (OK); }/******************************************************************************** stackDataConstruct - initialize stack data ***/LOCAL STATUS stackDataConstruct ( PFW_OBJ * pfw, void * stackData, void * profileData ) { IPCP_STACK_DATA * pStackData = (IPCP_STACK_DATA *) stackData; IPCP_PROFILE_DATA * pProfileData = (IPCP_PROFILE_DATA *) profileData; NCP_STACK_DATA * pNcpStackData = (NCP_STACK_DATA *) stackData;#if 0 char * configString;#endif char partialString[256]; IPCP_CONFIG_OPTION * ipcpOption = NULL; ALTERNATE_OPTION_STRING * alternateConfigString = NULL; int options = 0; int stringLength = 0; PPP_IPCP_COMPONENT *pComponentData = NULL; IPCP_CONFIG_STRINGS *pIpcpConfigStrings = NULL; bzero (partialString, sizeof(partialString)); pComponentData = (PPP_IPCP_COMPONENT *) pfwPluginObjGet (pfw, "PPP_IPCP"); if (pComponentData == NULL) return ERROR; /* Zeroing IPCP and NCP Stack Data */ bzero ((char *) pStackData, sizeof (IPCP_STACK_DATA)); pNcpStackData->ncp_protocol = IPCP_PROTOCOL; if ((pNcpStackData->pNcpUpEventObj = pfwEventObjGet(pfw,"IPCP_UP_EVENT")) == NULL) { return ERROR; } if ((pNcpStackData->pNcpDownEventObj = pfwEventObjGet(pfw,"IPCP_DOWN_EVENT")) == NULL) { return ERROR; } if (pProfileData->pIpcpConfigStrings != NULL) { /* Obsolete option IP_ADDRESSES_OPTION_TYPE = 0x01 is not supported */ for (options = IP_COMPRESSION_OPTION_TYPE; options <= NUMBER_OF_IPCP_OPTIONS; options++) { ipcpOption = &pComponentData->option[options]; pIpcpConfigStrings = &pProfileData->pIpcpConfigStrings[options]; if (pIpcpConfigStrings->configString == NULL && pIpcpConfigStrings->remoteConfigString == NULL) continue; if (pIpcpConfigStrings->configString != NULL) { stringLength = strlen(pIpcpConfigStrings->configString) + 1; bzero(partialString,stringLength); strcpy(partialString,pIpcpConfigStrings->configString); if (generate_option_list_entry(pfw,&pNcpStackData->option_lists, partialString, ipcpOption->name, ipcpOption->optionType,"IPCP", ipcpOption->optionTypeString) != OK) { return ERROR; } } if (pIpcpConfigStrings->remoteConfigString != NULL) { stringLength = strlen(pIpcpConfigStrings->remoteConfigString)+1; bzero(partialString,stringLength); strcpy(partialString, pIpcpConfigStrings->remoteConfigString); if (generate_option_list_entry(pfw,&pNcpStackData->option_lists, partialString, ipcpOption->name, ipcpOption->optionType,"IPCP", ipcpOption->optionTypeString) != OK) { return ERROR; } } alternateConfigString = pIpcpConfigStrings->alternateConfigString; while (alternateConfigString != NULL) { stringLength = strlen(alternateConfigString->configString) + 1; bzero(partialString,stringLength); strcpy(partialString, alternateConfigString->configString); if (generate_option_list_entry(pfw,&pNcpStackData->option_lists, partialString, ipcpOption->name, ipcpOption->optionType,"IPCP", ipcpOption->optionTypeString) != OK) { return ERROR; } alternateConfigString = alternateConfigString->next; } } /* free the IPCP config strings from the profile data */ for (options = IP_COMPRESSION_OPTION_TYPE; options <= NUMBER_OF_IPCP_OPTIONS; options++) { ipcpOptionConfigStringsFree (&pProfileData->pIpcpConfigStrings[options]); } if (pProfileData->pIpcpConfigStrings != NULL) { pfwFree (pProfileData->pIpcpConfigStrings); pProfileData->pIpcpConfigStrings = NULL; } } pNcpStackData->stateData.action_table = &ipcpStateActionTable; return OK; }/******************************************************************************** ipcpAddrGet - ** NOMANUAL*/STATUS ipcpAddrGet ( PFW_OBJ *pfwObj, PFW_STACK_OBJ *stackObj, UINT *localAddr, UINT *remoteAddr ) { IPCP_STACK_DATA *pStackData = NULL; PFW_PLUGIN_OBJ *pluginObj = NULL; PFW_PLUGIN_OBJ_STATE *state = NULL; pluginObj = pfwPluginObjGet (pfwObj, "IPCP_COMPONENT"); state = pfwPluginObjStateGet(stackObj, pluginObj); pStackData = state->stackData; *localAddr = inet_addr (pStackData->localAddr); *remoteAddr = inet_addr (pStackData->remoteAddr); return (OK); }/******************************************************************************** ipcp_setStackData - initialize stack data ***/LOCAL STATUS ipcp_setStackData ( PFW_OBJ *pfw, IPCP_PROFILE_DATA *profileData, IPCP_CONFIG_OPTION *ipcpOption, char *value ) { IPCP_STACK_DATA *pStackData = profileData->pIpcpStackData; OPTION_LIST *optionList = NULL; OPTION_LIST_ENTRY *optionEntry = NULL; char partialString[256]; char configString[256]; char localOrRemote[10]; BOOLEAN isLocalConfig = TRUE; BOOLEAN bDeleteEntry=FALSE; BOOLEAN isRasRemoteDone = TRUE; UINT valueLength = 0; char *pValue = value; NCP_STACK_DATA *pNcpStackData = (NCP_STACK_DATA *) pStackData; /* Continue only if this profile is associated with stack */ if (!pStackData) { return OK; } bzero (localOrRemote, sizeof (localOrRemote)); if (value == NULL) return ERROR; valueLength = strlen (value); if (strstr(value,"Remote") != NULL) { isLocalConfig = FALSE; if (valueLength <= 7) /* 7 ==> strlen("Remote:") */ { bDeleteEntry = TRUE; } } else if (strstr (value, "Local") != NULL) { isLocalConfig = TRUE; if (valueLength <= 6) /* 6 ==> strlen("Local:") */ { bDeleteEntry = TRUE; } } else if (strstr (value, "RAS-AMM") != NULL) {ras_remote_configuration: value = configString; bzero(configString, sizeof (configString)); if (isLocalConfig) { strcpy (localOrRemote, "Local:"); } else { strcpy (localOrRemote, "Remote:"); } if (valueLength <= 8) /* 8 ==> strlen("RAS-AMM:") Error */ { sprintf(configString, "%s",localOrRemote); bDeleteEntry = TRUE; } else { sprintf(configString, "%s%s%s", localOrRemote, "Negotiation Required, Not Negotiable:", pValue); } if (isLocalConfig) { isRasRemoteDone = FALSE; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -