Sho SHIMIZU
Committed by Gerrit Code Review

Fix cast error when building flow entries containging optical properties

Change-Id: I6e963143a22fcd57e2f1388941f7cb4fc51e52f6
......@@ -26,6 +26,7 @@ import org.onlab.packet.MplsLabel;
import org.onlab.packet.VlanId;
import org.onosproject.core.DefaultGroupId;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Lambda;
import org.onosproject.net.PortNumber;
import org.onosproject.net.flow.DefaultFlowEntry;
import org.onosproject.net.flow.DefaultFlowRule;
......@@ -63,17 +64,24 @@ import org.projectfloodlight.openflow.protocol.match.MatchField;
import org.projectfloodlight.openflow.protocol.oxm.OFOxm;
import org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigidBasic;
import org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13;
import org.projectfloodlight.openflow.types.CircuitSignalID;
import org.projectfloodlight.openflow.types.EthType;
import org.projectfloodlight.openflow.types.IPv4Address;
import org.projectfloodlight.openflow.types.IPv6Address;
import org.projectfloodlight.openflow.types.Masked;
import org.projectfloodlight.openflow.types.OFVlanVidMatch;
import org.projectfloodlight.openflow.types.U32;
import org.projectfloodlight.openflow.types.U8;
import org.projectfloodlight.openflow.types.VlanPcp;
import org.slf4j.Logger;
import java.util.List;
import static org.onosproject.net.flow.criteria.Criteria.matchLambda;
import static org.onosproject.net.flow.criteria.Criteria.matchOchSignalType;
import static org.onosproject.provider.of.flow.impl.FlowModBuilderHelper.convertChannelSpacing;
import static org.onosproject.provider.of.flow.impl.FlowModBuilderHelper.convertGridType;
import static org.onosproject.provider.of.flow.impl.FlowModBuilderHelper.convertOchSignalType;
import static org.slf4j.LoggerFactory.getLogger;
public class FlowEntryBuilder {
......@@ -633,11 +641,15 @@ public class FlowEntryBuilder {
.getValue());
break;
case OCH_SIGID:
builder.matchLambda(match.get(MatchField.OCH_SIGID).getChannelNumber());
CircuitSignalID sigId = match.get(MatchField.OCH_SIGID);
builder.add(matchLambda(Lambda.ochSignal(
convertGridType(sigId.getGridType()), convertChannelSpacing(sigId.getChannelSpacing()),
sigId.getChannelNumber(), sigId.getChannelSpacing())
));
break;
case OCH_SIGTYPE:
builder.matchOpticalSignalType(match.get(MatchField
.OCH_SIGTYPE).getValue());
U8 sigType = match.get(MatchField.OCH_SIGTYPE);
builder.add(matchOchSignalType(convertOchSignalType((byte) sigType.getValue())));
break;
case ARP_OP:
case ARP_SHA:
......
......@@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory;
/**
* Collection of helper methods to convert protocol agnostic models to values used in OpenFlow spec.
*/
// TODO: Rename to a better name
final class FlowModBuilderHelper {
private static final Logger log = LoggerFactory.getLogger(FlowModBuilderHelper.class);
......@@ -58,6 +59,28 @@ final class FlowModBuilderHelper {
}
/**
* Converts a byte value for grid type
* defined in ONF "Optical Transport Protocol Extensions Version 1.0"
* to the corresponding {@link GridType} instance.
*
* @param type byte value as grid type defined the spec
* @return the corresponding GridType instance
*/
static GridType convertGridType(byte type) {
switch (type) {
case 1:
return GridType.DWDM;
case 2:
return GridType.CWDM;
case 3:
return GridType.FLEX;
default:
log.info("The value {} for grid type is not supported");
return null;
}
}
/**
* Converts a {@link ChannelSpacing} to the corresponding byte value defined in
* ONF "Optical Transport Protocol Extensions Version 1.0".
*
......@@ -90,6 +113,32 @@ final class FlowModBuilderHelper {
}
/**
* Converts a byte value for channel spacing
* defined in ONF "Optical Transport Protocol Extensions Version 1.0"
* to the corresponding {@link ChannelSpacing} instance.
*
* @param spacing byte value as channel spacing defined the spec
* @return the corresponding ChannelSpacing instance
*/
static ChannelSpacing convertChannelSpacing(byte spacing) {
switch (spacing) {
case 1:
return ChannelSpacing.CHL_100GHZ;
case 2:
return ChannelSpacing.CHL_50GHZ;
case 3:
return ChannelSpacing.CHL_25GHZ;
case 4:
return ChannelSpacing.CHL_12P5GHZ;
case 5:
return ChannelSpacing.CHL_6P25GHZ;
default:
log.info("The value {} for channel spacing is not supported");
return null;
}
}
/**
* Converts a {@link OchSignalType} to the corresponding byte value.
*
* @param signalType optical signal type
......@@ -106,4 +155,24 @@ final class FlowModBuilderHelper {
return (byte) 0;
}
}
/**
* Converts a byte value for Och signal type
* defined in ONF "Optical Transport Protocol Extensions Version 1.0"
* to the corresponding {@link OchSignalType} instance.
*
* @param signalType byte value as Och singal type defined the spec
* @return the corresponding OchSignalType instance
*/
static OchSignalType convertOchSignalType(byte signalType) {
switch (signalType) {
case 1:
return OchSignalType.FIXED_GRID;
case 2:
return OchSignalType.FLEX_GRID;
default:
log.info("The value {} for Och signal type is not supported");
return null;
}
}
}
......