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
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.nx.resubmit.action.rev130731.NxResubmitAction;
\r
22 * @author michal.polkorab
\r
25 public class NxResubmitActionRegistrator implements AutoCloseable {
\r
27 /** Nicira experimenter ID */
\r
28 public static final Long NICIRA_EXPERIMENTER_ID = 0x00002320L;
\r
29 private List<SwitchConnectionProvider> providers;
\r
32 * @param providers providers that shall be filled with serializers
\r
34 public void registerNxResubmitSerializer(List<SwitchConnectionProvider> providers) {
\r
35 if (providers != null) {
\r
36 this.providers = providers;
\r
37 for (SwitchConnectionProvider provider : providers) {
\r
38 provider.registerActionSerializer(new ExperimenterActionSerializerKey(
\r
39 EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID, NxResubmitAction.class),
\r
40 new NxActionResubmitSerializer());
\r
46 * @param providers providers that shall be filled with deserializers
\r
48 public void registerNxResubmitDeserializer(List<SwitchConnectionProvider> providers) {
\r
49 if (providers != null) {
\r
50 this.providers = providers;
\r
51 for (SwitchConnectionProvider provider : providers) {
\r
52 /* In case of handling multiple actions, instructions and other structures which
\r
53 * are differentiated by vendor / experimenter subtype, vendor has to
\r
54 * switch / choose between these subtypes.
\r
56 * This has to be done in this way because of experimenter headers, which
\r
57 * provide only vendor / experimenter ID. Subtype position may be different
\r
58 * for different vendors (or not present at all) - that's why vendor has to
\r
59 * handle it in his own implementations.
\r
61 provider.registerActionDeserializer(new ExperimenterActionDeserializerKey(
\r
62 EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID),
\r
63 new NxActionResubmitDeserializer());
\r
69 public void close() throws Exception {
\r
70 for (SwitchConnectionProvider provider : providers) {
\r
71 // unregister serializer
\r
72 provider.unregisterSerializer(new ExperimenterActionSerializerKey(
\r
73 EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID, NxResubmitAction.class));
\r
74 // unregister deserializer
\r
75 provider.unregisterDeserializer(new ExperimenterActionDeserializerKey(
\r
76 EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID));
\r