/[cwmp]/google/acs.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /google/acs.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 12 - (hide annotations)
Mon May 21 12:06:04 2007 UTC (16 years, 11 months ago) by dpavlin
File MIME type: text/plain
File size: 3121 byte(s)
cludge to handle empty requests so that we get callback for it, and try to generate correct response
1 dpavlin 2 #!/usr/bin/perl
2    
3     use warnings;
4     use strict;
5    
6 dpavlin 11 use lib 'lib';
7 dpavlin 2 use SOAP::Transport::HTTP +trace => 'debug';
8 dpavlin 12 use SOAP::Lite +trace => 'debug';
9 dpavlin 2
10     # Eh...
11     $SOAP::Constants::DO_NOT_CHECK_MUSTUNDERSTAND = 1;
12    
13     $SIG{PIPE} = $SIG{INT} = 'IGNORE'; # don't want to die on 'Broken pipe' or Ctrl-C
14    
15     my $daemon = SOAP::Transport::HTTP::Daemon->new(
16     #LocalAddr => 'localhost',
17     LocalPort => 3333,
18     Reuse => 1,
19     #'Listen' => 128,
20     )
21 dpavlin 12 ->dispatch_with(
22     { 'urn:dslforum-org:cwmp-1-0' => 'CWMP'},
23     )
24 dpavlin 2 ;
25    
26    
27     print "Contact to ACS server at ", $daemon->url, "\n";
28     $daemon->handle;
29    
30     package CWMP;
31     use strict;
32    
33     use Data::Dump qw/dump/;
34 dpavlin 7 use Carp qw/cluck/;
35 dpavlin 2
36     sub new {
37     bless {}, shift;
38     }
39    
40 dpavlin 12 # CPE methods Responding Calling
41     #
42     # GetRPCMethods Required Optional
43     # SetParameterValues Required Required
44     # GetParameterValues Required Required
45     # GetParameterNames Required Required
46     # SetParameterAttributes Required Optional
47     # GetParameterAttributes Required Optional
48     # AddObject Required Optional
49     # DeleteObject Required Optional
50     # Reboot Required Optional
51     # Download Required Required
52     # Upload Optional Optional
53     # FactoryReset Optional Optional
54     # GetQueuedTransfers Optional Optional
55     # ScheduleInform Optional Optional
56     # SetVouchers Optional Optional
57     # GetOptions Optional Optional
58    
59 dpavlin 2 # Server methods Calling Responding
60 dpavlin 12 #
61 dpavlin 2 # GetRPCMethods Optional Required
62     # Inform Required Required
63     # TransferComplete Required Required
64     # RequestDownload Optional Optional
65     # Kicked Optional Optional
66    
67 dpavlin 12
68     my $ID;
69    
70 dpavlin 2 sub Inform {
71 dpavlin 7 my ($self, $DeviceId, $Event, $MaxEnvelopes, $CurrentTime, $RetryCount, $ParameterList, $headers) = @_;
72 dpavlin 2
73     my $p;
74    
75 dpavlin 7 #cluck dump( $daemon );
76     #warn dump( $headers );
77    
78 dpavlin 12 $ID = ( grep { $_->name eq 'ID' } @$headers )[0]->value;
79 dpavlin 7
80 dpavlin 2 foreach ( @$ParameterList ) {
81     $p->{ $_->{Name} } = $_->{Value};
82     }
83    
84 dpavlin 7 warn "request $ID from ", dump( $DeviceId ), " with events ",dump( $Event ), "maxEnvelopes: $MaxEnvelopes on $CurrentTime retry $RetryCount params ", dump( $p );
85 dpavlin 2
86 dpavlin 7 return SOAP::Data->name('MaxEnvelopes' => $MaxEnvelopes);
87 dpavlin 2 }
88 dpavlin 12
89     sub GetParameterValuesResponse {
90     warn "GetParameterValuesResponse ",dump( @_ );
91     }
92    
93     sub empty_request {
94     my (undef, $self) = @_;
95    
96     $self->serializer->soapversion(SOAP::Lite->soapversion);
97     $self->serializer->xmlschema($SOAP::Constants::DEFAULT_XML_SCHEMA);
98    
99     my @results = (
100     SOAP::Header->name('ID' => $ID)->prefix('cwmp')->mustUnderstand(1),
101     SOAP::Data->name('GetParameterValues' =>
102     'ParameterNames' => [
103     'InternetGatewayDevice.ManagementServer.',
104     'a.', 'a.b.', 'a.b.c.',
105     ],
106     )->prefix('cwmp'),
107     );
108    
109     my $result = $self->serializer
110     # ->prefix('s') # distinguish generated element names between client and server
111     # ->uri('urn:dslforum-org:cwmp-1-0')
112     ->ns('urn:dslforum-org:cwmp-1-0', 'cwmp')
113     ->envelope( freeform => @results );
114    
115     my $xml = $result;
116     $xml =~ s/</\n</gs;
117    
118     print "empty request result: $xml\n";
119    
120     return $result;
121     }

Properties

Name Value
svn:executable

  ViewVC Help
Powered by ViewVC 1.1.26