use Data::Dump qw/dump/;
use Carp qw/carp confess cluck croak/;
-use CWMP::Request;
+use CWMP::Parser;
use CWMP::Methods;
use CWMP::Store;
+use CWMP::Vendor;
#use Devel::LeakTrace::Fast;
warn "## request payload: ",length($xml)," bytes\n$xml\n" if $self->debug;
- $state = CWMP::Request->parse( $xml );
+ $state = CWMP::Parser->parse( $xml );
warn "## acquired state = ", dump( $state ), "\n" if $self->debug;
- if ( ! defined( $state->{DeviceID} ) ) {
+ if ( ! defined( $state->{DeviceId} ) ) {
if ( $self->state ) {
- warn "## state without DeviceID, using old one...\n";
- $state->{DeviceID} = $self->state->{DeviceID};
+ warn "## state without DeviceId, using old one...\n";
+ $state->{DeviceId} = $self->state->{DeviceId};
} else {
- warn "WARNING: state without DeviceID, and I don't have old one!\n";
+ warn "WARNING: state without DeviceId, and I don't have old one!\n";
warn "## state = ",dump( $state );
}
}
my $uid = $self->store->state_to_uid( $state );
- my $to_uid = join(" ", grep { defined($_) } "to $uid",
- # board
- $state->{Parameter}->{'InternetGatewayDevice.DeviceInfo.HardwareVersion'},
- # version
- $state->{Parameter}->{'InternetGatewayDevice.DeviceInfo.SoftwareVersion'},
- # summary
-# $state->{Parameter}->{'InternetGatewayDevice.DeviceSummary'},
- ) . "\n";
-
my $queue = CWMP::Queue->new({
id => $uid,
debug => $self->debug,
});
+
$xml = '';
+ my $status = 200;
if ( my $dispatch = $state->{_dispatch} ) {
$xml = $self->dispatch( $dispatch );
$xml = $self->dispatch( $job->dispatch );
$job->finish;
} else {
- my $stored = $self->store->get_state( $uid );
- if ( ! defined $stored->{ParameterInfo} ) {
- $xml = $self->dispatch( 'GetParameterNames', [ 'InternetGatewayDevice.', 1 ] );
- } else {
- my @params = grep { m/\.$/ } keys %{ $stored->{ParameterInfo} };
- if ( @params ) {
- warn "# GetParameterNames ", dump( @params );
- $xml = $self->dispatch( 'GetParameterNames', [ shift @params, 1 ] );
- foreach ( @params ) {
- $queue->enqueue( 'GetParameterNames', [ $_, 1 ] );
- delete( $stored->{ParameterInfo}->{ $_ } );
- }
- $self->store->set_state( $uid, $stored );
- } else {
- warn ">>> empty response $to_uid";
- $state->{NoMoreRequests} = 1;
- $xml = '';
- }
+ my @dispatch;
+ @dispatch = CWMP::Vendor->all_parameters( $self->store, $uid, $queue );
+warn "XXX", dump @dispatch;
+ @dispatch = CWMP::Vendor->vendor_config( $self->store, $uid, $queue ) unless @dispatch;
+warn "XXX", dump @dispatch;
+ $xml = $self->dispatch( @dispatch ) if @dispatch;
+ if ( ! $xml ) {
+ warn ">>> no more work for $uid sending empty response\n";
+ $state->{NoMoreRequests} = 1;
+ $xml = '';
+ $status = 204;
}
}
- my $status = length($xml) ? 200 : 204;
-
my $out = join("\r\n",
"HTTP/1.1 $status OK",
'Content-Type: text/xml; charset="utf-8"',
$out .= "Content-Length: " . length( $xml ) . "\r\n\r\n";
$out .= $xml if length($xml);
- warn "### request over for $uid\n" if $self->debug;
-
return $out; # next request
};