--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.api.extensibility;\r
+\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public interface DeserializerRegistry {\r
+\r
+ /**\r
+ * Initializes deserializers\r
+ */\r
+ public void init();\r
+\r
+ /**\r
+ * @param key used for deserializer lookup\r
+ * @return deserializer found\r
+ */\r
+ public <SERIALIZER_TYPE extends OFGeneralDeserializer>\r
+ SERIALIZER_TYPE getDeserializer(MessageCodeKey key);\r
+\r
+ /**\r
+ * @param key used to registry lookup\r
+ * @param deserializer deserializer instance\r
+ */\r
+ public void registerDeserializer(MessageCodeKey key, OFGeneralDeserializer deserializer);\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.api.extensibility;\r
+\r
+/**\r
+ * Injects registry\r
+ * @author michal.polkorab\r
+ */\r
+public interface DeserializerRegistryInjector {\r
+\r
+ /**\r
+ * Injects deserializer registry into deserializer\r
+ * @param deserializerRegistry\r
+ */\r
+ public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry);\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.api.extensibility;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class EnhancedMessageCodeKey extends MessageCodeKey {\r
+\r
+ private int msgType2;\r
+\r
+ /**\r
+ * Constructor\r
+ * @param version wire protocol version\r
+ * @param value used as distinguisher\r
+ * @param value2 used as detailed distinguisher\r
+ * @param clazz class of object that is going to be deserialized\r
+ */\r
+ public EnhancedMessageCodeKey(short version, int value, int value2, Class<?> clazz) {\r
+ super(version, value, clazz);\r
+ this.msgType2 = value2;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj)\r
+ return true;\r
+ if (!super.equals(obj))\r
+ return false;\r
+ if (getClass() != obj.getClass())\r
+ return false;\r
+ EnhancedMessageCodeKey other = (EnhancedMessageCodeKey) obj;\r
+ if (msgType2 != other.msgType2)\r
+ return false;\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return super.toString() + " msgType2: " + msgType2;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.api.extensibility;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.yangtools.yang.binding.DataObject;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ * @param <E> \r
+ */\r
+public interface HeaderDeserializer<E extends DataObject> extends OFGeneralDeserializer {\r
+\r
+ /**\r
+ * Deserializes byte message headers\r
+ * \r
+ * @param rawMessage message as bytes in ByteBuf\r
+ * @return POJO/DTO\r
+ */\r
+ public E deserializeHeader(ByteBuf rawMessage);\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.api.extensibility;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ */\r
+public class MessageCodeKey {\r
+\r
+ private short msgVersion;\r
+ private int msgType;\r
+ private Class<?> clazz;\r
+\r
+ /**\r
+ * Constructor\r
+ * @param version wire protocol version\r
+ * @param value used as distinguisher\r
+ * @param clazz class of object that is going to be deserialized\r
+ */\r
+ public MessageCodeKey(short version, int value, Class<?> clazz) {\r
+ this.msgVersion = version;\r
+ this.msgType = value;\r
+ this.clazz = clazz;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result + ((clazz == null) ? 0 : clazz.hashCode());\r
+ result = prime * result + msgType;\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj)\r
+ return true;\r
+ if (obj == null)\r
+ return false;\r
+ if (getClass() != obj.getClass())\r
+ return false;\r
+ MessageCodeKey other = (MessageCodeKey) obj;\r
+ if (clazz == null) {\r
+ if (other.clazz != null)\r
+ return false;\r
+ } else if (!clazz.equals(other.clazz))\r
+ return false;\r
+ if (msgType != other.msgType)\r
+ return false;\r
+ if (msgVersion != other.msgVersion)\r
+ return false;\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return "msgVersion: " + msgVersion + " class: " + clazz.getName() + " msgType: " + msgType;\r
+ }\r
+}\r
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.openflowjava.protocol.impl.deserialization;
-
-import org.opendaylight.yangtools.yang.binding.DataObject;
+package org.opendaylight.openflowjava.protocol.api.extensibility;
import io.netty.buffer.ByteBuf;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
/**
* Uniform interface for deserializing factories
* @author michal.polkorab
* @author timotej.kubas
* @param <E> message code type
*/
-public interface OFDeserializer<E extends DataObject> {
+public interface OFDeserializer<E extends DataObject> extends OFGeneralDeserializer {
/**
* Transforms byte message into POJO/DTO (of type E).
- * Assumes that input ByteBuf's readerIndex is pointing on length in OpenFlow header
*
- * @param rawMessage message as bytes in ByteBuf
- * @param version version of used OF Protocol
- * @return HelloMessage as DataObject
+ * @param message message as bytes in ByteBuf
+ * @return POJO/DTO
*/
- public abstract E bufferToMessage(ByteBuf rawMessage, short version);
-
+ public E deserialize(ByteBuf message);
}
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.api.extensibility;\r
+\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ */\r
+public interface OFGeneralDeserializer {\r
+\r
+ // empty unifying interface\r
+}\r
import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey;
import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer;
import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler;
import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory;
import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.slf4j.Logger;
private ConnectionConfiguration connConfig;
private SerializationFactory serializationFactory;
private SerializerRegistry serializerRegistry;
+ private DeserializerRegistry deserializerRegistry;
+ private DeserializationFactory deserializationFactory;
/** Constructor */
public SwitchConnectionProviderImpl() {
serializerRegistry.init();
serializationFactory = new SerializationFactory();
serializationFactory.setSerializerTable(serializerRegistry);
+ deserializerRegistry = new DeserializerRegistryImpl();
+ deserializerRegistry.init();
+ deserializationFactory = new DeserializationFactory();
+ deserializationFactory.setRegistry(deserializerRegistry);
}
@Override
boolean tlsSupported = FEATURE_SUPPORT.REQUIRED.equals(connConfig.getTlsSupport());
server.setEncryption(tlsSupported);
server.setSerializationFactory(serializationFactory);
+ server.setDeserializationFactory(deserializationFactory);
return server;
}
serializerRegistry.registerSerializer(key, serializer);
}
+ @Override
+ public void registerDeserializer(MessageCodeKey key,
+ OFGeneralDeserializer deserializer) {
+ deserializerRegistry.registerDeserializer(key, deserializer);
+ }
+
@Override
public void close() throws Exception {
shutdown();
public class OFDecoder extends MessageToMessageDecoder<VersionMessageWrapper> {
private static final Logger LOGGER = LoggerFactory.getLogger(OFDecoder.class);
+ private DeserializationFactory deserializationFactory;
/**
* Constructor of class
}
DataObject dataObject = null;
try {
- dataObject = DeserializationFactory.bufferToMessage(msg.getMessageBuffer(),
+ dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(),
msg.getVersion());
} catch(Exception e) {
LOGGER.error("Message deserialization failed");
msg.getMessageBuffer().release();
out.add(dataObject);
}
+
+ /**
+ * @param deserializationFactory
+ */
+ public void setDeserializationFactory(DeserializationFactory deserializationFactory) {
+ this.deserializationFactory = deserializationFactory;
+ }
+
}
import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionFacade;
import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler.COMPONENT_NAMES;
import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private long switchIdleTimeout;
private boolean encryption;
private SerializationFactory serializationFactory;
+ private DeserializationFactory deserializationFactory;
/**
* default ctor
}
ch.pipeline().addLast(COMPONENT_NAMES.OF_FRAME_DECODER.name(), new OFFrameDecoder());
ch.pipeline().addLast(COMPONENT_NAMES.OF_VERSION_DETECTOR.name(), new OFVersionDetector());
- ch.pipeline().addLast(COMPONENT_NAMES.OF_DECODER.name(), new OFDecoder());
+ OFDecoder ofDecoder = new OFDecoder();
+ ofDecoder.setDeserializationFactory(deserializationFactory);
+ ch.pipeline().addLast(COMPONENT_NAMES.OF_DECODER.name(), ofDecoder);
OFEncoder ofEncoder = new OFEncoder();
ofEncoder.setSerializationFactory(serializationFactory);
ch.pipeline().addLast(COMPONENT_NAMES.OF_ENCODER.name(), ofEncoder);
public void setSerializationFactory(SerializationFactory serializationFactory) {
this.serializationFactory = serializationFactory;
}
+
+ /**
+ * @param deserializationFactory
+ */
+ public void setDeserializationFactory(DeserializationFactory deserializationFactory) {
+ this.deserializationFactory = deserializationFactory;
+ }
+
}
import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
import org.opendaylight.openflowjava.protocol.impl.connection.ServerFacade;
import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public void setEncryption(boolean tlsSupported) {
channelInitializer.setEncryption(tlsSupported);
}
-
+
/**
* @param sf serialization factory
*/
public void setSerializationFactory(SerializationFactory sf) {
channelInitializer.setSerializationFactory(sf);
}
+
+ /**
+ * @param factory
+ */
+ public void setDeserializationFactory(DeserializationFactory factory) {
+ channelInitializer.setDeserializationFactory(factory);
+ }
+
}
+++ /dev/null
-/*
- * Copyright (c) 2013 Pantheon Technologies s.r.o. 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;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.BarrierReplyMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoReplyMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoRequestMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.ErrorMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.ExperimenterMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FeaturesReplyMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FlowRemovedMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetAsyncReplyMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetConfigReplyMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10ErrorMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FeaturesReplyMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FlowRemovedMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10HelloMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PacketInMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PortStatusMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10QueueGetConfigReplyMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10VendorMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PacketInMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PortStatusMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.QueueGetConfigReplyMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.RoleReplyMessageFactory;
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
-
-/**
- * Stores and provides correct decoders for received messages
- * @author michal.polkorab
- *
- * <pre>
- * Type Message
- * 0: HELLO
- * 1: ERROR
- * 2: ECHO_REQUEST
- * 3: ECHO_REPLY
- * 4: EXPERIMENTER
- * 5: FEATURES_REQUEST
- * 6: FEATURES_REPLY
- * 7: GET_CONFIG_REQUEST
- * 8: GET_CONFIG_REPLY
- * 9: SET_CONFIG
- * 10: PACKET_IN
- * 11: FLOW_REMOVED
- * 12: PORT_STATUS
- * 13: PACKET_OUT
- * 14: FLOW_MOD
- * 15: GROUP_MOD
- * 16: PORT_MOD
- * 17: TABLE_MOD
- * 18: MULTIPART_REQUEST
- * 19: MULTIPART_REPLY
- * 20: BARRIER_REQUEST
- * 21: BARRIER_REPLY
- * 22: QUEUE_GET_CONFIG_REQUEST
- * 23: QUEUE_GET_CONFIG_REPLY
- * 24: ROLE_REQUEST
- * 25: ROLE_REPLY
- * 26: GET_ASYNC_REQUEST
- * 27: GET_ASYNC_REPLY
- * 28: SET_ASYNC
- * 29: METER_MOD
- * </pre>
- */
-public class DecoderTable {
-
- private static final short OF10 = EncodeConstants.OF10_VERSION_ID;
- private static final short OF13 = EncodeConstants.OF13_VERSION_ID;
- private Map<MessageTypeCodeKey, OFDeserializer<?>> table;
- private static DecoderTable instance;
-
-
- private DecoderTable() {
- // do nothing
- }
-
- /**
- * @return singleton instance
- */
- public static synchronized DecoderTable getInstance() {
- if (instance == null) {
- instance = new DecoderTable();
- instance.init();
- }
- return instance;
- }
-
- /**
- * Decoder table provisioning
- */
- public void init() {
- table = new HashMap<>();
- table.put(new MessageTypeCodeKey(OF10, (short) 0), OF10HelloMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF10, (short) 1), OF10ErrorMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF10, (short) 2), EchoRequestMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF10, (short) 3), EchoReplyMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF10, (short) 4), OF10VendorMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF10, (short) 6), OF10FeaturesReplyMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF10, (short) 8), GetConfigReplyMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF10, (short) 10), OF10PacketInMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF10, (short) 11), OF10FlowRemovedMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF10, (short) 12), OF10PortStatusMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF10, (short) 17), OF10StatsReplyMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF10, (short) 19), BarrierReplyMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF10, (short) 21), OF10QueueGetConfigReplyMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF13, (short) 0), HelloMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF13, (short) 1), ErrorMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF13, (short) 2), EchoRequestMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF13, (short) 3), EchoReplyMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF13, (short) 4), ExperimenterMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF13, (short) 6), FeaturesReplyMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF13, (short) 8), GetConfigReplyMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF13, (short) 10), PacketInMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF13, (short) 11), FlowRemovedMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF13, (short) 12), PortStatusMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF13, (short) 19), MultipartReplyMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF13, (short) 21), BarrierReplyMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF13, (short) 23), QueueGetConfigReplyMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF13, (short) 25), RoleReplyMessageFactory.getInstance());
- table.put(new MessageTypeCodeKey(OF13, (short) 27), GetAsyncReplyMessageFactory.getInstance());
- }
-
- /**
- * @param msgTypeKey
- * @return decoder for given message types
- */
- public OFDeserializer<?> getDecoder(MessageTypeCodeKey msgTypeKey) {
- return table.get(msgTypeKey);
- }
-
-}
import io.netty.buffer.ByteBuf;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* @author michal.polkorab
* @author timotej.kubas
*/
-public abstract class DeserializationFactory {
-
- private static final Logger LOGGER = LoggerFactory
- .getLogger(DeserializationFactory.class);
+public class DeserializationFactory {
+
+ private DeserializerRegistry registry;
+ private Map<TypeToClassKey, Class<?>> messageClassMap;
+
+ /**
+ * Constructor
+ */
+ public DeserializationFactory() {
+ messageClassMap = new HashMap<>();
+ initTypeToClassMapping();
+ }
/**
* Transforms ByteBuf into correct POJO message
- * @param rawMessage
+ * @param rawMessage
* @param version version decoded from OpenFlow protocol message
* @return correct POJO as DataObject
*/
- public static DataObject bufferToMessage(ByteBuf rawMessage, short version) {
+ public DataObject deserialize(ByteBuf rawMessage, short version) {
DataObject dataObject = null;
- short type = rawMessage.readUnsignedByte();
+ int type = rawMessage.readUnsignedByte();
+ Class<?> clazz = messageClassMap.get(new TypeToClassKey(version, type));
rawMessage.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
-
- MessageTypeCodeKey msgTypeCodeKey = new MessageTypeCodeKey(version, type);
- OFDeserializer<?> decoder = DecoderTable.getInstance().getDecoder(msgTypeCodeKey);
- if (decoder != null) {
- dataObject = decoder.bufferToMessage(rawMessage, version);
- } else {
- LOGGER.warn("No correct decoder found in DecoderTable for arguments: " + msgTypeCodeKey.toString());
+ OFDeserializer<DataObject> deserializer = registry.getDeserializer(
+ new MessageCodeKey(version, type, clazz));
+ if (deserializer != null) {
+ dataObject = deserializer.deserialize(rawMessage);
}
return dataObject;
}
+
+ /**
+ * @param registry
+ */
+ public void setRegistry(DeserializerRegistry registry) {
+ this.registry = registry;
+ }
+
+ private void initTypeToClassMapping() {
+ TypeToClassMapInitializer.initializeTypeToClassMap(messageClassMap);
+ }
}
--- /dev/null
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. 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;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.ActionsDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.InstructionsDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.OF10ActionsDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchDeserializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10;
+
+/**
+ * Stores and registers deserializers
+ * @author michal.polkorab
+ */
+public class DeserializerRegistryImpl implements DeserializerRegistry {
+
+ private Map<MessageCodeKey, OFGeneralDeserializer> registry;
+
+ /**
+ * Decoder table provisioning
+ */
+ @Override
+ public void init() {
+ registry = new HashMap<>();
+ // register message deserializers
+ MessageDerializerInitializer.registerMessageDeserializers(this);
+
+ // register common structure deserializers
+ registerDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID,
+ EncodeConstants.EMPTY_VALUE, MatchV10.class), new OF10MatchDeserializer());
+ registerDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID,
+ EncodeConstants.EMPTY_VALUE, Action.class), new OF10ActionsDeserializer());
+ registerDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID,
+ EncodeConstants.EMPTY_VALUE, Match.class), new MatchDeserializer());
+ registerDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID,
+ EncodeConstants.EMPTY_VALUE, Action.class), new ActionsDeserializer());
+ registerDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID,
+ EncodeConstants.EMPTY_VALUE, Instruction.class), new InstructionsDeserializer());
+
+ // register match entry deserializers
+ MatchEntryDeserializerInitializer.registerMatchEntryDeserializers(this);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <DESERIALIZER_TYPE extends OFGeneralDeserializer> DESERIALIZER_TYPE getDeserializer(
+ MessageCodeKey key) {
+ OFGeneralDeserializer deserializer = registry.get(key);
+ if (deserializer == null) {
+ throw new NullPointerException("Deserializer for key: " + key.toString()
+ + " was not found");
+ }
+ return (DESERIALIZER_TYPE) deserializer;
+ }
+
+ @Override
+ public void registerDeserializer(MessageCodeKey key,
+ OFGeneralDeserializer deserializer) {
+ if ((key == null) || (deserializer == null)) {
+ throw new NullPointerException("MessageCodeKey or Deserializer is null");
+ }
+ if (deserializer instanceof DeserializerRegistryInjector) {
+ ((DeserializerRegistryInjector) deserializer).injectDeserializerRegistry(this);
+ }
+ registry.put(key, deserializer);
+ }
+
+}
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpOpDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpShaDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpSpaDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpThaDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpTpaDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmEthDstDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmEthSrcDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmEthTypeDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv4CodeDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv4TypeDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv6CodeDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv6TypeDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmInPhyPortDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmInPortDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpDscpDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpEcnDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpProtoDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv4DstDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv4SrcDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6DstDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6ExtHdrDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6FlabelDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6NdSllDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6NdTargetDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6NdTllDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6SrcDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMetadataDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMplsBosDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMplsLabelDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMplsTcDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmPbbIsidDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmSctpDstDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmSctpSrcDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmTcpDstDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmTcpSrcDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmTunnelIdDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmUdpDstDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmUdpSrcDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmVlanPcpDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmVlanVidDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.MatchEntryDeserializerRegistryHelper;\r
+import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class MatchEntryDeserializerInitializer {\r
+\r
+ /**\r
+ * Registers match entry deserializers\r
+ * @param registry registry to be filled with deserializers\r
+ */\r
+ public static void registerMatchEntryDeserializers(DeserializerRegistry registry) {\r
+ // register OpenflowBasicClass match entry deserializers\r
+ MatchEntryDeserializerRegistryHelper helper =\r
+ new MatchEntryDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID,\r
+ OxmMatchConstants.OPENFLOW_BASIC_CLASS, registry);\r
+ helper.register(OxmMatchConstants.IN_PORT, new OxmInPortDeserializer());\r
+ helper.register(OxmMatchConstants.IN_PHY_PORT, new OxmInPhyPortDeserializer());\r
+ helper.register(OxmMatchConstants.METADATA, new OxmMetadataDeserializer());\r
+ helper.register(OxmMatchConstants.ETH_DST, new OxmEthDstDeserializer());\r
+ helper.register(OxmMatchConstants.ETH_SRC, new OxmEthSrcDeserializer());\r
+ helper.register(OxmMatchConstants.ETH_TYPE, new OxmEthTypeDeserializer());\r
+ helper.register(OxmMatchConstants.VLAN_VID, new OxmVlanVidDeserializer());\r
+ helper.register(OxmMatchConstants.VLAN_PCP, new OxmVlanPcpDeserializer());\r
+ helper.register(OxmMatchConstants.IP_DSCP, new OxmIpDscpDeserializer());\r
+ helper.register(OxmMatchConstants.IP_ECN, new OxmIpEcnDeserializer());\r
+ helper.register(OxmMatchConstants.IP_PROTO, new OxmIpProtoDeserializer());\r
+ helper.register(OxmMatchConstants.IPV4_SRC, new OxmIpv4SrcDeserializer());\r
+ helper.register(OxmMatchConstants.IPV4_DST, new OxmIpv4DstDeserializer());\r
+ helper.register(OxmMatchConstants.TCP_SRC, new OxmTcpSrcDeserializer());\r
+ helper.register(OxmMatchConstants.TCP_DST, new OxmTcpDstDeserializer());\r
+ helper.register(OxmMatchConstants.UDP_SRC, new OxmUdpSrcDeserializer());\r
+ helper.register(OxmMatchConstants.UDP_DST, new OxmUdpDstDeserializer());\r
+ helper.register(OxmMatchConstants.SCTP_SRC, new OxmSctpSrcDeserializer());\r
+ helper.register(OxmMatchConstants.SCTP_DST, new OxmSctpDstDeserializer());\r
+ helper.register(OxmMatchConstants.ICMPV4_TYPE, new OxmIcmpv4TypeDeserializer());\r
+ helper.register(OxmMatchConstants.ICMPV4_CODE, new OxmIcmpv4CodeDeserializer());\r
+ helper.register(OxmMatchConstants.ARP_OP, new OxmArpOpDeserializer());\r
+ helper.register(OxmMatchConstants.ARP_SPA, new OxmArpSpaDeserializer());\r
+ helper.register(OxmMatchConstants.ARP_TPA, new OxmArpTpaDeserializer());\r
+ helper.register(OxmMatchConstants.ARP_SHA, new OxmArpShaDeserializer());\r
+ helper.register(OxmMatchConstants.ARP_THA, new OxmArpThaDeserializer());\r
+ helper.register(OxmMatchConstants.IPV6_SRC, new OxmIpv6SrcDeserializer());\r
+ helper.register(OxmMatchConstants.IPV6_DST, new OxmIpv6DstDeserializer());\r
+ helper.register(OxmMatchConstants.IPV6_FLABEL, new OxmIpv6FlabelDeserializer());\r
+ helper.register(OxmMatchConstants.ICMPV6_TYPE, new OxmIcmpv6TypeDeserializer());\r
+ helper.register(OxmMatchConstants.ICMPV6_CODE, new OxmIcmpv6CodeDeserializer());\r
+ helper.register(OxmMatchConstants.IPV6_ND_TARGET, new OxmIpv6NdTargetDeserializer());\r
+ helper.register(OxmMatchConstants.IPV6_ND_SLL, new OxmIpv6NdSllDeserializer());\r
+ helper.register(OxmMatchConstants.IPV6_ND_TLL, new OxmIpv6NdTllDeserializer());\r
+ helper.register(OxmMatchConstants.MPLS_LABEL, new OxmMplsLabelDeserializer());\r
+ helper.register(OxmMatchConstants.MPLS_TC, new OxmMplsTcDeserializer());\r
+ helper.register(OxmMatchConstants.MPLS_BOS, new OxmMplsBosDeserializer());\r
+ helper.register(OxmMatchConstants.PBB_ISID, new OxmPbbIsidDeserializer());\r
+ helper.register(OxmMatchConstants.TUNNEL_ID, new OxmTunnelIdDeserializer());\r
+ helper.register(OxmMatchConstants.IPV6_EXTHDR, new OxmIpv6ExtHdrDeserializer());\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.BarrierReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoRequestMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.ErrorMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FeaturesReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FlowRemovedMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetAsyncReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetConfigReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10BarrierReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10EchoReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10EchoRequestMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10ErrorMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FeaturesReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FlowRemovedMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10GetConfigReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10HelloMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PacketInMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PortStatusMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10QueueGetConfigReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PacketInMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PortStatusMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.QueueGetConfigReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.RoleReplyMessageFactory;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.MessageDeserializerRegistryHelper;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class MessageDerializerInitializer {\r
+\r
+ /**\r
+ * Registers message deserializers\r
+ * @param registry registry to be filled with deserializers\r
+ */\r
+ public static void registerMessageDeserializers(DeserializerRegistry registry) {\r
+ // register OF v1.0 message deserializers\r
+ MessageDeserializerRegistryHelper helper =\r
+ new MessageDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry);\r
+ helper.registerMessageDeserializer(0, HelloMessage.class, new OF10HelloMessageFactory());\r
+ helper.registerMessageDeserializer(1, ErrorMessage.class, new OF10ErrorMessageFactory());\r
+ helper.registerMessageDeserializer(2, EchoRequestMessage.class, new OF10EchoRequestMessageFactory());\r
+ helper.registerMessageDeserializer(3, EchoOutput.class, new OF10EchoReplyMessageFactory());\r
+ helper.registerMessageDeserializer(6, GetFeaturesOutput.class, new OF10FeaturesReplyMessageFactory());\r
+ helper.registerMessageDeserializer(8, GetConfigOutput.class, new OF10GetConfigReplyMessageFactory());\r
+ helper.registerMessageDeserializer(10, PacketInMessage.class, new OF10PacketInMessageFactory());\r
+ helper.registerMessageDeserializer(11, FlowRemovedMessage.class, new OF10FlowRemovedMessageFactory());\r
+ helper.registerMessageDeserializer(12, PortStatusMessage.class, new OF10PortStatusMessageFactory());\r
+ helper.registerMessageDeserializer(17, MultipartReplyMessage.class, new OF10StatsReplyMessageFactory());\r
+ helper.registerMessageDeserializer(19, BarrierOutput.class, new OF10BarrierReplyMessageFactory());\r
+ helper.registerMessageDeserializer(21, GetQueueConfigOutput.class, new OF10QueueGetConfigReplyMessageFactory());\r
+ // register Of v1.3 message deserializers\r
+ helper = new MessageDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry);\r
+ helper.registerMessageDeserializer(0, HelloMessage.class, new HelloMessageFactory());\r
+ helper.registerMessageDeserializer(1, ErrorMessage.class, new ErrorMessageFactory());\r
+ helper.registerMessageDeserializer(2, EchoRequestMessage.class, new EchoRequestMessageFactory());\r
+ helper.registerMessageDeserializer(3, EchoOutput.class, new EchoReplyMessageFactory());\r
+ helper.registerMessageDeserializer(6, GetFeaturesOutput.class, new FeaturesReplyMessageFactory());\r
+ helper.registerMessageDeserializer(8, GetConfigOutput.class, new GetConfigReplyMessageFactory());\r
+ helper.registerMessageDeserializer(10, PacketInMessage.class, new PacketInMessageFactory());\r
+ helper.registerMessageDeserializer(11, FlowRemovedMessage.class, new FlowRemovedMessageFactory());\r
+ helper.registerMessageDeserializer(12, PortStatusMessage.class, new PortStatusMessageFactory());\r
+ helper.registerMessageDeserializer(19, MultipartReplyMessage.class, new MultipartReplyMessageFactory());\r
+ helper.registerMessageDeserializer(21, BarrierOutput.class, new BarrierReplyMessageFactory());\r
+ helper.registerMessageDeserializer(23, GetQueueConfigOutput.class, new QueueGetConfigReplyMessageFactory());\r
+ helper.registerMessageDeserializer(25, RoleRequestOutput.class, new RoleReplyMessageFactory());\r
+ helper.registerMessageDeserializer(27, GetAsyncOutput.class, new GetAsyncReplyMessageFactory());\r
+ }\r
+}\r
/**
- * Class used as a key in {@link DecoderTable}
+ * Class used as a key in {@link DeserializerRegistryImpl}
* @author michal.polkorab
* @author timotej.kubas
*/
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class TypeToClassKey {\r
+\r
+ private short version;\r
+ private int type;\r
+\r
+ /**\r
+ * Constructor\r
+ * @param version wire protocol version\r
+ * @param type message type / code\r
+ */\r
+ public TypeToClassKey(short version, int type) {\r
+ this.version = version;\r
+ this.type = type;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result + type;\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj)\r
+ return true;\r
+ if (obj == null)\r
+ return false;\r
+ if (getClass() != obj.getClass())\r
+ return false;\r
+ TypeToClassKey other = (TypeToClassKey) obj;\r
+ if (type != other.type)\r
+ return false;\r
+ if (version != other.version)\r
+ return false;\r
+ return true;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization;\r
+\r
+import java.util.Map;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassInitHelper;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class TypeToClassMapInitializer {\r
+\r
+ /**\r
+ * Initializes type to class map\r
+ * @param messageClassMap\r
+ */\r
+ public static void initializeTypeToClassMap(Map<TypeToClassKey, Class<?>> messageClassMap) {\r
+ // init OF v1.0 mapping\r
+ TypeToClassInitHelper helper = \r
+ new TypeToClassInitHelper(EncodeConstants.OF10_VERSION_ID, messageClassMap);\r
+ helper.registerTypeToClass((short) 0, HelloMessage.class);\r
+ helper.registerTypeToClass((short) 1, ErrorMessage.class);\r
+ helper.registerTypeToClass((short) 2, EchoRequestMessage.class);\r
+ helper.registerTypeToClass((short) 3, EchoOutput.class);\r
+ helper.registerTypeToClass((short) 4, ExperimenterMessage.class);\r
+ helper.registerTypeToClass((short) 6, GetFeaturesOutput.class);\r
+ helper.registerTypeToClass((short) 8, GetConfigOutput.class);\r
+ helper.registerTypeToClass((short) 10, PacketInMessage.class);\r
+ helper.registerTypeToClass((short) 11, FlowRemovedMessage.class);\r
+ helper.registerTypeToClass((short) 12, PortStatusMessage.class);\r
+ helper.registerTypeToClass((short) 17, MultipartReplyMessage.class);\r
+ helper.registerTypeToClass((short) 19, BarrierOutput.class);\r
+ helper.registerTypeToClass((short) 21, GetQueueConfigOutput.class);\r
+ // init OF v1.0 mapping\r
+ helper = new TypeToClassInitHelper(EncodeConstants.OF13_VERSION_ID, messageClassMap);\r
+ helper.registerTypeToClass((short) 0, HelloMessage.class);\r
+ helper.registerTypeToClass((short) 1, ErrorMessage.class);\r
+ helper.registerTypeToClass((short) 2, EchoRequestMessage.class);\r
+ helper.registerTypeToClass((short) 3, EchoOutput.class);\r
+ helper.registerTypeToClass((short) 4, ExperimenterMessage.class);\r
+ helper.registerTypeToClass((short) 6, GetFeaturesOutput.class);\r
+ helper.registerTypeToClass((short) 8, GetConfigOutput.class);\r
+ helper.registerTypeToClass((short) 10, PacketInMessage.class);\r
+ helper.registerTypeToClass((short) 11, FlowRemovedMessage.class);\r
+ helper.registerTypeToClass((short) 12, PortStatusMessage.class);\r
+ helper.registerTypeToClass((short) 19, MultipartReplyMessage.class);\r
+ helper.registerTypeToClass((short) 21, BarrierOutput.class);\r
+ helper.registerTypeToClass((short) 23, GetQueueConfigOutput.class);\r
+ helper.registerTypeToClass((short) 25, RoleRequestOutput.class);\r
+ helper.registerTypeToClass((short) 27, GetAsyncOutput.class);\r
+ }\r
+}\r
import io.netty.buffer.ByteBuf;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder;
* @author michal.polkorab
* @author timotej.kubas
*/
-public class BarrierReplyMessageFactory implements
- OFDeserializer<BarrierOutput> {
-
- private static BarrierReplyMessageFactory instance;
-
- private BarrierReplyMessageFactory() {
- // do nothing, just singleton
- }
-
- /**
- * @return singleton factory
- */
- public static synchronized BarrierReplyMessageFactory getInstance() {
- if (instance == null) {
- instance = new BarrierReplyMessageFactory();
- }
- return instance;
- }
+public class BarrierReplyMessageFactory implements OFDeserializer<BarrierOutput> {
@Override
- public BarrierOutput bufferToMessage(ByteBuf rawMessage, short version) {
+ public BarrierOutput deserialize(ByteBuf rawMessage) {
BarrierOutputBuilder builder = new BarrierOutputBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
return builder.build();
}
-
}
import io.netty.buffer.ByteBuf;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutputBuilder;
*/
public class EchoReplyMessageFactory implements OFDeserializer<EchoOutput> {
- private static EchoReplyMessageFactory instance;
-
- private EchoReplyMessageFactory() {
- // do nothing, just singleton
- }
-
- /**
- * @return singleton factory
- */
- public static synchronized EchoReplyMessageFactory getInstance() {
- if (instance == null) {
- instance = new EchoReplyMessageFactory();
- }
- return instance;
- }
-
@Override
- public EchoOutput bufferToMessage(ByteBuf rawMessage, short version) {
+ public EchoOutput deserialize(ByteBuf rawMessage) {
EchoOutputBuilder builder = new EchoOutputBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
int remainingBytes = rawMessage.readableBytes();
if (remainingBytes > 0) {
import io.netty.buffer.ByteBuf;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder;
*/
public class EchoRequestMessageFactory implements OFDeserializer<EchoRequestMessage>{
- private static EchoRequestMessageFactory instance;
-
- private EchoRequestMessageFactory() {
- // do nothing, just singleton
- }
-
- /**
- * @return singleton factory
- */
- public static synchronized EchoRequestMessageFactory getInstance() {
- if (instance == null) {
- instance = new EchoRequestMessageFactory();
- }
- return instance;
- }
-
@Override
- public EchoRequestMessage bufferToMessage(ByteBuf rawMessage, short version) {
+ public EchoRequestMessage deserialize(ByteBuf rawMessage) {
EchoRequestMessageBuilder builder = new EchoRequestMessageBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array());
return builder.build();
import io.netty.buffer.ByteBuf;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterError;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterErrorBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadActionCode;
private static final String UNKNOWN_CODE = "UNKNOWN_CODE";
private static final String UNKNOWN_TYPE = "UNKNOWN_TYPE";
-
- private static ErrorMessageFactory instance;
-
- private ErrorMessageFactory() {
- // do nothing, just singleton
- }
-
- /**
- * @return singleton factory
- */
- public static synchronized ErrorMessageFactory getInstance() {
- if (instance == null) {
- instance = new ErrorMessageFactory();
- }
- return instance;
- }
-
+
@Override
- public ErrorMessage bufferToMessage(ByteBuf rawMessage, short version) {
+ public ErrorMessage deserialize(ByteBuf rawMessage) {
ErrorMessageBuilder builder = new ErrorMessageBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
int type = rawMessage.readUnsignedShort();
ErrorType errorType = ErrorType.forValue(type);
+++ /dev/null
-/*
- * Copyright (c) 2013 Pantheon Technologies s.r.o. 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.factories;
-
-import io.netty.buffer.ByteBuf;
-
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder;
-
-/**
- * Translates Experimenter messages
- * @author michal.polkorab,
- * @author timotej.kubas
- */
-public class ExperimenterMessageFactory implements OFDeserializer<ExperimenterMessage>{
-
- private static ExperimenterMessageFactory instance;
-
- private ExperimenterMessageFactory() {
- //singleton
- }
-
-
- /**
- * @return singleton factory
- */
- public static synchronized ExperimenterMessageFactory getInstance(){
- if (instance == null){
- instance = new ExperimenterMessageFactory();
- }
- return instance;
- }
-
- @Override
- public ExperimenterMessage bufferToMessage(ByteBuf rawMessage, short version) {
- ExperimenterMessageBuilder builder = new ExperimenterMessageBuilder();
- builder.setVersion(version);
- builder.setXid(rawMessage.readUnsignedInt());
- builder.setExperimenter(rawMessage.readUnsignedInt());
- builder.setExpType(rawMessage.readUnsignedInt());
- int remainingBytes = rawMessage.readableBytes();
- if (remainingBytes > 0) {
- builder.setData(rawMessage.readBytes(remainingBytes).array());
- }
- return builder.build();
- }
-}
import java.math.BigInteger;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
* @author timotej.kubas
*/
public class FeaturesReplyMessageFactory implements OFDeserializer<GetFeaturesOutput>{
-
+
private static final byte PADDING_IN_FEATURES_REPLY_HEADER = 2;
-
- private static FeaturesReplyMessageFactory instance;
- private FeaturesReplyMessageFactory() {
- // do nothing, just singleton
- }
-
- /**
- * @return singleton factory
- */
- public static synchronized FeaturesReplyMessageFactory getInstance() {
- if (instance == null) {
- instance = new FeaturesReplyMessageFactory();
- }
- return instance;
- }
-
@Override
- public GetFeaturesOutput bufferToMessage(ByteBuf rawMessage, short version) {
+ public GetFeaturesOutput deserialize(ByteBuf rawMessage) {
GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
byte[] datapathId = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
rawMessage.readBytes(datapathId);
import java.math.BigInteger;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
-import org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder;
* @author michal.polkorab
* @author timotej.kubas
*/
-public class FlowRemovedMessageFactory implements OFDeserializer<FlowRemovedMessage> {
-
- private static FlowRemovedMessageFactory instance;
-
- private FlowRemovedMessageFactory() {
- // singleton
- }
-
- /**
- * @return singleton factory
- */
- public static synchronized FlowRemovedMessageFactory getInstance(){
- if(instance == null){
- instance = new FlowRemovedMessageFactory();
- }
- return instance;
- }
+public class FlowRemovedMessageFactory implements OFDeserializer<FlowRemovedMessage>,
+ DeserializerRegistryInjector {
+
+ private DeserializerRegistry registry;
@Override
- public FlowRemovedMessage bufferToMessage(ByteBuf rawMessage, short version) {
+ public FlowRemovedMessage deserialize(ByteBuf rawMessage) {
FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
rawMessage.readBytes(cookie);
byte[] byte_count = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
rawMessage.readBytes(byte_count);
builder.setByteCount(new BigInteger(1, byte_count));
- builder.setMatch(MatchDeserializer.createMatch(rawMessage));
+ OFDeserializer<Match> matchDeserializer = registry.getDeserializer(new MessageCodeKey(
+ EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class));
+ builder.setMatch(matchDeserializer.deserialize(rawMessage));
return builder.build();
}
+
+ @Override
+ public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+ registry = deserializerRegistry;
+ }
}
import java.util.ArrayList;
import java.util.List;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;
* @author michal.polkorab
*/
public class GetAsyncReplyMessageFactory implements OFDeserializer<GetAsyncOutput> {
-
- private static GetAsyncReplyMessageFactory instance;
+
private static final byte SEPARATE_ROLES = 2;
-
- private GetAsyncReplyMessageFactory() {
- // singleton
- }
- /**
- * @return singleton factory
- */
- public static synchronized GetAsyncReplyMessageFactory getInstance() {
- if (instance == null) {
- instance = new GetAsyncReplyMessageFactory();
- }
- return instance;
- }
-
@Override
- public GetAsyncOutput bufferToMessage(ByteBuf rawMessage, short version) {
+ public GetAsyncOutput deserialize(ByteBuf rawMessage) {
GetAsyncOutputBuilder builder = new GetAsyncOutputBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
builder.setPacketInMask(decodePacketInMask(rawMessage));
builder.setPortStatusMask(decodePortStatusMask(rawMessage));
import io.netty.buffer.ByteBuf;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutputBuilder;
*/
public class GetConfigReplyMessageFactory implements OFDeserializer<GetConfigOutput> {
- private static GetConfigReplyMessageFactory instance;
-
- private GetConfigReplyMessageFactory() {
- // singleton
- }
-
- /**
- * @return singleton factory
- */
- public static synchronized GetConfigReplyMessageFactory getInstance(){
- if(instance == null){
- instance = new GetConfigReplyMessageFactory();
- }
- return instance;
- }
-
@Override
- public GetConfigOutput bufferToMessage(ByteBuf rawMessage, short version) {
+ public GetConfigOutput deserialize(ByteBuf rawMessage) {
GetConfigOutputBuilder builder = new GetConfigOutputBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
builder.setFlags(SwitchConfigFlag.forValue(rawMessage.readUnsignedShort()));
builder.setMissSendLen(rawMessage.readUnsignedShort());
import java.util.ArrayList;
import java.util.List;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloElementType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;
*/
public class HelloMessageFactory implements OFDeserializer<HelloMessage> {
- private static HelloMessageFactory instance;
private static final byte HELLO_ELEMENT_HEADER_SIZE = 4;
-
- private HelloMessageFactory() {
- // do nothing, just singleton
- }
-
- /**
- * @return singleton factory
- */
- public static synchronized HelloMessageFactory getInstance() {
- if (instance == null) {
- instance = new HelloMessageFactory();
- }
- return instance;
- }
-
@Override
- public HelloMessage bufferToMessage(ByteBuf rawMessage, short version) {
+ public HelloMessage deserialize(ByteBuf rawMessage) {
HelloMessageBuilder builder = new HelloMessageBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
if (rawMessage.readableBytes() > 0) {
builder.setElements(readElement(rawMessage));
import java.util.ArrayList;
import java.util.List;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
-import org.opendaylight.openflowjava.protocol.impl.util.ActionsDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.openflowjava.protocol.impl.util.DecodingUtils;
import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
-import org.opendaylight.openflowjava.protocol.impl.util.InstructionsDeserializer;
-import org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeatureProperty;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeaturePropertyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIds;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIdsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList;
* @author timotej.kubas
* @author michal.polkorab
*/
-public class MultipartReplyMessageFactory implements OFDeserializer<MultipartReplyMessage> {
+public class MultipartReplyMessageFactory implements OFDeserializer<MultipartReplyMessage>,
+ DeserializerRegistryInjector {
private static final byte PADDING_IN_MULTIPART_REPLY_HEADER = 4;
private static final int DESC_STR_LEN = 256;
private static final byte PADDING_IN_BUCKETS_HEADER = 4;
private static final byte GROUP_DESC_HEADER_LENGTH = 8;
private static final byte BUCKETS_HEADER_LENGTH = 16;
-
-
- private static MultipartReplyMessageFactory instance;
-
- private MultipartReplyMessageFactory() {
- // singleton
- }
-
- /**
- * @return singleton factory
- */
- public static synchronized MultipartReplyMessageFactory getInstance() {
- if (instance == null){
- instance = new MultipartReplyMessageFactory();
- }
- return instance;
- }
+ private DeserializerRegistry registry;
@Override
- public MultipartReplyMessage bufferToMessage(ByteBuf rawMessage, short version) {
+ public MultipartReplyMessage deserialize(ByteBuf rawMessage) {
MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
int type = rawMessage.readUnsignedShort();
builder.setType(MultipartType.forValue(type));
return caseBuilder.build();
}
- private static MultipartReplyFlowCase setFlow(ByteBuf input) {
+ private MultipartReplyFlowCase setFlow(ByteBuf input) {
MultipartReplyFlowCaseBuilder caseBuilder = new MultipartReplyFlowCaseBuilder();
MultipartReplyFlowBuilder flowBuilder = new MultipartReplyFlowBuilder();
List<FlowStats> flowStatsList = new ArrayList<>();
byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
subInput.readBytes(byteCount);
flowStatsBuilder.setByteCount(new BigInteger(1, byteCount));
- flowStatsBuilder.setMatch(MatchDeserializer.createMatch(subInput));
- flowStatsBuilder.setInstruction(InstructionsDeserializer.createInstructions(subInput, subInput.readableBytes()));
+ OFDeserializer<Match> matchDeserializer = registry.getDeserializer(new MessageCodeKey(
+ EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class));
+ flowStatsBuilder.setMatch(matchDeserializer.deserialize(subInput));
+ OFDeserializer<Instruction> insDeserializer = registry.getDeserializer(new MessageCodeKey(
+ EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Instruction.class));
+ List<Instruction> instructions = DecodingUtils.deserializeList(
+ subInput.readableBytes(), subInput, insDeserializer);
+ flowStatsBuilder.setInstruction(instructions);
flowStatsList.add(flowStatsBuilder.build());
}
flowBuilder.setFlowStats(flowStatsList);
return caseBuilder.build();
}
- private static MultipartReplyTableFeaturesCase setTableFeatures(ByteBuf input) {
+ private MultipartReplyTableFeaturesCase setTableFeatures(ByteBuf input) {
MultipartReplyTableFeaturesCaseBuilder caseBuilder = new MultipartReplyTableFeaturesCaseBuilder();
MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();
List<TableFeatures> features = new ArrayList<>();
return new TableConfig(deprecated);
}
- private static List<TableFeatureProperties> createTableFeaturesProperties(ByteBuf input, int length) {
+ private List<TableFeatureProperties> createTableFeaturesProperties(ByteBuf input, int length) {
List<TableFeatureProperties> properties = new ArrayList<>();
int tableFeaturesLength = length;
while (tableFeaturesLength > 0) {
if (type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONS)
|| type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS)) {
InstructionRelatedTableFeaturePropertyBuilder insBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
- insBuilder.setInstruction(InstructionsDeserializer.createInstructionIds(input, propertyLength - COMMON_PROPERTY_LENGTH));
+ HeaderDeserializer<Instruction> insDeserializer = registry.getDeserializer(new MessageCodeKey(
+ EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Instruction.class));
+ List<Instruction> instructions = DecodingUtils.deserializeHeaders(
+ propertyLength - COMMON_PROPERTY_LENGTH, input, insDeserializer);
+ insBuilder.setInstruction(instructions);
builder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insBuilder.build());
} else if (type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLES)
|| type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS)) {
|| type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONS)
|| type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS)) {
ActionRelatedTableFeaturePropertyBuilder actionBuilder = new ActionRelatedTableFeaturePropertyBuilder();
- actionBuilder.setAction(ActionsDeserializer.createActionIds(input, propertyLength - COMMON_PROPERTY_LENGTH));
+ HeaderDeserializer<Action> deserializer = registry.getDeserializer(new MessageCodeKey(
+ EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Action.class));
+ List<Action> actions = DecodingUtils.deserializeHeaders(
+ propertyLength - COMMON_PROPERTY_LENGTH, input, deserializer);
+ actionBuilder.setAction(actions);
builder.addAugmentation(ActionRelatedTableFeatureProperty.class, actionBuilder.build());
} else if (type.equals(TableFeaturesPropType.OFPTFPTMATCH)
|| type.equals(TableFeaturesPropType.OFPTFPTWILDCARDS)
|| type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD)
|| type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS)) {
OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
- oxmBuilder.setMatchEntries(MatchDeserializer.createMatchIds(input, propertyLength - COMMON_PROPERTY_LENGTH));
+ oxmBuilder.setMatchEntries(DecodingUtils.deserializeMatchEntryHeaders(
+ propertyLength - COMMON_PROPERTY_LENGTH, input, registry));
builder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
} else if (type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTER)
|| type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS)) {
ExperimenterRelatedTableFeaturePropertyBuilder expBuilder = new ExperimenterRelatedTableFeaturePropertyBuilder();
expBuilder.setExperimenter(input.readUnsignedInt());
expBuilder.setExpType(input.readUnsignedInt());
- int dataLength = propertyLength - COMMON_PROPERTY_LENGTH - 2 * EncodeConstants.SIZE_OF_INT_IN_BYTES;
- if (dataLength > 0) {
- byte[] data = new byte[dataLength];
- input.readBytes(data);
- expBuilder.setData(data);
- }
- builder.addAugmentation(ExperimenterRelatedTableFeatureProperty.class, expBuilder.build());
+ OFDeserializer<ExperimenterRelatedTableFeatureProperty> propDeserializer = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF13_VERSION_ID,
+ type.getIntValue(), ExperimenterRelatedTableFeatureProperty.class));
+ ExperimenterRelatedTableFeatureProperty expProp = propDeserializer.deserialize(input);
+ builder.addAugmentation(ExperimenterRelatedTableFeatureProperty.class, expProp);
}
if (paddingRemainder != 0) {
input.skipBytes(EncodeConstants.PADDING - paddingRemainder);
return new GroupTypes(OFPGT_ALL, OFPGT_FF, OFPGT_INDIRECT, OFPGT_SELECT);
}
- private static MultipartReplyGroupDescCase setGroupDesc(ByteBuf input) {
+ private MultipartReplyGroupDescCase setGroupDesc(ByteBuf input) {
MultipartReplyGroupDescCaseBuilder caseBuilder = new MultipartReplyGroupDescCaseBuilder();
MultipartReplyGroupDescBuilder builder = new MultipartReplyGroupDescBuilder();
List<GroupDesc> groupDescsList = new ArrayList<>();
bucketsBuilder.setWatchPort(new PortNumber(input.readUnsignedInt()));
bucketsBuilder.setWatchGroup(input.readUnsignedInt());
input.skipBytes(PADDING_IN_BUCKETS_HEADER);
- List<Action> actionsList = ActionsDeserializer
- .createActions(input, bucketsLength - BUCKETS_HEADER_LENGTH);
+ OFDeserializer<Action> deserializer = registry.getDeserializer(new MessageCodeKey(
+ EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Action.class));
+ List<Action> actionsList = DecodingUtils.deserializeList(
+ bucketsLength - BUCKETS_HEADER_LENGTH, input, deserializer);
bucketsBuilder.setAction(actionsList);
bucketsList.add(bucketsBuilder.build());
actualLength += bucketsLength;
caseBuilder.setMultipartReplyGroupDesc(builder.build());
return caseBuilder.build();
}
-
+
+ @Override
+ public void injectDeserializerRegistry(
+ DeserializerRegistry deserializerRegistry) {
+ registry = deserializerRegistry;
+ }
}
--- /dev/null
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. 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.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder;
+
+/**
+ * Translates BarrierReply messages (both OpenFlow v1.0 and OpenFlow v1.3)
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class OF10BarrierReplyMessageFactory implements OFDeserializer<BarrierOutput> {
+
+ @Override
+ public BarrierOutput deserialize(ByteBuf rawMessage) {
+ BarrierOutputBuilder builder = new BarrierOutputBuilder();
+ builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
+ builder.setXid(rawMessage.readUnsignedInt());
+ return builder.build();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. 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.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutputBuilder;
+
+/**
+ * Translates EchoReply messages (both OpenFlow v1.0 and OpenFlow v1.3)
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class OF10EchoReplyMessageFactory implements OFDeserializer<EchoOutput> {
+
+ @Override
+ public EchoOutput deserialize(ByteBuf rawMessage) {
+ EchoOutputBuilder builder = new EchoOutputBuilder();
+ builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
+ builder.setXid(rawMessage.readUnsignedInt());
+ int remainingBytes = rawMessage.readableBytes();
+ if (remainingBytes > 0) {
+ builder.setData(rawMessage.readBytes(remainingBytes).array());
+ }
+ return builder.build();
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. 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.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder;
+
+/**
+ * Translates EchoRequest messages (both OpenFlow v1.0 and OpenFlow v1.3)
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class OF10EchoRequestMessageFactory implements OFDeserializer<EchoRequestMessage>{
+
+ @Override
+ public EchoRequestMessage deserialize(ByteBuf rawMessage) {
+ EchoRequestMessageBuilder builder = new EchoRequestMessageBuilder();
+ builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
+ builder.setXid(rawMessage.readUnsignedInt());
+ builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array());
+ return builder.build();
+ }
+}
import io.netty.buffer.ByteBuf;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadActionCodeV10;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadRequestCodeV10;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ErrorTypeV10;
*/
public class OF10ErrorMessageFactory implements OFDeserializer<ErrorMessage> {
- private static final String UNKNOWN_TYPE = "UNKNOWN_TYPE";
+ private static final String UNKNOWN_TYPE = "UNKNOWN_TYPE";
private static final String UNKNOWN_CODE = "UNKNOWN_CODE";
-
- private static OF10ErrorMessageFactory instance;
-
- private OF10ErrorMessageFactory() {
- // do nothing, just singleton
- }
-
- /**
- * @return singleton factory
- */
- public static synchronized OF10ErrorMessageFactory getInstance() {
- if (instance == null) {
- instance = new OF10ErrorMessageFactory();
- }
- return instance;
- }
-
+
@Override
- public ErrorMessage bufferToMessage(ByteBuf rawMessage, short version) {
+ public ErrorMessage deserialize(ByteBuf rawMessage) {
ErrorMessageBuilder builder = new ErrorMessageBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
int type = rawMessage.readUnsignedShort();
ErrorTypeV10 errorType = ErrorTypeV10.forValue(type);
import java.util.ArrayList;
import java.util.List;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
public class OF10FeaturesReplyMessageFactory implements OFDeserializer<GetFeaturesOutput> {
private static final byte PADDING_IN_FEATURES_REPLY_HEADER = 3;
-
- private static OF10FeaturesReplyMessageFactory instance;
- private OF10FeaturesReplyMessageFactory() {
- // do nothing, just singleton
- }
-
- /**
- * @return singleton factory
- */
- public static synchronized OF10FeaturesReplyMessageFactory getInstance() {
- if (instance == null) {
- instance = new OF10FeaturesReplyMessageFactory();
- }
- return instance;
- }
-
@Override
- public GetFeaturesOutput bufferToMessage(ByteBuf rawMessage, short version) {
+ public GetFeaturesOutput deserialize(ByteBuf rawMessage) {
GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
byte[] datapathId = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
rawMessage.readBytes(datapathId);
import java.math.BigInteger;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
-import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchDeserializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder;
* Translates FlowRemoved messages (OpenFlow v1.0)
* @author michal.polkorab
*/
-public class OF10FlowRemovedMessageFactory implements OFDeserializer<FlowRemovedMessage> {
+public class OF10FlowRemovedMessageFactory implements OFDeserializer<FlowRemovedMessage>,
+ DeserializerRegistryInjector {
private static final byte PADDING_IN_FLOW_REMOVED_MESSAGE = 1;
private static final byte PADDING_IN_FLOW_REMOVED_MESSAGE_2 = 2;
-
-
- private static OF10FlowRemovedMessageFactory instance;
-
- private OF10FlowRemovedMessageFactory() {
- // singleton
- }
-
- /**
- * @return singleton factory
- */
- public static synchronized OF10FlowRemovedMessageFactory getInstance(){
- if(instance == null){
- instance = new OF10FlowRemovedMessageFactory();
- }
- return instance;
- }
+ private DeserializerRegistry registry;
@Override
- public FlowRemovedMessage bufferToMessage(ByteBuf rawMessage, short version) {
+ public FlowRemovedMessage deserialize(ByteBuf rawMessage) {
FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
- builder.setMatchV10(OF10MatchDeserializer.createMatchV10(rawMessage));
+ OFDeserializer<MatchV10> matchDeserializer = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class));
+ builder.setMatchV10(matchDeserializer.deserialize(rawMessage));
byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
rawMessage.readBytes(cookie);
builder.setCookie(new BigInteger(1, cookie));
return builder.build();
}
-
+ @Override
+ public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+ registry = deserializerRegistry;
+ }
}
--- /dev/null
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. 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.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutputBuilder;
+
+/**
+ * Translates GetConfigReply messages (both OpenFlow v1.0 and OpenFlow v1.3)
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class OF10GetConfigReplyMessageFactory implements OFDeserializer<GetConfigOutput> {
+
+ @Override
+ public GetConfigOutput deserialize(ByteBuf rawMessage) {
+ GetConfigOutputBuilder builder = new GetConfigOutputBuilder();
+ builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
+ builder.setXid(rawMessage.readUnsignedInt());
+ builder.setFlags(SwitchConfigFlag.forValue(rawMessage.readUnsignedShort()));
+ builder.setMissSendLen(rawMessage.readUnsignedShort());
+ return builder.build();
+ }
+}
import io.netty.buffer.ByteBuf;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder;
* @author michal.polkorab
*/
public class OF10HelloMessageFactory implements OFDeserializer<HelloMessage> {
-
-private static OF10HelloMessageFactory instance;
-
- private OF10HelloMessageFactory() {
- // do nothing, just singleton
- }
-
- /**
- * @return singleton factory
- */
- public static synchronized OF10HelloMessageFactory getInstance() {
- if (instance == null) {
- instance = new OF10HelloMessageFactory();
- }
- return instance;
- }
-
+
@Override
- public HelloMessage bufferToMessage(ByteBuf rawMessage, short version) {
+ public HelloMessage deserialize(ByteBuf rawMessage) {
HelloMessageBuilder builder = new HelloMessageBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
if (rawMessage.readableBytes() > 0) {
rawMessage.skipBytes(rawMessage.readableBytes());
import io.netty.buffer.ByteBuf;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder;
private static final byte PADDING_IN_PACKET_IN_HEADER = 1;
- private static OF10PacketInMessageFactory instance;
-
- private OF10PacketInMessageFactory() {
- // Singleton
- }
-
- /**
- * @return singleton factory
- */
- public static synchronized OF10PacketInMessageFactory getInstance(){
- if(instance == null){
- instance = new OF10PacketInMessageFactory();
- }
- return instance;
- }
-
@Override
- public PacketInMessage bufferToMessage(ByteBuf rawMessage, short version) {
+ public PacketInMessage deserialize(ByteBuf rawMessage) {
PacketInMessageBuilder builder = new PacketInMessageBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
builder.setBufferId(rawMessage.readUnsignedInt());
builder.setTotalLen(rawMessage.readUnsignedShort());
import io.netty.buffer.ByteBuf;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
private static final byte PADDING_IN_PORT_STATUS_HEADER = 7;
- private static OF10PortStatusMessageFactory instance;
-
- private OF10PortStatusMessageFactory() {
- // Singleton
- }
-
- /**
- * @return singleton factory
- */
- public static synchronized OF10PortStatusMessageFactory getInstance(){
- if(instance == null){
- instance = new OF10PortStatusMessageFactory();
- }
- return instance;
- }
-
@Override
- public PortStatusMessage bufferToMessage(ByteBuf rawMessage, short version) {
+ public PortStatusMessage deserialize(ByteBuf rawMessage) {
PortStatusMessageBuilder builder = new PortStatusMessageBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
builder.setReason(PortReason.forValue(rawMessage.readUnsignedByte()));
rawMessage.skipBytes(PADDING_IN_PORT_STATUS_HEADER);
import java.util.ArrayList;
import java.util.List;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueuePropertyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
private static final byte PADDING_IN_RATE_QUEUE_PROPERTY = 6;
private static final byte PACKET_QUEUE_HEADER_LENGTH = 8;
- private static OF10QueueGetConfigReplyMessageFactory instance;
-
- private OF10QueueGetConfigReplyMessageFactory() {
- // singleton
- }
-
- /**
- *
- * @return singleton factory
- */
- public static synchronized OF10QueueGetConfigReplyMessageFactory getInstance(){
-
- if(instance == null){
- instance = new OF10QueueGetConfigReplyMessageFactory();
- }
- return instance;
- }
-
@Override
- public GetQueueConfigOutput bufferToMessage(ByteBuf rawMessage, short version) {
+ public GetQueueConfigOutput deserialize(ByteBuf rawMessage) {
GetQueueConfigOutputBuilder builder = new GetQueueConfigOutputBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid((rawMessage.readUnsignedInt()));
builder.setPort(new PortNumber((long) rawMessage.readUnsignedShort()));
rawMessage.skipBytes(PADDING_IN_QUEUE_GET_CONFIG_REPLY_HEADER);
import java.util.ArrayList;
import java.util.List;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.openflowjava.protocol.impl.util.DecodingUtils;
import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
-import org.opendaylight.openflowjava.protocol.impl.util.OF10ActionsDeserializer;
import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchDeserializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase;
* Translates StatsReply messages (OpenFlow v1.0)
* @author michal.polkorab
*/
-public class OF10StatsReplyMessageFactory implements OFDeserializer<MultipartReplyMessage> {
+public class OF10StatsReplyMessageFactory implements OFDeserializer<MultipartReplyMessage>,
+ DeserializerRegistryInjector {
private static final int DESC_STR_LEN = 256;
private static final int SERIAL_NUM_LEN = 32;
private static final byte PADDING_IN_QUEUE_HEADER = 2;
private static final byte LENGTH_OF_FLOW_STATS = 88;
private static final int TABLE_STATS_LENGTH = 64;
-
- private static OF10StatsReplyMessageFactory instance;
-
- private OF10StatsReplyMessageFactory() {
- // singleton
- }
-
- /**
- * @return singleton factory
- */
- public static synchronized OF10StatsReplyMessageFactory getInstance() {
- if (instance == null){
- instance = new OF10StatsReplyMessageFactory();
- }
- return instance;
- }
+ private DeserializerRegistry registry;
@Override
- public MultipartReplyMessage bufferToMessage(ByteBuf rawMessage, short version) {
+ public MultipartReplyMessage deserialize(ByteBuf rawMessage) {
MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
int type = rawMessage.readUnsignedShort();
builder.setType(MultipartType.forValue(type));
return caseBuilder.build();
}
- private static MultipartReplyFlowCase setFlow(ByteBuf input) {
+ private MultipartReplyFlowCase setFlow(ByteBuf input) {
MultipartReplyFlowCaseBuilder caseBuilder = new MultipartReplyFlowCaseBuilder();
MultipartReplyFlowBuilder flowBuilder = new MultipartReplyFlowBuilder();
List<FlowStats> flowStatsList = new ArrayList<>();
int length = input.readUnsignedShort();
flowStatsBuilder.setTableId(input.readUnsignedByte());
input.skipBytes(PADDING_IN_FLOW_STATS_HEADER);
- flowStatsBuilder.setMatchV10(OF10MatchDeserializer.createMatchV10(input));
+ OFDeserializer<MatchV10> matchDeserializer = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class));
+ flowStatsBuilder.setMatchV10(matchDeserializer.deserialize(input));
flowStatsBuilder.setDurationSec(input.readUnsignedInt());
flowStatsBuilder.setDurationNsec(input.readUnsignedInt());
flowStatsBuilder.setPriority(input.readUnsignedShort());
byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(byteCount);
flowStatsBuilder.setByteCount(new BigInteger(1, byteCount));
- flowStatsBuilder.setAction(OF10ActionsDeserializer
- .createActionsList(input, length - LENGTH_OF_FLOW_STATS));
+ OFDeserializer<Action> deserializer = registry.getDeserializer(new MessageCodeKey(
+ EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, Action.class));
+ List<Action> actions = DecodingUtils.deserializeList(length - LENGTH_OF_FLOW_STATS,
+ input, deserializer);
+ flowStatsBuilder.setAction(actions);
flowStatsList.add(flowStatsBuilder.build());
}
flowBuilder.setFlowStats(flowStatsList);
caseBuilder.setMultipartReplyExperimenter(builder.build());
return caseBuilder.build();
}
+
+ @Override
+ public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+ registry = deserializerRegistry;
+ }
}
+++ /dev/null
-/*
- * Copyright (c) 2013 Pantheon Technologies s.r.o. 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.factories;
-
-import io.netty.buffer.ByteBuf;
-
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder;
-
-/**
- * Translates Vendor messages (OpenFlow v1.0)
- * @author michal.polkorab
- */
-public class OF10VendorMessageFactory implements OFDeserializer<ExperimenterMessage> {
-
-private static OF10VendorMessageFactory instance;
-
- private OF10VendorMessageFactory() {
- //singleton
- }
-
- /**
- * @return singleton factory
- */
- public static synchronized OF10VendorMessageFactory getInstance(){
- if (instance == null){
- instance = new OF10VendorMessageFactory();
- }
- return instance;
- }
-
- @Override
- public ExperimenterMessage bufferToMessage(ByteBuf rawMessage, short version) {
- ExperimenterMessageBuilder builder = new ExperimenterMessageBuilder();
- builder.setVersion(version);
- builder.setXid(rawMessage.readUnsignedInt());
- builder.setExperimenter(rawMessage.readUnsignedInt());
- int remainingBytes = rawMessage.readableBytes();
- if (remainingBytes > 0) {
- builder.setData(rawMessage.readBytes(remainingBytes).array());
- }
- return builder.build();
- }
-}
import java.math.BigInteger;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
-import org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder;
* @author michal.polkorab
* @author timotej.kubas
*/
-public class PacketInMessageFactory implements OFDeserializer<PacketInMessage> {
+public class PacketInMessageFactory implements OFDeserializer<PacketInMessage>,
+ DeserializerRegistryInjector {
- private static PacketInMessageFactory instance;
private static final byte PADDING_IN_PACKET_IN_HEADER = 2;
-
- private PacketInMessageFactory() {
- // Singleton
- }
-
- /**
- * @return singleton factory
- */
- public static synchronized PacketInMessageFactory getInstance(){
- if(instance == null){
- instance = new PacketInMessageFactory();
- }
- return instance;
- }
+ private DeserializerRegistry registry;
@Override
- public PacketInMessage bufferToMessage(ByteBuf rawMessage, short version) {
+ public PacketInMessage deserialize(ByteBuf rawMessage) {
PacketInMessageBuilder builder = new PacketInMessageBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
builder.setBufferId(rawMessage.readUnsignedInt());
builder.setTotalLen(rawMessage.readUnsignedShort());
byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
rawMessage.readBytes(cookie);
builder.setCookie(new BigInteger(1, cookie));
- builder.setMatch(MatchDeserializer.createMatch(rawMessage));
+ OFDeserializer<Match> matchDeserializer = registry.getDeserializer(new MessageCodeKey(
+ EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class));
+ builder.setMatch(matchDeserializer.deserialize(rawMessage));
rawMessage.skipBytes(PADDING_IN_PACKET_IN_HEADER);
builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array());
return builder.build();
}
+
+ @Override
+ public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+ registry = deserializerRegistry;
+ }
}
import io.netty.buffer.ByteBuf;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
*/
public class PortStatusMessageFactory implements OFDeserializer<PortStatusMessage> {
- private static PortStatusMessageFactory instance;
private static final byte PADDING_IN_PORT_STATUS_HEADER = 7;
private static final byte PADDING_IN_OFP_PORT_HEADER_1 = 4;
private static final byte PADDING_IN_OFP_PORT_HEADER_2 = 2;
-
- private PortStatusMessageFactory() {
- // Singleton
- }
-
- /**
- * @return singleton factory
- */
- public static synchronized PortStatusMessageFactory getInstance(){
- if(instance == null){
- instance = new PortStatusMessageFactory();
- }
- return instance;
- }
-
+
@Override
- public PortStatusMessage bufferToMessage(ByteBuf rawMessage, short version) {
+ public PortStatusMessage deserialize(ByteBuf rawMessage) {
PortStatusMessageBuilder builder = new PortStatusMessageBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
builder.setReason(PortReason.forValue(rawMessage.readUnsignedByte()));
rawMessage.skipBytes(PADDING_IN_PORT_STATUS_HEADER);
final Boolean _noPacketIn = ((input) & (1<<6)) != 0;
return new PortConfig(_noFwd, _noPacketIn, _noRecv, _portDown);
}
-
}
import java.util.ArrayList;
import java.util.List;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterQueuePropertyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty;
private static final int PADDING_IN_EXPERIMENTER_QUEUE_PROPERTY = 4;
private static final byte PACKET_QUEUE_LENGTH = 16;
- private static QueueGetConfigReplyMessageFactory instance;
-
- private QueueGetConfigReplyMessageFactory() {
- // singleton
- }
-
- /**
- *
- * @return singleton factory
- */
- public static synchronized QueueGetConfigReplyMessageFactory getInstance(){
-
- if(instance == null){
- instance = new QueueGetConfigReplyMessageFactory();
- }
- return instance;
- }
-
@Override
- public GetQueueConfigOutput bufferToMessage(ByteBuf rawMessage, short version) {
+ public GetQueueConfigOutput deserialize(ByteBuf rawMessage) {
GetQueueConfigOutputBuilder builder = new GetQueueConfigOutputBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid((rawMessage.readUnsignedInt()));
builder.setPort(new PortNumber(rawMessage.readUnsignedInt()));
rawMessage.skipBytes(PADDING_IN_QUEUE_GET_CONFIG_REPLY_HEADER);
import java.math.BigInteger;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutputBuilder;
* @author michal.polkorab
*/
public class RoleReplyMessageFactory implements OFDeserializer<RoleRequestOutput>{
- private static RoleReplyMessageFactory instance;
+
private static final byte PADDING_IN_ROLE_REPLY_HEADER = 4;
-
- private RoleReplyMessageFactory() {
- // singleton
- }
-
- /**
- *
- * @return singleton factory
- */
- public static synchronized RoleReplyMessageFactory getInstance(){
- if(instance == null){
- instance = new RoleReplyMessageFactory();
- }
- return instance;
- }
@Override
- public RoleRequestOutput bufferToMessage(ByteBuf rawMessage, short version) {
+ public RoleRequestOutput deserialize(ByteBuf rawMessage) {
RoleRequestOutputBuilder builder = new RoleRequestOutputBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
builder.setRole(ControllerRole.forValue((int) rawMessage.readUnsignedInt()));
rawMessage.skipBytes(PADDING_IN_ROLE_REPLY_HEADER);
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+import com.google.common.base.Joiner;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class AbstractOxmIpv4AddressDeserializer extends AbstractOxmMatchEntryDeserializer \r
+ implements OFDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserialize(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ addIpv4AddressAugmentation(builder, input);\r
+ if (builder.isHasMask()) {\r
+ OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
+ }\r
+ return builder.build();\r
+ }\r
+\r
+ private static void addIpv4AddressAugmentation(MatchEntriesBuilder builder, ByteBuf input) {\r
+ Ipv4AddressMatchEntryBuilder ipv4AddressBuilder = new Ipv4AddressMatchEntryBuilder();\r
+ List<String> groups = new ArrayList<>();\r
+ for (int i = 0; i < EncodeConstants.GROUPS_IN_IPV4_ADDRESS; i++) {\r
+ groups.add(Short.toString(input.readUnsignedByte()));\r
+ }\r
+ Joiner joiner = Joiner.on(".");\r
+ ipv4AddressBuilder.setIpv4Address(new Ipv4Address(joiner.join(groups)));\r
+ builder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4AddressBuilder.build());\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+import com.google.common.base.Joiner;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class AbstractOxmIpv6AddressDeserializer extends AbstractOxmMatchEntryDeserializer\r
+ implements OFDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserialize(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ addIpv6AddressAugmentation(builder, input);\r
+ if (builder.isHasMask()) {\r
+ OxmMaskDeserializer.addMaskAugmentation(builder, input,\r
+ EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES);\r
+ }\r
+ return builder.build();\r
+ }\r
+\r
+ private static void addIpv6AddressAugmentation(MatchEntriesBuilder builder, ByteBuf input) {\r
+ Ipv6AddressMatchEntryBuilder ipv6AddressBuilder = new Ipv6AddressMatchEntryBuilder();\r
+ List<String> groups = new ArrayList<>();\r
+ for (int i = 0; i < EncodeConstants.GROUPS_IN_IPV6_ADDRESS; i++) {\r
+ groups.add(String.format("%04X", input.readUnsignedShort()));\r
+ }\r
+ Joiner joiner = Joiner.on(":");\r
+ ipv6AddressBuilder.setIpv6Address(new Ipv6Address(joiner.join(groups)));\r
+ builder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6AddressBuilder.build());\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class AbstractOxmMacAddressDeserializer extends AbstractOxmMatchEntryDeserializer\r
+ implements OFDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserialize(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ addMacAddressAugmentation(builder, input);\r
+ if (builder.isHasMask()) {\r
+ OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.MAC_ADDRESS_LENGTH);\r
+ }\r
+ return builder.build();\r
+ }\r
+\r
+ private static void addMacAddressAugmentation(MatchEntriesBuilder builder, ByteBuf input) {\r
+ MacAddressMatchEntryBuilder macAddress = new MacAddressMatchEntryBuilder();\r
+ byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];\r
+ input.readBytes(address);\r
+ macAddress.setMacAddress(new MacAddress(ByteBufUtils.macAddressToString(address)));\r
+ builder.addAugmentation(MacAddressMatchEntry.class, macAddress.build());\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class AbstractOxmMatchEntryDeserializer implements HeaderDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserializeHeader(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ return builder.build();\r
+ }\r
+\r
+ /**\r
+ * @return oxm_field class\r
+ */\r
+ protected abstract Class<? extends MatchField> getOxmField();\r
+\r
+ /**\r
+ * @return oxm_class class\r
+ */\r
+ protected abstract Class<? extends Clazz> getOxmClass();\r
+\r
+ /**\r
+ * Prepares match entry header - sets oxm_class, oxm_field, hasMask\r
+ * + sets the buffer.readerIndex() to the end of match entry \r
+ * - where augmentation starts\r
+ * @param oxm_class oxm class type\r
+ * @param oxm_field oxm field type\r
+ * @param input input bytebuf\r
+ * @return MatchEntriesBuilder which can be filled with MatchEntry augmentation\r
+ */\r
+ protected MatchEntriesBuilder processHeader(Class<? extends Clazz> oxm_class,\r
+ Class<? extends MatchField> oxm_field, ByteBuf input) {\r
+ MatchEntriesBuilder builder = new MatchEntriesBuilder();\r
+ builder.setOxmClass(oxm_class);\r
+ // skip oxm_class (provided)\r
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ builder.setOxmMatchField(oxm_field);\r
+ boolean hasMask = (input.readUnsignedByte() & 1) != 0;\r
+ builder.setHasMask(hasMask);\r
+ // skip match entry length - not needed\r
+ input.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);\r
+ return builder;\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class AbstractOxmMetadataDeserializer extends AbstractOxmMatchEntryDeserializer\r
+ implements OFDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserialize(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ addMetadataAugmentation(builder, input);\r
+ if (builder.isHasMask()) {\r
+ OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_LONG_IN_BYTES);\r
+ }\r
+ return builder.build();\r
+ }\r
+\r
+ private static void addMetadataAugmentation(MatchEntriesBuilder builder, ByteBuf input) {\r
+ MetadataMatchEntryBuilder metadata = new MetadataMatchEntryBuilder();\r
+ byte[] metadataBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];\r
+ input.readBytes(metadataBytes);\r
+ metadata.setMetadata(metadataBytes);\r
+ builder.addAugmentation(MetadataMatchEntry.class, metadata.build());\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class AbstractOxmPortDeserializer extends AbstractOxmMatchEntryDeserializer\r
+ implements OFDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserialize(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ addPortAugmentation(builder, input);\r
+ return builder.build();\r
+ }\r
+\r
+ private static void addPortAugmentation(MatchEntriesBuilder builder, ByteBuf input) {\r
+ PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder();\r
+ portBuilder.setPort(new PortNumber(input.readUnsignedShort()));\r
+ builder.addAugmentation(PortMatchEntry.class, portBuilder.build());\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class AbstractOxmPortNumberDeserializer extends AbstractOxmMatchEntryDeserializer\r
+ implements OFDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserialize(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ PortNumberMatchEntryBuilder port = new PortNumberMatchEntryBuilder();\r
+ port.setPortNumber(new PortNumber(input.readUnsignedInt()));\r
+ builder.addAugmentation(PortNumberMatchEntry.class, port.build());\r
+ return builder.build();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmArpOpDeserializer extends AbstractOxmMatchEntryDeserializer\r
+ implements OFDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserialize(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ addArpOpAugmentation(input, builder);\r
+ return builder.build();\r
+ }\r
+\r
+ private static void addArpOpAugmentation(ByteBuf input, MatchEntriesBuilder builder) {\r
+ OpCodeMatchEntryBuilder opcodeBuilder = new OpCodeMatchEntryBuilder();\r
+ opcodeBuilder.setOpCode(input.readUnsignedShort());\r
+ builder.addAugmentation(OpCodeMatchEntry.class, opcodeBuilder.build());\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return ArpOp.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmArpShaDeserializer extends AbstractOxmMacAddressDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return ArpSha.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmArpSpaDeserializer extends AbstractOxmIpv4AddressDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return ArpSpa.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmArpThaDeserializer extends AbstractOxmMacAddressDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return ArpTha.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmArpTpaDeserializer extends AbstractOxmIpv4AddressDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return ArpTpa.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmEthDstDeserializer extends AbstractOxmMacAddressDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return EthDst.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmEthSrcDeserializer extends AbstractOxmMacAddressDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return EthSrc.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmEthTypeDeserializer extends AbstractOxmMatchEntryDeserializer\r
+ implements OFDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserialize(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ addEthTypeAugmentation(input, builder);\r
+ return builder.build();\r
+ }\r
+\r
+ private static void addEthTypeAugmentation(ByteBuf input, MatchEntriesBuilder builder) {\r
+ EthTypeMatchEntryBuilder ethertypeBuilder = new EthTypeMatchEntryBuilder();\r
+ ethertypeBuilder.setEthType(new EtherType(input.readUnsignedShort()));\r
+ builder.addAugmentation(EthTypeMatchEntry.class, ethertypeBuilder.build());\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return EthType.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIcmpv4CodeDeserializer extends AbstractOxmMatchEntryDeserializer\r
+ implements OFDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserialize(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ addIcmpv4CodeAugmentation(input, builder);\r
+ return builder.build();\r
+ }\r
+\r
+ private static void addIcmpv4CodeAugmentation(ByteBuf input,\r
+ MatchEntriesBuilder builder) {\r
+ Icmpv4CodeMatchEntryBuilder icmpv4CodeBuilder = new Icmpv4CodeMatchEntryBuilder();\r
+ icmpv4CodeBuilder.setIcmpv4Code(input.readUnsignedByte());\r
+ builder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4CodeBuilder.build());\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return Icmpv4Code.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIcmpv4TypeDeserializer extends AbstractOxmMatchEntryDeserializer\r
+ implements OFDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserialize(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ addIcmpv4TypeAugmentation(input, builder);\r
+ return builder.build();\r
+ }\r
+\r
+ private static void addIcmpv4TypeAugmentation(ByteBuf input,\r
+ MatchEntriesBuilder builder) {\r
+ Icmpv4TypeMatchEntryBuilder icmpv4TypeBuilder = new Icmpv4TypeMatchEntryBuilder();\r
+ icmpv4TypeBuilder.setIcmpv4Type(input.readUnsignedByte());\r
+ builder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4TypeBuilder.build());\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return Icmpv4Type.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIcmpv6CodeDeserializer extends AbstractOxmMatchEntryDeserializer\r
+ implements OFDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserialize(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ addIcmpv6CodeAugmentation(input, builder);\r
+ return builder.build();\r
+ }\r
+\r
+ private static void addIcmpv6CodeAugmentation(ByteBuf input,\r
+ MatchEntriesBuilder builder) {\r
+ Icmpv6CodeMatchEntryBuilder icmpv6CodeBuilder = new Icmpv6CodeMatchEntryBuilder();\r
+ icmpv6CodeBuilder.setIcmpv6Code(input.readUnsignedByte());\r
+ builder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6CodeBuilder.build());\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return Icmpv6Code.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIcmpv6TypeDeserializer extends AbstractOxmMatchEntryDeserializer\r
+ implements OFDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserialize(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ Icmpv6TypeMatchEntryBuilder icmpv6TypeBuilder = new Icmpv6TypeMatchEntryBuilder();\r
+ icmpv6TypeBuilder.setIcmpv6Type(input.readUnsignedByte());\r
+ builder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6TypeBuilder.build());\r
+ return builder.build();\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return Icmpv6Type.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmInPhyPortDeserializer extends AbstractOxmPortNumberDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return InPhyPort.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmInPortDeserializer extends AbstractOxmPortNumberDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return InPort.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpDscpDeserializer extends AbstractOxmMatchEntryDeserializer\r
+ implements OFDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserialize(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ addIpDscpAugmentation(input, builder);\r
+ return builder.build();\r
+ }\r
+\r
+ private static void addIpDscpAugmentation(ByteBuf input, MatchEntriesBuilder builder) {\r
+ DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder();\r
+ dscpBuilder.setDscp(new Dscp(input.readUnsignedByte()));\r
+ builder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build());\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return IpDscp.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpEcnDeserializer extends AbstractOxmMatchEntryDeserializer\r
+ implements OFDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserialize(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ addIpEcnAugmentation(input, builder);\r
+ return builder.build();\r
+ }\r
+\r
+ private static void addIpEcnAugmentation(ByteBuf input, MatchEntriesBuilder builder) {\r
+ EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder();\r
+ ecnBuilder.setEcn(input.readUnsignedByte());\r
+ builder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build());\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return IpEcn.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpProtoDeserializer extends AbstractOxmMatchEntryDeserializer\r
+ implements OFDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserialize(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ addIpProtoAugmentation(input, builder);\r
+ return builder.build();\r
+ }\r
+\r
+ private static void addIpProtoAugmentation(ByteBuf input, MatchEntriesBuilder builder) {\r
+ ProtocolNumberMatchEntryBuilder protoNumberBuilder = new ProtocolNumberMatchEntryBuilder();\r
+ protoNumberBuilder.setProtocolNumber(input.readUnsignedByte());\r
+ builder.addAugmentation(ProtocolNumberMatchEntry.class, protoNumberBuilder.build());\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return IpProto.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpv4DstDeserializer extends AbstractOxmIpv4AddressDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return Ipv4Dst.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpv4SrcDeserializer extends AbstractOxmIpv4AddressDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return Ipv4Src.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpv6DstDeserializer extends AbstractOxmIpv6AddressDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return Ipv6Dst.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpv6ExtHdrDeserializer extends AbstractOxmMatchEntryDeserializer\r
+ implements OFDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserialize(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ addIpv6ExtHdrAugmentation(input, builder);\r
+ if (builder.isHasMask()) {\r
+ OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ }\r
+ return builder.build();\r
+ }\r
+\r
+ private static void addIpv6ExtHdrAugmentation(ByteBuf input,\r
+ MatchEntriesBuilder builder) {\r
+ PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder();\r
+ int bitmap = input.readUnsignedShort();\r
+ final Boolean NONEXT = ((bitmap) & (1<<0)) != 0;\r
+ final Boolean ESP = ((bitmap) & (1<<1)) != 0;\r
+ final Boolean AUTH = ((bitmap) & (1<<2)) != 0;\r
+ final Boolean DEST = ((bitmap) & (1<<3)) != 0;\r
+ final Boolean FRAG = ((bitmap) & (1<<4)) != 0;\r
+ final Boolean ROUTER = ((bitmap) & (1<<5)) != 0;\r
+ final Boolean HOP = ((bitmap) & (1<<6)) != 0;\r
+ final Boolean UNREP = ((bitmap) & (1<<7)) != 0;\r
+ final Boolean UNSEQ = ((bitmap) & (1<<8)) != 0;\r
+ pseudoBuilder.setPseudoField(new Ipv6ExthdrFlags(AUTH, DEST, ESP, FRAG, HOP, NONEXT, ROUTER, UNREP, UNSEQ));\r
+ builder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build());\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return Ipv6Exthdr.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpv6FlabelDeserializer extends AbstractOxmMatchEntryDeserializer\r
+ implements OFDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserialize(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ addIpv6FlabelAugmentation(input, builder);\r
+ if (builder.isHasMask()) {\r
+ OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_INT_IN_BYTES);\r
+ }\r
+ return builder.build();\r
+ }\r
+\r
+ private static void addIpv6FlabelAugmentation(ByteBuf input,\r
+ MatchEntriesBuilder builder) {\r
+ Ipv6FlabelMatchEntryBuilder ipv6FlabelBuilder = new Ipv6FlabelMatchEntryBuilder();\r
+ ipv6FlabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(input.readUnsignedInt()));\r
+ builder.addAugmentation(Ipv6FlabelMatchEntry.class, ipv6FlabelBuilder.build());\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return Ipv6Flabel.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpv6NdSllDeserializer extends AbstractOxmMacAddressDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return Ipv6NdSll.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpv6NdTargetDeserializer extends AbstractOxmIpv6AddressDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return Ipv6NdTarget.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpv6NdTllDeserializer extends AbstractOxmMacAddressDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return Ipv6NdTll.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmIpv6SrcDeserializer extends AbstractOxmIpv6AddressDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return Ipv6Src.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmMaskDeserializer {\r
+\r
+ /**\r
+ * Appends mask to match entry (match entry builder)\r
+ * @param builder builder which the mask will append to\r
+ * @param input input ByteBuf\r
+ * @param matchEntryLength mask length\r
+ */\r
+ public static void addMaskAugmentation(MatchEntriesBuilder builder, ByteBuf input,\r
+ int matchEntryLength) {\r
+ MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder();\r
+ byte[] mask = new byte[matchEntryLength];\r
+ input.readBytes(mask);\r
+ maskBuilder.setMask(mask);\r
+ builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build());\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmMetadataDeserializer extends AbstractOxmMetadataDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return Metadata.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmMplsBosDeserializer extends AbstractOxmMatchEntryDeserializer\r
+ implements OFDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserialize(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ addMplsBosDeserializer(input, builder);\r
+ return builder.build();\r
+ }\r
+\r
+\r
+ private static void addMplsBosDeserializer(ByteBuf input,\r
+ MatchEntriesBuilder builder) {\r
+ BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder();\r
+ if (input.readUnsignedByte() != 0) {\r
+ bosBuilder.setBos(true);\r
+ } else {\r
+ bosBuilder.setBos(false);\r
+ }\r
+ builder.addAugmentation(BosMatchEntry.class, bosBuilder.build());\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return MplsBos.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmMplsLabelDeserializer extends AbstractOxmMatchEntryDeserializer\r
+implements OFDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserialize(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ addMplsLabelAugmentation(input, builder);\r
+ return builder.build();\r
+ }\r
+\r
+ private static void addMplsLabelAugmentation(ByteBuf input,\r
+ MatchEntriesBuilder builder) {\r
+ MplsLabelMatchEntryBuilder mplsLabelBuilder = new MplsLabelMatchEntryBuilder();\r
+ mplsLabelBuilder.setMplsLabel(input.readUnsignedInt());\r
+ builder.addAugmentation(MplsLabelMatchEntry.class, mplsLabelBuilder.build());\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return MplsLabel.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmMplsTcDeserializer extends AbstractOxmMatchEntryDeserializer\r
+ implements OFDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserialize(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ addMplsTcAugmentation(input, builder);\r
+ return builder.build();\r
+ }\r
+\r
+ private static void addMplsTcAugmentation(ByteBuf input,\r
+ MatchEntriesBuilder builder) {\r
+ TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder();\r
+ tcBuilder.setTc(input.readUnsignedByte());\r
+ builder.addAugmentation(TcMatchEntry.class, tcBuilder.build());\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return MplsTc.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmPbbIsidDeserializer extends AbstractOxmMatchEntryDeserializer\r
+ implements OFDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserialize(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ addPbbIsidAugmentation(input, builder);\r
+ if (builder.isHasMask()) {\r
+ OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_3_BYTES);\r
+ }\r
+ return builder.build();\r
+ }\r
+\r
+ private static void addPbbIsidAugmentation(ByteBuf input,\r
+ MatchEntriesBuilder builder) {\r
+ IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder();\r
+ Integer isid = input.readUnsignedMedium();\r
+ isidBuilder.setIsid(isid.longValue());\r
+ builder.addAugmentation(IsidMatchEntry.class, isidBuilder.build());\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return PbbIsid.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmSctpDstDeserializer extends AbstractOxmPortDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return SctpDst.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmSctpSrcDeserializer extends AbstractOxmPortDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return SctpSrc.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmTcpDstDeserializer extends AbstractOxmPortDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return TcpDst.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmTcpSrcDeserializer extends AbstractOxmPortDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return TcpSrc.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmTunnelIdDeserializer extends AbstractOxmMetadataDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return TunnelId.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmUdpDstDeserializer extends AbstractOxmPortDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return UdpDst.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmUdpSrcDeserializer extends AbstractOxmPortDeserializer {\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return UdpSrc.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmVlanPcpDeserializer extends AbstractOxmMatchEntryDeserializer\r
+ implements OFDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserialize(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ addVlanPcpAugmentation(input, builder);\r
+ return builder.build();\r
+ }\r
+\r
+ private static void addVlanPcpAugmentation(ByteBuf input, MatchEntriesBuilder builder) {\r
+ VlanPcpMatchEntryBuilder vlanPcpBuilder = new VlanPcpMatchEntryBuilder();\r
+ vlanPcpBuilder.setVlanPcp(input.readUnsignedByte());\r
+ builder.addAugmentation(VlanPcpMatchEntry.class, vlanPcpBuilder.build());\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return VlanPcp.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class OxmVlanVidDeserializer extends AbstractOxmMatchEntryDeserializer\r
+ implements OFDeserializer<MatchEntries> {\r
+\r
+ @Override\r
+ public MatchEntries deserialize(ByteBuf input) {\r
+ MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
+ addVlanVidAugmentation(input, builder);\r
+ if (builder.isHasMask()) {\r
+ OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+ }\r
+ return builder.build();\r
+ }\r
+\r
+ private static void addVlanVidAugmentation(ByteBuf input, MatchEntriesBuilder builder) {\r
+ VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();\r
+ int vidEntryValue = input.readUnsignedShort();\r
+ vlanVidBuilder.setCfiBit((vidEntryValue & (1 << 12)) != 0); // cfi is 13-th bit\r
+ vlanVidBuilder.setVlanVid(vidEntryValue & ((1 << 12) - 1)); // value without 13-th bit\r
+ builder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends MatchField> getOxmField() {\r
+ return VlanVid.class;\r
+ }\r
+\r
+ @Override\r
+ protected Class<? extends Clazz> getOxmClass() {\r
+ return OpenflowBasicClass.class;\r
+ }\r
+}\r
import java.util.ArrayList;
import java.util.List;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
/**
* Deserializes ofp_actions (OpenFlow v1.3)
* @author timotej.kubas
* @author michal.polkorab
*/
-public class ActionsDeserializer {
+public class ActionsDeserializer implements OFDeserializer<Action>,
+ HeaderDeserializer<Action>, DeserializerRegistryInjector {
- private static final byte ACTION_HEADER_LENGTH = 4;
private static final byte PADDING_IN_ACTIONS_HEADER = 4;
private static final byte PADDING_IN_OUTPUT_ACTIONS_HEADER = 6;
private static final byte PADDING_IN_SET_MPLS_TTL_ACTIONS_HEADER = 3;
private static final byte PADDING_IN_PUSH_VLAN_ACTIONS_HEADER = 2;
private static final byte PADDING_IN_NW_TTL_ACTIONS_HEADER = 3;
- private static final byte EXPERIMENTER_ACTION_HEADER_LENGTH = 8;
-
- /**
- * Creates list of actions (OpenFlow v1.3)
- * @param input input ByteBuf
- * @param actionsLength length of buckets
- * @return ActionsList
- */
- public static List<Action> createActions(ByteBuf input, int actionsLength) {
- List<Action> actions = new ArrayList<>();
- int length = 0;
- while (length < actionsLength) {
- int type = input.readUnsignedShort();
- int currentActionLength = input.readUnsignedShort();
- ActionBuilder actionBuilder = new ActionBuilder();
- switch(type) {
- case 0:
- actions.add(createOutputAction(input, actionBuilder));
- break;
- case 11:
- actions.add(createCopyTtlOutAction(input, actionBuilder));
- break;
- case 12:
- actions.add(createCopyTtlInAction(input, actionBuilder));
- break;
- case 15:
- actions.add(createSetMplsTtlAction(input, actionBuilder));
- break;
- case 16:
- actions.add(createDecMplsTtlOutAction(input, actionBuilder));
- break;
- case 17:
- actions.add(createPushVlanAction(input, actionBuilder));
- break;
- case 18:
- actions.add(createPopVlanAction(input, actionBuilder));
- break;
- case 19:
- actions.add(createPushMplsAction(input, actionBuilder));
- break;
- case 20:
- actions.add(createPopMplsAction(input, actionBuilder));
- break;
- case 21:
- actions.add(createSetQueueAction(input, actionBuilder));
- break;
- case 22:
- actions.add(createGroupAction(input, actionBuilder));
- break;
- case 23:
- actions.add(createSetNwTtlAction(input, actionBuilder));
- break;
- case 24:
- actions.add(createDecNwTtlAction(input, actionBuilder));
- break;
- case 25:
- actions.add(createSetFieldAction(input, actionBuilder, currentActionLength));
- break;
- case 26:
- actions.add(createPushPbbAction(input, actionBuilder));
- break;
- case 27:
- actions.add(createPopPbbAction(input, actionBuilder));
- break;
- case 0xFFFF:
- actions.add(createExperimenterAction(input, actionBuilder, currentActionLength));
- break;
- default:
- break;
- }
- length += currentActionLength;
- }
- return actions;
+ private DeserializerRegistry registry;
+
+ @Override
+ public Action deserialize(ByteBuf input) {
+ Action action = null;
+ ActionBuilder actionBuilder = new ActionBuilder();
+ int type = input.getUnsignedShort(input.readerIndex());
+ switch(type) {
+ case 0:
+ action = createOutputAction(input, actionBuilder);
+ break;
+ case 11:
+ action = createCopyTtlOutAction(input, actionBuilder);
+ break;
+ case 12:
+ action = createCopyTtlInAction(input, actionBuilder);
+ break;
+ case 15:
+ action = createSetMplsTtlAction(input, actionBuilder);
+ break;
+ case 16:
+ action = createDecMplsTtlOutAction(input, actionBuilder);
+ break;
+ case 17:
+ action = createPushVlanAction(input, actionBuilder);
+ break;
+ case 18:
+ action = createPopVlanAction(input, actionBuilder);
+ break;
+ case 19:
+ action = createPushMplsAction(input, actionBuilder);
+ break;
+ case 20:
+ action = createPopMplsAction(input, actionBuilder);
+ break;
+ case 21:
+ action = createSetQueueAction(input, actionBuilder);
+ break;
+ case 22:
+ action = createGroupAction(input, actionBuilder);
+ break;
+ case 23:
+ action = createSetNwTtlAction(input, actionBuilder);
+ break;
+ case 24:
+ action = createDecNwTtlAction(input, actionBuilder);
+ break;
+ case 25:
+ action = createSetFieldAction(input, actionBuilder);
+ break;
+ case 26:
+ action = createPushPbbAction(input, actionBuilder);
+ break;
+ case 27:
+ action = createPopPbbAction(input, actionBuilder);
+ break;
+ case 0xFFFF:
+ OFDeserializer<ExperimenterAction> expDeserializer = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 0xFFFF, ExperimenterAction.class));
+ ExperimenterAction expAction = expDeserializer.deserialize(input);
+ actionBuilder.addAugmentation(ExperimenterAction.class, expAction);
+ break;
+ default:
+ break;
+ }
+ return action;
}
- /**
- * Creates action ids - actions without values (OpenFlow v1.3)
- * @param input input ByteBuf
- * @param actionsLength length of actions
- * @return ActionsList
- */
- public static List<Action> createActionIds(ByteBuf input, int actionsLength) {
- List<Action> actionsList = new ArrayList<>();
- int length = 0;
+ @Override
+ public Action deserializeHeader(ByteBuf input) {
ActionBuilder builder;
- while (length < actionsLength) {
- builder = new ActionBuilder();
- int type = input.readUnsignedShort();
- int currentActionLength = input.readUnsignedShort();
- switch(type) {
- case 0:
- builder.setType(Output.class);
- break;
- case 11:
- builder.setType(CopyTtlOut.class);
- break;
- case 12:
- builder.setType(CopyTtlIn.class);
- break;
- case 15:
- builder.setType(SetMplsTtl.class);
- break;
- case 16:
- builder.setType(DecMplsTtl.class);
- break;
- case 17:
- builder.setType(PushVlan.class);
- break;
- case 18:
- builder.setType(PopVlan.class);
- break;
- case 19:
- builder.setType(PushMpls.class);
- break;
- case 20:
- builder.setType(PopMpls.class);
- break;
- case 21:
- builder.setType(SetQueue.class);
- break;
- case 22:
- builder.setType(Group.class);
- break;
- case 23:
- builder.setType(SetNwTtl.class);
- break;
- case 24:
- builder.setType(DecNwTtl.class);
- break;
- case 25:
- builder.setType(SetField.class);
- break;
- case 26:
- builder.setType(PushPbb.class);
- break;
- case 27:
- builder.setType(PopPbb.class);
- break;
- case 0xFFFF:
- builder.setType(Experimenter.class);
- ExperimenterActionBuilder experimenter = new ExperimenterActionBuilder();
- experimenter.setExperimenter(input.readUnsignedInt());
- builder.addAugmentation(ExperimenterAction.class, experimenter.build());
- break;
- default:
- break;
- }
- actionsList.add(builder.build());
- length += currentActionLength;
- }
- return actionsList;
+ builder = new ActionBuilder();
+ int type = input.readUnsignedShort();
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+ switch(type) {
+ case 0:
+ builder.setType(Output.class);
+ break;
+ case 11:
+ builder.setType(CopyTtlOut.class);
+ break;
+ case 12:
+ builder.setType(CopyTtlIn.class);
+ break;
+ case 15:
+ builder.setType(SetMplsTtl.class);
+ break;
+ case 16:
+ builder.setType(DecMplsTtl.class);
+ break;
+ case 17:
+ builder.setType(PushVlan.class);
+ break;
+ case 18:
+ builder.setType(PopVlan.class);
+ break;
+ case 19:
+ builder.setType(PushMpls.class);
+ break;
+ case 20:
+ builder.setType(PopMpls.class);
+ break;
+ case 21:
+ builder.setType(SetQueue.class);
+ break;
+ case 22:
+ builder.setType(Group.class);
+ break;
+ case 23:
+ builder.setType(SetNwTtl.class);
+ break;
+ case 24:
+ builder.setType(DecNwTtl.class);
+ break;
+ case 25:
+ builder.setType(SetField.class);
+ break;
+ case 26:
+ builder.setType(PushPbb.class);
+ break;
+ case 27:
+ builder.setType(PopPbb.class);
+ break;
+ case 0xFFFF:
+ HeaderDeserializer<ExperimenterAction> expDeserializer = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 0xFFFF, ExperimenterAction.class));
+ ExperimenterAction expAction = expDeserializer.deserializeHeader(input);
+ builder.setType(Experimenter.class);
+ builder.addAugmentation(ExperimenterAction.class, expAction);
+ break;
+ default:
+ break;
+ }
+ return builder.build();
}
private static Action createEmptyHeader(Class<? extends ActionBase> action,
ByteBuf in, ActionBuilder actionBuilder) {
actionBuilder.setType(action);
+ in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
in.skipBytes(PADDING_IN_ACTIONS_HEADER);
return actionBuilder.build();
}
private static Action createOutputAction(ByteBuf in, ActionBuilder actionBuilder) {
actionBuilder.setType(Output.class);
+ in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
PortActionBuilder port = new PortActionBuilder();
port.setPort(new PortNumber(in.readUnsignedInt()));
actionBuilder.addAugmentation(PortAction.class, port.build());
private static Action createSetMplsTtlAction(ByteBuf in, ActionBuilder actionBuilder) {
actionBuilder.setType(SetMplsTtl.class);
+ in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
MplsTtlActionBuilder mplsTtl = new MplsTtlActionBuilder();
mplsTtl.setMplsTtl(in.readUnsignedByte());
actionBuilder.addAugmentation(MplsTtlAction.class, mplsTtl.build());
private static Action createPushAction(Class<? extends ActionBase> action,
ByteBuf in, ActionBuilder actionBuilder) {
actionBuilder.setType(action);
+ in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
EthertypeActionBuilder etherType = new EthertypeActionBuilder();
etherType.setEthertype(new EtherType(in.readUnsignedShort()));
actionBuilder.addAugmentation(EthertypeAction.class, etherType.build());
private static Action createSetQueueAction(ByteBuf in, ActionBuilder actionBuilder) {
actionBuilder.setType(SetQueue.class);
+ in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
QueueIdActionBuilder queueId = new QueueIdActionBuilder();
queueId.setQueueId(in.readUnsignedInt());
actionBuilder.addAugmentation(QueueIdAction.class, queueId.build());
private static Action createGroupAction(ByteBuf in, ActionBuilder actionBuilder) {
actionBuilder.setType(Group.class);
+ in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
GroupIdActionBuilder group = new GroupIdActionBuilder();
group.setGroupId(in.readUnsignedInt());
actionBuilder.addAugmentation(GroupIdAction.class, group.build());
return actionBuilder.build();
}
-
- private static Action createExperimenterAction(ByteBuf in, ActionBuilder actionBuilder, int actionLength) {
- actionBuilder.setType(Experimenter.class);
- ExperimenterActionBuilder experimenter = new ExperimenterActionBuilder();
- experimenter.setExperimenter(in.readUnsignedInt());
- int dataLength = actionLength - EXPERIMENTER_ACTION_HEADER_LENGTH;
- if (dataLength > 0) {
- byte[] data = new byte[dataLength];
- in.readBytes(data);
- experimenter.setData(data);
- }
- actionBuilder.addAugmentation(ExperimenterAction.class, experimenter.build());
- return actionBuilder.build();
- }
-
+
private static Action createSetNwTtlAction(ByteBuf in, ActionBuilder actionBuilder) {
actionBuilder.setType(SetNwTtl.class);
+ in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
NwTtlActionBuilder nwTtl = new NwTtlActionBuilder();
nwTtl.setNwTtl(in.readUnsignedByte());
actionBuilder.addAugmentation(NwTtlAction.class, nwTtl.build());
return actionBuilder.build();
}
- private static Action createSetFieldAction(ByteBuf in, ActionBuilder actionBuilder, int actionLength) {
+ private Action createSetFieldAction(ByteBuf in, ActionBuilder actionBuilder) {
actionBuilder.setType(SetField.class);
+ int startIndex = in.readerIndex();
+ in.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder();
- matchEntries.setMatchEntries(MatchDeserializer.createMatchEntry(in, actionLength - ACTION_HEADER_LENGTH));
+ int oxmClass = in.getUnsignedShort(in.readerIndex());
+ // get oxm_field & hasMask byte and extract the field value
+ int oxmField = in.getUnsignedByte(in.readerIndex()
+ + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1;
+ OFDeserializer<MatchEntries> matchDeserializer = registry.getDeserializer(
+ new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, oxmClass,
+ oxmField, MatchEntries.class));
+ List<MatchEntries> entry = new ArrayList<>();
+ entry.add(matchDeserializer.deserialize(in));
+ matchEntries.setMatchEntries(entry);
actionBuilder.addAugmentation(OxmFieldsAction.class, matchEntries.build());
+ int paddingRemainder = (in.readerIndex() - startIndex) % EncodeConstants.PADDING;
+ if (paddingRemainder != 0) {
+ in.skipBytes(EncodeConstants.PADDING - paddingRemainder);
+ }
return actionBuilder.build();
}
+
+ @Override
+ public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+ registry = deserializerRegistry;
+ }
}
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.util;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageCodeKey;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yangtools.yang.binding.DataObject;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public abstract class DecodingUtils {\r
+\r
+ /**\r
+ * Deserializes lists of actions or instructions\r
+ * @param length length of list (in bytes)\r
+ * @param input input bytebuf\r
+ * @param deserializer \r
+ * false in case of whole body deserialization\r
+ * @return List of actions or instructions\r
+ */\r
+ @SuppressWarnings("unchecked")\r
+ public static <E extends DataObject> List<E> deserializeList(int length, ByteBuf input,\r
+ OFGeneralDeserializer deserializer) {\r
+ List<E> list = new ArrayList<>();\r
+ int startIndex = input.readerIndex();\r
+ OFDeserializer<E> actionsDeserializer = (OFDeserializer<E>) deserializer;\r
+ while ((input.readerIndex() - startIndex) < length) {\r
+ list.add(actionsDeserializer.deserialize(input));\r
+ }\r
+ return list;\r
+ }\r
+\r
+ /**\r
+ * Deserializes action or instruction headers\r
+ * @param length length of list (in bytes)\r
+ * @param input input bytebuf\r
+ * @param deserializer \r
+ * false in case of whole body deserialization\r
+ * @return List of action or instruction headers\r
+ */\r
+ @SuppressWarnings("unchecked")\r
+ public static <E extends DataObject> List<E> deserializeHeaders(int length, ByteBuf input,\r
+ OFGeneralDeserializer deserializer) {\r
+ List<E> list = new ArrayList<>();\r
+ int startIndex = input.readerIndex();\r
+ HeaderDeserializer<E> instructionsDeserializer = (HeaderDeserializer<E>) deserializer;\r
+ while ((input.readerIndex() - startIndex) < length) {\r
+ list.add(instructionsDeserializer.deserializeHeader(input));\r
+ }\r
+ return list;\r
+ }\r
+\r
+ /**\r
+ * Deserializes match entry headers\r
+ * @param length length of list (in bytes)\r
+ * @param input input bytebuf\r
+ * @param registry registry with deserializers\r
+ * false in case of whole body deserialization\r
+ * @return List of match entry headers\r
+ */\r
+ public static List<MatchEntries> deserializeMatchEntryHeaders(int length, ByteBuf input,\r
+ DeserializerRegistry registry) {\r
+ List<MatchEntries> list = new ArrayList<>();\r
+ int startIndex = input.readerIndex();\r
+ while ((input.readerIndex() - startIndex) < length) {\r
+ int oxmClass = input.getUnsignedShort(input.readerIndex());\r
+ int oxmField = input.getUnsignedByte(input.readerIndex()\r
+ + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >> 1;\r
+ HeaderDeserializer<MatchEntries> deserializer = registry.getDeserializer(\r
+ new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, oxmClass,\r
+ oxmField, MatchEntries.class));\r
+ list.add(deserializer.deserializeHeader(input));\r
+ }\r
+ return list;\r
+ }\r
+\r
+ /**\r
+ * Deserializes list of match entries\r
+ * @param length length of list (in bytes)\r
+ * @param input input bytebuf\r
+ * @param registry registry with deserializers\r
+ * false in case of whole body deserialization\r
+ * @return List of match entries\r
+ */\r
+ public static List<MatchEntries> deserializeMatchEntries(int length, ByteBuf input,\r
+ DeserializerRegistry registry) {\r
+ List<MatchEntries> list = new ArrayList<>();\r
+ int startIndex = input.readerIndex();\r
+ while ((input.readerIndex() - startIndex) < length) {\r
+ int oxmClass = input.getUnsignedShort(input.readerIndex());\r
+ int oxmField = input.getUnsignedByte(input.readerIndex()\r
+ + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >> 1;\r
+ OFDeserializer<MatchEntries> deserializer = registry.getDeserializer(\r
+ new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, oxmClass,\r
+ oxmField, MatchEntries.class));\r
+ list.add(deserializer.deserialize(input));\r
+ }\r
+ return list;\r
+ }\r
+}\r
/** Length of 3 bytes */
public static final byte SIZE_OF_3_BYTES = 3;
+ /** Empty (zero) int value */
+ public static final int EMPTY_VALUE = 0;
+
/** OF v1.0 maximal port name length */
public static final byte MAX_PORT_NAME_LENGTH = 16;
import io.netty.buffer.ByteBuf;
-import java.util.ArrayList;
import java.util.List;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstructionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstruction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstructionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter;
* @author michal.polkorab
* @author timotej.kubas
*/
-public abstract class InstructionsDeserializer {
+public class InstructionsDeserializer implements OFDeserializer<Instruction>,
+ HeaderDeserializer<Instruction>, DeserializerRegistryInjector {
private static final byte WRITE_APPLY_CLEAR_ACTION_LENGTH = 8;
- private static final byte EXPERIMENTER_HEADER_LENGTH = 8;
private static final byte GOTO_TABLE_PADDING = 3;
private static final byte WRITE_METADATA_PADDING = 4;
private static final byte ACTIONS_RELATED_INSTRUCTION_PADDING = 4;
+ private DeserializerRegistry registry;
- /**
- * Creates list of instructions
- * @param input
- * @param length
- * @return list of ofp_instruction
- */
- public static List<Instruction> createInstructions(ByteBuf input, int length) {
- List<Instruction> instructions = new ArrayList<>();
- if (input.readableBytes() != 0) {
- int lengthOfInstructions = length;
- while (lengthOfInstructions > 0) {
- InstructionBuilder builder = new InstructionBuilder();
- int type = input.readUnsignedShort();
- int instructionLength = input.readUnsignedShort();
- lengthOfInstructions -= instructionLength;
- switch (type) {
- case 1:
- createGotoTableInstruction(builder, input);
- break;
- case 2:
- createMetadataInstruction(builder, input);
- break;
- case 3:
- builder.setType(WriteActions.class);
- createActionRelatedInstruction(input, builder, instructionLength - WRITE_APPLY_CLEAR_ACTION_LENGTH);
- break;
- case 4:
- builder.setType(ApplyActions.class);
- createActionRelatedInstruction(input, builder, instructionLength - WRITE_APPLY_CLEAR_ACTION_LENGTH);
- break;
- case 5:
- builder.setType(ClearActions.class);
- createActionRelatedInstruction(input, builder, instructionLength - WRITE_APPLY_CLEAR_ACTION_LENGTH);
- break;
- case 6:
- builder.setType(Meter.class);
- MeterIdInstructionBuilder meterBuilder = new MeterIdInstructionBuilder();
- meterBuilder.setMeterId(input.readUnsignedInt());
- builder.addAugmentation(MeterIdInstruction.class, meterBuilder.build());
- break;
- case 65535:
- builder.setType(Experimenter.class);
- ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder();
- expBuilder.setExperimenter(input.readUnsignedInt());
- int dataLength = instructionLength - EXPERIMENTER_HEADER_LENGTH;
- if (dataLength > 0) {
- byte[] data = new byte[dataLength];
- input.readBytes(data);
- expBuilder.setData(data);
- }
- builder.addAugmentation(ExperimenterInstruction.class, expBuilder.build());
- break;
- default:
- break;
- }
- instructions.add(builder.build());
- }
+ @Override
+ public Instruction deserialize(ByteBuf input) {
+ InstructionBuilder builder = new InstructionBuilder();
+ int type = input.readUnsignedShort();
+ switch (type) {
+ case 1:
+ createGotoTableInstruction(builder, input);
+ break;
+ case 2:
+ createMetadataInstruction(builder, input);
+ break;
+ case 3:
+ builder.setType(WriteActions.class);
+ createActionRelatedInstruction(input, builder);
+ break;
+ case 4:
+ builder.setType(ApplyActions.class);
+ createActionRelatedInstruction(input, builder);
+ break;
+ case 5:
+ builder.setType(ClearActions.class);
+ createActionRelatedInstruction(input, builder);
+ break;
+ case 6:
+ builder.setType(Meter.class);
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+ MeterIdInstructionBuilder meterBuilder = new MeterIdInstructionBuilder();
+ meterBuilder.setMeterId(input.readUnsignedInt());
+ builder.addAugmentation(MeterIdInstruction.class, meterBuilder.build());
+ break;
+ case 65535:
+ builder.setType(Experimenter.class);
+ OFDeserializer<ExperimenterInstruction> deserializer = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, type, ExperimenterInstruction.class));
+ ExperimenterInstruction expInstruction = deserializer.deserialize(input);
+ builder.addAugmentation(ExperimenterInstruction.class, expInstruction);
+ break;
+ default:
+ break;
}
- return instructions;
+ return builder.build();
}
- /**
- * Creates instruction ids (instructions without values)
- * @param input
- * @param length
- * @return list of ofp_instruction without values
- */
- public static List<Instruction> createInstructionIds(ByteBuf input, int length) {
- List<Instruction> instructions = new ArrayList<>();
- if (input.readableBytes() != 0) {
- int lengthOfInstructions = length;
- while (lengthOfInstructions > 0) {
- InstructionBuilder builder = new InstructionBuilder();
- int type = input.readUnsignedShort();
- int instructionLength = input.readUnsignedShort();
- lengthOfInstructions -= instructionLength;
- switch (type) {
- case 1:
- builder.setType(GotoTable.class);
- break;
- case 2:
- builder.setType(WriteMetadata.class);
- break;
- case 3:
- builder.setType(WriteActions.class);
- break;
- case 4:
- builder.setType(ApplyActions.class);
- break;
- case 5:
- builder.setType(ClearActions.class);
- break;
- case 6:
- builder.setType(Meter.class);
- break;
- case 65535:
- builder.setType(Experimenter.class);
- ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder();
- expBuilder.setExperimenter(input.readUnsignedInt());
- builder.addAugmentation(ExperimenterInstruction.class, expBuilder.build());
- break;
- default:
- break;
- }
- instructions.add(builder.build());
- }
+ @Override
+ public Instruction deserializeHeader(ByteBuf input) {
+ InstructionBuilder builder = new InstructionBuilder();
+ int type = input.readUnsignedShort();
+ switch (type) {
+ case 1:
+ builder.setType(GotoTable.class);
+ break;
+ case 2:
+ builder.setType(WriteMetadata.class);
+ break;
+ case 3:
+ builder.setType(WriteActions.class);
+ break;
+ case 4:
+ builder.setType(ApplyActions.class);
+ break;
+ case 5:
+ builder.setType(ClearActions.class);
+ break;
+ case 6:
+ builder.setType(Meter.class);
+ break;
+ case 65535:
+ builder.setType(Experimenter.class);
+ ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder();
+ expBuilder.setExperimenter(input.readUnsignedInt());
+ builder.addAugmentation(ExperimenterInstruction.class, expBuilder.build());
+ break;
+ default:
+ break;
}
- return instructions;
+ return builder.build();
}
private static void createGotoTableInstruction(InstructionBuilder builder,
ByteBuf input) {
builder.setType(GotoTable.class);
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
TableIdInstructionBuilder tableBuilder = new TableIdInstructionBuilder();
tableBuilder.setTableId(input.readUnsignedByte());
builder.addAugmentation(TableIdInstruction.class, tableBuilder.build());
private static void createMetadataInstruction(InstructionBuilder builder,
ByteBuf input) {
- input.skipBytes(WRITE_METADATA_PADDING);
builder.setType(WriteMetadata.class);
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+ input.skipBytes(WRITE_METADATA_PADDING);
MetadataInstructionBuilder metadataBuilder = new MetadataInstructionBuilder();
byte[] metadata = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(metadata);
builder.addAugmentation(MetadataInstruction.class, metadataBuilder.build());
}
- private static void createActionRelatedInstruction(ByteBuf input,
- InstructionBuilder builder, int actionsLength) {
+ private void createActionRelatedInstruction(ByteBuf input, InstructionBuilder builder) {
+ int instructionLength = input.readUnsignedShort();
input.skipBytes(ACTIONS_RELATED_INSTRUCTION_PADDING);
ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder();
- actionsBuilder.setAction(ActionsDeserializer.createActions(input, actionsLength));
+ OFDeserializer<Action> deserializer = registry.getDeserializer(new MessageCodeKey(
+ EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Action.class));
+ List<Action> actions = DecodingUtils.deserializeList(
+ instructionLength - WRITE_APPLY_CLEAR_ACTION_LENGTH, input, deserializer);
+ actionsBuilder.setAction(actions);
builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build());
}
+ @Override
+ public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+ registry = deserializerRegistry;
+ }
}
import io.netty.buffer.ByteBuf;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
-
-import com.google.common.base.Joiner;
/**
* Deserializes ofp_match (OpenFlow v1.3) and its oxm_fields structures
* @author timotej.kubas
* @author michal.polkorab
*/
-public abstract class MatchDeserializer {
+public class MatchDeserializer implements OFDeserializer<Match>,
+ DeserializerRegistryInjector {
+
+ private DeserializerRegistry registry;
- /**
- * Creates match
- * @param in input ByteBuf
- * @return ofp_match (OpenFlow v1.3)
- */
- public static Match createMatch(ByteBuf in) {
- if (in.readableBytes() > 0) {
+ @Override
+ public Match deserialize(ByteBuf input) {
+ if (input.readableBytes() > 0) {
MatchBuilder builder = new MatchBuilder();
- int type = in.readUnsignedShort();
- int length = in.readUnsignedShort();
+ int type = input.readUnsignedShort();
+ int length = input.readUnsignedShort();
switch (type) {
case 0:
builder.setType(StandardMatchType.class);
default:
break;
}
- builder.setMatchEntries(createMatchEntries(in, length - 2 * (EncodeConstants.SIZE_OF_SHORT_IN_BYTES)));
+ builder.setMatchEntries(DecodingUtils.deserializeMatchEntries(
+ length - 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES, input, registry));
int paddingRemainder = length % EncodeConstants.PADDING;
if (paddingRemainder != 0) {
- in.skipBytes(EncodeConstants.PADDING - paddingRemainder);
+ input.skipBytes(EncodeConstants.PADDING - paddingRemainder);
}
return builder.build();
}
return null;
}
- /**
- * Deserializes single match entry (oxm_field)
- * @param in input ByteBuf
- * @param matchLength length of match entry
- * @return MatchEntriesList list containing one match entry
- */
- public static List<MatchEntries> createMatchEntry(ByteBuf in, int matchLength) {
- return createMatchEntriesInternal(in, matchLength, true);
- }
-
- /**
- * @param in input ByteBuf
- * @param matchLength length of match entries
- * @return MatchEntriesList list of match entries
- */
- public static List<MatchEntries> createMatchEntries(ByteBuf in, int matchLength) {
- return createMatchEntriesInternal(in, matchLength, false);
- }
-
- private static List<MatchEntries> createMatchEntriesInternal(ByteBuf in, int matchLength, boolean oneEntry) {
- List<MatchEntries> matchEntriesList = new ArrayList<>();
- int currLength = 0;
- while(currLength < matchLength) {
- MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
- switch (in.readUnsignedShort()) {
- case 0x0000:
- matchEntriesBuilder.setOxmClass(Nxm0Class.class);
- break;
- case 0x0001:
- matchEntriesBuilder.setOxmClass(Nxm1Class.class);
- break;
- case 0x8000:
- matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
- break;
- case 0xFFFF:
- matchEntriesBuilder.setOxmClass(ExperimenterClass.class);
- break;
- default:
- break;
- }
-
- int fieldAndMask = in.readUnsignedByte();
- boolean hasMask = (fieldAndMask & 1) != 0;
- matchEntriesBuilder.setHasMask(hasMask);
- int matchField = fieldAndMask >> 1;
- int matchEntryLength = in.readUnsignedByte();
- currLength += EncodeConstants.SIZE_OF_SHORT_IN_BYTES +
- (2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES) + matchEntryLength;
-
- switch(matchField) {
- case 0:
- matchEntriesBuilder.setOxmMatchField(InPort.class);
- PortNumberMatchEntryBuilder port = new PortNumberMatchEntryBuilder();
- port.setPortNumber(new PortNumber(in.readUnsignedInt()));
- matchEntriesBuilder.addAugmentation(PortNumberMatchEntry.class, port.build());
- break;
- case 1:
- matchEntriesBuilder.setOxmMatchField(InPhyPort.class);
- PortNumberMatchEntryBuilder phyPort = new PortNumberMatchEntryBuilder();
- phyPort.setPortNumber(new PortNumber(in.readUnsignedInt()));
- matchEntriesBuilder.addAugmentation(PortNumberMatchEntry.class, phyPort.build());
- break;
- case 2:
- matchEntriesBuilder.setOxmMatchField(Metadata.class);
- addMetadataAugmentation(matchEntriesBuilder, in);
- if (hasMask) {
- addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_LONG_IN_BYTES);
- }
- break;
- case 3:
- matchEntriesBuilder.setOxmMatchField(EthDst.class);
- addMacAddressAugmentation(matchEntriesBuilder, in);
- if (hasMask) {
- addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.MAC_ADDRESS_LENGTH);
- }
- break;
- case 4:
- matchEntriesBuilder.setOxmMatchField(EthSrc.class);
- addMacAddressAugmentation(matchEntriesBuilder, in);
- if (hasMask) {
- addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.MAC_ADDRESS_LENGTH);
- }
- break;
- case 5:
- matchEntriesBuilder.setOxmMatchField(EthType.class);
- EthTypeMatchEntryBuilder ethertypeBuilder = new EthTypeMatchEntryBuilder();
- ethertypeBuilder.setEthType(new EtherType(in.readUnsignedShort()));
- matchEntriesBuilder.addAugmentation(EthTypeMatchEntry.class, ethertypeBuilder.build());
- break;
- case 6:
- matchEntriesBuilder.setOxmMatchField(VlanVid.class);
- VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();
- int vidEntryValue = in.readUnsignedShort();
- vlanVidBuilder.setCfiBit((vidEntryValue & (1 << 12)) != 0); // cfi is 13-th bit
- vlanVidBuilder.setVlanVid(vidEntryValue & ((1 << 12) - 1)); // value without 13-th bit
- matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());
- if (hasMask) {
- addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
- }
- break;
- case 7:
- matchEntriesBuilder.setOxmMatchField(VlanPcp.class);
- VlanPcpMatchEntryBuilder vlanPcpBuilder = new VlanPcpMatchEntryBuilder();
- vlanPcpBuilder.setVlanPcp(in.readUnsignedByte());
- matchEntriesBuilder.addAugmentation(VlanPcpMatchEntry.class, vlanPcpBuilder.build());
- break;
- case 8:
- matchEntriesBuilder.setOxmMatchField(IpDscp.class);
- DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder();
- dscpBuilder.setDscp(new Dscp(in.readUnsignedByte()));
- matchEntriesBuilder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build());
- break;
- case 9:
- matchEntriesBuilder.setOxmMatchField(IpEcn.class);
- EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder();
- ecnBuilder.setEcn(in.readUnsignedByte());
- matchEntriesBuilder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build());
- break;
- case 10:
- matchEntriesBuilder.setOxmMatchField(IpProto.class);
- ProtocolNumberMatchEntryBuilder protoNumberBuilder = new ProtocolNumberMatchEntryBuilder();
- protoNumberBuilder.setProtocolNumber(in.readUnsignedByte());
- matchEntriesBuilder.addAugmentation(ProtocolNumberMatchEntry.class, protoNumberBuilder.build());
- break;
- case 11:
- matchEntriesBuilder.setOxmMatchField(Ipv4Src.class);
- addIpv4AddressAugmentation(matchEntriesBuilder, in);
- if (hasMask) {
- addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES);
- }
- break;
- case 12:
- matchEntriesBuilder.setOxmMatchField(Ipv4Dst.class);
- addIpv4AddressAugmentation(matchEntriesBuilder, in);
- if (hasMask) {
- addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES);
- }
- break;
- case 13:
- matchEntriesBuilder.setOxmMatchField(TcpSrc.class);
- addPortAugmentation(matchEntriesBuilder, in);
- break;
- case 14:
- matchEntriesBuilder.setOxmMatchField(TcpDst.class);
- addPortAugmentation(matchEntriesBuilder, in);
- break;
- case 15:
- matchEntriesBuilder.setOxmMatchField(UdpSrc.class);
- addPortAugmentation(matchEntriesBuilder, in);
- break;
- case 16:
- matchEntriesBuilder.setOxmMatchField(UdpDst.class);
- addPortAugmentation(matchEntriesBuilder, in);
- break;
- case 17:
- matchEntriesBuilder.setOxmMatchField(SctpSrc.class);
- addPortAugmentation(matchEntriesBuilder, in);
- break;
- case 18:
- matchEntriesBuilder.setOxmMatchField(SctpDst.class);
- addPortAugmentation(matchEntriesBuilder, in);
- break;
- case 19:
- matchEntriesBuilder.setOxmMatchField(Icmpv4Type.class);
- Icmpv4TypeMatchEntryBuilder icmpv4TypeBuilder = new Icmpv4TypeMatchEntryBuilder();
- icmpv4TypeBuilder.setIcmpv4Type(in.readUnsignedByte());
- matchEntriesBuilder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4TypeBuilder.build());
- break;
- case 20:
- matchEntriesBuilder.setOxmMatchField(Icmpv4Code.class);
- Icmpv4CodeMatchEntryBuilder icmpv4CodeBuilder = new Icmpv4CodeMatchEntryBuilder();
- icmpv4CodeBuilder.setIcmpv4Code(in.readUnsignedByte());
- matchEntriesBuilder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4CodeBuilder.build());
- break;
- case 21:
- matchEntriesBuilder.setOxmMatchField(ArpOp.class);
- OpCodeMatchEntryBuilder opcodeBuilder = new OpCodeMatchEntryBuilder();
- opcodeBuilder.setOpCode(in.readUnsignedShort());
- matchEntriesBuilder.addAugmentation(OpCodeMatchEntry.class, opcodeBuilder.build());
- break;
- case 22:
- matchEntriesBuilder.setOxmMatchField(ArpSpa.class);
- addIpv4AddressAugmentation(matchEntriesBuilder, in);
- if (hasMask) {
- addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES);
- }
- break;
- case 23:
- matchEntriesBuilder.setOxmMatchField(ArpTpa.class);
- addIpv4AddressAugmentation(matchEntriesBuilder, in);
- if (hasMask) {
- addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES);
- }
- break;
- case 24:
- matchEntriesBuilder.setOxmMatchField(ArpSha.class);
- addMacAddressAugmentation(matchEntriesBuilder, in);
- if (hasMask) {
- addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.MAC_ADDRESS_LENGTH);
- }
- break;
- case 25:
- matchEntriesBuilder.setOxmMatchField(ArpTha.class);
- addMacAddressAugmentation(matchEntriesBuilder, in);
- if (hasMask) {
- addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.MAC_ADDRESS_LENGTH);
- }
- break;
- case 26:
- matchEntriesBuilder.setOxmMatchField(Ipv6Src.class);
- addIpv6AddressAugmentation(matchEntriesBuilder, in);
- if (hasMask) {
- addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES);
- }
- break;
- case 27:
- matchEntriesBuilder.setOxmMatchField(Ipv6Dst.class);
- addIpv6AddressAugmentation(matchEntriesBuilder, in);
- if (hasMask) {
- addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES);
- }
- break;
- case 28:
- matchEntriesBuilder.setOxmMatchField(Ipv6Flabel.class);
- Ipv6FlabelMatchEntryBuilder ipv6FlabelBuilder = new Ipv6FlabelMatchEntryBuilder();
- ipv6FlabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(in.readUnsignedInt()));
- matchEntriesBuilder.addAugmentation(Ipv6FlabelMatchEntry.class, ipv6FlabelBuilder.build());
- if (hasMask) {
- addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES);
- }
- break;
- case 29:
- matchEntriesBuilder.setOxmMatchField(Icmpv6Type.class);
- Icmpv6TypeMatchEntryBuilder icmpv6TypeBuilder = new Icmpv6TypeMatchEntryBuilder();
- icmpv6TypeBuilder.setIcmpv6Type(in.readUnsignedByte());
- matchEntriesBuilder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6TypeBuilder.build());
- break;
- case 30:
- matchEntriesBuilder.setOxmMatchField(Icmpv6Code.class);
- Icmpv6CodeMatchEntryBuilder icmpv6CodeBuilder = new Icmpv6CodeMatchEntryBuilder();
- icmpv6CodeBuilder.setIcmpv6Code(in.readUnsignedByte());
- matchEntriesBuilder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6CodeBuilder.build());
- break;
- case 31:
- matchEntriesBuilder.setOxmMatchField(Ipv6NdTarget.class);
- addIpv6AddressAugmentation(matchEntriesBuilder, in);
- break;
- case 32:
- matchEntriesBuilder.setOxmMatchField(Ipv6NdSll.class);
- addMacAddressAugmentation(matchEntriesBuilder, in);
- break;
- case 33:
- matchEntriesBuilder.setOxmMatchField(Ipv6NdTll.class);
- addMacAddressAugmentation(matchEntriesBuilder, in);
- break;
- case 34:
- matchEntriesBuilder.setOxmMatchField(MplsLabel.class);
- MplsLabelMatchEntryBuilder mplsLabelBuilder = new MplsLabelMatchEntryBuilder();
- mplsLabelBuilder.setMplsLabel(in.readUnsignedInt());
- matchEntriesBuilder.addAugmentation(MplsLabelMatchEntry.class, mplsLabelBuilder.build());
- break;
- case 35:
- matchEntriesBuilder.setOxmMatchField(MplsTc.class);
- TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder();
- tcBuilder.setTc(in.readUnsignedByte());
- matchEntriesBuilder.addAugmentation(TcMatchEntry.class, tcBuilder.build());
- break;
- case 36:
- matchEntriesBuilder.setOxmMatchField(MplsBos.class);
- BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder();
- if (in.readUnsignedByte() != 0) {
- bosBuilder.setBos(true);
- } else {
- bosBuilder.setBos(false);
- }
- matchEntriesBuilder.addAugmentation(BosMatchEntry.class, bosBuilder.build());
- break;
- case 37:
- matchEntriesBuilder.setOxmMatchField(PbbIsid.class);
- IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder();
- Integer isid = in.readUnsignedMedium();
- isidBuilder.setIsid(isid.longValue());
- matchEntriesBuilder.addAugmentation(IsidMatchEntry.class, isidBuilder.build());
- if (hasMask) {
- addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_3_BYTES);
- }
- break;
- case 38:
- matchEntriesBuilder.setOxmMatchField(TunnelId.class);
- addMetadataAugmentation(matchEntriesBuilder, in);
- if (hasMask) {
- addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_LONG_IN_BYTES);
- }
- break;
- case 39:
- matchEntriesBuilder.setOxmMatchField(Ipv6Exthdr.class);
- PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder();
- int bitmap = in.readUnsignedShort();
- final Boolean NONEXT = ((bitmap) & (1<<0)) != 0;
- final Boolean ESP = ((bitmap) & (1<<1)) != 0;
- final Boolean AUTH = ((bitmap) & (1<<2)) != 0;
- final Boolean DEST = ((bitmap) & (1<<3)) != 0;
- final Boolean FRAG = ((bitmap) & (1<<4)) != 0;
- final Boolean ROUTER = ((bitmap) & (1<<5)) != 0;
- final Boolean HOP = ((bitmap) & (1<<6)) != 0;
- final Boolean UNREP = ((bitmap) & (1<<7)) != 0;
- final Boolean UNSEQ = ((bitmap) & (1<<8)) != 0;
- pseudoBuilder.setPseudoField(new Ipv6ExthdrFlags(AUTH, DEST, ESP, FRAG, HOP, NONEXT, ROUTER, UNREP, UNSEQ));
- matchEntriesBuilder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build());
- if (hasMask) {
- addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
- }
- break;
- default:
- break;
- }
- matchEntriesList.add(matchEntriesBuilder.build());
- if (oneEntry) {
- break;
- }
- }
- if ((matchLength - currLength) > 0) {
- in.skipBytes(matchLength - currLength);
- }
- return matchEntriesList;
- }
-
- /** Decodes oxm ids
- * @param in input ByteBuf
- * @param matchLength match entries length
- * @return list of match ids
- */
- public static List<MatchEntries> createMatchIds(ByteBuf in, int matchLength) {
- return MatchIdsDeserializer.createOxmIds(in, matchLength);
- }
-
- private static void addMaskAugmentation(MatchEntriesBuilder builder, ByteBuf in, int matchEntryLength) {
- MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder();
- byte[] mask = new byte[matchEntryLength];
- in.readBytes(mask);
- maskBuilder.setMask(mask);
- builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build());
- }
-
- private static void addIpv6AddressAugmentation(MatchEntriesBuilder builder, ByteBuf in) {
- Ipv6AddressMatchEntryBuilder ipv6AddressBuilder = new Ipv6AddressMatchEntryBuilder();
- List<String> groups = new ArrayList<>();
- for (int i = 0; i < EncodeConstants.GROUPS_IN_IPV6_ADDRESS; i++) {
- groups.add(String.format("%04X", in.readUnsignedShort()));
- }
- Joiner joiner = Joiner.on(":");
- ipv6AddressBuilder.setIpv6Address(new Ipv6Address(joiner.join(groups)));
- builder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6AddressBuilder.build());
- }
-
- private static void addMetadataAugmentation(MatchEntriesBuilder builder, ByteBuf in) {
- MetadataMatchEntryBuilder metadata = new MetadataMatchEntryBuilder();
- byte[] metadataBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
- in.readBytes(metadataBytes);
- metadata.setMetadata(metadataBytes);
- builder.addAugmentation(MetadataMatchEntry.class, metadata.build());
- }
-
- private static void addIpv4AddressAugmentation(MatchEntriesBuilder builder, ByteBuf in) {
- Ipv4AddressMatchEntryBuilder ipv4AddressBuilder = new Ipv4AddressMatchEntryBuilder();
- List<String> groups = new ArrayList<>();
- for (int i = 0; i < EncodeConstants.GROUPS_IN_IPV4_ADDRESS; i++) {
- groups.add(Short.toString(in.readUnsignedByte()));
- }
- Joiner joiner = Joiner.on(".");
- ipv4AddressBuilder.setIpv4Address(new Ipv4Address(joiner.join(groups)));
- builder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4AddressBuilder.build());
- }
-
- private static void addMacAddressAugmentation(MatchEntriesBuilder builder, ByteBuf in) {
- MacAddressMatchEntryBuilder macAddress = new MacAddressMatchEntryBuilder();
- byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
- in.readBytes(address);
- macAddress.setMacAddress(new MacAddress(ByteBufUtils.macAddressToString(address)));
- builder.addAugmentation(MacAddressMatchEntry.class, macAddress.build());
- }
-
- private static void addPortAugmentation(MatchEntriesBuilder builder, ByteBuf in) {
- PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder();
- portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.
- xml.ns.yang.ietf.inet.types.rev100924.PortNumber(in.readUnsignedShort()));
- builder.addAugmentation(PortMatchEntry.class, portBuilder.build());
+ @Override
+ public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+ this.registry = deserializerRegistry;
}
}
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.util;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageCodeKey;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class MatchEntryDeserializerRegistryHelper {\r
+\r
+ private short version;\r
+ private DeserializerRegistry registry;\r
+ private int oxmClass;\r
+\r
+ /**\r
+ * @param version wire protocol version\r
+ * @param oxmClass oxm_class that will be used for match entry deserializer\r
+ * registration\r
+ * @param deserializerRegistry registry to be filled with message deserializers\r
+ */\r
+ public MatchEntryDeserializerRegistryHelper(short version, int oxmClass,\r
+ DeserializerRegistry deserializerRegistry) {\r
+ this.version = version;\r
+ this.oxmClass = oxmClass;\r
+ this.registry = deserializerRegistry;\r
+ }\r
+\r
+ /**\r
+ * Registers match entry deserializer under provided oxmfield ()\r
+ * @param oxmField oxm_field value/code\r
+ * @param deserializer deserializer instance\r
+ */\r
+ public void register(int oxmField, OFGeneralDeserializer deserializer) {\r
+ registry.registerDeserializer(new EnhancedMessageCodeKey(version, oxmClass,\r
+ oxmField, MatchEntries.class), deserializer);\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.util;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class MessageDeserializerRegistryHelper {\r
+\r
+ private short version;\r
+ private DeserializerRegistry registry;\r
+\r
+ /**\r
+ * @param version wire protocol version\r
+ * @param deserializerRegistry registry to be filled with message deserializers\r
+ */\r
+ public MessageDeserializerRegistryHelper(short version, DeserializerRegistry deserializerRegistry) {\r
+ this.version = version;\r
+ this.registry = deserializerRegistry;\r
+ }\r
+\r
+ /**\r
+ * @param code code / value to distinguish between deserializers\r
+ * @param deserializedObjectClass class of object that will be deserialized\r
+ * by given deserializer\r
+ * @param deserializer deserializer instance\r
+ */\r
+ public void registerMessageDeserializer(int code,\r
+ Class<?> deserializedObjectClass, OFGeneralDeserializer deserializer) {\r
+ registry.registerDeserializer(new MessageCodeKey(version, code,\r
+ deserializedObjectClass), deserializer);\r
+ }\r
+}\r
import java.util.ArrayList;
import java.util.List;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Enqueue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc;
* Deserializes ofp_action (OpenFlow v1.0) structures
* @author michal.polkorab
*/
-public abstract class OF10ActionsDeserializer {
+public class OF10ActionsDeserializer implements OFDeserializer<Action>,
+ DeserializerRegistryInjector {
private static final byte PADDING_IN_SET_VLAN_VID_ACTION = 2;
private static final byte PADDING_IN_SET_VLAN_PCP_ACTION = 3;
private static final byte PADDING_IN_NW_TOS_ACTION = 3;
private static final byte PADDING_IN_TP_ACTION = 2;
private static final byte PADDING_IN_ENQUEUE_ACTION = 6;
+ private DeserializerRegistry registry;
- /**
- * Creates list of actions (OpenFlow v1.0) from ofp_action structures
- * @param input input ByteBuf
- * @return ActionsList list of actions
- */
- public static List<Action> createActionsList(ByteBuf input) {
- List<Action> actions = new ArrayList<>();
- while (input.readableBytes() > 0) {
- int type = input.readUnsignedShort();
- input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
- actions.add(decodeAction(input, type));
- }
- return actions;
- }
-
- /**
- * Creates list of actions (OpenFlow v1.0) from ofp_action structures, which are not the last structure
- * in message
- * @param input input ByteBuf
- * @param actionsLength length of actions
- * @return ActionsList list of actions
- */
- public static List<Action> createActionsList(ByteBuf input, int actionsLength) {
- List<Action> actions = new ArrayList<>();
- int currentLength = 0;
- while (currentLength < actionsLength) {
- int type = input.readUnsignedShort();
- currentLength += input.readUnsignedShort();
- actions.add(decodeAction(input, type));
- }
- return actions;
- }
-
- private static Action decodeAction(ByteBuf input, int type) {
+ @Override
+ public Action deserialize(ByteBuf input) {
+ int type = input.readUnsignedShort();
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
ActionBuilder actionsBuilder = new ActionBuilder();
Action actionsList = null;
switch(type) {
actionsList = createEnqueueAction(input, actionsBuilder);
break;
case 0xFFFF:
- actionsList = createExperimenterAction(input, actionsBuilder);
+ OFDeserializer<ExperimenterAction> expDeserializer = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 0xFFFF, ExperimenterAction.class));
+ expDeserializer.deserialize(input);
break;
default:
break;
return builder.build();
}
- private static Action createExperimenterAction(ByteBuf input, ActionBuilder builder) {
- builder.setType(Experimenter.class);
- ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder();
- expBuilder.setExperimenter(input.readUnsignedInt());
- builder.addAugmentation(ExperimenterAction.class, expBuilder.build());
- return builder.build();
+ @Override
+ public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) {
+ registry = deserializerRegistry;
}
-
}
import java.util.ArrayList;
import java.util.List;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
* Deserializes ofp_match (OpenFlow v1.0) structure
* @author michal.polkorab
*/
-public abstract class OF10MatchDeserializer {
-
+public class OF10MatchDeserializer implements OFDeserializer<MatchV10> {
+
private static final byte PADDING_IN_MATCH = 1;
private static final byte PADDING_IN_MATCH_2 = 2;
private static final byte NW_SRC_BITS = 6;
private static final byte NW_DST_SHIFT = 14;
private static final int NW_DST_MASK = ((1 << NW_DST_BITS) - 1) << NW_DST_SHIFT;
- /**
- * Creates ofp_match (OpenFlow v1.0) structure
- * @param rawMessage ByteBuf with input data
- * @return ofp_match (OpenFlow v1.0)
- */
- public static MatchV10 createMatchV10(ByteBuf rawMessage) {
+ @Override
+ public MatchV10 deserialize(ByteBuf input) {
MatchV10Builder builder = new MatchV10Builder();
- long wildcards = rawMessage.readUnsignedInt();
+ long wildcards = input.readUnsignedInt();
builder.setWildcards(createWildcards(wildcards));
builder.setNwSrcMask(decodeNwSrcMask(wildcards));
builder.setNwDstMask(decodeNwDstMask(wildcards));
- builder.setInPort(rawMessage.readUnsignedShort());
+ builder.setInPort(input.readUnsignedShort());
byte[] dlSrc = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
- rawMessage.readBytes(dlSrc);
+ input.readBytes(dlSrc);
builder.setDlSrc(new MacAddress(ByteBufUtils.macAddressToString(dlSrc)));
byte[] dlDst = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
- rawMessage.readBytes(dlDst);
+ input.readBytes(dlDst);
builder.setDlDst(new MacAddress(ByteBufUtils.macAddressToString(dlDst)));
- builder.setDlVlan(rawMessage.readUnsignedShort());
- builder.setDlVlanPcp(rawMessage.readUnsignedByte());
- rawMessage.skipBytes(PADDING_IN_MATCH);
- builder.setDlType(rawMessage.readUnsignedShort());
- builder.setNwTos(rawMessage.readUnsignedByte());
- builder.setNwProto(rawMessage.readUnsignedByte());
- rawMessage.skipBytes(PADDING_IN_MATCH_2);
+ builder.setDlVlan(input.readUnsignedShort());
+ builder.setDlVlanPcp(input.readUnsignedByte());
+ input.skipBytes(PADDING_IN_MATCH);
+ builder.setDlType(input.readUnsignedShort());
+ builder.setNwTos(input.readUnsignedByte());
+ builder.setNwProto(input.readUnsignedByte());
+ input.skipBytes(PADDING_IN_MATCH_2);
List<String> srcGroups = new ArrayList<>();
for (int i = 0; i < EncodeConstants.GROUPS_IN_IPV4_ADDRESS; i++) {
- srcGroups.add(Short.toString(rawMessage.readUnsignedByte()));
+ srcGroups.add(Short.toString(input.readUnsignedByte()));
}
Joiner joiner = Joiner.on(".");
builder.setNwSrc(new Ipv4Address(joiner.join(srcGroups)));
List<String> dstGroups = new ArrayList<>();
for (int i = 0; i < EncodeConstants.GROUPS_IN_IPV4_ADDRESS; i++) {
- dstGroups.add(Short.toString(rawMessage.readUnsignedByte()));
+ dstGroups.add(Short.toString(input.readUnsignedByte()));
}
builder.setNwDst(new Ipv4Address(joiner.join(dstGroups)));
- builder.setTpSrc(rawMessage.readUnsignedShort());
- builder.setTpDst(rawMessage.readUnsignedShort());
+ builder.setTpSrc(input.readUnsignedShort());
+ builder.setTpDst(input.readUnsignedShort());
return builder.build();
}
-
+
/**
* Decodes FlowWildcards
* @param input input ByteBuf
public static short decodeNwDstMask(long input) {
return (short) Math.max(32 - ((input & NW_DST_MASK) >> NW_DST_SHIFT), 0);
}
-
}
public static final int OPENFLOW_BASIC_CLASS = 0x8000;\r
/** Experimenter class */\r
public static final int EXPERIMENTER_CLASS = 0xFFFF;\r
- \r
+\r
/** Switch input port */\r
public static final int IN_PORT = 0;\r
/** Switch physical input port */\r
public static final int TUNNEL_ID = 38;\r
/** IPv6 Extension Header pseudo-field */\r
public static final int IPV6_EXTHDR = 39;\r
-}\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.openflowjava.protocol.impl.util;\r
+\r
+import java.util.Map;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.TypeToClassKey;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class TypeToClassInitHelper {\r
+\r
+ private short version;\r
+ private Map<TypeToClassKey, Class<?>> messageClassMap;\r
+\r
+ /**\r
+ * Constructor\r
+ * @param version protocol wire version\r
+ * @param messageClassMap map which stores type to class mapping\r
+ */\r
+ public TypeToClassInitHelper(short version, Map<TypeToClassKey, \r
+ Class<?>> messageClassMap) {\r
+ this.version = version;\r
+ this.messageClassMap = messageClassMap;\r
+ }\r
+\r
+ /**\r
+ * Registers Class int the type to class mapping\r
+ * @param type code value for message type / class\r
+ * @param clazz corresponding code -> class\r
+ */\r
+ public void registerTypeToClass(short type, Class<?> clazz) {\r
+ messageClassMap.put(new TypeToClassKey(version, type), clazz);\r
+ }\r
+}\r
import io.netty.buffer.ByteBuf;
+import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
/**
*/
public class BarrierReplyMessageFactoryTest {
+ private OFDeserializer<BarrierOutput> barrierFactory;
+
/**
- * Testing of {@link BarrierReplyMessageFactory} for correct translation into POJO
+ * Initializes deserializer registry and lookups correct deserializer
*/
- @Test
- public void test() {
- ByteBuf bb = BufferHelper.buildBuffer();
- BarrierOutput builtByFactory = BufferHelper.decodeV13(
- BarrierReplyMessageFactory.getInstance(), bb);
-
- BufferHelper.checkHeaderV13(builtByFactory);
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ barrierFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 21, BarrierOutput.class));
}
-
+
/**
* Testing of {@link BarrierReplyMessageFactory} for correct translation into POJO
*/
@Test
- public void testV10() {
+ public void test() {
ByteBuf bb = BufferHelper.buildBuffer();
- BarrierOutput builtByFactory = BufferHelper.decodeV10(
- BarrierReplyMessageFactory.getInstance(), bb);
+ BarrierOutput builtByFactory = BufferHelper.deserialize(
+ barrierFactory, bb);
- BufferHelper.checkHeaderV10(builtByFactory);
+ BufferHelper.checkHeaderV13(builtByFactory);
}
}
import io.netty.buffer.ByteBuf;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoReplyMessageFactory;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;
/**
*/
public class EchoReplyMessageFactoryTest {
- /**
- * Testing {@link EchoReplyMessageFactory} for correct translation into POJO
- */
- @Test
- public void testWithEmptyDataField() {
- ByteBuf bb = BufferHelper.buildBuffer();
- EchoOutput builtByFactory = BufferHelper.decodeV13(
- EchoReplyMessageFactory.getInstance(), bb);
+ private OFDeserializer<EchoOutput> echoFactory;
- BufferHelper.checkHeaderV13(builtByFactory);
- }
-
/**
- * Testing {@link EchoReplyMessageFactory} for correct translation into POJO
+ * Initializes deserializer registry and lookups correct deserializer
*/
- @Test
- public void testWithDataFieldSet() {
- byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
- ByteBuf bb = BufferHelper.buildBuffer(data);
- EchoOutput builtByFactory = BufferHelper.decodeV13(
- EchoReplyMessageFactory.getInstance(), bb);
-
- BufferHelper.checkHeaderV13(builtByFactory);
- Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ echoFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 3, EchoOutput.class));
}
-
+
/**
* Testing {@link EchoReplyMessageFactory} for correct translation into POJO
*/
@Test
- public void testWithEmptyDataFieldV10() {
+ public void testWithEmptyDataField() {
ByteBuf bb = BufferHelper.buildBuffer();
- EchoOutput builtByFactory = BufferHelper.decodeV10(
- EchoReplyMessageFactory.getInstance(), bb);
+ EchoOutput builtByFactory = BufferHelper.deserialize(echoFactory, bb);
- BufferHelper.checkHeaderV10(builtByFactory);
+ BufferHelper.checkHeaderV13(builtByFactory);
}
/**
* Testing {@link EchoReplyMessageFactory} for correct translation into POJO
*/
@Test
- public void testWithDataFieldSetV10() {
+ public void testWithDataFieldSet() {
byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
ByteBuf bb = BufferHelper.buildBuffer(data);
- EchoOutput builtByFactory = BufferHelper.decodeV10(
- EchoReplyMessageFactory.getInstance(), bb);
+ EchoOutput builtByFactory = BufferHelper.deserialize(echoFactory, bb);
- BufferHelper.checkHeaderV10(builtByFactory);
+ BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());
}
-
}
import io.netty.buffer.ByteBuf;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoRequestMessageFactory;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;
/**
*/
public class EchoRequestMessageFactoryTest {
- /**
- * Testing {@link EchoRequestMessageFactory} for correct translation into POJO
- */
- @Test
- public void testWithEmptyDataField() {
- ByteBuf bb = BufferHelper.buildBuffer();
- EchoRequestMessage builtByFactory = BufferHelper.decodeV13(
- EchoRequestMessageFactory.getInstance(), bb);
+ private OFDeserializer<EchoRequestMessage> echoFactory;
- BufferHelper.checkHeaderV13(builtByFactory);
- }
-
/**
- * Testing {@link EchoRequestMessageFactory} for correct translation into POJO
+ * Initializes deserializer registry and lookups correct deserializer
*/
- @Test
- public void testWithDataFieldSet() {
- byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
- ByteBuf bb = BufferHelper.buildBuffer(data);
- EchoRequestMessage builtByFactory = BufferHelper.decodeV13(
- EchoRequestMessageFactory.getInstance(), bb);
-
- BufferHelper.checkHeaderV13(builtByFactory);
- Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ echoFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 2, EchoRequestMessage.class));
}
-
+
/**
* Testing {@link EchoRequestMessageFactory} for correct translation into POJO
*/
@Test
- public void testWithEmptyDataFieldV10() {
+ public void testWithEmptyDataField() {
ByteBuf bb = BufferHelper.buildBuffer();
- EchoRequestMessage builtByFactory = BufferHelper.decodeV10(
- EchoRequestMessageFactory.getInstance(), bb);
+ EchoRequestMessage builtByFactory = BufferHelper.deserialize(echoFactory, bb);
- BufferHelper.checkHeaderV10(builtByFactory);
+ BufferHelper.checkHeaderV13(builtByFactory);
}
/**
* Testing {@link EchoRequestMessageFactory} for correct translation into POJO
*/
@Test
- public void testWithDataFieldSetV10() {
+ public void testWithDataFieldSet() {
byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
ByteBuf bb = BufferHelper.buildBuffer(data);
- EchoRequestMessage builtByFactory = BufferHelper.decodeV10(
- EchoRequestMessageFactory.getInstance(), bb);
+ EchoRequestMessage builtByFactory = BufferHelper.deserialize(echoFactory, bb);
- BufferHelper.checkHeaderV10(builtByFactory);
+ BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());
}
-
}
import io.netty.buffer.ByteBuf;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
/**
*/
public class ErrorMessageFactoryTest {
+ private OFDeserializer<ErrorMessage> errorFactory;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ errorFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 1, ErrorMessage.class));
+ }
+
/**
* Test of {@link ErrorMessageFactory} for correct translation into POJO
*/
@Test
public void testWithoutData() {
ByteBuf bb = BufferHelper.buildBuffer("00 01 00 02");
- ErrorMessage builtByFactory = BufferHelper.decodeV13(
- ErrorMessageFactory.getInstance(), bb);
+ ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 1, builtByFactory.getType().intValue());
@Test
public void testWithData() {
ByteBuf bb = BufferHelper.buildBuffer("00 00 00 01 00 01 02 03");
- ErrorMessage builtByFactory = BufferHelper.decodeV13(
- ErrorMessageFactory.getInstance(), bb);
+ ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 0, builtByFactory.getType().intValue());
@Test
public void testWithIncorrectTypeEnum() {
ByteBuf bb = BufferHelper.buildBuffer("00 20 00 05 00 01 02 03");
- ErrorMessage builtByFactory = BufferHelper.decodeV13(
- ErrorMessageFactory.getInstance(), bb);
+ ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 32, builtByFactory.getType().intValue());
@Test
public void testWithIncorrectCodeEnum() {
ByteBuf bb = BufferHelper.buildBuffer("00 03 00 10 00 01 02 03");
- ErrorMessage builtByFactory = BufferHelper.decodeV13(
- ErrorMessageFactory.getInstance(), bb);
+ ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 3, builtByFactory.getType().intValue());
+++ /dev/null
-/*
- * Copyright (c) 2013 Pantheon Technologies s.r.o. 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.factories;
-
-import io.netty.buffer.ByteBuf;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;
-
-/**
- * @author michal.polkorab
- *
- */
-public class ExperimenterMessageFactoryTest {
-
- /**
- * Testing {@link ExperimenterMessageFactory} for correct translation into POJO
- */
- @Test
- public void test() {
- ByteBuf bb = BufferHelper.buildBuffer("01 02 03 04 01 02 03 04");
- ExperimenterMessage builtByFactory = BufferHelper.decodeV13(
- ExperimenterMessageFactory.getInstance(), bb);
-
- BufferHelper.checkHeaderV13(builtByFactory);
- Assert.assertEquals("Wrong experimenter", 0x01020304L, builtByFactory.getExperimenter().longValue());
- Assert.assertEquals("Wrong expType", 0x01020304L, builtByFactory.getExpType().longValue());
- }
-
-}
import io.netty.buffer.ByteBuf;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
*/
public class FeaturesReplyMessageFactoryTest {
+ private OFDeserializer<GetFeaturesOutput> featuresFactory;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ featuresFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 6, GetFeaturesOutput.class));
+ }
+
/**
* Testing {@link FeaturesReplyMessageFactory} for correct translation into POJO
*/
public void test() {
ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 01 00 00 00"
+ " 00 01 41 00 01 02 03");
- GetFeaturesOutput builtByFactory = BufferHelper.decodeV13(
- FeaturesReplyMessageFactory.getInstance(), bb);
+ GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong datapathId", 0x0001020304050607L, builtByFactory.getDatapathId().longValue());
import io.netty.buffer.ByteBuf;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
*/
public class FlowRemovedMessageFactoryTest {
+ private OFDeserializer<FlowRemovedMessage> flowFactory;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ flowFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 11, FlowRemovedMessage.class));
+ }
+
/**
* Testing {@link FlowRemovedMessageFactory} for correct translation into POJO
*/
public void test(){
ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 03 02 04 00 00 00 02"
+ " 00 00 00 05 00 01 00 03 00 01 02 03 04 05 06 07 00 01 02 03 04 05 06 07");
- FlowRemovedMessage builtByFactory = BufferHelper.decodeV13(FlowRemovedMessageFactory.getInstance(), bb);
+ FlowRemovedMessage builtByFactory = BufferHelper.deserialize(flowFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
import java.util.List;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;
*
*/
public class GetAsyncReplyMessageFactoryTest {
-
+
+ private OFDeserializer<GetAsyncOutput> asyncFactory;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ asyncFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 27, GetAsyncOutput.class));
+ }
/**
* Testing {@link GetAsyncReplyMessageFactory} for correct translation into POJO
"00 00 00 00 "+
"00 00 00 03 "+
"00 00 00 0A");
- GetAsyncOutput builtByFactory = BufferHelper.decodeV13(GetAsyncReplyMessageFactory.getInstance(), bb);
+ GetAsyncOutput builtByFactory = BufferHelper.deserialize(asyncFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong packetInMask",createPacketInMask(),
import io.netty.buffer.ByteBuf;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput;
/**
*/
public class GetConfigReplyMessageFactoryTest {
+ private OFDeserializer<GetConfigOutput> configFactory;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ configFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 8, GetConfigOutput.class));
+ }
+
/**
* Testing {@link GetConfigReplyMessageFactory} for correct translation into POJO
*/
@Test
public void test() {
ByteBuf bb = BufferHelper.buildBuffer("00 01 00 03");
- GetConfigOutput builtByFactory = BufferHelper.decodeV13(
- GetConfigReplyMessageFactory.getInstance(), bb);
+ GetConfigOutput builtByFactory = BufferHelper.deserialize(configFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong switchConfigFlag", 0x01, builtByFactory.getFlags().getIntValue());
package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
+import io.netty.buffer.ByteBuf;
+
import java.util.ArrayList;
import java.util.List;
-import io.netty.buffer.ByteBuf;
-
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloElementType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements;
/** Number of currently supported version / codec */
public static final Short VERSION_YET_SUPPORTED = 0x04;
+ private OFDeserializer<HelloMessage> helloFactory;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ helloFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 0, HelloMessage.class));
+ }
/**
* Testing {@link HelloMessageFactory} for correct translation into POJO
+ "00 00 00 00 " // bitmap 2
+ "00 00 00 00" // padding
);
- HelloMessage builtByFactory = BufferHelper.decodeV13(
- HelloMessageFactory.getInstance(), bb);
+ HelloMessage builtByFactory = BufferHelper.deserialize(helloFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
List<Elements> element = createElement();
import java.math.BigInteger;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;
*/
public class MultipartReplyMessageFactoryTest {
+ private OFDeserializer<MultipartReplyMessage> multipartFactory;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ multipartFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 19, MultipartReplyMessage.class));
+ }
+
private static final Logger LOGGER = LoggerFactory
.getLogger(MultipartReplyMessageFactoryTest.class);
bb.writeBytes(dpDescBytes);
ByteBufUtils.padBuffer((DESC_STR_LEN - dpDescBytes.length), bb);
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 0x00, builtByFactory.getType().getIntValue());
"00 01 00 08 06 00 00 00 "+
"00 01 00 08 06 00 00 00");
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue());
"00 00 00 00"//pad
);
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 0x02, builtByFactory.getType().getIntValue());
"AF 01 01 01 01 01 01 01"//matchedCount
);
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 0x03, builtByFactory.getType().getIntValue());
"00 00 00 04"//durationNsec
);
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 0x04, builtByFactory.getType().getIntValue());
"00 00 00 04"//durationNsec
);
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 0x05, builtByFactory.getType().getIntValue());
"FF 02 02 02 02 02 02 02"//byteCountBucket_2.2
);
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 0x06, builtByFactory.getType().getIntValue());
"00 00"//pad
);
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue());
"FF 03 03 03 03 03 03 03"//byteBandCount_03
);
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue());
"FF 03 03 03 03 03 03 03"//byteBandCount_13
);
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue());
"00 00 00 04"//meterBandExperimenter.experimenter
);
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue());
"00 00 00"//meterBandDscp01.pad
);
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue());
"00 00 01 01 00 00 01 01"
);
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 0xFFFF, builtByFactory.getType().getIntValue());
);
bb.writeBytes(bb2.copy(4, bb2.readableBytes()-4));//excluding version and xid
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue());
"00 08 "+//copyTTLIntLen
"00 00 00 00"//copyTTLInPad
);
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
"00 00"//pushPbbPad
);
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
"00 00 00 00"//decNwTtlPad
);
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
"00 00 00 00"
);
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
--- /dev/null
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. 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.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10BarrierReplyMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
+
+/**
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class OF10BarrierReplyMessageFactoryTest {
+
+ private OFDeserializer<BarrierOutput> barrierFactory;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ barrierFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 19, BarrierOutput.class));
+ }
+
+ /**
+ * Testing of {@link OF10BarrierReplyMessageFactory} for correct translation into POJO
+ */
+ @Test
+ public void testV10() {
+ ByteBuf bb = BufferHelper.buildBuffer();
+ BarrierOutput builtByFactory = BufferHelper.deserialize(
+ barrierFactory, bb);
+
+ BufferHelper.checkHeaderV10(builtByFactory);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. 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.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10EchoReplyMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;
+
+/**
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class OF10EchoReplyMessageFactoryTest {
+
+ private OFDeserializer<EchoOutput> echoFactory;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ echoFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 3, EchoOutput.class));
+ }
+
+ /**
+ * Testing {@link OF10EchoReplyMessageFactory} for correct translation into POJO
+ */
+ @Test
+ public void testWithEmptyDataFieldV10() {
+ ByteBuf bb = BufferHelper.buildBuffer();
+ EchoOutput builtByFactory = BufferHelper.deserialize(echoFactory, bb);
+
+ BufferHelper.checkHeaderV10(builtByFactory);
+ }
+
+ /**
+ * Testing {@link OF10EchoReplyMessageFactory} for correct translation into POJO
+ */
+ @Test
+ public void testWithDataFieldSetV10() {
+ byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
+ ByteBuf bb = BufferHelper.buildBuffer(data);
+ EchoOutput builtByFactory = BufferHelper.deserialize(echoFactory, bb);
+
+ BufferHelper.checkHeaderV10(builtByFactory);
+ Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. 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.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;
+
+/**
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class OF10EchoRequestMessageFactoryTest {
+
+ private OFDeserializer<EchoRequestMessage> echoFactory;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ echoFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 2, EchoRequestMessage.class));
+ }
+
+ /**
+ * Testing {@link OF10EchoReplyMessageFactoryTest} for correct translation into POJO
+ */
+ @Test
+ public void testWithEmptyDataFieldV10() {
+ ByteBuf bb = BufferHelper.buildBuffer();
+ EchoRequestMessage builtByFactory = BufferHelper.deserialize(echoFactory, bb);
+
+ BufferHelper.checkHeaderV10(builtByFactory);
+ }
+
+ /**
+ * Testing {@link OF10EchoReplyMessageFactoryTest} for correct translation into POJO
+ */
+ @Test
+ public void testWithDataFieldSetV10() {
+ byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
+ ByteBuf bb = BufferHelper.buildBuffer(data);
+ EchoRequestMessage builtByFactory = BufferHelper.deserialize(echoFactory, bb);
+
+ BufferHelper.checkHeaderV10(builtByFactory);
+ Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());
+ }
+}
import io.netty.buffer.ByteBuf;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
/**
* @author michal.polkorab
*/
public class OF10ErrorMessageFactoryTest {
+ private OFDeserializer<ErrorMessage> errorFactory;
- /**
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ errorFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 1, ErrorMessage.class));
+ }
+
+ /**
* Test of {@link OF10ErrorMessageFactory} for correct translation into POJO
*/
@Test
public void testWithoutData() {
ByteBuf bb = BufferHelper.buildBuffer("00 01 00 02");
- ErrorMessage builtByFactory = BufferHelper.decodeV10(
- OF10ErrorMessageFactory.getInstance(), bb);
+ ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong type", 1, builtByFactory.getType().intValue());
@Test
public void testWithData() {
ByteBuf bb = BufferHelper.buildBuffer("00 00 00 01 00 01 02 03");
- ErrorMessage builtByFactory = BufferHelper.decodeV10(
- OF10ErrorMessageFactory.getInstance(), bb);
+ ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong type", 0, builtByFactory.getType().intValue());
@Test
public void testWithIncorrectTypeEnum() {
ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 05 00 01 02 03");
- ErrorMessage builtByFactory = BufferHelper.decodeV10(
- OF10ErrorMessageFactory.getInstance(), bb);
+ ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong type", 10, builtByFactory.getType().intValue());
@Test
public void testWithIncorrectCodeEnum() {
ByteBuf bb = BufferHelper.buildBuffer("00 03 00 06 00 01 02 03");
- ErrorMessage builtByFactory = BufferHelper.decodeV10(
- OF10ErrorMessageFactory.getInstance(), bb);
+ ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong type", 3, builtByFactory.getType().intValue());
import io.netty.buffer.ByteBuf;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10;
*/
public class OF10FeaturesReplyMessageFactoryTest {
+ private OFDeserializer<GetFeaturesOutput> featuresFactory;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ featuresFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 6, GetFeaturesOutput.class));
+ }
+
/**
* Testing {@link OF10FeaturesReplyMessageFactory} for correct translation into POJO
*/
+ "00 00 00 8B 00 00 03 B5 "
+ "00 10 01 01 05 01 04 02 41 4C 4F 48 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 00 00 01 01 "
+ "00 00 00 31 00 00 04 42 00 00 03 0C 00 00 08 88");
- GetFeaturesOutput builtByFactory = BufferHelper.decodeV10(
- OF10FeaturesReplyMessageFactory.getInstance(), bb);
+ GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong datapathId", 0x0001020304050607L, builtByFactory.getDatapathId().longValue());
+ "00 00 00 31 00 00 04 42 00 00 03 0C 00 00 08 88 "
+ "00 10 01 01 05 01 04 02 41 4C 4F 48 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 00 00 01 01 "
+ "00 00 00 31 00 00 04 42 00 00 03 0C 00 00 08 88 ");
- GetFeaturesOutput builtByFactory = BufferHelper.decodeV10(
- OF10FeaturesReplyMessageFactory.getInstance(), bb);
+ GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong ports size", 2, builtByFactory.getPhyPort().size());
public void testWithTwoPortsSet() {
ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 00 00 00 "
+ "00 00 00 8B 00 00 03 B5");
- GetFeaturesOutput builtByFactory = BufferHelper.decodeV10(
- OF10FeaturesReplyMessageFactory.getInstance(), bb);
+ GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong ports size", 0, builtByFactory.getPhyPort().size());
import io.netty.buffer.ByteBuf;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
/**
*/
public class OF10FlowRemovedMessageFactoryTest {
- /**
+ private OFDeserializer<FlowRemovedMessage> flowFactory;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ flowFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 11, FlowRemovedMessage.class));
+ }
+
+ /**
* Testing {@link OF10FlowRemovedMessageFactory} for correct translation into POJO
*/
@Test
+ "50 50 20 20 "// match
+ "00 01 02 03 04 05 06 07 00 03 01 00 00 00 00 02 "
+ "00 00 00 05 00 08 00 00 00 01 02 03 04 05 06 07 00 01 02 03 04 05 06 07");//41
- FlowRemovedMessage builtByFactory = BufferHelper.decodeV10(OF10FlowRemovedMessageFactory.getInstance(), bb);
+ FlowRemovedMessage builtByFactory = BufferHelper.deserialize(flowFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong cookie", 0x0001020304050607L, builtByFactory.getCookie().longValue());
--- /dev/null
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. 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.factories;
+
+import io.netty.buffer.ByteBuf;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10GetConfigReplyMessageFactory;
+import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput;
+
+/**
+ * @author michal.polkorab
+ * @author timotej.kubas
+ */
+public class OF10GetConfigReplyMessageFactoryTest {
+
+ private OFDeserializer<GetConfigOutput> configFactory;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ configFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 8, GetConfigOutput.class));
+ }
+
+ /**
+ * Testing {@link OF10GetConfigReplyMessageFactory} for correct translation into POJO
+ */
+ @Test
+ public void test() {
+ ByteBuf bb = BufferHelper.buildBuffer("00 01 00 03");
+ GetConfigOutput builtByFactory = BufferHelper.deserialize(configFactory, bb);
+
+ BufferHelper.checkHeaderV10(builtByFactory);
+ Assert.assertEquals("Wrong switchConfigFlag", 0x01, builtByFactory.getFlags().getIntValue());
+ Assert.assertEquals("Wrong missSendLen", 0x03, builtByFactory.getMissSendLen().intValue());
+ }
+
+}
import io.netty.buffer.ByteBuf;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;
/**
*/
public class OF10HelloMessageFactoryTest {
- /**
+ private OFDeserializer<HelloMessage> helloFactory;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ helloFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 0, HelloMessage.class));
+ }
+
+ /**
* Testing {@link OF10HelloMessageFactory} for correct translation into POJO
*/
@Test
public void testWithoutElements() {
ByteBuf bb = BufferHelper.buildBuffer();
- HelloMessage builtByFactory = BufferHelper.decodeV10(
- OF10HelloMessageFactory.getInstance(), bb);
+ HelloMessage builtByFactory = BufferHelper.deserialize(
+ helloFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertNull("Wrong elements", builtByFactory.getElements());
+ "00 00 00 00 " // bitmap 2
+ "00 00 00 00" // padding
);
- HelloMessage builtByFactory = BufferHelper.decodeV10(
- OF10HelloMessageFactory.getInstance(), bb);
+ HelloMessage builtByFactory = BufferHelper.deserialize(
+ helloFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertNull("Wrong elements", builtByFactory.getElements());
import io.netty.buffer.ByteBuf;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
+/**
+ * @author michal.polkorab
+ */
public class OF10PacketInMessageFactoryTest {
- /**
+ private OFDeserializer<PacketInMessage> packetInFactory;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ packetInFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 10, PacketInMessage.class));
+ }
+
+ /**
* Testing {@link OF10PacketInMessageFactory} for correct translation into POJO
*/
@Test
public void test(){
ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 01 02 01 02 00 00 01 02 03 04");
- PacketInMessage builtByFactory = BufferHelper.decodeV10(OF10PacketInMessageFactory.getInstance(), bb);
+ PacketInMessage builtByFactory = BufferHelper.deserialize(packetInFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong bufferID", 0x00010203L, builtByFactory.getBufferId().longValue());
import io.netty.buffer.ByteBuf;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10;
*/
public class OF10PortStatusMessageFactoryTest {
+ private OFDeserializer<PortStatusMessage> statusFactory;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ statusFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 12, PortStatusMessage.class));
+ }
+
/**
* Testing {@link OF10PortStatusMessageFactory} for correct translation into POJO
*/
ByteBuf bb = BufferHelper.buildBuffer("00 00 00 00 00 00 00 00 "
+ "00 10 01 01 05 01 04 02 41 4C 4F 48 41 00 00 00 00 00 00 00 00 00 00 "
+ "00 00 00 00 15 00 00 01 01 00 00 00 31 00 00 04 42 00 00 03 0C 00 00 08 88");
- PortStatusMessage builtByFactory = BufferHelper.decodeV10(OF10PortStatusMessageFactory.getInstance(), bb);
+ PortStatusMessage builtByFactory = BufferHelper.deserialize(statusFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong reason", PortReason.OFPPRADD, builtByFactory.getReason());
import io.netty.buffer.ByteBuf;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;
*/
public class OF10QueueGetConfigReplyMessageFactoryTest {
+ private OFDeserializer<GetQueueConfigOutput> queueFactory;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ queueFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 21, GetQueueConfigOutput.class));
+ }
+
/**
* Testing of {@link OF10QueueGetConfigReplyMessageFactory} for correct
* translation into POJO
+ "00 00 00 08 00 10 00 00 00 00 00 08 00 00 00 00 "
+ "00 00 00 02 00 28 00 00 00 01 00 10 00 00 00 00 00 20 00 00 00 00 00 00 "
+ "00 01 00 10 00 00 00 00 00 30 00 00 00 00 00 00");
- GetQueueConfigOutput builtByFactory = BufferHelper.decodeV10(
- OF10QueueGetConfigReplyMessageFactory.getInstance(), bb);
+ GetQueueConfigOutput builtByFactory = BufferHelper.deserialize(
+ queueFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong port", 1, builtByFactory.getPort().getValue().intValue());
import java.math.BigInteger;\r
\r
import org.junit.Assert;\r
+import org.junit.Before;\r
import org.junit.Test;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;\r
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction;\r
*/\r
public class OF10StatsReplyMessageFactoryTest {\r
\r
+ private OFDeserializer<MultipartReplyMessage> statsFactory;\r
+\r
+ /**\r
+ * Initializes deserializer registry and lookups correct deserializer\r
+ */\r
+ @Before\r
+ public void startUp() {\r
+ DeserializerRegistry registry = new DeserializerRegistryImpl();\r
+ registry.init();\r
+ statsFactory = registry.getDeserializer(\r
+ new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 17, MultipartReplyMessage.class));\r
+ }\r
+\r
/**\r
* Testing OF10StatsReplyMessageFactory (Desc) for correct deserialization\r
*/\r
bb.writeBytes(dpDescBytes);\r
ByteBufUtils.padBuffer((DESC_STR_LEN - dpDescBytes.length), bb);\r
\r
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV10(OF10StatsReplyMessageFactory.getInstance(), bb);\r
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);\r
\r
BufferHelper.checkHeaderV10(builtByFactory);\r
Assert.assertEquals("Wrong type", 0, builtByFactory.getType().getIntValue());\r
+ "FF 01 02 03 04 05 06 07 FF 01 02 03 04 05 06 07 FF 00 00 00 00 00 00 20 "\r
+ "00 00 00 08 00 01 00 02 00 01 00 08 00 03 00 00");\r
\r
- MultipartReplyMessage builtByFactory = \r
- BufferHelper.decodeV10(OF10StatsReplyMessageFactory.getInstance(), bb);\r
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);\r
\r
BufferHelper.checkHeaderV10(builtByFactory);\r
Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue());\r
ByteBuf bb = BufferHelper.buildBuffer("00 02 00 01 "\r
+ "FF 01 02 03 04 05 06 07 FF 00 00 00 00 00 00 20 00 00 00 30 00 00 00 00");\r
\r
- MultipartReplyMessage builtByFactory = \r
- BufferHelper.decodeV10(OF10StatsReplyMessageFactory.getInstance(), bb);\r
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);\r
\r
BufferHelper.checkHeaderV10(builtByFactory);\r
Assert.assertEquals("Wrong type", 0x02, builtByFactory.getType().getIntValue());\r
+ "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "\r
+ "00 00 00 30 00 00 00 10 FF 01 01 01 01 01 01 01 FF 01 01 01 01 01 01 00");\r
\r
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV10(OF10StatsReplyMessageFactory.getInstance(), bb);\r
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);\r
\r
BufferHelper.checkHeaderV10(builtByFactory);\r
Assert.assertEquals("Wrong type", 0x03, builtByFactory.getType().getIntValue());\r
+ "FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 "\r
+ "FF 02 03 02 03 02 03 02 ");\r
\r
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV10(OF10StatsReplyMessageFactory.getInstance(), bb);\r
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);\r
\r
BufferHelper.checkHeaderV10(builtByFactory);\r
Assert.assertEquals("Wrong type", 0x04, builtByFactory.getType().getIntValue());\r
+ "FF 02 02 02 02 02 02 02 "\r
+ "FF 02 03 02 03 02 03 02 ");\r
\r
- MultipartReplyMessage builtByFactory = BufferHelper.decodeV10(OF10StatsReplyMessageFactory.getInstance(), bb);\r
+ MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);\r
\r
BufferHelper.checkHeaderV10(builtByFactory);\r
Assert.assertEquals("Wrong type", 0x05, builtByFactory.getType().getIntValue());\r
+++ /dev/null
-/*
- * Copyright (c) 2013 Pantheon Technologies s.r.o. 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.factories;
-
-import io.netty.buffer.ByteBuf;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;
-
-/**
- * @author michal.polkorab
- */
-public class OF10VendorMessageFactoryTest {
-
- /**
- * Testing {@link OF10VendorMessageFactory} for correct translation into POJO
- */
- @Test
- public void test() {
- ByteBuf bb = BufferHelper.buildBuffer("01 02 03 04");
- ExperimenterMessage builtByFactory = BufferHelper.decodeV10(
- OF10VendorMessageFactory.getInstance(), bb);
-
- BufferHelper.checkHeaderV10(builtByFactory);
- Assert.assertEquals("Wrong experimenter", 0x01020304L, builtByFactory.getExperimenter().longValue());
- }
-}
import io.netty.buffer.ByteBuf;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* @author timotej.kubas
*/
public class PacketInMessageFactoryTest {
- private static final Logger LOGGER = LoggerFactory
- .getLogger(PacketInMessageFactoryTest.class);
-
+ private OFDeserializer<PacketInMessage> packetInFactory;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ packetInFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 10, PacketInMessage.class));
+ }
+
/**
* Testing {@link PacketInMessageFactory} for correct translation into POJO
*/
public void test(){
ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 01 02 01 04 00 01 02 03 04 05 06 07 00 01 00 0C"
+ " 80 00 02 04 00 00 00 01 00 00 00 00 00 00 01 02 03 04");
- PacketInMessage builtByFactory = BufferHelper.decodeV13(PacketInMessageFactory.getInstance(), bb);
+ PacketInMessage builtByFactory = BufferHelper.deserialize(packetInFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
import io.netty.buffer.ByteBuf;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
*/
public class PortStatusMessageFactoryTest {
+ private OFDeserializer<PortStatusMessage> statusFactory;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ statusFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 12, PortStatusMessage.class));
+ }
+
/**
* Testing {@link PortStatusMessageFactory} for correct translation into POJO
*/
"00 00 00 80" //max speed
);
- PortStatusMessage builtByFactory = BufferHelper.decodeV13(PortStatusMessageFactory.getInstance(), bb);
+ PortStatusMessage builtByFactory = BufferHelper.deserialize(statusFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong reason", 0x01, builtByFactory.getReason().getIntValue());
import java.util.List;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueuePropertyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
*/
public class QueueGetConfigReplyMessageFactoryMultiTest {
+ private OFDeserializer<GetQueueConfigOutput> queueFactory;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ queueFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 23, GetQueueConfigOutput.class));
+ }
+
/**
* Testing of {@link QueueGetConfigReplyMessageFactory} for correct
* translation into POJO
"00 00 00 00 00 00 " // pad
);
- GetQueueConfigOutput builtByFactory = BufferHelper.decodeV13(
- QueueGetConfigReplyMessageFactory.getInstance(), bb);
+ GetQueueConfigOutput builtByFactory = BufferHelper.deserialize(
+ queueFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong port", 66051L, builtByFactory.getPort().getValue().longValue());
import java.util.List;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueuePropertyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
*/
public class QueueGetConfigReplyMessageFactoryTest {
+ private OFDeserializer<GetQueueConfigOutput> queueFactory;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ queueFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 23, GetQueueConfigOutput.class));
+ }
+
/**
* Testing {@link QueueGetConfigReplyMessageFactory} for correct translation into POJO
*/
@Test
public void test(){
ByteBuf bb = BufferHelper.buildBuffer("00 00 00 03 00 00 00 00 00 00 00 01 00 00 00 03 00 20 00 00 00 00 00 00 00 02 00 10 00 00 00 00 00 05 00 00 00 00 00 00");
- GetQueueConfigOutput builtByFactory = BufferHelper.decodeV13(QueueGetConfigReplyMessageFactory.getInstance(), bb);
+ GetQueueConfigOutput builtByFactory = BufferHelper.deserialize(queueFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong port", 3L, builtByFactory.getPort().getValue().longValue());
Assert.assertEquals("Wrong queues", builtByFactory.getQueues(), createQueuesList());
import io.netty.buffer.ByteBuf;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput;
/**
*/
public class RoleReplyMessageFactoryTest {
+ private OFDeserializer<RoleRequestOutput> roleFactory;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ roleFactory = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 25, RoleRequestOutput.class));
+ }
+
/**
* Testing of {@link RoleReplyMessageFactory} for correct translation into POJO
*/
@Test
public void test(){
ByteBuf bb = BufferHelper.buildBuffer("00 00 00 02 00 00 00 00 00 01 02 03 04 05 06 07");
- RoleRequestOutput builtByFactory = BufferHelper.decodeV13(RoleReplyMessageFactory.getInstance(), bb);
+ RoleRequestOutput builtByFactory = BufferHelper.deserialize(roleFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
import java.util.List;\r
\r
import org.junit.Assert;\r
+import org.junit.Before;\r
import org.junit.Test;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction;\r
\r
private static final Logger LOGGER = LoggerFactory\r
.getLogger(ActionsDeserializerTest.class);\r
+ private OFDeserializer<Action> actionDeserializer;\r
+\r
+ /**\r
+ * Initializes deserializer registry and lookups correct deserializer\r
+ */\r
+ @Before\r
+ public void startUp() {\r
+ DeserializerRegistry registry = new DeserializerRegistryImpl();\r
+ registry.init();\r
+ actionDeserializer = registry.getDeserializer(\r
+ new MessageCodeKey(EncodeConstants.OF13_VERSION_ID,\r
+ EncodeConstants.EMPTY_VALUE, Action.class));\r
+ }\r
+\r
/**\r
* Testing actions deserialization\r
*/\r
+ "00 18 00 08 00 00 00 00 "\r
+ "00 19 00 10 80 00 02 04 00 00 00 0B 00 00 00 00 "\r
+ "00 1A 00 08 00 0A 00 00 "\r
- + "00 1B 00 08 00 00 00 00 "\r
- + "FF FF 00 10 00 00 00 08 00 01 02 03 04 05 06 07");\r
+ + "00 1B 00 08 00 00 00 00");\r
\r
message.skipBytes(4); // skip XID\r
LOGGER.info("bytes: " + message.readableBytes());\r
- List<Action> actions = ActionsDeserializer.createActions(message, message.readableBytes());\r
+ \r
+ \r
+ List<Action> actions = DecodingUtils.deserializeList(message.readableBytes(),\r
+ message, actionDeserializer);\r
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight."\r
+ "openflow.common.action.rev130731.Output", actions.get(0).getType().getName());\r
Assert.assertEquals("Wrong action port", 1,\r
actions.get(14).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue());\r
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight."\r
+ "openflow.common.action.rev130731.PopPbb", actions.get(15).getType().getName());\r
- Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight."\r
- + "openflow.common.action.rev130731.Experimenter", actions.get(16).getType().getName());\r
- Assert.assertEquals("Wrong experimenter", 8, actions.get(16).getAugmentation(ExperimenterAction.class)\r
- .getExperimenter().intValue());\r
- Assert.assertArrayEquals("Wrong data", new byte[]{0, 1, 2, 3, 4, 5, 6, 7}, actions.get(16)\r
- .getAugmentation(ExperimenterAction.class).getData());\r
Assert.assertTrue("Unread data in message", message.readableBytes() == 0);\r
}\r
\r
import java.lang.reflect.Method;
import org.junit.Assert;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yangtools.yang.binding.DataObject;
Method m2 = builder.getClass().getMethod("setXid", Long.class);
m2.invoke(builder, BufferHelper.DEFAULT_XID);
}
-
- /**
- * Use version 1.3 for decoding message
- * @param decoder decoder instance
- * @param bb data input buffer
- * @return message decoded pojo
- */
- public static <E extends DataObject> E decodeV13(OFDeserializer<E> decoder, ByteBuf bb) {
- return bufferToMessage(decoder, EncodeConstants.OF13_VERSION_ID, bb);
- }
-
+
/**
- * Use version 1.0 for decoding message
+ * Decode message
* @param decoder decoder instance
* @param bb data input buffer
* @return message decoded pojo
*/
- public static <E extends DataObject> E decodeV10(OFDeserializer<E> decoder, ByteBuf bb) {
- return bufferToMessage(decoder, EncodeConstants.OF10_VERSION_ID, bb);
- }
-
- private static <E extends DataObject> E bufferToMessage(OFDeserializer<E> decoder, short version, ByteBuf bb) {
- return decoder.bufferToMessage(bb, version);
+ public static <E extends DataObject> E deserialize(OFDeserializer<E> decoder, ByteBuf bb) {
+ return decoder.deserialize(bb);
}
}
}
/**
- * Test of {@link ByteBufUtils#fillBitMaskFromList(java.util.Map)}
+ * Test of {@link ByteBufUtils#fillBitMaskFromList(List)}
*/
@Test
public void testFillBitmaskByEmptyList() {
}
/**
- * Test of {@link ByteBufUtils#fillBitMaskFromList(java.util.Map)}
+ * Test of {@link ByteBufUtils#fillBitMaskFromList(List)}
*/
@Test
public void testFillBitmaskByFullList() {
}
/**
- * Test of {@link ByteBufUtils#fillBitMaskFromList(java.util.Map)}
+ * Test of {@link ByteBufUtils#fillBitMaskFromList(List)}
*/
@Test
public void testFillBitmaskByZeroList() {
}
/**
- * Test of {@link ByteBufUtils#fillBitMaskFromList(java.util.Map)}
+ * Test of {@link ByteBufUtils#fillBitMaskFromList(List)}
*/
@Test
public void testFillBitmaskFromRandomList() {
import java.util.List;\r
\r
import org.junit.Assert;\r
+import org.junit.Before;\r
import org.junit.Test;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;\r
*\r
*/\r
public class InstructionsDeserializerTest {\r
- \r
+\r
+ private OFDeserializer<Instruction> insDeserializer;\r
+\r
+ /**\r
+ * Initializes deserializer registry and lookups correct deserializer\r
+ */\r
+ @Before\r
+ public void startUp() {\r
+ DeserializerRegistry registry = new DeserializerRegistryImpl();\r
+ registry.init();\r
+ insDeserializer = registry.getDeserializer(\r
+ new MessageCodeKey(EncodeConstants.OF13_VERSION_ID,\r
+ EncodeConstants.EMPTY_VALUE, Instruction.class));\r
+ }\r
+\r
/**\r
* Testing instructions translation\r
*/\r
+ "00 16 00 08 00 00 00 50 00 04 00 18 00 00 00 00 00 15 00 08 00 00 00 25 00 0F 00 08 05 00 00 00");\r
\r
message.skipBytes(4); // skip XID\r
- List<Instruction> instructions = InstructionsDeserializer.createInstructions(message, message.readableBytes());\r
+ \r
+ List<Instruction> instructions = DecodingUtils.deserializeList(\r
+ message.readableBytes(), message, insDeserializer);\r
Instruction i1 = instructions.get(0);\r
Assert.assertEquals("Wrong type - i1", "org.opendaylight.yang.gen.v1.urn."\r
+ "opendaylight.openflow.common.instruction.rev130731.GotoTable", i1.getType().getName());\r
import java.util.List;\r
\r
import org.junit.Assert;\r
+import org.junit.Before;\r
import org.junit.Test;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageCodeKey;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;\r
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;\r
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;\r
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid;\r
*\r
*/\r
public class MatchDeserializerTest {\r
- \r
+\r
+ private OFDeserializer<Match> matchDeserializer;\r
+ private DeserializerRegistry registry;\r
+\r
+ /**\r
+ * Initializes deserializer registry and lookups correct deserializer\r
+ */\r
+ @Before\r
+ public void startUp() {\r
+ registry = new DeserializerRegistryImpl();\r
+ registry.init();\r
+ matchDeserializer = registry.getDeserializer(\r
+ new MessageCodeKey(EncodeConstants.OF13_VERSION_ID,\r
+ EncodeConstants.EMPTY_VALUE, Match.class));\r
+ }\r
+\r
/**\r
* Testing Ipv4 address deserialization\r
*/\r
@Test\r
public void testIpv4Address() {\r
ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 18 04 00 01 02 03");\r
- \r
- List<MatchEntries> list = MatchDeserializer.createMatchEntry(buffer, 8);\r
- MatchEntries entry = list.get(0);\r
+\r
+ OFDeserializer<MatchEntries> entryDeserializer = registry.getDeserializer(\r
+ new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 12, MatchEntries.class));\r
+ MatchEntries entry = entryDeserializer.deserialize(buffer);\r
Assert.assertEquals("Wrong Ipv4 address format", new Ipv4Address("0.1.2.3"),\r
entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address());\r
}\r
public void testIpv6Address() {\r
ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 34 10 00 00 00 01 00 02 00 03 00 04 00 05 00 06 0F 07");\r
\r
- List<MatchEntries> list = MatchDeserializer.createMatchEntry(buffer, 20);\r
- MatchEntries entry = list.get(0);\r
+ OFDeserializer<MatchEntries> entryDeserializer = registry.getDeserializer(\r
+ new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 26, MatchEntries.class));\r
+ MatchEntries entry = entryDeserializer.deserialize(buffer);\r
Assert.assertEquals("Wrong Ipv6 address format", new Ipv6Address("0000:0001:0002:0003:0004:0005:0006:0F07"),\r
entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address());\r
}\r
public void testMatch() {\r
ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 01 AC "\r
+ "80 00 00 04 00 00 00 01 "\r
- + "00 00 02 04 00 00 00 02 "\r
- + "00 01 05 10 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 04 "\r
- + "FF FF 07 0C 00 00 00 00 00 05 00 00 00 00 00 06 "\r
+ + "80 00 02 04 00 00 00 02 "\r
+ + "80 00 05 10 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 04 "\r
+ + "80 00 07 0C 00 00 00 00 00 05 00 00 00 00 00 06 "\r
+ "80 00 09 0C 00 00 00 00 00 07 00 00 00 00 00 08 "\r
+ "80 00 0A 02 00 09 "\r
+ "80 00 0D 04 00 0A 00 0B "\r
+ "80 00 4F 04 01 66 03 04 "\r
+ "00 00 00 00");\r
\r
- Match match = MatchDeserializer.createMatch(buffer);\r
+ Match match = matchDeserializer.deserialize(buffer);\r
Assert.assertEquals("Wrong match type", OxmMatchType.class, match.getType());\r
Assert.assertEquals("Wrong match entries size", 40, match.getMatchEntries().size());\r
List<MatchEntries> entries = match.getMatchEntries();\r
Assert.assertEquals("Wrong entry value", 1,\r
entry0.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue());\r
MatchEntries entry1 = entries.get(1);\r
- Assert.assertEquals("Wrong entry class", Nxm0Class.class, entry1.getOxmClass());\r
+ Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry1.getOxmClass());\r
Assert.assertEquals("Wrong entry field", InPhyPort.class, entry1.getOxmMatchField());\r
Assert.assertEquals("Wrong entry hasMask", false, entry1.isHasMask());\r
Assert.assertEquals("Wrong entry value", 2,\r
entry1.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue());\r
MatchEntries entry2 = entries.get(2);\r
- Assert.assertEquals("Wrong entry class", Nxm1Class.class, entry2.getOxmClass());\r
+ Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry2.getOxmClass());\r
Assert.assertEquals("Wrong entry field", Metadata.class, entry2.getOxmMatchField());\r
Assert.assertEquals("Wrong entry hasMask", true, entry2.isHasMask());\r
Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"), \r
Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 04"), \r
entry2.getAugmentation(MaskMatchEntry.class).getMask());\r
MatchEntries entry3 = entries.get(3);\r
- Assert.assertEquals("Wrong entry class", ExperimenterClass.class, entry3.getOxmClass());\r
+ Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry3.getOxmClass());\r
Assert.assertEquals("Wrong entry field", EthDst.class, entry3.getOxmMatchField());\r
Assert.assertEquals("Wrong entry hasMask", true, entry3.isHasMask());\r
Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:05"), \r
import java.util.List;\r
\r
import org.junit.Assert;\r
+import org.junit.Before;\r
import org.junit.Test;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;\r
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction;\r
*/\r
public class OF10ActionsDeserializerTest {\r
\r
+ private OFDeserializer<Action> actionsDeserializer;\r
+\r
+ /**\r
+ * Initializes deserializer registry and lookups correct deserializer\r
+ */\r
+ @Before\r
+ public void startUp() {\r
+ DeserializerRegistry registry = new DeserializerRegistryImpl();\r
+ registry.init();\r
+ actionsDeserializer = registry.getDeserializer(\r
+ new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE,\r
+ Action.class));\r
+ }\r
+\r
/**\r
* Testing correct deserialization of actions (OF v1.0)\r
*/\r
+ "00 08 00 08 01 00 00 00 "\r
+ "00 09 00 08 00 02 00 00 "\r
+ "00 0A 00 08 00 03 00 00 "\r
- + "00 0B 00 10 00 04 00 00 00 00 00 00 00 00 00 30 "\r
- + "FF FF 00 08 00 00 12 34");\r
+ + "00 0B 00 10 00 04 00 00 00 00 00 00 00 00 00 30");\r
\r
message.skipBytes(4); // skip XID\r
- List<Action> actions = OF10ActionsDeserializer.createActionsList(message);\r
- Assert.assertEquals("Wrong number of actions", 13, actions.size());\r
+ List<Action> actions = DecodingUtils.deserializeList(message.readableBytes(),\r
+ message, actionsDeserializer);\r
+ Assert.assertEquals("Wrong number of actions", 12, actions.size());\r
Action action1 = actions.get(0);\r
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight"\r
+ ".openflow.common.action.rev130731.Output", action1.getType().getName());\r
.getPort().getValue().intValue());\r
Assert.assertEquals("Wrong queue-id", 48,\r
action12.getAugmentation(QueueIdAction.class).getQueueId().intValue());\r
- Action action13 = actions.get(12);\r
- Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight"\r
- + ".openflow.common.action.rev130731.Experimenter", action13.getType().getName());\r
- Assert.assertEquals("Wrong port", 4660, action13.getAugmentation(ExperimenterAction.class)\r
- .getExperimenter().intValue());\r
}\r
\r
}\r
import io.netty.buffer.ByteBuf;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
*/
public class OF10MatchDeserializerTest {
+ private OFDeserializer<MatchV10> matchDeserializer;
+
+ /**
+ * Initializes deserializer registry and lookups correct deserializer
+ */
+ @Before
+ public void startUp() {
+ DeserializerRegistry registry = new DeserializerRegistryImpl();
+ registry.init();
+ matchDeserializer = registry.getDeserializer(
+ new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class));
+ }
+
/**
* Testing correct deserialization of ofp_match
*/
+ "AA BB CC DD EE FF 00 05 10 00 00 08 07 06 00 00 10 11 12 13 01 02 03 04 "
+ "50 50 20 20");
message.skipBytes(4); // skip XID
- MatchV10 match = OF10MatchDeserializer.createMatchV10(message);
+ MatchV10 match = matchDeserializer.deserialize(message);
Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(false, false, true, false,
false, true, false, true, true, false), match.getWildcards());
Assert.assertEquals("Wrong srcMask", 24, match.getNwSrcMask().shortValue());
+ "AA BB CC DD EE FF 00 05 10 00 00 08 07 06 00 00 10 11 12 13 01 02 03 04 "
+ "50 50 20 20");
message.skipBytes(4); // skip XID
- MatchV10 match = OF10MatchDeserializer.createMatchV10(message);
+ MatchV10 match = matchDeserializer.deserialize(message);
Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(true, true, true, true,
true, true, true, true, true, true), match.getWildcards());
Assert.assertEquals("Wrong srcMask", 0, match.getNwSrcMask().shortValue());
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration;
import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration.FEATURE_SUPPORT;
import org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent;
import org.opendaylight.openflowjava.protocol.impl.clients.ScenarioFactory;
import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey;
import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer;
import org.opendaylight.yangtools.yang.binding.DataObject;
import com.google.common.util.concurrent.ListenableFuture;
*/
public <E extends DataObject> void registerCustomSerializer(MessageTypeKey<E> key,
OFSerializer<E> serializer);
+
+ /**
+ * Registers custom deserializer
+ * @param key used for deserializer lookup
+ * @param deserializer deserializer instance
+ */
+ public void registerDeserializer(MessageCodeKey key, OFGeneralDeserializer deserializer);
+
}