35 |
my $server = CWMP::Session->new({ |
my $server = CWMP::Session->new({ |
36 |
sock => $io_socket_object, |
sock => $io_socket_object, |
37 |
store => 'state.db', |
store => 'state.db', |
38 |
queue => [ qw/GetRPCMethods GetParameterNames/ ], |
queue => [ |
39 |
|
'GetRPCMethods', |
40 |
|
[ 'GetParameterValyes', 'InternetGatewayDevice.DeviceInfo.SerialNumber', 0 ], |
41 |
|
], |
42 |
debug => 1, |
debug => 1, |
43 |
}); |
}); |
44 |
|
|
101 |
|
|
102 |
my $r = $sock->get_request || confess "can't get_request"; |
my $r = $sock->get_request || confess "can't get_request"; |
103 |
|
|
104 |
my $chunk = $r->content; |
my $xml = $r->content; |
105 |
|
|
106 |
my $size = length( $chunk ); |
my $size = length( $xml ); |
107 |
|
|
108 |
warn "<<<< ", $sock->peerhost, " [" . localtime() . "] ", $r->method, " ", $r->uri, " $size bytes\n"; |
warn "<<<< ", $sock->peerhost, " [" . localtime() . "] ", $r->method, " ", $r->uri, " $size bytes\n"; |
109 |
|
|
110 |
if ( $self->debug > 2 ) { |
if ( $self->debug > 2 ) { |
111 |
my $file = sprintf("dump/%04d-%s.request", $dump_nr++, $sock->peerhost); |
my $file = sprintf("dump/%04d-%s.request", $dump_nr++, $sock->peerhost); |
112 |
write_file( $file, $r->as_string ); |
write_file( $file, $r->as_string ); |
113 |
warn "### request dump: $file\n"; |
warn "### request dumped to file: $file\n"; |
114 |
} |
} |
115 |
|
|
116 |
my $state; |
my $state; |
117 |
|
|
118 |
if ( $size > 0 ) { |
if ( $size > 0 ) { |
119 |
|
|
120 |
die "no SOAPAction header in ",dump($chunk) unless defined ( $r->header('SOAPAction') ); |
die "no SOAPAction header in ",dump($xml) unless defined ( $r->header('SOAPAction') ); |
121 |
|
|
122 |
$state = CWMP::Request->parse( $chunk ); |
warn "## request payload: ",length($xml)," bytes\n$xml\n" if $self->debug; |
123 |
|
|
124 |
|
$state = CWMP::Request->parse( $xml ); |
125 |
|
|
126 |
warn "## acquired state = ", dump( $state ), "\n"; |
warn "## acquired state = ", dump( $state ), "\n"; |
127 |
|
|
184 |
my $self = shift; |
my $self = shift; |
185 |
|
|
186 |
my $dispatch = shift || die "no dispatch?"; |
my $dispatch = shift || die "no dispatch?"; |
187 |
|
my @args = @_; |
188 |
|
|
189 |
|
if ( ref($dispatch) eq 'ARRAY' ) { |
190 |
|
my @a = @$dispatch; |
191 |
|
$dispatch = shift @a; |
192 |
|
push @args, @a; |
193 |
|
} |
194 |
|
|
195 |
my $response = CWMP::Response->new({ debug => $self->debug }); |
my $response = CWMP::Response->new({ debug => $self->debug }); |
196 |
|
|
197 |
if ( $response->can( $dispatch ) ) { |
if ( $response->can( $dispatch ) ) { |
198 |
warn ">>> dispatching to $dispatch\n"; |
warn ">>> dispatching to $dispatch\n"; |
199 |
my $xml = $response->$dispatch( $self->state, @_ ); |
my $xml = $response->$dispatch( $self->state, @args ); |
200 |
warn "## response payload: ",length($xml)," bytes\n$xml\n" if $self->debug; |
warn "## response payload: ",length($xml)," bytes\n$xml\n" if $self->debug; |
201 |
if ( $self->debug > 2 ) { |
if ( $self->debug > 2 ) { |
202 |
my $file = sprintf("dump/%04d-%s.response", $dump_nr++, $self->sock->peerhost); |
my $file = sprintf("dump/%04d-%s.response", $dump_nr++, $self->sock->peerhost); |