[Netpass-devel] NetPass/lib/NetPass Config.pm,1.40,1.41
Brought to you by:
jeffmurphy
|
From: jeff m. <jef...@us...> - 2005-05-20 15:16:21
|
Update of /cvsroot/netpass/NetPass/lib/NetPass In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21675/lib/NetPass Modified Files: Config.pm Log Message: bugs, network cfg ui Index: Config.pm =================================================================== RCS file: /cvsroot/netpass/NetPass/lib/NetPass/Config.pm,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- Config.pm 19 May 2005 20:15:04 -0000 1.40 +++ Config.pm 20 May 2005 15:16:12 -0000 1.41 @@ -705,6 +705,53 @@ return ""; } +=head2 $cfg-E<gt>setNetwork(-network => '', -comment => '', -interface => '', -qvid => #, -uqvid => #) + +Given a network, set the various "core" network fields. A comment of "" or undef is OK. All other +fields are required. + +RETURNS + +0 on success +"..." on failure + +=cut + + +sub setNetwork { + my $self = shift; + + my $parms = parse_parms({ + -parms => \@_, + -legal => [qw(-network -comment -interface -qvid -uqvid)], + -required => [qw(-network -interface -qvid -uqvid)], + -defaults => { -comment => '' } + } + ); + + if (!defined($parms)) { + return "invalid parameters: ".Carp::longmess("invalid parameters ".Class::ParmList->error); + } + + my ($network, $comment, $interface, $qvid, $uqvid) = + $parms->get('-network', '-comment', '-interface', '-qvid', '-uqvid'); + + $comment ||= ''; + + $self->reloadIfChanged(); + + if( ! $self->{'cfg'}->obj('network')->exists($network) ) { + $self->{'cfg'}->obj('network')->$network({}); + } + + $self->{'cfg'}->obj('network')->obj($network)->comment($comment); + $self->{'cfg'}->obj('network')->obj($network)->interface($interface); + $self->{'cfg'}->obj('network')->obj($network)->quarantine($qvid); + $self->{'cfg'}->obj('network')->obj($network)->nonquarantine($uqvid); + + return 0; +} + =head2 $val = $np->policy(-key => $key, -network => $nw, -val => $value) @@ -766,8 +813,8 @@ _log("DEBUG", "policy(-key $pvar, -network $nw)\n") if $self->debug; - $self->reloadIfChanged() || return undef; - + $self->reloadIfChanged(); + $pvar =~ tr [A-Z] [a-z]; # because of AutoLowerCase # if network looks like an IP, figure out which <network> clause |