/** NXM TCP_Flag value */
public static final int NXM_NX_TCP_FLAG = 34;
+ /**
+ * ONF Approved Extensions Constants
+ */
+
+ /** ONFOXM_ET_TCP_FLAGS value */
+ public static final int ONFOXM_ET_TCP_FLAGS = 42;
+ /** ONFOXM_ET_TCP_FLAGS Experimenter Id (0x4F4E4600) */
+ public static final long ONFOXM_ET_TCP_FLAGS_EXP_ID = 1330529792;
+
private OxmMatchConstants() {
//not called
}
--- /dev/null
+module openflow-approved-extensions {
+ namespace "urn:opendaylight:openflow:approved:extensions";
+ prefix "ofext";
+
+ import yang-ext {prefix ext;}
+ import ietf-inet-types {prefix inet;}
+ import ietf-yang-types {prefix yang;}
+
+ import openflow-types {prefix oft;}
+ import openflow-protocol {prefix ofproto;}
+ import openflow-action {prefix ofaction;}
+ import openflow-instruction {prefix ofinstruction;}
+ import openflow-extensible-match {prefix oxm;}
+ import openflow-augments {prefix aug;}
+
+ revision "2016-08-02" {
+ description "Openflow approved extensions definition";
+ }
+
+ //ONF Approved OpenFlow Extensions
+
+ // Extension 109 - TCP FLAGS
+ identity tcp_flags {
+ base oxm:match-field;
+ description "TCP flags from the TCP header";
+ }
+
+ augment "/oxm:oxm-container/oxm:match-entry-value/aug:experimenter-id-case" {
+ ext:augment-identifier "tcp-flags-container";
+ container tcp-flags {
+ leaf flags {
+ type uint16;
+ }
+ leaf mask {
+ type binary;
+ }
+ }
+ }
+
+}
\ No newline at end of file
import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmVlanPcpDeserializer;
import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmVlanVidDeserializer;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.ext.OnfOxmTcpFlagsDeserializer;
import org.opendaylight.openflowjava.protocol.impl.util.MatchEntryDeserializerRegistryHelper;
import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
helper.register(OxmMatchConstants.PBB_ISID, new OxmPbbIsidDeserializer());
helper.register(OxmMatchConstants.TUNNEL_ID, new OxmTunnelIdDeserializer());
helper.register(OxmMatchConstants.IPV6_EXTHDR, new OxmIpv6ExtHdrDeserializer());
+
+ // Register approved openflow match entry deserializers
+ helper.registerExperimenter(OxmMatchConstants.ONFOXM_ET_TCP_FLAGS, OxmMatchConstants.ONFOXM_ET_TCP_FLAGS_EXP_ID,
+ new OnfOxmTcpFlagsDeserializer());
}
}
--- /dev/null
+/*
+ * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match.ext;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.AbstractOxmMatchEntryDeserializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
+
+/**
+ * Created by Anil Vishnoi (avishnoi@Brocade.com) on 7/26/16.
+ */
+public abstract class AbstractOxmExperimenterMatchEntryDeserializer extends AbstractOxmMatchEntryDeserializer {
+
+ protected ExperimenterIdCaseBuilder createExperimenterIdCase(MatchEntryBuilder entryBuilder, ByteBuf input) {
+ ExperimenterIdCaseBuilder expCaseBuilder = new ExperimenterIdCaseBuilder();
+ ExperimenterBuilder expBuilder = new ExperimenterBuilder();
+ expBuilder.setExperimenter(new ExperimenterId(input.readUnsignedInt()));
+ expCaseBuilder.setExperimenter(expBuilder.build());
+ return expCaseBuilder;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match.ext;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlagsContainer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlagsContainerBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.oxm.container.match.entry.value.experimenter.id._case.TcpFlagsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
+
+/**
+ * Created by Anil Vishnoi (avishnoi@Brocade.com) on 7/26/16.
+ */
+public class OnfOxmTcpFlagsDeserializer extends AbstractOxmExperimenterMatchEntryDeserializer
+ implements OFDeserializer<MatchEntry> {
+
+ @Override
+ public MatchEntry deserialize(ByteBuf input) {
+ MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder(deserializeHeader(input));
+ ExperimenterIdCaseBuilder expCaseBuilder = createExperimenterIdCase(matchEntryBuilder, input);
+ addTcpFlagsAugmentation(input, expCaseBuilder, matchEntryBuilder.isHasMask());
+ matchEntryBuilder.setMatchEntryValue(expCaseBuilder.build());
+ return matchEntryBuilder.build();
+
+ }
+
+ private static void addTcpFlagsAugmentation(ByteBuf input, ExperimenterIdCaseBuilder expCaseBuilder, boolean hasMask) {
+ TcpFlagsContainerBuilder flagsContainerBuilder = new TcpFlagsContainerBuilder();
+ TcpFlagsBuilder flagsBuilder = new TcpFlagsBuilder();
+ flagsBuilder.setFlags(input.readUnsignedShort());
+ if (hasMask) {
+ byte[] mask = new byte[EncodeConstants.SIZE_OF_SHORT_IN_BYTES];
+ input.readBytes(mask);
+ flagsBuilder.setMask(mask);
+ }
+ flagsContainerBuilder.setTcpFlags(flagsBuilder.build());
+ expCaseBuilder.addAugmentation(TcpFlagsContainer.class, flagsContainerBuilder.build());
+ }
+
+ /**
+ * @return oxm_field class
+ */
+ @Override
+ protected Class<? extends MatchField> getOxmField() {
+ return TcpFlags.class;
+ }
+
+ /**
+ * @return oxm_class class
+ */
+ @Override
+ protected Class<? extends OxmClassBase> getOxmClass() {
+ return ExperimenterClass.class;
+ }
+}
import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpOpSerializer;
import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpShaSerializer;
import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpSpaSerializer;
import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmUdpSrcSerializer;
import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanPcpSerializer;
import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanVidSerializer;
+import org.opendaylight.openflowjava.protocol.impl.serialization.match.ext.OnfOxmTcpFlagsSerializer;
import org.opendaylight.openflowjava.protocol.impl.util.MatchEntrySerializerRegistryHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpOp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSha;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSpa;
helper.registerSerializer(PbbIsid.class, new OxmPbbIsidSerializer());
helper.registerSerializer(TunnelId.class, new OxmTunnelIdSerializer());
helper.registerSerializer(Ipv6Exthdr.class, new OxmIpv6ExtHdrSerializer());
+
+ // Register approved openflow match entry serializers
+ helper.registerExperimenterSerializer(TcpFlags.class, OxmMatchConstants.ONFOXM_ET_TCP_FLAGS_EXP_ID,
+ new OnfOxmTcpFlagsSerializer());
}
}
--- /dev/null
+/*
+ * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.match.ext;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.openflowjava.protocol.impl.serialization.match.AbstractOxmMatchEntrySerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+
+/**
+ * Created by Anil Vishnoi (avishnoi@Brocade.com) on 7/25/16.
+ */
+public abstract class AbstractOxmExperimenterMatchEntrySerializer extends AbstractOxmMatchEntrySerializer {
+
+ @Override
+ public void serialize(MatchEntry entry, ByteBuf outBuffer) {
+ serializeHeader(entry, outBuffer);
+ }
+
+ @Override
+ public void serializeHeader(MatchEntry entry, ByteBuf outBuffer) {
+ outBuffer.writeShort(getOxmClassCode());
+ writeOxmFieldAndLength(outBuffer, getOxmFieldCode(), entry.isHasMask(),
+ getValueLength());
+ }
+
+ protected static void writeOxmFieldAndLength(ByteBuf out, int fieldValue, boolean hasMask, int lengthArg) {
+ int fieldAndMask = fieldValue << 1;
+ int length = lengthArg;
+ if (hasMask) {
+ fieldAndMask |= 1;
+ length *= 2;
+ }
+
+ //Add experimenter-id lenge
+ length = length + EncodeConstants.SIZE_OF_INT_IN_BYTES;
+ out.writeByte(fieldAndMask);
+ out.writeByte(length);
+ }
+
+ protected ExperimenterIdCase serializeExperimenterId(MatchEntry matchEntry, ByteBuf out) {
+ ExperimenterIdCase expCase = (ExperimenterIdCase) matchEntry.getMatchEntryValue();
+ out.writeInt(expCase.getExperimenter().getExperimenter().getValue().intValue());
+ return expCase;
+ }
+
+ /**
+ * @return Experimenter match entry ID
+ */
+ protected abstract long getExperimenterId();
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.match.ext;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlagsContainer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.oxm.container.match.entry.value.experimenter.id._case.TcpFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+
+/**
+ * Created by Anil Vishnoi (avishnoi@Brocade.com) on 7/25/16.
+ */
+public class OnfOxmTcpFlagsSerializer extends AbstractOxmExperimenterMatchEntrySerializer {
+
+ @Override
+ public void serialize(MatchEntry entry, ByteBuf outBuffer) {
+ super.serialize(entry, outBuffer);
+ ExperimenterIdCase expCase = serializeExperimenterId(entry, outBuffer);
+ TcpFlags tcpFlags = expCase.getAugmentation(TcpFlagsContainer.class).getTcpFlags();
+ outBuffer.writeShort(tcpFlags.getFlags());
+ if (entry.isHasMask()) {
+ outBuffer.writeBytes(tcpFlags.getMask());
+ }
+ }
+
+ /**
+ * @return Experimenter match entry ID
+ */
+ @Override
+ protected long getExperimenterId() {
+ return OxmMatchConstants.ONFOXM_ET_TCP_FLAGS_EXP_ID;
+ }
+
+ /**
+ * @return numeric representation of oxm_field
+ */
+ @Override
+ protected int getOxmFieldCode() {
+ return OxmMatchConstants.ONFOXM_ET_TCP_FLAGS;
+ }
+
+ /**
+ * @return numeric representation of oxm_class
+ */
+ @Override
+ protected int getOxmClassCode() {
+ return OxmMatchConstants.EXPERIMENTER_CLASS;
+ }
+
+ /**
+ * @return match entry value length (without mask length)
+ */
+ @Override
+ protected int getValueLength() {
+ return EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
+ }
+}
import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer;
import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
/**
* @author michal.polkorab
key.setExperimenterId(null);
registry.registerDeserializer(key, deserializer);
}
+
+ public void registerExperimenter(int oxmField, long expId, OFGeneralDeserializer deserializer) {
+ MatchEntryDeserializerKey key =
+ new MatchEntryDeserializerKey(version, OxmMatchConstants.EXPERIMENTER_CLASS, oxmField);
+ key.setExperimenterId(expId);
+ registry.registerDeserializer(key, deserializer);
+ }
}
\ No newline at end of file
import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer;
import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase;
key.setExperimenterId(null);
serializerRegistry.registerSerializer(key, serializer);
}
+
+ /**
+ * Registers ExperimenterClass type match serializer
+ * @param specificClass
+ * @param serializer
+ */
+ public <F extends MatchField> void registerExperimenterSerializer(
+ Class<F> specificClass, long expId, OFGeneralSerializer serializer) {
+ MatchEntrySerializerKey<?, ?> key = new MatchEntrySerializerKey<>(version, ExperimenterClass.class, specificClass);
+ key.setExperimenterId(expId);
+ serializerRegistry.registerSerializer(key, serializer);
+ }
+
}
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.oxm.container.match.entry.value.experimenter.id._case.TcpFlagsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;