1 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
\r
2 package org.opendaylight.openflowjava.protocol.impl.deserialization;
\r
4 import java.util.HashMap;
\r
5 import java.util.Map;
\r
7 import org.opendaylight.openflowjava.protocol.impl.core.OFVersionDetector;
\r
8 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.BarrierReplyMessageFactory;
\r
9 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoReplyMessageFactory;
\r
10 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoRequestMessageFactory;
\r
11 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.ErrorMessageFactory;
\r
12 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.ExperimenterMessageFactory;
\r
13 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FeaturesReplyMessageFactory;
\r
14 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FlowRemovedMessageFactory;
\r
15 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetAsyncReplyMessageFactory;
\r
16 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetConfigReplyMessageFactory;
\r
17 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactory;
\r
18 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory;
\r
19 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10BarrierReplyMessageFactory;
\r
20 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10EchoReplyMessageFactory;
\r
21 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10EchoRequestMessageFactory;
\r
22 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10ErrorMessageFactory;
\r
23 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FeaturesReplyMessageFactory;
\r
24 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FlowRemovedMessageFactory;
\r
25 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10GetConfigReplyMessageFactory;
\r
26 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10HelloMessageFactory;
\r
27 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PacketInMessageFactory;
\r
28 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PortStatusMessageFactory;
\r
29 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10QueueGetConfigReplyMessageFactory;
\r
30 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory;
\r
31 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10VendorMessageFactory;
\r
32 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PacketInMessageFactory;
\r
33 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PortStatusMessageFactory;
\r
34 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.QueueGetConfigReplyMessageFactory;
\r
35 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.RoleReplyMessageFactory;
\r
38 * @author michal.polkorab
\r
47 * 5: FEATURES_REQUEST
\r
49 * 7: GET_CONFIG_REQUEST
\r
50 * 8: GET_CONFIG_REPLY
\r
60 * 18: MULTIPART_REQUEST
\r
61 * 19: MULTIPART_REPLY
\r
62 * 20: BARRIER_REQUEST
\r
64 * 22: QUEUE_GET_CONFIG_REQUEST
\r
65 * 23: QUEUE_GET_CONFIG_REPLY
\r
68 * 26: GET_ASYNC_REQUEST
\r
69 * 27: GET_ASYNC_REPLY
\r
74 public class DecoderTable {
\r
76 private static final short OF10 = OFVersionDetector.OF10_VERSION_ID;
\r
77 private static final short OF13 = OFVersionDetector.OF13_VERSION_ID;
\r
78 private Map<MessageTypeCodeKey, OFDeserializer<?>> table;
\r
79 private static DecoderTable instance;
\r
82 private DecoderTable() {
\r
87 * @return singleton instance
\r
89 public static synchronized DecoderTable getInstance() {
\r
90 if (instance == null) {
\r
91 instance = new DecoderTable();
\r
98 * Decoder table provisioning
\r
100 public void init() {
\r
101 table = new HashMap<>();
\r
102 table.put(new MessageTypeCodeKey(OF10, (short) 0), OF10HelloMessageFactory.getInstance());
\r
103 table.put(new MessageTypeCodeKey(OF10, (short) 1), OF10ErrorMessageFactory.getInstance());
\r
104 table.put(new MessageTypeCodeKey(OF10, (short) 2), OF10EchoRequestMessageFactory.getInstance());
\r
105 table.put(new MessageTypeCodeKey(OF10, (short) 3), OF10EchoReplyMessageFactory.getInstance());
\r
106 table.put(new MessageTypeCodeKey(OF10, (short) 4), OF10VendorMessageFactory.getInstance());
\r
107 table.put(new MessageTypeCodeKey(OF10, (short) 6), OF10FeaturesReplyMessageFactory.getInstance());
\r
108 table.put(new MessageTypeCodeKey(OF10, (short) 8), OF10GetConfigReplyMessageFactory.getInstance());
\r
109 table.put(new MessageTypeCodeKey(OF10, (short) 10), OF10PacketInMessageFactory.getInstance());
\r
110 table.put(new MessageTypeCodeKey(OF10, (short) 11), OF10FlowRemovedMessageFactory.getInstance());
\r
111 table.put(new MessageTypeCodeKey(OF10, (short) 12), OF10PortStatusMessageFactory.getInstance());
\r
112 table.put(new MessageTypeCodeKey(OF10, (short) 16), OF10StatsReplyMessageFactory.getInstance());
\r
113 table.put(new MessageTypeCodeKey(OF10, (short) 18), OF10BarrierReplyMessageFactory.getInstance());
\r
114 table.put(new MessageTypeCodeKey(OF10, (short) 20), OF10QueueGetConfigReplyMessageFactory.getInstance());
\r
115 table.put(new MessageTypeCodeKey(OF13, (short) 0), HelloMessageFactory.getInstance());
\r
116 table.put(new MessageTypeCodeKey(OF13, (short) 1), ErrorMessageFactory.getInstance());
\r
117 table.put(new MessageTypeCodeKey(OF13, (short) 2), EchoRequestMessageFactory.getInstance());
\r
118 table.put(new MessageTypeCodeKey(OF13, (short) 3), EchoReplyMessageFactory.getInstance());
\r
119 table.put(new MessageTypeCodeKey(OF13, (short) 4), ExperimenterMessageFactory.getInstance());
\r
120 table.put(new MessageTypeCodeKey(OF13, (short) 6), FeaturesReplyMessageFactory.getInstance());
\r
121 table.put(new MessageTypeCodeKey(OF13, (short) 8), GetConfigReplyMessageFactory.getInstance());
\r
122 table.put(new MessageTypeCodeKey(OF13, (short) 10), PacketInMessageFactory.getInstance());
\r
123 table.put(new MessageTypeCodeKey(OF13, (short) 11), FlowRemovedMessageFactory.getInstance());
\r
124 table.put(new MessageTypeCodeKey(OF13, (short) 12), PortStatusMessageFactory.getInstance());
\r
125 table.put(new MessageTypeCodeKey(OF13, (short) 19), MultipartReplyMessageFactory.getInstance());
\r
126 table.put(new MessageTypeCodeKey(OF13, (short) 21), BarrierReplyMessageFactory.getInstance());
\r
127 table.put(new MessageTypeCodeKey(OF13, (short) 23), QueueGetConfigReplyMessageFactory.getInstance());
\r
128 table.put(new MessageTypeCodeKey(OF13, (short) 25), RoleReplyMessageFactory.getInstance());
\r
129 table.put(new MessageTypeCodeKey(OF13, (short) 27), GetAsyncReplyMessageFactory.getInstance());
\r
133 * @param msgTypeKey
\r
134 * @return decoder for given message types
\r
136 public OFDeserializer<?> getDecoder(MessageTypeCodeKey msgTypeKey) {
\r
137 return table.get(msgTypeKey);
\r