Search in sources :

Example 6 with ArpMatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder in project openflowplugin by opendaylight.

the class OpenflowpluginTestCommandProvider method createAppyActionInstruction43.

private static InstructionsBuilder createAppyActionInstruction43() {
    final List<Action> actionList = new ArrayList<>();
    final ActionBuilder ab = new ActionBuilder();
    final ActionBuilder ab1 = new ActionBuilder();
    final ActionBuilder ab2 = new ActionBuilder();
    final ActionBuilder ab3 = new ActionBuilder();
    final ActionBuilder ab4 = new ActionBuilder();
    final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
    final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
    final SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
    final SetFieldBuilder setFieldBuilder3 = new SetFieldBuilder();
    final SetFieldBuilder setFieldBuilder4 = new SetFieldBuilder();
    // setting the values of ARP
    final MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
    final MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
    final Ipv4Prefix dstiparp = new Ipv4Prefix("200.71.9.52");
    final Ipv4Prefix srciparp = new Ipv4Prefix("100.1.1.1");
    // create ARP match action
    final ArpMatchBuilder arpmatch = new ArpMatchBuilder();
    final ArpMatchBuilder arpmatch1 = new ArpMatchBuilder();
    final ArpMatchBuilder arpmatch2 = new ArpMatchBuilder();
    final ArpMatchBuilder arpmatch3 = new ArpMatchBuilder();
    final ArpMatchBuilder arpmatch4 = new ArpMatchBuilder();
    final ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
    arpsrc.setAddress(macsrc);
    final ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
    arpdst.setAddress(macdest);
    arpmatch.setArpOp(2);
    arpmatch1.setArpSourceHardwareAddress(arpsrc.build());
    arpmatch2.setArpTargetHardwareAddress(arpdst.build());
    arpmatch3.setArpSourceTransportAddress(srciparp);
    arpmatch4.setArpTargetTransportAddress(dstiparp);
    setFieldBuilder.setLayer3Match(arpmatch.build());
    ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
    ab.setKey(new ActionKey(0));
    actionList.add(ab.build());
    setFieldBuilder1.setLayer3Match(arpmatch1.build());
    ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
    ab1.setKey(new ActionKey(1));
    actionList.add(ab1.build());
    setFieldBuilder2.setLayer3Match(arpmatch2.build());
    ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
    ab2.setKey(new ActionKey(2));
    actionList.add(ab2.build());
    setFieldBuilder3.setLayer3Match(arpmatch3.build());
    ab3.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder3.build()).build());
    ab3.setKey(new ActionKey(3));
    actionList.add(ab3.build());
    setFieldBuilder4.setLayer3Match(arpmatch4.build());
    ab4.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder4.build()).build());
    ab4.setKey(new ActionKey(4));
    actionList.add(ab4.build());
    final ApplyActionsBuilder aab = new ApplyActionsBuilder();
    aab.setAction(actionList);
    final InstructionBuilder ib = new InstructionBuilder();
    ib.setKey(new InstructionKey(0));
    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<>();
    instructions.add(ib.build());
    isb.setInstruction(instructions);
    return isb;
}
Also used : InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder) DropAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) SetFieldCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder) ControllerActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder) LoopbackActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.loopback.action._case.LoopbackActionBuilder) HwPathActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.hw.path.action._case.HwPathActionBuilder) SetVlanIdActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder) DropActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder) SetVlanCfiActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.cfi.action._case.SetVlanCfiActionBuilder) PushPbbActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder) SetMplsTtlActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder) PopMplsActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder) SetDlSrcActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder) SetDlTypeActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.type.action._case.SetDlTypeActionBuilder) SetTpDstActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstActionBuilder) SetNextHopActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.next.hop.action._case.SetNextHopActionBuilder) PushVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder) SetNwTtlActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder) PopPbbActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder) SetNwTosActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder) SetTpSrcActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder) SetNwDstActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder) GroupActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder) PushMplsActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder) PopVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder) SwPathActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.sw.path.action._case.SwPathActionBuilder) SetDlDstActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder) StripVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.strip.vlan.action._case.StripVlanActionBuilder) FloodAllActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.all.action._case.FloodAllActionBuilder) SetVlanPcpActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder) SetQueueActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder) SetNwSrcActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder) FloodActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.action._case.FloodActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder) ArrayList(java.util.ArrayList) InstructionKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey) ActionKey(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) ArpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder) SetFieldBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder) InstructionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder) ArpSourceHardwareAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder) ApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder) ArpTargetHardwareAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) ApplyActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder)

