- store debugging moved to debug level 4 (makes make dump much more useful)
- version bump [0.06]
git-svn-id: https://perl-cwmp.googlecode.com/svn/trunk@168
836a5e1a-633d-0410-964b-
294494ad4392
use inc::Module::Install;
name 'CWMP';
use inc::Module::Install;
name 'CWMP';
license 'GPL';
requires 'Net::Server';
requires 'HTTP::Daemon';
license 'GPL';
requires 'Net::Server';
requires 'HTTP::Daemon';
debug => $debug,
},
debug => $debug,
debug => $debug,
},
debug => $debug,
- default_queue => [ qw/
- GetRPCMethods
- GetParameterNames
- / ],
-# Reboot
+ default_queue => [
+ 'GetRPCMethods',
+ [ 'GetParameterNames', 'InternetGatewayDevice.DeviceInfo.SerialNumber', 0 ],
+ [ 'GetParameterValues', 'InternetGatewayDevice.DeviceInfo.SerialNumber', 1 ],
+# 'Reboot',
+ ],
my $server = CWMP::Session->new({
sock => $io_socket_object,
store => 'state.db',
my $server = CWMP::Session->new({
sock => $io_socket_object,
store => 'state.db',
- queue => [ qw/GetRPCMethods GetParameterNames/ ],
+ queue => [
+ 'GetRPCMethods',
+ [ 'GetParameterValyes', 'InternetGatewayDevice.DeviceInfo.SerialNumber', 0 ],
+ ],
my $r = $sock->get_request || confess "can't get_request";
my $r = $sock->get_request || confess "can't get_request";
- my $chunk = $r->content;
- my $size = length( $chunk );
+ my $size = length( $xml );
warn "<<<< ", $sock->peerhost, " [" . localtime() . "] ", $r->method, " ", $r->uri, " $size bytes\n";
if ( $self->debug > 2 ) {
my $file = sprintf("dump/%04d-%s.request", $dump_nr++, $sock->peerhost);
write_file( $file, $r->as_string );
warn "<<<< ", $sock->peerhost, " [" . localtime() . "] ", $r->method, " ", $r->uri, " $size bytes\n";
if ( $self->debug > 2 ) {
my $file = sprintf("dump/%04d-%s.request", $dump_nr++, $sock->peerhost);
write_file( $file, $r->as_string );
- warn "### request dump: $file\n";
+ warn "### request dumped to file: $file\n";
}
my $state;
if ( $size > 0 ) {
}
my $state;
if ( $size > 0 ) {
- die "no SOAPAction header in ",dump($chunk) unless defined ( $r->header('SOAPAction') );
+ die "no SOAPAction header in ",dump($xml) unless defined ( $r->header('SOAPAction') );
- $state = CWMP::Request->parse( $chunk );
+ warn "## request payload: ",length($xml)," bytes\n$xml\n" if $self->debug;
+
+ $state = CWMP::Request->parse( $xml );
warn "## acquired state = ", dump( $state ), "\n";
warn "## acquired state = ", dump( $state ), "\n";
my $self = shift;
my $dispatch = shift || die "no dispatch?";
my $self = shift;
my $dispatch = shift || die "no dispatch?";
+ my @args = @_;
+
+ if ( ref($dispatch) eq 'ARRAY' ) {
+ my @a = @$dispatch;
+ $dispatch = shift @a;
+ push @args, @a;
+ }
my $response = CWMP::Response->new({ debug => $self->debug });
if ( $response->can( $dispatch ) ) {
warn ">>> dispatching to $dispatch\n";
my $response = CWMP::Response->new({ debug => $self->debug });
if ( $response->can( $dispatch ) ) {
warn ">>> dispatching to $dispatch\n";
- my $xml = $response->$dispatch( $self->state, @_ );
+ my $xml = $response->$dispatch( $self->state, @args );
warn "## response payload: ",length($xml)," bytes\n$xml\n" if $self->debug;
if ( $self->debug > 2 ) {
my $file = sprintf("dump/%04d-%s.response", $dump_nr++, $self->sock->peerhost);
warn "## response payload: ",length($xml)," bytes\n$xml\n" if $self->debug;
if ( $self->debug > 2 ) {
my $file = sprintf("dump/%04d-%s.response", $dump_nr++, $self->sock->peerhost);
confess "unknown store module $module not one of ", dump( $self->possible_stores ) unless $s;
confess "unknown store module $module not one of ", dump( $self->possible_stores ) unless $s;
- warn "## current store = $s\n" if $self->debug;
+ warn "#### current store = $s\n" if $self->debug > 4;
confess "need $k value" unless $v;
confess "need state" unless $state;
confess "need $k value" unless $v;
confess "need state" unless $state;
- warn "## update_state( $k => $v, ", dump( $state ), " )\n" if $self->debug;
+ warn "#### update_state( $k => $v, ", dump( $state ), " )\n" if $self->debug > 4;
confess "need ID or uid" unless $k =~ m/^(ID|uid)$/;
confess "need $k value" unless $v;
confess "need ID or uid" unless $k =~ m/^(ID|uid)$/;
confess "need $k value" unless $v;
- warn "## get_state( $k => $v )\n" if $self->debug;
+ warn "#### get_state( $k => $v )\n" if $self->debug > 4;
confess "need ID" unless $ID;
confess "need ID" unless $ID;
- warn "ID_to_uid",dump( $ID, $state ),$/ if $self->debug;
+ warn "#### ID_to_uid",dump( $ID, $state ),$/ if $self->debug > 4;
$session->{ $ID }->{last_seen} = time();
$session->{ $ID }->{last_seen} = time();
return $uid;
} else {
warn "## can't find uid for ID $ID, first seen?\n";
return $uid;
} else {
warn "## can't find uid for ID $ID, first seen?\n";
}
# TODO: expire sessions longer than 30m
}
# TODO: expire sessions longer than 30m
- warn "current session = ",dump( $session );
-