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
8 package org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures.matchfield;
10 import io.netty.buffer.ByteBuf;
11 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;
14 public abstract class AbstractMatchFieldSerializer implements OFSerializer<SetFieldMatch> {
17 public void serialize(final SetFieldMatch setFieldMatch, final ByteBuf byteBuf) {
18 byteBuf.writeShort(getOxmClassCode());
20 int fieldAndMask = getOxmFieldCode() << 1;
21 int length = getValueLength();
23 if (setFieldMatch.getHasMask()) {
28 byteBuf.writeByte(fieldAndMask);
29 byteBuf.writeByte(length);
32 protected abstract int getOxmClassCode();
34 protected abstract int getOxmFieldCode();
36 protected abstract int getValueLength();