Example 7 with ArpMatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder in project openflowplugin by opendaylight.

the class MatchNormalizationUtilTest method normalizeArpMatch.

@Test
public void normalizeArpMatch() {
    final int arpOp = 10;
    final String source = "192.168.1.2/24";
    final String destination = "192.168.2.2/24";
    final MacAddress sourceHw = new MacAddress("01:23:45:AB:CD:EF");
    final MacAddress dstHw = new MacAddress("01:23:45:AB:C0:EF");
    final MacAddress mask = new MacAddress("FF:FF:FF:FF:FF:FF");
    final MatchBuilder matchBuilder = MatchNormalizationUtil.normalizeArpMatch(new MatchBuilder().setLayer3Match(new ArpMatchBuilder().setArpOp(10).setArpSourceTransportAddress(new Ipv4Prefix(source)).setArpTargetTransportAddress(new Ipv4Prefix(destination)).setArpTargetHardwareAddress(new ArpTargetHardwareAddressBuilder().setAddress(dstHw).setMask(mask).build()).setArpSourceHardwareAddress(new ArpSourceHardwareAddressBuilder().setAddress(sourceHw).setMask(mask).build()).build()));
    assertEquals(arpOp, ArpMatch.class.cast(matchBuilder.getLayer3Match()).getArpOp().intValue());
}
Also used : ArpSourceHardwareAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder) ArpTargetHardwareAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder) ArpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ArpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder) TunnelIpv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder) Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder) ArpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Test(org.junit.Test)

Example 8 with ArpMatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder in project openflowplugin by opendaylight.

the class ArpOpEntrySerializerTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    final int arpOp = 42;
    final Match arpOpMatch = new MatchBuilder().setLayer3Match(new ArpMatchBuilder().setArpOp(arpOp).build()).build();
    assertMatch(arpOpMatch, false, (out) -> assertEquals(out.readShort(), arpOp));
}
Also used : MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) ArpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder) ArpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match) Test(org.junit.Test)

Example 9 with ArpMatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder in project openflowplugin by opendaylight.

the class ArpSourceTransportAddressEntrySerializerTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    final Match arpSpaMatch = new MatchBuilder().setLayer3Match(new ArpMatchBuilder().setArpSourceTransportAddress(new Ipv4Prefix("10.0.2.0/24")).build()).build();
    assertMatch(arpSpaMatch, true, (out) -> {
        byte[] address = new byte[4];
        out.readBytes(address);
        assertArrayEquals(address, new byte[] { 10, 0, 2, 0 });
        byte[] mask = new byte[4];
        out.readBytes(mask);
        assertArrayEquals(mask, new byte[] { (byte) 255, (byte) 255, (byte) 255, 0 });
    });
    final Match arpSpaMatchNoMask = new MatchBuilder().setLayer3Match(new ArpMatchBuilder().setArpSourceTransportAddress(new Ipv4Prefix("10.0.0.0/32")).build()).build();
    assertMatch(arpSpaMatchNoMask, false, (out) -> {
        byte[] address = new byte[4];
        out.readBytes(address);
        assertArrayEquals(address, new byte[] { 10, 0, 0, 0 });
    });
}
Also used : MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) ArpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder) ArpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match) Test(org.junit.Test)

Example 10 with ArpMatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder in project openflowplugin by opendaylight.

the class OfToSalArpOpCase method process.

@Override
public Optional<MatchBuilder> process(@Nonnull ArpOpCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
    final MatchBuilder matchBuilder = data.getMatchBuilder();
    final ArpMatchBuilder arpMatchBuilder = data.getArpMatchBuilder();
    ArpOp arpOp = source.getArpOp();
    if (arpOp != null) {
        arpMatchBuilder.setArpOp(arpOp.getOpCode());
        matchBuilder.setLayer3Match(arpMatchBuilder.build());
    }
    return Optional.of(matchBuilder);
}
Also used : ArpOp(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.op._case.ArpOp) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) ArpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder) ArpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder)

Aggregations

ArpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder)21 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)15 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)11 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)9 Test (org.junit.Test)8 ArpSourceHardwareAddressBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder)8 ArpTargetHardwareAddressBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder)8 ArpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch)6 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match)5 EthernetMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)5 Layer3Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match)5 Ipv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder)5 Ipv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder)5 TunnelIpv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder)5 Icmpv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder)4 Icmpv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder)4 IpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder)4 VlanMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder)4 SctpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder)4 TcpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder)4