📄 ppplcpcomponent.c
字号:
if (strstr(value,"Remote") != NULL) { isLocalConfig = FALSE; if (valueLength <= 7) /* 7 ==> strlen("Remote:") */ { if (pOptionConfigStrings->remoteConfigString != NULL) { pfwFree(pOptionConfigStrings->remoteConfigString); pOptionConfigStrings->remoteConfigString = NULL; } removeAlternateValues(pOptionConfigStrings,value); return (lcp_setStackData(pfw, pProfileData, pLcpOption, value)); } pConfigString = &pOptionConfigStrings->remoteConfigString; } else if (strstr(value,"Local") != NULL) { if (valueLength <= 6) /* 6 ==> strlen("Local:") */ { if (pOptionConfigStrings->configString != NULL) { pfwFree(pOptionConfigStrings->configString); pOptionConfigStrings->configString = NULL; } removeAlternateValues(pOptionConfigStrings,value); return (lcp_setStackData(pfw, pProfileData, pLcpOption, value)); } pConfigString = &pOptionConfigStrings->configString; } else { return ERROR; } if (strstr(value,"Alternate") != NULL || strstr(value,"Range") != NULL) { if (strstr(value,"Local") != NULL) alternateString = pOptionConfigStrings->localAlternateConfigString; else if (strstr(value,"Remote") != NULL) alternateString = pOptionConfigStrings->remoteAlternateConfigString; else { return ERROR; } previous = NULL; while(alternateString != NULL) { if (strcmp(alternateString->configString,value) == 0) { return OK; } previous = alternateString; alternateString = alternateString->next; } alternateLength = sizeof(ALTERNATE_OPTION_STRING)+ valueLength; if ((alternateString = pfwMalloc(pfw,alternateLength)) == NULL) { return ERROR; } bzero((void *)alternateString,alternateLength); if (previous != NULL) { alternateString->preference = previous->preference + 1; previous->next = alternateString; } else { alternateString->preference = 1; if (strstr(value,"Local") != NULL) { pOptionConfigStrings->localAlternateConfigString = alternateString; } else pOptionConfigStrings->remoteAlternateConfigString = alternateString; } alternateStringPtr = alternateString->configString; pConfigString = &alternateStringPtr; /* just to say that we already have a long enough buffer */ memset(*pConfigString,'e',valueLength); } if (pConfigString == NULL) { return ERROR; } if (*pConfigString != NULL) { /* do we have a long enough buffer */ if ((stringLength = strlen(*pConfigString)) < valueLength) { if (*pConfigString != NULL) { pfwFree(*pConfigString); *pConfigString = NULL; } } } stringLength = valueLength; if (*pConfigString == NULL) if ((*pConfigString = pfwMalloc(pfw,stringLength + 1)) == NULL) { return ERROR; } bzero(*pConfigString,stringLength+1); strcpy(*pConfigString,value); return (lcp_setStackData(pfw, pProfileData, pLcpOption, value)); } else if (operType == PFW_PARAMETER_GET) { if (pStackData == NULL) { if (pOptionConfigStrings == NULL) return ERROR; stringLength = 0; if (pOptionConfigStrings->configString) { sprintf(value,"{%s}",pOptionConfigStrings->configString); stringLength = strlen(value); } alternateString = pOptionConfigStrings->localAlternateConfigString; while(alternateString) { if ((stringLength + strlen(alternateString->configString)) < MAX_VALUE_STRING_LENGTH) { sprintf(value+stringLength,"{%s}", alternateString->configString); stringLength += strlen(alternateString->configString) + 2; } else break; alternateString = alternateString->next; } if (pOptionConfigStrings->remoteConfigString) { if ((stringLength + strlen(pOptionConfigStrings->remoteConfigString)) < MAX_VALUE_STRING_LENGTH) sprintf(value+stringLength,"{%s}", pOptionConfigStrings->remoteConfigString); stringLength += strlen(pOptionConfigStrings->remoteConfigString) + 2; } alternateString = pOptionConfigStrings->remoteAlternateConfigString; while(alternateString) { if ((stringLength + strlen(alternateString->configString)) < MAX_VALUE_STRING_LENGTH) { sprintf(value+stringLength,"{%s}", alternateString->configString); stringLength += strlen(alternateString->configString) + 2; } else break; alternateString = alternateString->next; } return (OK); } while(isTrue == TRUE) { if (isLocalConfig == TRUE) { optionList = &pStackData->option_lists.configured; optionEntry = find_matching_option(optionList,pLcpOption->optionType); if (optionEntry != NULL) strcpy(value, "{Local:"); } else { optionList = &pStackData->option_lists.remote_configured; optionEntry = find_matching_option(optionList,pLcpOption->optionType); if (optionEntry != NULL) strcat(value ,"{Remote:"); isTrue = FALSE; } if(optionEntry != NULL) { if(optionEntry->option_flags.negotiation_required == PPP_FLAG_ON) strcat(value, "Negotiation Required, "); else if (optionEntry->option_flags.negotiation_required == PPP_FLAG_OFF) strcat(value, "Negotiation Not Required, "); else { printf("Error in flag\n"); return(ERROR); } if(optionEntry->option_flags.negotiable == PPP_FLAG_ON) strcat(value , "Negotiable"); else if (optionEntry->option_flags.negotiable == PPP_FLAG_OFF) strcat(value, "Not Negotiable"); else { printf("Error in flag\n"); return(ERROR); } bzero (tempValue, sizeof (tempValue)); get_value_string(optionEntry->uptr_data, optionEntry->length, pLcpOption->optionTypeString, tempValue, *((UNION_OPTION_TYPES *)&pLcpOption->optionType), pLcpOption->name); if (strlen(tempValue) != 0) { strcat(value,":"); strcat(value, tempValue); } strcat(value,"}"); if(optionEntry->option_flags.alternate_checking_enabled == PPP_FLAG_ON) { for (sptr_alternate_option = optionEntry->alternate_option_list.sptr_forward_link; sptr_alternate_option != NULL; ) { if (sptr_alternate_option == NULL) break; if (isLocalConfig == TRUE) strcat(value, "{Local:Alternate:"); else strcat(value, "{Remote:Alternate:"); bzero (tempValue, sizeof (tempValue)); get_value_string(sptr_alternate_option->uptr_data, sptr_alternate_option->length, pLcpOption->optionTypeString, tempValue, *((UNION_OPTION_TYPES *) &pLcpOption->optionType), pLcpOption->name); strcat(value, tempValue); strcat(value, "}"); sptr_alternate_option = sptr_alternate_option->links.sptr_forward_link; } } if((optionEntry->option_flags.range_checking_enabled == PPP_FLAG_ON) && (optionEntry->range_option != NULL)) { if (isLocalConfig == TRUE) strcat(value, "{Local:Range:"); else strcat(value, "{Remote:Range:"); bzero (tempValue, sizeof (tempValue)); get_value_string(optionEntry->range_option->uptr_lowest_value, optionEntry->length, pLcpOption->optionTypeString, tempValue, *((UNION_OPTION_TYPES *) &pLcpOption->optionType), pLcpOption->name); strcat(value, tempValue); strcat(value, ","); bzero (tempValue, sizeof (tempValue)); get_value_string(optionEntry->range_option->uptr_highest_value, optionEntry->length, pLcpOption->optionTypeString, tempValue, *((UNION_OPTION_TYPES *) &pLcpOption->optionType), pLcpOption->name); strcat(value, tempValue); strcat(value, ","); bzero (tempValue, sizeof (tempValue)); get_value_string(optionEntry->range_option->uptr_step, optionEntry->length, pLcpOption->optionTypeString, tempValue, *((UNION_OPTION_TYPES *) &pLcpOption->optionType), pLcpOption->name); strcat(value, tempValue); strcat(value,"}"); } } isLocalConfig = FALSE; } return OK; } else return ERROR; }/******************************************************************************** lcpOptionConfigStringsFree - frees the LCP option configuration string**/LOCAL void lcpOptionConfigStringsFree ( LCP_CONFIG_STRINGS *pOptionConfigStrings ) { ALTERNATE_OPTION_STRING *alternateConfigString = NULL; ALTERNATE_OPTION_STRING *nextAlternateString = NULL; if (pOptionConfigStrings != NULL) { if (pOptionConfigStrings->configString) { pfwFree ((void *)pOptionConfigStrings->configString); pOptionConfigStrings->configString = NULL; } if (pOptionConfigStrings->localAlternateConfigString) { alternateConfigString = pOptionConfigStrings->localAlternateConfigString; pOptionConfigStrings->localAlternateConfigString = NULL; while (alternateConfigString != NULL) { nextAlternateString = alternateConfigString->next; pfwFree((void *)alternateConfigString); alternateConfigString = nextAlternateString; } } if (pOptionConfigStrings->remoteAlternateConfigString) { alternateConfigString = pOptionConfigStrings->remoteAlternateConfigString; pOptionConfigStrings->remoteAlternateConfigString = NULL; while (alternateConfigString != NULL) { nextAlternateString = alternateConfigString->next; pfwFree((void *)alternateConfigString); alternateConfigString = nextAlternateString; } } if (pOptionConfigStrings->remoteConfigString) { pfwFree ((void *)pOptionConfigStrings->remoteConfigString); pOptionConfigStrings->remoteConfigString = NULL; } } }/******************************************************************************** lcp_optionsHandlerX01 - handler for LCP option number 0x1**/LOCAL STATUS lcp_optionsHandlerX01 ( PFW_OBJ * pfw, PFW_PARAMETER_OPERATION_TYPE operType, /* operation type */ void * pData, /* profile data bucket */ char * value /* value for this parameter */ ) { return lcp_optionsHandler(pfw,LCP_MAXIMUM_RECEIVE_UNIT,operType,pData,value); }/******************************************************************************** lcp_optionsHandlerX02 - handler for LCP option number 0x2**/LOCAL STATUS lcp_optionsHandlerX02 ( PFW_OBJ * pfw, PFW_PARAMETER_OPERATION_TYPE operType, /* operation type */ void * pData, /* profile data bucket */ char * value /* value for this parameter */ ) { return lcp_optionsHandler(pfw,LCP_ASYNC_CONTROL_CHARACTER_MAP, operType,pData,value); }/******************************************************************************** lcp_optionsHandlerX03 - handler for LCP option number 0x3**/LOCAL STATUS lcp_optionsHandlerX03 ( PFW_OBJ * pfw, PFW_PARAMETER_OPERATION_TYPE operType, /* operation type */ void * pData,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -