This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix Compress::Zlib test boilerplate
[perl5.git] / t / op / getprotobynumber.t
CommitLineData
aa4405f1
SS
1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6 require './test.pl';
7}
8
9my (%default_test, %protos, %test);
10
11%default_test = map { $_ => 1 } sort keys %protos;
12
13if ($^O eq 'MacOS') {
14 %test = %default_test;
15} elsif ($^O eq 'MSWin32') {
16 %test = map { $_ => 1 } (0,1,3,6,8,12,17,20,22,27,66);
17 $protos{0}[1] = 'IP';
18} elsif ($^O eq 'NetWare') {
19 %test = %default_test;
20} elsif ($^O eq 'VMS') {
21 %test = %default_test;
22} else {
23 %test = %default_test;
24}
25
26plan tests => scalar (keys %test) * 2;
27
28for my $number (sort {$a <=> $b} keys %protos) {
29 next unless exists $test{$number};
30 my ($name, $alias) = getprotobynumber($number);
31 is($name, $protos{$number}[0], "getprotobynumber($number) returned name ($name)");
32 is($alias, $protos{$number}[1], "getprotobynumber($number) returned alias ($alias)");
33}
34
35BEGIN {
36 %protos = (
37 0 => ['ip', 'IP HOPOPT'],
38 1 => [qw(icmp ICMP)],
39 2 => [qw(igmp IGMP)],
40 3 => [qw(ggp GGP)],
41 4 => [qw(ipencap IP-ENCAP)],
42 5 => [qw(st ST)],
43 6 => [qw(tcp TCP)],
44 7 => ['ucl', 'UCL CBT'],
45 8 => [qw(egp EGP)],
46 9 => [qw(igp IGP)],
47 10 => [qw(bbn-rcc-mon BBN-RCC-MON)],
48 11 => [qw(nvp-ii NVP-II)],
49 12 => [qw(pup PUP)],
50 13 => [qw(argus ARGUS)],
51 14 => [qw(emcon EMCON)],
52 15 => [qw(xnet XNET)],
53 16 => [qw(chaos CHAOS)],
54 17 => [qw(udp UDP)],
55 18 => [qw(mux MUX)],
56 19 => [qw(dcn-meas DCN-MEAS)],
57 20 => [qw(hmp HMP)],
58 21 => [qw(prm PRM)],
59 22 => [qw(xns-idp XNS-IDP)],
60 23 => [qw(trunk-1 TRUNK-1)],
61 24 => [qw(trunk-2 TRUNK-2)],
62 25 => [qw(leaf-1 LEAF-1)],
63 26 => [qw(leaf-2 LEAF-2)],
64 27 => [qw(rdp RDP)],
65 28 => [qw(irtp IRTP)],
66 29 => [qw(iso-tp4 ISO-TP4)],
67 30 => [qw(netblt NETBLT)],
68 31 => [qw(mfe-nsp MFE-NSP)],
69 32 => [qw(merit-inp MERIT-INP)],
70 33 => [qw(sep SEP)],
71 34 => [qw(3pc 3PC)],
72 35 => [qw(idpr IDPR)],
73 36 => [qw(xtp XTP)],
74 37 => [qw(ddp DDP)],
75 38 => [qw(idpr-cmtp IDPR-CMTP)],
76 39 => [qw(tp++ TP++)],
77 40 => [qw(il IL)],
78 41 => [qw(ipv6 IPv6)],
79 42 => [qw(sdrp SDRP)],
80 43 => [qw(sip-sr SIP-SR)],
81 44 => [qw(sip-frag SIP-FRAG)],
82 45 => [qw(idrp IDRP)],
83 46 => [qw(rsvp RSVP)],
84 47 => [qw(gre GRE)],
85 48 => [qw(mhrp MHRP)],
86 49 => [qw(bna BNA)],
87 50 => ['esp', 'IPSEC-ESP ESP'],
88 51 => ['ah', 'IPSEC-AH AH'],
89 52 => [qw(i-nlsp I-NLSP)],
90 53 => [qw(swipe SWIPE)],
91 54 => ['nhrp', 'NHRP NARP'],
92 55 => ['mobileip', 'MOBILEIP MOBILE'],
93 57 => [qw(skip SKIP)],
94 58 => ['ipv6-icmp', 'IPv6-ICMP icmp6'],
95 59 => [qw(ipv6-nonxt IPv6-NoNxt)],
96 60 => [qw(ipv6-opts IPv6-Opts)],
97 61 => [qw(any any)],
98 62 => [qw(cftp CFTP)],
99 63 => [qw(any any)],
100 64 => [qw(sat-expak SAT-EXPAK)],
101 65 => [qw(kryptolan KRYPTOLAN)],
102 66 => [qw(rvd RVD)],
103 67 => [qw(ippc IPPC)],
104 68 => [qw(any any)],
105 69 => [qw(sat-mon SAT-MON)],
106 70 => [qw(visa VISA)],
107 71 => [qw(ipcv IPCV)],
108 72 => [qw(cpnx CPNX)],
109 73 => [qw(cphb CPHB)],
110 74 => [qw(wsn WSN)],
111 75 => [qw(pvp PVP)],
112 76 => [qw(br-sat-mon BR-SAT-MON)],
113 77 => [qw(sun-nd SUN-ND)],
114 78 => [qw(wb-mon WB-MON)],
115 79 => [qw(wb-expak WB-EXPAK)],
116 80 => [qw(iso-ip ISO-IP)],
117 81 => [qw(vmtp VMTP)],
118 82 => [qw(secure-vmtp SECURE-VMTP)],
119 83 => [qw(vines VINES)],
120 84 => [qw(ttp TTP)],
121 85 => [qw(nsfnet-igp NSFNET-IGP)],
122 86 => [qw(dgp DGP)],
123 87 => [qw(tcf TCF)],
124 88 => ['igrp', 'IGRP EIGRP'],
125 89 => [qw(ospf OSPFIGP)],
126 90 => [qw(sprite-rpc Sprite-RPC)],
127 91 => [qw(larp LARP)],
128 92 => [qw(mtp MTP)],
129 93 => [qw(ax.25 AX.25)],
130 94 => [qw(ipip IPIP)],
131 95 => [qw(micp MICP)],
132 96 => [qw(scc-sp SCC-SP)],
133 97 => [qw(etherip ETHERIP)],
134 98 => [qw(encap ENCAP)],
135 99 => [qw(any any)],
136 100 => [qw(gmtp GMTP)],
137 101 => [qw(ifmp IFMP)],
138 102 => [qw(pnni PNNI)],
139 103 => [qw(pim PIM)],
140 104 => [qw(aris ARIS)],
141 105 => [qw(scps SCPS)],
142 106 => [qw(qnx QNX)],
143 107 => [qw(a/n A/N)],
144 108 => [qw(ipcomp IPComp)],
145 109 => [qw(snp SNP)],
146 110 => [qw(compaq-peer Compaq-Peer)],
147 111 => [qw(ipx-in-ip IPX-in-IP)],
148 112 => ['carp', 'CARP vrrp'],
149 113 => [qw(pgm PGM)],
150 115 => [qw(l2tp L2TP)],
151 116 => [qw(ddx DDX)],
152 117 => [qw(iatp IATP)],
153 118 => [qw(stp STP)],
154 119 => [qw(srp SRP)],
155 120 => [qw(uti UTI)],
156 121 => [qw(smp SMP)],
157 122 => [qw(sm SM)],
158 123 => [qw(ptp PTP)],
159 124 => [qw(isis ISIS)],
160 125 => [qw(fire FIRE)],
161 126 => [qw(crtp CRTP)],
162 127 => [qw(crudp CRUDP)],
163 128 => [qw(sscopmce SSCOPMCE)],
164 129 => [qw(iplt IPLT)],
165 130 => [qw(sps SPS)],
166 131 => [qw(pipe PIPE)],
167 132 => [qw(sctp SCTP)],
168 133 => [qw(fc FC)],
169 134 => [qw(rsvp-e2e-ignore RSVP-E2E-IGNORE)],
170 240 => [qw(pfsync PFSYNC)],
171 255 => [qw(reserved Reserved)]);
172}