| 1 | # | ||||||||||
| 2 | # $Id: SLL.pm,v 1.7 2006/12/06 21:20:02 gomor Exp $ | ||||||||||
| 3 | # | ||||||||||
| 4 | package Net::Frame::SLL; | ||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 2 | ▶ | use Net::Frame::Layer qw(:consts); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 2 | require Exporter; | |||||||||
| 10 | 2 | our @ISA = qw(Net::Frame::Layer Exporter); | |||||||||
| 11 | |||||||||||
| 12 | 2 | our %EXPORT_TAGS = ( | |||||||||
| 13 | consts => [qw( | ||||||||||
| 14 | NP_SLL_HDR_LEN | ||||||||||
| 15 | NP_SLL_PACKET_TYPE_SENT_BY_US | ||||||||||
| 16 | NP_SLL_PACKET_TYPE_UNICAST_TO_US | ||||||||||
| 17 | NP_SLL_ADDRESS_TYPE_512 | ||||||||||
| 18 | NP_SLL_PROTOCOL_USER | ||||||||||
| 19 | NP_SLL_PROTOCOL_IPv4 | ||||||||||
| 20 | NP_SLL_PROTOCOL_X25 | ||||||||||
| 21 | NP_SLL_PROTOCOL_ARP | ||||||||||
| 22 | NP_SLL_PROTOCOL_CGMP | ||||||||||
| 23 | NP_SLL_PROTOCOL_80211 | ||||||||||
| 24 | NP_SLL_PROTOCOL_PPPIPCP | ||||||||||
| 25 | NP_SLL_PROTOCOL_RARP | ||||||||||
| 26 | NP_SLL_PROTOCOL_DDP | ||||||||||
| 27 | NP_SLL_PROTOCOL_AARP | ||||||||||
| 28 | NP_SLL_PROTOCOL_PPPCCP | ||||||||||
| 29 | NP_SLL_PROTOCOL_WCP | ||||||||||
| 30 | NP_SLL_PROTOCOL_8021Q | ||||||||||
| 31 | NP_SLL_PROTOCOL_IPX | ||||||||||
| 32 | NP_SLL_PROTOCOL_STP | ||||||||||
| 33 | NP_SLL_PROTOCOL_IPv6 | ||||||||||
| 34 | NP_SLL_PROTOCOL_WLCCP | ||||||||||
| 35 | NP_SLL_PROTOCOL_PPPoED | ||||||||||
| 36 | NP_SLL_PROTOCOL_PPPoES | ||||||||||
| 37 | NP_SLL_PROTOCOL_8021x | ||||||||||
| 38 | NP_SLL_PROTOCOL_AoE | ||||||||||
| 39 | NP_SLL_PROTOCOL_80211i | ||||||||||
| 40 | NP_SLL_PROTOCOL_LLDP | ||||||||||
| 41 | NP_SLL_PROTOCOL_LOOP | ||||||||||
| 42 | NP_SLL_PROTOCOL_VLAN | ||||||||||
| 43 | NP_SLL_PROTOCOL_PPPPAP | ||||||||||
| 44 | NP_SLL_PROTOCOL_PPPCHAP | ||||||||||
| 45 | )], | ||||||||||
| 46 | ); | ||||||||||
| 47 | our @EXPORT_OK = ( | ||||||||||
| 48 | 2 | @{$EXPORT_TAGS{consts}}, | |||||||||
| 49 | ); | ||||||||||
| 50 | |||||||||||
| 51 | 2 | ▶ | use constant NP_SLL_HDR_LEN => 16; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 52 | 2 | ▶ | use constant NP_SLL_PACKET_TYPE_SENT_BY_US => 4; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 53 | 2 | ▶ | use constant NP_SLL_PACKET_TYPE_UNICAST_TO_US => 0; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 54 | 2 | ▶ | use constant NP_SLL_ADDRESS_TYPE_512 => 512; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 55 | 2 | ▶ | use constant NP_SLL_PROTOCOL_USER => 0x0000; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 56 | 2 | ▶ | use constant NP_SLL_PROTOCOL_IPv4 => 0x0800; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 57 | 2 | ▶ | use constant NP_SLL_PROTOCOL_X25 => 0x0805; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 58 | 2 | ▶ | use constant NP_SLL_PROTOCOL_ARP => 0x0806; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 59 | 2 | ▶ | use constant NP_SLL_PROTOCOL_CGMP => 0x2001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 60 | 2 | ▶ | use constant NP_SLL_PROTOCOL_80211 => 0x2452; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 61 | 2 | ▶ | use constant NP_SLL_PROTOCOL_PPPIPCP => 0x8021; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 62 | 2 | ▶ | use constant NP_SLL_PROTOCOL_RARP => 0x8035; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 63 | 2 | ▶ | use constant NP_SLL_PROTOCOL_DDP => 0x809b; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 64 | 2 | ▶ | use constant NP_SLL_PROTOCOL_AARP => 0x80f3; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 65 | 2 | ▶ | use constant NP_SLL_PROTOCOL_PPPCCP => 0x80fd; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 66 | 2 | ▶ | use constant NP_SLL_PROTOCOL_WCP => 0x80ff; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 67 | 2 | ▶ | use constant NP_SLL_PROTOCOL_8021Q => 0x8100; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 68 | 2 | ▶ | use constant NP_SLL_PROTOCOL_IPX => 0x8137; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 69 | 2 | ▶ | use constant NP_SLL_PROTOCOL_STP => 0x8181; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 70 | 2 | ▶ | use constant NP_SLL_PROTOCOL_IPv6 => 0x86dd; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 71 | 2 | ▶ | use constant NP_SLL_PROTOCOL_WLCCP => 0x872d; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 72 | 2 | ▶ | use constant NP_SLL_PROTOCOL_PPPoED => 0x8863; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 73 | 2 | ▶ | use constant NP_SLL_PROTOCOL_PPPoES => 0x8864; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 74 | 2 | ▶ | use constant NP_SLL_PROTOCOL_8021x => 0x888e; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 75 | 2 | ▶ | use constant NP_SLL_PROTOCOL_AoE => 0x88a2; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 76 | 2 | ▶ | use constant NP_SLL_PROTOCOL_80211i => 0x88c7; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 77 | 2 | ▶ | use constant NP_SLL_PROTOCOL_LLDP => 0x88cc; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 78 | 2 | ▶ | use constant NP_SLL_PROTOCOL_LOOP => 0x9000; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 79 | 2 | ▶ | use constant NP_SLL_PROTOCOL_VLAN => 0x9100; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 80 | 2 | ▶ | use constant NP_SLL_PROTOCOL_PPPPAP => 0xc023; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 81 | 2 | ▶ | use constant NP_SLL_PROTOCOL_PPPCHAP => 0xc223; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 82 | |||||||||||
| 83 | 2 | our @AS = qw( | |||||||||
| 84 | packetType | ||||||||||
| 85 | addressType | ||||||||||
| 86 | addressLength | ||||||||||
| 87 | source | ||||||||||
| 88 | protocol | ||||||||||
| 89 | ); | ||||||||||
| 90 | 2 | __PACKAGE__->cgBuildIndices; | |||||||||
| 91 | 2 | __PACKAGE__->cgBuildAccessorsScalar(\@AS); | |||||||||
| 92 | |||||||||||
| 93 | 2 | ▶ | no strict 'vars'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 94 | |||||||||||
| 95 | sub new { | ||||||||||
| 96 | shift->SUPER::new( | ||||||||||
| 97 | 1 | ▶ | packetType => NP_SLL_PACKET_TYPE_SENT_BY_US, | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 98 | addressType => NP_SLL_ADDRESS_TYPE_512, | ||||||||||
| 99 | addressLength => 0, | ||||||||||
| 100 | source => 0, | ||||||||||
| 101 | protocol => NP_SLL_PROTOCOL_IPv4, | ||||||||||
| 102 | @_, | ||||||||||
| 103 | ); | ||||||||||
| 104 | } | ||||||||||
| 105 | |||||||||||
| 106 | 0 | ▶ | sub getLength { NP_SLL_HDR_LEN } | ||||||||
|
Subroutine
getLength: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 107 | |||||||||||
| 108 | sub pack { | ||||||||||
| 109 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
pack: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 110 | |||||||||||
| 111 | 1 | ▶ | $self->[$__raw] = $self->SUPER::pack('nnnH16n', | ||||||||
|
Branch: 1 branch
| |||||||||||
| 112 | $self->[$__packetType], | ||||||||||
| 113 | $self->[$__addressType], | ||||||||||
| 114 | $self->[$__addressLength], | ||||||||||
| 115 | $self->[$__source], | ||||||||||
| 116 | $self->[$__protocol], | ||||||||||
| 117 | ) or return undef; | ||||||||||
| 118 | |||||||||||
| 119 | 1 | $self->[$__raw]; | |||||||||
| 120 | } | ||||||||||
| 121 | |||||||||||
| 122 | sub unpack { | ||||||||||
| 123 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
unpack: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 124 | |||||||||||
| 125 | 1 | ▶ | my ($pt, $at, $al, $s, $p, $payload) = | ||||||||
|
Branch: 1 branch
| |||||||||||
| 126 | $self->SUPER::unpack('nnnH16n a*', $self->[$__raw]) | ||||||||||
| 127 | or return undef; | ||||||||||
| 128 | |||||||||||
| 129 | 1 | $self->[$__packetType] = $pt; | |||||||||
| 130 | 1 | $self->[$__addressType] = $at; | |||||||||
| 131 | 1 | $self->[$__addressLength] = $al; | |||||||||
| 132 | 1 | $self->[$__source] = $s; | |||||||||
| 133 | 1 | $self->[$__protocol] = $p; | |||||||||
| 134 | 1 | $self->[$__payload] = $payload; | |||||||||
| 135 | |||||||||||
| 136 | 1 | $self; | |||||||||
| 137 | } | ||||||||||
| 138 | |||||||||||
| 139 | sub encapsulate { | ||||||||||
| 140 | 1 | ▶ | my $types = { | ||||||||
|
Subroutine
encapsulate: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||
| 141 | NP_SLL_PROTOCOL_IPv4() => 'IPv4', | ||||||||||
| 142 | NP_SLL_PROTOCOL_X25() => 'X25', | ||||||||||
| 143 | NP_SLL_PROTOCOL_ARP() => 'ARP', | ||||||||||
| 144 | NP_SLL_PROTOCOL_CGMP() => 'CGMP', | ||||||||||
| 145 | NP_SLL_PROTOCOL_80211() => '80211', | ||||||||||
| 146 | NP_SLL_PROTOCOL_PPPIPCP() => 'PPPIPCP', | ||||||||||
| 147 | NP_SLL_PROTOCOL_RARP() => 'RARP', | ||||||||||
| 148 | NP_SLL_PROTOCOL_DDP () => 'DDP', | ||||||||||
| 149 | NP_SLL_PROTOCOL_AARP() => 'AARP', | ||||||||||
| 150 | NP_SLL_PROTOCOL_PPPCCP() => 'PPPCCP', | ||||||||||
| 151 | NP_SLL_PROTOCOL_WCP() => 'WCP', | ||||||||||
| 152 | NP_SLL_PROTOCOL_8021Q() => '8021Q', | ||||||||||
| 153 | NP_SLL_PROTOCOL_IPX() => 'IPX', | ||||||||||
| 154 | NP_SLL_PROTOCOL_STP() => 'STP', | ||||||||||
| 155 | NP_SLL_PROTOCOL_IPv6() => 'IPv6', | ||||||||||
| 156 | NP_SLL_PROTOCOL_WLCCP() => 'WLCCP', | ||||||||||
| 157 | NP_SLL_PROTOCOL_PPPoED() => 'PPPoED', | ||||||||||
| 158 | NP_SLL_PROTOCOL_PPPoES() => 'PPPoES', | ||||||||||
| 159 | NP_SLL_PROTOCOL_8021x() => '8021x', | ||||||||||
| 160 | NP_SLL_PROTOCOL_AoE() => 'AoE', | ||||||||||
| 161 | NP_SLL_PROTOCOL_80211i() => '80211i', | ||||||||||
| 162 | NP_SLL_PROTOCOL_LLDP() => 'LLDP', | ||||||||||
| 163 | NP_SLL_PROTOCOL_LOOP() => 'LOOP', | ||||||||||
| 164 | NP_SLL_PROTOCOL_VLAN() => 'VLAN', | ||||||||||
| 165 | NP_SLL_PROTOCOL_PPPPAP() => 'PPPPAP', | ||||||||||
| 166 | NP_SLL_PROTOCOL_PPPCHAP() => 'PPPCHAP', | ||||||||||
| 167 | }; | ||||||||||
| 168 | |||||||||||
| 169 | 1 | ▶ | $types->{shift->[$__protocol]} || $self->[$__nextLayer]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 170 | } | ||||||||||
| 171 | |||||||||||
| 172 | sub print { | ||||||||||
| 173 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
print: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 174 | |||||||||||
| 175 | 1 | my $l = $self->layer; | |||||||||
| 176 | 1 | sprintf "$l: packetType:0x%04x addressType:0x%04x ". | |||||||||
| 177 | "addressLength:0x%04x\n". | ||||||||||
| 178 | "$l: source:%d protocol:0x%04x", | ||||||||||
| 179 | $self->[$__packetType], $self->[$__addressType], | ||||||||||
| 180 | $self->[$__addressLength], $self->[$__source], $self->[$__protocol]; | ||||||||||
| 181 | } | ||||||||||
| 182 | |||||||||||
| 183 | 2 | 1; | |||||||||
| 184 | |||||||||||
| 185 | __END__ | ||||||||||