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; ...@@ -26,6 +26,7 @@ import org.onlab.packet.MplsLabel;
26 import org.onlab.packet.VlanId; 26 import org.onlab.packet.VlanId;
27 import org.onosproject.core.DefaultGroupId; 27 import org.onosproject.core.DefaultGroupId;
28 import org.onosproject.net.DeviceId; 28 import org.onosproject.net.DeviceId;
29 +import org.onosproject.net.Lambda;
29 import org.onosproject.net.PortNumber; 30 import org.onosproject.net.PortNumber;
30 import org.onosproject.net.flow.DefaultFlowEntry; 31 import org.onosproject.net.flow.DefaultFlowEntry;
31 import org.onosproject.net.flow.DefaultFlowRule; 32 import org.onosproject.net.flow.DefaultFlowRule;
...@@ -63,17 +64,24 @@ import org.projectfloodlight.openflow.protocol.match.MatchField; ...@@ -63,17 +64,24 @@ import org.projectfloodlight.openflow.protocol.match.MatchField;
63 import org.projectfloodlight.openflow.protocol.oxm.OFOxm; 64 import org.projectfloodlight.openflow.protocol.oxm.OFOxm;
64 import org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigidBasic; 65 import org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigidBasic;
65 import org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13; 66 import org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13;
67 +import org.projectfloodlight.openflow.types.CircuitSignalID;
66 import org.projectfloodlight.openflow.types.EthType; 68 import org.projectfloodlight.openflow.types.EthType;
67 import org.projectfloodlight.openflow.types.IPv4Address; 69 import org.projectfloodlight.openflow.types.IPv4Address;
68 import org.projectfloodlight.openflow.types.IPv6Address; 70 import org.projectfloodlight.openflow.types.IPv6Address;
69 import org.projectfloodlight.openflow.types.Masked; 71 import org.projectfloodlight.openflow.types.Masked;
70 import org.projectfloodlight.openflow.types.OFVlanVidMatch; 72 import org.projectfloodlight.openflow.types.OFVlanVidMatch;
71 import org.projectfloodlight.openflow.types.U32; 73 import org.projectfloodlight.openflow.types.U32;
74 +import org.projectfloodlight.openflow.types.U8;
72 import org.projectfloodlight.openflow.types.VlanPcp; 75 import org.projectfloodlight.openflow.types.VlanPcp;
73 import org.slf4j.Logger; 76 import org.slf4j.Logger;
74 77
75 import java.util.List; 78 import java.util.List;
76 79
80 +import static org.onosproject.net.flow.criteria.Criteria.matchLambda;
81 +import static org.onosproject.net.flow.criteria.Criteria.matchOchSignalType;
82 +import static org.onosproject.provider.of.flow.impl.FlowModBuilderHelper.convertChannelSpacing;
83 +import static org.onosproject.provider.of.flow.impl.FlowModBuilderHelper.convertGridType;
84 +import static org.onosproject.provider.of.flow.impl.FlowModBuilderHelper.convertOchSignalType;
77 import static org.slf4j.LoggerFactory.getLogger; 85 import static org.slf4j.LoggerFactory.getLogger;
78 86
79 public class FlowEntryBuilder { 87 public class FlowEntryBuilder {
...@@ -633,11 +641,15 @@ public class FlowEntryBuilder { ...@@ -633,11 +641,15 @@ public class FlowEntryBuilder {
633 .getValue()); 641 .getValue());
634 break; 642 break;
635 case OCH_SIGID: 643 case OCH_SIGID:
636 - builder.matchLambda(match.get(MatchField.OCH_SIGID).getChannelNumber()); 644 + CircuitSignalID sigId = match.get(MatchField.OCH_SIGID);
645 + builder.add(matchLambda(Lambda.ochSignal(
646 + convertGridType(sigId.getGridType()), convertChannelSpacing(sigId.getChannelSpacing()),
647 + sigId.getChannelNumber(), sigId.getChannelSpacing())
648 + ));
637 break; 649 break;
638 case OCH_SIGTYPE: 650 case OCH_SIGTYPE:
639 - builder.matchOpticalSignalType(match.get(MatchField 651 + U8 sigType = match.get(MatchField.OCH_SIGTYPE);
640 - .OCH_SIGTYPE).getValue()); 652 + builder.add(matchOchSignalType(convertOchSignalType((byte) sigType.getValue())));
641 break; 653 break;
642 case ARP_OP: 654 case ARP_OP:
643 case ARP_SHA: 655 case ARP_SHA:
......
...@@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory; ...@@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory;
24 /** 24 /**
25 * Collection of helper methods to convert protocol agnostic models to values used in OpenFlow spec. 25 * Collection of helper methods to convert protocol agnostic models to values used in OpenFlow spec.
26 */ 26 */
27 +// TODO: Rename to a better name
27 final class FlowModBuilderHelper { 28 final class FlowModBuilderHelper {
28 29
29 private static final Logger log = LoggerFactory.getLogger(FlowModBuilderHelper.class); 30 private static final Logger log = LoggerFactory.getLogger(FlowModBuilderHelper.class);
...@@ -58,6 +59,28 @@ final class FlowModBuilderHelper { ...@@ -58,6 +59,28 @@ final class FlowModBuilderHelper {
58 } 59 }
59 60
60 /** 61 /**
62 + * Converts a byte value for grid type
63 + * defined in ONF "Optical Transport Protocol Extensions Version 1.0"
64 + * to the corresponding {@link GridType} instance.
65 + *
66 + * @param type byte value as grid type defined the spec
67 + * @return the corresponding GridType instance
68 + */
69 + static GridType convertGridType(byte type) {
70 + switch (type) {
71 + case 1:
72 + return GridType.DWDM;
73 + case 2:
74 + return GridType.CWDM;
75 + case 3:
76 + return GridType.FLEX;
77 + default:
78 + log.info("The value {} for grid type is not supported");
79 + return null;
80 + }
81 + }
82 +
83 + /**
61 * Converts a {@link ChannelSpacing} to the corresponding byte value defined in 84 * Converts a {@link ChannelSpacing} to the corresponding byte value defined in
62 * ONF "Optical Transport Protocol Extensions Version 1.0". 85 * ONF "Optical Transport Protocol Extensions Version 1.0".
63 * 86 *
...@@ -90,6 +113,32 @@ final class FlowModBuilderHelper { ...@@ -90,6 +113,32 @@ final class FlowModBuilderHelper {
90 } 113 }
91 114
92 /** 115 /**
116 + * Converts a byte value for channel spacing
117 + * defined in ONF "Optical Transport Protocol Extensions Version 1.0"
118 + * to the corresponding {@link ChannelSpacing} instance.
119 + *
120 + * @param spacing byte value as channel spacing defined the spec
121 + * @return the corresponding ChannelSpacing instance
122 + */
123 + static ChannelSpacing convertChannelSpacing(byte spacing) {
124 + switch (spacing) {
125 + case 1:
126 + return ChannelSpacing.CHL_100GHZ;
127 + case 2:
128 + return ChannelSpacing.CHL_50GHZ;
129 + case 3:
130 + return ChannelSpacing.CHL_25GHZ;
131 + case 4:
132 + return ChannelSpacing.CHL_12P5GHZ;
133 + case 5:
134 + return ChannelSpacing.CHL_6P25GHZ;
135 + default:
136 + log.info("The value {} for channel spacing is not supported");
137 + return null;
138 + }
139 + }
140 +
141 + /**
93 * Converts a {@link OchSignalType} to the corresponding byte value. 142 * Converts a {@link OchSignalType} to the corresponding byte value.
94 * 143 *
95 * @param signalType optical signal type 144 * @param signalType optical signal type
...@@ -106,4 +155,24 @@ final class FlowModBuilderHelper { ...@@ -106,4 +155,24 @@ final class FlowModBuilderHelper {
106 return (byte) 0; 155 return (byte) 0;
107 } 156 }
108 } 157 }
158 +
159 + /**
160 + * Converts a byte value for Och signal type
161 + * defined in ONF "Optical Transport Protocol Extensions Version 1.0"
162 + * to the corresponding {@link OchSignalType} instance.
163 + *
164 + * @param signalType byte value as Och singal type defined the spec
165 + * @return the corresponding OchSignalType instance
166 + */
167 + static OchSignalType convertOchSignalType(byte signalType) {
168 + switch (signalType) {
169 + case 1:
170 + return OchSignalType.FIXED_GRID;
171 + case 2:
172 + return OchSignalType.FLEX_GRID;
173 + default:
174 + log.info("The value {} for Och signal type is not supported");
175 + return null;
176 + }
177 + }
109 } 178 }
......