X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fsal%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fpacket%2FPacket.java;h=789aa126533c93c16660e5eafcfc995dc510fab1;hp=58b5d3914aa2dc199111dd2f2dc1ff8d5289dcc0;hb=3ce420ccd45e7530c2c2158bd57462fd5859a879;hpb=aa16124c5eff863f9d75a7514910008d34f3f40c diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Packet.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Packet.java index 58b5d3914a..789aa12653 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Packet.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Packet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -13,6 +13,7 @@ import java.util.Map; import java.util.Map.Entry; import org.apache.commons.lang3.tuple.Pair; +import org.opendaylight.controller.sal.match.Match; import org.opendaylight.controller.sal.utils.HexEncode; import org.opendaylight.controller.sal.utils.NetUtils; import org.slf4j.Logger; @@ -364,4 +365,31 @@ public abstract class Packet { return true; } + /** + * Adds to the passed Match this packet's header fields + * + * @param match + * The Match object to populate + */ + public void populateMatch(Match match) { + // To be overridden by derived packet classes which have well known + // header fields so that Packet.getMatch would return desired result + } + + /** + * Returns the Match object containing this packet and its payload + * encapsulated packets' header fields + * + * @return The Match containing the header fields of this packet and of its + * payload encapsulated packets + */ + public Match getMatch() { + Match match = new Match(); + Packet packet = this; + while (packet != null) { + packet.populateMatch(match); + packet = packet.getPayload(); + } + return match; + } }