#!/usr/lib/perl

#my $newdb2 = "newdb2";
#my $newdb5 = "newdb5";
#my $newdb7 = "newdb7";
#my $newdb10 = "newdb10";
#my $cli2xmldb1 = "cli2xmldb1";
#my $strmap = "strmap";
#my $strvalmap = "strvalmap";
#my $clifile = "clifile";
#my $xmldir = "";
#my $ignored_clifile = "ignored_clis";
#my $ignored_flash_clifile = "ignored_clis";
#my $invalid_config_tags_file = "invalid_db";
#my $fldfrmtdbase = "fldfrmtdbase";
#my $fldarraydbase = "fldarraydbase";
#my $McastUcast = "mcast_ucast_feature";

my $newdb2 = "/bsn/newdb2";
my $newdb5 = "/bsn/newdb5";
my $newdb7 = "/bsn/newdb7";
my $newdb10 = "/bsn/newdb10";
my $cli2xmldb1 = "/bsn/cli2xmldb1";
my $strmap = "/bsn/strmap";
my $strvalmap = "/bsn/strvalmap";
my $clifile = "/mnt/application/xml/clis/clifile";
my $ignored_flash_clifile = "/mnt/application/invclis/XMLIgnoredCLIConfig.txt";
my $ignored_clifile = "/mnt/application/xml/clis/XMLIgnoredCLIConfig.txt";
my $xmldir = "/mnt/application/xml/";
my $invalid_config_tags_file = "/mnt/application/xml/clis/XMLInvalidTagConfig.txt";
my $fldfrmtdbase = "/bsn/fldfrmtdbase";
my $fldarraydbase = "/bsn/fldarraydbase";
my $McastUcast = "/mnt/application/mcast_ucast_feature";

my @decimal_to_hex_string_array = ("0", "1", "2", "3", "4", "5", "6", "7", "8","9", "a", "b", "c", "d", "e", "f");

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 $grt_op = 1;
my $eq_op = 2;
my $less_op = 3;
my $exist_op = 4;
my $notexist_op = 5;

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 $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 $qvlan_name = ".sys.quarantine-0/";
my %glb_hash_bytetostring;


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();
append_ignored_config($ARGV[0]);
# cleanup_xml2cli_global_vars();

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[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;

#    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 $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 $lvlchngd = 0;
    my $mismachnotreqd =0;
    my $tmplvl = 0;
    my @invalid_tag_level;
    my @invalid_partialtag;
    my $invalid_tag_level_index = 0;
    my $found = 1;

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

    $href = \%digit_to_tag_actual;

# print "action_node5 $index, $temp[$index], $inpcmd\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";
            return $NO_INSTANCE_FOUND;
        } else {
            $href = \%{$$href{nxt}{$temp[$index]}};
        }
        if (defined($$href{array})) {
            $level += 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}\n";
    if ($arraybase == $arraybase_present) {
        $$pparam = $current_instance_indices{instance}[$level]{index};
    } else {
        $result = map_xml_format_to_cli_format($$href{val}, $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 $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);
#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);
    return $result;
}

sub action_node_arraybase
{
    my $input = $_[0];
    my $input_present = $_[1];
    my $inpcmd = $_[2];
    my $pparam = $_[3];
    my $result = $PARAM_UPDATE_SUCCESS;
    $result = action_node_internal($input, $input_present, $inpcmd, $pparam, $arraybase_present);
#print "action_node_arraybase $input $result\n";
    
    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;
    if ($flag_for_byte_string_cli_check && $flag_for_byte_mac_cli_check) {
# print "update_cli_tree_with_value after formats $value\n";
        if($glb_flag_arrayall_action == 1){
            my @temp = split(",", $glb_country_buffer);
            for(my $i=0; $i < $glb_country_count; $i++) {
               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}\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();
    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;
}

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\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 "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";
            $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 "\n";
            return 0;
        }
# print "$clitoxmldb1_instances{instance}[$i]{val}, ";
    }
# print "\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_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;
            $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};
            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(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(<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];
#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
{
    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;
}

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 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_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;

# 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;
    }
    $result = param_value_return($actrulefld, \$rulefld);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    $result = param_value_return($actrule, \$rule);
    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);

#print "update_reverse2 $actfld, $fld\n";
    $result = update_cli_tree_with_value($fld, $actfld, 1);
    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;
}

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);
    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);
# print "update_reverse_with_operated_index1 $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_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)) {
        $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;
}

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;
}

#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 $actmode;
    my $ip;
    my $mode;
    my $result = $NOOP_CLI_RETURN_OPTION;
    my $mcast_ucast_feature;

    open(DBMcastUcast,"$McastUcast");
    for $line_new(<DBMcastUcast>) {
        chomp $line_new;
        $mcast_ucast_feature = $line_new;
    }

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

    add_hole_in_cli_tree_buffer();
    $result = param_value_return($actip, \$ip);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    if($mcast_ucast_feature == 1) {
        $result = param_value_return($actmode, \$mode);
        if ($result != $PARAM_UPDATE_SUCCESS) {
            return $result;
        }
    } else {
        $mode = 1;
    }
    
    if ($mode == 1) {
        $result = update_cli_tree_with_value($ip, $actip, 1);
    } else {
        $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
    }
    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 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) {
            $result = update_cli_tree_with_value($fld, $actfld, 1);
        } else {
            $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
        }
    } elsif ($opr == $eq_op) {
        if ($fld == $val) {
            $result = update_cli_tree_with_value($fld, $actfld, 1);
        } else {
            $result = $DONOT_UPDATE_CLI_NODE_AND_STOP;
        }
    } elsif ($opr == $less_op) {
        if ($fld < $val) {
            $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)) {
            $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 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();
    $result = param_value_return($actfldmulticountry, \$fldmulticountry);
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
    my @tmp = split(' ',$fldmulticountry);
    #$glb_country_array[$glb_country_array_count] = $tmp[0];
#print "update_reverse_last_array_multiple_instances $glb_country_array[$glb_country_array_count]\n";
    #$glb_country_array_count += 1;
    if($glb_country_buffer eq "") {
        $glb_country_buffer = "$tmp[0]";
    } else {
        $glb_country_buffer .= ",$tmp[0]";
    }
#print "$glb_country_buffer\n";
    $result = param_value_return($actfldcount, \$fldcount);
    $glb_country_count = $fldcount;
    if ($result != $PARAM_UPDATE_SUCCESS) {
        return $result;
    }
#print "$fldcount";
    $glb_flag_arrayall_action = 1;
    $result = update_cli_tree_with_value($fldmulticountry, $actfldmulticountry, 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) {
             $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 ) {
             $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) {
        $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) {
#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 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;
}

#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
{
    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 $directfld;
    my @temp = split(/\./, $fld);
    for (my $i = 1; $i <= $#temp; $i++) {
        if($i == 1) {
            $directfld = $temp[$i];
        } else {
            $directfld = $directfld . "." .$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})) {
                    if(defined($direct_index_from_keyword{$directfld}{index})) {
                        $xmlref = \%{$$xmlref{instance}{$direct_index_from_keyword{$directfld}{index}}};
                    } else {
                        return 0;
                    }
                } else {
                    $xmlref = \%{$$xmlref{instance}{$current_instance_indices{instance}[$level+1]{index}}};
                }
                $level += 1;
            }
        } else {
            return 0;
        }
    }
    $$pval = $$xmlref{val};
    return 1;
}

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 ) {
        $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;
}

#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;
}

#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;
}
