#!/usr/lib/perl

my $local_debug = 0;

if ($local_debug == 1) {
    $newdb2 = "newdb2";
    $newdb5 = "newdb5";
    $newdb7 = "newdb7";
    $newdb10 = "newdb10";
    $newdb12 = "newdb12";
    $cli2xmldb1 = "cli2xmldb1";
    $fieldtransitiondb = "cli2xmldb3";
    $strmap = "strmap";
    $strvalmap = "strvalmap";
    $clifile = "clifile";
    $xmldir = "";
    $ignored_clifile = "ignored_clis";
    $ignored_flash_clifile = "ignored_clis";
    $invalid_config_tags_file = "invalid_db";
    $fldfrmtdbase = "fldfrmtdbase";
    $fldarraydbase = "fldarraydbase";
    $McastUcast = "mcast_ucast_feature";
    open(DB113,"platformInfo.txt") or die "Can't open format specifier database File:$!";
    $mobilityFlag = "mobilityFlag";
} else {
    $newdb2 = "/bsn/newdb2";
    $newdb5 = "/bsn/newdb5";
    $newdb7 = "/bsn/newdb7";
    $newdb10 = "/bsn/newdb10";
    $newdb12 = "/bsn/newdb12";
    $cli2xmldb1 = "/bsn/cli2xmldb1";
    $fieldtransitiondb = "/bsn/cli2xmldb3";
    $strmap = "/bsn/strmap";
    $strvalmap = "/bsn/strvalmap";
    $clifile = "/mnt/application/xml/clis/clifile";
    $ignored_flash_clifile = "/mnt/application/invclis/XMLIgnoredCLIConfig.txt";
    $ignored_clifile = "/mnt/application/xml/clis/XMLIgnoredCLIConfig.txt";
    $xmldir = "/mnt/application/xml/";
    $invalid_config_tags_file = "/mnt/application/xml/clis/XMLInvalidTagConfig.txt";
    $fldfrmtdbase = "/bsn/fldfrmtdbase";
    $fldarraydbase = "/bsn/fldarraydbase";
    $McastUcast = "/mnt/application/mcast_ucast_feature";
    open(DB113,"/mnt/application/xml/platformInfo.txt") or die "Can't open format specifier database File:$!";
    $mobilityFlag = "/mnt/application/xml/mobilityFlag";
}
my @decimal_to_hex_string_array = ("0", "1", "2", "3", "4", "5", "6", "7", "8","9", "a", "b", "c", "d", "e", "f");
my @me_platform_array = ("AP3802E", "AP3802I", "AP3802P", "AP4800", "AP2802E", "AP2802I", "AP2802A", "AP1852E", "AP1852I", "AP1832I", "AP1810W", "AP1815W", "AP1815I", "AP1562I", "AP1562E", "AP1562D", "AP1562PS", "AP1100AC", "AP900AC", "AP1101AC","AP1840I");
my %dbase;
my %digit_to_tag;
my %digit_to_tag_actual;
my %tag_to_digit;
my $ignore_input_tags = 0;
my %ignore_input_tag_info;
my @stack_digit;
my @stack_digit_actual;
my $stack_digit_level = 1;;
my @stack_tag;
my $stack_tag_level = 1;
my $line;
my @string_value_map;
my @value_string_map;
my @string_map;
my %current_instance_indices;
my %clitoxmldb1_instances;
my %clitoxmldb1_optional_instances;
my $current_optional_level_present = 0;
my $current_optional_level = 0;
my %clitoxmldb1;
my %direct_index_from_keyword;
my @direct_index_from_keyword_level;
my $input_cli;
my @clitoxmldb1_ptr;
my @clitoxmldb1_index;
my $clitoxmldb1_ptr_level = 0;
my $clitoxmldb1_ptr_level_prev_byte_array = 0;
my $initial_current_instance_indices_level = 1;
my $current_instance_indices_level = 0;
my @retcheck;
my $CLI_INPUT_OPTIONAL = 0;
my $ADVANCE_TO_NEXT_DEPTH = 1;
my $END_OF_CLI_TREE = 2;
my $INPUT_NOT_MATCHED = 3;
my $INVALID_CLI_OPTION = 4;
my $CLI_JUMP_OPTION = 5;
my $INSUFFICIENT_CLI_OPTIONS = 6;
my $NOOP_CLI_RETURN_OPTION = 7;
my $add_op = 1;
my $sub_op = 2;
my $mul_op = 3;
my $div_op = 4;
my $new_mobility_enabled = 2; # 1-yes, 0-NO, 2-not updated from Flash
my $make_next_node_mandatory = 0;
my $current_keyword_for_new_mobility = 0;
my $keyword_map_for_new_mobility = 0;

my $grt_op = 1;
my $eq_op = 2;
my $less_op = 3;
my $exist_op = 4;
my $notexist_op = 5;
my $neq_op = 6;

my $UPDATE_CLI_NODE = 8;
my $NO_INSTANCE_FOUND = 9;
my $BACKTRACK_TO_PREVIOUS_LEVEL = 10;
my $DELETE_CURRENT_AND_BACKTRACK_TO_PREVIOUS_LEVEL = 11;
my $DONOT_UPDATE_CLI_NODE_AND_STOP = 12;
my $MORE_INSTANCES_PRESENT = 13;
my $NO_MORE_INSTANCES = 14;
my $CLI_PRINTED = 15;
my $PARAM_UPDATE_SUCCESS = 16;
my $STRVALMAP_NO_VALUE_FOUND = 17;
my $STRVALMAP_NO_STRING_FOUND = 18;
my $GET_NEXT_INDEX_FOR_SET_LEVEL = 19;
my $TAG_FORMAT_NOT_MATCHED = 20;
my $TAG_FORMAT_MATCHED = 21;
my $GET_NEXT_INDEX_FOR_SET_LEVEL_INITIAL = 22;
my $ILLEGAL_CONVERSION_OPTION = 23;
my $VALUE_HAS_NON_DIGIT_CHARS = 24;
my $GET_NEXT_INDEX_FOR_SET_LEVEL_ARRAYALL = 25;
my $NO_INSTANCE_FOUND_ARRAYALL = 26;

my $local_node = 0;
my $pre_action = 1;
my $post_action = 2;
my $cli_map = 3;
my $keyword_string = 4;
my $value_field = 5;
my $action_value = 6;
my $action_string_value = 7;
my $action_local_node = 8;
my $action_node = 9;
my $reverse_action = 10;
my $action_map = 11;
my $keyword_string_map = 12;
my $action_node_arraybase = 13;
my $keyword_string_with_local = 14;
my $keyword_string_special = 15;
my $keyword_string_special_with_local = 16;
my $action_node_arraybase_field = 17;
my $action_node_arrayall = 18;
my $glb_flag_arrayall = 0;
my $glb_country_count = 0;
my $glb_flag_arrayall_action = 0;
my $glb_country_buffer = "";
my @glb_country_array;
my $glb_country_array_count = 0;
my $gbl_flag_two_cond = 0;
my $paramall_value_flag = 0;
my $glb_prev_level;
my $glb_flag_action_node_internal_with_optional = 0;
my $glb_clitoxmldb1_ptr_level_prev;
my @glb_clitoxmldb1_ptr_prev;
my @sigIdMap;
my %glb_sigIdMap_curr_level;

my $gbl_maxdd = 0;

my $GBL_CNT = 0;
my $GBL_MAX_CNT = 10000;

my %fldarraydbase_hash;
my %hash7;
my %fldfrmtdbase_hash;
my $xml_format ="xml_formats";
my $cli_format ="cli_formats";
my $max_formats = "MAX_TYPE_OF_VAR";
my @format_conv_arr;
my $global_string_for_byte = "";
my $prev_global_mac_instance_index = 0;
my $flag_for_byte_end_check = 0;
my $flag_for_byte_string_cli_check = 1;
my $flag_for_byte_mac_cli_check = 1;
my $macaddr_count = 0;

my $nodeconnector = "\.";
my $nodekewordvalend = "\%";
my $nodeparamconnector = "\,";

my $show_all_clis = 0;
my $show_invalid_config = 1;
my $output_cli_type = $show_all_clis;
my $arraybase_not_present = 0;
my $arraybase_present = 1;
my %invalid_config_tag_hash;
my $invalid_cli_found = 0;
my $mgmtintf = "management";
my $servintf = "service-port";
my $virtualintf = "virtual";
my $apmgrintf = "ap-manager";
my $default_prfname = "prfMaP1500LlEAuth93";
my $prefix_config_multicast_cli = "config network multicast mode multicast";
my $prefix_config_ipv6_multicast_cli = "config ipv6 multicast mode multicast[ ]*";
my $prefix_config_mgmtuser_cli = "config mgmtuser";
my $prefix_config_databse_cli = "config database size";
my $qvlan_name = ".sys.quarantine-0/";
my %glb_hash_bytetostring;
my @glb_cli_to_install;
my $glb_cli_to_install_curr_level;
my $glb_cli_to_install_last_level;
my $glb_cli_to_install_use_flag = 0;

#Transiton Changes
my $running_dimension = 0;
my $shifted_backward = 0;
my $starting_index = 0;
my @running_dim_array = "";
my %nextjumpcli = "";
my %shift_fwd_arr = "";
my %shift_bkwd_arr = "";
my $dynamicAPMgr = "0";
my $servicePortSupp = "1";
my $is_szabla = 0;
my $is_kukri = 0;
my $is_ambassador = 0;
my $is_saber = 0;
my $is_vm = 0;
my $is_pata = 0;
my $is_khanda = 0;
my $is_me = 0;
my $platform_Szabla = "AIR-CT2504-K9";
my $platform_Kukri = "AIR-CT3504-K9";
my $platform_ambassador = "AIR-CT7510-K9"; #7500
my $platform_pata = "AIR-CT5520";
my $platform_khanda = "AIR-CT8540";
my $platform_saber1 = "AIR-CT8510"; #8500 can have two PIDs CT8510 and CT85DC
my $platform_saber2 = "AIR-CT85DC"; #8500 can have two PIDs CT8510 and CT85DC
my $platform_vm = "AIR-CTVM-K9";
my $szabla_max_wlan = 16;


for $line_new(<DB113>) {
    chomp $line_new;
    $platform_type = $line_new;
    initialize_szabla_platform();
    initialize_ambassador_platform(); 
    initialize_saber_platform();
    initialize_kukri_platform(); 
    initialize_pata_platform();
    initialize_khanda_platform();
    initialize_vm_platform();
    initialize_me_platform();
#print "platform_type: $platform_type\n";
}

if ( $platform_type !~ m/^(AIR-WLC21|AIR-WLC440|WS-SVC-WISM|WS-C3750G|NME-AIR-WL)/ ) {	
	$dynamicAPMgr = "1";
}

if (($platform_type =~ m/^(AIR-WLC21)/) | ($platform_type =~ m/^(AIR-CT25)/)) {
#print "platform_type:2 $platform_type\n";
	$servicePortSupp = "0";
}

initialize_xml2cli_maps();
generate_digit_to_tag_viceversa();
populate_data_from_xml_files();
convert_bytestringarray_to_hex();
check_and_update_invalid_config_status($ARGV[0]);
# delete($digit_to_tag{nxt});
# delete($tag_to_digit{nxt});
#generate_cli_from_xml();
getSigIdToIndexMap();
generate_cli_from_xml_for_transition();
append_ignored_config($ARGV[0]);
if ($is_szabla == 1) {
search_mcast_cli();
}

if ($is_me == 0) {
remove_ipv6_mcast_cli(); #remove config ipv6 multicast mode multicast line just after clear config
}

reorder_mgmtuser_cli();

# cleanup_xml2cli_global_vars();

sub getSigIdToIndexMap
{
    my $i = 0;
    my $sigId;
    my $sigIdDd;
    open(DBMANDATORY,"$newdb12") or die "Can't open mandatory field database File:$!";
    for $line(<DBMANDATORY>) {
        chomp $line;
        my ($name, $value) = split('\t', $line, 2);
        if($name eq "sigIdFld") {
            $sigIdDd = $value;
        }
    }
    while(get_value_from_xml_dbase_with_key($sigIdDd, \$sigId, $i)) {
        $sigIdMap[$i] = $sigId;
#print "getSigIdToIndexMap $sigId, $i\n";
        $i++; 
    } 
    close(DBMANDATORY);
}
sub search_mcast_cli()
{
    system("grep -v '$prefix_config_multicast_cli.\$' $clifile > tmp_cli");
    system("cat tmp_cli > $clifile");
    system("rm -f tmp_cli");
}
sub remove_ipv6_mcast_cli()
{
    system("grep -E -v '$prefix_config_ipv6_multicast_cli.\$' $clifile > tmp_cli");
    system("cat tmp_cli > $clifile");
    system("rm -f tmp_cli");
}
sub reorder_mgmtuser_cli()
{
    system("grep -v '$prefix_config_mgmtuser_cli' $clifile > tmp_cli_no_mgmtusers");
    system("grep '$prefix_config_mgmtuser_cli' $clifile > tmp_cli_only_mgmtusers");
    system("sed '/$prefix_config_databse_cli/r tmp_cli_only_mgmtusers' tmp_cli_no_mgmtusers > tmp_cli_mgmtusers_on_top");
    system("cat tmp_cli_mgmtusers_on_top > $clifile");
    system("rm -f tmp_cli_no_mgmtusers");
    system("rm -f tmp_cli_only_mgmtusers");
    system("rm -f tmp_cli_mgmtusers_on_top");
}
sub get_value_from_xml_dbase_with_key
{

    my $fld = $_[0];
    my $pval = $_[1];
    my $instance_index = $_[2];
    my $xmlref = \%digit_to_tag_actual;
    my $str;
    my $level = 0;

#print "$fld, $pval, ....$instance_index\n";
    my @temp = split(/\./, $fld);
    if($fld == -1) {
        #print "Xml2Cli: Am failing here: 278\n";
        return 0;
    }
    for (my $i = 0; $i <= $#temp; $i++) {
        if ($i == 0) {
            $str = $temp[$i];
        } else {
            $str = $str . "." . $temp[$i];
        }

        if (defined($$xmlref{nxt}{$temp[$i]})) {
            $xmlref = \%{$$xmlref{nxt}{$temp[$i]}};
            if (defined($$xmlref{instance})) {
                $xmlref = \%{$$xmlref{instance}{$instance_index}};
                $level += 1;
            }
        } else {
            return 0;
        }
    }
    if (defined $$xmlref{val}) {
        $$pval = $$xmlref{val};
        return 1;
    } else {
        #print "Xml2Cli: Am failing here: 301\n";
        return 0;
    }
}
sub cleanup_xml2cli_global_vars
{
    delete($digit_to_tag_actual{nxt});
    delete($digit_to_tag{nxt});
    for (my $i = 0; $i <= $#stack_digit_actual; $i++) {
        delete($stack_digit_actual[$i]);
    }
    for (my $i = 0; $i <= $#stack_digit; $i++) {
        delete($stack_digit[$i]);
    }
    for (my $i = 0; $i <= $#stack_tag; $i++) {
        delete($stack_tag[$i]);
    }
    for (my $i = 0; $i <= $#string_value_map; $i++) {
        delete($string_value_map[$i]);
    }
    for (my $i = 0; $i <= $#value_string_map; $i++) {
        delete($value_string_map[$i]);
    }
    for (my $i = 0; $i <= $#string_map; $i++) {
        delete($string_map[$i]);
    }
    delete($current_instance_indices{instance});
    delete($clitoxmldb1_instances{instance});
    delete($clitoxmldb1_optional_instances{instance});
    delete($clitoxmldb1{cnt});
    delete($clitoxmldb1{array});
    foreach my $key1 (keys %direct_index_from_keyword) {
        delete($direct_index_from_keyword{$key1});
    }
    for (my $i = 0; $i <= $#direct_index_from_keyword_level; $i++) {
        delete($direct_index_from_keyword_level[$i]);
    }
    for (my $i = 0; $i <= $#clitoxmldb1_ptr; $i++) {
        delete($clitoxmldb1_ptr[$i]);
    }
    for (my $i = 0; $i <= $#clitoxmldb1_index; $i++) {
        delete($clitoxmldb1_index[$i]);
    }
    for (my $i = 0; $i <= $#retcheck; $i++) {
        delete($retcheck[$i]);
    }
    for (my $i = 0; $i <= $#glb_country_array; $i++) {
        delete($glb_country_array[$i]);
    }
    delete($fldarraydbase_hash{nxt});
    delete($fldfrmtdbase_hash{nxt});
    foreach my $key1 (keys %hash7) {
        delete($hash7{$key1});
    }
    for (my $i = 0; $i <= $#format_conv_arr; $i++) {
        delete($format_conv_arr[$i]);
    }
    delete($invalid_config_tag_hash{tag});
    delete($invalid_config_tag_hash{instance});
}


sub cleanup_xml2cli_global_vars
{
    delete($digit_to_tag_actual{nxt});
    delete($digit_to_tag{nxt});
    for (my $i = 0; $i <= $#stack_digit_actual; $i++) {
        delete($stack_digit_actual[$i]);
    }
    for (my $i = 0; $i <= $#stack_digit; $i++) {
        delete($stack_digit[$i]);
    }
    for (my $i = 0; $i <= $#stack_tag; $i++) {
        delete($stack_tag[$i]);
    }
    for (my $i = 0; $i <= $#string_value_map; $i++) {
        delete($string_value_map[$i]);
    }
    for (my $i = 0; $i <= $#value_string_map; $i++) {
        delete($value_string_map[$i]);
    }
    for (my $i = 0; $i <= $#string_map; $i++) {
        delete($string_map[$i]);
    }
    delete($current_instance_indices{instance});
    delete($clitoxmldb1_instances{instance});
    delete($clitoxmldb1_optional_instances{instance});
    delete($clitoxmldb1{cnt});
    delete($clitoxmldb1{array});
    foreach my $key1 (keys %direct_index_from_keyword) {
        delete($direct_index_from_keyword{$key1});
    }
    for (my $i = 0; $i <= $#direct_index_from_keyword_level; $i++) {
        delete($direct_index_from_keyword_level[$i]);
    }
    for (my $i = 0; $i <= $#clitoxmldb1_ptr; $i++) {
        delete($clitoxmldb1_ptr[$i]);
    }
    for (my $i = 0; $i <= $#clitoxmldb1_index; $i++) {
        delete($clitoxmldb1_index[$i]);
    }
    for (my $i = 0; $i <= $#retcheck; $i++) {
        delete($retcheck[$i]);
    }
    for (my $i = 0; $i <= $#glb_country_array; $i++) {
        delete($glb_country_array[$i]);
    }
    delete($fldarraydbase_hash{nxt});
    delete($fldfrmtdbase_hash{nxt});
    foreach my $key1 (keys %hash7) {
        delete($hash7{$key1});
    }
    for (my $i = 0; $i <= $#format_conv_arr; $i++) {
        delete($format_conv_arr[$i]);
    }
    delete($invalid_config_tag_hash{tag});
    delete($invalid_config_tag_hash{instance});
}

 #    print Dumper \%digit_to_tag;
 # print Dumper \%digit_to_tag_actual;
#    print Dumper \%tag_to_digit;

sub populate_xml_files
{
    my $href = $_[0];

    open(DB5,"$newdb5") or die "Can't open XML file name database File:$!";
    for my $line(<DB5>) {
        chomp $line;
        my @temp = split(/\t/, $line);
        $$href[$temp[0]] = $temp[1];
# print "populate_xml_files $$href[$temp[0]], $temp[0]\n";
    }
    close(DB5);
}

sub convert_bytestringarray_to_hex
{
    my $xmlref = \%digit_to_tag_actual;
#print "convert_bytestringarray_to_hex2 dtt:\{$$xmlref{nxt}{1}}\n";
    foreach my $key (keys %glb_hash_bytetostring) {
        if(defined($glb_hash_bytetostring{$key}{bytetostringarray})) {
            my @temp = split('\.', $key);
#print "convert_bytestringarray_to_hex1 $key, $$xmlref{nxt}{$temp[0]}\n";
            get_next_level_for_bytestring_array($xmlref, $key, 0); 
        }
    }
}

sub get_next_level_for_bytestring_array
{
    my $pxmlref = $_[0];
    my $digitdot = $_[1];
    my $depth = $_[2];
    my $ppxmlref;
    my @temp = split('\.', $digitdot);
#print "get_next_level_for_bytestring_array1 $depth , $pxmlref, $digitdot\n";
    if(defined($$pxmlref{instance})) {
#print "get_next_level_for_bytestring_array2 $temp[$depth], $depth , $ppxmlref\n";
        my $hexstring = "";
        foreach my $key (sort {$a <=> $b} keys %{$$pxmlref{instance}}) {
           $ppxmlref = \%{$$pxmlref{instance}{$key}}; 
#print "get_next_level_for_bytestring_array3 $temp[$depth], $depth , $ppxmlref\n";
            if(defined($$ppxmlref{val})) {
                $hexstring = $hexstring . convert_decimal_to_hex_string($$ppxmlref{val});
                #print "GOT value $$ppxmlref{val}, $hexstring\n";
            } else {
                get_next_level_for_bytestring_array($ppxmlref, $digitdot, $depth+1);    
            }
        }       
        if(defined($$ppxmlref{val})) {
            delete($$pxmlref{instance});
            $$pxmlref{val} = $hexstring;
            delete($$pxmlref{array}); 
#print "ADD hexstring: $hexstring to prev levels nxt-temp-depth and delete current instances and arrayflag\n";
#print "DELETE $$pxmlref{array}\n";
        }
    } elsif(defined($$pxmlref{nxt}{$temp[$depth]})) {
         $ppxmlref = \%{$$pxmlref{nxt}{$temp[$depth]}};
#print "get_next_level_for_bytestring_array6 $temp[$depth], $depth , $ppxmlref, $$ppxmlref{instance}\n";
         if(defined($$ppxmlref{instance})) {
             get_next_level_for_bytestring_array($ppxmlref, $digitdot, $depth);    
         } else {
             get_next_level_for_bytestring_array($ppxmlref, $digitdot, $depth+1);    
         }
    } elsif(defined($$pxmlref{val})) {
#print "#########SHOULD NEVER COME $$pxmlref{val} ######\n";
      return;
    } else {
#print "#########NOTHING FOUND\n";
    }
}

sub populate_data_from_xml_files
{
    my @xml_files;
    my $filename;
    my $line;
    my $filename_copy;
    populate_xml_files(\@xml_files);
    for (my $index=1; $index<=$#xml_files; $index++) {
        if (!defined($xml_files[$index])) {
            next;
        }
        $filename = $xmldir . $xml_files[$index];
        $filename_copy = $filename . ".copy";
        if (-f $filename_copy) {
            $filename = $filename_copy;
        }
        if (!-f $filename) {
            next;
        }
# print "populate_data_from_xml_files $xml_files[$index]\n";
        open(XML,$filename) or die "Can't open XML file $xml_files[$index]:$!";
        delete($ignore_input_tag_info{tag});
        delete($ignore_input_tag_info{level});
        $ignore_input_tags = 0;
        $stack_digit_level = 1;
        $stack_tag_level = 1;
        $stack_digit_actual[$stack_digit_level] = \%digit_to_tag_actual;
        $stack_digit[$stack_digit_level] = \%digit_to_tag;
        $stack_tag[$stack_tag_level] = \%tag_to_digit;
        while (<XML>) {
            chomp;
            $line = $_;
            if (!line_check(\$line)) {
            #checking for blank lines in XML config file
                last;
            }
            $line =~ s/\>[ ]+//g;
            $line=~tr/[<]/[>]/;
            #$line=~s/\s+//;
            my @temp = split(/\>/,$line);
            if ($temp[1] =~ /\//) {
                $temp[1] =~ s/\///g;
                end_tag_action($temp[1]);
            } else {
                start_tag_action($temp[1]);
            }
            if (defined($temp[2])) {
                value_action($temp[2]);
            }
            if (defined($temp[3])) {
                $temp[3] =~ s/\///g;
                end_tag_action($temp[3]);
            }
# print "populate_data_from_xml_files1 $line, $temp[1]\n";
        }
    }
}

