2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowjava.protocol.impl.deserialization;
11 import java.util.HashMap;
14 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.BarrierReplyMessageFactory;
15 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoReplyMessageFactory;
16 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoRequestMessageFactory;
17 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.ErrorMessageFactory;
18 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.ExperimenterMessageFactory;
19 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FeaturesReplyMessageFactory;
20 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FlowRemovedMessageFactory;
21 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetAsyncReplyMessageFactory;
22 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetConfigReplyMessageFactory;
23 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactory;
24 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory;
25 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10ErrorMessageFactory;
26 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FeaturesReplyMessageFactory;
27 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FlowRemovedMessageFactory;
28 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10HelloMessageFactory;
29 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PacketInMessageFactory;
30 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PortStatusMessageFactory;
31 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10QueueGetConfigReplyMessageFactory;
32 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory;
33 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10VendorMessageFactory;
34 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PacketInMessageFactory;
35 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PortStatusMessageFactory;
36 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.QueueGetConfigReplyMessageFactory;
37 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.RoleReplyMessageFactory;
38 import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
41 * Stores and provides correct decoders for received messages
42 * @author michal.polkorab
53 * 7: GET_CONFIG_REQUEST
64 * 18: MULTIPART_REQUEST
68 * 22: QUEUE_GET_CONFIG_REQUEST
69 * 23: QUEUE_GET_CONFIG_REPLY
72 * 26: GET_ASYNC_REQUEST
78 public class DecoderTable {
80 private static final short OF10 = EncodeConstants.OF10_VERSION_ID;
81 private static final short OF13 = EncodeConstants.OF13_VERSION_ID;
82 private Map<MessageTypeCodeKey, OFDeserializer<?>> table;
83 private static DecoderTable instance;
86 private DecoderTable() {
91 * @return singleton instance
93 public static synchronized DecoderTable getInstance() {
94 if (instance == null) {
95 instance = new DecoderTable();
102 * Decoder table provisioning
105 table = new HashMap<>();
106 table.put(new MessageTypeCodeKey(OF10, (short) 0), OF10HelloMessageFactory.getInstance());
107 table.put(new MessageTypeCodeKey(OF10, (short) 1), OF10ErrorMessageFactory.getInstance());
108 table.put(new MessageTypeCodeKey(OF10, (short) 2), EchoRequestMessageFactory.getInstance());
109 table.put(new MessageTypeCodeKey(OF10, (short) 3), EchoReplyMessageFactory.getInstance());
110 table.put(new MessageTypeCodeKey(OF10, (short) 4), OF10VendorMessageFactory.getInstance());
111 table.put(new MessageTypeCodeKey(OF10, (short) 6), OF10FeaturesReplyMessageFactory.getInstance());
112 table.put(new MessageTypeCodeKey(OF10, (short) 8), GetConfigReplyMessageFactory.getInstance());
113 table.put(new MessageTypeCodeKey(OF10, (short) 10), OF10PacketInMessageFactory.getInstance());
114 table.put(new MessageTypeCodeKey(OF10, (short) 11), OF10FlowRemovedMessageFactory.getInstance());
115 table.put(new MessageTypeCodeKey(OF10, (short) 12), OF10PortStatusMessageFactory.getInstance());
116 table.put(new MessageTypeCodeKey(OF10, (short) 17), OF10StatsReplyMessageFactory.getInstance());
117 table.put(new MessageTypeCodeKey(OF10, (short) 19), BarrierReplyMessageFactory.getInstance());
118 table.put(new MessageTypeCodeKey(OF10, (short) 21), OF10QueueGetConfigReplyMessageFactory.getInstance());
119 table.put(new MessageTypeCodeKey(OF13, (short) 0), HelloMessageFactory.getInstance());
120 table.put(new MessageTypeCodeKey(OF13, (short) 1), ErrorMessageFactory.getInstance());
121 table.put(new MessageTypeCodeKey(OF13, (short) 2), EchoRequestMessageFactory.getInstance());
122 table.put(new MessageTypeCodeKey(OF13, (short) 3), EchoReplyMessageFactory.getInstance());
123 table.put(new MessageTypeCodeKey(OF13, (short) 4), ExperimenterMessageFactory.getInstance());
124 table.put(new MessageTypeCodeKey(OF13, (short) 6), FeaturesReplyMessageFactory.getInstance());
125 table.put(new MessageTypeCodeKey(OF13, (short) 8), GetConfigReplyMessageFactory.getInstance());
126 table.put(new MessageTypeCodeKey(OF13, (short) 10), PacketInMessageFactory.getInstance());
127 table.put(new MessageTypeCodeKey(OF13, (short) 11), FlowRemovedMessageFactory.getInstance());
128 table.put(new MessageTypeCodeKey(OF13, (short) 12), PortStatusMessageFactory.getInstance());
129 table.put(new MessageTypeCodeKey(OF13, (short) 19), MultipartReplyMessageFactory.getInstance());
130 table.put(new MessageTypeCodeKey(OF13, (short) 21), BarrierReplyMessageFactory.getInstance());
131 table.put(new MessageTypeCodeKey(OF13, (short) 23), QueueGetConfigReplyMessageFactory.getInstance());
132 table.put(new MessageTypeCodeKey(OF13, (short) 25), RoleReplyMessageFactory.getInstance());
133 table.put(new MessageTypeCodeKey(OF13, (short) 27), GetAsyncReplyMessageFactory.getInstance());
138 * @return decoder for given message types
140 public OFDeserializer<?> getDecoder(MessageTypeCodeKey msgTypeKey) {
141 return table.get(msgTypeKey);