3 |
use strict; |
use strict; |
4 |
use warnings; |
use warnings; |
5 |
|
|
6 |
|
|
7 |
use base qw/Class::Accessor/; |
use base qw/Class::Accessor/; |
8 |
__PACKAGE__->add_accessor( qw/ |
__PACKAGE__->mk_accessors( qw/debug/ ); |
|
debug |
|
|
/); |
|
9 |
|
|
10 |
use XML::Generator; |
use XML::Generator; |
11 |
use Carp qw/confess/; |
use Carp qw/confess/; |
27 |
my $class = shift; |
my $class = shift; |
28 |
my $self = $class->SUPER::new( @_ ); |
my $self = $class->SUPER::new( @_ ); |
29 |
|
|
30 |
warn "created XML::Generator object" if $self->debug; |
warn "created XML::Generator object\n" if $self->debug; |
31 |
|
|
32 |
return $self; |
return $self; |
33 |
} |
} |
36 |
my $cwmp = [ cwmp => 'urn:dslforum-org:cwmp-1-0' ]; |
my $cwmp = [ cwmp => 'urn:dslforum-org:cwmp-1-0' ]; |
37 |
my $soap = [ soap => "http://schemas.xmlsoap.org/soap/envelope/" ]; |
my $soap = [ soap => "http://schemas.xmlsoap.org/soap/envelope/" ]; |
38 |
|
|
39 |
=head2 Inform |
=head2 InformResponse |
40 |
|
|
41 |
$response->Inform( $state ); |
$response->InformResponse( $state ); |
42 |
|
|
43 |
=cut |
=cut |
44 |
|
|
45 |
sub Inform { |
sub InformResponse { |
46 |
my ( $self, $state ) = @_; |
my ( $self, $state ) = @_; |
47 |
$self->xml( $state, sub { |
$self->xml( $state, sub { |
48 |
my ( $X, $state ) = @_; |
my ( $X, $state ) = @_; |
66 |
}); |
}); |
67 |
}; |
}; |
68 |
|
|
69 |
|
=head2 Reboot { |
70 |
|
|
71 |
|
$response->Reboot( $state ); |
72 |
|
|
73 |
|
=cut |
74 |
|
|
75 |
|
sub Reboot { |
76 |
|
my ( $self, $state ) = @_; |
77 |
|
$self->xml( $state, sub { |
78 |
|
my ( $X, $state ) = @_; |
79 |
|
$X->Reboot(); |
80 |
|
}); |
81 |
|
} |
82 |
|
|
83 |
|
=head2 GetParameterNames { |
84 |
|
|
85 |
|
$response->GetParameterNames( $state, $ParameterPath, $NextLevel ); |
86 |
|
|
87 |
|
=cut |
88 |
|
|
89 |
|
sub GetParameterNames { |
90 |
|
my ( $self, $state, $ParameterPath, $NextLevel ) = @_; |
91 |
|
$ParameterPath ||= ''; # all |
92 |
|
$NextLevel ||= 0; # all |
93 |
|
warn "# GetParameterNames( '$ParameterPath', $NextLevel )\n" if $self->debug; |
94 |
|
$self->xml( $state, sub { |
95 |
|
my ( $X, $state ) = @_; |
96 |
|
|
97 |
|
$X->GetParameterNames( $cwmp, |
98 |
|
$X->ParameterPath( $cwmp, $ParameterPath ), |
99 |
|
$X->NextLevel( $cwmp, $NextLevel ), |
100 |
|
); |
101 |
|
}); |
102 |
|
} |
103 |
|
|
104 |
|
=head2 GetParameterValues { |
105 |
|
|
106 |
|
$response->GetParameterValues( $state, $ParameterPath, $NextLevel ); |
107 |
|
|
108 |
|
=cut |
109 |
|
|
110 |
|
sub GetParameterValues { |
111 |
|
my ( $self, $state, $ParameterPath, $NextLevel ) = @_; |
112 |
|
$ParameterPath ||= ''; # all |
113 |
|
$NextLevel ||= 0; # all |
114 |
|
warn "# GetParameterValues( '$ParameterPath', $NextLevel )\n" if $self->debug; |
115 |
|
$self->xml( $state, sub { |
116 |
|
my ( $X, $state ) = @_; |
117 |
|
|
118 |
|
$X->GetParameterValues( $cwmp, |
119 |
|
$X->ParameterPath( $cwmp, $ParameterPath ), |
120 |
|
$X->NextLevel( $cwmp, $NextLevel ), |
121 |
|
); |
122 |
|
}); |
123 |
|
} |
124 |
|
|
125 |
=head2 xml |
=head2 xml |
126 |
|
|
127 |
Used to implement methods which modify just body of soap message. |
Used to implement methods which modify just body of soap message. |
139 |
|
|
140 |
confess "no ID in state ", dump( $state ) unless ( $state->{ID} ); |
confess "no ID in state ", dump( $state ) unless ( $state->{ID} ); |
141 |
|
|
142 |
|
#warn "state used to generate xml = ", dump( $state ) if $self->debug; |
143 |
|
|
144 |
my $X = XML::Generator->new(':pretty'); |
my $X = XML::Generator->new(':pretty'); |
145 |
|
|
146 |
return $X->Envelope( $soap, { 'soap:encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/" }, |
return $X->Envelope( $soap, { 'soap:encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/" }, |
147 |
$X->Header( $soap, |
$X->Header( $soap, |
148 |
$X->ID( $cwmp, { mustUnderstand => 1 }, $state->{ID} ), |
$X->ID( $cwmp, { mustUnderstand => 1 }, $state->{ID} ), |
149 |
|
$X->NoMoreRequests( $cwmp, $state->{NoMoreRequests} || 0 ), |
150 |
), |
), |
151 |
$X->Body( $soap, $closure->( $X, $state ) ), |
$X->Body( $soap, $closure->( $X, $state ) ), |
152 |
); |
); |