use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method createAppyActionInstruction25.
private static InstructionsBuilder createAppyActionInstruction25() {
final List<Action> actionList = new ArrayList<>();
final ActionBuilder ab = new ActionBuilder();
final SetNextHopActionBuilder setNextHopActionBuilder = new SetNextHopActionBuilder();
final Ipv4Builder ipnext = new Ipv4Builder();
final Ipv4Prefix prefix = new Ipv4Prefix(IPV4_PREFIX);
ipnext.setIpv4Address(prefix);
setNextHopActionBuilder.setAddress(ipnext.build());
ab.setAction(new SetNextHopActionCaseBuilder().setSetNextHopAction(setNextHopActionBuilder.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.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix in project openflowplugin by opendaylight.
the class OpenflowPluginBulkGroupTransactionProvider method createMatch2.
private static MatchBuilder createMatch2() {
MatchBuilder match = new MatchBuilder();
Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1");
ipv4Match.setIpv4Source(prefix);
Ipv4Match i4m = ipv4Match.build();
match.setLayer3Match(i4m);
EthernetMatchBuilder eth = new EthernetMatchBuilder();
EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x0800L));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
return match;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix in project openflowplugin by opendaylight.
the class AbstractMatchEntrySerializer method writeIpv4Prefix.
/**
* Serialize Ipv4 prefix (address and mask).
*
* @param prefix Ipv4 prefix
* @param outBuffer output buffer
*/
protected static void writeIpv4Prefix(final Ipv4Prefix prefix, final ByteBuf outBuffer) {
// Split address to IP and mask
final Iterator<String> addressParts = IpConversionUtil.splitToParts(prefix);
// Write address part of prefix
writeIpv4Address(new Ipv4Address(addressParts.next()), outBuffer);
// If prefix had mask, also write prefix
Optional.ofNullable(MatchConvertorUtil.extractIpv4Mask(addressParts)).ifPresent(mask -> writeMask(mask, outBuffer, EncodeConstants.GROUPS_IN_IPV4_ADDRESS));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix in project openflowplugin by opendaylight.
the class OfToSalIpv6SrcCase method setIpv6MatchBuilderFields.
private static void setIpv6MatchBuilderFields(final Ipv6MatchBuilder builder, final byte[] mask, final Ipv6Address prefix) {
Ipv6Prefix ipv6Prefix;
if (mask != null) {
ipv6Prefix = IpConversionUtil.createPrefix(prefix, mask);
} else {
ipv6Prefix = IpConversionUtil.createPrefix(prefix);
}
builder.setIpv6Source(ipv6Prefix);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix in project openflowplugin by opendaylight.
the class WriteActionsInstructionSerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final int order = 0;
final Ipv4Prefix prefix = new Ipv4Prefix("192.168.76.0/32");
final Instruction instruction = new WriteActionsCaseBuilder().setWriteActions(new WriteActionsBuilder().setAction(Collections.singletonList(new ActionBuilder().setOrder(order).setKey(new ActionKey(order)).setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(new SetNwSrcActionBuilder().setAddress(new Ipv4Builder().setIpv4Address(prefix).build()).build()).build()).build())).build()).build();
assertInstruction(instruction, out -> {
out.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
assertEquals(out.readUnsignedShort(), ActionConstants.SET_FIELD_CODE);
// Skip length of set field action
out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
assertEquals(out.readUnsignedShort(), OxmMatchConstants.OPENFLOW_BASIC_CLASS);
assertEquals(out.readUnsignedByte(), OxmMatchConstants.IPV4_SRC << 1);
// Skip match entry length
out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
byte[] addressBytes = new byte[4];
out.readBytes(addressBytes);
assertArrayEquals(addressBytes, new byte[] { (byte) 192, (byte) 168, 76, 0 });
// Padding at end
out.skipBytes(4);
});
}
Aggregations