Search in sources :

Example 1 with SetNwTosActionBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.tos._case.SetNwTosActionBuilder in project openflowplugin by opendaylight.

the class OpenflowpluginTestCommandProvider method createAppyActionInstruction28.

private static InstructionsBuilder createAppyActionInstruction28() {
    final List<Action> actionList = new ArrayList<>();
    final ActionBuilder ab = new ActionBuilder();
    final SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
    setNwTosActionBuilder.setTos(8);
    ab.setAction(new SetNwTosActionCaseBuilder().setSetNwTosAction(setNwTosActionBuilder.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;
}
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) 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) SetNwTosActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder) ArrayList(java.util.ArrayList) SetNwTosActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder) 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) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) InstructionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder) ApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder) ApplyActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder)

Example 2 with SetNwTosActionBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.tos._case.SetNwTosActionBuilder in project openflowplugin by opendaylight.

the class SalToOfSetNwTosActionV10Case method process.

@Nonnull
@Override
public Optional<Action> process(@Nonnull final SetNwTosActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
    SetNwTosAction setnwtosaction = source.getSetNwTosAction();
    SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
    SetNwTosCaseBuilder setNwTosCaseBuilder = new SetNwTosCaseBuilder();
    setNwTosActionBuilder.setNwTos(setnwtosaction.getTos().shortValue());
    setNwTosCaseBuilder.setSetNwTosAction(setNwTosActionBuilder.build());
    return Optional.of(new ActionBuilder().setActionChoice(setNwTosCaseBuilder.build()).build());
}
Also used : SetNwTosAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosAction) SetNwTosActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.tos._case.SetNwTosActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) SetNwTosActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.tos._case.SetNwTosActionBuilder) SetNwTosCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTosCaseBuilder) Nonnull(javax.annotation.Nonnull)

Example 3 with SetNwTosActionBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.tos._case.SetNwTosActionBuilder in project openflowplugin by opendaylight.

the class ActionConvertorV13Test method testGetActions.

/**
 * Test {@link ActionConvertor#convert(List, ActionConvertorData)} }.
 */
