| 1 | # | ||
| 2 | # $Id: TypeCapabilities.pm 2002 2015-02-15 16:50:35Z gomor $ | ||
| 3 | # | ||
| 4 | package Net::Packet::CDP::TypeCapabilities; | ||
| 5 | use strict; | ||
| 6 | use warnings; | ||
| 7 | |||
| 8 | require Net::Packet::CDP::Type; | ||
| 9 | our @ISA = qw(Net::Packet::CDP::Type); | ||
| 10 | |||
| 11 | use Net::Packet::Consts qw(:cdp); | ||
| 12 | |||
| 13 | our @AS = qw( | ||
| 14 | capabilities | ||
| 15 | ); | ||
| 16 | __PACKAGE__->cgBuildIndices; | ||
| 17 | __PACKAGE__->cgBuildAccessorsScalar(\@AS); | ||
| 18 | |||
| 19 | #no strict 'vars'; | ||
| 20 | |||
| 21 | sub new { | ||
| 22 | shift->SUPER::new( | ||
| 23 | type => NP_CDP_TYPE_CAPABILITIES, | ||
| 24 | length => 8, | ||
| 25 | capabilities => 0x00000000, | ||
| 26 | @_, | ||
| 27 | ); | ||
| 28 | } | ||
| 29 | |||
| 30 | sub pack { | ||
| 31 | my $self = shift; | ||
| 32 | |||
| 33 | $self->raw($self->SUPER::pack('nnN', | ||
| 34 | $self->type, | ||
| 35 | $self->length, | ||
| 36 | $self->capabilities, | ||
| 37 | )) or return undef; | ||
| 38 | |||
| 39 | 1; | ||
| 40 | } | ||
| 41 | |||
| 42 | sub unpack { | ||
| 43 | my $self = shift; | ||
| 44 | |||
| 45 | my ($type, $length, $capabilities, $payload) = | ||
| 46 | $self->SUPER::unpack('nnN a*', $self->raw) | ||
| 47 | or return undef; | ||
| 48 | |||
| 49 | $self->type($type); | ||
| 50 | $self->length($length); | ||
| 51 | $self->capabilities($capabilities); | ||
| 52 | |||
| 53 | $self->payload($payload); | ||
| 54 | |||
| 55 | 1; | ||
| 56 | } | ||
| 57 | |||
| 58 | sub print { | ||
| 59 | my $self = shift; | ||
| 60 | |||
| 61 | my $i = $self->is; | ||
| 62 | my $l = $self->layer; | ||
| 63 | sprintf "$l: $i: type:0x%04x length:%d capabilities:0x%08x", | ||
| 64 | $self->type, $self->length, $self->capabilities; | ||
| 65 | } | ||
| 66 | |||
| 67 | 1; | ||
| 68 | |||
| 69 | __END__ |