sub generate_digit_to_tag_viceversa
{
    my $href = \%digit_to_tag;
    my $href1 = \%tag_to_digit;
    my $href2 = \%fldarraydbase_hash;
    my $tag;
    open(DB2,"$newdb2") or die "Can't open digitdot to string database File:$!";
    for my $line(<DB2>) {
        $href = \%digit_to_tag;
        $href1 = \%tag_to_digit;
        $href2 = \%fldarraydbase_hash;
        my @temp = split('\t', $line);   
        my @digit_dot = split('\.', $temp[0]);
        for (my $i=0; $i < $#digit_dot; $i++) {
            $tag = $$href{nxt}{$digit_dot[$i]}{tag};
            $href1 = \%{$$href1{nxt}{$tag}};
            $href = \%{$$href{nxt}{$digit_dot[$i]}};
            $href2 = \%{$$href2{nxt}{$digit_dot[$i]}};
        }
        $$href{nxt}{$digit_dot[$#digit_dot]}{tag} = $temp[1];
        $$href1{nxt}{$temp[1]}{digit} = $digit_dot[$#digit_dot];
        $href2 = \%{$$href2{nxt}{$digit_dot[$#digit_dot]}};
        $href = \%{$$href{nxt}{$digit_dot[$#digit_dot]}};
        if (defined($$href2{array})) {
            $$href{array} = $$href2{array};
#print "generate_digit_to_tag_viceversa1 $temp[0]\n";
        }
#print "generate_digit_to_tag_viceversa $temp[0], $temp[1], $digit_dot[$#digit_dot], \%{$$href{nxt}{$digit_dot[$#digit_dot]}}, \%{$$href1{nxt}{$temp[1]}}, $$href{nxt}{$digit_dot[$#digit_dot]}{tag}, $$href1{nxt}{$temp[1]}{digit}\n";
    }
    close(DB2);
}

sub special_tag_check
{
    my $tag = $_[0];

    if ($tag eq "XML_config_variables" || $tag eq "XML_crc_file_size" || $tag eq "XML__CRC__CHECKSUM") {
        return 1;
    }
    return 0;
}

sub start_tag_action
{
    my $start_tag = $_[0];
    my @temp;
    my $dummy;
    my $local;
    my $digit;
    my $actual;
    my $actlocal;
    my $t1;
    my $t2;
    
    if ($ignore_input_tags) {
        $stack_tag_level += 1;
        return;
    }
    $t1 = $start_tag;
    if ($start_tag =~ /=/) {
        $start_tag =~ s/\=\"/"/;
        ($t1, $t2) = split(' ', $start_tag, 2);
        @temp = split('\"', $t2);
    }
    $dummy = $stack_tag[$stack_tag_level];
# print "start_tag_action5 $t1, $dummy, $$dummy{nxt}, \%{$$dummy{nxt}{$t1}}\n";
    if ((!defined($$dummy{nxt}) || !defined($$dummy{nxt}{$t1})) && !special_tag_check($t1)) {
        $stack_tag_level += 1;
        $ignore_input_tags = 1;
        $ignore_input_tag_info{tag} = $t1;
        $ignore_input_tag_info{level} = $stack_tag_level;
# print "start_tag_action6 $t1, $stack_tag_level, $$dummy{nxt}, $$dummy{nxt}{$t1}\n";
        return;
    }
    if (special_tag_check($t1)) {
        return;
    }
    $local = \%{$$dummy{nxt}{$t1}};
# print "start_tag_action $start_tag, $$local{digit}, $t1, $stack_tag_level, $local, $stack_tag[$stack_tag_level]\n";
    $stack_tag_level += 1;
    $stack_tag[$stack_tag_level] = $local;
    $digit = $$local{digit};
    $dummy = $stack_digit[$stack_digit_level];
    $actual = $stack_digit_actual[$stack_digit_level];
    $local = \%{$$dummy{nxt}{$digit}};
# print "start_tag_action4 $start_tag, $$local{tag}, $digit, $stack_digit_level, $local, $stack_digit[$stack_digit_level]\n";
    $stack_digit_level += 1;
    $stack_digit[$stack_digit_level] = $local;
    if (defined($temp[0])) {
        for (my $i=0; $i <= $#temp; $i+=2) {
            $$local{$temp[$i]} =$temp[$i+1];
# print "start_tag_action2 $temp[$i], $temp[$i+1]\n";
        }
    }
    $actlocal = \%{$$actual{nxt}{$digit}};
    if (defined($$local{index})) {
        if (!defined($$actlocal{count})) {
            $$actlocal{count} = 0;
        } else {
            $$actlocal{count} += 1;
        }
        $$actlocal{array}[$$actlocal{count}] = $$local{index};
        $actlocal = \%{$$actlocal{instance}{$$local{index}}};
#print "start_tag_action1 $$local{index}, $digit, $t1, $stack_digit_level\n";
    }
# print "start_tag_action3 $actlocal, $stack_digit_level\n";
    $stack_digit_actual[$stack_digit_level] = $actlocal;
}

sub end_tag_action
{
    my $local = $stack_digit[$stack_digit_level];
   
    if ($ignore_input_tags) {
        if ($ignore_input_tag_info{level} == $stack_tag_level && $ignore_input_tag_info{tag} eq $_[0]) {
            $ignore_input_tags = 0;
        }
        $stack_tag_level -= 1;
        return;
    }
    if (special_tag_check($_[0])) {
        return;
    }
#print "end_tag_action $_[0], $$local{tag}, $stack_tag_level\n";
    if($$local{tag} eq $_[0]) {
        $stack_tag_level -= 1;
        $stack_digit_level -= 1;
    }
}

sub value_action
{
    my $local = $stack_digit_actual[$stack_digit_level];
    if ($ignore_input_tags) {
        return;
    }
    $$local{val} = $_[0];
#print "value_action $_[0], $$local{tag}\n";
}

sub line_check
{
    my $pline = $_[0];
    if ($$pline=~ /^$/){
        while (<XML>) {
            $$pline=$_;
            if ($$pline !~ /^$/){
                return 1;
            }
        }
        return 0;
    }
    return 1;
}

sub initialize_retcheck
{
    $retcheck[$CLI_INPUT_OPTIONAL] = 0;
    $retcheck[$ADVANCE_TO_NEXT_DEPTH] = 1;
    $retcheck[$END_OF_CLI_TREE] = 1;
    $retcheck[$NPUT_NOT_MATCHED] = 0;
    $retcheck[$INVALID_CLI_OPTION] = 0;
    $retcheck[$CLI_JUMP_OPTION] = 0;
    $retcheck[$INSUFFICIENT_CLI_OPTIONS] = 0;
    $retcheck[$NOOP_CLI_RETURN_OPTION] = 1;
    $retcheck[$UPDATE_CLI_NODE] = 1;
    $retcheck[$NO_INSTANCE_FOUND] = 0;
    $retcheck[$BACKTRACK_TO_PREVIOUS_LEVEL] = 0;
    $retcheck[$DELETE_CURRENT_AND_BACKTRACK_TO_PREVIOUS_LEVEL] = 0;
    $retcheck[$DONOT_UPDATE_CLI_NODE_AND_STOP] = 0;
    $retcheck[$MORE_INSTANCES_PRESENT] = 1;
    $retcheck[$NO_MORE_INSTANCES] = 0;
    $retcheck[$CLI_PRINTED] = 1;
    $retcheck[$PARAM_UPDATE_SUCCESS] = 1;
    $retcheck[$STRVALMAP_NO_VALUE_FOUND] = 0;
    $retcheck[$STRVALMAP_NO_STRING_FOUND] = 0;
    $retcheck[$GET_NEXT_INDEX_FOR_SET_LEVEL] = 0;
    $retcheck[$TAG_FORMAT_NOT_MATCHED] = 1;
    $retcheck[$TAG_FORMAT_MATCHED] = 1;
    $retcheck[$GET_NEXT_INDEX_FOR_SET_LEVEL_INITIAL] = 1;
    $retcheck[$GET_NEXT_INDEX_FOR_SET_LEVEL_ARRAYALL] = 0;
    $retcheck[$NO_INSTANCE_FOUND_ARRAYALL] = 0;
}

sub initialize_parser_action
{
    $parser_action[$local_node] = \&local_node;
    $parser_action[$pre_action] = \&pre_action;
    $parser_action[$post_action] = \&post_action;
    $parser_action[$cli_map] = \&cli_map;
    $parser_action[$keyword_string] = \&keyword_string;
    $parser_action[$value_field] = \&value_field;
    $parser_action[$action_value] = \&action_value;
    $parser_action[$action_string_value] = \&action_string_value;
    $parser_action[$action_local_node] = \&action_local_node;
    $parser_action[$action_node] = \&action_node;
    $parser_action[$reverse_action] = \&reverse_action;
    $parser_action[$action_map] = \&action_map;
    $parser_action[$keyword_string_map] = \&keyword_string_map;
    $parser_action[$action_node_arraybase] = \&action_node_arraybase;
    $parser_action[$keyword_string_with_local] = \&keyword_string_with_local;
    $parser_action[$keyword_string_special] = \&keyword_string_special;
    $parser_action[$keyword_string_special_with_local] = \&keyword_string_special_with_local;
    $parser_action[$action_node_arraybase_field] = \&action_node_arraybase_field;
    $parser_action[$action_node_arrayall] = \&action_node_arrayall;
}

sub local_node
{
    my $input = $_[0];
    my $input_present = $_[1];
    my $inpcmd = $_[2];
    my $href = $_[3];
    my $result;
    my $string;

    my @tmp = split(/\%/, $inpcmd);
    $$href = $tmp[1];
    
# print "local_node $$href\n";
    $gbl_local_node_value[$tmp[0]] = $input;

    return $PARAM_UPDATE_SUCCESS;
}


sub pre_action
{
    my $input = $_[0];
    my $input_present = $_[1];
    my $inpcmd = $_[2];
    my $href = $_[3];
    my $result;

#    my @tmp = split(/\./, $inpcmd, 2);
    my @tmp1 = split(/\)/, $inpcmd, 2);
    my @tmp2 = split(/\(/, $tmp1[0], 2);   
    
    $$href = $tmp1[1];

# print "pre_action\n";
    $result = $action_array[$tmp2[0]]($tmp2[1]);        

    if ($result == $CLI_INPUT_OPTIONAL) {
        if ($current_optional_level_present == 0)  {
            $current_optional_level_present = 1;
            $current_optional_level = $clitoxmldb1_ptr_level;
        }
        $clitoxmldb1_optional_instances{instance}[$clitoxmldb1_ptr_level]{optional} = 1;
# print "pre_action $clitoxmldb1_ptr_level, $clitoxmldb1_optional_instances{instance}[$clitoxmldb1_ptr_level]{optional}\n";
        $result = $NOOP_CLI_RETURN_OPTION;
    }

    return $result;
}

sub optional_input
{
    return $CLI_INPUT_OPTIONAL;
}

sub post_action
{
    my $input = $_[0];
    my $input_present = $_[1];
    my $inpcmd = $_[2];
    my $href = $_[3];
#    my $result;

#    my @tmp = split(/\./, $inpcmd, 2);
    my @tmp1 = split(/\)/, $inpcmd, 2);
    my @tmp2 = split(/\(/, $tmp1[0], 2);   
    
    $$href = $tmp1[1];

    return $NOOP_CLI_RETURN_OPTION;
#    $result = $action_array[$tmp2[0]]($tmp2[1]);        
#
#    return $result;  
}

sub reverse_action
{
    my $input = $_[0];
    my $input_present = $_[1];
    my $inpcmd = $_[2];
    my $href = $_[3];
    my $result = $NOOP_CLI_RETURN_OPTION;

#print "reverse_action0 $input, $input_present, $inpcmd, $$href\n";
#    my @tmp = split(/\./, $inpcmd, 2);
    my @tmp1 = split(/\)/, $inpcmd, 2);
    my @tmp2 = split(/\(/, $tmp1[0], 2);   
    
    $$href = $tmp1[1];

#print "reverse_action1 $tmp2[0], $tmp2[1], $clitoxmldb1_ptr_level, $clitoxmldb1_optional_instances{instance}[$clitoxmldb1_ptr_level]{optional}\n";
    $result = $action_array[$tmp2[0]]($tmp2[1]);        
#print "reverse_action $$href, $tmp2[0], $tmp2[1], $result, $clitoxmldb1_ptr_level\n";

    return $result;  
}

sub value_field
{
    my $input = $_[0];
    my $input_present = $_[1];
    my $inpcmd = $_[2];
    my $href = $_[3];

#    my @tmp = split(/\./, $inpcmd, 2);
    my @tmp1 = split(/\)/, $inpcmd, 2);
    my @tmp2 = split(/\(/, $tmp1[0], 2);   
    
    $$href = $tmp1[1];

    return $NOOP_CLI_RETURN_OPTION;;
}

sub cli_map
{
    my $input = $_[0];
    my $input_present = $_[1];
    my $inpcmd = $_[2];
    my $href = $_[3];
    my $result = $NOOP_CLI_RETURN_OPTION;

    if (!defined($string_value_map[$inpcmd])) {
        print "Index $inpcmd is not part of string value map in CLI $input_cli\n";
        die;
    } else {
        $$href = $string_value_map[$inpcmd];
    }
    return $result;
}

sub action_value
{
    my $input = $_[0];
    my $input_present = $_[1];
    my $inpcmd = $_[2];
    my $href = $_[3];
    my $result = $PARAM_UPDATE_SUCCESS;

    $$href = convert_hex_to_decimal($inpcmd);
# print "action_value1 $$href\n";
    return $result;    
}

sub action_string_value
{
    my $input = $_[0];
    my $input_present = $_[1];
    my $inpcmd = $_[2];
    my $href = $_[3];
    my $result = $PARAM_UPDATE_SUCCESS;

    if (!defined($string_map[$inpcmd])) {
        print "Index $inpcmd is not part of string map in CLI $input_cli\n";
        die;
    } else {
        $$href = $string_map[$inpcmd];
    }
    return $result;
}

sub action_local_node
{
    my $input = $_[0];
    my $input_present = $_[1];
    my $inpcmd = $_[2];
    my $href = $_[3];
    my $result = $PARAM_UPDATE_SUCCESS;

    $$href = $gbl_local_node_value[$inpcmd];
    return $result;    
}

sub action_map
{
    my $input = $_[0];
    my $input_present = $_[1];
    my $inpcmd = $_[2];
    my $href = $_[3];
    my $result = $PARAM_UPDATE_SUCCESS;

    if (!defined($string_value_map[$inpcmd])) {
        print "Index $inpcmd is not part of string value map in CLI $input_cli\n";
        die;
    } else {
        $$href = $string_value_map[$inpcmd];
    }
# print "action_map1 $$href, $inpcmd\n";
    return $result;
}

sub param_value_return
{
    my $input = $_[0];
    my $pparam = $_[1];
    my $result;

    my @tmp1 = split(/\./, $input, 2);

#print "param_value_return1 $tmp1[0], $input, $tmp1[1]\n";
    $result = $parser_action[$tmp1[0]]($input, 0, $tmp1[1], $pparam);
#print "param_value_return2 $tmp1[0], $input, $tmp1[1], $$pparam\n";
    return $result;
}

sub paramall_value_return
{
    my $input = $_[0];
    my $pparam = $_[1];
    my $result = $PARAM_UPDATE_SUCCESS;
    my $param_local = "";
    my $cnt;

    my @tmp1 = split(/\./, $input, 2);
    while($result == $PARAM_UPDATE_SUCCESS) {
        $result = $parser_action[$tmp1[0]]($input, 0, $tmp1[1], \$param_local);
#print "paramall_value_return1 $param_local, $$pparam\n";
        if($result == $PARAM_UPDATE_SUCCESS) {
            my @tmp = split(' ', $param_local);
            if($cnt > 0) {
                $$pparam .= ",$tmp[0]";
            } else {
                $$pparam = $tmp[0];
            }
            $cnt += 1;
	}
    }

    return $result;
}

sub action_node_internal
{
    my $input = $_[0];
    my $input_present = $_[1];
    my $inpcmd = $_[2];
    my $pparam = $_[3];
    my $arraybase = $_[4];
    my $dimflag = $_[5];
    my $href;
    my $prevhref;
    my $retref;
    my $result = 0;
    my @instptr;
    my $index = 0;
    my $result = $PARAM_UPDATE_SUCCESS;
    my $partialtag = "";
    my $first = 1;
    my $level = 0;
    my $transitfielddim = 0;
    my $lvlchngd = 0;
    my $mismachnotreqd =0;
    my $tmplvl = 0;
    my @invalid_tag_level;
    my @invalid_partialtag;
    my $invalid_tag_level_index = 0;
    my $found = 1;
#Transition vars.
    my $hreffldtransition;
    my $transition_dim;
    my $maxdd;
    my $fldval;

    my @temp = split(/\./, $inpcmd);

    $href = \%digit_to_tag_actual;

#print "action_node_internal $index, $temp[$index], $inpcmd, $current_instance_indices_level\n";
    if ($output_cli_type == $show_invalid_config) {
        if (!check_if_field_present_at_instance($inpcmd,\$fldval, $dimflag)) {
#print "action_node_internal111 NO_INSTANCE_FOUND $inpcmd, $temp[$index], $index, $current_instance_indices{instance}[$current_instance_indices_level]{arridx}\n";
            $invalid_cli_found = 0;
            return $NO_INSTANCE_FOUND;
        } elsif ($glb_flag_arrayall == 1) {
            my $tmpfldval;
            my $num_arrayall = 0;
            my $tmpparam;
            if ($glb_flag_arrayall_action == 1) {
                $result = map_xml_format_to_cli_format($fldval, $inpcmd, 1, \$tmpparam);
                my @tmpcountry = split(' ',$tmpparam);
                $glb_country_buffer = "$tmpcountry[0]";
                $glb_country_count = 1;
            }
            $current_instance_indices{instance}[$current_instance_indices_level]{arridx}+=1;
            while(check_if_field_present_at_instance($inpcmd,\$tmpfldval, $dimflag)) {
                if (check_invalid_config_tag_and_instance_present($inpcmd)) {
                    $invalid_cli_found = 1;
                }
               if ($glb_flag_arrayall_action == 1) {
                   $result = map_xml_format_to_cli_format($tmpfldval, $inpcmd, 1, \$tmpparam);
                   my @tmpcountry = split(' ',$tmpparam);
                   $glb_country_buffer .= ",$tmpcountry[0]";
                   $glb_country_count += 1;
               } else {
                   $fldval .= " " . $tmpfldval;
               }
               $current_instance_indices{instance}[$current_instance_indices_level]{arridx}+=1;
            }
        } else {
            if (check_invalid_config_tag_and_instance_present($inpcmd)) {
                $invalid_cli_found = 1;
            }
        }
    } else {
        if (!check_if_field_present_at_instance($inpcmd,\$fldval, $dimflag)) {
#print "action_node_internal111 NO_INSTANCE_FOUND $inpcmd, $temp[$index], $index, $current_instance_indices{instance}[$current_instance_indices_level]{arridx}, $current_instance_indices_level\n";
            return $NO_INSTANCE_FOUND;
        } elsif ($glb_flag_arrayall == 1) {
            my $tmpfldval;
            my $num_arrayall = 0;
            my $tmpparam;
            #my $bufferdone = 0;
            if ($glb_flag_arrayall_action == 1) {
                $result = map_xml_format_to_cli_format($fldval, $inpcmd, 1, \$tmpparam);
                my @tmpcountry = split(' ',$tmpparam);
                $glb_country_buffer = "$tmpcountry[0]";
                $glb_country_count = 1;
            }
            $current_instance_indices{instance}[$current_instance_indices_level]{arridx}+=1;
#print "AAA: action_node_internal112 $current_instance_indices_level, $current_instance_indices{instance}[$current_instance_indices_level]{arridx}\n";
#            while(check_if_field_present_at_instance($inpcmd,\$tmpfldval, $dimflag) && ($bufferdone == 0)) {
            while(check_if_field_present_at_instance($inpcmd,\$tmpfldval, $dimflag)) {
               if ($glb_flag_arrayall_action == 1) {
                   $result = map_xml_format_to_cli_format($tmpfldval, $inpcmd, 1, \$tmpparam);
                   my @tmpcountry = split(' ',$tmpparam);
                   if (!defined($tmpcountry[0])) {
#                       $bufferdone = 1;
#print "Ended $tmpparam:$tmpcountry search\n";
                   } else {
#print "Continued $tmpparam:$tmpcountry search\n";
                       $glb_country_buffer .= ",$tmpcountry[0]";
                       $glb_country_count += 1;
                   }
               } else {
                   $fldval .= " " . $tmpfldval;
#print "CCC: action_node_internal112 $fldval\n";
               }
               $current_instance_indices{instance}[$current_instance_indices_level]{arridx}+=1;
#print "BBB: action_node_internal112 $current_instance_indices_level, $current_instance_indices{instance}[$current_instance_indices_level]{arridx}\n";
            }
        }
    }
#    for ($index = 0; $index <= $#temp; $index++) {
#        $prevhref = $href;
#        if ($index == 0) {
#            $partialtag = $temp[$index];
#        } else {
#            $partialtag = $partialtag . "." . $temp[$index];
#        }
# print "action_node1 $index, $temp[$index], $inpcmd, $href\n";
#        if (!defined($$href{nxt}{$temp[$index]})) {
#            $invalid_cli_found = 0;
#print "action_node2 $index, $temp[$index], $inpcmd, $partialtag, $href, $invalid_cli_found, $clitoxmldb1_ptr_level, $clitoxmldb1_optional_instances{instance}[$clitoxmldb1_ptr_level]{optional}\n";

 #           $hreffldtransition = $clitoxmldb1_ptr[$clitoxmldb1_ptr_level]; 
#            if(defined($$hreffldtransition{transition})) {
#                $nextjumpcli{nextcli} = $$hreffldtransition{transition}{nextjump};
#            }
#print "action_node_internal111 NO_INSTANCE_FOUND $inpcmd, $temp[$index], $index\n";
#            return $NO_INSTANCE_FOUND;
#        } else {
#            $href = \%{$$href{nxt}{$temp[$index]}};
#        }
##############################################################################################
#        if (defined($$href{array})) {
#            $level += 1;
#            $transitfielddim += 1;
#            $first = 0;
#            if ($level > $current_instance_indices_level) {
#                $current_instance_indices_level = $level;
#            }
#            $result = check_level_and_create_instances($href, \$current_instance_indices_level, $level, $inpcmd, \$retref, $partialtag, \$lvlchngd, \$mismachnotreqd);
#print "action_node3 $index, $temp[$index], $inpcmd, $partialtag, $retref, $level, $current_instance_indices_level, $result, $clitoxmldb1_optional_instances{instance}[$clitoxmldb1_ptr_level]{optional}\n";
#            if ($result == $NO_INSTANCE_FOUND || $result == $GET_NEXT_INDEX_FOR_SET_LEVEL) {
#                return $result;
#            }
#            $href = $retref;
#            if (defined($invalid_config_tag_hash{tag}{$partialtag})) {
# print "action_node_internal10 $partialtag\n";
#                $invalid_tag_level[$invalid_tag_level_index] = $level;
#                $invalid_partialtag[$invalid_tag_level_index] = $partialtag;
#                $invalid_tag_level_index += 1;
#            }
#        }
#    }

#    if ($level != $current_instance_indices_level && $lvlchngd == 0 && $mismachnotreqd == 0) {
#        $result = check_and_shift_instance_level($href, \$current_instance_indices_level, $current_instance_indices_level, $inpcmd, \$retref, $partialtag, \$lvlchngd, \$mismachnotreqd);
#        if ($result == $GET_NEXT_INDEX_FOR_SET_LEVEL) {
#            return $result;
#        }
#    }
#################################################################################################
# print "action_node_internal6 $global_string_for_byte, $inpcmd, $flag_for_byte_end_check, $lvlchngd, $flag_for_byte_string_cli_check, $clitoxmldb1_ptr_level, $clitoxmldb1_ptr_level_prev_byte_array\n";
    if ($current_optional_level_present == 1)  {
         $glb_flag_action_node_internal_with_optional = 1;
#        for (my $i = $current_optional_level; $i <= $clitoxmldb1_ptr_level; $i++) {
#            delete($clitoxmldb1_optional_instances{instance}[$i]{optional});
#        }
#        $current_optional_level_present = 0;
    }
    if ($lvlchngd == 1) {
        $tmplvl = $clitoxmldb1_ptr_level;
        $clitoxmldb1_ptr_level = $clitoxmldb1_ptr_level_prev_byte_array;
        if ($flag_for_byte_string_cli_check == 0) {
            $flag_for_byte_string_cli_check = 1;
            $flag_for_byte_end_check = 0;
            update_cli_tree_with_value($global_string_for_byte, $inpcmd, 1);
        } elsif ($flag_for_byte_mac_cli_check == 0) {
            $flag_for_byte_mac_cli_check = 1;
            for (my $i = ($prev_global_mac_instance_index + 1); $i <= 5; $i++) {
                $global_string_for_byte = $global_string_for_byte .":". "00";
            }
            update_cli_tree_with_value($global_string_for_byte, $inpcmd, 1);
        }
        $clitoxmldb1_ptr_level = $tmplvl;
        $clitoxmldb1_ptr_level_prev_byte_array = $tmplvl;
    }
#print "action_node4 $index, $temp[$index], $inpcmd, $level, $$href{val}, $current_instance_indices{instance}[$level]{index}, $current_instance_indices_level\n";
    if ($arraybase == $arraybase_present) {
         $newdim = get_dim_if_instance_present($inpcmd); 
#print "action_node_internal: newdim: $newdim\n";
         $$pparam = $current_instance_indices{instance}[$newdim]{index};
#print "Array Base $$pparam\n";
    } elsif ($glb_flag_arrayall == 1){
         $$pparam = $fldval;
    } else {
        #$result = map_xml_format_to_cli_format($$href{val}, $inpcmd, 1, $pparam);
        $result = map_xml_format_to_cli_format($fldval, $inpcmd, 1, $pparam);
    }
#    if ($output_cli_type == $show_invalid_config && (defined($invalid_config_tag_hash{tag}{$inpcmd}) || $invalid_tag_level != 0)) {
#        if (!$first) {
#print "action_node8 $inpcmd, $current_instance_indices_level, $invalid_tag_level\n";
#            $invalid_tag_level[$invalid_tag_level_index] = $current_instance_indices_level;
#            $invalid_partialtag[$invalid_tag_level_index] = $inpcmd;
#            $invalid_tag_level_index += 1;
#            for (my $j = 0; $j < $invalid_tag_level_index; $j++) {
#                $found = 1;
#                for (my $i = 0; $i < $invalid_tag_level[$j]; $i++) {
#                    $index = $current_instance_indices{instance}[($i + 1)]{index};
#print "action_node9 $inpcmd, $i, $invalid_config_tag_hash{instance}{$invalid_partialtag[$j]}{array}[$i]{$index}, $index, $current_instance_indices{instance}[($i+1)]{index}, $invalid_partialtag[$j], $j\n";
#                    if (!defined($invalid_config_tag_hash{instance}{$invalid_partialtag[$j]}{array}[$i]{$index})) { 
#                        $found = 0;
#                        last;
#                    }
#                }
#                if ($found) {
#                    $invalid_cli_found = 1;
#                    return $result;
#                }
#            }
#print "action_node6 $invalid_cli_found $inpcmd, $invalid_partialtag, $current_instance_indices_level\n";
#        } else {
#            $invalid_cli_found = 1;
#print "action_node7 $invalid_cli_found $inpcmd, $invalid_partialtag\n";
#        }
#    }
    return $result;
}

sub action_node_arrayall
{
    my $input = $_[0];
    my $input_present = $_[1];
    my $inpcmd = $_[2];
    my $pparam = $_[3];
    my $result = $PARAM_UPDATE_SUCCESS;

    $glb_flag_arrayall = 1;
#print "action_node_arrayall $input, $inpcmd, $clitoxmldb1_ptr_level, $clitoxmldb1_optional_instances{instance}[$clitoxmldb1_ptr_level]{optional}\n";
    $result = action_node_internal($input, $input_present, $inpcmd, $pparam, $arraybase_not_present, 1);
#print "Arrayall $$pparam,$tmp[0], $result\n";
    $glb_flag_arrayall = 0;
    return $result;
}


sub action_node
{
    my $input = $_[0];
    my $input_present = $_[1];
    my $inpcmd = $_[2];
    my $pparam = $_[3];
    my $result;

#print "action_node $clitoxmldb1_ptr_level, $clitoxmldb1_optional_instances{instance}[$clitoxmldb1_ptr_level]{optional}\n";
    $result = action_node_internal($input, $input_present, $inpcmd, $pparam, $arraybase_not_present, 1);
    return $result;
}

sub action_node_arraybase
{
    my $input = $_[0];
    my $input_present = $_[1];
    my $inpcmd = $_[2];
    my $pparam = $_[3];
    my $result = $PARAM_UPDATE_SUCCESS;

#print "action_node_arraybase $input , $input_present, $inpcmd, $pparam, $result\n";

    $result = action_node_internal($input, $input_present, $inpcmd, $pparam, $arraybase_present, 0);
    
    return $result;
}

sub action_node_arraybase_field
{
    my $input = $_[0];
    my $input_present = $_[1];
    my $inpcmd = $_[2];
    my $pparam = $_[3];

    $$pparam = $inpcmd;
    return $PARAM_UPDATE_SUCCESS;
}

sub check_tag_format
{
    my $input = $_[0];
    my $saved = $_[1];

    my @tmp1 = split(/\./, $input);
    my @tmp2 = split(/\./, $saved);

    if ($#tmp1 < $#tmp2) {
        return $TAG_FORMAT_NOT_MATCHED;
    }
    for (my $i = 0; $i <= $#tmp2; $i++) {
        if ($tmp1[$i] ne $tmp2[$i]) {
            return $TAG_FORMAT_NOT_MATCHED;
        }
    }
    return $TAG_FORMAT_MATCHED;
}

sub check_tag_format_and_return_mismatched_level
{
    my $input = $_[0];
    my $onematched = 0;

    for (my $i = $initial_current_instance_indices_level; $i <= $current_instance_indices_level; $i++) {
# print "check_tag_format_and_return_mismatched_level1 $input, $current_instance_indices{instance}[$i]{partialtag}\n";
        if (defined($current_instance_indices{instance}[$i]{partialtag})) {
            if (check_tag_format($input, $current_instance_indices{instance}[$i]{partialtag}) == $TAG_FORMAT_NOT_MATCHED) {
                return $i;
            } else {
                $onematched = 1;
            }
        }
    }
    if ($onematched) {
# print "check_tag_format_and_return_mismatched_level2 $current_instance_indices_level\n";
        return ($current_instance_indices_level + 1);
    } else {
# print "check_tag_format_and_return_mismatched_level3 $input, 0\n";
        return 0;
    }
}

sub check_level_and_create_instances
{
    my $href = $_[0];
    my $pmaxlevel = $_[1];
    my $curlevel = $_[2];
    my $input = $_[3];
    my $retref = $_[4];
    my $partialtag = $_[5];
    my $plvlchnged = $_[6];
    my $pmismatchnotreqd = $_[7];
    my $count = 0;
    my $result = $PARAM_UPDATE_SUCCESS;
    my $mismatched_level;
    my $tagref;
    my $arrindex;
    
    if (defined($current_instance_indices{instance}[$curlevel])) {
        $result = check_and_shift_instance_level($href, $pmaxlevel, $curlevel, $input, $retref, $partialtag, $plvlchnged, $pmismatchnotreqd);
# print "check_level_and_create_instances11 $input, $result\n";
        if ($result == $GET_NEXT_INDEX_FOR_SET_LEVEL) {
            return $result;
        }
        if ($result == $NO_INSTANCE_FOUND_ARRAYALL) {
            return $result;
        }
        if ($$pmaxlevel == 0) {
            $$pmaxlevel = $initial_current_instance_indices_level;
        }
    } else {
        update_prev_cli_buffer($$pmaxlevel);
    }

    if (!defined($current_instance_indices{instance})) {
        if (defined($direct_index_from_keyword{$partialtag})) {
            $index = $direct_index_from_keyword{$partialtag}{index};
            if (!defined($$href{instance}{$index})) {
                $invalid_cli_found = 0;
# print "check_level_and_create_instances9 $input, $index, $invalid_cli_found\n";
                return $NO_INSTANCE_FOUND;
            }
            $current_instance_indices{instance}[$curlevel]{index} = $index;
        } else {
            $current_instance_indices{instance}[$curlevel]{index} = $$href{array}[0];
            $index = $$href{array}[0];
        }
        $current_instance_indices{instance}[$curlevel]{arridx} = 0;
        if (!defined($current_instance_indices{tag}{$input})) {
            $current_instance_indices{tag}{$input} = $curlevel;
        }
        $clitoxmldb1_instances{instance}[$clitoxmldb1_ptr_level]{index} = $index;
        $current_instance_indices{instance}[$curlevel]{tag} = $input;
        for (my $i = 0; $i <= $clitoxmldb1_ptr_level; $i++) {
            $current_instance_indices{instance}[$curlevel]{clidb}[$i]{cliref} = $clitoxmldb1_ptr[$i];
            $current_instance_indices{instance}[$curlevel]{clidb}[$i]{cliidx} = $clitoxmldb1_index[$i];
            if (defined($clitoxmldb1_instances{instance}[$i]{val})) {
                $current_instance_indices{instance}[$curlevel]{clidb}[$i]{clival} = $clitoxmldb1_instances{instance}[$i]{val};
            }
        }
        $current_instance_indices{instance}[$curlevel]{clidblvl} = $clitoxmldb1_ptr_level;
        $current_instance_indices{instance}[$curlevel]{partialtag} = $partialtag;
        $current_instance_indices{instance}[$curlevel]{tagref} = $href;
        $$retref = \%{$$href{instance}{$index}};
# print "check_level_and_create_instances3 $$href{instance}{$index}{val}, $input, $index, $partialtag, $current_instance_indices{instance}[$curlevel]{partialtag}, $curlevel\n";
    } elsif (!defined($current_instance_indices{instance}[$curlevel]{index})) {
        if (defined($direct_index_from_keyword{$partialtag})) {
            $index = $direct_index_from_keyword{$partialtag}{index};
            if (!defined($$href{instance}{$index})) {
                $invalid_cli_found = 0;
# print "check_level_and_create_instances10 $input, $index, $invalid_cli_found\n";
                return $NO_INSTANCE_FOUND;
            }
            $current_instance_indices{instance}[$curlevel]{index} = $index;
        } else {
            $current_instance_indices{instance}[$curlevel]{index} = $$href{array}[0];
            $index = $$href{array}[0];
        }
        $current_instance_indices{instance}[$curlevel]{arridx} = 0;
        if (!defined($current_instance_indices{tag}{$input})) {
            $current_instance_indices{tag}{$input} = $curlevel;
        }
        $clitoxmldb1_instances{instance}[$clitoxmldb1_ptr_level]{index} = $index;
        $clitoxmldb1_instances{instance}[$clitoxmldb1_ptr_level]{count} += 1;
        $current_instance_indices{instance}[$curlevel]{tag} = $input;
        for (my $i = 0; $i <= $clitoxmldb1_ptr_level; $i++) {
            $current_instance_indices{instance}[$curlevel]{clidb}[$i]{cliref} = $clitoxmldb1_ptr[$i];
            $current_instance_indices{instance}[$curlevel]{clidb}[$i]{cliidx} = $clitoxmldb1_index[$i];
            if (defined($clitoxmldb1_instances{instance}[$i]{val})) {
                $current_instance_indices{instance}[$curlevel]{clidb}[$i]{clival} = $clitoxmldb1_instances{instance}[$i]{val};
            }
        }
        $current_instance_indices{instance}[$curlevel]{clidblvl} = $clitoxmldb1_ptr_level;
        $current_instance_indices{instance}[$curlevel]{partialtag} = $partialtag;
        $current_instance_indices{instance}[$curlevel]{tagref} = $href;
        $$retref = \%{$$href{instance}{$index}};
# print "check_level_and_create_instances4 $$href{instance}{$index}{val}, $input, $index, $partialtag, $current_instance_indices{instance}[$curlevel]{partialtag}, $curlevel\n";
    } elsif (defined($current_instance_indices{tag}{$input}) && $curlevel >= $current_instance_indices{tag}{$input}) {
        if (defined($direct_index_from_keyword{$current_instance_indices{instance}[$curlevel]{partialtag}})) {
            $index = $direct_index_from_keyword{$current_instance_indices{instance}[$curlevel]{partialtag}}{index};
            if (!defined($$href{instance}{$index})) {
                $invalid_cli_found = 0;
# print "check_level_and_create_instances11 $input, $index, $invalid_cli_found\n";
                return $NO_INSTANCE_FOUND;
            }
            $current_instance_indices{instance}[$curlevel]{index} = $index;
        } else {
            $arrindex = $current_instance_indices{instance}[$curlevel]{arridx};
            if (!defined($$href{array}[$arrindex])) {
                $invalid_cli_found = 0;
# print "check_level_and_create_instances2 $input, $index, $arrindex, $invalid_cli_found\n";
                return $NO_INSTANCE_FOUND;
            }
            $current_instance_indices{instance}[$curlevel]{index} = $$href{array}[$arrindex];
            $index = $$href{array}[$arrindex];
        }
        $clitoxmldb1_instances{instance}[$clitoxmldb1_ptr_level]{index} = $index;
        $$retref = \%{$$href{instance}{$index}};
# print "check_level_and_create_instances5 $$href{instance}{$index}{val}, $input, $index, $partialtag, $current_instance_indices{instance}[$curlevel]{partialtag}, $curlevel\n";
    } else {
        if (defined($direct_index_from_keyword{$partialtag})) {
            $index = $direct_index_from_keyword{$partialtag}{index};
            if (!defined($$href{instance}{$index})) {
                $invalid_cli_found = 0;
# print "check_level_and_create_instances12 $input, $index, $invalid_cli_found\n";
                return $NO_INSTANCE_FOUND;
            }
            $current_instance_indices{instance}[$curlevel]{index} = $index;
        }
        $index = $current_instance_indices{instance}[$curlevel]{index};
        if (!defined($$href{instance}{$index})) {
            $invalid_cli_found = 0;
# print "check_level_and_create_instances1 $input, $index, $invalid_cli_found\n";
            return $NO_INSTANCE_FOUND;
        }
        $clitoxmldb1_instances{instance}[$clitoxmldb1_ptr_level]{index} = $index;
        $$retref = \%{$$href{instance}{$index}};
# print "check_level_and_create_instances6 $$href{instance}{$index}{val}, $input, $index, $partialtag, $current_instance_indices{instance}[$curlevel]{partialtag}, $curlevel\n";
    }
# print "check_level_and_create_instances $curlevel, $result, $input, $partialtag, $current_instance_indices{instance}[$curlevel]{index}, $current_instance_indices{instance}[$curlevel]{arridx}, $current_instance_indices_level\n";
    return $result;
}

sub check_for_cli_change_and_mismatch_required
{
    my $curlevel = $_[0];
    my $pmismatchnotreqd = $_[1];
    if($glb_prev_level <= $curlevel) {
        return 1;
    }
    for(my $i=0; $i<=$glb_clitoxmldb1_ptr_level_prev; $i++) {
        if($glb_clitoxmldb1_ptr_prev[$i] != $clitoxmldb1_ptr[$i]) {
            return 1;
        }
    }
# print "check_for_cli_change_and_mismatch_required : Not required\n";
    $$pmismatchnotreqd = 1;
    return 0;
}

sub update_prev_cli_buffer
{
    my $curlevel = $_[0];
    $glb_prev_level = $curlevel;
    $glb_clitoxmldb1_ptr_level_prev = $clitoxmldb1_ptr_level;
    for(my $i=0; $i<=$glb_clitoxmldb1_ptr_level_prev; $i++) {
        $glb_clitoxmldb1_ptr_prev[$i] = $clitoxmldb1_ptr[$i];
    }
}


sub check_and_shift_instance_level
{
    my $href = $_[0];
    my $pmaxlevel = $_[1];
    my $curlevel = $_[2];
    my $input = $_[3];
    my $retref = $_[4];
    my $partialtag = $_[5];
    my $plvlchnged = $_[6];
    my $pmismatchnotreqd = $_[7];
    my $count = 0;
    my $result = $PARAM_UPDATE_SUCCESS;
    my $mismatched_level;
    my $tagref;
    my $arrindex;
    my $prevmaxlvl;

    $$plvlchnged = 0;

    $mismatched_level = check_tag_format_and_return_mismatched_level($input);
# print "check_and_shift_instance_level1, $input, $current_instance_indices{instance}[$$pmaxlevel]{partialtag}, $partialtag, $current_instance_indices{instance}[$$pmaxlevel]{index}, $clitoxmldb1_ptr_level, $$pmaxlevel, $mismatched_level, $curlevel\n";
    if(($glb_flag_arrayall == 1) && ($input eq $partialtag) && ($input eq $current_instance_indices{instance}[$$pmaxlevel]{partialtag})) {
# print "global array fld: $input, $glb_flag_arrayall, $gbl_arraybaseflag, $partialtag\n";
        $mismatched_level = $$pmaxlevel;
    }

    if (($mismatched_level <= $$pmaxlevel)&& check_for_cli_change_and_mismatch_required($curlevel, $pmismatchnotreqd)) {
        update_prev_cli_buffer($$pmaxlevel);
        $prevmaxlvl = $$pmaxlevel;
        $$plvlchnged = 1;
        for (my $i = $$pmaxlevel; $i >= $mismatched_level; $i--) {
# print "check_and_shift_instance_level2 $current_instance_indices{instance}[$i]{partialtag}\n";
            if (defined($direct_index_from_keyword{$current_instance_indices{instance}[$i]{partialtag}})) {
                next;
            }
            $tagref = $current_instance_indices{instance}[$i]{tagref};
            $arrindex = $current_instance_indices{instance}[$i]{arridx};
            $arrindex += 1;
            if (defined($$tagref{array}[$arrindex])) {
                for (my $j = ($i + 1); $j <= $$pmaxlevel; $j++) {
                    delete($current_instance_indices{instance}[$j]);
                }
                if ($i == $prevmaxlvl) {
                    $$plvlchnged = 0;
                }
                $$pmaxlevel = $i;
                $current_instance_indices{instance}[$i]{arridx} += 1;
                $current_instance_indices{instance}[$i]{index} = $$tagref{array}[$arrindex];
# print "check_and_shift_instance_level3, $input, $current_instance_indices{instance}[$$pmaxlevel]{partialtag}, $i, $arrindex, $current_instance_indices{instance}[$i]{arridx}, $current_instance_indices{instance}[$i]{clidblvl}, $clitoxmldb1_ptr_level, $$pmaxlevel, $mismatched_level\n";
                if(($glb_flag_arrayall != 1) || ($input ne $partialtag) || ($input ne $current_instance_indices{instance}[$$pmaxlevel]{partialtag})) {
                    for (my $j = 0; $j <= $current_instance_indices{instance}[$i]{clidblvl}; $j++) {
                        $clitoxmldb1_ptr[$j] = $current_instance_indices{instance}[$i]{clidb}[$j]{cliref};
                        $clitoxmldb1_index[$j] = $current_instance_indices{instance}[$i]{clidb}[$j]{cliidx};
                        if (defined($current_instance_indices{instance}[$i]{clidb}[$j]{clival})) {
                            $clitoxmldb1_instances{instance}[$j]{val} = $current_instance_indices{instance}[$i]{clidb}[$j]{clival};
                        }
                    }
# print "check_and_shift_instance_level4, $j: $clitoxmldb1_index[$j]\n";
                    $clitoxmldb1_ptr_level = $current_instance_indices{instance}[$i]{clidblvl};
                }
                if(($glb_flag_arrayall != 1) || ($input ne $partialtag) || ($input ne $current_instance_indices{instance}[$$pmaxlevel]{partialtag})) {
                    return $GET_NEXT_INDEX_FOR_SET_LEVEL;
                }
            } elsif(($glb_flag_arrayall == 1) && ($input eq $partialtag) && ($input eq $current_instance_indices{instance}[$$pmaxlevel]{partialtag})) {
                return $NO_INSTANCE_FOUND;
            }
        }
        if(($glb_flag_arrayall != 1) || ($input ne $partialtag) || ($input ne $current_instance_indices{instance}[$$pmaxlevel]{partialtag})) {
            for (my $i = $mismatched_level; $i <= $$pmaxlevel; $i++) {
                delete($current_instance_indices{instance}[$i]);
            }
            $$plvlchnged = 1;
            #$$pmaxlevel = $mismatched_level;
            if ($mismatched_level > 0) {
                $$pmaxlevel = $mismatched_level - 1;
            } else {
                $$pmaxlevel = 0;
            }
        }
    }
    update_prev_cli_buffer($$pmaxlevel);
    return $result;
}

sub map_xml_format_to_cli_format
{
    my $value = $_[0];
    my $digit_dot = $_[1];
    my $flag = $_[2];
    my $pparam = $_[3];
    my $result = $PARAM_UPDATE_SUCCESS;
    my $fmtref = \%fldfrmtdbase_hash;
    my $href = \%digit_to_tag;
    my $level = 0;
    my $xmlfmt;
    my $clifmt;
    my $conv_val;
    
# print "map_xml_format_to_cli_format1 outside flag $value $digit_dot\n";
    if ($flag == 1) {
        my @temp = split(/\./, $digit_dot);
        for (my $i = 0; $i <= $#temp; $i++) {
            if ($i == 0) {
                $str = $temp[$i];
            } else {
                $str = $str . "." . $temp[$i];
            }
# print "map_xml_format_to_cli_format2 $i--$temp[$i] $value $actfld--$digit_dot\n";
            if (defined($$href{nxt}{$temp[$i]})) {
                $fmtref = \%{$$fmtref{nxt}{$temp[$i]}};
                $href = \%{$$href{nxt}{$temp[$i]}};
            } else {
                print "Field $digit_dot is not defined in update_cli_tree_with_value\n";
                die;
            }
        }
        $conv_val = $value;
        if (defined($$fmtref{$xml_format})) {
            $xmlfmt = $$fmtref{$xml_format};
            $clifmt = $$fmtref{$cli_format};
# print "map_xml_format_to_cli_format3 formats $xmlfmt $clifmt\n";
            if (defined($$href{array})) {
                $result = $format_conv_arr[$xmlfmt][$clifmt]($value, \$conv_val, 1);
# print "map_xml_format_to_cli_format4 formats in array $xmlfmt $clifmt, $flag_for_byte_end_check, $lvlchngd\n";
                if ($flag_for_byte_end_check) {  
                    $conv_val = $global_string_for_byte;
                    $flag_for_byte_end_check = 0;
                    $flag_for_byte_string_cli_check = 1;
# print "map_xml_format_to_cli_format6 $xmlfmt, $clifmt, $value, $conv_val\n";
                }
            } else {
                $result = $format_conv_arr[$xmlfmt][$clifmt]($value, \$conv_val, 0);
            }
        }
        $value = $conv_val; 
    }

    if($hash7{string_TYPE} == $clifmt) {
        my @tmp1 = split(' ', $value);
        my @tmp2 = split('\t', $value);
        if($#tmp1 > 0) {
            $value = "\"" . $value . "\"";
        } elsif($#tmp2 > 0) {
            $value = "\"" . $value . "\"";
        }
    }

    $$pparam = $value;
# print "map_xml_format_to_cli_format5 $xmlfmt, $clifmt, $value\n";
    return $result;
}


sub update_cli_tree_with_value
{
    my $value = $_[0];
    my $actfld = $_[1];
    my $flag = $_[2];
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $arrayall_val;
    my $tmpcnt = 0;
    if ($flag_for_byte_string_cli_check && $flag_for_byte_mac_cli_check) {
#print "update_cli_tree_with_value after formats $value, $glb_flag_arrayall_action\n";
        if($glb_flag_arrayall_action == 1){
            if ($glb_country_count == $value) {
                $arrayall_val = $glb_country_buffer; 
            } else {
                my @temp = split(",", $glb_country_buffer);
                if ($glb_country_count < $value) {
                    $tmpcnt = $glb_country_count;
                    for(my $i=0; $i < $tmpcnt; $i++) {
#print "update_cli_tree_with_value2\n";
                       if($i == 0) {
                           $arrayall_val = "$temp[$i]"; 
                       } else {
                           $arrayall_val .= ",$temp[$i]"; 
                       }
                    }
                    for(my $i=$tmpcnt; $i < $value; $i++) {
#print "update_cli_tree_with_value2\n";
                       if($i == 0) {
                           $arrayall_val = "AE"; 
                       } else {
                           $arrayall_val .= ",AE"; 
                       }
                    }
                } else {
                    for(my $i=0; $i < $value; $i++) {
#print "update_cli_tree_with_value2\n";
                       if($i == 0) {
                           $arrayall_val = "$temp[$i]"; 
                       } else {
                           $arrayall_val .= ",$temp[$i]"; 
                       }
                    }
                }
            }
            $clitoxmldb1_instances{instance}[$clitoxmldb1_ptr_level]{val} = $arrayall_val; 
            delete($clitoxmldb1_instances{instance}[($clitoxmldb1_ptr_level + 1)]);
        } else {
            $clitoxmldb1_instances{instance}[$clitoxmldb1_ptr_level]{val} = $value;
            delete($clitoxmldb1_instances{instance}[($clitoxmldb1_ptr_level + 1)]);
        }

#print "update_cli_tree_with_value1 $clitoxmldb1_ptr_level, $value, $clitoxmldb1_optional_instances{instance}[$clitoxmldb1_ptr_level]{optional}\n";
#    $clitoxmldb1_instances{instance}[0]{print} = 0;
    }
    return $result;
}

sub print_cli
{
#print "Print cli called $clitoxmldb1_ptr_level, $invalid_cli_found, $output_cli_type\n";
#for (my $i = 0; $i <= $clitoxmldb1_ptr_level; $i++) {
#print "print_cli $clitoxmldb1_instances{instance}[$i]{val}, $clitoxmldb1_index[$i]\n";
#}
    if ($output_cli_type == $show_invalid_config && !$invalid_cli_found) {
        return;
    } else {
        $invalid_cli_found = 0;
    }
    for (my $i = 0; $i <= $clitoxmldb1_ptr_level; $i++) {
        if (!defined($clitoxmldb1_instances{instance}[$i]) || (!defined($clitoxmldb1_instances{instance}[$i]{val}) && !defined($clitoxmldb1_optional_instances{instance}[$i]{optional}))) {
            return;
        }
    }
    for (my $i = 0; $i <= $clitoxmldb1_ptr_level; $i++) {
        print CLIFILE "$clitoxmldb1_instances{instance}[$i]{val} ";
    }
    print CLIFILE "\n";
    $clitoxmldb1_instances{instance}[0]{print} = 1;
}

sub print_error_for_cli
{
    my $cli = "";
    for (my $i = 0; $i <= $#{$clitoxmldb1_instances{instance}}; $i++) {
        $cli = $cli ." $clitoxmldb1_instances{instance}[$i]{val}";
    }
    return $cli;
}

sub keyword_string_special
{
    my $input = $_[0];
    my $input_present = $_[1];
    my $inpcmd = $_[2];
    my $href = $_[3];
    my $hreff = $clitoxmldb1_ptr[$clitoxmldb1_ptr_level];
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $string;

    my @tmp = split(/\%/, $inpcmd);
    $$href = $tmp[1];
    
    if (defined($string_map[$tmp[0]])) {
        $string = $string_map[$tmp[0]];
    } else {
        print "Error in database for $input_cli, keyword_string_value = $tmp[0] not present\n";
        die;
    }
    return $result;
}

sub keyword_string_special_with_local
{
    my $input = $_[0];
    my $input_present = $_[1];
    my $inpcmd = $_[2];
    my $href = $_[3];
    my $hreff = $clitoxmldb1_ptr[$clitoxmldb1_ptr_level];
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $string;

    my @tmp = split(/\%/, $inpcmd);
    $$href = $tmp[1];
    
    if (defined($string_map[$tmp[0]])) {
        $string = $string_map[$tmp[0]];
    } else {
        print "Error in database for $input_cli, keyword_string_value = $tmp[0] not present\n";
        die;
    }
    return $result;
}

sub add_hole_in_cli_tree_buffer
{
    delete($clitoxmldb1_instances{instance}[$clitoxmldb1_ptr_level]);
}

sub keyword_string
{
    my $input = $_[0];
    my $input_present = $_[1];
    my $inpcmd = $_[2];
    my $href = $_[3];
    my $hreff = $clitoxmldb1_ptr[$clitoxmldb1_ptr_level];
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $string;

    my @tmp = split(/\%/, $inpcmd);
    $$href = $tmp[1];
    
    add_hole_in_cli_tree_buffer();
#print "keyword_string2 $inpcmd, @tmp, $clitoxmldb1_ptr_level, $tmp[0], $flag_for_byte_string_cli_check, $flag_for_byte_mac_cli_check\n";
    if (defined($string_map[$tmp[0]])) {
        $string = $string_map[$tmp[0]];
    } else {
        print "Error in database for $input_cli, keyword_string_value = $tmp[0] not present\n";
        die;
    }
    #update_cli_tree_with_value($string);
    update_cli_tree_with_value($string,0, 0 );
#print "keyword_string1 $clitoxmldb1_ptr_level, $clitoxmldb1_optional_instances{instance}[$clitoxmldb1_ptr_level]{optional}\n";
    return $result;
}

# This function checks whether the platform is Szabla.
# If so, then the CLI is not updated in the config file.
# else, the CLI is updated with the keyword param passed
# in the config file.

sub keyword_string_platform_specific
{
    my $input = $_[0];
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $input_val;
					 
    add_hole_in_cli_tree_buffer();
					 
    if ($is_szabla == 1) {
    	return $INVALID_CLI_OPTION;
	}
	
	$result = param_value_return($input, \$input_val);
	if ($result != $PARAM_UPDATE_SUCCESS) {
		return $result;
	}
					 
    update_cli_tree_with_value($input_val,0, 0 );
    return $result;
}


# This function checks whether the platform is vwlc
# If so, then the CLI is not updated in the config file.
# else, the CLI is updated with the keyword param passed
# in the config file.

sub keyword_string_platform_specific_vwlc
{
    my $input = $_[0];
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $input_val;
					 
    add_hole_in_cli_tree_buffer();
					 
    if ($is_vm == 1) {
    	return $INVALID_CLI_OPTION;
	}
	
	$result = param_value_return($input, \$input_val);
	if ($result != $PARAM_UPDATE_SUCCESS) {
		return $result;
	}
					 
    update_cli_tree_with_value($input_val,0, 0 );
    return $result;
}

sub keyword_string_platform_specific_szabla_exclude
{
    my $input = $_[0];
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $input_val;
					 
    add_hole_in_cli_tree_buffer();
					 
	$result = param_value_return($input, \$input_val);
	if ($result != $PARAM_UPDATE_SUCCESS) {
		return $result;
	}
					 
    update_cli_tree_with_value($input_val,0, 0 );
    return $result;
}
# This function checks whether the platform is ambassador.
# If so, then the CLI is not updated in the config file.
# else, the CLI is updated with the keyword param passed
# in the config file.
sub keyword_string_platform_specific_ambassador_vwlc
{
    my $input = $_[0];
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $input_val;
					 
    add_hole_in_cli_tree_buffer();
					 
    if ($is_ambassador == 1 || $is_vm == 1) {
    	return $NO_INSTANCE_FOUND;
    }
	
    $result = param_value_return($input, \$input_val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
					 
    update_cli_tree_with_value($input_val,0, 0 );
    return $result;
}
sub keyword_string_platform_specific_ucs_include
{
    my $input = $_[0];
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $input_val;

    add_hole_in_cli_tree_buffer();

    if ( !(($is_ambassador == 1) ||
           ($is_saber == 1) ||
           ($is_pata == 1) ||
           ($is_khanda == 1) ||
           ($is_kukri == 1)) ){
        return $NO_INSTANCE_FOUND;
    }

    $result = param_value_return($input, \$input_val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    update_cli_tree_with_value($input_val,0, 0 );
    return $result;
}
# This function checks whether the platform is VM.
# If so, then the CLI is updated with the keyword param in the config file.
# else, the CLI is not updated in the config file.

sub keyword_string_platform_specific_vm
{
    my $input = $_[0];
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $input_val;
					 
    add_hole_in_cli_tree_buffer();
					 
    if ($is_vm != 1) {
    	return $NO_INSTANCE_FOUND;
	}
	
	$result = param_value_return($input, \$input_val);
	if ($result != $PARAM_UPDATE_SUCCESS) {
		return $result;
	}
					 
    update_cli_tree_with_value($input_val,0, 0 );
    return $result;
}
# if the platform is supporting smart license feature
# (vwlc, khanda, pata) upload the CLI. Else do not .

sub keyword_string_smart_lic_specific
{
    my $input = $_[0];
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $input_val;
					 
    add_hole_in_cli_tree_buffer();
					 
    if (($is_vm != 1)  && ($is_pata != 1) && ($is_khanda != 1) && ($is_kukri != 1)) {
    	return $NO_INSTANCE_FOUND;
	}
	
	$result = param_value_return($input, \$input_val);
	if ($result != $PARAM_UPDATE_SUCCESS) {
		return $result;
	}
					 
    update_cli_tree_with_value($input_val,0, 0 );
    return $result;
}

# 7500/8500/pata/khanda/vwlc
sub keyword_string_platform_specific_ucs
{
    my $input = $_[0];
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $input_val;
					 
    add_hole_in_cli_tree_buffer();
					 
    if ( ($is_ambassador == 1) || 
         ($is_saber == 1) ||
         ($is_pata == 1) ||
         ($is_khanda == 1) ||
         ($is_vm == 1)) {
    	return $NO_INSTANCE_FOUND;
    }
	
    $result = param_value_return($input, \$input_val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
					 
    update_cli_tree_with_value($input_val,0, 0 );
    return $result;
}
sub keyword_string_with_local
{
    my $input = $_[0];
    my $input_present = $_[1];
    my $inpcmd = $_[2];
    my $href = $_[3];
    my $hreff = $clitoxmldb1_ptr[$clitoxmldb1_ptr_level];
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $string;

    my @tmp = split(/\%/, $inpcmd);
    $$href = $tmp[1];
    
    add_hole_in_cli_tree_buffer();
    if (defined($string_map[$tmp[0]])) {
        $string = $string_map[$tmp[0]];
    } else {
        print "Error in database for $input_cli, keyword_string_value = $tmp[0] not present\n";
        die;
    }
    update_cli_tree_with_value($string,0 ,0);
    return $result;
}

sub keyword_string_map
{
    my $input = $_[0];
    my $input_present = $_[1];
    my $inpcmd = $_[2];
    my $href = $_[3];
    my $hreff = $clitoxmldb1_ptr[$clitoxmldb1_ptr_level];
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $string;

    my @tmp = split(/\%/, $inpcmd);
    $$href = $tmp[1];
    
    return $result;
}

sub database1_read
{
    my $input = $_[0];
    my $href;
    my $hreff;
   
    my ($tmp1, $tmp2) = split(/\t/, $input);
    my @temp = split(/\./, $tmp1);

    $href = \%clitoxmldb1;
    for (my $i = 0; $i <= $#temp; $i++) {
        if (!defined($$href{cnt})) {
            $$href{cnt} = 0;
        }
        if (!defined($$href{array}{$temp[$i]})) {
            $$href{cnt} += 1;
        }
        if ($i == $#temp) {
            $$href{array}{$temp[$i]}{cur} = $tmp2;
        } else {
            $href = \%{$$href{array}{$temp[$i]}{nxt}};
        }
    }
}

sub database1_execute
{
    my $input = $_[0];
    my $input_present = $_[1];
    my $href;
    my $cmd;
    my @tmp1;
    my $result = $GET_NEXT_INDEX_FOR_SET_LEVEL_INITIAL;
    my $cli;

    $GBL_CNT = $GBL_CNT + 1;
    $glb_flag_action_node_internal_with_optional = 0;
    while ($result == $GET_NEXT_INDEX_FOR_SET_LEVEL || $result == $GET_NEXT_INDEX_FOR_SET_LEVEL_INITIAL) {
        $href = $clitoxmldb1_ptr[$clitoxmldb1_ptr_level];
#print "database1_execute6 $cmd, $clitoxmldb1_ptr_level, $clitoxmldb1_index[$clitoxmldb1_ptr_level], $clitoxmldb1_ptr[$clitoxmldb1_ptr_level]]\n";
        if (!defined($$href{array}) || !defined($$href{array}{$clitoxmldb1_index[$clitoxmldb1_ptr_level]})) {
#            print_cli();
            return $NOOP_CLI_RETURN_OPTION;
        }

        if (!defined($$href{array}{$clitoxmldb1_index[$clitoxmldb1_ptr_level]}{cur})) {
            $cli = print_error_for_cli();
#print "Debug: $clitoxmldb1_ptr_level, $clitoxmldb1_index[$clitoxmldb1_ptr_level]\n";
            print "Error in database, no cur option for $cli\n";
            die;
        }

        $result = $NOOP_CLI_RETURN_OPTION;
        $cmd = $$href{array}{$clitoxmldb1_index[$clitoxmldb1_ptr_level]}{cur};

#print "database1_execute1 $cmd, $clitoxmldb1_ptr_level, $clitoxmldb1_index[$clitoxmldb1_ptr_level]\n";
        @tmp1 = split(/\./, $cmd, 2);
#print "database1_execute4 $cmd, $clitoxmldb1_ptr_level, $clitoxmldb1_index[$clitoxmldb1_ptr_level], $result, $retcheck[$result], @tmp1\n";

        while ($retcheck[$result] && defined($tmp1[0])) {
#print "$result $clitoxmldb1_optional_instances{instance}[$clitoxmldb1_ptr_level]{optional}, $tmp1[1]\n";
#print "database1_execute3 $input $input_present, $tmp1[0], $tmp1[1]\n";
            $result = $parser_action[$tmp1[0]]($input, $input_present, $tmp1[1], \$cmd);
# for (my $i = 0; $i <= $clitoxmldb1_ptr_level; $i++) {
#   print "level = $i, cli index = $clitoxmldb1_index[$i], Instance index $clitoxmldb1_instances{instance}[$i]{index}\n";
#   }
#print "database1_execute2 $cmd, $clitoxmldb1_ptr_level, $clitoxmldb1_index[$clitoxmldb1_ptr_level], $clitoxmldb1_instances{instance}[$clitoxmldb1_ptr_level]{array}[$i] result $result\n";
            @tmp1 = split(/\./, $cmd, 2);
# print "database1_execute3 $cmd, $tmp1[0], $tmp1[1]\n";
        }
#print "database1_execute5 $cmd, $clitoxmldb1_ptr_level, $result\n";
    }

#If optional_level is present and instance is found , covers the case of 'value mismatch'
    if ($glb_flag_action_node_internal_with_optional == 1 && $result != $NO_INSTANCE_FOUND)  {
# print "\ncurrent_optional_level_present & INSTANCE_FOUND";
        for (my $i = $current_optional_level; $i <= $clitoxmldb1_ptr_level; $i++) {
            delete($clitoxmldb1_optional_instances{instance}[$i]{optional});
        }
        $current_optional_level_present = 0;
    }
    $glb_flag_action_node_internal_with_optional = 0;
    return $result;
}

sub check_for_no_holes_in_cli_buffer
{
#print "check_for_no_holes_in_cli_buffer1\n";
    for (my $i = 0; $i <= $clitoxmldb1_ptr_level; $i++) {
        if (!defined($clitoxmldb1_instances{instance}[$i]{val}) && !defined($clitoxmldb1_optional_instances{instance}[$i]{optional})) {
#print "0\n";
            return 0;
        }
#print "$clitoxmldb1_instances{instance}[$i]{val}, ";
    }
#print "1\n";
    return 1;
}

sub generate_cli_from_xml
{
    my $href;
    my $count;
    my $index;
    my $tagref;
    my $arrindex;
    my $level;
    my $result = $NOOP_CLI_RETURN_OPTION;

    $clitoxmldb1_ptr[$clitoxmldb1_ptr_level] = \%clitoxmldb1;
    $href = $clitoxmldb1_ptr[$clitoxmldb1_ptr_level];
    $count = $$href{cnt};
    $clitoxmldb1_index[$clitoxmldb1_ptr_level] = 1;

NEXTITER:
    while ($clitoxmldb1_index[0] <= $count) {
# print "generate_cli_from_xml1 $count, $clitoxmldb1_index[0]\n";
# print "generate_cli_from_xml2 $clitoxmldb1_index[$clitoxmldb1_ptr_level], $clitoxmldb1_ptr_level\n";
        $index = $clitoxmldb1_index[$clitoxmldb1_ptr_level];
        $href = $clitoxmldb1_ptr[$clitoxmldb1_ptr_level];
        if (!defined($$href{array}) || !defined($$href{array}{$index})) {
            if ($clitoxmldb1_ptr_level > 0) {
                delete($clitoxmldb1_optional_instances{instance}[$clitoxmldb1_ptr_level]{optional});
                $clitoxmldb1_ptr_level -= 1;
            }
            $level = $clitoxmldb1_ptr_level;
            $clitoxmldb1_index[$clitoxmldb1_ptr_level] += 1;
            if (defined($clitoxmldb1_optional_instances{instance}[$level]{optional}) && $clitoxmldb1_optional_instances{instance}[$level]{optional} == 1) {
                $clitoxmldb1_optional_instances{instance}[$clitoxmldb1_ptr_level]{optional} = 1;
            }
# for (my $j = 0; $j <= $clitoxmldb1_ptr_level; $j++) {
# print "generate_cli_from_xml6 $j : $clitoxmldb1_index[$j], $clitoxmldb1_ptr_level\n";
#  }
            next NEXTITER;
        }
        
        $result = database1_execute("config", 1);
        if ($GBL_MAX_CNT == $GBL_CNT) {
            print "##";
            $| = 1;
            $GBL_CNT = 0;
        }
        $index = $clitoxmldb1_index[$clitoxmldb1_ptr_level];
        $href = $clitoxmldb1_ptr[$clitoxmldb1_ptr_level];
#print "generate_cli_from_xml12 $result, $clitoxmldb1_ptr_level, $$href{array}{$index}{nxt}\n";
        if (defined($$href{array}{$index}{nxt}) && ($result != $NO_INSTANCE_FOUND && $result != $NO_MORE_INSTANCES)) {
            $href = \%{$$href{array}{$index}{nxt}};
            $level = $clitoxmldb1_ptr_level;
            $clitoxmldb1_ptr_level += 1;
            if (defined($clitoxmldb1_optional_instances{instance}[$level]{optional}) && $clitoxmldb1_optional_instances{instance}[$level]{optional} == 1) {
                $clitoxmldb1_optional_instances{instance}[$clitoxmldb1_ptr_level]{optional} = 1;
            }
            $clitoxmldb1_ptr[$clitoxmldb1_ptr_level] = $href;
            $clitoxmldb1_index[$clitoxmldb1_ptr_level] = 1;
# for (my $j = 0; $j <= $clitoxmldb1_ptr_level; $j++) {
# print "generate_cli_from_xml7 $j : $clitoxmldb1_index[$j], $clitoxmldb1_ptr_level\n";
#  }
        } else {
#print "generate_cli_from_xml10 $result, $clitoxmldb1_ptr_level, $clitoxmldb1_optional_instances{instance}[$clitoxmldb1_ptr_level]{optional}\n";
            if (((!defined($$href{array}{$index}{nxt}) && $result != $NO_INSTANCE_FOUND) || (defined($clitoxmldb1_optional_instances{instance}[$clitoxmldb1_ptr_level]{optional}) && $result == $NO_INSTANCE_FOUND)) && check_for_no_holes_in_cli_buffer()) {
                if (defined($clitoxmldb1_optional_instances{instance}[$clitoxmldb1_ptr_level]{optional}) && $result == $NO_INSTANCE_FOUND) {
                    if ($current_optional_level_present == 1) {
                        for (my $i = $current_optional_level; $i <= $clitoxmldb1_ptr_level; $i++) {
                            delete($clitoxmldb1_optional_instances{instance}[$i]);
                        }
                        $current_optional_level_present = 0;
                        if ($current_optional_level > 0) {
                            $clitoxmldb1_ptr_level = $current_optional_level - 1;
                        } else {
                            $clitoxmldb1_ptr_level = $current_optional_level;
                        }
                    }
                }
##print "Print CLI in generate_cli_from_xml\n";
                print_cli();
            } else {
                if ($current_optional_level_present == 1) {
                    for (my $i = $current_optional_level; $i <= $clitoxmldb1_ptr_level; $i++) {
                        delete($clitoxmldb1_optional_instances{instance}[$i]);
                    }
                    $current_optional_level_present = 0;
                    if ($current_optional_level > 0) {
                        $clitoxmldb1_ptr_level = $current_optional_level - 1;
                    } else {
                        $clitoxmldb1_ptr_level = $current_optional_level;
                    }
                }
            }
            $clitoxmldb1_index[$clitoxmldb1_ptr_level] += 1;
# print "generate_cli_from_xml9 $clitoxmldb1_ptr_level\n";
# for (my $j = 0; $j <= $clitoxmldb1_ptr_level; $j++) {
# print "generate_cli_from_xml8 $j : $clitoxmldb1_index[$j], $clitoxmldb1_ptr_level\n";
#  }
        }
    }
    for (my $i = $current_instance_indices_level; $i >= 0; $i--) {
        $tagref = $current_instance_indices{instance}[$i]{tagref};
        $arrindex = $current_instance_indices{instance}[$i]{arridx};
        $arrindex += 1;
# print "generate_cli_from_xml4 $current_instance_indices{instance}[$i]{partialtag}, $current_instance_indices{instance}[$i]{arridx}, $arrindex, $$tagref{array}[$arrindex], $i, $current_instance_indices_level\n";
        if (defined($$tagref{array}[$arrindex])) {
            for (my $j = ($i + 1); $j <= $current_instance_indices_level; $j++) {
                delete($current_instance_indices{instance}[$j]);
            }
            $current_instance_indices_level = $i;
#print"DDD: current_instance_indices_level: $current_instance_indices_level\n";
            $current_instance_indices{instance}[$i]{arridx} += 1;
#print "CCC: action_node_internal112 $current_instance_indices_level, $current_instance_indices{instance}[$current_instance_indices_level]{arridx}\n";
# print "generate_cli_from_xml3, $i, $current_instance_indices{instance}[$i]{partialtag}, $current_instance_indices{instance}[$i]{arridx}, $$tagref{array}[$arrindex], $arrindex\n";
            for (my $j = 0; $j <= $current_instance_indices{instance}[$i]{clidblvl}; $j++) {
                $clitoxmldb1_ptr[$j] = $current_instance_indices{instance}[$i]{clidb}[$j]{cliref};
                $clitoxmldb1_index[$j] = $current_instance_indices{instance}[$i]{clidb}[$j]{cliidx};
                if (defined($current_instance_indices{instance}[$i]{clidb}[$j]{clival})) {
                    $clitoxmldb1_instances{instance}[$j]{val} = $current_instance_indices{instance}[$i]{clidb}[$j]{clival};
                }
# print "generate_cli_from_xml5, $j: $clitoxmldb1_index[$j]\n";
            }
            $clitoxmldb1_ptr_level = $current_instance_indices{instance}[$i]{clidblvl};
            goto NEXTITER;
        }
    }
    print CLIFILE "\n";
    close(CLIFILE);
}


sub strmap_read
{
    my $input = $_[0];
    my @tmp = split(/\t/, $input, 2);
    $string_map[$tmp[0]] = $tmp[1];
}

sub strvalmap_read
{
    my $input = $_[0];
    my @tmp = split(/\t/, $input, 2);
    $string_value_map[$tmp[0]] = $tmp[1];
}

sub fldarraydbase_read
{
    my $input = $_[0];
    my @tmp = split(/\t/, $input, 2);
    my @temp = split(/\./, $tmp[0]);
    my $href = \%fldarraydbase_hash;

    for (my $i = 0; $i <= $#temp; $i++) {
        $href = \%{$$href{nxt}{$temp[$i]}};
    }
    if(!defined($glb_hash_bytetostring{$tmp[0]}{bytetostring})) {
    $$href{array} = $tmp[1];
    } else {
#print "fldarraydbase_read1 $tmp[0], $$href{array} \n";
        $glb_hash_bytetostring{$tmp[0]}{bytetostringarray} = 1;
    }
}

sub fldfrmtdbase_read
{
    my $input = $_[0];
    my @tmp = split(/\t/, $input, 3);
    my @temp = split(/\./, $tmp[0]);
    my $href = \%fldfrmtdbase_hash;

    for (my $i = 0; $i <= $#temp; $i++) {
        $href = \%{$$href{nxt}{$temp[$i]}};
    }
    if((($tmp[1]==$hash7{byte_TYPE})||($tmp[1]==$hash7{unsignedByte_TYPE})) && ($tmp[2]==$hash7{string_TYPE})) {
        $glb_hash_bytetostring{$tmp[0]}{bytetostring}=1;
#print "fldfrmtdbase_read1 $tmp[0], $tmp[1], $tmp[2] \n";
    }
    $$href{$xml_format} = $tmp[1];
    $$href{$cli_format} = $tmp[2];
}

sub convertformats_forbytestringarray
{
    my $href;
    foreach my $key (keys %glb_hash_bytetostring) {
        if(defined($glb_hash_bytetostring{$key}{bytetostringarray})) {
            my @temp = split(/\./, $key);
            $href = \%fldfrmtdbase_hash;
            for (my $i = 0; $i <= $#temp; $i++) {
                $href = \%{$$href{nxt}{$temp[$i]}};
            }
            $$href{$xml_format} = $hash7{HEXstring_TYPE};
#print "convertformats_forbytestringarray $href, $key, $$xmlref{nxt}{$temp[0]}\n";
        }
    }

}

sub initialize_xml2cli_maps
{
    open(DB7,"$newdb7") or die "Can't open format conversion names File:$!";
    open(DB10,"$newdb10") or die "Can't open action name database File:$!";
    open(DB12,"$cli2xmldb1") or die "Can't open cli to tag database File:$!";
    open(DBTRANS,"$fieldtransitiondb") or die "Can't open field transition database File $fieldtransitiondb:$!";
    open(DB13,"$strmap") or die "Can't open string map database File:$!";
    open(DB14,"$strvalmap") or die "Can't open string value map database File:$!";
    open(DB15,"$fldarraydbase") or die "Can't open fldarraydbase database File:$!";
    open(DB16,"$fldfrmtdbase") or die "Can't open format map database File:$!";
    open(CLIFILE, "+>", "$clifile") or die "Can't open File:$!";

    if ($ARGV[0] == $show_invalid_config) {
       print "\nThis may take some time....\n";
    }

# print "Initializaton started\n";
    for $line(<DB7>){
        chomp $line;
        @line=split('\t',$line,2);
        $hash7{$line[1]}=$line[0];
    }

    for $line(<DB10>){
#This database contains number to action name mapping.
        chomp $line;
        @line=split('\t',$line,2);
        $action_array[$line[0]] = \&{$line[1]};
# print "DB10 $line[0], $line[1]\n";
    }

    for $line(<DB12>){
        chomp $line;
        database1_read($line);
    }
    for $line(<DBTRANS>){
        chomp $line;
        fieldtransition_read($line);
    }
    for $line(<DB13>){
        chomp $line;
        strmap_read($line);
    }
    for $line(<DB14>){
        chomp $line;
        strvalmap_read($line);
    }
    for $line(<DB16>){
        chomp $line;
        fldfrmtdbase_read($line);
    }
    for $line(<DB15>){
        chomp $line;
        fldarraydbase_read($line);
    }
    convertformats_forbytestringarray();
    initialize_retcheck();
    initialize_parser_action();
    populate_array();
    close(DB7);
    close(DB10);
    close(DB12);
    close(DB13);
    close(DB14);
    close(DB16);
}

sub get_value_from_string
{
    my $map = $_[0];
    my $string = $_[1];
    my $pval = $_[2];

    my @temp = split(/\t/, $map);
    for (my $i = 0; $i <= $#temp; $i++) {
        (my $t1, my $t2) = split(/=/, $temp[$i]);
        if ($t1 eq $string) {
            $$pval = $t2;
            return $PARAM_UPDATE_SUCCESS;
        }
    }
    return $STRVALMAP_NO_STRING_FOUND;
}

sub get_string_from_value
{
    my $map = $_[0];
    my $value = $_[1];
    my $pstr = $_[2];
    
    my @temp = split(/\t/, $map);
    for (my $i = 0; $i <= $#temp; $i++) {
        (my $t1, my $t2) = split(/=/, $temp[$i]);
        if ($t2 eq $value) {
            $$pstr = $t1;
            return $PARAM_UPDATE_SUCCESS;
        }
    }
    return $STRVALMAP_NO_VALUE_FOUND;
}

sub convert_hex_to_decimal
{
    my ($str) = @_;
    my $decimal = 0;
    my @temp1 = split(//, $str);
    if ($str =~ /x/) {
       ($hex_header, $str) = split('x', $str);
        for (my $i = 0; $i <= $#temp1; $i++) {
            if ($temp1[$i] eq 'a' || $temp1[$i] eq 'A') {
                $temp1[$i] = 10;
            } elsif ($temp1[$i] eq 'b' || $temp1[$i] eq 'B') {
                $temp1[$i] = 11;
            } elsif ($temp1[$i] eq 'c' || $temp1[$i] eq 'C') {
                $temp1[$i] = 12;
            } elsif ($temp1[$i] eq 'd' || $temp1[$i] eq 'D') {
                $temp1[$i] = 13;
            } elsif ($temp1[$i] eq 'e' || $temp1[$i] eq 'E') {
                $temp1[$i] = 14;
            } elsif ($temp1[$i] eq 'f' || $temp1[$i] eq 'F') {
                $temp1[$i] = 15;
            }
            $decimal = $decimal * 16 + $temp1[$i];
        }
    } else {
        $decimal = $str;
    }
    return($decimal);
}

sub check_and_update_invalid_config_status
{
    my $input = $_[0];
    my $href;
    my $digit;
    my $digitdot = "";
    my $count;

    $output_cli_type = $show_all_clis;
    if ($input == $show_invalid_config) {
        $output_cli_type = $show_invalid_config;
        if (-f $invalid_config_tags_file) {
            open(INFILE, $invalid_config_tags_file);
NXTTAGHR:
            while (<INFILE>) {
                chomp;
                my @tmp1 = split(/\t/, $_);
                my @tmp2 = split(/\./, $tmp1[0]);
                $href = \%tag_to_digit;
                for (my $i = 0; $i <= $#tmp2; $i++) {
                    if (!defined($$href{nxt}{$tmp2[$i]}{digit})) {
                        print "Undefined tag element $tmp2[$i] in $tmp1[0] in invalid config \n";
                        next NXTTAGHR;
                    } else {
                        if ($i == 0) {
                            $digitdot = $$href{nxt}{$tmp2[$i]}{digit};
                        } else {
                            $digitdot = $digitdot . "." . $$href{nxt}{$tmp2[$i]}{digit};
                        }
                        $href = \%{$$href{nxt}{$tmp2[$i]}};
                    }
                }
                if (defined($tmp1[0])) {
                    $invalid_config_tag_hash{tag}{$digitdot} = $digitdot;
                    for (my $i = 1; $i <= $#tmp1; $i++) {
                        $invalid_config_tag_hash{instance}{$digitdot}{array}[($i - 1)]{$tmp1[$i]} = $tmp1[$i];
                        $invalid_config_tag_hash{instance}{$digitdot}{count} = $#tmp1;
#print "check_and_update_invalid_config_status1 $invalid_config_tag_hash{tag}{$digitdot}, $invalid_config_tag_hash{instance}{$digitdot}{array}[($i-1)], $tmp1[$i], $i\n";
                    }
                }
#print "check_and_update_invalid_config_status $invalid_config_tag_hash{tag}{$digitdot}, $invalid_config_tag_hash{instance}{$digitdot}{array}[0]\n";
            }
        }
    }
}

sub ignore_node_conditional_string_and_update_reverse_local_profiling
{
    my $input = $_[0];
    my $actradio_policy;
    my $radio_policy;
    my $updateactfld;
    my $updatefld;
    my $val;
    my $actval;
    my $comp_val;
    my $actcomp_val;
    my $actprofiling;
    my $actuserconf;
    my $profiling;
    my $userconf;
    my $result = $NOOP_CLI_RETURN_OPTION;
    ($actradio_policy, $actcomp_val, $updateactfld, $actprofiling, 
     $actuserconf, $actval) = split(/$nodeparamconnector/, $input, 6);
    if (get_value_from_xml_dbase( $actradio_policy, \$radio_policy)) {
    }

    $result = param_value_return($actcomp_val, \$comp_val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    if($comp_val eq $radio_policy) {
        return $NO_INSTANCE_FOUND;
    }

    $result = param_value_return($updateactfld, \$updatefld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    add_hole_in_cli_tree_buffer();

    if (get_value_from_xml_dbase($actprofiling, \$profiling)) {
    }

    if (get_value_from_xml_dbase($actuserconf, \$userconf)) {
    }

    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    if ($userconf) {
        if ($profiling) {
            update_cli_tree_with_value($updatefld, $updateactfld, 1);
        } else {
            update_cli_tree_with_value($val, $actval, 1);
        }
    }

    return 1;
}


sub ignore_node_conditional_string_remotelan
{
    my $input = $_[0];
    my $actfld;
    my $fld;
    my $updateactfld;
    my $updatefld;
    my $comp_val;
    my $actcomp_val;
    my $result = $NOOP_CLI_RETURN_OPTION;
    ($actfld, $actcomp_val, $updateactfld) = split(/$nodeparamconnector/, $input, 3);
    if (get_value_from_xml_dbase( $actfld, \$fld)) {
    }
    $result = param_value_return($actcomp_val, \$comp_val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

#print"comp_val: $comp_val, fld: $fld\n";
    if($comp_val ne $fld) {
        return $NO_INSTANCE_FOUND;
    }
    $result = param_value_return($updateactfld, \$updatefld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    update_cli_tree_with_value($updatefld, $updateactfld, 1);
    return 1;
}

sub ignore_node_conditional_string_v6v4_prefermode
{
    my $input = $_[0];
    my $actfld;
    my $fld;
    my $updatefld;
    my $comp_val;
    my $actcomp_val;
    my $allString = 'all';
    my $result = $NOOP_CLI_RETURN_OPTION;
    ($actfld, $actcomp_val) = split(/$nodeparamconnector/, $input, 2);
    if (get_value_from_xml_dbase( $actfld, \$fld)) {
    }
    $result = param_value_return($actcomp_val, \$comp_val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

#print"comp_val: $comp_val, fld: $fld,  allstring: $allString\n";
    if($comp_val ne $fld) {
        return $NO_INSTANCE_FOUND;
    }
    update_cli_tree_with_value($allString, $allString, 1);
    return 1;
}
sub ignore_node_conditional_bitset
{
    my $input = $_[0];
    my $actfld;
    my $fld;
    my $updateactfld;
    my $updatefld;
    my $comp_val;
    my $actcomp_val;
    my $result = $NOOP_CLI_RETURN_OPTION;
    ($actfld, $actcomp_val, $updateactfld) = split(/$nodeparamconnector/, $input, 3);
    if (get_value_from_xml_dbase( $actfld, \$fld)) {
    }
    $result = param_value_return($actcomp_val, \$comp_val);

    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print"ignore_node_conditional_bitset: fld: $fld, comp_val: $comp_val\n";
    if(($comp_val & $fld) == $comp_val) {
#print"No instance\n";
        return $NO_INSTANCE_FOUND;
    }
#print"ignore_node_conditional_bitset:comparison failed\n";
    $result = param_value_return($updateactfld, \$updatefld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print"ignore_node_conditional_bitset:updating vap: $updatefld)\n";
    update_cli_tree_with_value($updatefld, $updateactfld, 1);
    return 1;
}

sub ignore_node_conditional_bitset_not_equal
{
    my $input = $_[0];
    my $actfld;
    my $fld;
    my $comp_val;
    my $actcomp_val;
    my $updateactfld;
    my $updatefld;

    my $result = $NOOP_CLI_RETURN_OPTION;
    ($actfld, $actcomp_val,$updateactfld) = split(/$nodeparamconnector/, $input, 3);
    if (get_value_from_xml_dbase( $actfld, \$fld)) {
    }
    $result = param_value_return($actcomp_val, \$comp_val);

    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print"ignore_node_conditional_bitset_not_equal: fld: $fld, comp_val: $comp_val\n";
    if(($comp_val & $fld) != 0x0020) {
#print"No instance for not equal\n";
        return $NO_INSTANCE_FOUND;
    }
#print"ignore_node_conditional_bitset_not_equal:comparison failed\n";
    $result = param_value_return($updateactfld, \$updatefld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print"ignore_node_conditional_bitset_not_equal:updating vap: $updatefld)\n";

    update_cli_tree_with_value($updatefld, $updateactfld, 1);
    return 1;
}

sub ignore_node_conditional_string
{
    my $input = $_[0];
    my $actfld;
    my $fld;
    my $updateactfld;
    my $updatefld;
    my $comp_val;
    my $actcomp_val;
    my $result = $NOOP_CLI_RETURN_OPTION;
    ($actfld, $actcomp_val, $updateactfld) = split(/$nodeparamconnector/, $input, 3);
    if (get_value_from_xml_dbase( $actfld, \$fld)) {
    }
    $result = param_value_return($actcomp_val, \$comp_val);

    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    if($comp_val eq $fld) {
        return $NO_INSTANCE_FOUND;
    }
    $result = param_value_return($updateactfld, \$updatefld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    update_cli_tree_with_value($updatefld, $updateactfld, 1);
    return 1;
}

# If input1 is not equal to input2, return else upload input3.
sub ignore_node_conditional_string_if_not_equal
{
    my $input = $_[0];
    my $actfld;
    my $fld;
    my $updateactfld;
    my $updatefld;
    my $comp_val;
    my $actcomp_val;
    my $result = $NOOP_CLI_RETURN_OPTION;
    ($actfld, $actcomp_val, $updateactfld) = split(/$nodeparamconnector/, $input, 3);
    if (get_value_from_xml_dbase( $actfld, \$fld)) {
    }
    $result = param_value_return($actcomp_val, \$comp_val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print"ignore_node_conditional_string_if_not_equal: fld: $fld, comp_val: $comp_val\n";
    if($comp_val ne $fld) {
        return $NO_INSTANCE_FOUND;
    }
    $result = param_value_return($updateactfld, \$updatefld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    update_cli_tree_with_value($updatefld, $updateactfld, 1);
    return 1;
}

# If input1 is not equal to input2, return else upload input3.
sub ignore_node_conditional_string_if_not_equal_acl
{
    my $input = $_[0];
    my $actfld;
    my $fld;
    my $updateactfld;
    my $updatefld;
    my $comp_val;
    my $actcomp_val;
    my $actFlag, $flag;
    my $actAclType, $aclType;
    my $actTypeVal, $typeVal;
    my $result = $NOOP_CLI_RETURN_OPTION;
    ($actfld, $actcomp_val, $actFlag, $actAclType, $actTypeVal, $updateactfld) = split(/$nodeparamconnector/, $input, 6);
    if (get_value_from_xml_dbase( $actfld, \$fld)) {
    }
#print "actlfd : $actfld actcomp_val : $actcomp_val actflag : $actFlag actAclType : $actAclType actTypeval : $actTypeVal updateactlfd : $updateactfld\n ";

    if(!defined($fld)) {
    #check for 2 conditions: WHen flag is set to 3, and if its v4, though the id is 0 upload the cli.
#print "inside fld check\n";

        $result = param_value_return($actFlag, \$flag);
        if ($result != $PARAM_UPDATE_SUCCESS) {
#print "fail 1\n";
            return $result;
        }

        $result = param_value_return($actAclType, \$aclType);
        if ($result != $PARAM_UPDATE_SUCCESS) {
#print "failed to read acltype\n";
            return $result;
        }
#print "aclType: $aclType\n";

        $result = param_value_return($actTypeVal, \$typeVal);
        if ($result != $PARAM_UPDATE_SUCCESS) {
#print "fail2\n";
            return $result;
        }

#print"flag: $flag, aclType: $aclType, typeVal: $typeVal\n";

#        if (( $flag == 3 ) && ( $aclType eq $typeVal) ) {
#print "setting fld to zero since condition matches\n";
		#$fld = 0;
#        }
    }

    $result = param_value_return($actcomp_val, \$comp_val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
#print "\n fail3";
        return $result;
    }

#print"ignore_node_conditional_string_if_not_equal_acl: fld: $fld, comp_val: $comp_val\n";
    if($comp_val ne $fld) {
#print"No instance\n";
        return $NO_INSTANCE_FOUND;
    }

    $result = param_value_return($updateactfld, \$updatefld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
#print"fail4\n";
        return $result;
    }
#print "updatefld :$updatefld\n";

    update_cli_tree_with_value($updatefld, $updateactfld, 1);
    return 1;
}

sub ignore_node_conditional_string_with_default
{
    my $input = $_[0];
    my $actfld;
    my $fld;
    my $updateactfld;
    my $updatefld;
    my $defaultactfld;
    my $defaultfld;
    my $comp_val;
    my $actcomp_val;
    my $result = $NOOP_CLI_RETURN_OPTION;
    ($actfld, $actcomp_val, $updateactfld,$defaultactfld) = split(/$nodeparamconnector/, $input, 4);
    if (get_value_from_xml_dbase( $actfld, \$fld)) {
    }

    if(!defined($fld)) {
      $result = param_value_return($defaultactfld,\$defaultfld);
       if ($result != $PARAM_UPDATE_SUCCESS) {
               return $result;
       }
       $fld = $defaultfld;

    }
    $result = param_value_return($actcomp_val, \$comp_val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    if($comp_val eq $fld) {
        return $NO_INSTANCE_FOUND;
    }
    $result = param_value_return($updateactfld, \$updatefld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    update_cli_tree_with_value($updatefld, $updateactfld, 1);
    return 1;
}

# This function is used to update a node with a specific string when a 
# an integer corresponding to that string is present. 

sub update_node_conditional_string
{
	my $input = $_[0];
	my $actfld;
	my $fld;
	my $string;
	my $comp_val;
	my $actcomp_val;
	my $act_string;
	my $result = $NOOP_CLI_RETURN_OPTION;
	
	($actfld, $actcomp_val, $act_string) = split(/$nodeparamconnector/, $input, 3);
	
	if (get_value_from_xml_dbase( $actfld, \$fld)) {
	}
	if(defined($fld)) {
		$result = param_value_return($actfld, \$fld);
		
		if ($result != $PARAM_UPDATE_SUCCESS) {
			return $result;
		}
		$result = param_value_return($actcomp_val, \$comp_val);
		
		if ($result != $PARAM_UPDATE_SUCCESS) {
			return $result;
		}		
   
		if($comp_val eq $fld) {
	       $result = param_value_return($act_string, \$string);
		    
			if ($result != $PARAM_UPDATE_SUCCESS) {
				return $result;
			} 
			$fld = $string;
		}	
		
		$result = update_cli_tree_with_value($fld, $actfld, 1);
	}
	return $result;
}




sub ignore_node_conditional_string_lag
{
    my $input = $_[0];
    my $actfld;
    my $fld;
    my $updateactfld;
    my $updatefld;
    my $comp_val;
    my $actcomp_val;
    my $result = $NOOP_CLI_RETURN_OPTION;
    ($actfld, $actcomp_val, $updateactfld) = split(/$nodeparamconnector/, $input, 3);
    if (get_value_from_xml_dbase( $actfld, \$fld)) {
    }
    $result = param_value_return($actcomp_val, \$comp_val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    if($comp_val eq $fld) {
        return $NO_INSTANCE_FOUND;
    }
    $result = param_value_return($updateactfld, \$updatefld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    if($updatefld == 29) {
        $updatefld = 1;
    }
    update_cli_tree_with_value($updatefld, $updateactfld, 1);
    return 1;
}

sub ignore_node
{
# print "ignore_node called\n";
    return $NO_INSTANCE_FOUND;
}

sub update_reverse_bit_return_value
{
    my $input = $_[0];
    my $actfld;
    my $actbitmask;
    my $actretfld;
    my $actsetreset;
    my $fld;
    my $bitmask;
    my $retval;
    my $setreset;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $string;
    
    ($actfld, $actbitmask, $actretfld, $actsetreset) = split(/$nodeparamconnector/, $input, 3);
    add_hole_in_cli_tree_buffer();
# print "checkBit1 $actfld, $actbitmask, $actmap, $input\n";
    $result = param_value_return($actbitmask, \$bitmask);
# print "checkBit5 $actfld, $actbitmask, $actmap, $input, $bitmask\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
# print "checkBit4 $result, $actfld, $fld\n";
    $result = param_value_return($actfld, \$fld);
# print "checkBit3 $result, $actfld, $fld\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actretfld, \$retval);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actsetreset, \$setreset);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
# print "checkBit2 $bitmask, $fld, $map\n";
    if ($fld & $bitmask) {
# print "checkBit6 $bitmask, $fld, $map, $string\n";
        if ($setreset) {
            $result = update_cli_tree_with_value($retval, $actretfld, 1);
        } else {
            $result = $STRVALMAP_NO_VALUE_FOUND;
        }
    } else {
        if (!$setreset) {
            $result = update_cli_tree_with_value($retval, $actretfld, 1);
        } else {
            $result = $STRVALMAP_NO_VALUE_FOUND;
        }
    }
    return $result;
}
# 11nsupport mcs CLI require bit and index of an array
sub update_reverse_bit_with_map_and_index
{
    my $input = $_[0];
    my $actfld;
    my $actbitmask;
    my $actmap;
    my $actindexval;
    my $indexval;
    my $actindexfld;
    my $indexfld;
    my $fld;
    my $bitmask;
    my $map;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $string;

    ($actfld, $actbitmask, $actmap, $actindexfld, $actindexval) = split(/$nodeparamconnector/, $input, 5);
    add_hole_in_cli_tree_buffer();
# print "checkBit1 $actfld, $actbitmask, $actmap, $input\n";
    $result = param_value_return($actbitmask, \$bitmask);
# print "checkBit5 $actfld, $actbitmask, $actmap, $input, $bitmask\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
# print "checkBit4 $result, $actfld, $fld\n";
    $result = param_value_return($actfld, \$fld);
# print "checkBit3 $result, $actfld, $fld\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actmap, \$map);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actindexfld, \$indexfld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actindexval, \$indexval);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
# print "checkBit2 $bitmask, $fld, $map\n";
    if ($fld & $bitmask) {
        $result = get_string_from_value($map, 1, \$string);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
# print "checkBit6 $bitmask, $fld, $map, $string, $indexfld, $indexval\n";
        if($indexfld == $indexval) {
            $result = update_cli_tree_with_value($string, $actfld, 1);
        } else {
            return $NO_INSTANCE_FOUND;
        }
    } else {
        $result = get_string_from_value($map, 0, \$string);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
# print "checkBit7 $bitmask, $fld, $map, $string, $indexfld, $indexval\n";
        if($indexfld == $indexval) {
            $result = update_cli_tree_with_value($string, $actfld, 1);
        } else {
            return $NO_INSTANCE_FOUND;
        }
    }
    return $result;
}

sub update_reverse_bit_with_map_with_nonexist
{
    my $input = $_[0];
    my $actfld;
    my $actbitmask;
    my $actmap;
    my $fld;
    my $bitmask;
    my $map;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $string;
    my $dummy;
    
    ($actfld, $actbitmask, $actmap, $actvalstr) = split(/$nodeparamconnector/, $input, 4);
    add_hole_in_cli_tree_buffer();
# print "update_reverse_bit_with_map_with_nonexist1 $actfld, $actbitmask, $actmap, $input\n";
    if (!get_value_from_xml_dbase($actfld, \$dummy)) {
        $result = param_value_return($actvalstr, \$valstr);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
# print "update_reverse_bit_with_map_with_nonexist8 $valstr\n";
        $result = update_cli_tree_with_value($valstr, $actvalstr, 1);
        return $result;
    }

    $result = param_value_return($actbitmask, \$bitmask);
# print "update_reverse_bit_with_map_with_nonexist5 $actfld, $actbitmask, $actmap, $input, $bitmask\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
# print "update_reverse_bit_with_map_with_nonexist4 $result, $actfld, $fld\n";
    $result = param_value_return($actfld, \$fld);
# print "checkBit3 $result, $actfld, $fld\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actmap, \$map);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
# print "update_reverse_bit_with_map_with_nonexist2 $bitmask, $fld, $map\n";
    if ($fld & $bitmask) {
        $result = get_string_from_value($map, 1, \$string);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
# print "update_reverse_bit_with_map_with_nonexist6 $bitmask, $fld, $map, $string\n";
        $result = update_cli_tree_with_value($string, $actfld, 1);
    } else {
        $result = get_string_from_value($map, 0, \$string);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
# print "update_reverse_bit_with_map_with_nonexist7 $bitmask, $fld, $map, $string\n";
        $result = update_cli_tree_with_value($string, $actfld, 1);
    }
    return $result;
}

sub update_reverse_bit_with_map
{
    my $input = $_[0];
    my $actfld;
    my $actbitmask;
    my $actmap;
    my $fld;
    my $bitmask;
    my $map;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $string;

    ($actfld, $actbitmask, $actmap) = split(/$nodeparamconnector/, $input, 3);
    add_hole_in_cli_tree_buffer();
# print "checkBit1 $actfld, $actbitmask, $actmap, $input\n";
    $result = param_value_return($actbitmask, \$bitmask);
# print "checkBit5 $actfld, $actbitmask, $actmap, $input, $bitmask\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
# print "checkBit4 $result, $actfld, $fld\n";
    $result = param_value_return($actfld, \$fld);
# print "checkBit3 $result, $actfld, $fld\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actmap, \$map);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
# print "checkBit2 $bitmask, $fld, $map\n";
    if ($fld & $bitmask) {
        $result = get_string_from_value($map, 1, \$string);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
# print "checkBit6 $bitmask, $fld, $map, $string\n";
        $result = update_cli_tree_with_value($string, $actfld, 1);
    } else {
        $result = get_string_from_value($map, 0, \$string);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
# print "checkBit7 $bitmask, $fld, $map, $string\n";
        $result = update_cli_tree_with_value($string, $actfld, 1);
    }
    return $result;
}

sub update_reverse_bit_with_map_default
{
    my $input = $_[0];
    my $actfld;
    my $actbitmask;
    my $actmap;
    my $fld = 0;
    my $bitmask;
    my $map;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $string;
    
    ($actfld, $actbitmask, $actmap) = split(/$nodeparamconnector/, $input, 3);
    add_hole_in_cli_tree_buffer();
# print "checkBit1 $actfld, $actbitmask, $actmap, $input\n";
    $result = param_value_return($actbitmask, \$bitmask);
# print "checkBit5 $actfld, $actbitmask, $actmap, $input, $bitmask\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
# print "checkBit4 $result, $actfld, $fld\n";
    if (get_value_from_xml_dbase($actfld, \$fld)) {
    }
# print "checkBit3 $result, $actfld, $fld\n";
    $result = param_value_return($actmap, \$map);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
# print "checkBit2 $bitmask, $fld, $map\n";
    if ($fld & $bitmask) {
        $result = get_string_from_value($map, 1, \$string);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
# print "checkBit6 $bitmask, $fld, $map, $string\n";
        $result = update_cli_tree_with_value($string, $actfld, 1);
    } else {
        $result = get_string_from_value($map, 0, \$string);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
# print "checkBit7 $bitmask, $fld, $map, $string\n";
        $result = update_cli_tree_with_value($string, $actfld, 1);
    }
    return $result;
}

sub update_reverse_for_exclusionlist
{
    my $input = $_[0];
    my $actfld;
    my $fld;
    my $actservicefld;
    my $servicefld;
    my $actservice;
    my $service;
    my $actrulefld;
    my $rulefld;
    my $actrule;
    my $rule;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my @val_tmp;
    my $j=0;

    ($actfld, $actservicefld, $actservice, $actrulefld, $actrule) = split(/$nodeparamconnector/, $input, 5);
#print "update_reverse_for_exclusionlist1 $actfld\n";
    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld, \$fld);
#print "update_reverse_for_exclusionlist2 $actfld, $fld, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actservicefld, \$servicefld);
#print "update_reverse_for_exclusionlist3 $actservicefld, $servicefld, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actservice, \$service);
#print "update_reverse_for_exclusionlist4 $actservice, $service, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actrulefld, \$rulefld);
#print "update_reverse_for_exclusionlist5 $actrulefld, $rulefld, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actrule, \$rule);
#print "update_reverse_for_exclusionlist6 $actrule, $rule, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    if(($servicefld == $service)&& ($rulefld eq $rule)) {
    my @temp = split(//,$fld);
    for(my $i=0; $i<=11; $i++) {
        $val_tmp[$j]= $temp[$i];
        $j += 1;
        if(($i%2 == 1)&&($i != 11)) {
            $val_tmp[$j]= ':';
            $j += 1;
        }
    }
    $fld = join('',@val_tmp);

    $result = update_cli_tree_with_value($fld, $actfld, 1);
#print "update_reverse_for_exclusionlist2 $actfld, $fld, $result\n";
    return $result;
    }
    else {
        return $result;
    }
}

sub update_reverse_for_macfilter
{
    my $input = $_[0];
    my $actfld;
    my $fld;
    my $actservicefld;
    my $servicefld;
    my $actservice;
    my $service;
    my $actrulefld;
    my $rulefld;
    my $actrule;
    my $rule;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my @val_tmp;
    my $j=0;

# print "update_reverse1 $actfld\n";
    ($actfld, $actservicefld, $actservice, $actrulefld, $actrule) = split(/$nodeparamconnector/, $input, 5);
    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actservicefld, \$servicefld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actservice, \$service);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    if (get_value_from_xml_dbase($actrulefld, \$rulefld)) {
    }
    $result = param_value_return($actrule, \$rule);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    if(($servicefld == $service)&& ($rulefld ne $rule)) {
    my @temp = split(//,$fld);
    for(my $i=0; $i<=11; $i++) {
        $val_tmp[$j]= $temp[$i];
        $j += 1;
        if(($i%2 == 1)&&($i != 11)) {
            $val_tmp[$j]= ':';
            $j += 1;
        }
    }
    $fld = join('',@val_tmp);

#print "update_reverse2 $actfld, $fld\n";
    $result = update_cli_tree_with_value($fld, $actfld, 1);
    return $result;
    }
    else {
        return $result;
    }
}


sub update_reverse_for_mac_conditional
{
    my $input = $_[0];
    my $actfld;
    my $fld;
    my $actservicefld;
    my $servicefld;
    my $actservice;
    my $service;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my @val_tmp;
    my $j=0;

    ($actfld, $actservicefld, $actservice) = split(/$nodeparamconnector/, $input, 3);
    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actservicefld, \$servicefld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actservice, \$service);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    if($servicefld == $service){
        my @temp = split(//,$fld);
        for(my $i=0; $i<=11; $i++) {
            $val_tmp[$j]= $temp[$i];
            $j += 1;
            if(($i%2 == 1)&&($i != 11)) {
                $val_tmp[$j]= ':';
                $j += 1;
            }
        }
        $fld = join('',@val_tmp);
#print "update_reverse $service, $fld\n";
        $result = update_cli_tree_with_value($fld, $actfld, 1);
        return $result;
    }
    else {
        return $result;
    }
}

sub update_reverse_for_mac
{
    my $actfld = $_[0];
    my $fld;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my @val_tmp;
    my $j=0;

# print "update_reverse1 $actfld\n";
    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    my @temp = split(//,$fld);
    for(my $i=0; $i<=11; $i++) {
        $val_tmp[$j]= $temp[$i];
        $j += 1;
        if(($i%2 == 1)&&($i != 11)) {
            $val_tmp[$j]= ':';
            $j += 1;
        }
    }
    $fld = join(//,@val_tmp);
#print "testing: $fld\n";

    
#print "update_reverse2 $actfld, $fld\n";
    $result = update_cli_tree_with_value($fld, $actfld, 1);
    return $result;
}

sub update_reverse_keyword_if_default_field
{
    my $input = $_[0];
    my $actfld;
    my $fld;
    my $newfld;
    my $actval;
    my $val;
    my $actdefault;
    my $default;
    my $actmap;
    my $map;
    my $string;
    my $result = $NOOP_CLI_RETURN_OPTION;

#print "update_reverse1 $actfld\n";
    ($actfld, $actval, $actdefault, $actmap) = split(/$nodeparamconnector/, $input, 4);
    add_hole_in_cli_tree_buffer();
    if (get_value_from_xml_dbase($actfld, \$fld)) {
    }

    if(!defined($fld)) {
        $result = param_value_return($actval, \$val);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        $result = update_cli_tree_with_value($val, $actval, 1);
    } else {
        $result = param_value_return($actfld, \$newfld);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        $result = param_value_return($actdefault, \$default);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        $result = param_value_return($actmap, \$map);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        $result = get_string_from_value($map, $newfld, \$string);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
#print "update_reverse_keyword_if_default_field1 $map, $newfld, $string, $result\n";
        if($string ne $default) {
            $result = update_cli_tree_with_value($string, $actmap, 1);
        }
    }
#print "update_reverse2 $actfld, $fld\n";
    return $result;
}
################################################################
#@ Written on top of update_reverse_keyword_if_default_field   #
#@ function inject null character into string if               #
#@ new field is equal to zero                                  #
################################################################
sub update_reverse_keyword_if_default_field_server_precedence
{
    my $input = $_[0];
    my $actfld;
    my $fld;
    my $newfld;
    my $actval;
    my $val;
    my $actdefault;
    my $default;
    my $actmap;
    my $map;
    my $string;
    my $result = $NOOP_CLI_RETURN_OPTION;

#print "update_reverse1 $actfld\n";
    ($actfld, $actval, $actdefault, $actmap) = split(/$nodeparamconnector/, $input, 4);
    add_hole_in_cli_tree_buffer();
    if (get_value_from_xml_dbase($actfld, \$fld)) {
    }

    if(!defined($fld)) {
        $result = param_value_return($actval, \$val);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        $result = update_cli_tree_with_value($val, $actval, 1);
    } else {
        $result = param_value_return($actfld, \$newfld);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        $result = param_value_return($actdefault, \$default);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        $result = param_value_return($actmap, \$map);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
	if($newfld == 0) {
		$string="";
#print "found Zero\n";
	} else {
			$result = get_string_from_value($map, $newfld, \$string);
#print "\n printing map and fld from server_precedence $map $newfld $string\n";
			
			if ($result != $PARAM_UPDATE_SUCCESS) {
				return $result;
			}
	}
#print "update_reverse_keyword_if_default_field_server_precedence $map, $newfld, $string, $result\n";
        if($string ne $default) {
            $result = update_cli_tree_with_value($string, $actmap, 1);
        }
    }
    return $result;
}

sub update_reverse_hex_ascii
{
    my $input = $_[0];
    my $fld;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $hex;
    my $actfld;
    my $actval;
    my $actop;
    my $fld;
    my $val;
    my $top;
    ($actfld, $actval, $actop) = split(/\,/, $input);
    add_hole_in_cli_tree_buffer();

#print "called $actfld $actval $actop\n";

    $result = param_value_return($actfld, \$fld);
#print "update_reverse3 $actfld, $fld, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print "update_reverse2 $actval, $val\n";
    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
#        print "return2 $actval $val\n";
        return $result;
    }

#print "update_reverseval  $fld $val \n";
    $hex = $fld =~ /^[0-9a-fA-F]+$/;
#    / Now check if it contains HEX or not.
    if ((!$hex && $val == 3)  || ( $hex && $val == 2)) {
        $result = update_cli_tree_with_value($fld, $actfld, 1);
    } else {
    return $NOOP_CLI_RETURN_OPTION;
    }
    return $result;
}

sub update_reverse
{
    my $actfld = $_[0];
    my $fld;
    my $result = $NOOP_CLI_RETURN_OPTION;

#print "update_reverse1 $actfld\n";
    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld, \$fld);
#print "update_reverse3 $actfld, $fld, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print "update_reverse2 $actfld, $fld\n";
    $result = update_cli_tree_with_value($fld, $actfld, 1);
    return $result;
}

sub update_reverse_with_operated_index
{
    my $input = $_[0];
    my $actfld;
    my $actval;
    my $actop;
    my $fld;
    my $val;
    my $op;
    my $val;

    ($actfld, $actval, $actop) = split(/\,/, $input);
    add_hole_in_cli_tree_buffer();

    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $result = param_value_return($actop, \$op);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    if ($op == $add_op) {
        $fld = $fld + $val;
    } elsif ($op == $sub_op) {
        $fld = $fld - $val;
    } elsif ($op == $mul_op) {
        $fld = $fld * $val;
    } elsif ($op == $div_op) {
        $fld = $fld / $val;
    } else {
        print "Wrong operator entered it should be 1 = add, 2 = sub, 3 = mul or 4 = div\n";
        die;
    }
#print "update_reverse_with_operated_index1 $actfld, $fld\n";
    $result = update_cli_tree_with_value($fld, $actfld, 1);
    return $result;    
}

# This action will check whether the field (fld) is defined. 
# If it is not defined, fld will be set to the last 
# parameter passed (i.e. val2).
sub update_reverse_with_operated_index_with_default
{
    my $input = $_[0];
    my $actfld;
    my $actval;
    my $actval2;
    my $actop;
    my $fld;
    my $tmpfld;
    my $val;
    my $op;
    my $val2;

    ($actfld, $actval, $actop, $actval2) = split(/\,/, $input);
    add_hole_in_cli_tree_buffer();

    if (get_value_from_xml_dbase($actfld, \$tmpfld)) {
    }
    if(defined($tmpfld)) {
        $result = param_value_return($actfld, \$fld);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
    } else {
        $result = param_value_return($actval2, \$val2);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        $fld = $val2;
    }

    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $result = param_value_return($actop, \$op);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    if ($op == $add_op) {
        $fld = $fld + $val;
    } elsif ($op == $sub_op) {
        $fld = $fld - $val;
    } elsif ($op == $mul_op) {
        $fld = $fld * $val;
    } elsif ($op == $div_op) {
        $fld = $fld / $val;
    } else {
        print "Wrong operator entered it should be 1 = add, 2 = sub, 3 = mul or 4 = div\n";
        die;
    }
#print "update_reverse_with_operated_index_with_default1 $actfld, $fld\n";
    $result = update_cli_tree_with_value($fld, $actfld, 1);
    return $result;    
}

sub update_reverse_with_operated_value_guest
{
    my $input = $_[0];
    my $actfld;
    my $actval;
    my $actop;
    my $fld;
    my $val;
    my $op;
    my $val;

    ($actfld, $actval, $actop) = split(/\,/, $input);
    add_hole_in_cli_tree_buffer();

    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $result = param_value_return($actop, \$op);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

	if($is_szabla == 1) {
		if($val == 513) {
			$val = 17;
	    }
	}

    if ($op == $add_op) {
        $fld = $fld + $val;
    } elsif ($op == $sub_op) {
        $fld = $fld - $val;
    } elsif ($op == $mul_op) {
        $fld = $fld * $val;
    } elsif ($op == $div_op) {
        $fld = $fld / $val;
    } else {
        print "Wrong operator entered it should be 1 = add, 2 = sub, 3 = mul or 4 = div\n";
        die;
    }

    $result = update_cli_tree_with_value($fld, $actfld, 1);
    return $result;    
}

sub update_reverse_with_operated_value
{
    my $input = $_[0];
    my $actfld;
    my $actval;
    my $actop;
    my $fld;
    my $val;
    my $op;
    my $val;

    ($actfld, $actval, $actop) = split(/\,/, $input);
    add_hole_in_cli_tree_buffer();

    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $result = param_value_return($actop, \$op);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    if ($op == $add_op) {
        $fld = $fld + $val;
    } elsif ($op == $sub_op) {
        $fld = $fld - $val;
    } elsif ($op == $mul_op) {
        $fld = $fld * $val;
    } elsif ($op == $div_op) {
        $fld = $fld / $val;
    } else {
        print "Wrong operator entered it should be 1 = add, 2 = sub, 3 = mul or 4 = div\n";
        die;
    }

    $result = update_cli_tree_with_value($fld, $actfld, 1);
    return $result;    
}

sub update_reverse_index
{
    my $actfld = $_[0];
    my $fld;
    my $result = $NOOP_CLI_RETURN_OPTION;

# print "update_reverse_index1 $actfld\n";
    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = update_cli_tree_with_value($fld, $actfld, 1);
# print "update_reverse_index2 $fld, $actfld\n";
    return $result;
}

#Action added to perform reverse action specially for guest-lan in custom-web.
#It checks that wlans index should be greater than 513 and then subtract 513 from index to get actual guestlan-id.
sub  update_reverse_operated_index_with_condition
{

    my $input = $_[0];
    my $actfld;
    my $actval;
    my $actopr;
    my $fld;
    my $val;
    my $opr;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $string;

    ($actfld, $actval, $actopr) = split(/$nodeparamconnector/, $input, 3);

    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actopr, \$opr);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    if ($opr == $grt_op ) {
        if ($fld > $val) {
            add_hole_in_cli_tree_buffer();
#print "update_reverse_operated_index_with_condition fld $fld, val $val \n";
            $fld = $fld - $val;
            $result = update_cli_tree_with_value($fld, $actfld, 1);
        } else {
            $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
        }
    } else {
        print "Wrong operator entered it should be  1=greater than.\n";
        die;
    }
    return $result;
}


sub update_reverse_fieldvalue_or_defaultfieldvalue
{
    my $input = $_[0];
    my $actfld;
    my $actsupportfld;
    my $actval;
    my $fld;
    my $newfld;
    my $supportfld;
    my $val;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actsupportfld, $actval) = split(/$nodeparamconnector/, $input, 3);

    add_hole_in_cli_tree_buffer();
    if (get_value_from_xml_dbase($actfld, \$fld)) {
    }
    if(defined($fld) && ($fld ne "0.0.0.0")) {
        $result = param_value_return($actfld, \$newfld);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        $result = update_cli_tree_with_value($newfld, $actfld, 1);
    } else {
        $result = param_value_return($actsupportfld, \$supportfld);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        if (get_value_from_xml_dbase($actval, \$val)) {
        }
        if(defined($val)) {
#print "update_reverse_conditional_radiusport5 $actfld, $val \n";
            $result = update_cli_tree_with_value($val, $actval, 1);
        }
    }
    return $result;
}

#Action added to upload radius auth/acct CLIs with default port if IP address is given.
sub  update_reverse_default
{

    my $input = $_[0];
    my $actfld;
    my $actval;
    my $fld;
    my $val;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actval) = split(/$nodeparamconnector/, $input, 2);

    add_hole_in_cli_tree_buffer();
    if (get_value_from_xml_dbase($actfld, \$fld)) {
    }
    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    if(defined($fld)) {
#print "update_reverse_conditional_radiusport4 $fld, $val \n";
        $result = update_cli_tree_with_value($fld, $actfld, 1);
    } else {
        $result = update_cli_tree_with_value($val, $actfld, 1);
    }
    return $result;
}

sub  update_reverse_default_if_required
{
    my $input = $_[0];
    my $actfld;
    my $actsupportfld;
    my $actval;
    my $fld;
    my $newfld;
    my $supportfld;
    my $val;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actsupportfld, $actval) = split(/$nodeparamconnector/, $input, 3);

    add_hole_in_cli_tree_buffer();
    if (get_value_from_xml_dbase($actfld, \$fld)) {
    }
    if(defined($fld)) {
        $result = param_value_return($actfld, \$newfld);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        $result = update_cli_tree_with_value($newfld, $actfld, 1);
    } else {
        $result = param_value_return($actsupportfld, \$supportfld);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        $result = param_value_return($actval, \$val);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
#print "update_reverse_conditional_radiusport5 $actfld, $val \n";
        $result = update_cli_tree_with_value($val, $actfld, 1);
    }
    return $result;
}

# Consider a case when CLI updates more than 1 field. If fields have default values,
# they are not stored in XML. In transfer upload (XML to CLI), the CLI will not be 
# created if any of the fields of CLI is not present in XML file. To avoid this 
# situation this new action is added. This action will take following parameters:
# (1). Field value to be uploaded. 
# (2). Default value for field. If field is not present in XML, then upload default value.
# (3). Number of supporting fields (Number of remaining fields in CLI).(Say N).
# (3+1), (3+2)....(3+N). All the supporting fields.
# If atleast one of the supporting field is present then upload the CLI.
sub  update_reverse_if_supporting_fields_present
{
    my $input = $_[0];
    my $actfld;
    my $actsupportflds;
    my @actsupportfldsarray;
    my $actval;
    my $actnumsupportflds;
    my $numsupportflds;
    my $fld;
    my $newfld;
    my $supportfld;
    my $val;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actval, $actnumsupportflds, $actsupportflds) = split(/$nodeparamconnector/, $input, 4);
#print "update_reverse_if_supporting_fields_present1 $actfld, $actval, $numsupportflds, $actsupportflds\n";
    add_hole_in_cli_tree_buffer();
# Check if field is present in XML.
    if (get_value_from_xml_dbase($actfld, \$fld)) {
    }
    if(defined($fld)) {
        $result = param_value_return($actfld, \$newfld);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
# if field present the directly upload its value.
        $result = update_cli_tree_with_value($newfld, $actfld, 1);
    } else {
# if field is not present, then get the number of supporting fields.
        $result = param_value_return($actnumsupportflds, \$numsupportflds);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        @actsupportfldsarray = split(/$nodeparamconnector/, $actsupportflds, $numsupportflds);
        my $supportfieldfoundflag = 0;
        for(my $i=0; $i< $numsupportflds; $i++) {
            if (get_value_from_xml_dbase($actsupportfldsarray[$i], \$supportfld)) {
            }
# if any of the supporting field is present then upload the default value.
            if(defined($supportfld)) {
                $supportfieldfoundflag = 1;
            }   
        }
        $result = param_value_return($actval, \$val);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
#print "update_reverse_conditional_radiusport5 $actfld, $val \n";
        if($supportfieldfoundflag == 1) {
            $result = update_cli_tree_with_value($val, $actfld, 1);
        } else {
            $result = $NOOP_CLI_RETURN_OPTION;
        }
    }
    return $result;
}

# Reverse action when cli configures network multicast mode as multicast-multicast.
sub  update_reverse_if_supporting_fields_mcast
{
    my $input = $_[0];
    my $actfld;
    my $actsupportflds;
    my @actsupportfldsarray;
    my $actval;
    my $actnumsupportflds;
    my $numsupportflds;
    my $fld;
    my $newfld;
    my $supportfld;
    my $val;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actval, $actnumsupportflds, $actsupportflds) = split(/$nodeparamconnector/, $input, 4);
#print "update_reverse_if_supporting_fields_present1 $actfld, $actval, $numsupportflds, $actsupportflds\n";
    add_hole_in_cli_tree_buffer();
# Check if field is present in XML.
    if (get_value_from_xml_dbase($actfld, \$fld)) {
    }
    if(defined($fld)) {
        $result = param_value_return($actfld, \$newfld);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
# if field present then directly upload its value.
# if value is stored as 1 upload it as multicast.
        if($newfld == 1) { 
            $newfld = "multicast";
        }
        $result = update_cli_tree_with_value($newfld, $actfld, 1);
    } else {
# if field is not present, then get the number of supporting fields.
    if($is_saber == 1 || $is_pata == 1 || $is_khanda == 1 || $is_szabla == 1) {
        $result = param_value_return($actnumsupportflds, \$numsupportflds);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        @actsupportfldsarray = split(/$nodeparamconnector/, $actsupportflds, $numsupportflds);
        my $supportfieldfoundflag = 0;
        for(my $i=0; $i< $numsupportflds; $i++) {
            if (get_value_from_xml_dbase($actsupportfldsarray[$i], \$supportfld)) {
            }
# if any of the supporting field is present then upload the default value.
            if(defined($supportfld)) {
                $supportfieldfoundflag = 1;
            }   
        }
        $result = param_value_return($actval, \$val);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
# print "update_reverse_conditional_radiusport5 $actfld, $val \n";
        if($supportfieldfoundflag == 1) {
            $result = update_cli_tree_with_value($val, $actfld, 1);
        } else {
            $result = $NOOP_CLI_RETURN_OPTION;
        }
    }
    }
    return $result;
}
# This function is used in the following case : 
# When a CLI updates more than one value and a  particular node's value is to 
# be updated only when it is not mataching a specific value.
# Eg : config ipv6 neighbor-binding ra-throttling at-least <value> at-most <value or no-limit>
# This function is to be used for updating the at-most value. The at-most value is to be 
# updated even if its default and at-least is not default

sub  update_reverse_if_supporting_fields_present_with_exception
{
    my $input = $_[0];
    my $actfld;
    my $actsupportflds;
    my @actsupportfldsarray;
    my $actval;
    my $actnumsupportflds;
    my $numsupportflds;
    my $fld;
    my $newfld;
    my $supportfld;
    my $val;
	my $excfld;
	my $excval;
	my $actstring;
	my $stringval;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actval, $actnumsupportflds, $actsupportflds,$excfld,$actstring) = split(/$nodeparamconnector/, $input, 6);
	
    add_hole_in_cli_tree_buffer();
	
# Check if field is present in XML.
    if (get_value_from_xml_dbase($actfld, \$fld)) {
    }
    if(defined($fld)) {
        $result = param_value_return($actfld, \$newfld);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
# if field present the directly upload its value.
        $result = param_value_return($excfld, \$excval);
		if ($result != $PARAM_UPDATE_SUCCESS) {
			return $result;
		}
        if ($newfld != $excval) {
          	$result = update_cli_tree_with_value($newfld, $actfld, 1);
		} else {
		    $result = param_value_return($actstring,\$stringval); 
			if ($result != $PARAM_UPDATE_SUCCESS) {
				return $result;
			}
			$result = update_cli_tree_with_value($stringval, $actfld, 1);
			return $result;
		}
		  
    } else {
# if field is not present, then get the number of supporting fields.
        $result = param_value_return($actnumsupportflds, \$numsupportflds);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        @actsupportfldsarray = split(/$nodeparamconnector/, $actsupportflds, $numsupportflds);
        my $supportfieldfoundflag = 0;
        for(my $i=0; $i< $numsupportflds; $i++) {
            if (get_value_from_xml_dbase($actsupportfldsarray[$i], \$supportfld)) {
            }
# if any of the supporting field is present then upload the default value.
            if(defined($supportfld)) {
                $supportfieldfoundflag = 1;
            }   
        }
        $result = param_value_return($actval, \$val);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        if($supportfieldfoundflag == 1) {
            $result = update_cli_tree_with_value($val, $actfld, 1);
	    }
	    else
	    {
	       $result = $NOOP_CLI_RETURN_OPTION;
	    }
    }
    return $result;
}
# Consider a case when CLI updates more than 1 field. If fields have default values,
# they are not stored in XML. In transfer upload (XML to CLI), the CLI will not be
# created if any of the fields of CLI is not present in XML file. To avoid this
# situation this new action is added. This action will take following parameters:
# (1). Field value to be uploaded.
# (2). Default value for field. If field is not present in XML, then upload default value. The default value 
#      should be mapped string to be uploaded as default value
# (3). Map to be used to map the value of the field to string which will get uploaded.
# (4). Number of supporting fields (Number of remaining fields in CLI).(Say N).
# (4+1), (4+2)....(4+N). All the supporting fields.
# If atleast one of the supporting field is present then upload the CLI.
sub  update_reverse_if_supporting_fields_present_with_map
{
    my $input = $_[0];
    my $actfld;
    my $actsupportflds;
    my @actsupportfldsarray;
    my $actval;
    my $actmap;
    my $actnumsupportflds;
    my $numsupportflds;
    my $fld;
    my $newfld;
    my $supportfld;
    my $val;
    my $map;
    my $string;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actval, $actmap, $actnumsupportflds, $actsupportflds) =
                split(/$nodeparamconnector/, $input, 5);
#print "update_reverse_if_supporting_fields_present1 $actfld, $actval, $numsupportflds, $actsupportflds\n";
    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actmap, \$map);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
# Check if field is present in XML.
    if (get_value_from_xml_dbase($actfld, \$fld)) {
    }
    if(defined($fld)) {
        $result = param_value_return($actfld, \$newfld);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
# if field present the upload its value after mapping to respective string
        $result = get_string_from_value($map, $newfld, \$string);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        $result = update_cli_tree_with_value($string, $actfld, 1);
    } else {
# if field is not present, then get the number of supporting fields.
        $result = param_value_return($actnumsupportflds, \$numsupportflds);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        @actsupportfldsarray = split(/$nodeparamconnector/, $actsupportflds, $numsupportflds);
        my $supportfieldfoundflag = 0;
        for(my $i=0; $i< $numsupportflds; $i++) {
            if (get_value_from_xml_dbase($actsupportfldsarray[$i],
\$supportfld)) {
            }
# if any of the supporting field is present then upload the default value.
            if(defined($supportfld)) {
                $supportfieldfoundflag = 1;
            }
        }
        $result = param_value_return($actval, \$val);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
#print "update_reverse_conditional_radiusport5 $actfld, $val \n";
        if($supportfieldfoundflag == 1) {
            $result = update_cli_tree_with_value($val, $actfld, 1);
        } else {
            $result = $NOOP_CLI_RETURN_OPTION;
        }
    }
    return $result;
}
#Action added to upload radius auth/acct CLIs with default port if IP address is given.
sub  update_reverse_default_ifextrafield_present
{

    my $input = $_[0];
    my $actfld;
    my $actsupportfld;
    my $actval;
    my $fld;
    my $supportfld;
    my $val;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actsupportfld, $actval) = split(/$nodeparamconnector/, $input, 3);

    add_hole_in_cli_tree_buffer();
    if (get_value_from_xml_dbase($actfld, \$fld)) {
    }
    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actsupportfld, \$supportfld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    if(defined($fld)) {
        $result = update_cli_tree_with_value($fld, $actfld, 1);
    } else {
        if (defined($supportfld)) {
#print "update_reverse_conditional_radiusport5 $actfld, $val \n";
            $result = update_cli_tree_with_value($val, $actfld, 1);
        } else {
            return $NO_INSTANCE_FOUND;
        }
    }
    return $result;
}

#Action added to do reverse action for upload config of "config network multicast mode multicast <IP-address>"
sub update_reverse_multicast_mode
{

    my $input = $_[0];
    my $actip;
    my $ip;
    my $fld;
    my $mode;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actip, $actmode) = split(/$nodeparamconnector/, $input, 2);

    add_hole_in_cli_tree_buffer();
    if (get_value_from_xml_dbase($actmode, \$fld)) {
    }
    if (defined($fld)) {
        $result = param_value_return($actmode, \$mode);
        if ($result != $PARAM_UPDATE_SUCCESS) {
             return $result;
        }
        if ($mode == 0) {
             return $NOOP_CLI_RETURN_OPTION;
        }
    }
    $result = param_value_return($actip, \$ip);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = update_cli_tree_with_value($ip, $actip, 1);
    return $result;
}


#Action added to do reverse action for upload config of "config network ipv6 multicast mode multicast <IP-address>"
#Not able to get value from xml database in case of saber hack is to update the content ipv6 even it is not defined.
#if the node is with out any ipv6 address we remove that node in the
#post check using remove_ipv6_mcast_cli
sub update_reverse_multicast_mode_ipv6
{

    my $input = $_[0];
    my $actip;
    my $ip;
    my $fld;
    my $mode;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actip, $actmode) = split(/$nodeparamconnector/, $input, 2);

    add_hole_in_cli_tree_buffer();
    if (get_value_from_xml_dbase($actmode, \$fld)) {
    }
    if (defined($fld)) {
        $result = param_value_return($actmode, \$mode);
        if ($result != $PARAM_UPDATE_SUCCESS) {
             return $result;
        }
        if ($mode == 0) {
             return $NOOP_CLI_RETURN_OPTION;
        }
    }
    $result = param_value_return($actip, \$ip);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = update_cli_tree_with_value($ip, $actip, 1);
    return $result;
}

#Action added to do reverse action for upload config of "config network multicast mode unicast"
sub update_reverse_unicast_mode
{

    my $input = $_[0];
    my $actmode;
    my $mode;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actmode) = split(/$nodeparamconnector/, $input, 1);

    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actmode, \$mode);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    
    if ($mode == 0) {
        $result = update_cli_tree_with_value("unicast", $actmode, 1);
    } else {
        $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
    }
    return $result;
}

#Action added to perform reverse action based on action greater than,equal, less than.
sub  update_reverse_conditional_string
{

    my $input = $_[0];
    my $actfld;
    my $actval;
    my $actopr;
    my $fld;
    my $valstr;
    my $opr;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $string;
    my $dummy;

    ($actfld, $actvalstr, $actopr) = split(/$nodeparamconnector/, $input, 3);

    add_hole_in_cli_tree_buffer();
    if ($opr == $notexist_op) {
        if (!get_value_from_xml_dbase($actfld, \$dummy)) {
            $result = param_value_return($actvalstr, \$valstr);
            if ($result != $PARAM_UPDATE_SUCCESS) {
                return $result;
            }
            $result = update_cli_tree_with_value($valstr, $actvalstr, 1);
        } else {
            $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
        }
    }
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actvalstr, \$valstr);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actopr, \$opr);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

#print "update_reverse_conditional $fld, $val $opr\n";
    if ($opr == $exist_op) {
        if (get_value_from_xml_dbase($actfld, \$dummy)) {
            $result = update_cli_tree_with_value($valstr, $actvalstr, 1);
        } else {
            $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
        }
    } else {
        print "Wrong operator entered it 1=greater tham 2= equal 3 =lessthan. .\n";
        die;
    }
    return $result;
}

#Action added to perform reverse action based on if field exists and matches with input value upload input string
#The action uploads passed in string rather than the compared field value
sub  update_reverse_string_with_conditional_string
{

    my $input = $_[0];
    my $actfld;
    my $actval;
    my $actopr;
    my $actclistr;
    my $fld;
    my $val;
    my $opr;
    my $clistr;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $string;
    my $dummy;

    ($actfld, $actval, $actopr, $actclistr) = split(/$nodeparamconnector/, $input, 4);

    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actopr, \$opr);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actclistr, \$clistr);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

#print "update_reverse_string_with_conditional_string $fld, $val $opr, $clistr, $actclistr\n";
    if ($opr == $exist_op) {
        if (get_value_from_xml_dbase($actfld, \$dummy)) {
#print "update_reverse_string_with_conditional_string1 $fld, $val $opr, $clistr\n";
            if ($val eq $dummy) {
                $result = update_cli_tree_with_value($clistr, $actclistr, 1);
            } else {
                 $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
            }
        } else {
            $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
        }
    } elsif ($opr == $notexist_op) {
        if (get_value_from_xml_dbase($actfld, \$dummy)) {
#print "update_reverse_string_with_conditional_string2 $fld, $val $opr, $clistr\n";
            if ($val eq $dummy) {
                $result = update_cli_tree_with_value($clistr, $actclistr, 1);
            } else {
                $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
            }
        } else {
#print "update_reverse_string_with_conditional_string3 $fld, $val $opr, $clistr\n";
            $result = update_cli_tree_with_value($clistr, $actclistr, 1);
        }
    } else {
        print "Wrong operator entered it 1=greater tham 2= equal 3 =lessthan. .\n";
        die;
    }
    return $result;
}

#Action added to perform reverse action based on action greater than,equal, less than.
#The action uploads passed in string rather than the compared field value
sub  update_reverse_string_with_conditional
{

    my $input = $_[0];
    my $actfld;
    my $actval;
    my $actopr;
    my $actclistr;
    my $fld;
    my $val;
    my $opr;
    my $clistr;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $string;
    my $dummy;

    ($actfld, $actval, $actopr, $actclistr) = split(/$nodeparamconnector/, $input, 4);

    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actopr, \$opr);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actclistr, \$clistr);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

#print "update_reverse_string_with_conditional $fld, $val $opr, $clistr, $actclistr\n";
    if ($opr == $grt_op ) {
        if ($fld > $val) {
#print "update_reverse_string_with_conditional1 $fld, $val $opr, $clistr\n";
            $result = update_cli_tree_with_value($clistr, $actclistr, 1);
        } else {
            $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
        }
    } elsif ($opr == $eq_op) {
        if ($fld == $val) {
#print "update_reverse_string_with_conditional2 $fld, $val $opr, $clistr\n";
            $result = update_cli_tree_with_value($clistr, $actclistr, 1);
        } else {
            $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
        }
    } elsif ($opr == $less_op) {
        if ($fld < $val) {
#print "update_reverse_string_with_conditional3 $fld, $val $opr, $clistr\n";
            $result = update_cli_tree_with_value($clistr, $actclistr, 1);
        } else {
            $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
        }
    } elsif ($opr == $exist_op) {
        if (get_value_from_xml_dbase($actfld, \$dummy)) {
#print "update_reverse_string_with_conditional4 $fld, $val $opr, $clistr\n";
            $result = update_cli_tree_with_value($clistr, $actclistr, 1);
        } else {
            $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
        }
    } else {
        print "Wrong operator entered it 1=greater tham 2= equal 3 =lessthan. .\n";
        die;
    }
    return $result;
}


#Action added to perform reverse action based on action greater than,equal, less than.
sub  update_reverse_conditional
{

    my $input = $_[0];
    my $actfld;
    my $actval;
    my $actopr;
    my $fld;
    my $val;
    my $opr;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $string;
    my $dummy;

    ($actfld, $actval, $actopr) = split(/$nodeparamconnector/, $input, 3);

    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actopr, \$opr);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

#print "update_reverse_conditional $fld, $val $opr\n";
    if ($opr == $grt_op ) {
        if ($fld > $val) {
#print "update_reverse_conditional1 $fld, $val $opr\n";
            $result = update_cli_tree_with_value($fld, $actfld, 1);
        } else {
            $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
        }
    } elsif ($opr == $eq_op) {
        if ($fld == $val) {
#print "update_reverse_conditional2 $fld, $val $opr\n";
            $result = update_cli_tree_with_value($fld, $actfld, 1);
        } else {
            $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
        }
    } elsif ($opr == $less_op) {
        if ($fld < $val) {
#print "update_reverse_conditional3 $fld, $val $opr\n";
            $result = update_cli_tree_with_value($fld, $actfld, 1);
        } else {
            $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
        }
    } elsif ($opr == $exist_op) {
        if (get_value_from_xml_dbase($actfld, \$dummy)) {
#print "update_reverse_conditional4 $fld, $val $opr\n";
            $result = update_cli_tree_with_value($fld, $actfld, 1);
        } else {
            $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
        }
    } else {
        print "Wrong operator entered it 1=greater tham 2= equal 3 =lessthan. .\n";
        die;
    }
    return $result;
}

sub update_reverse_conditional_with_diff_param
{

    my $input = $_[0];
    my $actfld;
    my $actval;
    my $actopr;
    my $actfld2;
    my $fld;
    my $val;
    my $opr;
    my $fld2;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $string;
    my $dummy;

    ($actfld, $actval, $actopr, $actfld2) = split(/$nodeparamconnector/, $input, 4);

    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actopr, \$opr);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actfld2, \$fld2);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

#print "update_reverse_conditional_with_diff_param $fld, $val, $opr, $fld2\n";
    if ($opr == $grt_op ) {
        if ($fld > $val) {
#print "update_reverse_conditional_with_diff_param1 $fld, $val $opr, $fld2\n";
            $result = update_cli_tree_with_value($fld2, $actfld2, 1);
        } else {
            $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
        }
    } elsif ($opr == $eq_op) {
        if ($fld == $val) {
#print "update_reverse_conditional_with_diff_param2 $fld, $val, $opr, $fld2\n";
            $result = update_cli_tree_with_value($fld2, $actfld2, 1);
        } else {
            $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
        }
    } elsif ($opr == $less_op) {
        if ($fld < $val) {
#print "update_reverse_conditional_with_diff_param3 $fld, $val $opr, $fld2\n";
            $result = update_cli_tree_with_value($fld2, $actfld2, 1);
        } else {
            $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
        }
    } elsif ($opr == $exist_op) {
        if (get_value_from_xml_dbase($actfld, \$dummy)) {
#print "update_reverse_conditional_with_diff_param4 $fld, $val $opr, $fld2\n";
            $result = update_cli_tree_with_value($fld2, $actfld2, 1);
        } else {
            $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
        }
    } else {
        print "Wrong operator entered it 1=greater than 2= equal 3 =less than. \n";
        die;
    }
    return $result;
}

sub  update_reverse_conditional_index
{

    my $input = $_[0];
    my $actindx;
    my $actfld;
    my $actval;
    my $actopr;
    my $indx;
    my $fld;
    my $val;
    my $opr;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actindx, $actfld, $actval, $actopr) = split(/$nodeparamconnector/, $input, 4);

    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actindx, \$indx);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actopr, \$opr);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

#print "update_reverse_conditional_new indx1: $indx opr: $opr, val: $val fld: $fld\n";
    if ($opr == $grt_op ) {
        if ($indx > $val) {
            $result = update_cli_tree_with_value($fld, $actfld, 1);
        } else {
            $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
        }
    } elsif ($opr == $eq_op) {
        if ($indx == $val) {
            $result = update_cli_tree_with_value($fld, $actfld, 1);
        } else {
            $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
        }
    } elsif ($opr == $less_op) {
        if ($indx < $val) {
            $result = update_cli_tree_with_value($fld, $actfld, 1);
        } else {
            $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
        }
    } else {
        print "Wrong operator entered it 1=greater tham 2= equal 3 =lessthan. .\n";
        die;
    }
    return $result;
}


sub  update_reverse_compare_not_equal
{

    my $input = $_[0];
    my $actfld;
    my $actCmpVal;
    my $actString;
    my $fld;
    my $CmpVal;
    my $localString;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $string;

    ($actfld, $actCmpVal, $actString) = split(/$nodeparamconnector/, $input, 3);
    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actCmpVal, \$CmpVal);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
# print "checkBit4 $result, $actfld, $fld\n";
    $result = param_value_return($actfld, \$fld);
# print "checkBit3 $result, $actfld, $fld\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actString, \$localString);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
# print "checkBit2 $bitmask, $fld, $map\n";
    if ($fld != $CmpVal) {
        $string = $localString;
# print "checkBit6 $bitmask, $fld, $map, $string\n";
        $result = update_cli_tree_with_value($string, $actfld, 1);
    }
    return $result;
}

sub  update_reverse_compare_equal
{

    my $input = $_[0];
    my $actfld;
    my $actCmpVal;
    my $actString;
    my $fld;
    my $CmpVal;
    my $localString;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $string;

    ($actfld, $actCmpVal, $actString) = split(/$nodeparamconnector/, $input, 3);
    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actCmpVal, \$CmpVal);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
# print "checkBit4 $result, $actfld, $fld\n";
    $result = param_value_return($actfld, \$fld);
