2 * Copyright (c) 2017 Pantheon Technologies s.r.o. 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
9 package org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield;
11 import io.netty.buffer.ByteBuf;
12 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;
15 public abstract class AbstractMatchFieldSerializer implements OFSerializer<SetFieldMatch> {
18 public void serialize(final SetFieldMatch setFieldMatch, final ByteBuf byteBuf) {
19 byteBuf.writeShort(getOxmClassCode());
21 int fieldAndMask = getOxmFieldCode() << 1;
22 int length = getValueLength();
24 if (setFieldMatch.isHasMask()) {
29 byteBuf.writeByte(fieldAndMask);
30 byteBuf.writeByte(length);
33 protected abstract int getOxmClassCode();
34 protected abstract int getOxmFieldCode();
35 protected abstract int getValueLength();