calclulate IP addresses hash only from masked part of address
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / util / HashUtil.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.openflowplugin.impl.util;
10
11 import java.math.BigInteger;
12 import java.util.StringTokenizer;
13
14 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
15 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
16 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpVersion;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
20 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
21 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
22 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddress;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddress;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestination;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSource;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetType;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6Match;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer4Match;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagMatch;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatch;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4Match;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.Pbb;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId;
51 import org.slf4j.Logger;
52 import org.slf4j.LoggerFactory;
53
54 /**
55  * Created by Martin Bobak <mbobak@cisco.com> on 8.4.2015.
56  */
57 public final class HashUtil {
58
59     private static final Logger LOG = LoggerFactory.getLogger(HashUtil.class);
60     private static final int BASE_16 = 16;
61     private static final int BASE_10 = 10;
62     private static final int IPV6_TOKENS_COUNT = 8;
63     public static final String IPV6_TOKEN = ":0000";
64
65     private HashUtil() {
66
67         throw new IllegalStateException("This class should not be instantiated.");
68     }
69
70     public static int calculateEthernetMatchHash(EthernetMatch ethernetMatch) {
71         int hash = 0;
72
73         EthernetType ethernetType = ethernetMatch.getEthernetType();
74         if (null != ethernetType) {
75             hash += ethernetType.getType().getValue();
76         }
77
78         EthernetDestination ethernetDestination = ethernetMatch.getEthernetDestination();
79         if (null != ethernetDestination) {
80             hash += calculateEthernetDestinationHash(ethernetDestination);
81         }
82
83         EthernetSource ethernetSource = ethernetMatch.getEthernetSource();
84         if (null != ethernetSource) {
85             hash += calculateEthenetSourceHash(ethernetSource);
86         }
87
88         return hash;
89     }
90
91     public static int calculateEthenetSourceHash(EthernetSource ethernetSource) {
92         int hash = calculateMacAddressHash(ethernetSource.getAddress());
93         hash += calculateMacAddressHash(ethernetSource.getMask());
94         return hash;
95     }
96
97     public static int calculateEthernetDestinationHash(EthernetDestination ethernetDestination) {
98         int hash = calculateMacAddressHash(ethernetDestination.getAddress());
99         hash += calculateMacAddressHash(ethernetDestination.getMask());
100         return hash;
101     }
102
103     public static int calculateMacAddressHash(MacAddress macAddress) {
104
105         int hash = 0;
106         if (null != macAddress) {
107             StringTokenizer stringTokenizer = new StringTokenizer(macAddress.getValue(), ":");
108             hash = parseTokens(stringTokenizer, BASE_16);
109         }
110         LOG.trace("Calculated hash {} for mac {}", hash, macAddress);
111         return hash;
112     }
113
114     public static int calculateMatchHash(final Match match, DeviceContext deviceContext) {
115         int hash = 0;
116         int subHash = 0;
117         int base = 0;
118         if (null != match) {
119             if (null != match.getEthernetMatch()) {
120                 hash = 1 << base;
121                 subHash += calculateEthernetMatchHash(match.getEthernetMatch());
122             }
123             base++;
124             if (null != match.getIcmpv4Match()) {
125                 hash = 1 << base;
126                 subHash += calculateIcmpV4MatchHash(match.getIcmpv4Match());
127             }
128             base++;
129             if (null != match.getIcmpv6Match()) {
130                 hash = 1 << base;
131                 subHash += calculateIcmpV6MatchHash(match.getIcmpv6Match());
132             }
133             base++;
134             if (null != match.getInPhyPort()) {
135                 hash = 1 << base;
136                 subHash += calculateNodeConnectorIdHash(match.getInPhyPort(), deviceContext);
137             }
138             base++;
139             if (null != match.getInPort()) {
140                 hash = 1 << base;
141                 subHash += calculateNodeConnectorIdHash(match.getInPort(), deviceContext);
142             }
143             base++;
144             if (null != match.getIpMatch()) {
145                 hash = 1 << base;
146                 subHash += calculateIpMatchHash(match.getIpMatch());
147             }
148             base++;
149             if (null != match.getLayer3Match()) {
150                 hash = 1 << base;
151                 subHash += calculateLayer3MatchHash(match.getLayer3Match());
152             }
153             base++;
154             if (null != match.getLayer4Match()) {
155                 hash = 1 << base;
156                 subHash += calculateLayer4MatchHash(match.getLayer4Match());
157             }
158             base++;
159             if (null != match.getIcmpv6Match()) {
160                 hash = 1 << base;
161                 subHash += calculateIcmpv6MatchHash(match.getIcmpv6Match());
162             }
163             base++;
164             if (null != match.getMetadata()) {
165                 hash = 1 << base;
166                 subHash += calculateMetadataHash(match.getMetadata());
167             }
168             base++;
169             if (null != match.getProtocolMatchFields()) {
170                 hash = 1 << base;
171                 subHash += calculateProtocolMatchFieldsHash(match.getProtocolMatchFields());
172             }
173             base++;
174             if (null != match.getTcpFlagMatch()) {
175                 hash = 1 << base;
176                 subHash += calculateTcpFlagMatch(match.getTcpFlagMatch());
177             }
178             base++;
179             if (null != match.getVlanMatch()) {
180                 hash = 1 << base;
181                 subHash += calculateVlanMatchHash(match.getVlanMatch());
182             }
183             base++;
184             if (null != match.getTunnel()) {
185                 hash = 1 << base;
186                 subHash += calculateTunnelHash(match.getTunnel());
187             }
188         }
189         return hash + subHash;
190     }
191
192     private static int calculateTunnelHash(final Tunnel tunnel) {
193         int hash = 0;
194         BigInteger tunnelId = tunnel.getTunnelId();
195         if (null != tunnelId) {
196             hash += tunnelId.intValue();
197         }
198
199         BigInteger tunnelMask = tunnel.getTunnelMask();
200         if (null != tunnelMask) {
201             hash += tunnelMask.intValue();
202         }
203         return hash;
204     }
205
206     private static int calculateVlanMatchHash(final VlanMatch vlanMatch) {
207         int hash = 0;
208
209         VlanId vlanId = vlanMatch.getVlanId();
210         if (null != vlanId) {
211             hash += vlanId.getVlanId().getValue().intValue();
212         }
213
214         VlanPcp vlanPcp = vlanMatch.getVlanPcp();
215         if (null != vlanPcp) {
216             hash += vlanPcp.getValue().shortValue();
217         }
218
219         return hash;
220     }
221
222     private static int calculateTcpFlagMatch(final TcpFlagMatch tcpFlagMatch) {
223         int hash = tcpFlagMatch.getTcpFlag().intValue();
224         return hash;
225     }
226
227     private static int calculateProtocolMatchFieldsHash(final ProtocolMatchFields protocolMatchFields) {
228         int hash = 0;
229         Short mplsBos = protocolMatchFields.getMplsBos();
230         if (null != mplsBos) {
231             hash += mplsBos.intValue();
232         }
233         Short mplsTc = protocolMatchFields.getMplsTc();
234         if (null != mplsTc) {
235             hash += mplsTc.intValue();
236         }
237         Pbb pbb = protocolMatchFields.getPbb();
238         if (null != pbb) {
239             if (null != pbb.getPbbIsid()) {
240                 hash += pbb.getPbbIsid().intValue();
241             }
242             if (null != pbb.getPbbMask()) {
243                 hash += pbb.getPbbMask().intValue();
244             }
245         }
246         Long mplsLabel = protocolMatchFields.getMplsLabel();
247         if (null != mplsLabel) {
248             hash += mplsLabel.intValue();
249         }
250         return hash;
251     }
252
253     private static int calculateMetadataHash(final Metadata metadata) {
254         int hash = metadata.getMetadata().intValue();
255         hash += metadata.getMetadataMask().intValue();
256         return hash;
257     }
258
259     private static int calculateIcmpv6MatchHash(final Icmpv6Match icmpv6Match) {
260         int hash = icmpv6Match.getIcmpv6Code().intValue();
261         hash += icmpv6Match.getIcmpv6Type().intValue();
262         return hash;
263     }
264
265     private static int calculateLayer4MatchHash(final Layer4Match layer4Match) {
266         int hash = 0;
267         if (layer4Match instanceof SctpMatch) {
268             hash += calculateSctpMatchHash((SctpMatch) layer4Match);
269         }
270
271         if (layer4Match instanceof TcpMatch) {
272             hash += calculateTcpMatchHash((TcpMatch) layer4Match);
273         }
274         if (layer4Match instanceof UdpMatch) {
275             hash += calculateUdpMatchHash((UdpMatch) layer4Match);
276         }
277         return hash;
278     }
279
280     private static int calculateUdpMatchHash(final UdpMatch layer4Match) {
281         int hash = 0;
282         return hash;
283     }
284
285     private static int calculateTcpMatchHash(final TcpMatch layer4Match) {
286         int hash = 0;
287         PortNumber sourcePort = layer4Match.getTcpSourcePort();
288         if (null != sourcePort) {
289             hash += sourcePort.getValue().intValue();
290         }
291
292         PortNumber destinationPort = layer4Match.getTcpDestinationPort();
293         if (null != destinationPort) {
294             hash += destinationPort.getValue().intValue();
295         }
296         return hash;
297     }
298
299     private static int calculateSctpMatchHash(final SctpMatch layer4Match) {
300         int hash = 0;
301
302         PortNumber portNumber = layer4Match.getSctpDestinationPort();
303         if (null != portNumber) {
304             hash += portNumber.getValue().intValue();
305         }
306
307         PortNumber sourcePort = layer4Match.getSctpSourcePort();
308         if (null != sourcePort) {
309             hash += sourcePort.getValue().intValue();
310         }
311         return hash;
312     }
313
314     private static int calculateLayer3MatchHash(final Layer3Match layer3Match) {
315         int hash = 0;
316         if (layer3Match instanceof ArpMatch) {
317             hash += calculateArpMatchHash((ArpMatch) layer3Match);
318         }
319         if (layer3Match instanceof Ipv4Match) {
320             hash += calculateIpv4MatchHash((Ipv4Match) layer3Match);
321         }
322         if (layer3Match instanceof Ipv6Match) {
323             hash += calculateIpv6MatchHash((Ipv6Match) layer3Match);
324
325         }
326         if (layer3Match instanceof TunnelIpv4Match) {
327             hash += calculateTunnelIpv4Hash((TunnelIpv4Match) layer3Match);
328         }
329         return hash;
330     }
331
332     private static int calculateTunnelIpv4Hash(final TunnelIpv4Match layer3Match) {
333         Ipv4Prefix tunnelIpv4Destination = layer3Match.getTunnelIpv4Destination();
334         int hash = calculateIpv4PrefixHash(tunnelIpv4Destination);
335         Ipv4Prefix tunnelIpv4Source = layer3Match.getTunnelIpv4Source();
336         hash += calculateIpv4PrefixHash(tunnelIpv4Source);
337         return hash;
338     }
339
340     private static int calculateIpv6MatchHash(final Ipv6Match layer3Match) {
341         int hash = 0;
342         Ipv6Prefix ipv6Destination = layer3Match.getIpv6Destination();
343         if (null != ipv6Destination) {
344             hash += calculateIpv6PrefixHash(ipv6Destination);
345         }
346
347         if (null != layer3Match.getIpv6Source()) {
348             hash += calculateIpv6PrefixHash(layer3Match.getIpv6Source());
349         }
350
351         if (null != layer3Match.getIpv6ExtHeader()) {
352             hash += layer3Match.getIpv6ExtHeader().getIpv6Exthdr();
353             hash += layer3Match.getIpv6ExtHeader().getIpv6ExthdrMask();
354         }
355
356         if (null != layer3Match.getIpv6NdSll()) {
357             hash += calculateMacAddressHash(layer3Match.getIpv6NdSll());
358         }
359         if (null != layer3Match.getIpv6NdTll()) {
360             hash += calculateMacAddressHash(layer3Match.getIpv6NdTll());
361         }
362         if (null != layer3Match.getIpv6NdTarget()){
363             hash += calculateIpv6AddressHash(layer3Match.getIpv6NdTarget());
364         }
365         return hash;
366     }
367
368
369     public static int calculateIpv6PrefixHash(final Ipv6Prefix ipv6Prefix) {
370
371         StringTokenizer stringTokenizer = getStringTokenizerWithFullAddressString(ipv6Prefix.getValue());
372
373         int hash = parseTokens(stringTokenizer, BASE_16);
374         return hash;
375     }
376     public static int calculateIpv6AddressHash(final Ipv6Address ipv6Address) {
377
378         StringTokenizer stringTokenizer = getStringTokenizerWithFullAddressString(ipv6Address.getValue());
379
380         int hash = parseTokens(stringTokenizer, BASE_16);
381         return hash;
382     }
383
384     private static StringTokenizer getStringTokenizerWithFullAddressString(String value) {
385         String ipv6Value = value.replace("::", ":0000:");
386         StringTokenizer stringTokenizer = new StringTokenizer(ipv6Value, ":");
387
388         int delta = IPV6_TOKENS_COUNT - stringTokenizer.countTokens();
389
390         StringBuffer additions = new StringBuffer();
391
392         if (delta > 0) {
393             while (delta > 0) {
394                 additions.append(IPV6_TOKEN);
395                 delta--;
396             }
397             if (ipv6Value.contains("/")) {
398                 ipv6Value = ipv6Value.replace("/", additions.toString() + "/");
399             } else {
400                 ipv6Value += additions.toString();
401             }
402             stringTokenizer = new StringTokenizer(ipv6Value, ":");
403         }
404         return stringTokenizer;
405     }
406
407     private static int calculateStopperBasedOnMaskValue(final Ipv6Prefix ipv6Prefix, int bitsBase) {
408         double maskValue = extractMask(ipv6Prefix);
409         double bitCount = maskValue / bitsBase;
410         return (int) Math.ceil(bitCount);
411     }
412
413     private static int extractMask(final Ipv6Prefix ipv6Prefix) {
414         StringTokenizer maskTokenizer = new StringTokenizer(ipv6Prefix.getValue(), "/");
415         maskTokenizer.nextToken();
416         int mask = Integer.parseInt(maskTokenizer.nextToken());
417         return mask;
418     }
419
420     private static int parseTokens(final StringTokenizer stringTokenizer, int base) {
421         return parseTokens(stringTokenizer, 0, base);
422     }
423
424     private static int parseTokens(final StringTokenizer stringTokenizer, int stopper, int base) {
425         int hash = 0;
426         if (stringTokenizer.countTokens() > 0) {
427             int step = 0;
428             while (stringTokenizer.hasMoreTokens()) {
429                 String token = stringTokenizer.nextToken();
430                 step++;
431
432                 if (token.equals("")) {
433                     token = "0";
434                 }
435
436                 if (token.contains("/")) {
437                     StringTokenizer tokenizer = new StringTokenizer(token, "/");
438                     hash = hash ^ parseTokens(tokenizer, stopper, base);
439                 } else {
440                     hash = hash ^ ((Integer.parseInt(token, base) * step) + step);
441                     if (stopper > 0 && step == stopper) {
442                         break;
443                     }
444                 }
445             }
446         }
447         return hash;
448     }
449
450     private static int calculateIpv4MatchHash(final Ipv4Match layer3Match) {
451         int hash = 0;
452         Ipv4Prefix ipv4Destination = layer3Match.getIpv4Destination();
453         if (null != ipv4Destination) {
454             hash += calculateIpv4PrefixHash(ipv4Destination);
455         }
456
457         Ipv4Prefix ipv4Source = layer3Match.getIpv4Source();
458
459         if (null != ipv4Source) {
460             hash += calculateIpv4PrefixHash(ipv4Source);
461         }
462
463         //TODO : add calculation of hashes for augmentations
464         return hash;
465     }
466
467     private static int calculateArpMatchHash(final ArpMatch layer3Match) {
468         int hash = 0;
469         Integer arpOp = layer3Match.getArpOp();
470         if (null != arpOp) {
471             hash += arpOp.intValue();
472         }
473         ArpSourceHardwareAddress arpSourceHardwareAddress = layer3Match.getArpSourceHardwareAddress();
474         if (null != arpSourceHardwareAddress) {
475             hash += calculateMacAddressHash(arpSourceHardwareAddress.getAddress());
476             hash += calculateMacAddressHash(arpSourceHardwareAddress.getMask());
477         }
478
479         Ipv4Prefix sourceTransportAddress = layer3Match.getArpSourceTransportAddress();
480         if (null != sourceTransportAddress) {
481             hash += calculateIpv4PrefixHash(sourceTransportAddress);
482         }
483
484         ArpTargetHardwareAddress arpTargetHardwareAddress = layer3Match.getArpTargetHardwareAddress();
485         if (null != arpTargetHardwareAddress) {
486             hash += calculateMacAddressHash(arpTargetHardwareAddress.getAddress());
487             hash += calculateMacAddressHash(arpTargetHardwareAddress.getMask());
488         }
489
490         Ipv4Prefix targetTransportAddress = layer3Match.getArpTargetTransportAddress();
491         if (null != targetTransportAddress) {
492             hash += calculateIpv4PrefixHash(targetTransportAddress);
493         }
494
495         return hash;
496     }
497
498     public static int calculateIpv4PrefixHash(final Ipv4Prefix ipv4Prefix) {
499         int hash = 0;
500         StringTokenizer prefixAsArray = new StringTokenizer(ipv4Prefix.getValue(), "/");
501         if (prefixAsArray.countTokens() == 2) {
502             String address = prefixAsArray.nextToken();
503             Integer mask = Integer.parseInt(prefixAsArray.nextToken());
504             int numberOfAddressPartsToUse = (int) Math.ceil(mask.doubleValue() / 8);
505             hash += calculateIpAdressHash(address, numberOfAddressPartsToUse, BASE_10);
506             hash += mask.shortValue();
507         }
508         return hash;
509     }
510
511
512     private static int calculateIpAdressHash(final String address, int numberOfParts, int base) {
513         StringTokenizer stringTokenizer = new StringTokenizer(address, ".");
514         int hash = parseTokens(stringTokenizer, numberOfParts, base);
515         return hash;
516     }
517
518     private static int calculateIpMatchHash(final IpMatch ipMatch) {
519         int hash = 0;
520         Short ipEcn = ipMatch.getIpEcn();
521         if (null != ipEcn) {
522             hash += ipEcn.shortValue();
523         }
524         Short ipProtocol = ipMatch.getIpProtocol();
525         if (null != ipProtocol) {
526             hash += ipProtocol;
527         }
528
529         Short ipDscp = ipMatch.getIpDscp().getValue();
530         if (null != ipDscp) {
531             hash += ipDscp;
532         }
533
534         IpVersion ipVersion = ipMatch.getIpProto();
535         if (null != ipVersion) {
536             hash += ipVersion.getIntValue();
537         }
538         return hash;
539     }
540
541     private static int calculateNodeConnectorIdHash(final NodeConnectorId inPhyPort, DeviceContext deviceContext) {
542         int hash = 0;
543         short version = deviceContext.getDeviceState().getVersion();
544         Long portFromLogicalName = OpenflowPortsUtil.getPortFromLogicalName(OpenflowVersion.get(version), inPhyPort.getValue());
545         hash += portFromLogicalName.intValue();
546         return hash;
547     }
548
549     private static int calculateIcmpV6MatchHash(final Icmpv6Match icmpv6Match) {
550         int hash = 0;
551         if (null != icmpv6Match.getIcmpv6Code()) {
552             hash += icmpv6Match.getIcmpv6Code();
553         }
554         if (null != icmpv6Match.getIcmpv6Type()) {
555             hash += icmpv6Match.getIcmpv6Type();
556         }
557         return hash;
558     }
559
560     public static int calculateIcmpV4MatchHash(final Icmpv4Match icmpv4Match) {
561         int hash = 0;
562         if (null != icmpv4Match.getIcmpv4Code()) {
563             hash += icmpv4Match.getIcmpv4Code();
564         }
565         if (null != icmpv4Match.getIcmpv4Type()) {
566             hash += icmpv4Match.getIcmpv4Type();
567         }
568         return hash;
569     }
570
571
572 }