use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match in project openflowplugin by opendaylight.
the class Test method createMatchBld.
private static MatchBuilder createMatchBld() {
MatchBuilder match = new MatchBuilder();
Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
ipv4Match.setIpv4Destination(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.model.match.types.rev131026.match.layer._3.match.Ipv4Match in project openflowplugin by opendaylight.
the class Ipv4DestinationEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final Match ipv4match = new MatchBuilder().setLayer3Match(new Ipv4MatchBuilder().setIpv4Destination(new Ipv4Prefix("10.0.2.0/24")).build()).build();
assertMatch(ipv4match, 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 ipv4matchNoMask = new MatchBuilder().setLayer3Match(new Ipv4MatchBuilder().setIpv4Destination(new Ipv4Prefix("10.0.0.0/32")).build()).build();
assertMatch(ipv4matchNoMask, false, (out) -> {
byte[] address = new byte[4];
out.readBytes(address);
assertArrayEquals(address, new byte[] { 10, 0, 0, 0 });
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match in project openflowplugin by opendaylight.
the class TunnelIpv4DestinationEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final Match ipv4match = new MatchBuilder().setLayer3Match(new TunnelIpv4MatchBuilder().setTunnelIpv4Destination(new Ipv4Prefix("10.0.2.0/24")).build()).build();
assertMatch(ipv4match, 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 ipv4matchNoMask = new MatchBuilder().setLayer3Match(new TunnelIpv4MatchBuilder().setTunnelIpv4Destination(new Ipv4Prefix("10.0.0.0/32")).build()).build();
assertMatch(ipv4matchNoMask, false, (out) -> {
byte[] address = new byte[4];
out.readBytes(address);
assertArrayEquals(address, new byte[] { 10, 0, 0, 0 });
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match in project openflowplugin by opendaylight.
the class SimpleDropFirewallCli method createTcpFlow.
/**
* Form of input is: node name node-connector number source ip-address destinatinon ip-address.
*
* @param cliInput
* Parsed input from CLI
*/
public AddFlowInput createTcpFlow(final List<String> cliInput) {
AddFlowInputBuilder ret = new AddFlowInputBuilder();
ret.setNode(nodeFromString(cliInput.get(0)));
// We construct a match
MatchBuilder match = new MatchBuilder();
Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
ipv4Match.setIpv4Source(new Ipv4Prefix(cliInput.get(3)));
ipv4Match.setIpv4Destination(new Ipv4Prefix(cliInput.get(4)));
match.setLayer3Match(ipv4Match.build());
match.setLayer4Match(new TcpMatchBuilder().build());
ret.setMatch(match.build());
DropActionCase dropAction = new DropActionCaseBuilder().build();
ActionBuilder action = new ActionBuilder();
action.setAction(dropAction);
List<Action> actions = Collections.singletonList(action.build());
//
ApplyActionsCaseBuilder aaBldr = new ApplyActionsCaseBuilder();
aaBldr.setApplyActions(new ApplyActionsBuilder().setAction(actions).build());
InstructionBuilder instructionBldr = new InstructionBuilder();
instructionBldr.setInstruction(aaBldr.build());
List<Instruction> isntructions = Collections.singletonList(instructionBldr.build());
InstructionsBuilder instructionsBldr = new InstructionsBuilder();
instructionsBldr.setInstruction(isntructions);
ret.setInstructions(instructionsBldr.build());
return ret.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match in project openflowplugin by opendaylight.
the class OpenflowPluginBulkGroupTransactionProvider method createMatch1.
private static MatchBuilder createMatch1() {
MatchBuilder match = new MatchBuilder();
Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
ipv4Match.setIpv4Destination(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;
}
Aggregations