# print "checkBit3 $result, $actfld, $fld\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actString, \$localString);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
# print "checkBit2 $bitmask, $fld, $map\n";
    if ($fld == $CmpVal) {
        $string = $localString;
# print "checkBit6 $bitmask, $fld, $map, $string\n";
        $result = update_cli_tree_with_value($string, 0 ,0);
    }
    return $result;
}

sub update_keyword_index_with_map
{
    my $input = $_[0];
    my $actfld;
    my $actstr;
    my $actmap;
    my $fld;
    my $val;
    my $map;
    my $string;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actstr, $actmap) = split(/$nodeparamconnector/, $input, 3);
    add_hole_in_cli_tree_buffer();
# print "update_keyword_index_with_map1 $actfld, $actstr, $actmap, $input\n";
    $result = param_value_return($actfld, \$fld);
# print "update_keyword_index_with_map2 $fld, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actstr, \$string);
# print "update_keyword_index_with_map3 $string, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actmap, \$map);
# print "update_keyword_index_with_map4 $actmap, $map, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = get_value_from_string($map, $string, \$val);
# print "update_keyword_index_with_map5 $map, $string, $val, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
# print "update_keyword_index_with_map1 $fld, $val, $string, $map\n";
    $direct_index_from_keyword{$fld}{index} = $val;
    $direct_index_from_keyword{$fld}{level} = $clitoxmldb1_ptr_level;
    $direct_index_from_keyword_level[$clitoxmldb1_ptr_level]{$fld} = $fld;
    $result = update_cli_tree_with_value($string, 0, 0);
    return $result;
}

