package org.opendaylight.openflowplugin.impl.translator;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
public class FlowRemovedTranslator implements MessageTranslator<FlowRemoved, org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved> {
@Override
- public org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved translate(FlowRemoved input, DeviceContext deviceContext, Object connectionDistinguisher) {
+ public org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved translate(FlowRemoved input, DeviceState deviceState, Object connectionDistinguisher) {
FlowRemovedBuilder flowRemovedBld = new FlowRemovedBuilder()
- .setMatch(translateMatch(input, deviceContext).build())
+ .setMatch(translateMatch(input, deviceState).build())
.setCookie(new FlowCookie(input.getCookie()))
- .setNode(new NodeRef(deviceContext.getDeviceState().getNodeInstanceIdentifier()))
+ .setNode(new NodeRef(deviceState.getNodeInstanceIdentifier()))
.setPriority(input.getPriority())
- .setTableId(input.getTableId().getValue().shortValue());
+ .setTableId(translateTableId(input));
return flowRemovedBld.build();
}
- protected MatchBuilder translateMatch(FlowRemoved flowRemoved, DeviceContext deviceContext) {
+ protected MatchBuilder translateMatch(FlowRemoved flowRemoved, DeviceState deviceState) {
return MatchConvertorImpl.fromOFMatchToSALMatch(flowRemoved.getMatch(),
- deviceContext.getDeviceState().getFeatures().getDatapathId(), OpenflowVersion.OF13);
+ deviceState.getFeatures().getDatapathId(), OpenflowVersion.OF13);
+ }
+
+ /**
+ * Translate the table ID in the FLOW_REMOVED message to SAL table ID.
+ *
+ * @param flowRemoved FLOW_REMOVED message.
+ * @return SAL table ID.
+ */
+ protected Short translateTableId(FlowRemoved flowRemoved) {
+ return flowRemoved.getTableId().getValue().shortValue();
}
}