use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method createAppyActionInstruction7.
private static InstructionsBuilder createAppyActionInstruction7() {
final List<Action> actionList = new ArrayList<>();
final ActionBuilder ab = new ActionBuilder();
final SetVlanIdActionBuilder vl = new SetVlanIdActionBuilder();
final VlanId a = new VlanId(4000);
vl.setVlanId(a);
ab.setAction(new SetVlanIdActionCaseBuilder().setSetVlanIdAction(vl.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
final InstructionsBuilder isb = new InstructionsBuilder();
final List<Instruction> instructions = new ArrayList<>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId in project openflowplugin by opendaylight.
the class MatchV10ResponseConvertor method convert.
@Override
public MatchBuilder convert(MatchV10 source, VersionDatapathIdConvertorData datapathIdConvertorData) {
MatchBuilder matchBuilder = new MatchBuilder();
EthernetMatchBuilder ethMatchBuilder = new EthernetMatchBuilder();
VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
IpMatchBuilder ipMatchBuilder = new IpMatchBuilder();
OpenflowVersion ofVersion = OpenflowVersion.get(datapathIdConvertorData.getVersion());
BigInteger datapathid = datapathIdConvertorData.getDatapathId();
if (!source.getWildcards().isINPORT() && source.getInPort() != null) {
matchBuilder.setInPort(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(datapathid, (long) source.getInPort(), ofVersion));
}
if (!source.getWildcards().isDLSRC() && source.getDlSrc() != null) {
EthernetSourceBuilder ethSrcBuilder = new EthernetSourceBuilder();
ethSrcBuilder.setAddress(source.getDlSrc());
ethMatchBuilder.setEthernetSource(ethSrcBuilder.build());
matchBuilder.setEthernetMatch(ethMatchBuilder.build());
}
if (!source.getWildcards().isDLDST() && source.getDlDst() != null) {
EthernetDestinationBuilder ethDstBuilder = new EthernetDestinationBuilder();
ethDstBuilder.setAddress(source.getDlDst());
ethMatchBuilder.setEthernetDestination(ethDstBuilder.build());
matchBuilder.setEthernetMatch(ethMatchBuilder.build());
}
if (!source.getWildcards().isDLTYPE() && source.getDlType() != null) {
EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType((long) source.getDlType()));
ethMatchBuilder.setEthernetType(ethTypeBuilder.build());
matchBuilder.setEthernetMatch(ethMatchBuilder.build());
}
if (!source.getWildcards().isDLVLAN() && source.getDlVlan() != null) {
VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
int vlanId = source.getDlVlan() == 0xffff ? 0 : source.getDlVlan();
vlanIdBuilder.setVlanId(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId(vlanId));
vlanIdBuilder.setVlanIdPresent(vlanId != 0);
vlanMatchBuilder.setVlanId(vlanIdBuilder.build());
matchBuilder.setVlanMatch(vlanMatchBuilder.build());
}
if (!source.getWildcards().isDLVLANPCP() && source.getDlVlanPcp() != null) {
vlanMatchBuilder.setVlanPcp(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp(source.getDlVlanPcp()));
matchBuilder.setVlanMatch(vlanMatchBuilder.build());
}
if (!source.getWildcards().isDLTYPE() && source.getNwSrc() != null) {
final Ipv4Prefix prefix;
if (source.getNwSrcMask() != null) {
prefix = IetfInetUtil.INSTANCE.ipv4PrefixFor(source.getNwSrc(), source.getNwSrcMask());
} else {
// Openflow Spec : 1.3.2
// An all-one-bits oxm_mask is equivalent to specifying 0 for oxm_hasmask and omitting oxm_mask.
// So when user specify 32 as a mast, switch omit that mast and we get null as a mask in flow
// statistics response.
prefix = IetfInetUtil.INSTANCE.ipv4PrefixFor(source.getNwSrc());
}
if (!NO_IP.equals(prefix.getValue())) {
ipv4MatchBuilder.setIpv4Source(prefix);
matchBuilder.setLayer3Match(ipv4MatchBuilder.build());
}
}
if (!source.getWildcards().isDLTYPE() && source.getNwDst() != null) {
final Ipv4Prefix prefix;
if (source.getNwDstMask() != null) {
prefix = IetfInetUtil.INSTANCE.ipv4PrefixFor(source.getNwDst(), source.getNwDstMask());
} else {
// Openflow Spec : 1.3.2
// An all-one-bits oxm_mask is equivalent to specifying 0 for oxm_hasmask and omitting oxm_mask.
// So when user specify 32 as a mast, switch omit that mast and we get null as a mask in flow
// statistics response.
prefix = IetfInetUtil.INSTANCE.ipv4PrefixFor(source.getNwDst());
}
if (!NO_IP.equals(prefix.getValue())) {
ipv4MatchBuilder.setIpv4Destination(prefix);
matchBuilder.setLayer3Match(ipv4MatchBuilder.build());
}
}
if (!source.getWildcards().isNWPROTO() && source.getNwProto() != null) {
Short nwProto = source.getNwProto();
ipMatchBuilder.setIpProtocol(nwProto);
matchBuilder.setIpMatch(ipMatchBuilder.build());
int proto = nwProto.intValue();
if (proto == PROTO_TCP) {
TcpMatchBuilder tcpMatchBuilder = new TcpMatchBuilder();
boolean hasTcp = false;
if (!source.getWildcards().isTPSRC() && source.getTpSrc() != null) {
tcpMatchBuilder.setTcpSourcePort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(source.getTpSrc()));
hasTcp = true;
}
if (!source.getWildcards().isTPDST() && source.getTpDst() != null) {
tcpMatchBuilder.setTcpDestinationPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(source.getTpDst()));
hasTcp = true;
}
if (hasTcp) {
matchBuilder.setLayer4Match(tcpMatchBuilder.build());
}
} else if (proto == PROTO_UDP) {
UdpMatchBuilder udpMatchBuilder = new UdpMatchBuilder();
boolean hasUdp = false;
if (!source.getWildcards().isTPSRC() && source.getTpSrc() != null) {
udpMatchBuilder.setUdpSourcePort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(source.getTpSrc()));
hasUdp = true;
}
if (!source.getWildcards().isTPDST() && source.getTpDst() != null) {
udpMatchBuilder.setUdpDestinationPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(source.getTpDst()));
hasUdp = true;
}
if (hasUdp) {
matchBuilder.setLayer4Match(udpMatchBuilder.build());
}
} else if (proto == PROTO_ICMPV4) {
Icmpv4MatchBuilder icmpv4MatchBuilder = new Icmpv4MatchBuilder();
boolean hasIcmpv4 = false;
if (!source.getWildcards().isTPSRC()) {
Integer type = source.getTpSrc();
if (type != null) {
icmpv4MatchBuilder.setIcmpv4Type(type.shortValue());
hasIcmpv4 = true;
}
}
if (!source.getWildcards().isTPDST()) {
Integer code = source.getTpDst();
if (code != null) {
icmpv4MatchBuilder.setIcmpv4Code(code.shortValue());
hasIcmpv4 = true;
}
}
if (hasIcmpv4) {
matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build());
}
}
}
if (!source.getWildcards().isNWTOS() && source.getNwTos() != null) {
Short dscp = ActionUtil.tosToDscp(source.getNwTos());
ipMatchBuilder.setIpDscp(new Dscp(dscp));
matchBuilder.setIpMatch(ipMatchBuilder.build());
}
return matchBuilder;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId in project openflowplugin by opendaylight.
the class FlowConvertor method handleSetVlanIdForOF13.
/**
* A) If user provided flow's match includes vlan match and action has set_vlan_field
* Install following rules.
* 1) match on (OFPVID_PRESENT |value) without mask + action [set_field]
* <p/>
* B) if user provided flow's match doesn't include vlan match but action has set_vlan field
* 1) Match on (OFPVID_NONE ) without mask + action [push vlan tag + set_field]
* 2) Match on (OFPVID_PRESENT) with mask (OFPVID_PRESENT ) + action [ set_field]
*/
private List<FlowModInputBuilder> handleSetVlanIdForOF13(Flow srcFlow, VersionDatapathIdConvertorData versionDatapathIdConverterData) {
List<FlowModInputBuilder> list = new ArrayList<>(2);
final Match srcMatch = Preconditions.checkNotNull(srcFlow.getMatch());
final VlanMatch srcVlanMatch = srcMatch.getVlanMatch();
if (srcVlanMatch != null) {
// create flow with setfield and match
// match on vlan tag or vlanid with no mask
VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder(srcVlanMatch);
VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
vlanIdBuilder.setVlanIdPresent(srcVlanMatch.getVlanId().isVlanIdPresent());
vlanIdBuilder.setVlanId(srcVlanMatch.getVlanId().getVlanId());
vlanMatchBuilder.setVlanId(vlanIdBuilder.build());
Match match = new MatchBuilder(srcMatch).setVlanMatch(vlanMatchBuilder.build()).build();
Optional<? extends Flow> optional = injectMatchToFlow(srcFlow, match);
if (optional.isPresent()) {
list.add(toFlowModInput(optional.get(), versionDatapathIdConverterData));
}
} else {
// create 2 flows
// flow 1
// match on no vlan tag with no mask
Match match1 = new MatchBuilder(srcMatch).setVlanMatch(VLAN_MATCH_FALSE).build();
Optional<? extends Flow> optional1 = injectMatchAndAction(srcFlow, match1);
if (optional1.isPresent()) {
list.add(toFlowModInput(optional1.get(), versionDatapathIdConverterData));
}
// flow2
// match on vlan tag with mask
Match match2 = new MatchBuilder(srcMatch).setVlanMatch(VLAN_MATCH_TRUE).build();
Optional<? extends Flow> optional2 = injectMatchToFlow(srcFlow, match2);
if (optional2.isPresent()) {
list.add(toFlowModInput(optional2.get(), versionDatapathIdConverterData));
}
}
return list;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId in project openflowplugin by opendaylight.
the class OpenflowPluginBulkGroupTransactionProvider method createAppyActionInstruction7.
private static InstructionsBuilder createAppyActionInstruction7() {
List<Action> actionList = new ArrayList<>();
ActionBuilder ab = new ActionBuilder();
SetVlanIdActionBuilder vl = new SetVlanIdActionBuilder();
VlanId vlanId = new VlanId(4012);
vl.setVlanId(vlanId);
ab.setAction(new SetVlanIdActionCaseBuilder().setSetVlanIdAction(vl.build()).build());
actionList.add(ab.build());
// Create an Apply Action
ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
InstructionsBuilder isb = new InstructionsBuilder();
List<Instruction> instructions = new ArrayList<>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId in project openflowplugin by opendaylight.
the class OpenflowPluginBulkGroupTransactionProvider method createPushVlanAction.
private List<Action> createPushVlanAction() {
PushVlanActionBuilder vlan = new PushVlanActionBuilder();
vlan.setEthernetType(0x8100);
VlanId vlanId = new VlanId(2);
vlan.setVlanId(vlanId);
ActionBuilder action = new ActionBuilder();
action.setAction(new PushVlanActionCaseBuilder().setPushVlanAction(vlan.build()).build());
List<Action> actions = new ArrayList<>();
actions.add(action.build());
return actions;
}
Aggregations