forked from aduitsis/snmp-class
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added MacAddress and Hex_Generic roles.
- Loading branch information
Showing
5 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package SNMP::Class::Varbind::Hex_Generic; | ||
|
||
use Moose::Role; | ||
use Carp; | ||
use Data::Dumper; | ||
use Log::Log4perl qw(:easy); | ||
|
||
|
||
|
||
#we have to call the register_callback function in the INIT block to make sure | ||
#that the SNMP::Class::Varbind module is actually loaded | ||
INIT { | ||
SNMP::Class::Varbind::register_plugin(__PACKAGE__); | ||
DEBUG __PACKAGE__." plugin activated"; | ||
} | ||
|
||
sub matches { | ||
( $_[0]->has_label ) && ( | ||
( $_[0]->get_label eq 'snmpEngineID') | ||
); | ||
#DEBUG SNMP::Class::Utils::textual_convention_of( $_[0]->get_label ); | ||
#DEBUG SNMP::Class::Utils::syntax_of( $_[0]->get_label ); | ||
#DEBUG SNMP::Class::Utils::type_of( $_[0]->get_label ); | ||
} | ||
|
||
sub adopt { | ||
if(matches($_[0])) { | ||
__PACKAGE__->meta->apply($_[0]); | ||
DEBUG "Applying role ".__PACKAGE__." to ".$_[0]->get_label; | ||
} | ||
} | ||
|
||
sub value { | ||
return uc join(' ',(unpack '(H2)*',$_[0]->raw_value)) | ||
} | ||
|
||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package SNMP::Class::Varbind::MacAddress; | ||
|
||
use Moose::Role; | ||
use Carp; | ||
use Data::Dumper; | ||
use Log::Log4perl qw(:easy); | ||
|
||
|
||
|
||
#we have to call the register_callback function in the INIT block to make sure | ||
#that the SNMP::Class::Varbind module is actually loaded | ||
INIT { | ||
SNMP::Class::Varbind::register_plugin(__PACKAGE__); | ||
DEBUG __PACKAGE__." plugin activated"; | ||
} | ||
|
||
sub matches { | ||
( $_[0]->has_label ) | ||
&& | ||
( SNMP::Class::Utils::has_textual_convention( $_[0]->get_label ) ) | ||
&& | ||
( SNMP::Class::Utils::textual_convention_of( $_[0]->get_label ) eq 'MacAddress') | ||
; | ||
|
||
#DEBUG SNMP::Class::Utils::textual_convention_of( $_[0]->get_label ); | ||
#DEBUG SNMP::Class::Utils::syntax_of( $_[0]->get_label ); | ||
#DEBUG SNMP::Class::Utils::type_of( $_[0]->get_label ); | ||
} | ||
|
||
sub adopt { | ||
if(matches($_[0])) { | ||
__PACKAGE__->meta->apply($_[0]); | ||
DEBUG "Applying role ".__PACKAGE__." to ".$_[0]->get_label; | ||
} | ||
} | ||
|
||
sub value { | ||
return uc join(':',(unpack '(H2)*',$_[0]->raw_value)) | ||
} | ||
|
||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters