Search in sources :

Example 31 with Ipv4Match

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 MatchV10Convertor method convertL3Ipv4DstMatch.

/**
 * Method splits the IP address and its mask and set their respective values in MatchV10Builder instance.
 * Wildcard value of the IP mask will be determined by Openflow java encoding library.
 *
 * @param matchBuilder match builder
 * @param ipv4         ip v4 match
 */
private static void convertL3Ipv4DstMatch(final MatchV10Builder matchBuilder, final Ipv4Match ipv4) {
    if (ipv4.getIpv4Destination() != null) {
        Iterator<String> addressParts = IpConversionUtil.PREFIX_SPLITTER.split(ipv4.getIpv4Destination().getValue()).iterator();
        Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
        Integer prefix = buildPrefix(addressParts);
        matchBuilder.setNwDst(ipv4Address);
        matchBuilder.setNwDstMask(prefix.shortValue());
    }
}
Also used : Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 32 with Ipv4Match

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 MatchV10ResponseConvertorTest method test.

/**
 * Test {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
 */
@Test
public void test() {
    MatchV10Builder builder = new MatchV10Builder();
    builder.setWildcards(new FlowWildcardsV10(false, false, false, false, false, false, false, false, false, false));
    builder.setNwSrcMask((short) 24);
    builder.setNwDstMask((short) 16);
    builder.setInPort(6653);
    builder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
    builder.setDlDst(new MacAddress("02:02:02:02:02:02"));
    builder.setDlVlan(128);
    builder.setDlVlanPcp((short) 2);
    builder.setDlType(15);
    builder.setNwTos((short) 16);
    builder.setNwProto((short) 6);
    builder.setNwSrc(new Ipv4Address("1.1.1.2"));
    builder.setNwDst(new Ipv4Address("32.16.8.1"));
    builder.setTpSrc(2048);
    builder.setTpDst(4096);
    MatchV10 match = builder.build();
    final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
    datapathIdConvertorData.setDatapathId(new BigInteger("42"));
    final Match salMatch = convert(match, datapathIdConvertorData).build();
    Assert.assertEquals("Wrong in port", "openflow:42:6653", salMatch.getInPort().getValue());
    Assert.assertEquals("Wrong dl src", new MacAddress("01:01:01:01:01:01"), salMatch.getEthernetMatch().getEthernetSource().getAddress());
    Assert.assertEquals("Wrong dl dst", new MacAddress("02:02:02:02:02:02"), salMatch.getEthernetMatch().getEthernetDestination().getAddress());
    Assert.assertEquals("Wrong dl type", 15, salMatch.getEthernetMatch().getEthernetType().getType().getValue().intValue());
    Assert.assertEquals("Wrong dl vlan", 128, salMatch.getVlanMatch().getVlanId().getVlanId().getValue().intValue());
    Assert.assertEquals("Wrong dl vlan pcp", 2, salMatch.getVlanMatch().getVlanPcp().getValue().intValue());
    Ipv4Match ipv4Match = (Ipv4Match) salMatch.getLayer3Match();
    Assert.assertEquals("Wrong nw src address", "1.1.1.2/24", ipv4Match.getIpv4Source().getValue());
    Assert.assertEquals("Wrong nw dst address", "32.16.8.1/16", ipv4Match.getIpv4Destination().getValue());
    Assert.assertEquals("Wrong ip protocol", 6, salMatch.getIpMatch().getIpProtocol().intValue());
    Assert.assertEquals("Wrong ip proto", null, salMatch.getIpMatch().getIpProto());
    Assert.assertEquals("Wrong ip ecn", null, salMatch.getIpMatch().getIpEcn());
    Assert.assertEquals("Wrong ip dscp", 4, salMatch.getIpMatch().getIpDscp().getValue().intValue());
    TcpMatch tcpMatch = (TcpMatch) salMatch.getLayer4Match();
    Assert.assertEquals("Wrong tp dst", 4096, tcpMatch.getTcpDestinationPort().getValue().intValue());
    Assert.assertEquals("Wrong tp src", 2048, tcpMatch.getTcpSourcePort().getValue().intValue());
    Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
}
Also used : TcpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch) FlowWildcardsV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) MatchV10Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder) BigInteger(java.math.BigInteger) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) MatchV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10) Ipv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) TcpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch) UdpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch) Icmpv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match) EthernetMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match) Ipv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match) IpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch) Test(org.junit.Test)

Example 33 with Ipv4Match

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 OpenflowPluginBulkTransactionProvider method createMatch1000.

private static MatchBuilder createMatch1000() {
    MatchBuilder match = new MatchBuilder();
    Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
    Ipv4Prefix prefix = new Ipv4Prefix("10.1.1.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;
}
Also used : Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) EthernetTypeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder) EtherType(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType) 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) IpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder) Icmpv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Ipv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)

Example 34 with Ipv4Match

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

the class ActionSetDestinationIpTest method verifyAction.

private void verifyAction(Action action) {
    assertTrue(action.getAction() instanceof SetFieldCase);
    SetFieldCase actionCase = (SetFieldCase) action.getAction();
    assertNotNull(actionCase.getSetField().getLayer3Match());
    assertTrue(actionCase.getSetField().getLayer3Match() instanceof Ipv4Match);
    Ipv4Match ipv4Match = (Ipv4Match) actionCase.getSetField().getLayer3Match();
    assertEquals(new Ipv4Prefix(IP_ADDRESS + "/" + IP_MASK), ipv4Match.getIpv4Destination());
}
Also used : SetFieldCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase) Ipv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)

Example 35 with Ipv4Match

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

the class ActionSetSourceIpTest method verifyAction.

private void verifyAction(Action action) {
    assertTrue(action.getAction() instanceof SetFieldCase);
    SetFieldCase actionCase = (SetFieldCase) action.getAction();
    assertNotNull(actionCase.getSetField().getLayer3Match());
    assertTrue(actionCase.getSetField().getLayer3Match() instanceof Ipv4Match);
    Ipv4Match ipv4Match = (Ipv4Match) actionCase.getSetField().getLayer3Match();
    assertEquals(new Ipv4Prefix(IP_ADDRESS + "/" + IP_MASK), ipv4Match.getIpv4Source());
}
Also used : SetFieldCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase) Ipv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)

Aggregations

Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)26 Ipv4Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match)22 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)19 Ipv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder)18 EtherType (org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType)11 EthernetTypeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder)11 EthernetMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)11 Test (org.junit.Test)10 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)10 Icmpv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder)6 IpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder)6 Ipv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder)6 TunnelIpv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder)6 ArrayList (java.util.ArrayList)5 BigInteger (java.math.BigInteger)4 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match)4 EthernetMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch)4 TcpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch)4 UdpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch)4 VersionDatapathIdConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)3