2 * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.
\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
9 package org.opendaylight.openflowjava.protocol.nx;
\r
11 import java.util.List;
\r
13 import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey;
\r
14 import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey;
\r
15 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
\r
16 import org.opendaylight.openflowjava.protocol.nx.deserialization.NxActionResubmitDeserializer;
\r
17 import org.opendaylight.openflowjava.protocol.nx.serialization.NxActionResubmitSerializer;
\r
18 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
\r
21 * @author michal.polkorab
\r
24 public class NxResubmitActionRegistrator implements AutoCloseable {
\r
26 /** Nicira experimenter ID */
\r
27 public static final Long NICIRA_EXPERIMENTER_ID = 0x00002320L;
\r
28 private List<SwitchConnectionProvider> providers;
\r
31 * @param providers providers that shall be filled with serializers
\r
33 public void registerNxResubmitSerializer(List<SwitchConnectionProvider> providers) {
\r
34 if (providers != null) {
\r
35 this.providers = providers;
\r
36 for (SwitchConnectionProvider provider : providers) {
\r
37 /* In case of handling multiple actions, instructions and other structures which
\r
38 * are differentiated by vendor / experimenter subtype, vendor has to
\r
39 * switch / choose between these subtypes.
\r
41 * This has to be done in this way because of experimenter headers, which
\r
42 * provide only vendor / experimenter ID. Subtype position may be different
\r
43 * for different vendors (or not present at all) - that's why vendor has to
\r
44 * handle it in his own implementations.
\r
46 provider.registerActionSerializer(new ExperimenterActionSerializerKey(
\r
47 EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID),
\r
48 new NxActionResubmitSerializer());
\r
54 * @param providers providers that shall be filled with deserializers
\r
56 public void registerNxResubmitDeserializer(List<SwitchConnectionProvider> providers) {
\r
57 if (providers != null) {
\r
58 this.providers = providers;
\r
59 for (SwitchConnectionProvider provider : providers) {
\r
60 /* In case of handling multiple actions, instructions and other structures which
\r
61 * are differentiated by vendor / experimenter subtype, vendor has to
\r
62 * switch / choose between these subtypes.
\r
64 * This has to be done in this way because of experimenter headers, which
\r
65 * provide only vendor / experimenter ID. Subtype position may be different
\r
66 * for different vendors (or not present at all) - that's why vendor has to
\r
67 * handle it in his own implementations.
\r
69 provider.registerActionDeserializer(new ExperimenterActionDeserializerKey(
\r
70 EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID),
\r
71 new NxActionResubmitDeserializer());
\r
77 public void close() throws Exception {
\r
78 for (SwitchConnectionProvider provider : providers) {
\r
79 // unregister serializer
\r
80 provider.unregisterSerializer(new ExperimenterActionSerializerKey(
\r
81 EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID));
\r
82 // unregister deserializer
\r
83 provider.unregisterDeserializer(new ExperimenterActionDeserializerKey(
\r
84 EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID));
\r