From: Dobrica Pavlinusic Date: Sun, 7 Mar 2010 19:09:12 +0000 (+0000) Subject: use new CWMP::Parser X-Git-Url: http://git.rot13.org/?p=perl-cwmp.git;a=commitdiff_plain;h=a2544f1449c8b1f24a1f7ff0f8bcd79ab0eac977;ds=sidebyside use new CWMP::Parser - DeviceID was misspelled - we don't support _trigger any more git-svn-id: https://perl-cwmp.googlecode.com/svn/trunk@263 836a5e1a-633d-0410-964b-294494ad4392 --- diff --git a/lib/CWMP/Request.pm b/lib/CWMP/Request.pm index 0cea935..07b93f4 100644 --- a/lib/CWMP/Request.pm +++ b/lib/CWMP/Request.pm @@ -40,7 +40,7 @@ our $rules = [ next if $name eq '_content'; my $key = $name; $key =~ s/^\w+://; # stip namespace - $state->{DeviceID}->{ $key } = _tag( $tag_hash, $name, '_content' ); + $state->{DeviceId}->{ $key } = _tag( $tag_hash, $name, '_content' ); } }, 'EventStruct' => sub { diff --git a/lib/CWMP/Session.pm b/lib/CWMP/Session.pm index bdde16c..8a47f00 100644 --- a/lib/CWMP/Session.pm +++ b/lib/CWMP/Session.pm @@ -18,7 +18,7 @@ store use Data::Dump qw/dump/; use Carp qw/carp confess cluck croak/; -use CWMP::Request; +use CWMP::Parser; use CWMP::Methods; use CWMP::Store; @@ -88,16 +88,16 @@ sub process_request { 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 ); } } diff --git a/lib/CWMP/Store.pm b/lib/CWMP/Store.pm index da8164e..b90fd62 100644 --- a/lib/CWMP/Store.pm +++ b/lib/CWMP/Store.pm @@ -139,7 +139,7 @@ sub all_uids { my $CPE_uid = $store->ID_to_uid( $state ); -It uses C<< DeviceID.SerialNumber >> from C message as unique ID +It uses C<< DeviceId.SerialNumber >> from C message as unique ID for each CPE. =cut @@ -150,8 +150,8 @@ sub state_to_uid { warn "#### state_to_uid",dump( $state ),$/ if $self->debug > 4; - my $uid = $state->{DeviceID}->{SerialNumber} || - confess "no DeviceID.SerialNumber in ",dump( $state ); + my $uid = $state->{DeviceId}->{SerialNumber} || + confess "no DeviceId.SerialNumber in ",dump( $state ); chomp($uid); return $uid; diff --git a/lib/CWMP/Vendor.pm b/lib/CWMP/Vendor.pm index fdbdc1e..071d7cb 100644 --- a/lib/CWMP/Vendor.pm +++ b/lib/CWMP/Vendor.pm @@ -58,7 +58,7 @@ my ( $last_ip, $last_serial ); sub state2serial { my $state = shift; - my $serial = $state->{DeviceID}->{SerialNumber} || die "no DeviceID.SerialNumber in ",dump($state); + my $serial = $state->{DeviceId}->{SerialNumber} || die "no DeviceId.SerialNumber in ",dump($state); chomp($serial); my $ip = $state->{Parameter}->{'.ExternalIPAddress'} || @@ -84,6 +84,11 @@ Install all custom triggers =cut sub add_triggers { +} + +1; + +__END__ warn __PACKAGE__, "->add_triggers\n" if $debug; diff --git a/t/SpeedTouch-706/Fault.pl b/t/SpeedTouch-706/Fault.pl index 3a8b89e..1a710e9 100644 --- a/t/SpeedTouch-706/Fault.pl +++ b/t/SpeedTouch-706/Fault.pl @@ -1,5 +1,4 @@ { Fault => { FaultCode => 9001, FaultString => "Request Denied" }, ID => "22_THOM_TR69_ID", - _trigger => "Fault", } \ No newline at end of file diff --git a/t/SpeedTouch-706/GetParameterNamesResponse.pl b/t/SpeedTouch-706/GetParameterNamesResponse.pl index 4bfa00c..2b5b658 100644 --- a/t/SpeedTouch-706/GetParameterNamesResponse.pl +++ b/t/SpeedTouch-706/GetParameterNamesResponse.pl @@ -3265,5 +3265,4 @@ "InternetGatewayDevice.X_000E50_Firewall.LevelNumberOfEntries" => 0, "InternetGatewayDevice.X_000E50_Firewall.SelectedLevel" => 1, }, - _trigger => "GetParameterNamesResponse", } \ No newline at end of file diff --git a/t/SpeedTouch-706/GetRPCMethodsResponse.pl b/t/SpeedTouch-706/GetRPCMethodsResponse.pl index 56f80bf..6ff2d0a 100644 --- a/t/SpeedTouch-706/GetRPCMethodsResponse.pl +++ b/t/SpeedTouch-706/GetRPCMethodsResponse.pl @@ -11,5 +11,4 @@ "Reboot", "FactoryReset", ], - _trigger => "GetRPCMethodsResponse", } \ No newline at end of file diff --git a/t/SpeedTouch-706/Inform.pl b/t/SpeedTouch-706/Inform.pl index 5e768b5..12c1596 100644 --- a/t/SpeedTouch-706/Inform.pl +++ b/t/SpeedTouch-706/Inform.pl @@ -1,29 +1,28 @@ { - CurrentTime => "1970-01-01T03:18:53Z", - DeviceID => { - Manufacturer => "THOMSON", - OUI => "00147F", - ProductClass => "SpeedTouch 706", - SerialNumber => "CP0636JT3SH", - }, - EventStruct => ["2 PERIODIC"], - ID => "22_THOM_TR69_ID", + CurrentTime => "1970-01-01T03:18:53Z", + DeviceId => { + Manufacturer => "THOMSON", + OUI => "00147F", + ProductClass => "SpeedTouch 706", + SerialNumber => "CP0636JT3SH", + }, + Event => [{ CommandKey => undef, EventCode => "2 PERIODIC" }], + ID => "22_THOM_TR69_ID", MaxEnvelopes => 2, - Parameter => { - ".ExternalIPAddress" => "192.168.1.254", - "InternetGatewayDevice.DeviceInfo.HardwareVersion" => "BANT-S", - "InternetGatewayDevice.DeviceInfo.ProvisioningCode" => undef, - "InternetGatewayDevice.DeviceInfo.SoftwareVersion" => "6.2.15.5", - "InternetGatewayDevice.DeviceInfo.SpecVersion" => "1.1", - "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Date" => "0000-00-00T00:00:00", - "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Description" => "Factory Defaults", - "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Name" => "Routed PPPoE on 0/35 and 8/35", - "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Version" => undef, - "InternetGatewayDevice.DeviceSummary" => "InternetGatewayDevice:1.1[] (Baseline:1, EthernetLAN:1, ADSLWAN:1, Bridging:1, Time:1)", - "InternetGatewayDevice.ManagementServer.ConnectionRequestURL" => "http://192.168.1.254:51005/", - "InternetGatewayDevice.ManagementServer.ParameterKey" => undef, - }, - RetryCount => 10, - _dispatch => "InformResponse", - _trigger => "Inform", + Parameter => { + ".ExternalIPAddress" => "192.168.1.254", + "InternetGatewayDevice.DeviceInfo.HardwareVersion" => "BANT-S", + "InternetGatewayDevice.DeviceInfo.ProvisioningCode" => undef, + "InternetGatewayDevice.DeviceInfo.SoftwareVersion" => "6.2.15.5", + "InternetGatewayDevice.DeviceInfo.SpecVersion" => "1.1", + "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Date" => "0000-00-00T00:00:00", + "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Description" => "Factory Defaults", + "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Name" => "Routed PPPoE on 0/35 and 8/35", + "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Version" => undef, + "InternetGatewayDevice.DeviceSummary" => "InternetGatewayDevice:1.1[] (Baseline:1, EthernetLAN:1, ADSLWAN:1, Bridging:1, Time:1)", + "InternetGatewayDevice.ManagementServer.ConnectionRequestURL" => "http://192.168.1.254:51005/", + "InternetGatewayDevice.ManagementServer.ParameterKey" => undef, + }, + RetryCount => 10, + _dispatch => "InformResponse", } \ No newline at end of file diff --git a/t/SpeedTouch-780/Fault.pl b/t/SpeedTouch-780/Fault.pl index ac16f66..ba0142c 100644 --- a/t/SpeedTouch-780/Fault.pl +++ b/t/SpeedTouch-780/Fault.pl @@ -1,5 +1,4 @@ { Fault => { FaultCode => 9001, FaultString => "Request Denied" }, ID => "0_THOM_TR69_ID", - _trigger => "Fault", } \ No newline at end of file diff --git a/t/SpeedTouch-780/GetParameterNamesResponse.pl b/t/SpeedTouch-780/GetParameterNamesResponse.pl index a2a2fe4..48c60fa 100644 --- a/t/SpeedTouch-780/GetParameterNamesResponse.pl +++ b/t/SpeedTouch-780/GetParameterNamesResponse.pl @@ -3345,5 +3345,4 @@ "InternetGatewayDevice.X_000E50_Firewall.LevelNumberOfEntries" => 0, "InternetGatewayDevice.X_000E50_Firewall.SelectedLevel" => 1, }, - _trigger => "GetParameterNamesResponse", } \ No newline at end of file diff --git a/t/SpeedTouch-780/GetRPCMethodsResponse.pl b/t/SpeedTouch-780/GetRPCMethodsResponse.pl index 94b7527..3eda293 100644 --- a/t/SpeedTouch-780/GetRPCMethodsResponse.pl +++ b/t/SpeedTouch-780/GetRPCMethodsResponse.pl @@ -11,5 +11,4 @@ "Reboot", "FactoryReset", ], - _trigger => "GetRPCMethodsResponse", } \ No newline at end of file diff --git a/t/SpeedTouch-780/Inform.pl b/t/SpeedTouch-780/Inform.pl index 747202e..c99ea4b 100644 --- a/t/SpeedTouch-780/Inform.pl +++ b/t/SpeedTouch-780/Inform.pl @@ -1,29 +1,32 @@ { - CurrentTime => "1970-01-01T00:01:31Z", - DeviceID => { - Manufacturer => "THOMSON", - OUI => "00147F", - ProductClass => "SpeedTouch 780", - SerialNumber => "CP0644JTHJ4", - }, - EventStruct => ["1 BOOT", "2 PERIODIC", "4 VALUE CHANGE"], - ID => "0_THOM_TR69_ID", + CurrentTime => "1970-01-01T00:01:31Z", + DeviceId => { + Manufacturer => "THOMSON", + OUI => "00147F", + ProductClass => "SpeedTouch 780", + SerialNumber => "CP0644JTHJ4", + }, + Event => [ + { CommandKey => undef, EventCode => "1 BOOT" }, + { CommandKey => undef, EventCode => "2 PERIODIC" }, + { CommandKey => undef, EventCode => "4 VALUE CHANGE" }, + ], + ID => "0_THOM_TR69_ID", MaxEnvelopes => 2, - Parameter => { - ".ExternalIPAddress" => "192.168.1.254", - "InternetGatewayDevice.DeviceInfo.HardwareVersion" => "BANT-R", - "InternetGatewayDevice.DeviceInfo.ProvisioningCode" => undef, - "InternetGatewayDevice.DeviceInfo.SoftwareVersion" => "6.2.15.5", - "InternetGatewayDevice.DeviceInfo.SpecVersion" => "1.1", - "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Date" => "0000-00-00T00:00:00", - "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Description" => "Factory Defaults", - "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Name" => "Routed PPPoE on 0/35 and 8/35", - "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Version" => undef, - "InternetGatewayDevice.DeviceSummary" => "InternetGatewayDevice:1.1[] (Baseline:1, EthernetLAN:1, ADSLWAN:1, Bridging:1, Time:1, WiFiLAN:1)", - "InternetGatewayDevice.ManagementServer.ConnectionRequestURL" => "http://192.168.1.254:51005/", - "InternetGatewayDevice.ManagementServer.ParameterKey" => undef, - }, - RetryCount => "05", - _dispatch => "InformResponse", - _trigger => "Inform", + Parameter => { + ".ExternalIPAddress" => "192.168.1.254", + "InternetGatewayDevice.DeviceInfo.HardwareVersion" => "BANT-R", + "InternetGatewayDevice.DeviceInfo.ProvisioningCode" => undef, + "InternetGatewayDevice.DeviceInfo.SoftwareVersion" => "6.2.15.5", + "InternetGatewayDevice.DeviceInfo.SpecVersion" => "1.1", + "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Date" => "0000-00-00T00:00:00", + "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Description" => "Factory Defaults", + "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Name" => "Routed PPPoE on 0/35 and 8/35", + "InternetGatewayDevice.DeviceInfo.VendorConfigFile.1.Version" => undef, + "InternetGatewayDevice.DeviceSummary" => "InternetGatewayDevice:1.1[] (Baseline:1, EthernetLAN:1, ADSLWAN:1, Bridging:1, Time:1, WiFiLAN:1)", + "InternetGatewayDevice.ManagementServer.ConnectionRequestURL" => "http://192.168.1.254:51005/", + "InternetGatewayDevice.ManagementServer.ParameterKey" => undef, + }, + RetryCount => "05", + _dispatch => "InformResponse", } \ No newline at end of file