sub set_direct_index
{
    my $input = $_[0];
    my $actfld;
    my $actidx;
    my $fld;
    my $idx;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actidx) = split(/$nodeparamconnector/, $input, 2);
#print "1AAA: set_direct_index: $actfld, $actidx, $input\n";
    $result = param_value_return($actfld, \$fld);
#print "2AAA: set_direct_index: $fld, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actidx, \$idx);
#print "3AAA: set_direct_index: $idx, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print "4AAA: set_direct_index: $fld, $idx, $clitoxmldb1_ptr_level\n";
    $direct_index_from_keyword{$fld}{index} = $idx;
    $direct_index_from_keyword{$fld}{level} = $clitoxmldb1_ptr_level;
    $direct_index_from_keyword_level[$clitoxmldb1_ptr_level]{$fld} = $fld;
    return $result;
}

################################################################
#@Written on Top of sub set_direct_index                       #
#@Explicitly assigning the Level and instace from the XML code #
################################################################
sub set_direct_index_with_level
{
    my $input = $_[0];
    my $actfld;
    my $actidx;
    my $fld;
    my $idx;
    my $result = $NOOP_CLI_RETURN_OPTION;
	my $actlvl;
    my $lvl;
    ($actfld, $actlvl, $actidx) = split(/$nodeparamconnector/, $input, 3);
#print "1AAA: set_direct_index: $actfld, $actidx, $input\n";
    $result = param_value_return($actfld, \$fld);
#print "2AAA: set_direct_index: $fld, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actidx, \$idx);
#print "3AAA: set_direct_index: $idx, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actlvl, \$lvl);
#print "3AAA: set_direct_index: $idx, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print "4AAA: set_direct_index: $fld, $idx, $clitoxmldb1_ptr_level\n";
	$current_instance_indices_level=$lvl;
	$current_instance_indices{instance}[$current_instance_indices_level]{index}=$idx;
    $direct_index_from_keyword{$fld}{index} = $idx;
    $direct_index_from_keyword{$fld}{level} = $clitoxmldb1_ptr_level;
    $direct_index_from_keyword_level[$clitoxmldb1_ptr_level]{$fld} = $fld;
    return $result;
}

sub update_signature_index_with_sigid
{
    my $input = $_[0];
    my $actfld;
    my $fld;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld) = split(/$nodeparamconnector/, $input, 1);
    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld, \$fld);
#print "sigid1: $actfld, $fld, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
#print "sigid2: return\n";
        return $result;
    }
        $glb_sigIdMap_curr_level{$actfld} = $fld;
#print "sigid3: $sigIdMap[$glb_sigIdMap_curr_level{$actfld}], $glb_sigIdMap_curr_level{$actfld}\n";
    if(!defined $sigIdMap[$glb_sigIdMap_curr_level{$actfld}]) {
#print "sigid4: return\n";
        return $result;
    }
    $direct_index_from_keyword{$fld}{index} = $glb_sigIdMap_curr_level{$actfld};
    $direct_index_from_keyword{$fld}{level} = $clitoxmldb1_ptr_level;
    $direct_index_from_keyword_level[$clitoxmldb1_ptr_level]{$fld} = $fld;
    $result = update_cli_tree_with_value($sigIdMap[$glb_sigIdMap_curr_level{$actfld}], 0, 0);
    return $result;
}

sub update_keyword_index_with_map_and_keyword
{
    my $input = $_[0];
    my $actfld;
    my $actstr;
    my $actclistr;
    my $actmap;
    my $fld;
    my $clistr;
    my $val;
    my $map;
    my $string;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actstr, $actmap, $actclistr) = split(/$nodeparamconnector/, $input, 4);
    add_hole_in_cli_tree_buffer();
# print "update_keyword_index_with_map1 $actfld, $actstr, $actmap, $input\n";
    $result = param_value_return($actfld, \$fld);
# print "update_keyword_index_with_map2 $fld, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actstr, \$string);
# print "update_keyword_index_with_map3 $string, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actmap, \$map);
# print "update_keyword_index_with_map4 $actmap, $map, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actclistr, \$clistr);
# print "update_keyword_index_with_map4 $actmap, $map, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = get_value_from_string($map, $string, \$val);
# print "update_keyword_index_with_map5 $map, $string, $val, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print "update_keyword_index_with_map1 $fld, $val, $string, $map\n";
    $direct_index_from_keyword{$fld}{index} = $val;
    $direct_index_from_keyword{$fld}{level} = $clitoxmldb1_ptr_level;
    $direct_index_from_keyword_level[$clitoxmldb1_ptr_level]{$fld} = $fld;
    $result = update_cli_tree_with_value($clistr, 0, 0);
    return $result;
}

sub update_reverse_index_with_map
{
    my $input = $_[0];
    my $actfld;
    my $actmap;
    my $fld;
    my $map;
    my $string;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actmap) = split(/$nodeparamconnector/, $input, 3);
    add_hole_in_cli_tree_buffer();
# print "update_reverse_index_with_map $actfld, $actmap, $input\n";
    $result = param_value_return($actfld, \$fld);
# print "update_reverse_index_with_map2 $fld, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actmap, \$map);
# print "update_reverse_index_with_map4 $actmap, $map, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = get_string_from_value($map, $fld, \$string);
# print "update_reverse_index_with_map5 $map, $string, $val, $result\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
# print "update_reverse_index_with_map1 $fld, $string, $map\n";
    $result = update_cli_tree_with_value($string,0 ,0);
    return $result;
}

sub update_reverse_last_array_multiple_instances
{
    my $actfld = $_[0];
    my $fld;
    my $result = $NOOP_CLI_RETURN_OPTION;

    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld, \$fld);
#print "update_reverse_last_array_multiple_instances $actfld $fld $result, $clitoxmldb1_ptr_level\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = update_cli_tree_with_value($fld, $actfld, 1);
    return $result;
}

sub update_reverse_last_array_multiple_instances_with_map
{
    my $input = $_[0];
    my $actfld;
    my $actmap;
    my $fld;
    my $map;
    my $string;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actmap) = split(/$nodeparamconnector/, $input, 2);
    add_hole_in_cli_tree_buffer();
#print "update_reverse_last_array_multiple_instances_with_map1 $actfld, $actmap\n";
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actmap, \$map);
    if ($result != $PARAM_UPDATE_SUCCESS) {
    }
    $result = get_string_from_value($map, $fld, \$string);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print "update_reverse_last_array_multiple_instances_with_map2 $fld, $map, $string\n";
    $result = update_cli_tree_with_value($string, $actfld, 1);
    return $result;
}

sub update_reverse_clinode_with_multiple_instances
{
    my $input = $_[0];
    my $actfldmulticountry;
    my $actfldcount;
    my $actseperator_val;
    my $fldmulticountry;
    my $fldcount;
    my $seperator_val;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfldcount, $actfldmulticountry) = split(/$nodeparamconnector/, $input, 2);
    add_hole_in_cli_tree_buffer();
    $glb_flag_arrayall = 1;
    $glb_flag_arrayall_action = 1;
    $result = param_value_return($actfldmulticountry, \$fldmulticountry);
    $glb_flag_arrayall = 0;
    if ($result != $PARAM_UPDATE_SUCCESS) {
        $glb_flag_arrayall_action = 0;
        return $result;
    }
    $result = param_value_return($actfldcount, \$fldcount);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        $glb_flag_arrayall_action = 0;
        return $result;
    }
    $result = update_cli_tree_with_value($fldcount, $actfldcount, 1);
    $glb_flag_arrayall_action = 0;
    $glb_country_array_count = 0;
    return $result;
}


#Action added to check for quarantine vlan name check.
sub update_reverse_intf_create_check
{
    my $input = $_[0];
    my $actfld;
    my $actval;
    my $fld;
    my $val;
    my $result = $NOOP_CLI_RETURN_OPTION;
    add_hole_in_cli_tree_buffer();

    ($actfld, $actval) = split(/$nodeparamconnector/, $input, 2);
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    if (get_value_from_xml_dbase($actval, \$val)) {
    }

    if (defined($val)) {
         $qvlanintf = $qvlan_name . $val;
         if (($fld ne $mgmtintf && $fld ne $servintf && $fld ne $virtualintf && $fld ne $apmgrintf && $fld ne $qvlanintf) || ($fld eq $apmgrintf && $dynamicAPMgr eq "1")) {
             $result = update_cli_tree_with_value($fld, $actfld, 1);
         } else {
             $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
         }
    } else {
         if (($fld ne $mgmtintf && $fld ne $servintf && $fld ne $virtualintf && $fld ne $apmgrintf ) || ($fld eq $apmgrintf && $dynamicAPMgr eq "1")) {
             $result = update_cli_tree_with_value($fld, $actfld, 1);
         } else {
             $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
         }
    }
    return $result;
}

