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.ExperimenterMessageFactory;
\r
12 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FeaturesReplyMessageFactory;
\r
13 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactory;
\r
16 * @author michal.polkorab
\r
25 * 5: FEATURES_REQUEST
\r
27 * 7: GET_CONFIG_REQUEST
\r
28 * 8: GET_CONFIG_REPLY
\r
38 * 18: MULTIPART_REQUEST
\r
39 * 19: MULTIPART_REPLY
\r
40 * 20: BARRIER_REQUEST
\r
42 * 22: QUEUE_GET_CONFIG_REQUEST
\r
43 * 23: QUEUE_GET_CONFIG_REPLY
\r
46 * 26: GET_ASYNC_REQUEST
\r
47 * 27: GET_ASYNC_REPLY
\r
52 public class DecoderTable {
\r
54 private static final short OF13 = OFVersionDetector.OF13_VERSION_ID;
\r
55 private Map<MessageTypeCodeKey, OFDeserializer<?>> table;
\r
56 private static DecoderTable instance;
\r
59 private DecoderTable() {
\r
64 * @return singleton instance
\r
66 public static DecoderTable getInstance() {
\r
67 if (instance == null) {
\r
68 synchronized (DecoderTable.class) {
\r
69 instance = new DecoderTable();
\r
77 * Decoder table provisioning
\r
79 public void init() {
\r
80 table = new HashMap<>();
\r
81 table.put(new MessageTypeCodeKey(OF13, (short) 0), HelloMessageFactory.getInstance());
\r
82 table.put(new MessageTypeCodeKey(OF13, (short) 2), EchoRequestMessageFactory.getInstance());
\r
83 table.put(new MessageTypeCodeKey(OF13, (short) 3), EchoReplyMessageFactory.getInstance());
\r
84 table.put(new MessageTypeCodeKey(OF13, (short) 4), ExperimenterMessageFactory.getInstance());
\r
85 table.put(new MessageTypeCodeKey(OF13, (short) 6), FeaturesReplyMessageFactory.getInstance());
\r
86 table.put(new MessageTypeCodeKey(OF13, (short) 21), BarrierReplyMessageFactory.getInstance());
\r
91 * @return decoder for given message types
\r
93 public OFDeserializer<?> getDecoder(MessageTypeCodeKey msgTypeKey) {
\r
94 return table.get(msgTypeKey);
\r