2 * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.openflowjava.protocol.impl.serialization.match.ext;
10 import io.netty.buffer.ByteBuf;
11 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
12 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
13 import org.opendaylight.openflowjava.protocol.impl.serialization.match.AbstractOxmMatchEntrySerializer;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
18 * Created by Anil Vishnoi (avishnoi@Brocade.com) on 7/25/16.
20 public abstract class AbstractOxmExperimenterMatchEntrySerializer extends AbstractOxmMatchEntrySerializer {
23 public void serialize(MatchEntry entry, ByteBuf outBuffer) {
24 serializeHeader(entry, outBuffer);
28 public void serializeHeader(MatchEntry entry, ByteBuf outBuffer) {
29 outBuffer.writeShort(getOxmClassCode());
30 writeOxmFieldAndLength(outBuffer, getOxmFieldCode(), entry.isHasMask(),
34 protected static void writeOxmFieldAndLength(ByteBuf out, int fieldValue, boolean hasMask, int lengthArg) {
35 int fieldAndMask = fieldValue << 1;
36 int length = lengthArg;
42 //Add experimenter-id lenge
43 length = length + EncodeConstants.SIZE_OF_INT_IN_BYTES;
44 out.writeByte(fieldAndMask);
45 out.writeByte(length);
48 protected ExperimenterIdCase serializeExperimenterId(MatchEntry matchEntry, ByteBuf out) {
49 ExperimenterIdCase expCase = (ExperimenterIdCase) matchEntry.getMatchEntryValue();
50 out.writeInt(expCase.getExperimenter().getExperimenter().getValue().intValue());
55 * @return Experimenter match entry ID
57 protected abstract long getExperimenterId();