sub update_intf_vlan_check
{
    my $actfld = $_[0];
    my $fld;
    my $result = $NOOP_CLI_RETURN_OPTION;

    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print "update_reverse_intf_create_check2 $fld\n";
    if (($fld ne $mgmtintf && $fld ne $servintf && $fld ne $virtualintf && $fld ne $apmgrintf) || ($fld eq $apmgrintf && $dynamicAPMgr eq "1")) {
        $result = update_cli_tree_with_value($fld, $actfld, 1);
    }
    return $result;
}
sub update_intf_vlan_mgmt
{
    my $actfld = $_[0];
    my $fld;
    my $result = $NOOP_CLI_RETURN_OPTION;

    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    if ($fld eq $mgmtintf ) {
#print "update_intf_vlan_mgmt $fld , $actfld\n";
        $result = update_cli_tree_with_value($fld, $actfld, 1);
    } else {
        $result = $STRVALMAP_NO_VALUE_FOUND;
    }
    return $result;
}
sub update_intf_vlan_apmgr
{
    my $actfld = $_[0];
    my $fld;
    my $result = $NOOP_CLI_RETURN_OPTION;

    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print "update_intf_vlan_apmgr $fld\n";
    if (($fld eq $apmgrintf) && ($fld eq $apmgrintf && $dynamicAPMgr ne "1")) {
#print "update_intf_vlan_apmgr $fld , $actfld\n";
        $result = update_cli_tree_with_value($fld, $actfld, 1);
    } else {
        $result = $STRVALMAP_NO_VALUE_FOUND;
    }
    return $result;
}

sub check_service_port_supported
{
    my $actfld = $_[0];
    my $fld;
    my $result = $NOOP_CLI_RETURN_OPTION;

    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print "check_service_port_supported fld: $fld, actfld: $actfld, servintf: $servintf, servicePortSupp: $servicePortSupp\n";
    if (($fld eq $servintf) && ($servicePortSupp eq "1")) {
#print "check_service_port_supported2: fld: $fld, actfld: $actfld, servintf: $servintf, servicePortSupp: $servicePortSupp\n";
        $result = update_cli_tree_with_value($fld, $actfld, 1);
    } else {
        $result = $STRVALMAP_NO_VALUE_FOUND;
    }
    return $result;
}

sub update_reverse_profile_name_check
{
    my $actfld = $_[0];
    my $fld;
    my $result = $NOOP_CLI_RETURN_OPTION;

    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print "update_reverse_profile_check $fld $string\n";
    if ($fld ne $default_prfname) {
        $result = update_cli_tree_with_value($fld, $actfld, 1);
    } else {
        $result = $STRVALMAP_NO_VALUE_FOUND;
    }
    return $result;
}
#Action added to get keyword value based on two conditions.
#Condition combining to be added later. Right now default is 1.
sub update_reverse_with_two_condition
{
    my $input = $_[0];
    my $actfld1;
    my $actfld2;
    my $actvalue1;
    my $actvalue2;
    my $actupdfld1;
    my $actupdfld2;
    my $actopr1;
    my $actopr2;
    my $actcombcond;
    my $value1;
    my $value2;
    my $fld1;
    my $fld2;
    my $updfld1;
    my $updfld2;
    my $opr1;
    my $opr2;
    my $combcond;
    my $tmp_str;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld1, $actvalue1, $actupdfld1, $actopr1, $actfld2, $actvalue2, $actupdfld2, $actopr2, $actcombcond) = split(/$nodeparamconnector/, $input, 9);
    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld1, \$fld1);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actvalue1, \$value1);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actupdfld1, \$updfld1);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actopr1, \$opr1);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    if ($gbl_flag_two_cond) {
        $updfld1 = "";
        $gbl_flag_two_cond = 0;
    }

#print "update_reverse_with_two_condition $fld1, $value1,$updfld1\n";
    if ($opr1 == $grt_op ) {
        if ($fld1 > $val1) {
            $tmp_str = $updfld1;
        }
    } elsif ($opr1 == $eq_op) {
        if ($fld1 == $value1) {
            $gbl_flag_two_cond = 1;
            $tmp_str = $updfld1;
        }
    } elsif ($opr1 == $less_op) {
        if ($fld1 < $val1) {
            $tmp_str = $updfld1;
        }
    } else {
        print "Wrong operator entered it should be 1=greater than 2= equal 3 =less than. .\n";
        die;
    }

    $result = param_value_return($actfld2, \$fld2);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actvalue2, \$value2);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actupdfld2, \$updfld2);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actopr2, \$opr2);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $result = param_value_return($actcombcond, \$combcond);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    if ($opr2 == $grt_op ) {
        if ($fld2 > $val2) {
            $tmp_str = $updfld2;
        }
    } elsif ($opr2 == $eq_op) {
        if ($fld2 == $value2) {
            $tmp_str = $updfld2;
        }
    } elsif ($opr2 == $less_op) {
        if ($fld2 < $val2) {
            $tmp_str = $updfld2;
        }
    } else {
        print "Wrong operator entered it should be 1=greater than 2= equal 3 =less than. .\n";
        die;
    }

#print "update_reverse_with_two_condition2 $fld2, $value2,$updfld2\n";
    $result = update_cli_tree_with_value($tmp_str, $actfld1, 1);
    return $result;
}

# ddParameters a, b, c, d, e, f, g, h, i
# Function does the following:  
# Let first four parameters form function A, and the next four form another function b.
# Parameters to A: a, b, c, op1
# Based on op1, check whether conditions on 
#
#
#
 
sub update_reverse_with_two_condition_both
{
    my $input = $_[0];
    my $actfld1;
    my $actfld2;
    my $actvalue1;
    my $actvalue2;
    my $actupdfld1;
    my $actupdfld2;
    my $actopr1;
    my $actopr2;
    my $actcombcond;
    my $value1;
    my $value2;
    my $fld1;
    my $fld2 = 0;
    my $updfld1;
    my $updfld2;
    my $opr1;
    my $opr2;
    my $combcond;
    my $tmp_str;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $tmpFlag1=0;
    my $tmpFlag2=0;

    ($actfld1, $actvalue1, $actupdfld1, $actopr1, $actfld2, $actvalue2, $actupdfld2, $actopr2, $actcombcond) = split(/$nodeparamconnector/, $input, 9);
    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld1, \$fld1);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actvalue1, \$value1);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actupdfld1, \$updfld1);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actopr1, \$opr1);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }


    if ($opr1 == $grt_op ) {
        if ($fld1 > $value1) {
            $tmp_str = $updfld1;
            $tmpFlag1 = 1;
        }
    } elsif ($opr1 == $eq_op) {
        if ($fld1 eq "") {
            $tmp_str = $updfld1;
            $tmpFlag1 = 1;
        }
    } elsif ($opr1 == $less_op) {
#print"update_reverse_with_two_condition_both: opr is less than, $fld1, $value1\n";
        if ($fld1 < $value1) {

            $tmp_str = $updfld1;
            $tmpFlag1 = 1;
        }
    } else {
        print "Wrong operator entered it should be 1=greater than 2= equal 3 =less than. .\n";
        die;
    }

    if (get_value_from_xml_dbase($actfld2, \$fld2)) {
    }
    $result = param_value_return($actvalue2, \$value2);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actupdfld2, \$updfld2);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actopr2, \$opr2);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $result = param_value_return($actcombcond, \$combcond);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print"update_reverse_with_two_condition_both: $combcond, $opr2\n";
    if ($opr2 == $grt_op ) {
        if ($fld2 > $value2) {
            $tmp_str = $updfld2;
            $tmpFlag2 = 1;
        }
    } elsif ($opr2 == $eq_op) {
#print"update_reverse_with_two_condition_both: opr2 is equal to, $fld2, $value2\n";
        if ($fld2 eq $value2) {
            $tmp_str = $updfld2;
            $tmpFlag2 = 1;
        }
    } elsif ($opr2 == $less_op) {
        if ($fld2 < $value2) {
            $tmp_str = $updfld2;
            $tmpFlag2 = 1;
        }
    } elsif ($opr2 == $neq_op) {
        if ($fld2 ne $value2) {
            $tmp_str = $updfld2;
            $tmpFlag2 = 1;
        }
    } else {
        print "Wrong operator entered it should be 1=greater than 2= equal 3 =less than. .\n";
        die;
    }

    if ($combcond == 1) {
        $result = update_cli_tree_with_value($tmp_str, $actfld1, 1);
        return $result;
    } elsif ($combcond == 2) {
        if (($tmpFlag1 == 1) && ($tmpFlag2 == 1)) {
            $result = update_cli_tree_with_value($tmp_str, $actfld1, 1);
            return $result;
        }
    } elsif ($combcond == 3) {
#print"update_reverse_with_two_condition_both: $tmpFlag1, $tmpFlag2\n";
        if (($tmpFlag1 == 1) && ($tmpFlag2 == 1)) {
            $result = $NO_INSTANCE_FOUND;
        } elsif ($tmpFlag1 == 1) {
            $result = update_cli_tree_with_value($fld1, $actfld1, 1);
            return $result;
        }
    }
}


#Action added for wlan ms-open url.
sub update_reverse_wlan_url
{
    my $input = $_[0];
    my $actfld1;
    my $actvalue1;
    my $actupdfld1;
    my $actopr1;
    my $actcombcond;
    my $value1;
    my $fld1;
    my $updfld1;
    my $opr1;
    my $combcond;
    my $tmp_str;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $tmpFlag1=0;

    ($actfld1, $actvalue1, $actupdfld1, $actopr1) = split(/$nodeparamconnector/, $input, 4);

    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld1, \$fld1);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actvalue1, \$value1);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actupdfld1, \$updfld1);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actopr1, \$opr1);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    if ($opr1 == $less_op) {
        if ($fld1 < $value1) {
            $tmp_str = $updfld1;
            $tmpFlag1 = 1;
        }
    } else {
        print "reverse_update_wlan_url Wrong operator entered it should be 3 =less than. .\n";
        die;
    }

    if ($tmpFlag1 == 1) {
        $result = update_cli_tree_with_value($fld1, $actfld1, 1);
        return $result;
    }
}




#Action added for servicetype check for netuser.
sub update_reverse_check
{
    my $input = $_[0];
    my $actfld;
    my $actvalue;
    my $fld;
    my $actupdfld;
    my $updfld;
    my $value;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actvalue,$actupdfld) = split(/$nodeparamconnector/, $input, 3);
    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actvalue, \$value);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actupdfld, \$updfld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    if ($fld ne $value) {
        $result = $NO_INSTANCE_FOUND;
    } else {
        $result = update_cli_tree_with_value($updfld, $actupdfld, 1);

    }
#print "update_reverse_check $fld $value $result\n";
    return $result;
}

sub update_reverse_with_string
{
    my $input = $_[0];
    my $actfld;
    my $actstring;
    my $fld;
    my $string;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actstring) = split(/$nodeparamconnector/, $input, 2);
    add_hole_in_cli_tree_buffer();
# print "update_reverse_with_string1 $actfld, $actstring\n";
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actstring, \$string);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
# print "update_reverse_with_string2 $fld, $string\n";
    if ($fld eq $string) {
# print "update_reverse_with_string3 $fld, $string, $clitoxmldb1_ptr_level\n";
        $result = update_cli_tree_with_value($string, $actfld, 1);
    } else {
# print "update_reverse_with_string4 $fld, $string, $clitoxmldb1_ptr_level\n";
        $result = $STRVALMAP_NO_VALUE_FOUND;
    }
    return $result;
}

sub update_reverse_with_map_with_direct_index
{
    my $input = $_[0];
    my $actfld, $actfld2;
    my $actval;
    my $actmap;
    my $fld, $fld2;
    my $map;
    my $val;
    my $string;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $tmp, $tmpindex, $tmplevel;

    ($actfld, $actmap, $actfld2, $actval) = split(/$nodeparamconnector/, $input, 4);
    add_hole_in_cli_tree_buffer();
#print "update_reverse_with_map1 $actfld, $actmap, $actfld2, $actval\n";

    $result = param_value_return($actmap, \$map);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actfld2, \$fld2);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $direct_index_from_keyword{$fld2}{index} = $val;
    $direct_index_from_keyword{$fld2}{level} = $clitoxmldb1_ptr_level;
    $direct_index_from_keyword_level[$clitoxmldb1_ptr_level]{$fld2} = $fld2;

    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $result = get_string_from_value($map, $fld, \$string);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print "update_reverse_with_map2 $fld, $map, $fld2, $val, $string\n";

    $result = update_cli_tree_with_value($string, 0, 0);

    return $result;
}

sub update_reverse_with_map
{
    my $input = $_[0];
    my $actfld;
    my $actmap;
    my $fld;
    my $map;
    my $string;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actmap) = split(/$nodeparamconnector/, $input, 2);
    add_hole_in_cli_tree_buffer();
#print "update_reverse_with_map1 $actfld, $actmap\n";
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actmap, \$map);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = get_string_from_value($map, $fld, \$string);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print "update_reverse_with_map2 $fld, $map, $string\n";
    $result = update_cli_tree_with_value($string, 0, 0);
    return $result;
}

sub update_reverse_for_telnet
{
    my $input = $_[0];
    my $actfld;
    my $actmap;
    my $fld;
    my $actupdfld;
    my $updfld;
    my $map;
    my $string;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actmap, $actupdfld) = split(/$nodeparamconnector/, $input, 3);
    add_hole_in_cli_tree_buffer();
# print "update_reverse_with_map1 $actfld, $actmap\n";
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actmap, \$map);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actupdfld, \$updfld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = get_string_from_value($map, $fld, \$string);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

# print "update_reverse_for_telnet $fld, $map, $updfld\n";
    $result = update_cli_tree_with_value($updfld, $actupdfld, 1);
    return $result;
}

sub update_reverse_value_from_bitarray
{

}

sub update_reverse_divide
{
    my $input = $_[0];
    my $fld;
    my $val;
    my $result = $NOOP_CLI_RETURN_OPTION;

    my ($actfld, $actval) = split(/\,/, $input, 2);
    add_hole_in_cli_tree_buffer();
# print "update_reverse $actfld\n";
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $fld /= $val;
    $result = update_cli_tree_with_value($fld, $actfld, 1);
    return $result;

}

sub add_delete_node
{
    return  $NOOP_CLI_RETURN_OPTION;
}

sub asciitohex
{
    return  $NOOP_CLI_RETURN_OPTION;
}

sub increment
{
    return  $NOOP_CLI_RETURN_OPTION;
}

sub mobilityOui_action
{
    return  $NOOP_CLI_RETURN_OPTION;
}

sub multiply
{
    return  $NOOP_CLI_RETURN_OPTION;
}

sub searchIndexField
{
    return  $NOOP_CLI_RETURN_OPTION;
}

sub stringlen
{
    return  $NOOP_CLI_RETURN_OPTION;
}

sub update
{
    return  $NOOP_CLI_RETURN_OPTION;
}

sub update_hex_for_node
{
    return  $NOOP_CLI_RETURN_OPTION;
}

sub update_with_node
{
    return  $NOOP_CLI_RETURN_OPTION;
}

sub updatebit
{
    return  $NOOP_CLI_RETURN_OPTION;
}

sub updatebit_with_index
{
    return  $NOOP_CLI_RETURN_OPTION;
}

sub updatebitposition
{
    return  $NOOP_CLI_RETURN_OPTION;
}

sub updatewithmap
{
    return  $NOOP_CLI_RETURN_OPTION;
}

sub append_ignored_config
{
    my $input = $_[0];
    if ($input != $show_invalid_config) {
        return;
    }
    if (-f "$ignored_flash_clifile") {
        system("cat $ignored_flash_clifile >> $clifile"); 
    }
}

sub populate_array
{
    my $max = $hash7{$max_formats};
    for (my $i =0; $i<= $max; $i++) {
        for (my $j =0; $j<= $max; $j++) {
            if ($i == $j) {
                $format_conv_arr[$i][$j] = \&no_format_conversion;
            } else {
                $format_conv_arr[$i][$j] = \&format_conversion_illegal;
            }
        }
    }
    $format_conv_arr[$hash7{byte_TYPE}][$hash7{string_TYPE}] = \&BYTE_to_STRING;
    $format_conv_arr[$hash7{unsignedByte_TYPE}][$hash7{string_TYPE}] = \&BYTE_to_STRING;
    $format_conv_arr[$hash7{int_TYPE}][$hash7{IPv4addr_TYPE}] =  \&INT_to_IP;
    $format_conv_arr[$hash7{unsignedInt_TYPE}][$hash7{IPv4addr_TYPE}] =  \&INT_to_IP;
    $format_conv_arr[$hash7{HEXstring_TYPE}][$hash7{IPv4addr_TYPE}] =  \&HEX_to_STRING;
    $format_conv_arr[$hash7{HEXstring_TYPE}][$hash7{string_TYPE}] =  \&HEX_to_STRING;
    $format_conv_arr[$hash7{byte_TYPE}][$hash7{MACaddr_TYPE}] = \&BYTE_to_MAC;
    $format_conv_arr[$hash7{int_TYPE}][$hash7{string_TYPE}] = \&INT_to_STRING;
    $format_conv_arr[$hash7{unsignedInt_TYPE}][$hash7{string_TYPE}] = \&INT_to_STRING;
    $format_conv_arr[$hash7{short_TYPE}][$hash7{string_TYPE}] = \&INT_to_STRING;
    $format_conv_arr[$hash7{unsignedShort_TYPE}][$hash7{string_TYPE}] = \&INT_to_STRING;
    $format_conv_arr[$hash7{long_TYPE}][$hash7{string_TYPE}] = \&INT_to_STRING;
    $format_conv_arr[$hash7{unsignedLong_TYPE}][$hash7{string_TYPE}] = \&INT_to_STRING;
    $format_conv_arr[$hash7{IPv4addr_TYPE}][$hash7{string_TYPE}] = \&IP_to_STRING;
    $format_conv_arr[$hash7{MACaddr_TYPE}][$hash7{string_TYPE}] = \&MAC_to_STRING;
    $format_conv_arr[$hash7{HEXstring_TYPE}][$hash7{MACaddr_TYPE}] =  \&HEX_to_MAC;
}

sub no_format_conversion
{
    return $PARAM_UPDATE_SUCCESS;
}

sub format_conversion_illegal
{
    return $ILLEGAL_CONVERSION_OPTION;
}

sub INT_to_STRING
{
    my $value= $_[0];
    my $local_decimal = $_[1];
    my $array_flag = $_[2];
#   my $arr_flag = $_[2];
 #  if ($arr_flag == 0) {
       my $result =  check_for_digits($value);
       if ($result != $PARAM_UPDATE_SUCCESS) {
           print "Value $value does not contains digit,Wrong value \n";
           return $result;
       }
       $$local_decimal = $value;
#print "INT_to_STRING $value $$local_decimal\n";
  #  }
    return $PARAM_UPDATE_SUCCESS;
}

sub BYTE_to_STRING
{
    my $value = $_[0];
    my $local_str = $_[1];
    my $array_flag = $_[2];
    my $str;
    my $local_hex;
    
    if ($array_flag == 1) {
        $clitoxmldb1_ptr_level_prev_byte_array = $clitoxmldb1_ptr_level;
        $flag_for_byte_string_cli_check = 0;
        $local_hex = convert_decimal_to_hex_string($value);
        $str = hex_to_string_local($local_hex);
        if ($current_instance_indices{instance}[$current_instance_indices_level]{index} == 0) {
            $global_string_for_byte = "";
        }
#print "BYTE_to_STRING3 $value, $local_hex, $str, $global_string_for_byte\n";
        if ($value == 0) {
            $flag_for_byte_end_check = 1;
            return $PARAM_UPDATE_SUCCESS;
        }
        $global_string_for_byte = $global_string_for_byte . $str; 
#print "BYTE_to_STRING1 $value $local_hex $str $global_string_for_byte\n";
    } else {
        $$local_str = $value;
    }
#print "BYTE_to_STRING2 $value $$local_str\n";
    return $PARAM_UPDATE_SUCCESS;
}

sub INT_to_IP
{
    my $value= $_[0];
    my $local_str = $_[1];
    my $array_flag = $_[2];

    my @indvd_int;
# print "INT_to_IP1 $value $length\n";
    my $hexstring = convert_decimal_to_hex_string($value);
    my $length = length($hexstring);
    if ($length == 7) {
        $hexstring = '0' . $hexstring;
    }
    my @hex_indvd = $hexstring =~ /\w{2}/g;
    for(my $i=0; $i <= $#hex_indvd; $i++) {
        $indvd_int[$i] = convert_hex_to_decimal_without_header($hex_indvd[$i]);
    }
    $$local_str = join ('.', @indvd_int);
# print "INT_to_IP2 $value $$local_str\n";
    return $PARAM_UPDATE_SUCCESS;
}

sub HEX_to_STRING
{
    my $value= $_[0];
    my $local_str = $_[1];
    my $array_flag = $_[2];
    ## Convert each two-digit hex number back to an ASCII character.
    $value =~ s/([a-fA-F0-9]{2})/chr(hex $1)/eg;
#    (my $value = shift) =~ s/([a-fA-F0-9]{2})/chr(hex $1)/eg;
    my @temp = split(/\0/, $value, 2);
    $$local_str = $temp[0];
#print "HEX_to_STRING $value $$local_str\n";
    return $PARAM_UPDATE_SUCCESS;
}

sub HEX_to_MAC
{
    my $value= $_[0];
    my $local_str = $_[1];
    my $array_flag = $_[2];
    my @val_tmp;
    my $j = 0;
    HEX_to_STRING($value, $local_str, $array_flag);
    my @temp = split(//,$$local_str);
    for(my $i=0; $i<=11; $i++) {
        $val_tmp[$j]= $temp[$i];
        $j += 1;
        if(($i%2 == 1)&&($i != 11)) {
            $val_tmp[$j]= ':';
            $j += 1;
        }
    }
    $$local_str = join('',@val_tmp);
    return $PARAM_UPDATE_SUCCESS;
}

sub IP_to_STRING
{
    my $value= $_[0];
    my $local_decimal = $_[1];
    my $array_flag = $_[2];
    $$local_decimal = $value;
    return $PARAM_UPDATE_SUCCESS;
}

sub MAC_to_STRING
{
    my $value= $_[0];
    my $local_decimal = $_[1];
    my $array_flag = $_[2];
    $$local_decimal = $value;
    return $PARAM_UPDATE_SUCCESS;
}

sub BYTE_to_MAC
{
    my $value= $_[0];
    my $local_decimal = $_[1];
    my $array_flag = $_[2];
    my $index;
    
    if ($array_flag == 1) {
        $clitoxmldb1_ptr_level_prev_byte_array = $clitoxmldb1_ptr_level;
        $local_hex = convert_decimal_to_hex_string($value);
        $index = $current_instance_indices{instance}[$current_instance_indices_level]{index};
        if ($flag_for_byte_mac_cli_check) {
            $global_string_for_byte = "";
            for (my $i = 0; $i < $index; $i++) {
                $global_string_for_byte = $global_string_for_byte .":". "00";
            }
            $global_string_for_byte = $global_string_for_byte .":". $local_hex;
            $prev_global_mac_instance_index = $index;
        } else {
            for (my $i = ($prev_global_mac_instance_index + 1); $i < $index; $i++) {
                $global_string_for_byte = $global_string_for_byte .":". "00";
            }
            $global_string_for_byte = $global_string_for_byte .":". $local_hex;
            $prev_global_mac_instance_index = $index;
        }
        $flag_for_byte_mac_cli_check = 0;
     } else {
        $$local_str = $value;
     }
#print "BYTE_to_MAC $value $$local_str\n";
    return $PARAM_UPDATE_SUCCESS;
}

sub check_for_digits
{
    my $val = $_[0];

    if (($val =~ /\D/) && ($val !~ /^\-/)) {
        return $VALUE_HAS_NON_DIGIT_CHARS;
    }
    return $PARAM_UPDATE_SUCCESS;
}
sub hex_to_string_local
{
    ## Convert each two-digit hex number back to an ASCII character.
#    $value =~ s/([a-fA-F0-9]{2})/chr(hex $1)/eg;
    (my $value = shift) =~ s/([a-fA-F0-9]{2})/chr(hex $1)/eg;
    return $value;
}

sub convert_decimal_to_hex_string
{
    my $value = $_[0];
    my $temp1 = 1;
    my $temp2 = 0;
    my $hexstring = "";
    while ($temp1) {
        $temp1 = $value / 16;
        $temp1 = int($temp1);
        $temp2 = $value % 16;
        $hexstring = $decimal_to_hex_string_array[$temp2] . $hexstring;
        $value = $temp1;
    }
#print "convert_decimal_to_hex_string1 $hexstring\n";
    return ($hexstring);
}

sub convert_hex_to_decimal_without_header
{
    my ($str) = @_;
    my $decimal;
    if ($str =~ /x/) {
       ($hex_header, $str) = split('x', $str);
    }
    my @temp1 = split(//, $str);
    for (my $i = 0; $i <= $#temp1; $i++) {
        if ($temp1[$i] eq 'a' || $temp1[$i] eq 'A') {
            $temp1[$i] = 10;
        } elsif ($temp1[$i] eq 'b' || $temp1[$i] eq 'B') {
            $temp1[$i] = 11;
        } elsif ($temp1[$i] eq 'c' || $temp1[$i] eq 'C') {
            $temp1[$i] = 12;
        } elsif ($temp1[$i] eq 'd' || $temp1[$i] eq 'D') {
            $temp1[$i] = 13;
        } elsif ($temp1[$i] eq 'e' || $temp1[$i] eq 'E') {
            $temp1[$i] = 14;
        } elsif ($temp1[$i] eq 'f' || $temp1[$i] eq 'F') {
            $temp1[$i] = 15;
        }
        $decimal = $decimal * 16 + $temp1[$i];
    }
#print "convert_hex_to_decimal_without_header Input $str $decimal\n";
    return($decimal);
}

sub get_field_digit_dot
{
    my $temp = $_[0];
    my ($action, $fld_digit_dot) = split(/\./, $temp, 2);
    return $fld_digit_dot;

}

sub update_reverse_constant
{
    my $input = $_[0];
    my $actfld;
    my $fld;
    my $actconstantval;
    my $constantval;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actconstantval) = split(/$nodeparamconnector/, $input, 2);
# print "update_reverse1 $actfld\n";
    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actconstantval, \$constantval);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print "update_reverse2 $actfld, $fld\n";
    $result = update_cli_tree_with_value($constantval, $actfld, 1);
    return $result;
}


#Action added to upload acl direction by checking bitmask and value of direction. 
sub update_reverse_acl_direction_specific
{
    my $input = $_[0];
    my $actfld;
    my $actsupportfld;
    my $actmask;
    my $actmap;
    my $actval;
    my $fld;
    my $supportfld;
    my $mask;
    my $map;
    my $val;
    my $string;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actsupportfld, $actmask, $actmap, $actval) = split(/$nodeparamconnector/, $input, 5);

    add_hole_in_cli_tree_buffer();
    if (get_value_from_xml_dbase($actfld, \$fld)) {
    }
    if (get_value_from_xml_dbase($actsupportfld, \$supportfld)) {
    }
    $result = param_value_return($actmask, \$mask);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actmap, \$map);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    if(defined($fld)) {
        $result = get_string_from_value($map, $fld, \$string);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        $result = update_cli_tree_with_value($string, 0, 0);
    } else {
        if (($supportfld & $mask) == 0) {
            $result = update_cli_tree_with_value($val, $actfld, 1);
        } else {
            return $NO_INSTANCE_FOUND;
        }
    }
    return $result;
}

#Action added to check that index mapping for 802.11a and 802.11b specifically.
sub update_reverse_keyword_index_with_map_conditionally
{
    my $input = $_[0];
    my $actfld;
    my $actstr;
    my $actmap;
    my $actfldupd;
    my $actmapupd;
    my $fld;
    my $string;
    my $map;
    my $fldupd;
    my $mapupd;
    my $stringupd;
    my $val;

    my $result = $NOOP_CLI_RETURN_OPTION;
#print "update_reverse_keyword_index_with_map_conditionally ,,$input \n";

    ($actfld, $actstr, $actmap, $actfldupd, $actmapupd) = split(/$nodeparamconnector/, $input, 5);
    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld, \$fld);
#print "update_reverse_keyword_index_with_map_conditionally1 $fld, $actfld, $result \n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actstr, \$string);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actmap, \$map);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = get_value_from_string($map, $string, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print "update_reverse_keyword_index_with_map_conditionally2 $fld, $string, $val\n";

    $result = param_value_return($actfldupd, \$fldupd);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print "update_reverse_keyword_index_with_map_conditionally3 $fldupd, $actfldupd, \n";
    $result = param_value_return($actmapupd, \$mapupd);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = get_string_from_value($mapupd, $fldupd, \$stringupd);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

#print "update_reverse_keyword_index_with_map_conditionally4 $fldupd, $val, $stringupd, $mapupd\n";
    if($fld == $val) {
#print "update_reverse_keyword_index_with_map_conditionally5 $fldupd, $stringupd, $mapupd\n";
        $result = update_cli_tree_with_value($stringupd, 0, 0);
        return $result;
    } else {
        return $NO_INSTANCE_FOUND;
    }
}

#Action added to update passwd if secret obfuscation is disabled 
sub update_reverse_passwd_conditionally
{
    my $input = $_[0];
    my $actfld;
    my $fld;
    my $actval2;
    my $val2;
    my $val1;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actval2) = split(/$nodeparamconnector/, $input, 2);
    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actval2, \$val2);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print "update_reverse_passwd_conditionally1 $val2, $actfld, $fld\n";
    if(!(get_value_from_xml_dbase($actfld, \$val1))){
#print "not defined update_reverse_passwd_conditionally val1=$val1,val2=$val2\n";
        $val1 = $val2;
    }
#print "update_reverse_passwd_conditionally2 $val1, $actfld\n";
    $result = update_cli_tree_with_value($val1, $actfld, 1);
    return $result;
}

#Action added to update passwd with map if secret obfuscation is disabled 
sub update_reverse_passwd_conditionally_with_map
{
    my $input = $_[0];
    my $actfld;
    my $fld;
    my $actval2;
    my $val2;
    my $actmap;
    my $map;
    my $val1;
    my $temp_input;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actval2, $actmap) = split(/$nodeparamconnector/, $input, 3);
    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actval2, \$val2);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actmap, \$map);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print "update_reverse_passwd_conditionallymap $val2, $actfld, $map\n";
    if(!(get_value_from_xml_dbase($actfld, \$val1))){
#print "not defined update_reverse_passwd_conditionallymap val1=$val1,val2=$val2\n";
        $val1 = $val2;
        $result = update_cli_tree_with_value($val1, $actfld, 1);
    } else {
#print " defined update_reverse_passwd_conditionallymap val1=$val1,val2=$val2\n";
        $temp_input = $actfld."$nodeparamconnector". $actmap;
        $result =  update_reverse_with_map($temp_input);
    }
    return $result;
}

sub get_value_from_xml_dbase
{
    my $fld = $_[0];
    my $pval = $_[1];
    my $xmlref = \%digit_to_tag_actual;
    my $str;
    my $level = 0;

    my @temp = split(/\./, $fld);
    for (my $i = 1; $i <= $#temp; $i++) {
        if (defined($$xmlref{nxt}{$temp[$i]})) {
            $xmlref = \%{$$xmlref{nxt}{$temp[$i]}};
            if (defined($$xmlref{instance})) {
                if (!defined($current_instance_indices{instance}[$current_instance_indices_level]{index})) {
                    return 0;
                } elsif (defined($$xmlref{instance}{$current_instance_indices{instance}[$level+1]{index}})) {
                    $xmlref = \%{$$xmlref{instance}{$current_instance_indices{instance}[$level+1]{index}}};
#print "get_value_from_xml_dbase1 $current_instance_indices_level, $current_instance_indices{instance}[$current_instance_indices_level]{index}, $current_instance_indices{instance}[$level+1]{index}, $level\n";
                 
                } else {
                    return 0;
                }
                $level += 1;
            }
        } else {
            #print "Xml2Cli: Am failing here: 294\n";
            return 0;
        }
    }
    $$pval = $$xmlref{val};
    return 1;
}

sub get_dim_if_instance_present
{
    my $fld = $_[0];
    my $xmlref = \%digit_to_tag_actual;
    my $level = 0;

    my @temp = split(/\./, $fld);
#print "get_dim_if_instance_present: $fld, @temp\n";
    for (my $i = 0; $i <= $#temp; $i++) {
#print "i: $i, $temp[$i], $$xmlref{nxt}{$temp[$i]}\n";
        if (defined($$xmlref{nxt}{$temp[$i]})) {
            $xmlref = \%{$$xmlref{nxt}{$temp[$i]}};
            if (defined($$xmlref{instance})) {
                $xmlref = \%{$$xmlref{instance}{$current_instance_indices{instance}[$level+1]{index}}};
                $level += 1;
#print "LEVEL: $level\n";
            }
        } else {
            return -1;
        }
    }

#print "Level before returning: $level\n";

    return $level;
}

sub update_reverse_compare_byte
{

    my $input = $_[0];
    my $actfld;
    my $actbitmask;
    my $actstring;
    my $fld;
    my $bitmask;
    my $string;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actbitmask, $actstring) = split(/$nodeparamconnector/, $input, 3);
    add_hole_in_cli_tree_buffer();

    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actbitmask, \$bitmask);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actstring, \$string);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

#print "update_reverse_compare_byte1 $fld, $bitmask, $string\n";
    if ($fld & $bitmask) {
#print "update_reverse_compare_byte2 $string\n";
        $result = update_cli_tree_with_value($string, $actfld, 1);
    } else {
        $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
    }
    return $result;
}

#Action added to upload acl protocol/dscp by checking bitmask and value of respective fields. 
sub update_reverse_with_two_condition_using_bitmask
{
    my $input = $_[0];
    my $actfld;
    my $actsupportfld;
    my $actmask;
    my $actval;
    my $fld;
    my $supportfld;
    my $mask;
    my $val;
    my $string;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actsupportfld, $actmask, $actval) = split(/$nodeparamconnector/, $input, 4);

    add_hole_in_cli_tree_buffer();
    if (get_value_from_xml_dbase($actfld, \$fld)) {
    }
    if (get_value_from_xml_dbase($actsupportfld, \$supportfld)) {
    }
    $result = param_value_return($actmask, \$mask);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    if(defined($fld)) {
        $result = update_cli_tree_with_value($fld, $actfld, 1);
    } else {
        if (($supportfld & $mask) == 0) {
            $result = update_cli_tree_with_value($val, $actfld, 1);
        } else {
            return $NO_INSTANCE_FOUND;
        }
    }
    return $result;
}
#Action added specially when double maps is used for bit set/reset e.g. ckip kp,mmh enable.
sub update_reverse_bit_with_double_map
{
    my $input = $_[0];
    my $actfld;
    my $actbitmask;
    my $actmap;
    my $actremap;
    my $fld;
    my $bitmask;
    my $map;
    my $remap;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $string;
    my $act_val;

    ($actfld, $actbitmask, $actmap, $actremap) = split(/$nodeparamconnector/, $input, 4);
    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actbitmask, \$bitmask);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $result = param_value_return($actmap, \$map);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actremap, \$remap);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $result = get_string_from_value($remap, $fld, \$act_val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    if ($act_val & $bitmask) {
        $result = get_string_from_value($map, 1, \$string);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        $result = update_cli_tree_with_value($string, $actfld, 1);
    } else {
        $result = get_string_from_value($map, 0, \$string);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        $result = update_cli_tree_with_value($string, $actfld, 1);
    }
    return $result;
}

