1 |
#!/usr/bin/perl |
2 |
|
3 |
use warnings; |
4 |
use strict; |
5 |
|
6 |
use lib 'lib'; |
7 |
use SOAP::Transport::HTTP +trace => 'debug'; |
8 |
|
9 |
# Eh... |
10 |
$SOAP::Constants::DO_NOT_CHECK_MUSTUNDERSTAND = 1; |
11 |
|
12 |
$SIG{PIPE} = $SIG{INT} = 'IGNORE'; # don't want to die on 'Broken pipe' or Ctrl-C |
13 |
|
14 |
# change LocalPort to 81 if you want to test it with soapmark.pl |
15 |
|
16 |
my $daemon = SOAP::Transport::HTTP::Daemon->new( |
17 |
#LocalAddr => 'localhost', |
18 |
LocalPort => 3333, |
19 |
Reuse => 1, |
20 |
#'Listen' => 128, |
21 |
) |
22 |
->dispatch_with({ 'urn:dslforum-org:cwmp-1-0' => 'CWMP'}) |
23 |
; |
24 |
|
25 |
|
26 |
print "Contact to ACS server at ", $daemon->url, "\n"; |
27 |
$daemon->handle; |
28 |
|
29 |
package CWMP; |
30 |
use strict; |
31 |
|
32 |
use Data::Dump qw/dump/; |
33 |
use Carp qw/cluck/; |
34 |
|
35 |
sub new { |
36 |
bless {}, shift; |
37 |
} |
38 |
|
39 |
# Server methods Calling Responding |
40 |
# GetRPCMethods Optional Required |
41 |
# Inform Required Required |
42 |
# TransferComplete Required Required |
43 |
# RequestDownload Optional Optional |
44 |
# Kicked Optional Optional |
45 |
|
46 |
sub Inform { |
47 |
my ($self, $DeviceId, $Event, $MaxEnvelopes, $CurrentTime, $RetryCount, $ParameterList, $headers) = @_; |
48 |
|
49 |
my $p; |
50 |
|
51 |
#cluck dump( $daemon ); |
52 |
#warn dump( $headers ); |
53 |
|
54 |
my $ID = ( grep { $_->name eq 'ID' } @$headers )[0]->value; |
55 |
|
56 |
foreach ( @$ParameterList ) { |
57 |
$p->{ $_->{Name} } = $_->{Value}; |
58 |
} |
59 |
|
60 |
warn "request $ID from ", dump( $DeviceId ), " with events ",dump( $Event ), "maxEnvelopes: $MaxEnvelopes on $CurrentTime retry $RetryCount params ", dump( $p ); |
61 |
|
62 |
return SOAP::Data->name('MaxEnvelopes' => $MaxEnvelopes); |
63 |
} |