@Test
public void testGetActions() {
    org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
    SetVlanPcpActionCaseBuilder vlanPcpCaseBuilder = new SetVlanPcpActionCaseBuilder();
    SetVlanPcpActionBuilder pcpBuilder = new SetVlanPcpActionBuilder();
    pcpBuilder.setVlanPcp(new VlanPcp((short) 7));
    vlanPcpCaseBuilder.setSetVlanPcpAction(pcpBuilder.build());
    actionBuilder.setAction(vlanPcpCaseBuilder.build());
    actionBuilder.setOrder(0);
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> salActions = new ArrayList<>();
    salActions.add(actionBuilder.build());
    actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
    StripVlanActionCaseBuilder stripCaseBuilder = new StripVlanActionCaseBuilder();
    StripVlanActionBuilder stripBuilder = new StripVlanActionBuilder();
    stripCaseBuilder.setStripVlanAction(stripBuilder.build());
    actionBuilder.setAction(stripCaseBuilder.build());
    actionBuilder.setOrder(1);
    salActions.add(actionBuilder.build());
    actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
    SetDlDstActionCaseBuilder dlDstCaseBuilder = new SetDlDstActionCaseBuilder();
    SetDlDstActionBuilder dlDstBuilder = new SetDlDstActionBuilder();
    dlDstBuilder.setAddress(new MacAddress("00:00:00:00:00:06"));
    dlDstCaseBuilder.setSetDlDstAction(dlDstBuilder.build());
    actionBuilder.setAction(dlDstCaseBuilder.build());
    actionBuilder.setOrder(2);
    salActions.add(actionBuilder.build());
    actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
    SetDlSrcActionCaseBuilder dlSrcCaseBuilder = new SetDlSrcActionCaseBuilder();
    SetDlSrcActionBuilder dlSrcBuilder = new SetDlSrcActionBuilder();
    dlSrcBuilder.setAddress(new MacAddress("00:00:00:00:00:05"));
    dlSrcCaseBuilder.setSetDlSrcAction(dlSrcBuilder.build());
    actionBuilder.setAction(dlSrcCaseBuilder.build());
    actionBuilder.setOrder(3);
    salActions.add(actionBuilder.build());
    actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
    SetNwSrcActionCaseBuilder nwSrcCaseBuilder = new SetNwSrcActionCaseBuilder();
    SetNwSrcActionBuilder nwSrcBuilder = new SetNwSrcActionBuilder();
    Ipv4Builder ipv4Builder = new Ipv4Builder();
    /* Correct canonical form for v4 prefix!!! */
    ipv4Builder.setIpv4Address(new Ipv4Prefix("10.0.0.0/24"));
    nwSrcBuilder.setAddress(ipv4Builder.build());
    nwSrcCaseBuilder.setSetNwSrcAction(nwSrcBuilder.build());
    actionBuilder.setAction(nwSrcCaseBuilder.build());
    actionBuilder.setOrder(4);
    salActions.add(actionBuilder.build());
    actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
    SetNwDstActionBuilder nwDstBuilder = new SetNwDstActionBuilder();
    ipv4Builder = new Ipv4Builder();
    ipv4Builder.setIpv4Address(new Ipv4Prefix("10.0.0.2/32"));
    nwDstBuilder.setAddress(ipv4Builder.build());
    SetNwDstActionCaseBuilder nwDstCaseBuilder = new SetNwDstActionCaseBuilder();
    nwDstCaseBuilder.setSetNwDstAction(nwDstBuilder.build());
    actionBuilder.setAction(nwDstCaseBuilder.build());
    actionBuilder.setOrder(5);
    salActions.add(actionBuilder.build());
    actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
    SetTpSrcActionCaseBuilder tpSrcCaseBuilder = new SetTpSrcActionCaseBuilder();
    SetTpSrcActionBuilder tpSrcBuilder = new SetTpSrcActionBuilder();
    tpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(54));
    tpSrcCaseBuilder.setSetTpSrcAction(tpSrcBuilder.build());
    actionBuilder.setAction(tpSrcCaseBuilder.build());
    actionBuilder.setOrder(6);
    salActions.add(actionBuilder.build());
    actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
    SetTpDstActionCaseBuilder tpDstCaseBuilder = new SetTpDstActionCaseBuilder();
    SetTpDstActionBuilder tpDstBuilder = new SetTpDstActionBuilder();
    tpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(45));
    tpDstCaseBuilder.setSetTpDstAction(tpDstBuilder.build());
    actionBuilder.setAction(tpDstCaseBuilder.build());
    actionBuilder.setOrder(7);
    salActions.add(actionBuilder.build());
    actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
    SetNwTosActionCaseBuilder tosCaseBuilder = new SetNwTosActionCaseBuilder();
    SetNwTosActionBuilder tosBuilder = new SetNwTosActionBuilder();
    tosBuilder.setTos(16);
    tosCaseBuilder.setSetNwTosAction(tosBuilder.build());
    actionBuilder.setAction(tosCaseBuilder.build());
    actionBuilder.setOrder(8);
    salActions.add(actionBuilder.build());
    actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
    SetVlanIdActionCaseBuilder vlanIdCaseBuilder = new SetVlanIdActionCaseBuilder();
    SetVlanIdActionBuilder vlanIdBuilder = new SetVlanIdActionBuilder();
    vlanIdBuilder.setVlanId(new VlanId(22));
    vlanIdCaseBuilder.setSetVlanIdAction(vlanIdBuilder.build());
    actionBuilder.setAction(vlanIdCaseBuilder.build());
    actionBuilder.setOrder(9);
    salActions.add(actionBuilder.build());
    actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
    nwSrcCaseBuilder = new SetNwSrcActionCaseBuilder();
    nwSrcBuilder = new SetNwSrcActionBuilder();
    Ipv6Builder ipv6Builder = new Ipv6Builder();
    /* Use canonical form, 00:00:0000 is not a valid v6 notation */
    ipv6Builder.setIpv6Address(new Ipv6Prefix("::5/128"));
    nwSrcBuilder.setAddress(ipv6Builder.build());
    nwSrcCaseBuilder.setSetNwSrcAction(nwSrcBuilder.build());
    actionBuilder.setAction(nwSrcCaseBuilder.build());
    actionBuilder.setOrder(10);
    salActions.add(actionBuilder.build());
    actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
    nwDstCaseBuilder = new SetNwDstActionCaseBuilder();
    nwDstBuilder = new SetNwDstActionBuilder();
    ipv6Builder = new Ipv6Builder();
    /* Use canonical form, 00:00:0006/64 is not a valid v6 notation - this equates to ::/64 */
    ipv6Builder.setIpv6Address(new Ipv6Prefix("::/64"));
    nwDstBuilder.setAddress(ipv6Builder.build());
    nwDstCaseBuilder.setSetNwDstAction(nwDstBuilder.build());
    actionBuilder.setAction(nwDstCaseBuilder.build());
    actionBuilder.setOrder(11);
    salActions.add(actionBuilder.build());
    IpMatchBuilder ipMatchBld = new IpMatchBuilder().setIpProtocol((short) 6);
    MatchBuilder matchBld = new MatchBuilder().setIpMatch(ipMatchBld.build());
    FlowBuilder flowBld = new FlowBuilder().setMatch(matchBld.build());
    Flow flow = flowBld.build();
    ActionConvertorData data = new ActionConvertorData(OFConstants.OFP_VERSION_1_3);
    data.setDatapathId(new BigInteger("42"));
    data.setIpProtocol(FlowConvertorUtil.getIpProtocolFromFlow(flow));
    Optional<List<Action>> actionsOptional = convertorManager.convert(salActions, data);
    List<Action> actions = actionsOptional.orElse(Collections.emptyList());
    Assert.assertEquals("Wrong number of actions", 12, actions.size());
    Action action = actions.get(0);
    Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
    MatchEntry entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
    checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanPcp.class, false);
    Assert.assertEquals("Wrong vlan pcp", 7, ((VlanPcpCase) entry.getMatchEntryValue()).getVlanPcp().getVlanPcp().intValue());
    action = actions.get(1);
    Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
    setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
    entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
    checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid.class, false);
    Assert.assertEquals("Wrong vlan vid", 0, ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid().getVlanVid().intValue());
    Assert.assertEquals("Wrong cfi bit", true, ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid().isCfiBit());
    action = actions.get(2);
    Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
    setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
    entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
    checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthDst.class, false);
    Assert.assertEquals("Wrong dl dst", "00:00:00:00:00:06", ((EthDstCase) entry.getMatchEntryValue()).getEthDst().getMacAddress().getValue());
    action = actions.get(3);
    setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
    Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
    entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
    checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthSrc.class, false);
    Assert.assertEquals("Wrong dl src", "00:00:00:00:00:05", ((EthSrcCase) entry.getMatchEntryValue()).getEthSrc().getMacAddress().getValue());
    action = actions.get(4);
    setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
    Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
    entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
    checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src.class, false);
    Assert.assertEquals("Wrong ipv4 src", "10.0.0.0", ((Ipv4SrcCase) entry.getMatchEntryValue()).getIpv4Src().getIpv4Address().getValue());
    action = actions.get(5);
    setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
    Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
    entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
    checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst.class, false);
    Assert.assertEquals("Wrong ipv4 dst", "10.0.0.2", ((Ipv4DstCase) entry.getMatchEntryValue()).getIpv4Dst().getIpv4Address().getValue());
    action = actions.get(6);
    setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
    Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
    entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
    checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpSrc.class, false);
    Assert.assertEquals("Wrong tcp src", 54, ((TcpSrcCase) entry.getMatchEntryValue()).getTcpSrc().getPort().getValue().intValue());
    action = actions.get(7);
    setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
    Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
    entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
    checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpDst.class, false);
    Assert.assertEquals("Wrong tcp dst", 45, ((TcpDstCase) entry.getMatchEntryValue()).getTcpDst().getPort().getValue().intValue());
    action = actions.get(8);
    setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
    Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
    entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
    checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpDscp.class, false);
    Assert.assertEquals("Wrong ip dscp", 4, ((IpDscpCase) entry.getMatchEntryValue()).getIpDscp().getDscp().getValue().intValue());
    action = actions.get(9);
    setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
    Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
    entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
    checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid.class, false);
    Assert.assertEquals("Wrong vlan id", 22, ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid().getVlanVid().intValue());
    Assert.assertEquals("Wrong cfi bit", true, ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid().isCfiBit());
    action = actions.get(10);
    setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
    Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
    entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
    checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src.class, false);
    Assert.assertEquals("Wrong ipv6 src", "::5", ((Ipv6SrcCase) entry.getMatchEntryValue()).getIpv6Src().getIpv6Address().getValue());
    action = actions.get(11);
    setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
    Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
    entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
    checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst.class, false);
    Assert.assertEquals("Wrong ipv6 dst", "::", ((Ipv6DstCase) entry.getMatchEntryValue()).getIpv6Dst().getIpv6Address().getValue());
}
Also used : ArrayList(java.util.ArrayList) SetNwTosActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder) SetTpSrcActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCaseBuilder) SetVlanIdActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder) ArrayList(java.util.ArrayList) List(java.util.List) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) VlanId(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId) IpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder) ActionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData) IpDscpCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpDscpCase) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) SetNwDstActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder) SetNwSrcActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder) BigInteger(java.math.BigInteger) SetDlDstActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCaseBuilder) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) SetVlanIdActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder) PopMplsActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.pop.mpls._case.PopMplsActionBuilder) SetNwTtlActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.ttl._case.SetNwTtlActionBuilder) PushMplsActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.mpls._case.PushMplsActionBuilder) SetMplsTtlActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.mpls.ttl._case.SetMplsTtlActionBuilder) SetDlSrcActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder) GroupActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.group._case.GroupActionBuilder) SetTpDstActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstActionBuilder) SetFieldActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder) 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) PushVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder) SetQueueActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.queue._case.SetQueueActionBuilder) 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) SetVlanPcpActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) SetNwSrcActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder) PushPbbActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.pbb._case.PushPbbActionBuilder) SetTpSrcActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder) SetFieldCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase) SetDlDstActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder) Ipv4Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder) Ipv6Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6Builder) SetVlanPcpActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix) SetNwSrcActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder) StripVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.strip.vlan.action._case.StripVlanActionBuilder) SetDlSrcActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCaseBuilder) SetVlanPcpActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCaseBuilder) SetVlanIdActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder) SetNwTosActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder) StripVlanActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.StripVlanActionCaseBuilder) TcpSrcCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpSrcCase) SetTpDstActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCaseBuilder) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) TcpDstCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpDstCase) SetNwDstActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder) VlanPcp(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp) VlanVidCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCase) SetTpDstActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstActionBuilder) SetDlSrcActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder) IpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Test(org.junit.Test)

