my $debug = 0;
my $store_path = './';
my $store_plugin = 'YAML';
+my $create_dump = 1;
GetOptions(
'debug+' => \$debug,
'port=i' => \$port,
'store-path=s' => \$store_path,
'store-plugin=s' => \$store_plugin,
+ 'create_dump!' => \$create_dump,
);
my $server = CWMP::Server->new({
port => $port,
- store => {
- module => $store_plugin,
- path => $store_path,
- debug => $debug,
+ session => {
+ store => {
+ module => $store_plugin,
+ path => $store_path,
+ debug => $debug,
+ },
+ create_dump => $create_dump,
},
debug => $debug,
});
warn "injecting some tests commands\n";
- $q->enqueue( 'GetParameterNames', [ 'InternetGatewayDevice.LANDevice.', 1 ] );
+# $q->enqueue( 'GetParameterNames', [ 'InternetGatewayDevice.LANDevice.', 1 ] );
- $q->enqueue( 'GetParameterValues', [
- 'InternetGatewayDevice.',
- ]);
+# $q->enqueue( 'GetParameterValues', [
+# 'InternetGatewayDevice.',
+# ]);
+ $q->enqueue( 'GetParameterNames', [ '.ExternalIPAddress', 1 ] );
+ $q->enqueue( 'SetParameterValues', { '.ExternalIPAddress' => '192.168.1.250' });
+ $q->enqueue( 'GetParameterNames', [ '.ExternalIPAddress', 1 ] );
}
dump: all
rm dump/* || true
+ rm -Rf queue/ || true
./bin/acs.pl -d -d -d -d 2>&1 | tee log
html: \$(MAN1PODS) \$(MAN3PODS)
use base qw/Class::Accessor/;
__PACKAGE__->mk_accessors( qw/
port
-store
+session
background
debug
my $server = CWMP::Server->new({
port => 3333,
- store => {
- module => 'DBMDeep',
- path => 'var/',
- },
+ session => { ... },
background => 1,
debug => 1
});
port to listen on
-=item store
+=item session
hash with key C<module> with value C<DBMDeep> if L<CWMP::Store::DBMDeep>
is used. Other parametars are optional.
CWMP::Server::Helper->new({
proto => 'tcp',
port => $self->port,
- store => $self->store,
+ session => $self->session,
debug => $self->debug,
background => $self->background,
})
$self->SUPER::options($template);
# new single-value options
- foreach my $p ( qw/ store debug / ) {
+ foreach my $p ( qw/ session debug / ) {
$prop->{ $p } ||= undef;
$template->{ $p } = \$prop->{ $p };
}
my $sock = $prop->{client};
confess "no sock in ", ref( $self ) unless $sock;
+ my $sess = $prop->{session} || confess "no session";
+
eval {
- my $session = CWMP::Session->new({
- sock => $sock,
- store => $prop->{store},
- debug => $prop->{debug},
- }) || confess "can't create session";
+ $sess->{sock} = $sock;
+ $sess->{debug} = $prop->{debug};
+
+ warn "## sess = ", dump( $sess );
+
+ my $session = CWMP::Session->new( $sess ) || confess "can't create session from ",dump( $sess );
while ( $session->process_request ) {
warn "...waiting for next request from CPE...\n";
}
};
- if ($@) {
- warn $@;
- }
+ warn "ERROR: $@\n" if $@;
warn "...returning to accepting new connections\n";
__PACKAGE__->mk_accessors( qw/
debug
create_dump
-store
+session
sock
state
my $server = CWMP::Session->new({
sock => $io_socket_object,
- store => 'state.db',
+ store => { ... },
debug => 1,
create_dump => 1,
});
my $self = $class->SUPER::new( @_ );
confess "need sock" unless $self->sock;
+ confess "need store" unless $self->store;
+ my $peerhost = $self->sock->peerhost || confess "can't get sock->peerhost";
$self->debug( 0 ) unless $self->debug;
- warn "created ", __PACKAGE__, "(", dump( @_ ), ") for ", $self->sock->peerhost, "\n" if $self->debug;
+ warn "created ", __PACKAGE__, "(", dump( @_ ), ") for $peerhost\n" if $self->debug;
my $store_obj = CWMP::Store->new({
debug => $self->debug,
ok( my $server = CWMP::Server->new({
debug => $debug,
port => $port,
- store => {
- module => $store_module,
- path => $store_path,
- clean => 1,
- },
+ session => {
+ store => {
+ module => $store_module,
+ path => $store_path,
+ clean => 1,
+ },
+ create_dump => 0,
+ }
}), 'new' );
isa_ok( $server, 'CWMP::Server' );
ok( kill(9,$pid), 'kill ' . $pid );
ok( waitpid($pid,0), 'waitpid' );
+