1381475721e1788dfd09f0bbc26a183814bb7063
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / match / OxmVlanPcpDeserializer.java
1 /*
2  * Copyright (c) 2013 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.openflowjava.protocol.impl.deserialization.match;
9
10 import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8;
11
12 import io.netty.buffer.ByteBuf;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanPcp;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanPcpCaseBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.pcp._case.VlanPcpBuilder;
20
21 /**
22  * Translates OxmVlanPcp messages.
23  *
24  * @author michal.polkorab
25  */
26 public class OxmVlanPcpDeserializer extends AbstractOxmMatchEntryDeserializer {
27     @Override
28     public MatchEntry deserialize(final ByteBuf input) {
29         return processHeader(getOxmClass(), getOxmField(), input)
30                 .setMatchEntryValue(new VlanPcpCaseBuilder()
31                     .setVlanPcp(new VlanPcpBuilder().setVlanPcp(readUint8(input)).build())
32                     .build())
33                 .build();
34     }
35
36     @Override
37     protected Class<? extends MatchField> getOxmField() {
38         return VlanPcp.class;
39     }
40
41     @Override
42     protected Class<? extends OxmClassBase> getOxmClass() {
43         return OpenflowBasicClass.class;
44     }
45 }