525f5297051dbf8afef1d28dc06d1f8ee4e6c241
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / MessageDeserializerInitializer.java
1 /*\r
2  * Copyright (c) 2013 Pantheon Technologies s.r.o. and others.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 package org.opendaylight.openflowjava.protocol.impl.deserialization;\r
9 \r
10 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
11 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.BarrierReplyMessageFactory;\r
12 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoReplyMessageFactory;\r
13 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoRequestMessageFactory;\r
14 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.ErrorMessageFactory;\r
15 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FeaturesReplyMessageFactory;\r
16 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FlowRemovedMessageFactory;\r
17 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetAsyncReplyMessageFactory;\r
18 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetConfigReplyMessageFactory;\r
19 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactory;\r
20 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory;\r
21 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10BarrierReplyMessageFactory;\r
22 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10EchoReplyMessageFactory;\r
23 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10EchoRequestMessageFactory;\r
24 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10ErrorMessageFactory;\r
25 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FeaturesReplyMessageFactory;\r
26 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FlowRemovedMessageFactory;\r
27 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10GetConfigReplyMessageFactory;\r
28 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10HelloMessageFactory;\r
29 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PacketInMessageFactory;\r
30 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PortStatusMessageFactory;\r
31 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10QueueGetConfigReplyMessageFactory;\r
32 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory;\r
33 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PacketInMessageFactory;\r
34 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PortStatusMessageFactory;\r
35 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.QueueGetConfigReplyMessageFactory;\r
36 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.RoleReplyMessageFactory;\r
37 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
38 import org.opendaylight.openflowjava.protocol.impl.util.SimpleDeserializerRegistryHelper;\r
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;\r
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;\r
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage;\r
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;\r
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;\r
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput;\r
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput;\r
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;\r
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput;\r
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage;\r
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;\r
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;\r
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;\r
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput;\r
53 \r
54 /**\r
55  * @author michal.polkorab\r
56  *\r
57  */\r
58 public final class MessageDeserializerInitializer {\r
59 \r
60     private MessageDeserializerInitializer() {\r
61         throw new UnsupportedOperationException("Utility class shouldn't be instantiated");\r
62     }\r
63 \r
64     /**\r
65      * Registers message deserializers\r
66      * @param registry registry to be filled with deserializers\r
67      */\r
68     public static void registerMessageDeserializers(DeserializerRegistry registry) {\r
69         // register OF v1.0 message deserializers\r
70         SimpleDeserializerRegistryHelper helper =\r
71                 new SimpleDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry);\r
72         helper.registerDeserializer(0, null, HelloMessage.class, new OF10HelloMessageFactory());\r
73         helper.registerDeserializer(1, null, ErrorMessage.class, new OF10ErrorMessageFactory());\r
74         helper.registerDeserializer(2, null, EchoRequestMessage.class, new OF10EchoRequestMessageFactory());\r
75         helper.registerDeserializer(3, null, EchoOutput.class, new OF10EchoReplyMessageFactory());\r
76         helper.registerDeserializer(6, null, GetFeaturesOutput.class, new OF10FeaturesReplyMessageFactory());\r
77         helper.registerDeserializer(8, null, GetConfigOutput.class, new OF10GetConfigReplyMessageFactory());\r
78         helper.registerDeserializer(10, null, PacketInMessage.class, new OF10PacketInMessageFactory());\r
79         helper.registerDeserializer(11, null, FlowRemovedMessage.class, new OF10FlowRemovedMessageFactory());\r
80         helper.registerDeserializer(12, null, PortStatusMessage.class, new OF10PortStatusMessageFactory());\r
81         helper.registerDeserializer(17, null, MultipartReplyMessage.class, new OF10StatsReplyMessageFactory());\r
82         helper.registerDeserializer(19, null, BarrierOutput.class, new OF10BarrierReplyMessageFactory());\r
83         helper.registerDeserializer(21, null, GetQueueConfigOutput.class, new OF10QueueGetConfigReplyMessageFactory());\r
84         // register Of v1.3 message deserializers\r
85         helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry);\r
86         helper.registerDeserializer(0, null, HelloMessage.class, new HelloMessageFactory());\r
87         helper.registerDeserializer(1, null, ErrorMessage.class, new ErrorMessageFactory());\r
88         helper.registerDeserializer(2, null, EchoRequestMessage.class, new EchoRequestMessageFactory());\r
89         helper.registerDeserializer(3, null, EchoOutput.class, new EchoReplyMessageFactory());\r
90         helper.registerDeserializer(6, null, GetFeaturesOutput.class, new FeaturesReplyMessageFactory());\r
91         helper.registerDeserializer(8, null, GetConfigOutput.class, new GetConfigReplyMessageFactory());\r
92         helper.registerDeserializer(10, null, PacketInMessage.class, new PacketInMessageFactory());\r
93         helper.registerDeserializer(11, null, FlowRemovedMessage.class, new FlowRemovedMessageFactory());\r
94         helper.registerDeserializer(12, null, PortStatusMessage.class, new PortStatusMessageFactory());\r
95         helper.registerDeserializer(19, null, MultipartReplyMessage.class, new MultipartReplyMessageFactory());\r
96         helper.registerDeserializer(21, null, BarrierOutput.class, new BarrierReplyMessageFactory());\r
97         helper.registerDeserializer(23, null, GetQueueConfigOutput.class, new QueueGetConfigReplyMessageFactory());\r
98         helper.registerDeserializer(25, null, RoleRequestOutput.class, new RoleReplyMessageFactory());\r
99         helper.registerDeserializer(27, null, GetAsyncOutput.class, new GetAsyncReplyMessageFactory());\r
100     }\r
101 }\r