#Action added to upload a default field with map based on some other field is present.
sub  update_reverse_with_map_default_ifextrafield_present
{
    my $input = $_[0];
    my $actfld;
    my $actsupportfld;
    my $actval;
    my $actmap;
    my $map;
    my $fld;
    my $supportfld;
    my $val;
    my $string;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actsupportfld, $actval, $actmap) = split(/$nodeparamconnector/, $input, 4);

    add_hole_in_cli_tree_buffer();
    if (get_value_from_xml_dbase($actfld, \$fld)) {
    }
    $result = param_value_return($actsupportfld, \$supportfld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actmap, \$map);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    if(defined($fld)) {
        $result = get_string_from_value($map, $fld, \$string);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        $result = update_cli_tree_with_value($string, 0, 0);
    } else {
        if (defined($supportfld)) {
            $result = update_cli_tree_with_value($val, $actfld, 1);
        } else {
            return $NO_INSTANCE_FOUND;
        }
    }
    return $result;
}

#Action added specially to check for quarantine vlan name check for management interface.
sub update_reverse_intf_create_check_qvlan
{
    my $input = $_[0];
    my $actfld;
    my $actval;
    my $fld;
    my $val;
    my $result = $NOOP_CLI_RETURN_OPTION;
    add_hole_in_cli_tree_buffer();

    ($actfld, $actval) = split(/$nodeparamconnector/, $input, 2);
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    if (($fld ne $servintf && $fld ne $virtualintf && $fld ne $apmgrintf ) || ($fld eq $apmgrintf && $dynamicAPMgr eq "1")) {
        $result = update_cli_tree_with_value($fld, $actfld, 1);
    } else {
        $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
    }
    return $result;
}

#Action added to upload a default field with map based on index.
sub  update_reverse_with_map_default_based_on_index
{
    my $input = $_[0];
    my $actfld;
    my $actsupportfld;
    my $actcmpval;
    my $actval1;
    my $actval2;
    my $actmap;
    my $fld;
    my $supportfld;
    my $cmpval;
    my $val1;
    my $val2;
    my $map;
    my $string;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actsupportfld, $actcmpval, $actval1, $actval2, $actmap) = split(/$nodeparamconnector/, $input, 6);

    add_hole_in_cli_tree_buffer();
    if (get_value_from_xml_dbase($actfld, \$fld)) {
    }
    $result = param_value_return($actsupportfld, \$supportfld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actcmpval, \$cmpval);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actval1, \$val1);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actval2, \$val2);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actmap, \$map);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    if(defined($fld)) {
        $result = get_string_from_value($map, $fld, \$string);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
#print "update_reverse_with_map_default_based_on_index $fld,  $string \n";
        $result = update_cli_tree_with_value($string, 0, 0);
    } else {
        if (defined($supportfld)) {
            if($supportfld == $cmpval) {
#print "update_reverse_with_map_default_based_on_index $supportfld,  $cmpval \n";
                $result = update_cli_tree_with_value($val1, $actfld, 1);
#print "update_reverse_with_map_default_based_on_index $val1\n";
            } else {
                $result = update_cli_tree_with_value($val2, $actfld, 1);
#print "update_reverse_with_map_default_based_on_index $val2\n";
            }
        } else {
            return $NO_INSTANCE_FOUND;
        }
    }
    return $result;
}

sub update_reverse_string_for_nonzero
{
    my $input = $_[0];
    my $actfld;
    my $actstring;
    my $fld;
    my $string;
    my $actval;
    my $val;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actstring) = split(/$nodeparamconnector/, $input, 2);
    add_hole_in_cli_tree_buffer();
# print "update_reverse_with_string1 $actfld, $actstring\n";
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actstring, \$string);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    if($fld != 0) {
        $result = update_cli_tree_with_value($string, $actfld, 1);
    } else {
        $result = $STRVALMAP_NO_VALUE_FOUND;
    }
    return $result;
}


# upload given keyword if require bit is reset for index of an array
sub update_reverse_value_with_reset_bit_and_index
{
    my $input = $_[0];
    my $actfld;
    my $actbitmask;
    my $actval;
    my $actindexval;
    my $indexval;
    my $actindexfld;
    my $indexfld;
    my $fld;
    my $bitmask;
    my $val;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $string;

    ($actfld, $actbitmask, $actval, $actindexfld, $actindexval) = split(/$nodeparamconnector/, $input, 5);
    add_hole_in_cli_tree_buffer();
# print "checkBit1 $actfld, $actbitmask, $actval, $input\n";
    $result = param_value_return($actbitmask, \$bitmask);
# print "checkBit5 $actfld, $actbitmask, $actval, $input, $bitmask\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
# print "checkBit4 $result, $actfld, $fld\n";
    $result = param_value_return($actfld, \$fld);
# print "checkBit3 $result, $actfld, $fld\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actindexfld, \$indexfld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actindexval, \$indexval);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
# print "checkBit2 $bitmask, $fld, $val\n";
    if (($fld ^ $bitmask) & $bitmask) {
        if($indexfld == $indexval) {
            $result = update_cli_tree_with_value($val, $actfld, 1);
        } else {
            return $NO_INSTANCE_FOUND;
        }
    }
    return $result;
}

# upload given keyword if require bit is set for index of an array
sub update_reverse_value_with_bit_and_index
{
    my $input = $_[0];
    my $actfld;
    my $actbitmask;
    my $actval;
    my $actindexval;
    my $indexval;
    my $actindexfld;
    my $indexfld;
    my $fld;
    my $bitmask;
    my $val;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $string;

    ($actfld, $actbitmask, $actval, $actindexfld, $actindexval) = split(/$nodeparamconnector/, $input, 5);
    add_hole_in_cli_tree_buffer();
# print "checkBit1 $actfld, $actbitmask, $actval, $input\n";
    $result = param_value_return($actbitmask, \$bitmask);
# print "checkBit5 $actfld, $actbitmask, $actval, $input, $bitmask\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
# print "checkBit4 $result, $actfld, $fld\n";
    $result = param_value_return($actfld, \$fld);
# print "checkBit3 $result, $actfld, $fld\n";
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actindexfld, \$indexfld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actindexval, \$indexval);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
# print "checkBit2 $bitmask, $fld, $val\n";
    if ($fld & $bitmask) {
        if($indexfld == $indexval) {
            $result = update_cli_tree_with_value($val, $actfld, 1);
        } else {
            return $NO_INSTANCE_FOUND;
        }
    }
    return $result;
}

#Action added to upload a default field with map based on index.
sub  update_reverse_with_map_default_based_on_index
{
    my $input = $_[0];
    my $actfld;
    my $actsupportfld;
    my $actcmpval;
    my $actval1;
    my $actval2;
    my $actmap;
    my $fld;
    my $supportfld;
    my $cmpval;
    my $val1;
    my $val2;
    my $map;
    my $string;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actsupportfld, $actcmpval, $actval1, $actval2, $actmap) = split(/$nodeparamconnector/, $input, 6);

    add_hole_in_cli_tree_buffer();
    if (get_value_from_xml_dbase($actfld, \$fld)) {
    }
    $result = param_value_return($actsupportfld, \$supportfld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actcmpval, \$cmpval);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actval1, \$val1);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actval2, \$val2);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actmap, \$map);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    if(defined($fld)) {
        $result = get_string_from_value($map, $fld, \$string);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
#print "update_reverse_with_map_default_based_on_index $fld,  $string \n";
        $result = update_cli_tree_with_value($string, 0, 0);
    } else {
        if (defined($supportfld)) {
            if($supportfld == $cmpval) {
#print "update_reverse_with_map_default_based_on_index $supportfld,  $cmpval \n";
                $result = update_cli_tree_with_value($val1, $actfld, 1);
#print "update_reverse_with_map_default_based_on_index $val1\n";
            } else {
                $result = update_cli_tree_with_value($val2, $actfld, 1);
#print "update_reverse_with_map_default_based_on_index $val2\n";
            }
        } else {
            return $NO_INSTANCE_FOUND;
        }
    }
    return $result;
}

sub update_reverse_add_colon
{
    my $input = $_[0];
    my $actfld;
    my $fld;
    my $i, $j =0;
    my @val_tmp;
    my $result = $NOOP_CLI_RETURN_OPTION;

    my $actfld = $input;

    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    my @temp = split(//,$fld);
    for(my $i=0; $i<=$#temp; $i++) {
        $val_tmp[$j]= $temp[$i];
        $j += 1;
        if(($i%2 == 1)&&($i != $#temp)) {
            $val_tmp[$j]= ':';
            $j += 1;
        }
    }
    $fld = join('',@val_tmp);
    $result = update_cli_tree_with_value($fld, $actfld, 1);
    return $result;
}

sub fieldtransition_read
{
    my $input = $_[0];
    my $href;
    my @tmp = split(/\t/, $input, 7);
    my @temp = split(/\./, $tmp[0]);
    my $partialcli = "";
    $href = \%clitoxmldb1;
#print"\n";
    for (my $i = 0; $i <= $#temp; $i++) {
        if (!defined($$href{cnt}) || !defined($$href{array}{$temp[$i]})) {
            die "cli2xmldb3 does not have cnt or keyword $temp[$i] for $tmp[0], $i\n";
        }
        if($i != 0) {
            $partialcli .= "." . $temp[$i];
        } else {
            $partialcli = $temp[$i];
        }
#print "fieldtranstion_read1 $href, $temp[$i], $tmp[0], $tmp[1], $tmp[2], $tmp[3], $tmp[4], $tmp[5], $tmp[6]\n";
        if ($i == $tmp[4]) {
#print "fieldtranstion_read2 GOT $href, $i, $tmp[4],$temp[$i], $partialcli\n";
            $$href{array}{$temp[$i]}{transition}{dim} = $tmp[1];
            $$href{array}{$temp[$i]}{transition}{maxdim} = $tmp[2];
            $$href{array}{$temp[$i]}{transition}{maxdd} = $tmp[3];
            $$href{array}{$temp[$i]}{transition}{bkwd} = $tmp[5];
            $$href{array}{$temp[$i]}{transition}{fwd} = $tmp[6];
            my @local_arr_bkwd = split('$nodekewordvalend', $tmp[5]);
            my @local_arr_fwd = split('$nodekewordvalend', $tmp[6]);
            for(my $i = $tmp[1]; $i <= $#local_arr_bkwd; $i++) {
                $shift_bkwd_arr{$partialcli}{$i} = $local_arr_bkwd[$i]; 
                $shift_fwd_arr{$partialcli}{$i} = $local_arr_fwd[$i]; 
            }
            return;
        }
        $href = \%{$$href{array}{$temp[$i]}{nxt}};
    }
}

sub shift_fwd
{
    #my $fwd_cli = $$href{array}{$index}{transition}{fwd};
    if (defined($fwd_arr)) {
        if (defined($direct_index_from_keyword{$partialtag})) {
            $clitoxmldb1_index[$clitoxmldb1_ptr_level] = $direct_index_from_keyword{$partialtag}{index};
        } else {
            $clitoxmldb1_index[$clitoxmldb1_ptr_level] = $running_dim_array[$running_dimension]{index};
        }
    }
}

sub shift_bkwd
{
    my $href =  $_[0];
    my $index =  $_[1];
    my $prevdd; 
    my $prevdim; 
    my $curdd ;
    my $temp_dim;
    my $var;
    my $partialtag_tmp;

    my $curmaxdd = $$href{array}{$index}{transition}{maxdd};
    my $transition_dim = $$href{array}{$index}{transition}{dim};
    my $bkwd_cli = $$href{array}{$index}{transition}{bkwd};
    my $fwd_cli = $$href{array}{$index}{transition}{fwd};
    my $maxdim = $$href{array}{$index}{transition}{maxdim};
#print"CHECK:$href, $index, $curmaxdd, $prevdd,$curdd,..transdim $transition_dim transition_di...$bkwd_cli,bkwd_cl....$fwd_cli,fwd_cl......$maxdim, $running_dimension\n";
      
    
    #my @local_arr_bkwd = split('$nodekewordvalend', $bkwd_cli);
    
    my @local_arr_bkwd;
    if($running_dimension>$transition_dim) {
        @local_arr_bkwd = split('\%', $bkwd_cli);
    } else {
        $local_arr_bkwd[0] = $bkwd_cli;
    }
    #my @local_arr_fwd = split('$nodekewordvalend', $fwd_cli);
    my @local_arr_fwd = split('\%', $fwd_cli);
    my @bkwd_info = split('\#',$local_arr_bkwd[$running_dimension-$transition_dim]);
#    if (!(!defined($bkwd_info[0]) && $running_dimension == 1 && $transition_dim == 1)) {
        if (get_maxdd_for_transitioned_cli($bkwd_info[0], $bkwd_info[1], \$prevdd, \$prevdim) == 0) {
#print "$bkwd_cli, $running_dimension, $transition_dim\n";
#print "Maximum dimension digit dot for $bkwd_info[0] and $bkwd_info[1], @$local_arr_bkwd could not be found\n";
#            die;
        }
#    } else {
#        print "SHOULD NOT COME HERE NO PREVDD\n";
#       die;
#    }

    for (my $i = $running_dimension; $i >= 0; $i--) {
        $current_instance_indices{instance}[$i]{arridx}++;
#print "BEFORE check_and_set_if_inst_present_at_dim $prevdd, $curmaxdd, $i, $current_instance_indices{instance}[$i]{arridx}\n";
        if(defined($prevdd) && check_and_set_if_inst_present_at_dim($prevdd, $i, \$partialtag_tmp)) {
#print "SHIFT BACK install_cli :$local_arr_bkwd[$i-$transition_dim], $bkwd_cli, $i, $transition_dim\n";
            my @bkwd_info1 = split('\#',$local_arr_bkwd[$i-$transition_dim]);
#print "SHIFT BACK1 install_cli :$bkwd_info1[0], $bkwd_info1[1], $i, $transition_dim\n";
            install_cli($bkwd_info1[0], $bkwd_info1[1]);
            $running_dimension = $prevdim;
            $current_instance_indices_level = $i;
#print "running_dimension33333 $running_dimension\n";
#print "EEE: current_instance_indices_level: $current_instance_indices_level\n";
            $shifted_backward = 1;
            return;
        } else {
            if ($i > 0) {
                $current_instance_indices{instance}[$i]{arridx} = $starting_index;
#print "FFF: current_instance_indices_level: $current_instance_indices_level\n";
            }
            if ($i == $transition_dim) {#get transition dim for curr CLI;
#print"i==transition_dim $transition_dim, $maxdim, $starting_index, $curmaxdd, $current_instance_indices{instance}[$maxdim]{arridx}\n";
               $gbl_maxdd = $curmaxdd;
               if($transition_dim == 0 && $maxdim > 0) {
                   $temp_dim = 1;
               } else {
                   $temp_dim = $transition_dim;
               }
               if($temp_dim <= $maxdim) {
                   for (my $j = $temp_dim; $j <= $maxdim ; $j++) {
                       if($j > 0) {
                           $current_instance_indices{instance}[$j]{arridx} = $starting_index;
                           check_and_set_if_inst_present_at_dim($curmaxdd, $j, \$partialtag_tmp);
#print "shift_bkwd1 $temp_dim, $j, $maxdim, $partialtag_tmp, $direct_index_from_keyword{$partialtag_tmp}\n";
                           if (defined($direct_index_from_keyword{$partialtag_tmp})) {
                               $current_instance_indices{instance}[$j]{index} = $direct_index_from_keyword{$partialtag_tmp}{index};
                           }
                           $current_instance_indices_level = $j;
#print "GGG: current_instance_indices_level: $current_instance_indices_level\n";
                       }
                       #$running_dim_array[$i]{index} = $starting_index;
#                       if(!(check_and_set_if_inst_present_at_dim($curmaxdd, $j, \$partialtag_tmp))) {
#print"else shift_fwd1 !check_if_inst_present_at_dim $transition_dim, $maxdim, $j\n";
#                           $running_dimension = $j;
#print "running_dimension44444 $running_dimension\n";
#                           #shift_fwd();
#                           return;
#                       }
                       $running_dimension = $j;
#print "shift_bkwd5 $running_dimension\n";
                   }
               } else {
                   $current_instance_indices_level = $maxdim;
#print "HHH: current_instance_indices_level: $current_instance_indices_level\n";
                   if(!(check_and_set_if_inst_present_at_dim($curmaxdd, $maxdim, \$partialtag_tmp))) {
#print"else shift_fwd2 !check_if_inst_present_at_dim $transition_dim, $maxdim, $i, $current_instance_indices{instance}[$maxdim]{arridx}\n";
                       $running_dimension = $maxdim;
#print "running_dimension55555 $running_dimension\n";
                       #shift_fwd();
                       return;
                   }
                   $running_dimension = $maxdim;
#print "running_dimension66666 $running_dimension\n";
#print "shift_bkwd6 $running_dimension\n";
               }
#print "Continue with Transit CLI, install_cli, $current_instance_indices{instance}[$running_dimension]{arridx}\n";
               return;
            }
            if ($i >0) {
               $current_instance_indices{instance}[$i]{arridx}=$starting_index;
               $running_dimension = $i - 1;
#print "running_dimension77777 $running_dimension\n";
               if($running_dimension == 0) {
                   return;
               }            
#print "shift_bkwd11 $running_dimension\n";
            }else {
               $running_dimension = 0;
#print "running_dimension88888 $running_dimension\n";
#print "shift_bkwd12 $running_dimension\n";
            }
        }
    }#End of for
}

sub install_cli
{
    my $cli = $_[0];
    my $currlevel = $_[1];
    my @temp;
    my $href;
    @clitoxmldb1_index = split('\.', $cli);
    
    $glb_cli_to_install_curr_level = $currlevel; 
    $glb_cli_to_install_last_level = $#clitoxmldb1_index; 
    $glb_cli_to_install_use_flag = 1; 
    for (my $i = 0; $i <= $#clitoxmldb1_index; $i++) {
        $glb_cli_to_install[$i] = $clitoxmldb1_index[$i];    
    } 
#print"install_cli1 $cli\n";
    $clitoxmldb1_ptr_level = $currlevel;
    $href = \%clitoxmldb1;
    $clitoxmldb1_ptr[0] = $href;
    for (my $i = 0; $i <= $clitoxmldb1_ptr_level; $i++) {
        if ($i < $#clitoxmldb1_index) {
            $href = \%{$$href{array}{$clitoxmldb1_index[$i]}{nxt}};
        }
#print"install_cli2 $i, $clitoxmldb1_index[$i]\n";
        $clitoxmldb1_ptr[$i+1] = $href;
        #$clitoxmldb1_ptr_level = $currlevel;
    }
}

sub get_maxdd_for_transitioned_cli
{
    my $cli = $_[0];
    my $currlevel = $_[1];
    my $pmaxdd = $_[2];
    my $pmaxdim = $_[3];
    my @temp;
    my $href;
    my @ind = split('\.', $cli);
    my $flag = 0;
    
#    $glb_cli_to_install_curr_level = $currlevel; 
#    $glb_cli_to_install_last_level = $#clitoxmldb1_index; 
#    $glb_cli_to_install_use_flag = 1; 
#    for (my $i = 0; $i <= $#index; $i++) {
#        $glb_cli_to_install[$i] = $clitoxmldb1_index[$i];    
#    } 
#print"get_maxdd_for_transitioned_cli1 $cli\n";
#    $clitoxmldb1_ptr_level = $currlevel;
    $href = \%clitoxmldb1;
#    $clitoxmldb1_ptr[0] = $href;
    for (my $i = 0; $i <= $#ind; $i++) {
        if (defined($$href{array}{$ind[$i]}{transition})) {
            $$pmaxdd = $$href{array}{$ind[$i]}{transition}{maxdd};
            $$pmaxdim = $$href{array}{$ind[$i]}{transition}{maxdim};
#print "get_maxdd_for_transitioned_cli3 $$pmaxdd, $$pmaxdim\n";
            $flag = 1;
        }
       # if ($i != $#ind) {
       #     $href = \%{$$href{array}{$ind[$i]}{nxt}};
       # }

        if (defined($$href{array}{$ind[$i]}{nxt})) {
            $href = \%{$$href{array}{$ind[$i]}{nxt}};
        } else {
            if ($i != $#ind) {
                print "get_maxdd_for_transitioned_cli This should not happen\n";
            }
            return $flag;
        }

#print"get_maxdd_for_transitioned_cli2 $i, $ind[$i]\n";
#        $clitoxmldb1_ptr[$i+1] = $href;
        #$clitoxmldb1_ptr_level = $currlevel;
    }
    return $flag;
}

sub check_if_field_present_at_instance
{
    my $fld = $_[0];
    my $pval = $_[1];
    my $dimflag = $_[2];
    my $xmlref = \%digit_to_tag_actual;
    my $str;
    my $level = 0;
    my $temp_runndim = 0;
#print "check_if_field_present_at_instance0 $fld, $pval, $current_instance_indices_level\n";
    my @temp = split(/\./, $fld);
    for (my $i = 0; $i <= $#temp; $i++) {
        if($i == 0) {
            $partialtag_tmp = $temp[$i];
        } else {
            $partialtag_tmp .= "." . $temp[$i];
        }
#print "check_if_field_present_at_instance3 $xmlref, $i, $temp[$i], $fld\n";
        if (defined($$xmlref{nxt}{$temp[$i]})) {
            $xmlref = \%{$$xmlref{nxt}{$temp[$i]}};
            if (defined($$xmlref{instance})) {
                if((!defined($$xmlref{array}[$current_instance_indices{instance}[$level+1]{arridx}]))) {
#print"check_if_field_present_at_instance00 NOT FOUND ARRIDX, $current_instance_indices{instance}[$level+1]{arridx}, $i, $#temp, $level\n";
                    return 0;
                } else {
                    $temp_runndim += 1;
#print "check_if_field_present_at_instance11 $partialtag_tmp, $current_instance_indices{instance}[$level+1]{arridx}, $level\n";
                    if (defined($direct_index_from_keyword{$partialtag_tmp}{index})) {
#print "Found Direct: $direct_index_from_keyword{$partialtag_tmp}{index}\n";
                        $current_instance_indices{instance}[$level+1]{index} = $direct_index_from_keyword{$partialtag_tmp}{index};
                    } else {
                        delete($direct_index_from_keyword{$partialtag_tmp});
                        $current_instance_indices{instance}[$level+1]{index} = $$xmlref{array}[$current_instance_indices{instance}[$level+1]{arridx}];
#print "check_if_field_present_at_instance12 $partialtag_tmp, $current_instance_indices{instance}[$level+1]{index}, $level\n";
                    }
                    $xmlref = \%{$$xmlref{instance}{$current_instance_indices{instance}[$level+1]{index}}};
                }
                $level += 1;
            }
        } else {
#print "check_if_field_present_at_instance2 $fld, $temp[$i], $i, $current_instance_indices_level, $level, $current_instance_indices{instance}[$level]{index}, $current_instance_indices{instance}[$level]{arridx}\n";
            return 0;
        }
    }
    $$pval = $$xmlref{val};
    if ($dimflag == 1) {
        $current_instance_indices_level = $temp_runndim;
#print "KKK : current_instance_indices_level : $current_instance_indices_level\n";
    }
#print "99999 $running_dimension $fld\n";
#print "check_if_field_present_at_instance22 $fld $$pval\n";
    return 1;
}

sub check_if_inst_present_at_dim
{
    my $prevdd = $_[0];
    my $dim = $_[1];
    my $xmlref = \%digit_to_tag_actual;
    my $level = 0;
    my @temp = split(/\./, $prevdd);
   if ($prevdd == 0) {
#print"check_if_inst_present_at_dim null prevdd, \n";
      return 0;
   }
#print"check_if_inst_present_at_dim $prevdd, $dim\n";
    for (my $i = 0; $i <= $#temp; $i++) {
        if (defined($$xmlref{nxt}{$temp[$i]})) {
            $xmlref = \%{$$xmlref{nxt}{$temp[$i]}};
            if (defined($$xmlref{instance})) {
                if(!defined($$xmlref{array}[$current_instance_indices{instance}[$level+1]{instance}])) {
                    return 0;
                } else {
#print "check_if_inst_present_at_dim11 $current_instance_indices{instance}[$level+1]{index}, $level, $dim\n";
                    $dim--;
                    $xmlref = \%{$$xmlref{instance}{$current_instance_indices{instance}[$level+1]{index}}};
                    if($dim == 0) {
#print "$$$$$$ GOT Instance\n";
                        return 1;
                    }
                }
                $level += 1;
            }
        } else {
#print "check_if_inst_present_at_dim12 $prevdd, $i, $temp[$i]\n";
            return 0;
        }
    }
    return 0;
}

sub check_and_set_if_inst_present_at_dim
{
    my $prevdd = $_[0];
    my $dim = $_[1];
    my $xmlref = \%digit_to_tag_actual;
    my $level = 0;
    my @temp = split(/\./, $prevdd);
    my $partialtag_tmp = $_[2];
   if ($prevdd == 0) {
#print"check_and_set_if_inst_present_at_dim1 null prevdd, \n";
      return 0;
   }
#print"check_and_set_if_inst_present_at_dim2 $prevdd, $dim\n";
    for (my $i = 0; $i <= $#temp; $i++) {
        if($i == 0) {
            $$partialtag_tmp = $temp[$i];
        } else {
            $$partialtag_tmp .= "." . $temp[$i];
        }
        if (defined($$xmlref{nxt}{$temp[$i]})) {
            $xmlref = \%{$$xmlref{nxt}{$temp[$i]}};
            if (defined($$xmlref{instance})) {
# This is added for safety in case if dim contains 0 and instance is present
# for data structure field return 1 indicating for 0th dimension field instance
# is found
                if ($dim == 0) {
                    return 1;
                }
                if(!defined($$xmlref{array}[$current_instance_indices{instance}[$level+1]{arridx}])) {
#print"check_and_set_if_inst_present_at_dim3 NOT FOUND ARRIDX, $current_instance_indices{instance}[$level+1]{arridx}, $level\n";
                    return 0;
                } else {
                    if (defined($direct_index_from_keyword{$$partialtag_tmp})) {
                        if ($dim == 1) {
                            return 0;
                        } else {
                            $current_instance_indices{instance}[$level+1]{index} = $direct_index_from_keyword{$$partialtag_tmp}{index};
                        }
                    } else {
                        $current_instance_indices{instance}[$level+1]{index} = $$xmlref{array}[$current_instance_indices{instance}[$level+1]{arridx}];
                    }
#print "check_if_inst_present_at_dim11 $current_instance_indices{instance}[$level+1]{arridx}, $current_instance_indices{instance}[$level+1]{index}, $level, $dim\n";
                    $dim--;
                    $xmlref = \%{$$xmlref{instance}{$current_instance_indices{instance}[$level+1]{index}}};
                    if($dim == 0) {
#print "$$$$$$ GOT Instance, \n";
                        return 1;
                    }
                }
                $level += 1;
            }
        } else {
#print "check_if_inst_present_at_dim12 $prevdd, $i, $temp[$i]\n";
            return 0;
        }
    }
#print"check_and_set_if_inst_present_at_dim4\n";
    return 0;
}

sub generate_cli_from_xml_for_transition
{
    my $partialcli =  "";
    my $partialclilevel = 0;
    my $href;
    my $count;
    my $index;
    my $tagref;
    my $arrindex;
    my $level;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my @nextjumpcliarr;
    my $temp_dim;
    $clitoxmldb1_ptr[$clitoxmldb1_ptr_level] = \%clitoxmldb1;
    $href = $clitoxmldb1_ptr[$clitoxmldb1_ptr_level];
    $count = $$href{cnt};
    $clitoxmldb1_index[$clitoxmldb1_ptr_level] = 1;

    my $prevmaxdd;
    my $curmaxdd;
    my $currdd;
    my $transition_dim;
    my $bkwd_cli ;
    my $fwd_cli ;
    my $maxdim = 0;
    my $pmaxdim = 0;
    my $prevdd = "1.1.1.1.1";
    my $partialtag_tmp;
    my $date = localtime;
    
    #Add #begin and #end at the begning and end of the file
    #argv[0]=1 is for getting invalid config
    if($ARGV[0] != 1)
    { 
    	print CLIFILE "# WLC Config Begin <$date>\n";
        # read meta data info from /mnt/application/meta_data.txt
        if(open (META_FILE, '/mnt/application/meta_data.txt')) {
            while (<META_FILE>) { 
                chomp; print CLIFILE "! $_\n"; 
            } 
            close (META_FILE);
        }
    	print CLIFILE "\n";
    }
NEXTITER:
    while ($clitoxmldb1_index[0] <= $count) {
        $index = $clitoxmldb1_index[$clitoxmldb1_ptr_level];
        $href = $clitoxmldb1_ptr[$clitoxmldb1_ptr_level];
#print "ISSUE: $$href{array}, $$href{array}{$index}, $clitoxmldb1_ptr_level, $index\n";
        if (!defined($$href{array}) || !defined($$href{array}{$index})) {
            if ($clitoxmldb1_ptr_level > 0) {
                delete($clitoxmldb1_optional_instances{instance}[$clitoxmldb1_ptr_level]{optional});
                $clitoxmldb1_ptr_level -= 1;
            }
            $level = $clitoxmldb1_ptr_level;
            $clitoxmldb1_index[$clitoxmldb1_ptr_level] += 1;
            $shifted_backward = 0;
            $glb_cli_to_install_use_flag = 0;
#print "\n\nNEW CCLI STARTED1\n";
            if (defined($clitoxmldb1_optional_instances{instance}[$level]{optional}) && $clitoxmldb1_optional_instances{instance}[$level]{optional} == 1) {
                $clitoxmldb1_optional_instances{instance}[$clitoxmldb1_ptr_level]{optional} = 1;
            }
            next NEXTITER;
        }
#print "BEFORE TRANS href=$href, hrefnext=$$href{array}{$index}{nxt}, $index\n";
#print"TRANSITION2 :$href:transition_dim: $transition_dim, running_dim: $running_dimension, $shifted_backward, $index, maxdim: $maxdim, $pmaxdim \n";
#for (my $j = 0; $j <= $clitoxmldb1_ptr_level; $j++) {
#if($j != 0) {
#$currdd = $currdd . "." . $clitoxmldb1_index[$j];
#} else {
#$currdd = $clitoxmldb1_index[0];
#}
#print "generate_cli_from_xml666 $j : $clitoxmldb1_index[$j], $clitoxmldb1_ptr_level, $currdd\n";
#}
        if (defined($$href{array}{$index}{transition})) {
            $curmaxdd = $$href{array}{$index}{transition}{maxdd};
            $transition_dim = $$href{array}{$index}{transition}{dim};
#print"TRANSITION1 :$href: transition_dim: $transition_dim, running_dim: $running_dimension, $shifted_backward, $index, maxdim: $maxdim, $pmaxdim, $clitoxmldb1_ptr_level, $curmaxdd \n";
#            $pmaxdim = $maxdim;
            $maxdim = $$href{array}{$index}{transition}{maxdim};
#print"TRANSITION :$href:transition_dim: $transition_dim, running_dim: $running_dimension, $shifted_backward, $index, maxdim: $maxdim, $pmaxdim \n";
#for (my $j = 0; $j <= $clitoxmldb1_ptr_level; $j++) {
#if($j != 0) {
#$currdd = $currdd . "." . $clitoxmldb1_index[$j];
#} else {
#$currdd = $clitoxmldb1_index[0];
#}
#print "generate_cli_from_xml6 $j : $clitoxmldb1_index[$j], $clitoxmldb1_ptr_level, $currdd\n";
#}
           
#print "generate_cli_from_xml123 $$href{array}{$index}{transition}{maxdd}\n";
#if (defined($$href{array}{$index}{transition}{bkwd}) && ($$href{array}{$index}{transition}{bkwd} =~ /\#/)) {
#print "generate_cli_from_xml124  $$href{array}{$index}{transition}{bkwd}, $$href{array}{$index}{transition}{maxdd}\n";
#}
#            if(($transition_dim <= $running_dimension) && ($shifted_backward == 0) && (defined($$href{array}{$index}{transition}{bkwd})) && ($$href{array}{$index}{transition}{bkwd} =~ /\#/)) {
            if(($transition_dim <= $running_dimension) && ($shifted_backward == 0)) { 
#print "generate_cli_from_xml16 SHIFT BACK: transition_dim:$transition_dim, running_dim:$running_dimension\n";
                shift_bkwd($href, $index);
#                if ($shifted_backward == 1) {
#                    $maxdim = $pmaxdim;
#                }
#            } elsif(($shifted_backward == 0) && (defined($$href{array}{$index}{transition}{bkwd})) && ($$href{array}{$index}{transition}{bkwd} =~ /\#/)) {
            } elsif($shifted_backward == 0) {
            $running_dimension = $maxdim;
#print "running_dimension11111 $running_dimension\n";
                $gbl_maxdd = $curmaxdd; 
                if($transition_dim == 0 && $maxdim > 0) {
                   $temp_dim = 1;
                } else {
                   $temp_dim = $transition_dim;
                }
#print "generate_cli_from_xml26 $temp_dim, $transition_dim, $maxdim, $curmaxdd\n ";
                for (my $j = $temp_dim; $j <= $maxdim ; $j++) {
                    if($j > 0) {
                        $current_instance_indices{instance}[$j]{arridx} = $starting_index;
                        check_and_set_if_inst_present_at_dim($curmaxdd, $j, \$partialtag_tmp);
#print "generate_cli_from_xml28 continue $temp_dim, $j, $maxdim, $partialtag_tmp, $direct_index_from_keyword{$partialtag_tmp}\n";
                        if (defined($direct_index_from_keyword{$partialtag_tmp})) {
                            $current_instance_indices{instance}[$j]{index} = $direct_index_from_keyword{$partialtag_tmp}{index};
                        }
                        $current_instance_indices_level = $j;
#print "III: current_instance_indices_level: $current_instance_indices_level\n";
                    }
                    #$running_dim_array[$i]{index} = $starting_index;
                    $running_dimension = $j;
#print "running_dimension22222 $running_dimension\n";
#print "generate_cli_from_xml27 $running_dimension, $j, $maxdim, $curmaxdd\n ";
#                   if(!(check_and_set_if_inst_present_at_dim($curmaxdd, $j))) {
#print"else shift_fwd !check_if_inst_present_at_dim $transition_dim, $maxdim, $j\n";
                        #shift_fwd();
                        #return;
#                    }
                }
                $shifted_backward = 0;
                $glb_cli_to_install_use_flag = 0;
            }
        }
        
        $result = database1_execute("config", 1);
        if ($GBL_MAX_CNT == $GBL_CNT) {
            print "##";
            $| = 1;
            $GBL_CNT = 0;
        }
        $index = $clitoxmldb1_index[$clitoxmldb1_ptr_level];
        $href = $clitoxmldb1_ptr[$clitoxmldb1_ptr_level];
#print "generate_cli_from_xml12 $result, $clitoxmldb1_ptr_level, $$href{array}{$index}{nxt}\n";
#for (my $j = 0; $j <= $clitoxmldb1_ptr_level; $j++) {
#if($j != 0) {
#$currdd = $currdd . "." . $clitoxmldb1_index[$j];
#} else {
#$currdd = $clitoxmldb1_index[0];
#}
#print "generate_cli_from_xml121 $j : $clitoxmldb1_index[$j], $clitoxmldb1_ptr_level, $currdd\n";
#}
#Transition Logic
#            foreach($dim) {
#                if(!$node_inst) {
#                    if($dim < $transition_dim) {
#                        print "Error in Transition database....";
#                        die;
#                    }
#                    if($dim < $maxdim) {
#                        $running_dimension = $dim;
#                        shift_fwd;
#                goto start;#add goto
#                    } else {
#                        install_cli($currCLI);
#                    }
#                } else {
#                    if ($dim > $running_dimension) {
#                        $running_dimension = $dim;
#                        $current_instance_indices{instance}[$i]{index} = $starting_index;
#                    } 
#                }
#            }
#########
        if (defined($$href{array}{$index}{nxt}) && ($result != $NO_INSTANCE_FOUND && $result != $NO_MORE_INSTANCES)) {
            $href = \%{$$href{array}{$index}{nxt}};
            $level = $clitoxmldb1_ptr_level;
            $clitoxmldb1_ptr_level += 1;
#print "generate_cli_from_xml51 clitoxmldb1_ptr_level = $clitoxmldb1_ptr_level\n";
            if (defined($clitoxmldb1_optional_instances{instance}[$level]{optional}) && $clitoxmldb1_optional_instances{instance}[$level]{optional} == 1) {
                $clitoxmldb1_optional_instances{instance}[$clitoxmldb1_ptr_level]{optional} = 1;
            }
            $clitoxmldb1_ptr[$clitoxmldb1_ptr_level] = $href;
            if($glb_cli_to_install_use_flag ==  1) {
                $clitoxmldb1_index[$clitoxmldb1_ptr_level] = $glb_cli_to_install[$clitoxmldb1_ptr_level];
                if($glb_cli_to_install_curr_level == $glb_cli_to_install_last_level) {
                    $glb_cli_to_install_use_flag = 0;
                    $shifted_backward = 0;
                }
                $glb_cli_to_install_curr_level = $clitoxmldb1_ptr_level;
            } else {
                $clitoxmldb1_index[$clitoxmldb1_ptr_level] = 1;
            }
#print "\n\nNEW CCLI STARTED3, $glb_cli_to_install_use_flag\n";

#for (my $j = 0; $j <= $clitoxmldb1_ptr_level; $j++) {
#if($j != 0) {
#$currdd = $currdd . "." . $clitoxmldb1_index[$j];
#} else {
#$currdd = $clitoxmldb1_index[0];
#}
#print "generate_cli_from_xml122 $j : $clitoxmldb1_index[$j], $clitoxmldb1_ptr_level, $currdd\n";
#}
        } else {
#print "generate_cli_from_xml10 $result, $clitoxmldb1_ptr_level, $clitoxmldb1_optional_instances{instance}[$clitoxmldb1_ptr_level]{optional}, $href, $$href{array}{$index}{nxt}, $index\n";
            if (((!defined($$href{array}{$index}{nxt}) && $result != $NO_INSTANCE_FOUND) || (defined($clitoxmldb1_optional_instances{instance}[$clitoxmldb1_ptr_level]{optional}) && $result == $NO_INSTANCE_FOUND)) && check_for_no_holes_in_cli_buffer()) {
                if (defined($clitoxmldb1_optional_instances{instance}[$clitoxmldb1_ptr_level]{optional}) && $result == $NO_INSTANCE_FOUND) {
                    if ($current_optional_level_present == 1) {
                        for (my $i = $current_optional_level; $i <= $clitoxmldb1_ptr_level; $i++) {
                            delete($clitoxmldb1_optional_instances{instance}[$i]);
                        }
                        $current_optional_level_present = 0;
                        if ($current_optional_level > 0) {
                            $clitoxmldb1_ptr_level = $current_optional_level - 1;
                        } else {
                            $clitoxmldb1_ptr_level = $current_optional_level;
                        }
                    }
                }
#print "Print CLI in generate_cli_from_xml_for_transition, $clitoxmldb1_optional_instances{instance}[$clitoxmldb1_ptr_level]{optional}, $result\n";

                print_cli();
            } else {
                if ($current_optional_level_present == 1) {
                    for (my $i = $current_optional_level; $i <= $clitoxmldb1_ptr_level; $i++) {
                        delete($clitoxmldb1_optional_instances{instance}[$i]);
                    }
                    $current_optional_level_present = 0;
                    if ($current_optional_level > 0) {
                        $clitoxmldb1_ptr_level = $current_optional_level - 1;
                    } else {
                        $clitoxmldb1_ptr_level = $current_optional_level;
                    }
                }
            }
#print "\n\nNEW CCLI STARTED2\n";
            $clitoxmldb1_index[$clitoxmldb1_ptr_level] += 1;
            $glb_cli_to_install_use_flag = 0;
            $shifted_backward = 0;
        }
    }
    for (my $i = $current_instance_indices_level; $i >= 0; $i--) {
        $tagref = $current_instance_indices{instance}[$i]{tagref};
        $arrindex = $current_instance_indices{instance}[$i]{arridx};
        $arrindex += 1;
#print "generate_cli_from_xml4 $current_instance_indices{instance}[$i]{partialtag}, $current_instance_indices{instance}[$i]{arridx}, $arrindex, $$tagref{array}[$arrindex], $i, $current_instance_indices_level\n";
        if (defined($$tagref{array}[$arrindex])) {
            for (my $j = ($i + 1); $j <= $current_instance_indices_level; $j++) {
                delete($current_instance_indices{instance}[$j]);
            }
            $current_instance_indices_level = $i;
#print "JJJ: current_instance_indices_level: $current_instance_indices_level\n";
            $current_instance_indices{instance}[$i]{arridx} += 1;
#print "generate_cli_from_xml3, $i, $current_instance_indices{instance}[$i]{partialtag}, $current_instance_indices{instance}[$i]{arridx}, $$tagref{array}[$arrindex], $arrindex\n";
            for (my $j = 0; $j <= $current_instance_indices{instance}[$i]{clidblvl}; $j++) {
                $clitoxmldb1_ptr[$j] = $current_instance_indices{instance}[$i]{clidb}[$j]{cliref};
                $clitoxmldb1_index[$j] = $current_instance_indices{instance}[$i]{clidb}[$j]{cliidx};
                if (defined($current_instance_indices{instance}[$i]{clidb}[$j]{clival})) {
                    $clitoxmldb1_instances{instance}[$j]{val} = $current_instance_indices{instance}[$i]{clidb}[$j]{clival};
                }
#print "generate_cli_from_xml5, $j: $clitoxmldb1_index[$j]\n";
            }
            $clitoxmldb1_ptr_level = $current_instance_indices{instance}[$i]{clidblvl};
#print "generate_cli_from_xml5 clitoxmldb1_ptr_level = $clitoxmldb1_ptr_level\n";
            goto NEXTITER;
        }
    }
    if($ARGV[0] != 1)
    { 
    	$date = localtime;
    	print CLIFILE "\n";
    	print CLIFILE "# WLC Config End <$date>";
    } 
    print CLIFILE "\n";
    close(CLIFILE);
}


sub check_invalid_config_tag_and_instance_present
{
    my $tag = $_[0];
    my $digitdot = "";

    my @tmp1 = split(/\./, $tag);

#print "check_invalid_config_tag_and_instance_present1 $tag, $#tmp1\n";
    for (my $i = 0; $i <= $#tmp1; $i++) {
#print "check_invalid_config_tag_and_instance_present6 $i, $#tmp1, $digitdot\n";
        if ($i == 0) {
            $digitdot = $tmp1[$i];
        } else {
            $digitdot = $digitdot . "." . $tmp1[$i];
        }
        if (defined($invalid_config_tag_hash{tag}{$digitdot})) {
#print "check_invalid_config_tag_and_instance_present2 $digitdot, $invalid_config_tag_hash{tag}{$digitdot}\n";
            if (defined($invalid_config_tag_hash{instance}{$digitdot})) {
#print "check_invalid_config_tag_and_instance_present3 $digitdot, $invalid_config_tag_hash{instance}{$digitdot}, $invalid_config_tag_hash{instance}{$digitdot}{count}\n";
                for (my $j = 1; $j <= $invalid_config_tag_hash{instance}{$digitdot}{count}; $j++) {
#print "check_invalid_config_tag_and_instance_present4 $j, $current_instance_indices{instance}[$j]{index}\n";
                    if (!defined($invalid_config_tag_hash{instance}{$digitdot}{array}[($j - 1)]{$current_instance_indices{instance}[$j]{index}})) {
#print "check_invalid_config_tag_and_instance_present5 $digitdot, $j, $current_instance_indices{instance}[$j]{index}\n";
                        return 0;
                    }
                }
            }
            return 1;
        }
    }
    return 0;
}

#Action added to upload a default field with map based on some other field is present.
sub  update_reverse_with_map_default
{
    my $input = $_[0];
    my $actfld;
    my $actval;
    my $actmap;
    my $map;
    my $fld;
    my $val;
    my $string;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actval, $actmap) = split(/$nodeparamconnector/, $input, 3);

    add_hole_in_cli_tree_buffer();
    if (get_value_from_xml_dbase($actfld, \$fld)) {
    }
    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actmap, \$map);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    if(defined($fld)) {
        $result = get_string_from_value($map, $fld, \$string);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        $result = update_cli_tree_with_value($string, 0, 0);
    } else {
#print "1($actfld, $actsupportfld, $actval, $actmap\n";
            $result = update_cli_tree_with_value($val, $actfld, 1);
    }
    return $result;
}

