use of org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpEthInstruction in project onos by opennetworkinglab.
the class LinkCollectionCompiler method updateBuilder.
/**
* Update the selector builder using a L3 instruction.
*
* @param builder the builder to update
* @param l3instruction the l3 instruction to use
*/
private void updateBuilder(TrafficSelector.Builder builder, L3ModificationInstruction l3instruction) {
// TODO check ethernet proto
switch(l3instruction.subtype()) {
case IPV4_SRC:
case IPV4_DST:
case IPV6_SRC:
case IPV6_DST:
ModIPInstruction ipInstr = (ModIPInstruction) l3instruction;
// TODO check if ip falls in original prefix
IpPrefix prefix = ipInstr.ip().toIpPrefix();
switch(ipInstr.subtype()) {
case IPV4_SRC:
builder.matchIPSrc(prefix);
break;
case IPV4_DST:
builder.matchIPSrc(prefix);
break;
case IPV6_SRC:
builder.matchIPv6Src(prefix);
break;
case IPV6_DST:
builder.matchIPv6Dst(prefix);
break;
default:
throw new IntentCompilationException(UNSUPPORTED_IP_SUBTYPE);
}
break;
case IPV6_FLABEL:
ModIPv6FlowLabelInstruction ipFlowInstr = (ModIPv6FlowLabelInstruction) l3instruction;
builder.matchIPv6FlowLabel(ipFlowInstr.flowLabel());
break;
case DEC_TTL:
// no-op
break;
case TTL_OUT:
// no-op
break;
case TTL_IN:
// no-op
break;
case ARP_SPA:
ModArpIPInstruction srcArpIpInstr = (ModArpIPInstruction) l3instruction;
if (srcArpIpInstr.ip().isIp4()) {
builder.matchArpSpa((Ip4Address) srcArpIpInstr.ip());
} else {
throw new IntentCompilationException(UNSUPPORTED_ARP);
}
break;
case ARP_SHA:
ModArpEthInstruction srcArpEthInstr = (ModArpEthInstruction) l3instruction;
builder.matchArpSha(srcArpEthInstr.mac());
break;
case ARP_TPA:
ModArpIPInstruction dstArpIpInstr = (ModArpIPInstruction) l3instruction;
if (dstArpIpInstr.ip().isIp4()) {
builder.matchArpTpa((Ip4Address) dstArpIpInstr.ip());
} else {
throw new IntentCompilationException(UNSUPPORTED_ARP);
}
break;
case ARP_THA:
ModArpEthInstruction dstArpEthInstr = (ModArpEthInstruction) l3instruction;
builder.matchArpTha(dstArpEthInstr.mac());
break;
case ARP_OP:
ModArpOpInstruction arpOpInstr = (ModArpOpInstruction) l3instruction;
// FIXME is the long to int cast safe?
builder.matchArpOp((int) arpOpInstr.op());
break;
default:
throw new IntentCompilationException(UNSUPPORTED_L3);
}
}
use of org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpEthInstruction in project onos by opennetworkinglab.
the class FlowModBuilderVer13 method buildL3Modification.
protected OFAction buildL3Modification(Instruction i) {
L3ModificationInstruction l3m = (L3ModificationInstruction) i;
ModIPInstruction ip;
Ip4Address ip4;
Ip6Address ip6;
OFOxm<?> oxm = null;
switch(l3m.subtype()) {
case IPV4_SRC:
ip = (ModIPInstruction) i;
ip4 = ip.ip().getIp4Address();
oxm = factory().oxms().ipv4Src(IPv4Address.of(ip4.toInt()));
break;
case IPV4_DST:
ip = (ModIPInstruction) i;
ip4 = ip.ip().getIp4Address();
oxm = factory().oxms().ipv4Dst(IPv4Address.of(ip4.toInt()));
break;
case IP_DSCP:
L3ModificationInstruction.ModDscpInstruction dscp = (L3ModificationInstruction.ModDscpInstruction) i;
IpDscp ipDscp = IpDscp.of(dscp.dscp());
oxm = factory().oxms().ipDscp(ipDscp);
break;
case IPV6_SRC:
ip = (ModIPInstruction) i;
ip6 = ip.ip().getIp6Address();
oxm = factory().oxms().ipv6Src(IPv6Address.of(ip6.toOctets()));
break;
case IPV6_DST:
ip = (ModIPInstruction) i;
ip6 = ip.ip().getIp6Address();
oxm = factory().oxms().ipv6Dst(IPv6Address.of(ip6.toOctets()));
break;
case IPV6_FLABEL:
ModIPv6FlowLabelInstruction flowLabelInstruction = (ModIPv6FlowLabelInstruction) i;
int flowLabel = flowLabelInstruction.flowLabel();
oxm = factory().oxms().ipv6Flabel(IPv6FlowLabel.of(flowLabel));
break;
case ARP_SPA:
ModArpIPInstruction sAip = (ModArpIPInstruction) i;
ip4 = sAip.ip().getIp4Address();
oxm = factory().oxms().arpSpa(IPv4Address.of(ip4.toInt()));
break;
case ARP_SHA:
ModArpEthInstruction sAei = (ModArpEthInstruction) i;
oxm = factory().oxms().arpSha(MacAddress.of(sAei.mac().toLong()));
break;
case ARP_TPA:
ModArpIPInstruction dAip = (ModArpIPInstruction) i;
ip4 = dAip.ip().getIp4Address();
oxm = factory().oxms().arpTpa(IPv4Address.of(ip4.toInt()));
break;
case ARP_THA:
ModArpEthInstruction dAei = (ModArpEthInstruction) i;
oxm = factory().oxms().arpTha(MacAddress.of(dAei.mac().toLong()));
break;
case ARP_OP:
ModArpOpInstruction oi = (ModArpOpInstruction) i;
oxm = factory().oxms().arpOp(ArpOpcode.of((int) oi.op()));
break;
case DEC_TTL:
return factory().actions().decNwTtl();
case TTL_IN:
return factory().actions().copyTtlIn();
case TTL_OUT:
return factory().actions().copyTtlOut();
default:
log.warn("Unimplemented action type {}.", l3m.subtype());
break;
}
if (oxm != null) {
return factory().actions().buildSetField().setField(oxm).build();
}
return null;
}
Aggregations