📄 pppbacpcomponent.c
字号:
ALTERNATE_OPTION_STRING *pAlternateString = NULL; UINT valueLength = 0; BOOLEAN isLocalConfig=TRUE; PPP_BACP_COMPONENT *pComponentData = NULL; BACP_CONFIG_STRINGS *pOptionConfigStrings = NULL; BOOLEAN isTrue = TRUE; char tempValue[MAX_PROFILE_PARAM_LENGTH]; BACP_STACK_DATA *pStackData = pProfileData->stackData; OPTION_LIST *optionList = NULL; OPTION_LIST_ENTRY *optionEntry = NULL; ALTERNATE_OPTION *sptr_alternate_option = NULL; if (value == NULL) return ERROR; if (pfw == NULL) return ERROR; if (pProfileData == NULL) return ERROR; pComponentData = (PPP_BACP_COMPONENT *)pfwPluginObjGet (pfw, "PPP_BACP"); if (pComponentData == NULL) return ERROR; pBacpOption = &pComponentData->option[optionType]; if (pBacpOption == NULL) return ERROR; bzero (tempValue, sizeof (tempValue)); if (pProfileData->bacpConfigStrings != NULL) pOptionConfigStrings = &pProfileData->bacpConfigStrings[optionType]; /* set the option value */ if (operType == PFW_PARAMETER_SET) { if (pOptionConfigStrings == NULL) { return (bacp_setStackData(pfw, pProfileData, pBacpOption, value)); } valueLength = strlen (value); /* set the remote config string */ 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 (bacp_setStackData(pfw, pProfileData, pBacpOption, value)); } ppConfigString = (char **)&pOptionConfigStrings->remoteConfigString; } /* set the local config string */ else if (strstr (value, "Local") != NULL) { isLocalConfig = TRUE; if (valueLength <= 6) /* 6 ==> strlen("Local:") */ { if (pOptionConfigStrings->configString != NULL) { pfwFree (pOptionConfigStrings->configString); pOptionConfigStrings->configString = NULL; } removeAlternateValues (pOptionConfigStrings, value); return (bacp_setStackData(pfw, pProfileData, pBacpOption, value)); } ppConfigString = (char **)&pOptionConfigStrings->configString; } else return ERROR; /* set the local/remote alternate config string */ if (strstr (value, "Alternate") != NULL || strstr (value, "Range") != NULL) { if (strstr (value, "Local") != NULL) pAlternateString = pOptionConfigStrings->localAlternateConfigString; else if (strstr (value, "Remote") != NULL) pAlternateString = pOptionConfigStrings->remoteAlternateConfigString; else return ERROR; pPrevious = NULL; while (pAlternateString != NULL) { if (strcmp (pAlternateString->configString, value) == 0) return OK; pPrevious = pAlternateString; pAlternateString = pAlternateString->next; } alternateLength = sizeof (ALTERNATE_OPTION_STRING) + valueLength; if ((pAlternateString = pfwMalloc (pfw, alternateLength)) == NULL) return ERROR; bzero ((void *)pAlternateString, alternateLength); if (pPrevious != NULL) { pAlternateString->preference = pPrevious->preference + 1; pPrevious->next = pAlternateString; } else { pAlternateString->preference = 1; if (strstr (value, "Local") != NULL) pOptionConfigStrings->localAlternateConfigString = pAlternateString; else pOptionConfigStrings->remoteAlternateConfigString = pAlternateString; } pAlternateStringPtr = pAlternateString->configString; ppConfigString = &pAlternateStringPtr; /* just to say that we already have a long enough buffer */ memset (*ppConfigString, 'e', valueLength); } if (ppConfigString == NULL) return ERROR; if (*ppConfigString != NULL) { /* do we have a long enough buffer */ if ((stringLength = strlen (*ppConfigString)) < valueLength) { if (*ppConfigString != NULL) { pfwFree (*ppConfigString); *ppConfigString = NULL; } } } stringLength = valueLength; if (*ppConfigString == NULL) if ((*ppConfigString = pfwMalloc (pfw, stringLength + 1)) == NULL) return ERROR; bzero (*ppConfigString, stringLength+1); strcpy (*ppConfigString, value); bacp_setStackData(pfw, pProfileData, pBacpOption, value); return OK; } /* get the option value */ else if (operType == PFW_PARAMETER_GET) { if (pStackData == NULL) { if (pOptionConfigStrings == NULL) return ERROR; /* copy the local config string */ stringLength = 0; if (pOptionConfigStrings->configString) { sprintf (value, "{%s}", pOptionConfigStrings->configString); stringLength = strlen (value); } /* copy the local alternate config string */ pAlternateString = pOptionConfigStrings->localAlternateConfigString; while (pAlternateString) { if ((stringLength + strlen (pAlternateString->configString)) < MAX_VALUE_STRING_LENGTH) { sprintf (value + stringLength, "{%s}", pAlternateString->configString); stringLength += strlen (pAlternateString->configString) + 2; } else break; pAlternateString = pAlternateString->next; } /* copy the remote config string */ if (pOptionConfigStrings->remoteConfigString) { if ((stringLength + strlen (pOptionConfigStrings->remoteConfigString)) < MAX_VALUE_STRING_LENGTH) sprintf (value + stringLength, "{%s}", pOptionConfigStrings->remoteConfigString); stringLength += strlen (pOptionConfigStrings->remoteConfigString) + 2; } /* copy the remote alternate config string */ pAlternateString = pOptionConfigStrings->remoteAlternateConfigString; while (pAlternateString) { if ((stringLength + strlen (pAlternateString->configString)) < MAX_VALUE_STRING_LENGTH) { sprintf (value + stringLength, "{%s}", pAlternateString->configString); stringLength += strlen (pAlternateString->configString) + 2; } else break; pAlternateString = pAlternateString->next; } return OK; } while(isTrue == TRUE) { if (isLocalConfig == TRUE) { optionList = &pStackData->option_lists.configured; optionEntry = find_matching_option(optionList,pBacpOption->optionType); if (optionEntry != NULL) strcpy(value, "{Local:"); } else { optionList = &pStackData->option_lists.remote_configured; optionEntry = find_matching_option(optionList,pBacpOption->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, pBacpOption->optionTypeString, tempValue,*((UNION_OPTION_TYPES *) &pBacpOption->optionType), pBacpOption->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, pBacpOption->optionTypeString, tempValue, *((UNION_OPTION_TYPES *)&pBacpOption->optionType), pBacpOption->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, pBacpOption->optionTypeString, tempValue, *((UNION_OPTION_TYPES *) &pBacpOption->optionType), pBacpOption->name); strcat(value, tempValue); strcat(value, ","); bzero (tempValue, sizeof (tempValue)); get_value_string(optionEntry->range_option->uptr_highest_value, optionEntry->length, pBacpOption->optionTypeString, tempValue, *((UNION_OPTION_TYPES *)&pBacpOption->optionType), pBacpOption->name); strcat(value, tempValue); strcat(value, ","); bzero (tempValue, sizeof (tempValue)); get_value_string(optionEntry->range_option->uptr_step, optionEntry->length, pBacpOption->optionTypeString, tempValue, *((UNION_OPTION_TYPES *) &pBacpOption->optionType), pBacpOption->name); strcat(value, tempValue); strcat(value,"}"); } } isLocalConfig = FALSE; } return OK; } else return ERROR; }/******************************************************************************** bacp_optionsHandlerX01 - handler for BACP option number 0x01** This routine calls the bacp_optionsHandler () to handle the option.** RETURNS: OK/ERROR*/LOCAL STATUS bacp_optionsHandlerX01 ( PFW_OBJ * pfw, /* framework reference */ PFW_PARAMETER_OPERATION_TYPE operType, /* operation type */ void * pData, /* profile data bucket */ char * value /* value for this parameter */ ) { STATUS status; status = bacp_optionsHandler (pfw, BACP_FAVORED_PEER, operType, pData, value); return status; }/******************************************************************************* bacp_maxConfigRequests - get/set the max BACP configuration requests to * send in one attempt** This routine gets or sets the value of the BACP profile data parameter * maximum_number_of_bacp_configuration_requests.** RETURNS: OK/ERROR*/LOCAL STATUS bacp_maxConfigRequests ( PFW_OBJ * pfw, /* framework reference */ PFW_PARAMETER_OPERATION_TYPE operType, /* operation type */ void * pData, /* profile data bucket */ char * value /* value for this parameter */ ) { BACP_PROFILE_DATA * pProfileData = (BACP_PROFILE_DATA *)pData; UINT configValue = 0; if (operType == PFW_PARAMETER_SET) { if (value == NULL) return ERROR; if ((configValue = atoi (value)) > 0) pProfileData->maximum_number_of_bacp_configuration_requests = configValue; return OK; } else if (operType == PFW_PARAMETER_GET) { sprintf (value, "%ld", pProfileData->maximum_number_of_bacp_configuration_requests); return OK; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -