use inc::Module::Install;
name 'CWMP';
-version '0.07';
+version '0.08';
license 'GPL';
requires 'Net::Server';
requires 'HTTP::Daemon';
debug => $debug,
default_queue => [
'GetRPCMethods',
- [ 'GetParameterNames', 'InternetGatewayDevice.DeviceInfo.SerialNumber', 0 ],
- [ 'GetParameterNames', 'InternetGatewayDevice.DeviceInfo.', 1 ],
+ 'GetParameterNames',
+# [ 'GetParameterNames', 'InternetGatewayDevice.DeviceInfo.SerialNumber', 0 ],
+# [ 'GetParameterNames', 'InternetGatewayDevice.DeviceInfo.', 1 ],
[ 'GetParameterValues',
'InternetGatewayDevice.DeviceInfo.SerialNumber',
'InternetGatewayDevice.DeviceInfo.VendorConfigFile.',
+ 'InternetGatewayDevice.DeviceInfo.X_000E50_Country',
+ ],
+ [ 'SetParameterValues',
+ 'InternetGatewayDevice.DeviceInfo.ProvisioningCode' => 'test provision',
+# 'InternetGatewayDevice.DeviceInfo.X_000E50_Country' => 1,
],
# 'Reboot',
],
=head2 SetParameterValues
-B<not implemented>
+ $method->SetParameterValues( $state,
+ param1 => 'value1',
+ param2 => 'value2',
+ ...
+ );
+
+It doesn't support base64 encoding of values yet.
+
+To preserve data, it does support repeatable parametar names.
+Behaviour on this is not defined in protocol.
+
+=cut
+
+sub SetParameterValues {
+ my $self = shift;
+ my $state = shift;
+
+ confess "SetParameterValues needs parameters" unless @_;
+
+ my @params = @_;
+
+ my ( @names, @values );
+
+ while ( @_ ) {
+ push @names, shift @_;
+ push @values, shift @_;
+ }
+
+ confess "can't convert params ", dump( @params ), " to name/value pairs" unless $#names == $#values;
+
+ warn "# SetParameterValues", dump( @params ), "\n" if $self->debug;
+
+ $self->xml( $state, sub {
+ my ( $X, $state ) = @_;
+
+ $X->SetParameterValues( $cwmp,
+ $X->ParameterList( $cwmp,
+ $X->ParameterNames( $cwmp,
+ map {
+ $X->ParameterValueStruct( $cwmp,
+ $X->Name( $cwmp, $_ ),
+ $X->Value( $cwmp, shift @values )
+ )
+ } @names
+ )
+ )
+ );
+ });
+}
+
=head2 GetParameterValues
my $self = shift;
my $state = shift;
my @ParameterNames = @_;
- confess "need ParameterNames" unless @ParameterNames;
+ confess "GetParameterValues need ParameterNames" unless @ParameterNames;
warn "# GetParameterValues", dump( @ParameterNames ), "\n" if $self->debug;
$self->xml( $state, sub {
my $debug = shift @ARGV;
-use Test::More tests => 14;
+use Test::More tests => 16;
use Data::Dump qw/dump/;
use Cwd qw/abs_path/;
use File::Slurp;
ok(my $abs_path = abs_path($0), "abs_path");
$abs_path =~ s!/[^/]*$!/!; #!fix-vim
-ok( my $response = CWMP::Methods->new({ debug => $debug }), 'new' );
-isa_ok( $response, 'CWMP::Methods' );
+ok( my $method = CWMP::Methods->new({ debug => $debug }), 'new' );
+isa_ok( $method, 'CWMP::Methods' );
-sub check_response {
+sub check_method {
my $command = shift || die "no command?";
my $state = {
ID => 42,
};
- diag "check_response $command",dump( 'state', @_ ) if $debug;
- ok( my $xml = $response->$command( $state, @_ ), "generate response $command" . dump(@_) );
+ diag "check_method $command",dump( 'state', @_ ) if $debug;
+ ok( my $xml = $method->$command( $state, @_ ), "generate method $command" . dump(@_) );
- my $file = "$abs_path/response/$command.xml";
+ my $file = "$abs_path/methods/$command.xml";
if ( ! -e $file ) {
diag "creating $file";
my $template_xml = read_file( $file ) || die "can't read template xml $file: $!";
- is( $xml, $template_xml, "compare $command" );
+ is( $xml, $template_xml, "compare $file" );
}
-check_response( 'InformResponse' );
-check_response( 'GetRPCMethods' );
-check_response( 'Reboot' );
-check_response( 'GetParameterNames', 'InternetGatewayDevice.DeviceInfo.SerialNumber' );
-check_response( 'GetParameterValues', 'InternetGatewayDevice.DeviceInfo.SerialNumber', 'InternetGatewayDevice.DeviceInfo.VendorConfigFile.' );
+check_method( 'InformResponse' );
+check_method( 'GetRPCMethods' );
+check_method( 'Reboot' );
+check_method( 'SetParameterValues',
+ 'InternetGatewayDevice.DeviceInfo.ProvisioningCode' => 'test provision',
+ 'InternetGatewayDevice.DeviceInfo.X_000E50_Country' => 42,
+);
+check_method( 'GetParameterNames', 'InternetGatewayDevice.DeviceInfo.SerialNumber' );
+check_method( 'GetParameterValues',
+ 'InternetGatewayDevice.DeviceInfo.SerialNumber',
+ 'InternetGatewayDevice.DeviceInfo.VendorConfigFile.',
+);
--- /dev/null
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:cwmp="urn:dslforum-org:cwmp-1-0"
+ soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
+ <soap:Header>
+ <cwmp:ID mustUnderstand="1">42</cwmp:ID>
+ <cwmp:NoMoreRequests>0</cwmp:NoMoreRequests>
+ </soap:Header>
+ <soap:Body>
+ <cwmp:GetParameterNames>
+ <cwmp:ParameterPath>InternetGatewayDevice.DeviceInfo.SerialNumber</cwmp:ParameterPath>
+ <cwmp:NextLevel>0</cwmp:NextLevel>
+ </cwmp:GetParameterNames>
+ </soap:Body>
+</soap:Envelope>
\ No newline at end of file
--- /dev/null
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:cwmp="urn:dslforum-org:cwmp-1-0"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance"
+ soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
+ <soap:Header>
+ <cwmp:ID mustUnderstand="1">42</cwmp:ID>
+ <cwmp:NoMoreRequests>0</cwmp:NoMoreRequests>
+ </soap:Header>
+ <soap:Body>
+ <cwmp:GetParameterValues>
+ <cwmp:ParameterNames>
+ <xsd:string>InternetGatewayDevice.DeviceInfo.SerialNumber</xsd:string>
+ <xsd:string>InternetGatewayDevice.DeviceInfo.VendorConfigFile.</xsd:string>
+ </cwmp:ParameterNames>
+ </cwmp:GetParameterValues>
+ </soap:Body>
+</soap:Envelope>
\ No newline at end of file
--- /dev/null
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:cwmp="urn:dslforum-org:cwmp-1-0"
+ soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
+ <soap:Header>
+ <cwmp:ID mustUnderstand="1">42</cwmp:ID>
+ <cwmp:NoMoreRequests>0</cwmp:NoMoreRequests>
+ </soap:Header>
+ <soap:Body>
+ <GetRPCMethods />
+ </soap:Body>
+</soap:Envelope>
\ No newline at end of file
--- /dev/null
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:cwmp="urn:dslforum-org:cwmp-1-0"
+ soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
+ <soap:Header>
+ <cwmp:ID mustUnderstand="1">42</cwmp:ID>
+ <cwmp:NoMoreRequests>0</cwmp:NoMoreRequests>
+ </soap:Header>
+ <soap:Body>
+ <cwmp:InformResponse>
+ <cwmp:MaxEnvelopes>1</cwmp:MaxEnvelopes>
+ </cwmp:InformResponse>
+ </soap:Body>
+</soap:Envelope>
\ No newline at end of file
--- /dev/null
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:cwmp="urn:dslforum-org:cwmp-1-0"
+ soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
+ <soap:Header>
+ <cwmp:ID mustUnderstand="1">42</cwmp:ID>
+ <cwmp:NoMoreRequests>0</cwmp:NoMoreRequests>
+ </soap:Header>
+ <soap:Body>
+ <Reboot />
+ </soap:Body>
+</soap:Envelope>
\ No newline at end of file
--- /dev/null
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:cwmp="urn:dslforum-org:cwmp-1-0"
+ soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
+ <soap:Header>
+ <cwmp:ID mustUnderstand="1">42</cwmp:ID>
+ <cwmp:NoMoreRequests>0</cwmp:NoMoreRequests>
+ </soap:Header>
+ <soap:Body>
+ <cwmp:SetParameterValues>
+ <cwmp:ParameterList>
+ <cwmp:ParameterNames>
+ <cwmp:ParameterValueStruct>
+ <cwmp:Name>InternetGatewayDevice.DeviceInfo.ProvisioningCode</cwmp:Name>
+ <cwmp:Value>test provision</cwmp:Value>
+ </cwmp:ParameterValueStruct>
+ <cwmp:ParameterValueStruct>
+ <cwmp:Name>InternetGatewayDevice.DeviceInfo.X_000E50_Country</cwmp:Name>
+ <cwmp:Value>42</cwmp:Value>
+ </cwmp:ParameterValueStruct>
+ </cwmp:ParameterNames>
+ </cwmp:ParameterList>
+ </cwmp:SetParameterValues>
+ </soap:Body>
+</soap:Envelope>
\ No newline at end of file
+++ /dev/null
-<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:cwmp="urn:dslforum-org:cwmp-1-0"
- soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
- <soap:Header>
- <cwmp:ID mustUnderstand="1">42</cwmp:ID>
- <cwmp:NoMoreRequests>0</cwmp:NoMoreRequests>
- </soap:Header>
- <soap:Body>
- <cwmp:GetParameterNames>
- <cwmp:ParameterPath>InternetGatewayDevice.DeviceInfo.SerialNumber</cwmp:ParameterPath>
- <cwmp:NextLevel>0</cwmp:NextLevel>
- </cwmp:GetParameterNames>
- </soap:Body>
-</soap:Envelope>
\ No newline at end of file
+++ /dev/null
-<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:cwmp="urn:dslforum-org:cwmp-1-0"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance"
- soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
- <soap:Header>
- <cwmp:ID mustUnderstand="1">42</cwmp:ID>
- <cwmp:NoMoreRequests>0</cwmp:NoMoreRequests>
- </soap:Header>
- <soap:Body>
- <cwmp:GetParameterValues>
- <cwmp:ParameterNames>
- <xsd:string>InternetGatewayDevice.DeviceInfo.SerialNumber</xsd:string>
- <xsd:string>InternetGatewayDevice.DeviceInfo.VendorConfigFile.</xsd:string>
- </cwmp:ParameterNames>
- </cwmp:GetParameterValues>
- </soap:Body>
-</soap:Envelope>
\ No newline at end of file
+++ /dev/null
-<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:cwmp="urn:dslforum-org:cwmp-1-0"
- soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
- <soap:Header>
- <cwmp:ID mustUnderstand="1">42</cwmp:ID>
- <cwmp:NoMoreRequests>0</cwmp:NoMoreRequests>
- </soap:Header>
- <soap:Body>
- <GetRPCMethods />
- </soap:Body>
-</soap:Envelope>
\ No newline at end of file
+++ /dev/null
-<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:cwmp="urn:dslforum-org:cwmp-1-0"
- soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
- <soap:Header>
- <cwmp:ID mustUnderstand="1">42</cwmp:ID>
- <cwmp:NoMoreRequests>0</cwmp:NoMoreRequests>
- </soap:Header>
- <soap:Body>
- <cwmp:InformResponse>
- <cwmp:MaxEnvelopes>1</cwmp:MaxEnvelopes>
- </cwmp:InformResponse>
- </soap:Body>
-</soap:Envelope>
\ No newline at end of file
+++ /dev/null
-<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:cwmp="urn:dslforum-org:cwmp-1-0"
- soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
- <soap:Header>
- <cwmp:ID mustUnderstand="1">42</cwmp:ID>
- <cwmp:NoMoreRequests>0</cwmp:NoMoreRequests>
- </soap:Header>
- <soap:Body>
- <Reboot />
- </soap:Body>
-</soap:Envelope>
\ No newline at end of file