sub ignore_node_conditional_two_fields
{
    my $input = $_[0];
    my $actfld;
    my $actfld2;
    my $fld;
    my $fld2;
    my $comp_val;
    my $comp_val2;
    my $actcomp_val;
    my $actcomp_val2;
    my $actop1;
    my $op1;
    my $actop2;
    my $op2;
    my $actmap;
    my $map;
    my $string;
    my $result = $NOOP_CLI_RETURN_OPTION;
    ($actfld, $actcomp_val, $actop1, $actfld2, $actcomp_val2, $actop2, $actmap) = split(/$nodeparamconnector/, $input, 7);
    if (get_value_from_xml_dbase( $actfld, \$fld)) {
    }
    $result = param_value_return($actcomp_val, \$comp_val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $result = param_value_return($actop1, \$op1);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $result = param_value_return($actfld2, \$fld2);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $result = param_value_return($actcomp_val2, \$comp_val2);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $result = param_value_return($actop2, \$op2);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $result = param_value_return($actmap, \$map);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    if($op1 == 1 && $comp_val eq $fld) {
        if($op2 == 1 && $comp_val2 ne $fld2) {
            return $NO_INSTANCE_FOUND;
        }
    }

    $result = get_string_from_value($map, $fld2, \$string);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $result = update_cli_tree_with_value($string, $actfld2, 1);
    return 1;
}

sub update_reverese_bit_for_sig_state
{
    my $input = $_[0];
    my $actfld;
    my $actid;
    my $actstr;
    my $str;
    my $fld;
    my $sigid;
    my $idx;
    my $bitoffset;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $sigval;

    ($actfld, $actid, $actstr) = split(/$nodeparamconnector/, $input, 3);
    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actid, \$sigid);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actstr, \$str);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $idx         = $sigid / 8;
    $bitoffset   = $sigid % 8;
    my @tmp = split(//, $fld);
    my @sigState;
    my $sigStateInt;
    for(my $i=0, my $j=0; $i <= $#tmp;) {
        $sigState[$j] = $tmp[$i] . $tmp[$i+1];
        $j++;
        $i += 2;
    }
    $sigStateInt = hex($sigState[$idx]);
    if((($sigStateInt >> $bitoffset) & 0x1) == 0x0) {
        $result = update_cli_tree_with_value($str, 0, 0);
    }
    return $result;
}

sub update_reverse_for_session_timeout
{
    my $input = $_[0];
    my $actfld;
    my $actsupportfld;
    my $actval;
    my $secval1;
    my $secval2;
    my $secval3;
    my $fld;
    my $supportfld;
    my $val;
    my $val1;
    my $val2;
    my $val3;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actsupportfld, $actval, $secval1, $secval2, $secval3) = split(/$nodeparamconnector/, $input, 6);

    add_hole_in_cli_tree_buffer();
    if (get_value_from_xml_dbase($actfld, \$fld)) {
    }
    if (get_value_from_xml_dbase($actsupportfld, \$supportfld)) {
    }
    if (get_value_from_xml_dbase($actval, \$val)) {
    }
    $result = param_value_return($secval1, \$val1);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($secval2, \$val2);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($secval3, \$val3);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    if(!defined($supportfld)) {
        $supportfld = 0;
    }
    if(!defined($fld)) {
        $fld = 0;
    }
    if((!($val & $val1)) && ($val & ($val3 | $val2))) {
        $result = update_cli_tree_with_value($fld, $actfld, 1);
    } else {
        $result = update_cli_tree_with_value($supportfld, $actsupportfld, 1);
    }
    return $result;
}

sub initialize_me_platform
{
  my %params = map { $_ => 1 } @me_platform_array;
  $platform_type =~ /-([A-Z0-9]+)-/;
  my $ap_type = $1;
  if(exists($params{$ap_type})) {
        $is_me = 1;
  }
}

sub initialize_szabla_platform
{
    if ($platform_type eq $platform_Szabla) {
        $is_szabla = 1;
    }
}
sub initialize_kukri_platform
{
    if ($platform_type eq $platform_Kukri) {
        $is_kukri = 1;
    }
}

sub initialize_ambassador_platform
{
    if ($platform_type eq $platform_ambassador) {
	    $is_ambassador = 1;
    }
}

sub initialize_saber_platform
{
    if (($platform_type  =~ m/^($platform_saber1)/) || ($platform_type  =~ m/^($platform_saber2)/)) {
	    $is_saber = 1;
    }
}

sub initialize_pata_platform
{
    if ($platform_type  =~ m/^($platform_pata)/) {
	    $is_pata = 1;
    }
}
sub initialize_khanda_platform
{
    if ($platform_type  =~ m/^($platform_khanda)/) {
	    $is_khanda = 1;
    }
}
sub is_node_unsupported_on_platform
{
	if ($is_szabla == 1) {
		return $INVALID_CLI_OPTION;
	}
	return $NOOP_CLI_RETURN_OPTION;
}

#for kukri,abassador,saber,khanda,pata platforms
sub is_node_supported_on_ucs
{
      if ( ($is_ambassador == 1) || ($is_saber == 1) ||
           ($is_pata == 1) || ($is_khanda == 1) || ($is_kukri == 1) ) {
         return $NOOP_CLI_RETURN_OPTION;
      }
      return $INVALID_CLI_OPTION;
}

sub is_node_unsupported_on_platform_vwlc
{
	if ($is_vm == 1) {
		return $INVALID_CLI_OPTION;
	}
	return $NOOP_CLI_RETURN_OPTION;
}
sub is_node_unsupported_on_ambassador_vwlc
{
	if ($is_ambassador ==  1 || $is_vm == 1) {
		return $INVALID_CLI_OPTION;
	}
	return $NOOP_CLI_RETURN_OPTION;
}

sub initialize_vm_platform
{
    if ($platform_type eq $platform_vm) {
        $is_vm = 1;
    }
}
sub is_node_only_on_vm
{
	if ($is_vm == 1) {
		return $NOOP_CLI_RETURN_OPTION;
	}
	return $INVALID_CLI_OPTION;
}

sub check_wlan_id_boundary
{
	my $input = $_[0];
	my $val;

	if ($is_szabla == 1) {
		param_value_return($input, \$val);
		if ($val > $szabla_max_wlan) {
			return $INVALID_CLI_OPTION;
		}
		else {
			return $NOOP_CLI_RETURN_OPTION;
		}
	}
	return $NOOP_CLI_RETURN_OPTION;
}

sub update_reverse_unicast_mode_check_szabla
{
    my $input = $_[0];
    my $actmode;
    my $mode;
    my $result = $NOOP_CLI_RETURN_OPTION;

    if ($is_szabla == 1) {
               return $INVALID_CLI_OPTION;
    }

    ($actmode) = split(/$nodeparamconnector/, $input, 1);

    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actmode, \$mode);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    if ($mode == 0) {
        $result = update_cli_tree_with_value("unicast", $actmode, 1);
    } else {
        $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
    }
    return $result;
}

#Reverse Update function for string. If null is present, none is 
#uploaded instead
sub update_reverse_with_none_str_default
{

    my $input = $_[0];
    my $actfld;
    my $actval;
    my $fld;
    my $updatefld;
    my $val;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actval) = split(/$nodeparamconnector/, $input, 2);
    add_hole_in_cli_tree_buffer();
    if (get_value_from_xml_dbase($actfld, \$fld)) {
    }
    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    if ($fld eq "") {
    $fld = "none";
    }

   if(defined($fld)) {
#print "update_reverse_conditional_radiusport4 $fld, $val \n";
       if ($fld ne "none") {
          $result = param_value_return($actfld, \$updatefld); 
          if ($result != $PARAM_UPDATE_SUCCESS) {
               return $result;
          }
          $result = param_value_return($actfld, \$updatefld);
        } else {
          $updatefld = "none";
        }
        update_cli_tree_with_value($updatefld, $actfld, 1);
    } 
    return $result;
}

#11u action
sub update_reverse_with_dot11u_oui 
{
    my $input = $_[0];
    my $actfld;
    my $actlen;
    my $fld;
    my $len;
    my $output;

    ($actfld, $actlen) = split(/\,/, $input);
    add_hole_in_cli_tree_buffer();

    $result = param_value_return($actfld, \$fld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $result = param_value_return($actlen, \$len);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $output = substr($fld,0,$len*2);
#print "update_reverse_with_required_len $fld, $len, $output \n";
    update_cli_tree_with_value($output, $actfld, 1);
    return $result;
}


 sub  update_reverse_default_ifextrafield_present_with_operated_value
{

    my $input = $_[0];
    my $actfld;
    my $actsupportfld;
    my $actval;
    my $fld;
    my $supportfld;
    my $val;
    my $actop;
    my $op;
    my $result = $NOOP_CLI_RETURN_OPTION;

    ($actfld, $actsupportfld, $actval, $actop) = split(/$nodeparamconnector/, $input, 4);

    add_hole_in_cli_tree_buffer();
    if (get_value_from_xml_dbase($actfld, \$fld)) {
    }
    $result = param_value_return($actval, \$val);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actsupportfld, \$supportfld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actop, \$op );
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    if(defined($fld)) {
        if ($op == $add_op) {
            $fld = $fld + $val;
        } elsif ($op == $sub_op) {
            $fld = $fld - $val;
        } elsif ($op == $mul_op) {
            $fld = $fld * $val;
        } elsif ($op == $div_op) {
            $fld = $fld / $val;
        } else {
            print "Wrong operator entered it should be 1 = add, 2 = sub, 3 = mul or 4 = div\n";
            die;
        }
#print "update_reverse_conditional_vikram $actfld, $val,$fld \n";
        $result = update_cli_tree_with_value($fld, $actfld, 1);
    } else {
        if (defined($supportfld)) {
            $fld = $val;
#print "update_reverse_conditional_radiusport5 $actfld, $val,$fld \n";
            $result = update_cli_tree_with_value($fld, $actfld, 1);
        } else {
            return $NO_INSTANCE_FOUND;
        }
    }
    return $result;
}
sub is_supported_on_ucs
{
      if ( ($is_ambassador == 1) || ($is_saber == 1) ||
           ($is_pata == 1) || ($is_khanda == 1) || ($is_vm == 1) ) {
         return $INVALID_CLI_OPTION;
      }
      return $NOOP_CLI_RETURN_OPTION;
}
sub HEX_to_ASCII($)
{
    (my $str = shift) =~ s/([a-fA-F0-9]{2})/chr(hex $1)/eg;
#print "HEX_to_ASCII $str \n";
  return $str;
}

sub remove_spl_chars($)
{
      my $string = shift;
      $string =~ s/[^a-zA-Z0-9_.~*()@!-]*//g;
      return $string;
}

sub update_reverse_policy_name
{
    my $input = $_[0];
    my $pname;
    my $pnamestr;
    my $actpolicyfld;
    my $policyfld;
    my $tmp;
    my $result = $NOOP_CLI_RETURN_OPTION;

    my ($actruleid, $actpolicyfld) = split(/$nodeparamconnector/, $input, 2);
    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actruleid, \$ruleid);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    my ($tmp, $policyfld) = split(/9./, $actpolicyfld);

#print "ruleid is $ruleid\n";

    if(get_value_from_xml_dbase_with_key($policyfld, \$pname, $ruleid - 1)) {
#print "pname is $pname\n";
    } 
#print "Xml2Cli: pname retrieved: $pname\n";
    my $policyAscii = HEX_to_ASCII($pname);
#print "Xml2Cli: pname after HEX_to_ASCII: $policyAscii\n";

    $pnamestr = remove_spl_chars($policyAscii);
#print "Xml2Cli: pname after special character delete: $pnamestr\n";

    $result = update_cli_tree_with_value($pnamestr, $actpolicyfld, 1);
    return $result;
}

sub update_reverse_with_two_condition_both_for_snmpcomm_mode
{
    my $input = $_[0];
    my $actfld1;
    my $actfld2;
    my $actvalue1;
    my $actvalue2;
    my $actupdfld1;
    my $actupdfld2;
    my $actopr1;
    my $actopr2;
    my $actcombcond;
    my $value1;
    my $value2;
    my $fld1;
    my $fld2 = 0;
    my $updfld1;
    my $updfld2;
    my $opr1;
    my $opr2;
    my $combcond;
    my $tmp_str;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $tmpFlag1=0;
    my $tmpFlag2=0;

    ($actfld1, $actvalue1, $actupdfld1, $actopr1, $actfld2, $actvalue2, $actupdfld2, $actopr2, $actcombcond) = split(/$nodeparamconnector/, $input, 9);
    add_hole_in_cli_tree_buffer();
    if (get_value_from_xml_dbase($actfld1, \$fld1)) {
    }
    $result = param_value_return($actvalue1, \$value1);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actupdfld1, \$updfld1);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actopr1, \$opr1);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }


    if ($opr1 == $grt_op ) {
        if ($fld1 > $value1) {
            $tmp_str = $updfld1;
            $tmpFlag1 = 1;
        }
    } elsif ($opr1 == $eq_op) {
        if ($fld1 eq "") {
            $tmp_str = $updfld1;
            $tmpFlag1 = 1;
        }
            $tmpFlag1 = 1;
#print "1 SNMP update_reverse_with_two_condition_both: opr is eq than, $fld1, $value1, $updfld1, $tmp_str\n";
    } elsif ($opr1 == $less_op) {
        if ($fld1 < $value1) {

            $tmp_str = $updfld1;
            $tmpFlag1 = 1;
        }
    } else {
        print "Wrong operator entered it should be 1=greater than 2= equal 3 =less than. .\n";
        die;
    }

#    if (get_value_from_xml_dbase($actfld2, \$fld2)) {
 #   }
    $result = param_value_return($actfld2, \$fld2);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        print "Wrong operator entered it should be 1=greater than 2= equal 3 =less than. .\n";
        return $result;
    }
    $result = param_value_return($actvalue2, \$value2);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actupdfld2, \$updfld2);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actopr2, \$opr2);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $result = param_value_return($actcombcond, \$combcond);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print"update_reverse_with_two_condition_both: $combcond, $opr2\n";
    if ($opr2 == $grt_op ) {
        if ($fld2 > $value2) {
            $tmp_str = $updfld2;
            $tmpFlag2 = 1;
        }
    } elsif ($opr2 == $eq_op) {
#print"update_reverse_with_two_condition_both: opr2 is equal to, $fld2, $value2\n";
#print" 2. SNMPupdate_reverse_with_two_condition_both: opr is eq than, $fld2, $value2, $updfld2\n";
        if ($fld2 eq $value2) {
            $tmp_str = $updfld2;
            $tmpFlag2 = 1;
        }
    } elsif ($opr2 == $less_op) {
        if ($fld2 < $value2) {
            $tmp_str = $updfld2;
            $tmpFlag2 = 1;
        }
    } elsif ($opr2 == $neq_op) {
        if ($fld2 ne $value2) {
            $tmp_str = $updfld2;
            $tmpFlag2 = 1;
        }
    } else {
        print "Wrong operator entered it should be 1=greater than 2= equal 3 =less than. .\n";
        die;
    }

    if ($combcond == 1) {
#print" 4. SNMP update_reverse_with_two_condition_both: $tmp_str, $tmpFlag1, $tmpFlag2\n";
        $result = update_cli_tree_with_value($tmp_str, $actfld1, 1);
        return $result;
    } elsif ($combcond == 2) {
#print" 3. SNMP update_reverse_with_two_condition_both: $tmpFlag1, $tmpFlag2\n";
        if (($tmpFlag1 == 1) && ($tmpFlag2 == 1)) {
            $result = update_cli_tree_with_value($tmp_str, $actfld1, 1);
            return $result;
        }
    } elsif ($combcond == 3) {
#print"update_reverse_with_two_condition_both: $tmpFlag1, $tmpFlag2\n";
        if (($tmpFlag1 == 1) && ($tmpFlag2 == 1)) {
            $result = $NO_INSTANCE_FOUND;
        } elsif ($tmpFlag1 == 1) {
            $result = update_cli_tree_with_value($fld1, $actfld1, 1);
            return $result;
        }
    }
}

####################################################################################################################
#
# 1.config mobility group member add <mac>   <ip>    <group-name> 
# 2.config mobility group member add <ip> group-name <group-name> mac-address <mac-address> public-ip-address <pubIp>
#                                              ^                      ^                           ^                        
#                                              |                      |                           |                        
# This function is called everytime the keywords/Values pointed above 
#
####################################################################################################################
sub update_ip_or_keyowrd_depending_on_presence_of_data_newmob
{
    my $input = $_[0];
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $groupDD;
    my $pubIpDD;
    my $macDD;
    my $group;
    my $pubIp;
    my $mac;
    my $ipDigitDot;
    my $ip;
    my $keyword_local;
    my $mapGroupName = 1;
    my $mapPubIp = 2;
    my $mapMac = 4;
    my $mapNone = 8;
    
    #ptr_mmCfgData.mwarList.group
    #ptr_mmCfgData.mwarList.peerAddr.pubIp
    #ptr_mmCfgData.mwarList.peerAddr.mac.id

    ($groupDD, $pubIpDD, $macDD, $ipDigitDot) = split(/$nodeparamconnector/, $input, 4);

    add_hole_in_cli_tree_buffer();

    if($new_mobility_enabled) {
        $result = param_value_return($groupDD, \$group);
        if ($result != $PARAM_UPDATE_SUCCESS || (($mapGroupName & $keyword_map_for_new_mobility) == $mapGroupName) ) {
            #Group is not found, So try and see the existence of pubIP
            $result = param_value_return($pubIpDD, \$pubIp);
            if ($result != $PARAM_UPDATE_SUCCESS  || (($mapPubIp & $keyword_map_for_new_mobility) == $mapPubIp) ) {
                #PubIP is not found, So try and see the existence of mac-address 
                $result = param_value_return($macDD, \$mac);
                if ($result != $PARAM_UPDATE_SUCCESS || (($mapMac & $keyword_map_for_new_mobility) == $mapMac) ) {
                    #No data is found. Return from here 
                    $keyword_local = $mapNone;
                    $result = update_cli_tree_with_value("", $macDD, 1);
                } else {
                #mac is found, Go update the data structures
                    $keyword_local = $mapMac;
                    $result = update_cli_tree_with_value('mac-address', $macDD, 1);
                }
            } else {
            #Pubip is found, Go update the data structures
                $keyword_local = $mapPubIp;
                $result = update_cli_tree_with_value('public-ip-address', $pubIpDD, 1);
            }
        } else {
        #Group is found, Go update the data structures
            $keyword_local = $mapGroupName;
            $result = update_cli_tree_with_value('group-name', $groupDD, 1);
        }
    } else {
        if ($current_keyword_for_new_mobility != $mapNone){
            $result = param_value_return($ipDigitDot, \$ip);
            if ($result != $PARAM_UPDATE_SUCCESS) {
                return $result;
            }
            $result = update_cli_tree_with_value($ip, $ipDigitDot, 1);
        } else {
            $result = update_cli_tree_with_value("", $ipDigitDot, 1);
            return $result;
        }
    }

    #Say for this particular CLI that particular keyword is already taken
    $keyword_map_for_new_mobility |= $keyword_local;
    #update this varialbe to identify which data structure to upload
    $current_keyword_for_new_mobility = $keyword_local;

    # 1.config mobility group member add <mac>   <ip>    <group-name> 
    # 2.config mobility group member add <ip> group-name <group-name> mac-address <mac-address> public-ip-address <pubIp>
    #                                              ^
    #                                              |
    #                                              we are here while in first case node is mandaroy, in the second case its not
    # If you have not found the keyword, then do not make the the next node mandatory

    if ($keyword_local != $mapNone || !$new_mobility_enabled){
        $make_next_node_mandatory = 1;
    }

    return $result;
}

####################################################################################################################
#
# 1.config mobility group member add <mac>   <ip>    <group-name> 
# 2.config mobility group member add <ip> group-name <group-name> mac-address <mac-address> public-ip-address <pubIp>
#                                                        ^                          ^                            ^                        
#                                                        |                          |                            |                        
# This function is called everytime the keywords/Values pointed above 
#
####################################################################################################################
sub update_value_depending_on_map_new_mobility
{
    my $input = $_[0];
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $groupDD;
    my $pubIpDD;
    my $macDD;
    my $group;
    my $pubIp;
    my $mac;
    my $dataDigitDot;
    my $data;
    my $mapGroupName = 1;
    my $mapPubIp = 2;
    my $mapMac = 4;
    my $mapNone = 8;
    #ptr_mmCfgData.mwarList.group
    #ptr_mmCfgData.mwarList.peerAddr.pubIp
    #ptr_mmCfgData.mwarList.peerAddr.mac.id
    
    ($groupDD, $pubIpDD, $macDD) = split(/$nodeparamconnector/, $input, 3);
    add_hole_in_cli_tree_buffer();
    
    if($new_mobility_enabled) {
        if ($current_keyword_for_new_mobility == $mapGroupName){
            #last keyword was group-name, so update value for this node
            $dataDigitDot = $groupDD; 
        } elsif ($current_keyword_for_new_mobility == $mapPubIp) {
            #last keyword was mac-address, so update value for this node
            $dataDigitDot = $pubIpDD; 
        } elsif ($current_keyword_for_new_mobility == $mapMac) {
            #last keyword was public-ip-address, so update value for this node
            $dataDigitDot = $macDD; 
        } elsif ($current_keyword_for_new_mobility == $mapNone) {
            #There was no keyword, so update Null for this node
            $result = update_cli_tree_with_value("", $macDD, 1);
            return $result;
        } else {
            return $INVALID_CLI_OPTION; 
        }
    } else {
        # Old Mobility case where you have Group at this point
        if ($current_keyword_for_new_mobility != $mapNone){
            $dataDigitDot = $groupDD; 
        } else {
            #There was no group, so update Null for this node and return
            $result = update_cli_tree_with_value("", $macDD, 1);
            return $result;
        }
        $current_keyword_for_new_mobility = $mapNone;
    }

    $result = param_value_return($dataDigitDot, \$data);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = update_cli_tree_with_value($data, $dataDigitDot, 1);
    return $result;
}

####################################################################################################################
#
# 1.config mobility group member add <mac>   <ip>    <group-name> 
# 2.config mobility group member add <ip> group-name <group-name> mac-address <mac-address> public-ip-address <pubIp>
#                                     ^
#                                     |
# This function is called everytime the keywords/Values pointed above 
#
####################################################################################################################
sub update_mac_or_ip_dependingon_type_of_mobility
{
    my $input = $_[0];
    my $macDigitDot;
    my $ipDigitDot;
    my $mac;
    my $ip;
    my $result = $NOOP_CLI_RETURN_OPTION;

    #If this is the first time invocation we should read from flash
    if ($new_mobility_enabled == 2) {
        #open(DB114,"$mobilityFlag") or die "Can't open format specifier database File- mobilityFlag";
        open(DB115,"$mobilityFlag") or $new_mobility_enabled = 0;
            for $line(<DB115>) {
                chomp $line;
                if ($line == 0 || $line == 1){
                    $new_mobility_enabled = $line;
                } else {
                    $new_mobility_enabled = 0;
                }
            } 
    }

    ($ipDigitDot, $macDigitDot) = split(/$nodeparamconnector/, $input, 2);

    add_hole_in_cli_tree_buffer();

    $current_keyword_for_new_mobility = 0;
    if($new_mobility_enabled){
        $keyword_map_for_new_mobility = 0;
        # read and update the ip
        $result = param_value_return($ipDigitDot, \$ip);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        $result = update_cli_tree_with_value($ip, $ipDigitDot, 1);
    } else {
        # read and update the mac
        $result = param_value_return($macDigitDot, \$mac);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
        if( $mac eq '00:00:00:00:00:00') {
            return $INVALID_CLI_OPTION;
        }
        $result = update_cli_tree_with_value($mac, $macDigitDot, 1);
    }
    return $result;
}

################################################################
#                                                              #
# Written on top of optional_input                             #
# Makes the next node mandatory depending on a global flag     #
#                                                              #
################################################################
sub optional_input_mobility
{
    if ($make_next_node_mandatory == 1){
        $make_next_node_mandatory = 0;
        return $ADVANCE_TO_NEXT_DEPTH;
    } else {
        return $CLI_INPUT_OPTIONAL;
    }
}

sub update_tunnel_eogre_dhcpopt_string
{
    my $input = $_[0];
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $node;
    my $nodeval;

    my ($node) = split(/\,/, $input, 1);

    $result = param_value_return($node, \$nodeval);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    # Remove "
    $nodeval =~ s/"//g;

    update_cli_tree_with_value($nodeval, 0, 0 );
    return $CLI_INPUT_OPTIONAL;
}

sub check_gateway_primary_flag
{
    my $val1 = $_[0];
    my $val2;
    my $val3;
    my $val4;
    my $val11;
    my $string;
    my $result = $NOOP_CLI_RETURN_OPTION;

    my ($val11, $val3) = split(/\,/, $val1, 2);
    $result = param_value_return($val11, \$val2);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    $result = param_value_return($val3, \$val4);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }

    if ($val2 eq "TUNNEL_GW_PRIMARY") {
        update_cli_tree_with_value($val4, 0, 0);
        return $PARAM_UPDATE_SUCCESS;
    }
    return $NOOP_CLI_RETURN_OPTION;
}
