2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
8 package org.opendaylight.openflowjava.protocol.impl.deserialization.match;
\r
10 import io.netty.buffer.ByteBuf;
\r
12 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
\r
13 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
\r
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry;
\r
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder;
\r
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;
\r
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
\r
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase;
\r
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid;
\r
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
\r
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
\r
24 * @author michal.polkorab
\r
27 public class OxmVlanVidDeserializer extends AbstractOxmMatchEntryDeserializer
\r
28 implements OFDeserializer<MatchEntries> {
\r
31 public MatchEntries deserialize(ByteBuf input) {
\r
32 MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);
\r
33 addVlanVidAugmentation(input, builder);
\r
34 if (builder.isHasMask()) {
\r
35 OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
\r
37 return builder.build();
\r
40 private static void addVlanVidAugmentation(ByteBuf input, MatchEntriesBuilder builder) {
\r
41 VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();
\r
42 int vidEntryValue = input.readUnsignedShort();
\r
43 vlanVidBuilder.setCfiBit((vidEntryValue & (1 << 12)) != 0); // cfi is 13-th bit
\r
44 vlanVidBuilder.setVlanVid(vidEntryValue & ((1 << 12) - 1)); // value without 13-th bit
\r
45 builder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());
\r
49 protected Class<? extends MatchField> getOxmField() {
\r
50 return VlanVid.class;
\r
54 protected Class<? extends OxmClassBase> getOxmClass() {
\r
55 return OpenflowBasicClass.class;
\r