blib/lib/LaBrea/Codes.pm untested

filter: Statementstmt 0.0% 0 / 28 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 51 CC 8 SCAR 26.2
CC
8
Cov
0%
protocol
20.0
icmp
20.0
numeric
6.0
CRAP 13.7
1 #
2 # DO NOT EDIT THIS FILE, CHANGES WILL BE LOST
3 #
4 # Created by Makefile.PL
5 # (IANA/build_codes.pl)
6 # from IANA/protocols
7 # and IANA/icmp
8 # Thu Nov 12 20:06:42 2026
9 #
10 package LaBrea::Codes;
11 use strict;
12 use vars qw($VERSION @ISA @EXPORT_OK %prot %pnum %icmp %inum );
13  
14 $VERSION = do { my @r = (q$Revision: 0.01 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
15  
16 require Exporter;
17 @ISA = qw(Exporter);
18 @EXPORT_OK = qw(
19 protocol
20 icmp
21 );
22  
23 =head1 NAME
24  
25 LaBrea::Tarpit::Codes
26  
27 =head1 SYNOPSIS
28  
29 use LaBrea::Tarpit::Codes qw (
30 protocol
31 icmp
32 numeric
33 );
34  
35 $text = protocol(number);
36 $number = protocol(text);
37 $text = icmp(number);
38 $number = icmp(text);
39 $rv = numeric(scalar);
40  
41 =head1 DESCRIPTION
42  
43 This module is built by B<Makefile.PL> from the text files
44 in the IANA subdirectory (copied from the IANA web site).
45  
46 Do not edit the Codes.pm file, changes will be lost.
47  
48 =over 4
49  
50 =item $rv = protocol($x);
51  
52 Returns the upper case text name of a protocol
53 number or the protocol number of a text name.
54  
55 i.e. 'TCP' = protocol(6);
56 6 = protocol('Tcp');
57 (not case sensitive)
58  
59 return -1 or 'unknown' if lookup value
60 is not present in table
61  
62 =cut
63
64 sub protocol {
65 if (numeric($_[0])) { # seeking numeric
66 my $v = uc $_[0];
67 return (exists $pnum{$v}) ? $pnum{$v} : -1;
68 } else { # seeking text
69 return (exists $prot{$_[0]}) ? $prot{$_[0]} : 'unknown';
70 }
71 }
72  
73 =item $rv = icmp($x);
74  
75 Returns the upper case text name of an icmp
76 number or the icmp number of the text name.
77  
78 i.e. 'ECHO' = icmp(8);
79 8 = icmp('EcHo');
80 (not case sensitive)
81  
82 return -1 or 'unknown' if lookup value
83 is not present in table
84  
85 =cut
86  
87 sub icmp {
88 if (numeric($_[0])) { # seeking numeric
89 my $v = uc $_[0];
90 return (exists $inum{$v}) ? $inum{$v} : -1;
91 } else { # seeking text
92 return (exists $icmp{$_[0]}) ? $icmp{$_[0]} : 'unknown';
93 }
94 }
95  
96 =item $rv = numeric(scalar);
97  
98 Return true if the scalar is a number
99 0,-n,+n
100 else
101 returns false
102  
103 =back
104  
105 =cut
106  
107 sub numeric {
108 return ($_[0] =~ /[^\d\-]/) ? 1:0;
109 }
110  
111 %prot = (
112 #
113 # Assigned Internet Protocol Numbers
114 #
115 # Decimal Keyword Protocol References
116 # ------- ------- -------- ----------
117 0 => 'HOPOPT', # IPv6 Hop-by-Hop Option [RFC1883]
118 1 => 'ICMP', # Internet Control Message [RFC792]
119 2 => 'IGMP', # Internet Group Management [RFC1112]
120 3 => 'GGP', # Gateway-to-Gateway [RFC823]
121 4 => 'IP', # IP in IP (encapsulation) [RFC2003]
122 5 => 'ST', # Stream [RFC1190,RFC1819]
123 6 => 'TCP', # Transmission Control [RFC793]
124 7 => 'CBT', # CBT [Ballardie]
125 8 => 'EGP', # Exterior Gateway Protocol [RFC888,DLM1]
126 # 9 IGP any private interior gateway [IANA]
127 # (used by Cisco for their IGRP)
128 10 => 'BBN-RCC-MON', # BBN RCC Monitoring [SGC]
129 11 => 'NVP-II', # Network Voice Protocol [RFC741,SC3]
130 12 => 'PUP', # PUP [PUP,XEROX]
131 13 => 'ARGUS', # ARGUS [RWS4]
132 14 => 'EMCON', # EMCON [BN7]
133 15 => 'XNET', # Cross Net Debugger [IEN158,JFH2]
134 16 => 'CHAOS', # Chaos [NC3]
135 17 => 'UDP', # User Datagram [RFC768,JBP]
136 18 => 'MUX', # Multiplexing [IEN90,JBP]
137 19 => 'DCN-MEAS', # DCN Measurement Subsystems [DLM1]
138 20 => 'HMP', # Host Monitoring [RFC869,RH6]
139 21 => 'PRM', # Packet Radio Measurement [ZSU]
140 22 => 'XNS-IDP', # XEROX NS IDP [ETHERNET,XEROX]
141 23 => 'TRUNK-1', # Trunk-1 [BWB6]
142 24 => 'TRUNK-2', # Trunk-2 [BWB6]
143 25 => 'LEAF-1', # Leaf-1 [BWB6]
144 26 => 'LEAF-2', # Leaf-2 [BWB6]
145 27 => 'RDP', # Reliable Data Protocol [RFC908,RH6]
146 28 => 'IRTP', # Internet Reliable Transaction [RFC938,TXM]
147 29 => 'ISO-TP4', # ISO Transport Protocol Class 4 [RFC905,RC77]
148 30 => 'NETBLT', # Bulk Data Transfer Protocol [RFC969,DDC1]
149 31 => 'MFE-NSP', # MFE Network Services Protocol [MFENET,BCH2]
150 32 => 'MERIT-INP', # MERIT Internodal Protocol [HWB]
151 33 => 'SEP', # Sequential Exchange Protocol [JC120]
152 34 => '3PC', # Third Party Connect Protocol [SAF3]
153 35 => 'IDPR', # Inter-Domain Policy Routing Protocol [MXS1]
154 36 => 'XTP', # XTP [GXC]
155 37 => 'DDP', # Datagram Delivery Protocol [WXC]
156 38 => 'IDPR-CMTP', # IDPR Control Message Transport Proto [MXS1]
157 39 => 'TP++', # TP++ Transport Protocol [DXF]
158 40 => 'IL', # IL Transport Protocol [Presotto]
159 41 => 'IPV6', # Ipv6 [Deering]
160 42 => 'SDRP', # Source Demand Routing Protocol [DXE1]
161 43 => 'IPV6-ROUTE', # Routing Header for IPv6 [Deering]
162 44 => 'IPV6-FRAG', # Fragment Header for IPv6 [Deering]
163 45 => 'IDRP', # Inter-Domain Routing Protocol [Sue Hares]
164 46 => 'RSVP', # Reservation Protocol [Bob Braden]
165 47 => 'GRE', # General Routing Encapsulation [Tony Li]
166 48 => 'MHRP', # Mobile Host Routing Protocol[David Johnson]
167 49 => 'BNA', # BNA [Gary Salamon]
168 50 => 'ESP', # Encapsulating Security Payload [RFC1827]
169 51 => 'AH', # Authentication Header [RFC1826]
170 52 => 'I-NLSP', # Integrated Net Layer Security TUBA [GLENN]
171 53 => 'SWIPE', # IP with Encryption [JI6]
172 54 => 'NARP', # NBMA Address Resolution Protocol [RFC1735]
173 55 => 'MOBILE', # IP Mobility [Perkins]
174 56 => 'TLSP', # Transport Layer Security Protocol [Oberg]
175 # using Kryptonet key management
176 57 => 'SKIP', # SKIP [Markson]
177 58 => 'IPV6-ICMP', # ICMP for IPv6 [RFC1883]
178 59 => 'IPV6-NONXT', # No Next Header for IPv6 [RFC1883]
179 60 => 'IPV6-OPTS', # Destination Options for IPv6 [RFC1883]
180 # 61 any host internal protocol [IANA]
181 62 => 'CFTP', # CFTP [CFTP,HCF2]
182 # 63 any local network [IANA]
183 64 => 'SAT-EXPAK', # SATNET and Backroom EXPAK [SHB]
184 65 => 'KRYPTOLAN', # Kryptolan [PXL1]
185 66 => 'RVD', # MIT Remote Virtual Disk Protocol [MBG]
186 67 => 'IPPC', # Internet Pluribus Packet Core [SHB]
187 # 68 any distributed file system [IANA]
188 69 => 'SAT-MON', # SATNET Monitoring [SHB]
189 70 => 'VISA', # VISA Protocol [GXT1]
190 71 => 'IPCV', # Internet Packet Core Utility [SHB]
191 72 => 'CPNX', # Computer Protocol Network Executive [DXM2]
192 73 => 'CPHB', # Computer Protocol Heart Beat [DXM2]
193 74 => 'WSN', # Wang Span Network [VXD]
194 75 => 'PVP', # Packet Video Protocol [SC3]
195 76 => 'BR-SAT-MON', # Backroom SATNET Monitoring [SHB]
196 77 => 'SUN-ND', # SUN ND PROTOCOL-Temporary [WM3]
197 78 => 'WB-MON', # WIDEBAND Monitoring [SHB]
198 79 => 'WB-EXPAK', # WIDEBAND EXPAK [SHB]
199 80 => 'ISO-IP', # ISO Internet Protocol [MTR]
200 81 => 'VMTP', # VMTP [DRC3]
201 82 => 'SECURE-VMTP', # SECURE-VMTP [DRC3]
202 83 => 'VINES', # VINES [BXH]
203 84 => 'TTP', # TTP [JXS]
204 85 => 'NSFNET-IGP', # NSFNET-IGP [HWB]
205 86 => 'DGP', # Dissimilar Gateway Protocol [DGP,ML109]
206 87 => 'TCF', # TCF [GAL5]
207 88 => 'EIGRP', # EIGRP [CISCO,GXS]
208 89 => 'OSPFIGP', # OSPFIGP [RFC1583,JTM4]
209 90 => 'SPRITE-RPC', # Sprite RPC Protocol [SPRITE,BXW]
210 91 => 'LARP', # Locus Address Resolution Protocol [BXH]
211 92 => 'MTP', # Multicast Transport Protocol [SXA]
212 93 => 'AX.25', # AX.25 Frames [BK29]
213 94 => 'IPIP', # IP-within-IP Encapsulation Protocol [JI6]
214 95 => 'MICP', # Mobile Internetworking Control Pro. [JI6]
215 96 => 'SCC-SP', # Semaphore Communications Sec. Pro. [HXH]
216 97 => 'ETHERIP', # Ethernet-within-IP Encapsulation [RDH1]
217 98 => 'ENCAP', # Encapsulation Header [RFC1241,RXB3]
218 # 99 any private encryption scheme [IANA]
219 100 => 'GMTP', # GMTP [RXB5]
220 101 => 'IFMP', # Ipsilon Flow Management Protocol [Hinden]
221 102 => 'PNNI', # PNNI over IP [Callon]
222 103 => 'PIM', # Protocol Independent Multicast [Farinacci]
223 104 => 'ARIS', # ARIS [Feldman]
224 105 => 'SCPS', # SCPS [Durst]
225 106 => 'QNX', # QNX [Hunter]
226 107 => 'A/N', # Active Networks [Braden]
227 108 => 'IPCOMP', # IP Payload Compression Protocol [RFC2393]
228 109 => 'SNP', # Sitara Networks Protocol [Sridhar]
229 110 => 'COMPAQ-PEER', # Compaq Peer Protocol [Volpe]
230 111 => 'IPX-IN-IP', # IPX in IP [Lee]
231 112 => 'VRRP', # Virtual Router Redundancy Protocol [Hinden]
232 113 => 'PGM', # PGM Reliable Transport Protocol [Speakman]
233 # 114 any 0-hop protocol [IANA]
234 115 => 'L2TP', # Layer Two Tunneling Protocol [Aboba]
235 116 => 'DDX', # D-II Data Exchange (DDX) [Worley]
236 117 => 'IATP', # Interactive Agent Transfer Protocol [Murphy]
237 118 => 'STP', # Schedule Transfer Protocol [JMP]
238 119 => 'SRP', # SpectraLink Radio Protocol [Hamilton]
239 120 => 'UTI', # UTI [Lothberg]
240 121 => 'SMP', # Simple Message Protocol [Ekblad]
241 122 => 'SM', # SM [Crowcroft]
242 123 => 'PTP', # Performance Transparency Protocol [Welzl]
243 124 => 'ISIS', # over IPv4 [Przygienda]
244 125 => 'FIRE', # [Partridge]
245 126 => 'CRTP', # Combat Radio Transport Protocol [Sautter]
246 127 => 'CRUDP', # Combat Radio User Datagram [Sautter]
247 128 => 'SSCOPMCE', # [Waber]
248 129 => 'IPLT', # [Hollbach]
249 130 => 'SPS', # Secure Packet Shield [McIntosh]
250 131 => 'PIPE', # Private IP Encapsulation within IP [Petri]
251 132 => 'SCTP', # Stream Control Transmission Protocol [Stewart]
252 133 => 'FC', # Fibre Channel [Rajagopal]
253 134 => 'RSVP-E2E-IGNORE', # [RFC3175]
254 # 135-254 Unassigned [IANA]
255 # 255 Reserved [IANA]
256 );
257 %pnum = reverse %prot;
258 %icmp = (
259 # NAME
260 # LaBrea::Tarpit::Codes
261 #
262 # SYNOPSIS
263 # use LaBrea::Tarpit::Codes qw (
264 # protocol
265 # icmp
266 # numeric
267 # );
268 #
269 # $text = protocol(number);
270 # $number = protocol(text);
271 # $text = icmp(number);
272 # $number = icmp(text);
273 # $rv = numeric(scalar);
274 #
275 # DESCRIPTION
276 # This module is built by Makefile.PL from the text files in the IANA
277 # subdirectory (copied from the IANA web site).
278 #
279 # Do not edit the Codes.pm file, changes will be lost.
280 #
281 # $rv = protocol($x);
282 # Returns the upper case text name of a protocol
283 # number or the protocol number of a text name.
284 #
285 # i.e. 'TCP' = protocol(6);
286 # 6 = protocol('Tcp');
287 # (not case sensitive)
288 #
289 # return -1 or 'unknown' if lookup value
290 # is not present in table
291 #
292 # $rv = icmp($x);
293 # Returns the upper case text name of an icmp
294 # number or the icmp number of the text name.
295 #
296 # i.e. 'ECHO' = icmp(8);
297 # 8 = icmp('EcHo');
298 # (not case sensitive)
299 #
300 # return -1 or 'unknown' if lookup value
301 # is not present in table
302 #
303 # $rv = numeric(scalar);
304 # Return true if the scalar is a number
305 # 0,-n,+n
306 # else
307 # returns false
308 #
309 # EXPORT
310 # None by default.
311 #
312 # COPYRIGHT
313 # Copyright 2002, Michael Robinton & BizSystems This program is free
314 # software; you can redistribute it and/or modify it under the terms of
315 # the GNU General Public License as published by the Free Software
316 # Foundation; either version 2 of the License, or (at your option) any
317 # later version.
318 #
319 # This program is distributed in the hope that it will be useful, but
320 # WITHOUT ANY WARRANTY; without even the implied warranty of
321 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
322 # Public License for more details.
323 #
324 # You should have received a copy of the GNU General Public License along
325 # with this program; if not, write to the Free Software Foundation, Inc.,
326 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
327 #
328 # AUTHOR
329 # Michael Robinton, michael@bizsystems.com
330 #
331 # SEE ALSO
332 # perl(1), LaBrea::Tarpit(3), LaBrea::Tarpit::Get(3),
333 # LaBrea::Tarpit::Report(3), LaBrea::Tarpit::Util(3),
334 # LaBrea::Tarpit::DShield(3)
335 #
336 # EOF
337 #
338 # close C;
339 #
340 );
341 %inum = reverse %icmp;
342  
343 1;
344 __END__