/**
- * Activate library bundle, expose provided implementations:
+ * Activates library bundle, exposes provided implementations:
* <ul>
* <li>{@link SwitchConnectionProviderImpl}</li>
* </ul>
import com.google.common.util.concurrent.SettableFuture;
/**
+ * Handles messages (notifications + rpcs) and connections
* @author mirehak
* @author michal.polkorab
*/
\r
/**\r
* @author michal.polkorab\r
- *\r
*/\r
public interface ConnectionFacade extends MessageConsumer, ConnectionAdapter {\r
\r
/**
* @author mirehak
- *
*/
public interface MessageConsumer {
/**
* @author mirehak
- *
*/
public interface OnlineProvider {
/**
* @author mirehak
- *
*/
public class RpcResponseKey {
/**
* @author mirehak
- *
*/
public interface ServerFacade extends ShutdownProvider, OnlineProvider, Runnable {
/**
* @author mirehak
- *
*/
public interface ShutdownProvider {
import com.google.common.util.concurrent.SettableFuture;
/**
+ * Exposed class for server handling
* @author mirehak
* @author michal.polkorab
*/
return result;
}
+ /**
+ * @return servers
+ */
public Set<ServerFacade> getServerLot() {
return serverLot;
}
import io.netty.channel.ChannelHandlerContext;\r
import io.netty.channel.ChannelInboundHandlerAdapter;\r
\r
+import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterImpl;\r
import org.opendaylight.openflowjava.protocol.impl.connection.MessageConsumer;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEventBuilder;\r
import org.opendaylight.yangtools.yang.binding.DataObject;\r
import org.slf4j.LoggerFactory;\r
\r
/**\r
+ * Holds reference to {@link ConnectionAdapterImpl} and passes messages for further processing.\r
+ * Also informs on switch disconnection.\r
* @author michal.polkorab\r
- *\r
*/\r
public class DelegatingInboundHandler extends ChannelInboundHandlerAdapter {\r
\r
import org.slf4j.LoggerFactory;
/**
- *
+ * Detects idle state of switch and informs upper layers
* @author michal.polkorab
- *
*/
public class IdleHandler extends IdleStateHandler{
private static final Logger LOGGER = LoggerFactory.getLogger(IdleHandler.class);
/**
- *
* @param readerIdleTime
* @param writerIdleTime
* @param allIdleTime
\r
/**\r
* Transforms OpenFlow Protocol messages to POJOs\r
- *\r
* @author michal.polkorab\r
*/\r
public class OF13Decoder extends MessageToMessageDecoder<VersionMessageWrapper> {\r
\r
/**\r
* Transforms OpenFlow Protocol messages to POJOs\r
- * \r
* @author michal.polkorab\r
+ * @author timotej.kubas\r
*/\r
public class OF13Encoder extends MessageToByteEncoder<OfHeader> {\r
\r
public OF13Encoder() {\r
LOGGER.debug("Creating OF13Encoder");\r
}\r
+ \r
@Override\r
protected void encode(ChannelHandlerContext ctx, OfHeader msg, ByteBuf out)\r
throws Exception {\r
import org.slf4j.LoggerFactory;
/**
- * Class for decoding incoming messages into message frames.
- *
+ * Decodes incoming messages into message frames.
* @author michal.polkorab
*/
public class OFFrameDecoder extends ByteToMessageDecoder {
import org.slf4j.LoggerFactory;
/**
- * Class that detects version of used OpenFlow Protocol and engages right OFCodec into
- * pipeline.
- *
+ * Detects version of used OpenFlow Protocol and discards unsupported version messages
* @author michal.polkorab
*/
public class OFVersionDetector extends ByteToMessageDecoder {
import org.slf4j.LoggerFactory;
/**
+ * Initializes the channel
* @author michal.polkorab
- *
*/
public class PublishingChannelInitializer extends ChannelInitializer<SocketChannel> {
import io.netty.buffer.ByteBuf;\r
\r
/**\r
+ * Wraps received messages (includes version)\r
* @author michal.polkorab\r
- *\r
*/\r
public class VersionMessageWrapper {\r
\r
import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.RoleReplyMessageFactory;\r
\r
/**\r
+ * Stores and provides correct decoders for received messages\r
* @author michal.polkorab\r
* \r
* <pre> \r
import org.slf4j.LoggerFactory;\r
\r
/**\r
- *\r
* @author michal.polkorab\r
+ * @author timotej.kubas\r
*/\r
public abstract class DeserializationFactory {\r
\r
/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
package org.opendaylight.openflowjava.protocol.impl.deserialization;\r
\r
+\r
/**\r
+ * Class used as a key in {@link DecoderTable}\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
*/\r
public class MessageTypeCodeKey {\r
\r
import io.netty.buffer.ByteBuf;\r
\r
/**\r
+ * Uniform interface for deserializing factories\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
* @param <E> message code type\r
*/\r
public interface OFDeserializer<E extends DataObject> {\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder;
/**
+ * Translates BarrierReply messages
* @author michal.polkorab
* @author timotej.kubas
- *
*/
public class BarrierReplyMessageFactory implements
OFDeserializer<BarrierOutput> {
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutputBuilder;\r
\r
/**\r
+ * Translates EchoReply messages\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
*/\r
public class EchoReplyMessageFactory implements OFDeserializer<EchoOutput> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder;\r
\r
/**\r
+ * Translates EchoRequest messages\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
*/\r
public class EchoRequestMessageFactory implements OFDeserializer<EchoRequestMessage>{\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder;\r
\r
/**\r
+ * Translates Error messages\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
*/\r
public class ErrorMessageFactory implements OFDeserializer<ErrorMessage> {\r
\r
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>{
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder;\r
\r
/**\r
+ * Translates FeaturesReply messages\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
*/\r
public class FeaturesReplyMessageFactory implements OFDeserializer<GetFeaturesOutput>{\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder;
/**
+ * Translates FlowRemoved messages
* @author michal.polkorab
* @author timotej.kubas
*/
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.get.async.reply.PortStatusMaskBuilder;\r
\r
/**\r
+ * Translates GetAsyncReply messages\r
* @author timotej.kubas\r
* @author michal.polkorab\r
*/\r
public class GetAsyncReplyMessageFactory implements OFDeserializer<GetAsyncOutput> {\r
+ \r
private static GetAsyncReplyMessageFactory instance;\r
\r
private GetAsyncReplyMessageFactory() {\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutputBuilder;
/**
+ * Translates GetConfigReply messages
* @author michal.polkorab
* @author timotej.kubas
*/
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.ElementsBuilder;\r
\r
/**\r
+ * Translates Hello messages\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
*/\r
public class HelloMessageFactory implements OFDeserializer<HelloMessage> {\r
\r
import org.slf4j.LoggerFactory;\r
\r
/**\r
+ * Translates MultipartReply messages\r
* @author timotej.kubas\r
* @author michal.polkorab\r
*/\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder;\r
\r
/**\r
+ * Translates BarrierReply messages (OpenFlow v1.0)\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10BarrierReplyMessageFactory implements OFDeserializer<BarrierOutput> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutputBuilder;\r
\r
/**\r
+ * Translates EchoReply messages (OpenFlow v1.0)\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10EchoReplyMessageFactory implements OFDeserializer<EchoOutput> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder;\r
\r
/**\r
+ * Translates EchoRequest messages (OpenFlow v1.0)\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10EchoRequestMessageFactory implements OFDeserializer<EchoRequestMessage> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder;\r
\r
/**\r
+ * Translates Error messages (OpenFlow v1.0)\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10ErrorMessageFactory implements OFDeserializer<ErrorMessage> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder;\r
\r
/**\r
+ * Translates FeaturesReply messages (OpenFlow v1.0)\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10FeaturesReplyMessageFactory implements OFDeserializer<GetFeaturesOutput> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder;\r
\r
/**\r
+ * Translates FlowRemoved messages (OpenFlow v1.0)\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10FlowRemovedMessageFactory implements OFDeserializer<FlowRemovedMessage> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutputBuilder;\r
\r
/**\r
+ * Translates GetConfigReply messages (OpenFlow v1.0)\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10GetConfigReplyMessageFactory implements OFDeserializer<GetConfigOutput> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder;\r
\r
/**\r
+ * Translates Hello messages (OpenFlow v1.0)\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10HelloMessageFactory implements OFDeserializer<HelloMessage> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder;\r
\r
/**\r
+ * Translates PacketIn messages (OpenFlow v1.0)\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10PacketInMessageFactory implements OFDeserializer<PacketInMessage> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder;\r
\r
/**\r
+ * Translates PortStatus messages (OpenFlow v1.0)\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10PortStatusMessageFactory implements OFDeserializer<PortStatusMessage> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueuePropertyBuilder;\r
\r
/**\r
+ * Translates QueueGetConfigReply messages (OpenFlow v1.0)\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10QueueGetConfigReplyMessageFactory implements OFDeserializer<GetQueueConfigOutput> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.TableStatsBuilder;\r
\r
/**\r
+ * Translates StatsReply messages (OpenFlow v1.0)\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10StatsReplyMessageFactory implements OFDeserializer<MultipartReplyMessage> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder;\r
\r
/**\r
+ * Translates Vendor messages (OpenFlow v1.0)\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10VendorMessageFactory implements OFDeserializer<ExperimenterMessage> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder;
/**
+ * Translates PacketIn messages
* @author michal.polkorab
* @author timotej.kubas
*/
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder;
/**
+ * Translates PortStatus messages
* @author michal.polkorab
* @author timotej.kubas
*/
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueuePropertyBuilder;\r
\r
/**\r
+ * Translates QueueGetConfigReply messages\r
* @author timotej.kubas\r
* @author michal.polkorab\r
*/\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutputBuilder;\r
\r
/**\r
+ * Translates RoleReply messages\r
* @author timotej.kubas\r
* @author michal.polkorab\r
*/\r
import org.opendaylight.yangtools.yang.binding.DataObject;\r
\r
/**\r
+ * Stores and provides correct encoders for received messages\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
*/\r
public class EncoderTable {\r
\r
import org.opendaylight.yangtools.yang.binding.DataObject;\r
\r
/**\r
+ * Class used as a key in {@link EncoderTable}\r
* @author michal.polkorab\r
+ * @author timotej.kubas\r
* @param <E> message type (class)\r
- *\r
*/\r
public class MessageTypeKey<E extends DataObject> {\r
\r
import org.opendaylight.yangtools.yang.binding.DataObject;\r
\r
/**\r
+ * Uniform interface for serializing factories\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
* @param <E> message type\r
*/\r
public interface OFSerializer <E extends DataObject> {\r
public abstract int computeLength(E message);\r
\r
/**\r
- * \r
* @return message code type\r
*/\r
public byte getMessageType();\r
\r
/**\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
*/\r
public class SerializationFactory {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;\r
\r
/**\r
+ * Translates BarrierRequest messages\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
*/\r
public class BarrierInputMessageFactory implements OFSerializer<BarrierInput> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput;\r
\r
/**\r
+ * Translates EchoRequest messages\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
*/\r
public class EchoInputMessageFactory implements OFSerializer<EchoInput> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput;\r
\r
/**\r
+ * Translates EchoReply messages\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
*/\r
public class EchoReplyInputMessageFactory implements OFSerializer<EchoReplyInput>{\r
\r
package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
\r
/**\r
+ * Stores common constants\r
* @author michal.polkorab\r
- *\r
*/\r
public abstract class EncodeConstants {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;\r
\r
/**\r
+ * Translates Experimenter messages\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
*/\r
public class ExperimenterInputMessageFactory implements OFSerializer<ExperimenterInput>{\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;\r
\r
/**\r
+ * Translates FlowMod messages\r
* @author timotej.kubas\r
* @author michal.polkorab\r
*/\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput;\r
\r
/**\r
+ * Translates GetAsyncRequest messages\r
* @author timotej.kubas\r
* @author michal.polkorab\r
*/\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput;\r
\r
/**\r
+ * Translates GetConfigRequest messages\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
*/\r
public class GetConfigInputMessageFactory implements OFSerializer<GetConfigInput> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput;\r
\r
/**\r
+ * Translates FeaturesRequest messages\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
*/\r
public class GetFeaturesInputMessageFactory implements OFSerializer<GetFeaturesInput>{\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput;
/**
+ * Translates QueueGetConfigRequest messages
* @author timotej.kubas
* @author michal.polkorab
*/
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.BucketsList;\r
\r
/**\r
+ * Translates GroupMod messages\r
* @author timotej.kubas\r
* @author michal.polkorab\r
*/\r
import org.slf4j.LoggerFactory;\r
\r
/**\r
+ * Translates Hello messages\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
*/\r
public class HelloInputMessageFactory implements OFSerializer<HelloInput>{\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands;\r
\r
/**\r
+ * Translates MeterMod messages\r
* @author timotej.kubas\r
* @author michal.polkorab\r
*/\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.TableFeatureProperties;\r
\r
/**\r
+ * Translates MultipartRequest messages\r
* @author timotej.kubas\r
* @author michal.polkorab\r
*/\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;\r
\r
/**\r
+ * Translates BarrierRequest messages\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10BarrierInputMessageFactory implements OFSerializer<BarrierInput> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput;\r
\r
/**\r
+ * Translates EchoRequest messages\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10EchoInputMessageFactory implements OFSerializer<EchoInput> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput;\r
\r
/**\r
+ * Translates EchoReply messages\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10EchoReplyInputMessageFactory implements OFSerializer<EchoReplyInput> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput;\r
\r
/**\r
+ * Translates FeaturesRequest messages\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10FeaturesInputMessageFactory implements OFSerializer<GetFeaturesInput>{\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;\r
\r
/**\r
+ * Translates FlowMod messages\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10FlowModInputMessageFactory implements OFSerializer<FlowModInput> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput;\r
\r
/**\r
+ * Translates GetConfigRequest messages\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10GetConfigInputMessageFactory implements OFSerializer<GetConfigInput> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput;\r
\r
/**\r
+ * Translates Hello messages\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10HelloInputMessageFactory implements OFSerializer<HelloInput> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;\r
\r
/**\r
+ * Translates PacketOut messages\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10PacketOutInputMessageFactory implements OFSerializer<PacketOutInput> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;\r
\r
/**\r
+ * Translates PortMod messages\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10PortModInputMessageFactory implements OFSerializer<PortModInput> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput;\r
\r
/**\r
+ * Translates QueueGetConfigRequest messages\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10QueueGetConfigInputMessageFactory implements OFSerializer<GetQueueConfigInput> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;\r
\r
/**\r
+ * Translates SetConfig messages\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10SetConfigMessageFactory implements OFSerializer<SetConfigInput> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueue;\r
\r
/**\r
+ * Translates StatsRequest messages\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10StatsRequestMessageFactory implements OFSerializer<MultipartRequestMessage> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput;\r
\r
/**\r
+ * Translates Vendor messages\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10VendorInputMessageFactory implements OFSerializer<ExperimenterInput> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;\r
\r
/**\r
+ * Translates PacketOut messages\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
*/\r
public class PacketOutInputMessageFactory implements OFSerializer<PacketOutInput>{\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;\r
\r
/**\r
+ * Translates PortMod messages\r
* @author timotej.kubas\r
* @author michal.polkorab\r
*/\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput;\r
\r
/**\r
+ * Translates RoleRequest messages\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
*/\r
public class RoleRequestInputMessageFactory implements OFSerializer<RoleRequestInput> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput;\r
\r
/**\r
+ * Translates SetAsync messages\r
* @author timotej.kubas\r
* @author michal.polkorab\r
*/\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;\r
\r
/**\r
+ * Translates SetConfig messages\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
*/\r
public class SetConfigMessageFactory implements OFSerializer<SetConfigInput> {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;\r
\r
/**\r
+ * Translates TableMod messages\r
* @author timotej.kubas\r
* @author michal.polkorab\r
*/\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
\r
/**\r
- * Class for easy deserialization of actions\r
- * \r
+ * Deserializes ofp_actions (OpenFlow v1.3)\r
* @author timotej.kubas\r
* @author michal.polkorab\r
*/\r
private static final byte ACTION_HEADER_LENGTH = 4;\r
\r
/**\r
+ * Creates list of actions (OpenFlow v1.3)\r
* @param input input ByteBuf\r
* @param actionsLength length of buckets\r
* @return ActionsList\r
int currentActionLength = 0;\r
switch(input.readUnsignedShort()) {\r
case 0: currentActionLength = input.readUnsignedShort(); //outputActionLength\r
- actionsList.add(ActionsDeserializer.createOutputAction(input, actionsListBuilder));\r
+ actionsList.add(createOutputAction(input, actionsListBuilder));\r
break;\r
case 11: \r
currentActionLength = input.readUnsignedShort();//empty header length\r
- actionsList.add(ActionsDeserializer.createCopyTtlOutAction(input, actionsListBuilder));\r
+ actionsList.add(createCopyTtlOutAction(input, actionsListBuilder));\r
break;\r
\r
case 12: \r
currentActionLength = input.readUnsignedShort();//empty header length\r
- actionsList.add(ActionsDeserializer.createCopyTtlInAction(input, actionsListBuilder));\r
+ actionsList.add(createCopyTtlInAction(input, actionsListBuilder));\r
break;\r
\r
case 15: \r
currentActionLength = input.readUnsignedShort();//empty header length\r
- actionsList.add(ActionsDeserializer.createSetMplsTtlAction(input, actionsListBuilder));\r
+ actionsList.add(createSetMplsTtlAction(input, actionsListBuilder));\r
break;\r
\r
case 16: \r
currentActionLength = input.readUnsignedShort();//empty header length\r
- actionsList.add(ActionsDeserializer.createDecMplsTtlOutAction(input, actionsListBuilder));\r
+ actionsList.add(createDecMplsTtlOutAction(input, actionsListBuilder));\r
break;\r
\r
case 17: \r
currentActionLength = input.readUnsignedShort();\r
- actionsList.add(ActionsDeserializer.createPushVlanAction(input, actionsListBuilder));\r
+ actionsList.add(createPushVlanAction(input, actionsListBuilder));\r
break;\r
\r
case 18: \r
currentActionLength = input.readUnsignedShort();//empty header length\r
- actionsList.add(ActionsDeserializer.createPopVlanAction(input, actionsListBuilder));\r
+ actionsList.add(createPopVlanAction(input, actionsListBuilder));\r
break;\r
\r
case 19: \r
currentActionLength = input.readUnsignedShort();//8\r
- actionsList.add(ActionsDeserializer.createPushMplsAction(input, actionsListBuilder));\r
+ actionsList.add(createPushMplsAction(input, actionsListBuilder));\r
break;\r
\r
case 20: \r
currentActionLength = input.readUnsignedShort();//8\r
- actionsList.add(ActionsDeserializer.createPopMplsAction(input, actionsListBuilder));\r
+ actionsList.add(createPopMplsAction(input, actionsListBuilder));\r
break;\r
\r
case 21: \r
currentActionLength = input.readUnsignedShort();\r
- actionsList.add(ActionsDeserializer.createSetQueueAction(input, actionsListBuilder));\r
+ actionsList.add(createSetQueueAction(input, actionsListBuilder));\r
break;\r
\r
case 22: \r
currentActionLength = input.readUnsignedShort();//8\r
- actionsList.add(ActionsDeserializer.createGroupAction(input, actionsListBuilder));\r
+ actionsList.add(createGroupAction(input, actionsListBuilder));\r
break;\r
\r
case 23: \r
currentActionLength = input.readUnsignedShort();//8\r
- actionsList.add(ActionsDeserializer.createSetNwTtlAction(input, actionsListBuilder));\r
+ actionsList.add(createSetNwTtlAction(input, actionsListBuilder));\r
break;\r
\r
case 24: \r
currentActionLength = input.readUnsignedShort();//empty header length\r
- actionsList.add(ActionsDeserializer.createDecNwTtlAction(input, actionsListBuilder));\r
+ actionsList.add(createDecNwTtlAction(input, actionsListBuilder));\r
break;\r
\r
case 25:\r
currentActionLength = input.readUnsignedShort();//8\r
- actionsList.add(ActionsDeserializer.createSetFieldAction(input, actionsListBuilder,\r
- currentActionLength));\r
+ actionsList.add(createSetFieldAction(input, actionsListBuilder, currentActionLength));\r
break; \r
case 26: \r
currentActionLength = input.readUnsignedShort();//8\r
- actionsList.add(ActionsDeserializer.createPushPbbAction(input, actionsListBuilder));\r
+ actionsList.add(createPushPbbAction(input, actionsListBuilder));\r
break;\r
\r
case 27: \r
currentActionLength = input.readUnsignedShort();//empty header length\r
- actionsList.add(ActionsDeserializer.createPopPbbAction(input, actionsListBuilder));\r
+ actionsList.add(createPopPbbAction(input, actionsListBuilder));\r
break;\r
\r
case 0xFFFF: \r
currentActionLength = input.readUnsignedShort();\r
- actionsList.add(ActionsDeserializer.createExperimenterAction(input, actionsListBuilder));\r
+ actionsList.add(createExperimenterAction(input, actionsListBuilder));\r
break;\r
default: \r
break;\r
return actionsList;\r
}\r
\r
- \r
- /**\r
- * @param action input action that contains empty header\r
- * @param in input ByteBuf \r
- * @param actionsListBuilder \r
- * @return Action\r
- */\r
private static ActionsList createEmptyHeader(Class<? extends org.opendaylight.yang.gen.v1.\r
urn.opendaylight.openflow.common.types.rev130731.Action> action,\r
ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
return actionsListBuilder.build();\r
}\r
\r
- /**\r
- * @param in input ByteBuf\r
- * @param actionsListBuilder \r
- * @return Action\r
- */\r
- public static ActionsList createCopyTtlInAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
+ private static ActionsList createCopyTtlInAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
return createEmptyHeader(CopyTtlIn.class, in, actionsListBuilder);\r
}\r
- \r
- /**\r
- * @param in input ByteBuf\r
- * @param actionsListBuilder \r
- * @return Action\r
- */\r
- public static ActionsList createCopyTtlOutAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
+\r
+ private static ActionsList createCopyTtlOutAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
return createEmptyHeader(CopyTtlOut.class, in, actionsListBuilder);\r
}\r
\r
- /**\r
- * @param in input ByteBuf\r
- * @param actionsListBuilder \r
- * @return Action\r
- */\r
- public static ActionsList createDecMplsTtlOutAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
+ private static ActionsList createDecMplsTtlOutAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
return createEmptyHeader(DecMplsTtl.class, in, actionsListBuilder);\r
}\r
\r
- /**\r
- * @param in input ByteBuf\r
- * @param actionsListBuilder \r
- * @return Action\r
- */\r
- public static ActionsList createPopVlanAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
+ private static ActionsList createPopVlanAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
return createEmptyHeader(PopVlan.class, in, actionsListBuilder);\r
}\r
\r
- /**\r
- * @param in input ByteBuf\r
- * @param actionsListBuilder \r
- * @return Action\r
- */\r
- public static ActionsList createDecNwTtlAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
+ private static ActionsList createDecNwTtlAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
return createEmptyHeader(DecNwTtl.class, in, actionsListBuilder);\r
}\r
\r
- /**\r
- * @param in input ByteBuf\r
- * @param actionsListBuilder \r
- * @return Action\r
- */\r
- public static ActionsList createPopPbbAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
+ private static ActionsList createPopPbbAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
return createEmptyHeader(PopPbb.class, in, actionsListBuilder);\r
}\r
\r
- /**\r
- * @param in input ByteBuf\r
- * @param actionsListBuilder \r
- * @return ActionList\r
- */\r
- public static ActionsList createOutputAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
+ private static ActionsList createOutputAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
final byte PADDING_IN_OUTPUT_ACTIONS_HEADER = 6;\r
ActionBuilder actionBuilder = new ActionBuilder();\r
actionBuilder.setType(Output.class);\r
actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build());\r
actionsListBuilder.setAction(actionBuilder.build());\r
in.skipBytes(PADDING_IN_OUTPUT_ACTIONS_HEADER);\r
- \r
return actionsListBuilder.build();\r
}\r
\r
- /**\r
- * @param in input ByteBuf\r
- * @param actionsListBuilder \r
- * @return ActionList\r
- */\r
- public static ActionsList createSetMplsTtlAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
+ private static ActionsList createSetMplsTtlAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
final byte PADDING_IN_SET_MPLS_TTL_ACTIONS_HEADER = 3;\r
ActionBuilder actionBuilder = new ActionBuilder();\r
actionBuilder.setType(SetMplsTtl.class);\r
actionBuilder.addAugmentation(MplsTtlAction.class, mplsTtl.build());\r
actionsListBuilder.setAction(actionBuilder.build());\r
in.skipBytes(PADDING_IN_SET_MPLS_TTL_ACTIONS_HEADER);\r
- \r
return actionsListBuilder.build();\r
}\r
\r
- /**\r
- * @param action input action that contains push\r
- * @param in input ByteBuf\r
- * @param actionsListBuilder \r
- * @return ActionList\r
- */\r
private static ActionsList createPushAction(Class<? extends org.opendaylight.yang.gen.\r
v1.urn.opendaylight.openflow.common.types.rev130731.Action> action,\r
ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
actionBuilder.addAugmentation(EthertypeAction.class, etherType.build());\r
actionsListBuilder.setAction(actionBuilder.build());\r
in.skipBytes(PADDING_IN_PUSH_VLAN_ACTIONS_HEADER);\r
- \r
return actionsListBuilder.build();\r
}\r
\r
- /**\r
- * @param in input ByteBuf\r
- * @param actionsListBuilder \r
- * @return Action\r
- */\r
- public static ActionsList createPushVlanAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
+ private static ActionsList createPushVlanAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
return createPushAction(PushVlan.class, in, actionsListBuilder);\r
}\r
\r
- /**\r
- * @param in input ByteBuf\r
- * @param actionsListBuilder \r
- * @return Action\r
- */\r
- public static ActionsList createPushMplsAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
+ private static ActionsList createPushMplsAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
return createPushAction(PushMpls.class, in, actionsListBuilder);\r
}\r
\r
- /**\r
- * @param in input ByteBuf\r
- * @param actionsListBuilder \r
- * @return Action\r
- */\r
- public static ActionsList createPopMplsAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
+ private static ActionsList createPopMplsAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
return createPushAction(PopMpls.class, in, actionsListBuilder);\r
}\r
\r
- /**\r
- * @param in input ByteBuf\r
- * @param actionsListBuilder \r
- * @return Action\r
- */\r
- public static ActionsList createPushPbbAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
+ private static ActionsList createPushPbbAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
return createPushAction(PushPbb.class, in, actionsListBuilder);\r
}\r
\r
- /**\r
- * @param in input ByteBuf\r
- * @param actionsListBuilder \r
- * @return ActionList\r
- */\r
- public static ActionsList createSetQueueAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
+ private static ActionsList createSetQueueAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
ActionBuilder actionBuilder = new ActionBuilder();\r
actionBuilder.setType(SetQueue.class);\r
QueueIdActionBuilder queueId = new QueueIdActionBuilder();\r
queueId.setQueueId(in.readUnsignedInt());\r
actionBuilder.addAugmentation(QueueIdAction.class, queueId.build());\r
actionsListBuilder.setAction(actionBuilder.build());\r
- \r
return actionsListBuilder.build();\r
}\r
\r
- /**\r
- * @param in input ByteBuf\r
- * @param actionsListBuilder \r
- * @return ActionList\r
- */\r
- public static ActionsList createGroupAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
+ private static ActionsList createGroupAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
ActionBuilder actionBuilder = new ActionBuilder();\r
actionBuilder.setType(Group.class);\r
GroupIdActionBuilder group = new GroupIdActionBuilder();\r
group.setGroupId(in.readUnsignedInt());\r
actionBuilder.addAugmentation(GroupIdAction.class, group.build());\r
actionsListBuilder.setAction(actionBuilder.build());\r
- \r
return actionsListBuilder.build();\r
}\r
\r
- /**\r
- * @param in input ByteBuf\r
- * @param actionsListBuilder \r
- * @return ActionList\r
- */\r
- public static ActionsList createExperimenterAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
+ private static ActionsList createExperimenterAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
ActionBuilder actionBuilder = new ActionBuilder();\r
actionBuilder.setType(Experimenter.class);\r
ExperimenterActionBuilder experimenter = new ExperimenterActionBuilder();\r
experimenter.setExperimenter(in.readUnsignedInt());\r
actionBuilder.addAugmentation(ExperimenterAction.class, experimenter.build());\r
actionsListBuilder.setAction(actionBuilder.build());\r
- \r
return actionsListBuilder.build();\r
}\r
\r
- /**\r
- * @param in input ByteBuf\r
- * @param actionsListBuilder \r
- * @return ActionList\r
- */\r
- public static ActionsList createSetNwTtlAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
+ private static ActionsList createSetNwTtlAction(ByteBuf in, ActionsListBuilder actionsListBuilder) {\r
final byte PADDING_IN_NW_TTL_ACTIONS_HEADER = 3;\r
ActionBuilder actionBuilder = new ActionBuilder();\r
actionBuilder.setType(SetNwTtl.class);\r
actionBuilder.addAugmentation(NwTtlAction.class, nwTtl.build());\r
actionsListBuilder.setAction(actionBuilder.build());\r
in.skipBytes(PADDING_IN_NW_TTL_ACTIONS_HEADER);\r
- \r
return actionsListBuilder.build();\r
}\r
\r
- /**\r
- * @param in input ByteBuf\r
- * @param actionsListBuilder \r
- * @param actionLength length of action\r
- * @return ActionList\r
- */\r
- public static ActionsList createSetFieldAction(ByteBuf in, ActionsListBuilder actionsListBuilder, int actionLength) {\r
+ private static ActionsList createSetFieldAction(ByteBuf in, ActionsListBuilder actionsListBuilder, int actionLength) {\r
ActionBuilder actionBuilder = new ActionBuilder();\r
actionBuilder.setType(SetField.class);\r
OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder();\r
matchEntries.setMatchEntries(MatchDeserializer.createMatchEntry(in, actionLength - ACTION_HEADER_LENGTH));\r
actionBuilder.addAugmentation(OxmFieldsAction.class, matchEntries.build());\r
actionsListBuilder.setAction(actionBuilder.build());\r
- \r
return actionsListBuilder.build();\r
}\r
}\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntries;\r
\r
/**\r
- * Class for easy serialization of actions\r
- * \r
+ * Serializes ofp_actions (OpenFlow v1.3)\r
* @author michal.polkorab\r
* @author timotej.kubas\r
*/\r
length += EncodeConstants.PADDING - paddingRemainder;\r
}\r
outBuffer.writeShort(length);\r
+ MatchSerializer.encodeMatchEntries(oxmField.getMatchEntries(), outBuffer);\r
+ ByteBufUtils.padBuffer(EncodeConstants.PADDING - paddingRemainder, outBuffer);\r
}\r
\r
private static void encodePushPbbAction(Action action, ByteBuf outBuffer) {\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;\r
\r
/** Class for common operations on ByteBuf\r
- *\r
* @author michal.polkorab\r
+ * @author timotej.kubas\r
*/\r
public abstract class ByteBufUtils {\r
\r
import io.netty.buffer.ByteBuf;\r
\r
/**\r
+ * Deserializes ofp_instruction (OpenFlow v1.3) structures\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
*/\r
public class InstructionsDeserializer {\r
\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Instruction;\r
\r
/**\r
+ * Serializes ofp_instruction (OpenFlow v 1.3) structure\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
*/\r
public abstract class InstructionsSerializer {\r
\r
/**\r
* Computes length of instructions\r
* @param instructions List of instructions\r
- * @return length of instructions(in bytes)\r
+ * @return length of instructions (in bytes)\r
*/\r
public static int computeInstructionsLength(List<Instructions> instructions) {\r
int length = 0;\r
import com.google.common.base.Joiner;\r
\r
/**\r
- * Class for easy creation of matches\r
+ * Deserializes ofp_match (OpenFlow v1.3) and its oxm_fields structures\r
* @author timotej.kubas\r
* @author michal.polkorab\r
*/\r
/**\r
* Creates match\r
* @param in input ByteBuf\r
- * @return ofp_match\r
+ * @return ofp_match (OpenFlow v1.3)\r
*/\r
public static Match createMatch(ByteBuf in) {\r
if (in.readableBytes() > 0) {\r
}\r
\r
/**\r
+ * Deserializes single match entry (oxm_field)\r
* @param in input ByteBuf\r
- * @param matchLength to infer size of array\r
- * @return MatchEntriesList\r
+ * @param matchLength length of match entry\r
+ * @return MatchEntriesList list containing one match entry\r
*/\r
public static List<MatchEntries> createMatchEntry(ByteBuf in, int matchLength) {\r
return createMatchEntriesInternal(in, matchLength, true);\r
\r
/**\r
* @param in input ByteBuf\r
- * @param matchLength to infer size of array\r
- * @return MatchEntriesList\r
+ * @param matchLength length of match entries\r
+ * @return MatchEntriesList list of match entries\r
*/\r
public static List<MatchEntries> createMatchEntries(ByteBuf in, int matchLength) {\r
return createMatchEntriesInternal(in, matchLength, false);\r
}\r
\r
private static void addMaskAugmentation(MatchEntriesBuilder builder, ByteBuf in, int matchEntryLength) {\r
-// TODO - check if matchEntryLength is in bytes\r
MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder();\r
byte[] mask = new byte[matchEntryLength];\r
in.readBytes(mask);\r
import org.slf4j.LoggerFactory;\r
\r
/**\r
+ * Serializes ofp_match (OpenFlow v1.3) and its oxm_fields structures\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
*/\r
public class MatchSerializer {\r
\r
private static final Logger LOGGER = LoggerFactory.getLogger(MatchSerializer.class);\r
\r
/**\r
- * Encodes OF match\r
+ * Encodes match (OpenFlow v1.3)\r
* @param match ofp_match object\r
* @param out output ByteBuf\r
*/\r
\r
/**\r
* Encodes MatchEntries\r
- * @param matchEntries\r
- * @param out\r
+ * @param matchEntries list of match entries (oxm_fields)\r
+ * @param out output ByteBuf\r
*/\r
public static void encodeMatchEntries(List<MatchEntries> matchEntries, ByteBuf out) {\r
if (matchEntries == null) {\r
}\r
for (MatchEntries entry : matchEntries) {\r
encodeClass(entry.getOxmClass(), out);\r
- encodeRest(entry, null);\r
+ encodeRest(entry, out);\r
}\r
}\r
\r
}\r
\r
/**\r
- * Computes length of ofp_match structure (in bytes)\r
+ * Computes length of match (in bytes)\r
* @param match\r
* @return length of ofp_match (excluding padding)\r
*/\r
\r
/**\r
* Computes length of MatchEntries (in bytes)\r
- * @param matchEntries\r
+ * @param matchEntries list of match entries (oxm_fields)\r
* @return length of MatchEntries\r
*/\r
public static int computeMatchEntriesLength(List<MatchEntries> matchEntries) {\r
import com.google.common.base.Joiner;\r
\r
/**\r
+ * Deserializes ofp_action (OpenFlow v1.0) structures\r
* @author michal.polkorab\r
- *\r
*/\r
public class OF10ActionsDeserializer {\r
\r
/**\r
+ * Creates list of actions (OpenFlow v1.0) from ofp_action structures\r
* @param input input ByteBuf\r
- * @return ActionsList\r
+ * @return ActionsList list of actions\r
*/\r
public static List<ActionsList> createActionsList(ByteBuf input) {\r
List<ActionsList> actions = new ArrayList<>();\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.Action;\r
\r
/**\r
+ * Serializes ofp_action (OpenFlow v1.0) structures\r
* @author michal.polkorab\r
- *\r
*/\r
public abstract class OF10ActionsSerializer {\r
\r
/**\r
- * Encodes actions (OpenFlow v1.0)\r
- * @param out\r
- * @param actionsList\r
+ * Encodes ofp_action (OpenFlow v1.0) structures\r
+ * @param out output ByteBuf that actions will be written into\r
+ * @param actionsList actions to be encoded\r
*/\r
public static void encodeActionsV10(ByteBuf out, List<ActionsList> actionsList) {\r
if (actionsList == null) {\r
import com.google.common.base.Joiner;\r
\r
/**\r
+ * Deserializes ofp_match (OpenFlow v1.0) structure\r
* @author michal.polkorab\r
- *\r
*/\r
public abstract class OF10MatchDeserializer {\r
\r
private static final byte GROUPS_IN_IPV4_ADDRESS = 4;\r
\r
/**\r
- * Creates match \r
- * @param rawMessage\r
+ * Creates ofp_match (OpenFlow v1.0) structure\r
+ * @param rawMessage ByteBuf with input data\r
* @return ofp_match (OpenFlow v1.0)\r
*/\r
public static MatchV10 createMatchV10(ByteBuf rawMessage) {\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10;\r
\r
/**\r
+ * Serializes ofp_match (OpenFlow v1.0) structure\r
* @author michal.polkorab\r
- *\r
*/\r
public abstract class OF10MatchSerializer {\r
\r
\r
/**\r
* Encodes ofp_match (OpenFlow v1.0)\r
- * @param out\r
- * @param match\r
+ * @param out output ByteBuf that match will be written into\r
+ * @param match match to be encoded\r
*/\r
public static void encodeMatchV10(ByteBuf out, MatchV10 match) {\r
out.writeInt(match.getWildcards().intValue());\r
import io.netty.buffer.UnpooledByteBufAllocator;\r
\r
import java.math.BigInteger;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
\r
import org.junit.Assert;\r
import org.junit.Test;\r
import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\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.augments.rev131002.MetadataInstruction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstructionBuilder;\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.augments.rev131002.TableIdInstruction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstructionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.Instructions;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.InstructionsBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;\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.IpEcn;\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.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.oxm.fields.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntriesBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.MatchBuilder;\r
\r
/**\r
* @author timotej.kubas\r
public void testFlowModInputMessageFactory() throws Exception {\r
FlowModInputBuilder builder = new FlowModInputBuilder();\r
BufferHelper.setupHeader(builder);\r
- byte[] cookie = new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};\r
+ byte[] cookie = new byte[]{0x00, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01};\r
builder.setCookie(new BigInteger(cookie));\r
- byte[] cookieMask = new byte[]{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};\r
+ byte[] cookieMask = new byte[]{0x01, 0x05, 0x00, 0x00, 0x09, 0x30, 0x00, 0x30};\r
builder.setCookieMask(new BigInteger(cookieMask));\r
builder.setTableId(new TableId(65L));\r
builder.setCommand(FlowModCommand.forValue(2));\r
builder.setOutPort(new PortNumber(4422L));\r
builder.setOutGroup(98L);\r
builder.setFlags(new FlowModFlags(true, false, true, false, true));\r
+ MatchBuilder matchBuilder = new MatchBuilder();\r
+ matchBuilder.setType(OxmMatchType.class);\r
+ List<MatchEntries> entries = new ArrayList<>();\r
+ MatchEntriesBuilder entriesBuilder = new MatchEntriesBuilder();\r
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
+ entriesBuilder.setOxmMatchField(InPhyPort.class);\r
+ entriesBuilder.setHasMask(false);\r
+ PortNumberMatchEntryBuilder portNumberBuilder = new PortNumberMatchEntryBuilder();\r
+ portNumberBuilder.setPortNumber(new PortNumber(42L));\r
+ entriesBuilder.addAugmentation(PortNumberMatchEntry.class, portNumberBuilder.build());\r
+ entries.add(entriesBuilder.build());\r
+ entriesBuilder.setOxmClass(Nxm0Class.class);\r
+ entriesBuilder.setOxmMatchField(IpEcn.class);\r
+ entriesBuilder.setHasMask(false);\r
+ EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder();\r
+ ecnBuilder.setEcn((short) 4);\r
+ entriesBuilder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build());\r
+ entries.add(entriesBuilder.build());\r
+ matchBuilder.setMatchEntries(entries);\r
+ builder.setMatch(matchBuilder.build());\r
+ List<Instructions> instructions = new ArrayList<>();\r
+ InstructionsBuilder insBuilder = new InstructionsBuilder();\r
+ insBuilder.setType(GotoTable.class);\r
+ TableIdInstructionBuilder idBuilder = new TableIdInstructionBuilder();\r
+ idBuilder.setTableId((short) 43);\r
+ insBuilder.addAugmentation(TableIdInstruction.class, idBuilder.build());\r
+ instructions.add(insBuilder.build());\r
+ insBuilder.setType(WriteMetadata.class);\r
+ MetadataInstructionBuilder metaBuilder = new MetadataInstructionBuilder();\r
+ metaBuilder.setMetadata(cookie);\r
+ metaBuilder.setMetadataMask(cookieMask);\r
+ insBuilder.addAugmentation(MetadataInstruction.class, metaBuilder.build());\r
+ instructions.add(insBuilder.build());\r
+ builder.setInstructions(instructions);\r
FlowModInput message = builder.build();\r
\r
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));\r
Assert.assertEquals("Wrong cookie", message.getCookie().longValue(), out.readLong());\r
Assert.assertEquals("Wrong cookieMask", message.getCookieMask().longValue(), out.readLong());\r
- Assert.assertEquals("Wrong tableId", message.getTableId().getValue().intValue(), out.readByte());\r
- Assert.assertEquals("Wrong command", message.getCommand().getIntValue(), out.readByte());\r
+ Assert.assertEquals("Wrong tableId", message.getTableId().getValue().intValue(), out.readUnsignedByte());\r
+ Assert.assertEquals("Wrong command", message.getCommand().getIntValue(), out.readUnsignedByte());\r
Assert.assertEquals("Wrong idleTimeOut", message.getIdleTimeout().intValue(), out.readShort());\r
Assert.assertEquals("Wrong hardTimeOut", message.getHardTimeout().intValue(), out.readShort());\r
Assert.assertEquals("Wrong priority", message.getPriority().intValue(), out.readUnsignedShort());\r
Assert.assertEquals("Wrong bufferId", message.getBufferId().intValue(), out.readUnsignedInt());\r
Assert.assertEquals("Wrong outPort", message.getOutPort().getValue().intValue(), out.readUnsignedInt());\r
Assert.assertEquals("Wrong outGroup", message.getOutGroup().intValue(), out.readUnsignedInt());\r
- Assert.assertEquals("Wrong flags", message.getFlags(), createFlowModFalgsFromBitmap(out.readShort()));\r
+ Assert.assertEquals("Wrong flags", message.getFlags(), createFlowModFlagsFromBitmap(out.readUnsignedShort()));\r
out.skipBytes(PADDING_IN_FLOW_MOD_MESSAGE);\r
- // TODO implementation of match structure\r
- // TODO implementation of instructions\r
+ Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort());\r
+ out.skipBytes(Short.SIZE / Byte.SIZE);\r
+ Assert.assertEquals("Wrong oxm class", 0x8000, out.readUnsignedShort());\r
+ short fieldAndMask = out.readUnsignedByte();\r
+ Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);\r
+ Assert.assertEquals("Wrong oxm field", 1, fieldAndMask >> 1);\r
+ out.skipBytes(Byte.SIZE / Byte.SIZE);\r
+ Assert.assertEquals("Wrong oxm value", 42, out.readUnsignedInt());\r
+ Assert.assertEquals("Wrong oxm class", 0, out.readUnsignedShort());\r
+ fieldAndMask = out.readUnsignedByte();\r
+ Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);\r
+ Assert.assertEquals("Wrong oxm field", 9, fieldAndMask >> 1);\r
+ out.skipBytes(Byte.SIZE / Byte.SIZE);\r
+ Assert.assertEquals("Wrong oxm value", 4, out.readUnsignedByte());\r
+ out.skipBytes(7);\r
+ Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort());\r
+ out.skipBytes(Short.SIZE / Byte.SIZE);\r
+ Assert.assertEquals("Wrong instruction value", 43, out.readUnsignedByte());\r
+ out.skipBytes(3);\r
+ Assert.assertEquals("Wrong instruction type", 2, out.readUnsignedShort());\r
+ out.skipBytes(Short.SIZE / Byte.SIZE);\r
+ out.skipBytes(Integer.SIZE / Byte.SIZE);\r
+ byte[] cookieRead = new byte[Long.SIZE / Byte.SIZE];\r
+ out.readBytes(cookieRead);\r
+ byte[] cookieMaskRead = new byte[Long.SIZE / Byte.SIZE];\r
+ out.readBytes(cookieMaskRead);\r
+ Assert.assertArrayEquals("Wrong metadata", cookie, cookieRead);\r
+ Assert.assertArrayEquals("Wrong metadata mask", cookieMask, cookieMaskRead); \r
}\r
\r
- private static FlowModFlags createFlowModFalgsFromBitmap(short input){\r
+ private static FlowModFlags createFlowModFlagsFromBitmap(int input){\r
final Boolean _oFPFFSENDFLOWREM = (input & (1 << 0)) > 0;\r
final Boolean _oFPFFCHECKOVERLAP = (input & (1 << 1)) > 0;\r
final Boolean _oFPFFRESETCOUNTS = (input & (1 << 2)) > 0; \r
\r
import io.netty.buffer.ByteBuf;\r
import io.netty.buffer.UnpooledByteBufAllocator;\r
-import junit.framework.Assert;\r
\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.junit.Assert;\r
import org.junit.Test;\r
import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\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.EthertypeActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsListBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.ActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInputBuilder;\r
*/\r
public class PacketOutInputMessageFactoryTest {\r
private static final byte MESSAGE_TYPE = 13;\r
- private static final int MESSAGE_LENGTH = 24;\r
private static final byte PADDING_IN_PACKET_OUT_MESSAGE = 6;\r
+ private static final int PADDING_IN_ACTION_HEADER = 4;\r
\r
/**\r
* Testing of {@link PacketOutInputMessageFactory} for correct translation from POJO\r
BufferHelper.setupHeader(builder);\r
builder.setBufferId(256L);\r
builder.setInPort(new PortNumber(256L));\r
+ List<ActionsList> actions = new ArrayList<>();\r
+ ActionsListBuilder actionsListBuilder = new ActionsListBuilder();\r
+ ActionBuilder actionBuilder = new ActionBuilder();\r
+ actionBuilder.setType(PushVlan.class);\r
+ EthertypeActionBuilder ethertypeBuilder = new EthertypeActionBuilder();\r
+ ethertypeBuilder.setEthertype(new EtherType(25));\r
+ actionBuilder.addAugmentation(EthertypeAction.class, ethertypeBuilder.build());\r
+ actionsListBuilder.setAction(actionBuilder.build());\r
+ actions.add(actionsListBuilder.build());\r
+ actionBuilder = new ActionBuilder();\r
+ actionBuilder.setType(PopVlan.class);\r
+ actionsListBuilder.setAction(actionBuilder.build());\r
+ actions.add(actionsListBuilder.build());\r
+ builder.setActionsList(actions);\r
+ builder.setData(ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14"));\r
PacketOutInput message = builder.build();\r
\r
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();\r
PacketOutInputMessageFactory factory = PacketOutInputMessageFactory.getInstance();\r
factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
\r
- BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);\r
+ BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, 56);\r
Assert.assertEquals("Wrong BufferId", message.getBufferId().longValue(), out.readUnsignedInt());\r
Assert.assertEquals("Wrong PortNumber", message.getInPort().getValue().longValue(), out.readUnsignedInt());\r
- // TODO make test for actions after its implementation in factory \r
- // TODO data\r
+ Assert.assertEquals("Wrong ActionsLength", 16, out.readUnsignedShort());\r
out.skipBytes(PADDING_IN_PACKET_OUT_MESSAGE);\r
+ Assert.assertEquals("Wrong action type", 17, out.readUnsignedShort());\r
+ Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());\r
+ Assert.assertEquals("Wrong ethertype", 25, out.readUnsignedShort());\r
+ out.skipBytes(Short.SIZE / Byte.SIZE);\r
+ Assert.assertEquals("Wrong action type", 18, out.readUnsignedShort());\r
+ Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());\r
+ out.skipBytes(PADDING_IN_ACTION_HEADER);\r
+ Assert.assertArrayEquals("Wrong data", message.getData(), out.readBytes(out.readableBytes()).array());\r
}\r
}\r
@Override\r
public void onPacketInMessage(PacketInMessage notification) {\r
LOGGER.debug("PacketIn message received");\r
- \r
+ LOGGER.debug("BufferId: " + notification.getBufferId());\r
+ LOGGER.debug("TotalLength: " + notification.getTotalLen());\r
+ LOGGER.debug("Reason: " + notification.getReason());\r
+ LOGGER.debug("TableId: " + notification.getTableId());\r
+ LOGGER.debug("Cookie: " + notification.getCookie());\r
+ LOGGER.debug("Class: " + notification.getMatch().getMatchEntries().get(0).getOxmClass());\r
+ LOGGER.debug("Field: " + notification.getMatch().getMatchEntries().get(0).getOxmMatchField());\r
+ LOGGER.debug("Datasize: " + notification.getData().length);\r
}\r
\r
@Override\r
--- /dev/null
+/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
+
+package org.opendaylight.openflowjava.protocol.impl.clients;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.ByteToMessageDecoder;
+
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class for decoding incoming messages into message frames.
+ *
+ * @author michal.polkorab
+ */
+public class SimpleClientFramer extends ByteToMessageDecoder {
+
+ /** Length of OpenFlow 1.3 header */
+ public static final byte LENGTH_OF_HEADER = 8;
+ private static final byte LENGTH_INDEX_IN_HEADER = 2;
+ private static final Logger LOGGER = LoggerFactory.getLogger(SimpleClientFramer.class);
+
+ /**
+ * Constructor of class.
+ */
+ public SimpleClientFramer() {
+ LOGGER.debug("Creating OFFrameDecoder");
+ }
+
+ @Override
+ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+ LOGGER.warn("Unexpected exception from downstream.", cause);
+ ctx.close();
+ }
+
+ @Override
+ protected void decode(ChannelHandlerContext chc, ByteBuf bb, List<Object> list) throws Exception {
+ if (bb.readableBytes() < LENGTH_OF_HEADER) {
+ LOGGER.debug("skipping bb - too few data for header: " + bb.readableBytes());
+ return;
+ }
+
+ int length = bb.getUnsignedShort(LENGTH_INDEX_IN_HEADER);
+ if (bb.readableBytes() < length) {
+ LOGGER.debug("skipping bb - too few data for msg: " +
+ bb.readableBytes() + " < " + length);
+ return;
+ }
+ LOGGER.info("OF Protocol message received, type:{}", bb.getByte(1));
+
+ ByteBuf messageBuffer = bb.slice(bb.readerIndex(), length);
+ list.add(messageBuffer);
+ messageBuffer.retain();
+ bb.skipBytes(length);
+ }
+
+}
public class SimpleClientHandler extends ChannelInboundHandlerAdapter {\r
\r
protected static final Logger LOGGER = LoggerFactory.getLogger(SimpleClientHandler.class);\r
- private static final int OFP_HEADER_LENGTH = 8;\r
+ private static final int LENGTH_INDEX_IN_HEADER = 2;\r
private SettableFuture<Boolean> isOnlineFuture;\r
protected ScenarioHandler scenarioHandler;\r
\r
\r
@Override\r
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {\r
- LOGGER.info("SimpleClientHandler - start of read");\r
ByteBuf bb = (ByteBuf) msg;\r
if (LOGGER.isDebugEnabled()) {\r
LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(bb));\r
}\r
- \r
- if (bb.readableBytes() < OFP_HEADER_LENGTH) {\r
- LOGGER.debug("too few bytes received: "+bb.readableBytes()+" - wait for next data portion");\r
- return;\r
- }\r
- int msgSize = bb.getUnsignedShort(2);\r
- byte[] message = new byte[msgSize];\r
+ int length = bb.getUnsignedShort(LENGTH_INDEX_IN_HEADER);\r
+ LOGGER.info("SimpleClientHandler - start of read");\r
+ byte[] message = new byte[length];\r
bb.readBytes(message);\r
scenarioHandler.addOfMsg(message);\r
LOGGER.info("end of read");\r
.createSSLEngine();
engine.setUseClientMode(true);
pipeline.addLast("ssl", new SslHandler(engine));
+ pipeline.addLast("framer", new SimpleClientFramer());
}
SimpleClientHandler simpleClientHandler = new SimpleClientHandler(isOnlineFuture, scenarioHandler);
simpleClientHandler.setScenario(scenarioHandler);