| 1 | # | ||||||||||||
| 2 | # $Id: SLL.pm,v ce68fbcc7f6d 2019/05/23 05:58:40 gomor $ | ||||||||||||
| 3 | # | ||||||||||||
| 4 | package Net::Frame::Layer::SLL; | ||||||||||||
| 5 | 3 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 3 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | 3 | ▶ | use Net::Frame::Layer qw(:consts); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 3 | require Exporter; | |||||||||||
| 10 | 3 | our @ISA = qw(Net::Frame::Layer Exporter); | |||||||||||
| 11 | |||||||||||||
| 12 | 3 | our %EXPORT_TAGS = ( | |||||||||||
| 13 | consts => [qw( | ||||||||||||
| 14 | NF_SLL_HDR_LEN | ||||||||||||
| 15 | NF_SLL_PACKET_TYPE_SENT_BY_US | ||||||||||||
| 16 | NF_SLL_PACKET_TYPE_UNICAST_TO_US | ||||||||||||
| 17 | NF_SLL_ADDRESS_TYPE_512 | ||||||||||||
| 18 | NF_SLL_PROTOCOL_IPv4 | ||||||||||||
| 19 | NF_SLL_PROTOCOL_X25 | ||||||||||||
| 20 | NF_SLL_PROTOCOL_ARP | ||||||||||||
| 21 | NF_SLL_PROTOCOL_CGMP | ||||||||||||
| 22 | NF_SLL_PROTOCOL_80211 | ||||||||||||
| 23 | NF_SLL_PROTOCOL_PPPIPCP | ||||||||||||
| 24 | NF_SLL_PROTOCOL_RARP | ||||||||||||
| 25 | NF_SLL_PROTOCOL_DDP | ||||||||||||
| 26 | NF_SLL_PROTOCOL_AARP | ||||||||||||
| 27 | NF_SLL_PROTOCOL_PPPCCP | ||||||||||||
| 28 | NF_SLL_PROTOCOL_WCP | ||||||||||||
| 29 | NF_SLL_PROTOCOL_8021Q | ||||||||||||
| 30 | NF_SLL_PROTOCOL_IPX | ||||||||||||
| 31 | NF_SLL_PROTOCOL_STP | ||||||||||||
| 32 | NF_SLL_PROTOCOL_IPv6 | ||||||||||||
| 33 | NF_SLL_PROTOCOL_WLCCP | ||||||||||||
| 34 | NF_SLL_PROTOCOL_MPLS | ||||||||||||
| 35 | NF_SLL_PROTOCOL_PPPoED | ||||||||||||
| 36 | NF_SLL_PROTOCOL_PPPoES | ||||||||||||
| 37 | NF_SLL_PROTOCOL_8021X | ||||||||||||
| 38 | NF_SLL_PROTOCOL_AoE | ||||||||||||
| 39 | NF_SLL_PROTOCOL_80211I | ||||||||||||
| 40 | NF_SLL_PROTOCOL_LLDP | ||||||||||||
| 41 | NF_SLL_PROTOCOL_LLTD | ||||||||||||
| 42 | NF_SLL_PROTOCOL_LOOP | ||||||||||||
| 43 | NF_SLL_PROTOCOL_VLAN | ||||||||||||
| 44 | NF_SLL_PROTOCOL_PPPPAP | ||||||||||||
| 45 | NF_SLL_PROTOCOL_PPPCHAP | ||||||||||||
| 46 | )], | ||||||||||||
| 47 | ); | ||||||||||||
| 48 | our @EXPORT_OK = ( | ||||||||||||
| 49 | 3 | @{$EXPORT_TAGS{consts}}, | |||||||||||
| 50 | ); | ||||||||||||
| 51 | |||||||||||||
| 52 | 3 | ▶ | use constant NF_SLL_HDR_LEN => 16; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 53 | 3 | ▶ | use constant NF_SLL_PACKET_TYPE_SENT_BY_US => 4; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 54 | 3 | ▶ | use constant NF_SLL_PACKET_TYPE_UNICAST_TO_US => 0; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 55 | 3 | ▶ | use constant NF_SLL_ADDRESS_TYPE_512 => 512; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 56 | 3 | ▶ | use constant NF_SLL_PROTOCOL_IPv4 => 0x0800; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 57 | 3 | ▶ | use constant NF_SLL_PROTOCOL_X25 => 0x0805; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 58 | 3 | ▶ | use constant NF_SLL_PROTOCOL_ARP => 0x0806; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 59 | 3 | ▶ | use constant NF_SLL_PROTOCOL_CGMP => 0x2001; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 60 | 3 | ▶ | use constant NF_SLL_PROTOCOL_80211 => 0x2452; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 61 | 3 | ▶ | use constant NF_SLL_PROTOCOL_PPPIPCP => 0x8021; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 62 | 3 | ▶ | use constant NF_SLL_PROTOCOL_RARP => 0x8035; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 63 | 3 | ▶ | use constant NF_SLL_PROTOCOL_DDP => 0x809b; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 64 | 3 | ▶ | use constant NF_SLL_PROTOCOL_AARP => 0x80f3; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 65 | 3 | ▶ | use constant NF_SLL_PROTOCOL_PPPCCP => 0x80fd; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 66 | 3 | ▶ | use constant NF_SLL_PROTOCOL_WCP => 0x80ff; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 67 | 3 | ▶ | use constant NF_SLL_PROTOCOL_8021Q => 0x8100; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 68 | 3 | ▶ | use constant NF_SLL_PROTOCOL_IPX => 0x8137; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 69 | 3 | ▶ | use constant NF_SLL_PROTOCOL_STP => 0x8181; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 70 | 3 | ▶ | use constant NF_SLL_PROTOCOL_IPv6 => 0x86dd; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 71 | 3 | ▶ | use constant NF_SLL_PROTOCOL_WLCCP => 0x872d; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 72 | 3 | ▶ | use constant NF_SLL_PROTOCOL_MPLS => 0x8847; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 73 | 3 | ▶ | use constant NF_SLL_PROTOCOL_PPPoED => 0x8863; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 74 | 3 | ▶ | use constant NF_SLL_PROTOCOL_PPPoES => 0x8864; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 75 | 3 | ▶ | use constant NF_SLL_PROTOCOL_8021X => 0x888e; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 76 | 3 | ▶ | use constant NF_SLL_PROTOCOL_AoE => 0x88a2; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 77 | 3 | ▶ | use constant NF_SLL_PROTOCOL_80211I => 0x88c7; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 78 | 3 | ▶ | use constant NF_SLL_PROTOCOL_LLDP => 0x88cc; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 79 | 3 | ▶ | use constant NF_SLL_PROTOCOL_LLTD => 0x88d9; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 80 | 3 | ▶ | use constant NF_SLL_PROTOCOL_LOOP => 0x9000; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 81 | 3 | ▶ | use constant NF_SLL_PROTOCOL_VLAN => 0x9100; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 82 | 3 | ▶ | use constant NF_SLL_PROTOCOL_PPPPAP => 0xc023; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 83 | 3 | ▶ | use constant NF_SLL_PROTOCOL_PPPCHAP => 0xc223; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 84 | |||||||||||||
| 85 | 3 | our @AS = qw( | |||||||||||
| 86 | packetType | ||||||||||||
| 87 | addressType | ||||||||||||
| 88 | addressLength | ||||||||||||
| 89 | source | ||||||||||||
| 90 | protocol | ||||||||||||
| 91 | ); | ||||||||||||
| 92 | 3 | __PACKAGE__->cgBuildIndices; | |||||||||||
| 93 | 3 | __PACKAGE__->cgBuildAccessorsScalar(\@AS); | |||||||||||
| 94 | |||||||||||||
| 95 | 3 | ▶ | no strict 'vars'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 96 | |||||||||||||
| 97 | 1 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 98 | shift->SUPER::new( | ||||||||||||
| 99 | 1 | packetType => NF_SLL_PACKET_TYPE_SENT_BY_US, | |||||||||||
| 100 | addressType => NF_SLL_ADDRESS_TYPE_512, | ||||||||||||
| 101 | addressLength => 0, | ||||||||||||
| 102 | source => 0, | ||||||||||||
| 103 | protocol => NF_SLL_PROTOCOL_IPv4, | ||||||||||||
| 104 | @_, | ||||||||||||
| 105 | ); | ||||||||||||
| 106 | } | ||||||||||||
| 107 | |||||||||||||
| 108 | 0 | ▶ | sub getLength { NF_SLL_HDR_LEN } | ||||||||||
|
Subroutine
getLength: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 109 | |||||||||||||
| 110 | 1 | ▶ | sub pack { | ||||||||||
|
Subroutine
pack: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||
| 111 | 1 | my $self = shift; | |||||||||||
| 112 | |||||||||||||
| 113 | 1 | ▶ | $self->[$__raw] = $self->SUPER::pack('nnnH16n', | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 114 | $self->[$__packetType], | ||||||||||||
| 115 | $self->[$__addressType], | ||||||||||||
| 116 | $self->[$__addressLength], | ||||||||||||
| 117 | $self->[$__source], | ||||||||||||
| 118 | $self->[$__protocol], | ||||||||||||
| 119 | ) or return undef; | ||||||||||||
| 120 | |||||||||||||
| 121 | 1 | $self->[$__raw]; | |||||||||||
| 122 | } | ||||||||||||
| 123 | |||||||||||||
| 124 | 1 | ▶ | sub unpack { | ||||||||||
|
Subroutine
unpack: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||
| 125 | 1 | my $self = shift; | |||||||||||
| 126 | |||||||||||||
| 127 | 1 | ▶ | my ($pt, $at, $al, $s, $p, $payload) = | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 128 | $self->SUPER::unpack('nnnH16n a*', $self->[$__raw]) | ||||||||||||
| 129 | or return undef; | ||||||||||||
| 130 | |||||||||||||
| 131 | 1 | $self->[$__packetType] = $pt; | |||||||||||
| 132 | 1 | $self->[$__addressType] = $at; | |||||||||||
| 133 | 1 | $self->[$__addressLength] = $al; | |||||||||||
| 134 | 1 | $self->[$__source] = $s; | |||||||||||
| 135 | 1 | $self->[$__protocol] = $p; | |||||||||||
| 136 | 1 | $self->[$__payload] = $payload; | |||||||||||
| 137 | |||||||||||||
| 138 | 1 | $self; | |||||||||||
| 139 | } | ||||||||||||
| 140 | |||||||||||||
| 141 | 3 | our $Next = { | |||||||||||
| 142 | NF_SLL_PROTOCOL_IPv4() => 'IPv4', | ||||||||||||
| 143 | NF_SLL_PROTOCOL_X25() => 'X25', | ||||||||||||
| 144 | NF_SLL_PROTOCOL_ARP() => 'ARP', | ||||||||||||
| 145 | NF_SLL_PROTOCOL_CGMP() => 'CGMP', | ||||||||||||
| 146 | NF_SLL_PROTOCOL_80211() => '80211', | ||||||||||||
| 147 | NF_SLL_PROTOCOL_PPPIPCP() => 'PPPIPCP', | ||||||||||||
| 148 | NF_SLL_PROTOCOL_RARP() => 'RARP', | ||||||||||||
| 149 | NF_SLL_PROTOCOL_DDP () => 'DDP', | ||||||||||||
| 150 | NF_SLL_PROTOCOL_AARP() => 'AARP', | ||||||||||||
| 151 | NF_SLL_PROTOCOL_PPPCCP() => 'PPPCCP', | ||||||||||||
| 152 | NF_SLL_PROTOCOL_WCP() => 'WCP', | ||||||||||||
| 153 | NF_SLL_PROTOCOL_8021Q() => '8021Q', | ||||||||||||
| 154 | NF_SLL_PROTOCOL_IPX() => 'IPX', | ||||||||||||
| 155 | NF_SLL_PROTOCOL_STP() => 'STP', | ||||||||||||
| 156 | NF_SLL_PROTOCOL_IPv6() => 'IPv6', | ||||||||||||
| 157 | NF_SLL_PROTOCOL_WLCCP() => 'WLCCP', | ||||||||||||
| 158 | NF_SLL_PROTOCOL_MPLS() => 'MPLS', | ||||||||||||
| 159 | NF_SLL_PROTOCOL_PPPoED() => 'PPPoED', | ||||||||||||
| 160 | NF_SLL_PROTOCOL_PPPoES() => 'PPPoES', | ||||||||||||
| 161 | NF_SLL_PROTOCOL_8021X() => '8021X', | ||||||||||||
| 162 | NF_SLL_PROTOCOL_AoE() => 'AoE', | ||||||||||||
| 163 | NF_SLL_PROTOCOL_80211I() => '80211I', | ||||||||||||
| 164 | NF_SLL_PROTOCOL_LLDP() => 'LLDP', | ||||||||||||
| 165 | NF_SLL_PROTOCOL_LLTD() => 'LLTD', | ||||||||||||
| 166 | NF_SLL_PROTOCOL_LOOP() => 'LOOP', | ||||||||||||
| 167 | NF_SLL_PROTOCOL_VLAN() => 'VLAN', | ||||||||||||
| 168 | NF_SLL_PROTOCOL_PPPPAP() => 'PPPPAP', | ||||||||||||
| 169 | NF_SLL_PROTOCOL_PPPCHAP() => 'PPPCHAP', | ||||||||||||
| 170 | }; | ||||||||||||
| 171 | |||||||||||||
| 172 | 1 | ▶ | sub encapsulate { | ||||||||||
|
Subroutine
encapsulate: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||
| 173 | 1 | my $self = shift; | |||||||||||
| 174 | |||||||||||||
| 175 | 1 | ▶ | return $self->[$__nextLayer] if $self->[$__nextLayer]; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 176 | |||||||||||||
| 177 | 1 | ▶ | return $Next->{$self->[$__protocol]} || NF_LAYER_UNKNOWN; | ||||||||||
|
Condition50%1/2
$$Next{$self->[$__protocol]} || 1
MC/DC0%0/1
$$Next{$self->[$__protocol]} || 1
$$Next{$self->[$__protocol]}
Truth table50%1/2
A
A= $$Next{$self->[$__protocol]}
| |||||||||||||
| 178 | } | ||||||||||||
| 179 | |||||||||||||
| 180 | 1 | ▶ | sub print { | ||||||||||
|
Subroutine
print: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 181 | 1 | my $self = shift; | |||||||||||
| 182 | |||||||||||||
| 183 | 1 | my $l = $self->layer; | |||||||||||
| 184 | 1 | sprintf "$l: packetType:0x%04x addressType:0x%04x ". | |||||||||||
| 185 | "addressLength:0x%04x\n". | ||||||||||||
| 186 | "$l: source:%d protocol:0x%04x", | ||||||||||||
| 187 | $self->[$__packetType], $self->[$__addressType], | ||||||||||||
| 188 | $self->[$__addressLength], $self->[$__source], $self->[$__protocol]; | ||||||||||||
| 189 | } | ||||||||||||
| 190 | |||||||||||||
| 191 | 3 | 1; | |||||||||||
| 192 | |||||||||||||
| 193 | __END__ | ||||||||||||