Use ByteBuf.readRetainedSlice()
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / protocol / serialization / match / TunnelIpv4SourceEntrySerializer.java
1 /*
2  * Copyright (c) 2016 Pantheon Technologies s.r.o. 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 package org.opendaylight.openflowplugin.impl.protocol.serialization.match;
9
10 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
11 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4Match;
15
16 // TODO: Why is this serialization exactly same as in Ipv4SourceEntrySerializer?
17 public class TunnelIpv4SourceEntrySerializer extends AbstractIpv4PrefixEntrySerializer {
18     public TunnelIpv4SourceEntrySerializer() {
19         super(OxmMatchConstants.OPENFLOW_BASIC_CLASS, OxmMatchConstants.IPV4_SRC);
20     }
21
22     @Override
23     protected Ipv4Prefix extractEntry(final Match match) {
24         final Layer3Match l3Match = match.getLayer3Match();
25         return l3Match instanceof TunnelIpv4Match ? ((TunnelIpv4Match) l3Match).getTunnelIpv4Source() : null;
26     }
27 }