r234@brr: dpavlin | 2007-11-18 18:18:38 +0100
[perl-cwmp.git] / lib / CWMP / Session.pm
index b971331..3cd9a78 100644 (file)
@@ -113,7 +113,7 @@ sub process_request {
 
        if ( $self->create_dump ) {
                write_file( $file, $r->as_string );
-               warn "### request dumped to file: $file\n";
+               warn "### request dumped to file: $file\n" if $self->debug;
        }
 
        my $state;
@@ -131,7 +131,7 @@ sub process_request {
                        symlink $file, $type || warn "can't symlink $file -> $type: $!";
                }
 
-               warn "## acquired state = ", dump( $state ), "\n";
+               warn "## acquired state = ", dump( $state ), "\n" if $self->debug;
 
                if ( ! defined( $state->{DeviceID} ) ) {
                        warn "## state with DeviceID, using old one...\n";
@@ -139,7 +139,7 @@ sub process_request {
                }
 
                $self->state( $state );
-               $self->store->update_state( ID => $state->{ID}, $state );
+               $self->store->update_state( $state );
 
        } else {
 
@@ -150,17 +150,25 @@ sub process_request {
                #warn "last request state = ", dump( $state ), "\n" if $self->debug > 1;
        }
 
-
        $sock->send(join("\r\n",
                'HTTP/1.1 200 OK',
                'Content-Type: text/xml; charset="utf-8"',
-               'Server: AcmeCWMP/42',
-               'SOAPServer: AcmeCWMP/42'
+               'Server: PerlCWMP/42',
+               'SOAPServer: PerlCWMP/42'
        )."\r\n");
 
        $sock->send( "Set-Cookie: ID=" . $state->{ID} . "; path=/\r\n" ) if ( $state->{ID} );
 
-       my $uid = $self->store->ID_to_uid( $state->{ID}, $state );
+       my $uid = $self->store->state_to_uid( $state );
+
+       my $to_uid = join(" ", grep { defined($_) } "to $uid",
+                       # board
+                       $state->{Parameter}->{'InternetGatewayDevice.DeviceInfo.HardwareVersion'},
+                       # version
+                       $state->{Parameter}->{'InternetGatewayDevice.DeviceInfo.SoftwareVersion'},
+                       # summary
+#                      $state->{Parameter}->{'InternetGatewayDevice.DeviceSummary'},
+       ) . "\n";
 
        my $queue = CWMP::Queue->new({
                id => $uid,
@@ -174,10 +182,10 @@ sub process_request {
        } elsif ( $job = $queue->dequeue ) {
                $xml = $self->dispatch( $job->dispatch );
        } elsif ( $size == 0 ) {
-               warn ">>> no more queued commands, closing connection to $uid\n";
+               warn ">>> no more queued commands, closing connection $to_uid";
                return 0;
        } else {
-               warn ">>> empty response to $uid\n";
+               warn ">>> empty response $to_uid";
                $state->{NoMoreRequests} = 1;
                $xml = $self->dispatch( 'xml', sub {} );
        }
@@ -185,7 +193,7 @@ sub process_request {
        $sock->send( "Content-Length: " . length( $xml ) . "\r\n\r\n" );
        $sock->send( $xml ) or die "can't send response";
 
-       warn ">>>> " . $sock->peerhost . " [" . localtime() . "] sent ", length( $xml )," bytes to $uid\n";
+       warn ">>>> " . $sock->peerhost . " [" . localtime() . "] sent ", length( $xml )," bytes $to_uid";
 
        $job->finish if $job;
        warn "### request over for $uid\n" if $self->debug;
@@ -216,7 +224,7 @@ sub dispatch {
                if ( $self->create_dump ) {
                        my $file = sprintf("dump/%04d-%s.response", $dump_nr++, $self->sock->peerhost);
                        write_file( $file, $xml );
-                       warn "### response dump: $file\n";
+                       warn "### response dump: $file\n" if $self->debug;
                }
                return $xml;
        } else {