Example 4 with SetNwTosActionBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.tos._case.SetNwTosActionBuilder in project openflowplugin by opendaylight.

the class OF10SetNwTosActionDeserializer method deserialize.

@Override
public Action deserialize(ByteBuf input) {
    final ActionBuilder builder = new ActionBuilder();
    input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    SetNwTosCaseBuilder caseBuilder = new SetNwTosCaseBuilder();
    SetNwTosActionBuilder tosBuilder = new SetNwTosActionBuilder();
    tosBuilder.setNwTos(input.readUnsignedByte());
    caseBuilder.setSetNwTosAction(tosBuilder.build());
    builder.setActionChoice(caseBuilder.build());
    input.skipBytes(ActionConstants.PADDING_IN_SET_NW_TOS_ACTION);
    return builder.build();
}
Also used : SetNwTosActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.tos._case.SetNwTosActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) SetNwTosCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTosCaseBuilder) SetNwTosActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.tos._case.SetNwTosActionBuilder)

Example 5 with SetNwTosActionBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.tos._case.SetNwTosActionBuilder in project openflowplugin by opendaylight.

the class OF10ActionsSerializerTest method test.

/**
 * Testing correct serialization of actions (OF v1.0).
 */
@Test
public void test() {
    final List<Action> actions = new ArrayList<>();
    OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
    OutputActionBuilder outputBuilder = new OutputActionBuilder();
    outputBuilder.setPort(new PortNumber(42L));
    outputBuilder.setMaxLength(32);
    caseBuilder.setOutputAction(outputBuilder.build());
    ActionBuilder actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(caseBuilder.build());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    SetVlanVidCaseBuilder vlanVidCaseBuilder = new SetVlanVidCaseBuilder();
    SetVlanVidActionBuilder vlanVidBuilder = new SetVlanVidActionBuilder();
    vlanVidBuilder.setVlanVid(15);
    vlanVidCaseBuilder.setSetVlanVidAction(vlanVidBuilder.build());
    actionBuilder.setActionChoice(vlanVidCaseBuilder.build());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    SetVlanPcpCaseBuilder vlanPcpCaseBuilder = new SetVlanPcpCaseBuilder();
    SetVlanPcpActionBuilder vlanPcpBuilder = new SetVlanPcpActionBuilder();
    vlanPcpBuilder.setVlanPcp((short) 16);
    vlanPcpCaseBuilder.setSetVlanPcpAction(vlanPcpBuilder.build());
    actionBuilder.setActionChoice(vlanPcpCaseBuilder.build());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(new StripVlanCaseBuilder().build());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    SetDlSrcCaseBuilder dlSrcCaseBuilder = new SetDlSrcCaseBuilder();
    SetDlSrcActionBuilder dlSrcBuilder = new SetDlSrcActionBuilder();
    dlSrcBuilder.setDlSrcAddress(new MacAddress("00:00:00:02:03:04"));
    dlSrcCaseBuilder.setSetDlSrcAction(dlSrcBuilder.build());
    actionBuilder.setActionChoice(dlSrcCaseBuilder.build());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    SetDlDstCaseBuilder dlDstCaseBuilder = new SetDlDstCaseBuilder();
    SetDlDstActionBuilder dlDstBuilder = new SetDlDstActionBuilder();
    dlDstBuilder.setDlDstAddress(new MacAddress("00:00:00:01:02:03"));
    dlDstCaseBuilder.setSetDlDstAction(dlDstBuilder.build());
    actionBuilder.setActionChoice(dlDstCaseBuilder.build());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    SetNwSrcCaseBuilder nwSrcCaseBuilder = new SetNwSrcCaseBuilder();
    SetNwSrcActionBuilder nwSrcBuilder = new SetNwSrcActionBuilder();
    nwSrcBuilder.setIpAddress(new Ipv4Address("10.0.0.1"));
    nwSrcCaseBuilder.setSetNwSrcAction(nwSrcBuilder.build());
    actionBuilder.setActionChoice(nwSrcCaseBuilder.build());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    SetNwDstCaseBuilder nwDstCaseBuilder = new SetNwDstCaseBuilder();
    SetNwDstActionBuilder nwDstBuilder = new SetNwDstActionBuilder();
    nwDstBuilder.setIpAddress(new Ipv4Address("10.0.0.3"));
    nwDstCaseBuilder.setSetNwDstAction(nwDstBuilder.build());
    actionBuilder.setActionChoice(nwDstCaseBuilder.build());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    SetNwTosCaseBuilder tosCaseBuilder = new SetNwTosCaseBuilder();
    SetNwTosActionBuilder tosBuilder = new SetNwTosActionBuilder();
    tosBuilder.setNwTos((short) 204);
    tosCaseBuilder.setSetNwTosAction(tosBuilder.build());
    actionBuilder.setActionChoice(tosCaseBuilder.build());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    SetTpSrcCaseBuilder tpSrcCaseBuilder = new SetTpSrcCaseBuilder();
    SetTpSrcActionBuilder tpSrcBuilder = new SetTpSrcActionBuilder();
    tpSrcBuilder.setPort(new PortNumber(6653L));
    tpSrcCaseBuilder.setSetTpSrcAction(tpSrcBuilder.build());
    actionBuilder.setActionChoice(tpSrcCaseBuilder.build());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    SetTpDstCaseBuilder tpDstCaseBuilder = new SetTpDstCaseBuilder();
    SetTpDstActionBuilder tpDstBuilder = new SetTpDstActionBuilder();
    tpDstBuilder.setPort(new PortNumber(6633L));
    tpDstCaseBuilder.setSetTpDstAction(tpDstBuilder.build());
    actionBuilder.setActionChoice(tpDstCaseBuilder.build());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    EnqueueCaseBuilder enqueueCaseBuilder = new EnqueueCaseBuilder();
    EnqueueActionBuilder enqueueBuilder = new EnqueueActionBuilder();
    enqueueBuilder.setPort(new PortNumber(6613L));
    enqueueBuilder.setQueueId(new QueueId(400L));
    enqueueCaseBuilder.setEnqueueAction(enqueueBuilder.build());
    actionBuilder.setActionChoice(enqueueCaseBuilder.build());
    actions.add(actionBuilder.build());
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    ListSerializer.serializeList(actions, TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF10_VERSION_ID), registry, out);
    Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort());
    Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
    Assert.assertEquals("Wrong port", 42, out.readUnsignedShort());
    Assert.assertEquals("Wrong max-length", 32, out.readUnsignedShort());
    Assert.assertEquals("Wrong action type", 1, out.readUnsignedShort());
    Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
    Assert.assertEquals("Wrong vlan-vid", 15, out.readUnsignedShort());
    out.skipBytes(2);
    Assert.assertEquals("Wrong action type", 2, out.readUnsignedShort());
    Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
    Assert.assertEquals("Wrong vlan-pcp", 16, out.readUnsignedByte());
    out.skipBytes(3);
    Assert.assertEquals("Wrong action type", 3, out.readUnsignedShort());
    Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
    out.skipBytes(4);
    Assert.assertEquals("Wrong action type", 4, out.readUnsignedShort());
    Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort());
    byte[] data = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
    out.readBytes(data);
    Assert.assertArrayEquals("Wrong dl-address", ByteBufUtils.macAddressToBytes("00:00:00:02:03:04"), data);
    out.skipBytes(6);
    Assert.assertEquals("Wrong action type", 5, out.readUnsignedShort());
    Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort());
    data = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
    out.readBytes(data);
    Assert.assertArrayEquals("Wrong dl-address", ByteBufUtils.macAddressToBytes("00:00:00:01:02:03"), data);
    out.skipBytes(6);
    Assert.assertEquals("Wrong action type", 6, out.readUnsignedShort());
    Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
    Assert.assertEquals("Wrong ip-address(1)", 10, out.readUnsignedByte());
    Assert.assertEquals("Wrong ip-address(2)", 0, out.readUnsignedByte());
    Assert.assertEquals("Wrong ip-address(3)", 0, out.readUnsignedByte());
    Assert.assertEquals("Wrong ip-address(4)", 1, out.readUnsignedByte());
    Assert.assertEquals("Wrong action type", 7, out.readUnsignedShort());
    Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
    Assert.assertEquals("Wrong ip-address(1)", 10, out.readUnsignedByte());
    Assert.assertEquals("Wrong ip-address(2)", 0, out.readUnsignedByte());
    Assert.assertEquals("Wrong ip-address(3)", 0, out.readUnsignedByte());
    Assert.assertEquals("Wrong ip-address(4)", 3, out.readUnsignedByte());
    Assert.assertEquals("Wrong action type", 8, out.readUnsignedShort());
    Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
    Assert.assertEquals("Wrong nw-tos", 204, out.readUnsignedByte());
    out.skipBytes(3);
    Assert.assertEquals("Wrong action type", 9, out.readUnsignedShort());
    Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
    Assert.assertEquals("Wrong port", 6653, out.readUnsignedShort());
    out.skipBytes(2);
    Assert.assertEquals("Wrong action type", 10, out.readUnsignedShort());
    Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
    Assert.assertEquals("Wrong port", 6633, out.readUnsignedShort());
    out.skipBytes(2);
    Assert.assertEquals("Wrong action type", 11, out.readUnsignedShort());
    Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort());
    Assert.assertEquals("Wrong port", 6613, out.readUnsignedShort());
    out.skipBytes(6);
    Assert.assertEquals("Wrong queue-id", 400, out.readUnsignedInt());
    Assert.assertTrue("Written more bytes than needed", out.readableBytes() == 0);
}
Also used : OutputActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) SetVlanPcpCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanPcpCaseBuilder) SetTpSrcActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.tp.src._case.SetTpSrcActionBuilder) SetTpDstActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.tp.dst._case.SetTpDstActionBuilder) SetVlanVidActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.vlan.vid._case.SetVlanVidActionBuilder) SetDlSrcActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.dl.src._case.SetDlSrcActionBuilder) SetNwSrcActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.src._case.SetNwSrcActionBuilder) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder) SetDlDstActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.dl.dst._case.SetDlDstActionBuilder) SetNwTosActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.tos._case.SetNwTosActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) SetNwDstActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.dst._case.SetNwDstActionBuilder) SetVlanPcpActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.vlan.pcp._case.SetVlanPcpActionBuilder) EnqueueActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.enqueue._case.EnqueueActionBuilder) SetTpSrcActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.tp.src._case.SetTpSrcActionBuilder) ArrayList(java.util.ArrayList) SetDlDstCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlDstCaseBuilder) SetNwTosCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTosCaseBuilder) SetNwTosActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.tos._case.SetNwTosActionBuilder) SetDlDstActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.dl.dst._case.SetDlDstActionBuilder) ByteBuf(io.netty.buffer.ByteBuf) SetVlanPcpActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.vlan.pcp._case.SetVlanPcpActionBuilder) SetTpSrcCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpSrcCaseBuilder) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder) SetDlSrcCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlSrcCaseBuilder) SetVlanVidCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanVidCaseBuilder) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) SetTpDstCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpDstCaseBuilder) SetNwDstCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCaseBuilder) QueueId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) EnqueueActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.enqueue._case.EnqueueActionBuilder) StripVlanCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCaseBuilder) EnqueueCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.EnqueueCaseBuilder) SetVlanVidActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.vlan.vid._case.SetVlanVidActionBuilder) SetNwDstActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.dst._case.SetNwDstActionBuilder) SetNwSrcActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.src._case.SetNwSrcActionBuilder) SetNwSrcCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwSrcCaseBuilder) SetTpDstActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.tp.dst._case.SetTpDstActionBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) SetDlSrcActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.dl.src._case.SetDlSrcActionBuilder) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)5 SetNwTosActionCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder)5 SetNwTosActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder)5 Test (org.junit.Test)4 SetDlSrcActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder)4 SetNwDstActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder)4 SetNwSrcActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder)4 SetVlanIdActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder)4 SetVlanPcpActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder)4 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)3 SetDlDstActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder)3 SetTpDstActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstActionBuilder)3 SetTpSrcActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder)3 StripVlanActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.strip.vlan.action._case.StripVlanActionBuilder)3 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)3 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder)3 OutputActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder)3 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder)3 BigInteger (java.math.BigInteger)2 List (java.util.List)2