Updated the Flow Mod builders (FlowModBuilder, FlowModBuilderVer10,
and FlowModBuilderVer13) to use Ip4Address and Ip4Prefix instead of the generic IpAddress and IpPrefix when handling IPv4 source and destination. Change-Id: If35d735efe4cf557c79dc04eccf38f6a909e4506
Showing
3 changed files
with
27 additions
and
18 deletions
... | @@ -30,8 +30,8 @@ import org.onlab.onos.net.flow.criteria.Criteria.TcpPortCriterion; | ... | @@ -30,8 +30,8 @@ import org.onlab.onos.net.flow.criteria.Criteria.TcpPortCriterion; |
30 | import org.onlab.onos.net.flow.criteria.Criteria.VlanIdCriterion; | 30 | import org.onlab.onos.net.flow.criteria.Criteria.VlanIdCriterion; |
31 | import org.onlab.onos.net.flow.criteria.Criteria.VlanPcpCriterion; | 31 | import org.onlab.onos.net.flow.criteria.Criteria.VlanPcpCriterion; |
32 | import org.onlab.onos.net.flow.criteria.Criterion; | 32 | import org.onlab.onos.net.flow.criteria.Criterion; |
33 | -import org.onlab.packet.IpAddress; | 33 | +import org.onlab.packet.Ip4Address; |
34 | -import org.onlab.packet.IpPrefix; | 34 | +import org.onlab.packet.Ip4Prefix; |
35 | import org.projectfloodlight.openflow.protocol.OFFactory; | 35 | import org.projectfloodlight.openflow.protocol.OFFactory; |
36 | import org.projectfloodlight.openflow.protocol.OFFlowAdd; | 36 | import org.projectfloodlight.openflow.protocol.OFFlowAdd; |
37 | import org.projectfloodlight.openflow.protocol.OFFlowDelete; | 37 | import org.projectfloodlight.openflow.protocol.OFFlowDelete; |
... | @@ -124,6 +124,7 @@ public abstract class FlowModBuilder { | ... | @@ -124,6 +124,7 @@ public abstract class FlowModBuilder { |
124 | Match.Builder mBuilder = factory.buildMatch(); | 124 | Match.Builder mBuilder = factory.buildMatch(); |
125 | EthCriterion eth; | 125 | EthCriterion eth; |
126 | IPCriterion ip; | 126 | IPCriterion ip; |
127 | + Ip4Prefix ip4Prefix; | ||
127 | TcpPortCriterion tp; | 128 | TcpPortCriterion tp; |
128 | for (Criterion c : selector.criteria()) { | 129 | for (Criterion c : selector.criteria()) { |
129 | switch (c.type()) { | 130 | switch (c.type()) { |
... | @@ -145,32 +146,32 @@ public abstract class FlowModBuilder { | ... | @@ -145,32 +146,32 @@ public abstract class FlowModBuilder { |
145 | break; | 146 | break; |
146 | case IPV4_DST: | 147 | case IPV4_DST: |
147 | ip = (IPCriterion) c; | 148 | ip = (IPCriterion) c; |
148 | - if (ip.ip().prefixLength() != IpPrefix.MAX_INET_MASK_LENGTH) { | 149 | + ip4Prefix = ip.ip().getIp4Prefix(); |
149 | - IpAddress maskAddr = | 150 | + if (ip4Prefix.prefixLength() != Ip4Prefix.MAX_MASK_LENGTH) { |
150 | - IpAddress.makeMaskPrefix(ip.ip().address().version(), | 151 | + Ip4Address maskAddr = |
151 | - ip.ip().prefixLength()); | 152 | + Ip4Address.makeMaskPrefix(ip4Prefix.prefixLength()); |
152 | Masked<IPv4Address> maskedIp = | 153 | Masked<IPv4Address> maskedIp = |
153 | - Masked.of(IPv4Address.of(ip.ip().address().toInt()), | 154 | + Masked.of(IPv4Address.of(ip4Prefix.address().toInt()), |
154 | IPv4Address.of(maskAddr.toInt())); | 155 | IPv4Address.of(maskAddr.toInt())); |
155 | mBuilder.setMasked(MatchField.IPV4_DST, maskedIp); | 156 | mBuilder.setMasked(MatchField.IPV4_DST, maskedIp); |
156 | } else { | 157 | } else { |
157 | mBuilder.setExact(MatchField.IPV4_DST, | 158 | mBuilder.setExact(MatchField.IPV4_DST, |
158 | - IPv4Address.of(ip.ip().address().toInt())); | 159 | + IPv4Address.of(ip4Prefix.address().toInt())); |
159 | } | 160 | } |
160 | break; | 161 | break; |
161 | case IPV4_SRC: | 162 | case IPV4_SRC: |
162 | ip = (IPCriterion) c; | 163 | ip = (IPCriterion) c; |
163 | - if (ip.ip().prefixLength() != IpPrefix.MAX_INET_MASK_LENGTH) { | 164 | + ip4Prefix = ip.ip().getIp4Prefix(); |
164 | - IpAddress maskAddr = | 165 | + if (ip4Prefix.prefixLength() != Ip4Prefix.MAX_MASK_LENGTH) { |
165 | - IpAddress.makeMaskPrefix(ip.ip().address().version(), | 166 | + Ip4Address maskAddr = |
166 | - ip.ip().prefixLength()); | 167 | + Ip4Address.makeMaskPrefix(ip4Prefix.prefixLength()); |
167 | Masked<IPv4Address> maskedIp = | 168 | Masked<IPv4Address> maskedIp = |
168 | - Masked.of(IPv4Address.of(ip.ip().address().toInt()), | 169 | + Masked.of(IPv4Address.of(ip4Prefix.address().toInt()), |
169 | IPv4Address.of(maskAddr.toInt())); | 170 | IPv4Address.of(maskAddr.toInt())); |
170 | mBuilder.setMasked(MatchField.IPV4_SRC, maskedIp); | 171 | mBuilder.setMasked(MatchField.IPV4_SRC, maskedIp); |
171 | } else { | 172 | } else { |
172 | mBuilder.setExact(MatchField.IPV4_SRC, | 173 | mBuilder.setExact(MatchField.IPV4_SRC, |
173 | - IPv4Address.of(ip.ip().address().toInt())); | 174 | + IPv4Address.of(ip4Prefix.address().toInt())); |
174 | } | 175 | } |
175 | break; | 176 | break; |
176 | case IP_PROTO: | 177 | case IP_PROTO: | ... | ... |
... | @@ -29,6 +29,7 @@ import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModVlanIdI | ... | @@ -29,6 +29,7 @@ import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModVlanIdI |
29 | import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction; | 29 | import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction; |
30 | import org.onlab.onos.net.flow.instructions.L3ModificationInstruction; | 30 | import org.onlab.onos.net.flow.instructions.L3ModificationInstruction; |
31 | import org.onlab.onos.net.flow.instructions.L3ModificationInstruction.ModIPInstruction; | 31 | import org.onlab.onos.net.flow.instructions.L3ModificationInstruction.ModIPInstruction; |
32 | +import org.onlab.packet.Ip4Address; | ||
32 | import org.projectfloodlight.openflow.protocol.OFFactory; | 33 | import org.projectfloodlight.openflow.protocol.OFFactory; |
33 | import org.projectfloodlight.openflow.protocol.OFFlowAdd; | 34 | import org.projectfloodlight.openflow.protocol.OFFlowAdd; |
34 | import org.projectfloodlight.openflow.protocol.OFFlowDelete; | 35 | import org.projectfloodlight.openflow.protocol.OFFlowDelete; |
... | @@ -166,13 +167,16 @@ public class FlowModBuilderVer10 extends FlowModBuilder { | ... | @@ -166,13 +167,16 @@ public class FlowModBuilderVer10 extends FlowModBuilder { |
166 | private OFAction buildL3Modification(Instruction i) { | 167 | private OFAction buildL3Modification(Instruction i) { |
167 | L3ModificationInstruction l3m = (L3ModificationInstruction) i; | 168 | L3ModificationInstruction l3m = (L3ModificationInstruction) i; |
168 | ModIPInstruction ip; | 169 | ModIPInstruction ip; |
170 | + Ip4Address ip4; | ||
169 | switch (l3m.subtype()) { | 171 | switch (l3m.subtype()) { |
170 | case IP_DST: | 172 | case IP_DST: |
171 | ip = (ModIPInstruction) i; | 173 | ip = (ModIPInstruction) i; |
172 | - return factory().actions().setNwDst(IPv4Address.of(ip.ip().toInt())); | 174 | + ip4 = ip.ip().getIp4Address(); |
175 | + return factory().actions().setNwDst(IPv4Address.of(ip4.toInt())); | ||
173 | case IP_SRC: | 176 | case IP_SRC: |
174 | ip = (ModIPInstruction) i; | 177 | ip = (ModIPInstruction) i; |
175 | - return factory().actions().setNwSrc(IPv4Address.of(ip.ip().toInt())); | 178 | + ip4 = ip.ip().getIp4Address(); |
179 | + return factory().actions().setNwSrc(IPv4Address.of(ip4.toInt())); | ||
176 | default: | 180 | default: |
177 | log.warn("Unimplemented action type {}.", l3m.subtype()); | 181 | log.warn("Unimplemented action type {}.", l3m.subtype()); |
178 | break; | 182 | break; | ... | ... |
... | @@ -31,6 +31,7 @@ import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModVlanIdI | ... | @@ -31,6 +31,7 @@ import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModVlanIdI |
31 | import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction; | 31 | import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction; |
32 | import org.onlab.onos.net.flow.instructions.L3ModificationInstruction; | 32 | import org.onlab.onos.net.flow.instructions.L3ModificationInstruction; |
33 | import org.onlab.onos.net.flow.instructions.L3ModificationInstruction.ModIPInstruction; | 33 | import org.onlab.onos.net.flow.instructions.L3ModificationInstruction.ModIPInstruction; |
34 | +import org.onlab.packet.Ip4Address; | ||
34 | import org.projectfloodlight.openflow.protocol.OFFactory; | 35 | import org.projectfloodlight.openflow.protocol.OFFactory; |
35 | import org.projectfloodlight.openflow.protocol.OFFlowAdd; | 36 | import org.projectfloodlight.openflow.protocol.OFFlowAdd; |
36 | import org.projectfloodlight.openflow.protocol.OFFlowDelete; | 37 | import org.projectfloodlight.openflow.protocol.OFFlowDelete; |
... | @@ -230,14 +231,17 @@ public class FlowModBuilderVer13 extends FlowModBuilder { | ... | @@ -230,14 +231,17 @@ public class FlowModBuilderVer13 extends FlowModBuilder { |
230 | private OFAction buildL3Modification(Instruction i) { | 231 | private OFAction buildL3Modification(Instruction i) { |
231 | L3ModificationInstruction l3m = (L3ModificationInstruction) i; | 232 | L3ModificationInstruction l3m = (L3ModificationInstruction) i; |
232 | ModIPInstruction ip; | 233 | ModIPInstruction ip; |
234 | + Ip4Address ip4; | ||
233 | OFOxm<?> oxm = null; | 235 | OFOxm<?> oxm = null; |
234 | switch (l3m.subtype()) { | 236 | switch (l3m.subtype()) { |
235 | case IP_DST: | 237 | case IP_DST: |
236 | ip = (ModIPInstruction) i; | 238 | ip = (ModIPInstruction) i; |
237 | - oxm = factory().oxms().ipv4Dst(IPv4Address.of(ip.ip().toInt())); | 239 | + ip4 = ip.ip().getIp4Address(); |
240 | + oxm = factory().oxms().ipv4Dst(IPv4Address.of(ip4.toInt())); | ||
238 | case IP_SRC: | 241 | case IP_SRC: |
239 | ip = (ModIPInstruction) i; | 242 | ip = (ModIPInstruction) i; |
240 | - oxm = factory().oxms().ipv4Src(IPv4Address.of(ip.ip().toInt())); | 243 | + ip4 = ip.ip().getIp4Address(); |
244 | + oxm = factory().oxms().ipv4Src(IPv4Address.of(ip4.toInt())); | ||
241 | default: | 245 | default: |
242 | log.warn("Unimplemented action type {}.", l3m.subtype()); | 246 | log.warn("Unimplemented action type {}.", l3m.subtype()); |
243 | break; | 247 | break; | ... | ... |
-
Please register or login to post a comment