11 |
use File::Slurp; |
use File::Slurp; |
12 |
use blib; |
use blib; |
13 |
use CWMP::Request; |
use CWMP::Request; |
14 |
|
use YAML::Syck; |
15 |
|
|
16 |
my $path = shift @ARGV || die "usage: $0 dump/client_ip/\n"; |
my $path = shift @ARGV || die "usage: $0 dump/client_ip/\n"; |
17 |
|
|
38 |
|
|
39 |
my $test_path = 't/dump/'; |
my $test_path = 't/dump/'; |
40 |
|
|
41 |
|
sub xml2state { |
42 |
|
my $xml = shift; |
43 |
|
$xml =~ s/^.*?</</s; |
44 |
|
return CWMP::Request->parse( $xml ); |
45 |
|
} |
46 |
|
|
47 |
if ( my $i = $requests->{Inform} ) { |
if ( my $i = $requests->{Inform} ) { |
48 |
|
|
49 |
my $xml = read_file($i); |
my $xml = read_file($i); |
|
$xml =~ s/^.*?</</s; |
|
50 |
|
|
51 |
# warn "## xml: $xml\n"; |
# warn "## xml: $xml\n"; |
52 |
|
|
53 |
my $state = CWMP::Request->parse( $xml ); |
my $state = xml2state( $xml ); |
54 |
|
|
55 |
# warn "## state = ",dump( $state ); |
# warn "## state = ",dump( $state ); |
56 |
|
|
73 |
my $to = "$test_path/$name"; |
my $to = "$test_path/$name"; |
74 |
warn "## $from -> $to\n"; |
warn "## $from -> $to\n"; |
75 |
next if -e $to; |
next if -e $to; |
76 |
write_file( $to, read_file( $from ) ); |
my $xml = read_file( $from ); |
77 |
|
write_file( $to, $xml ); |
78 |
|
DumpFile( "$to.yml", xml2state( $xml ) ); |
79 |
warn "created $to\n"; |
warn "created $to\n"; |
80 |
} |
} |