Search in sources :

Example 66 with Ipv4Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address in project bgpcep by opendaylight.

the class MatchOriginatorIdSetHandler method matchOriginatorCondition.

private boolean matchOriginatorCondition(final Ipv4Address localOriginatorId, final OriginatorId originatorId, final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev180109.match.originator.id.set.condition.grouping.MatchOriginatorIdSetCondition condition) {
    final OriginatorIdSet originatorIdSet = this.sets.getUnchecked(StringUtils.substringBetween(condition.getOriginatorIdSet(), "=\"", "\""));
    if (originatorIdSet == null) {
        return false;
    }
    boolean found = false;
    if (originatorId != null) {
        final Ipv4Address remOrigin = originatorId.getOriginator();
        if (originatorIdSet.getLocal() != null && localOriginatorId.equals(remOrigin)) {
            found = true;
        }
        if (!found && originatorIdSet.getOriginatorId() != null) {
            found = originatorIdSet.getOriginatorId().contains(remOrigin);
        }
    }
    final MatchSetOptionsRestrictedType matchOption = condition.getMatchSetOptions();
    return matchOption.equals(MatchSetOptionsRestrictedType.ANY) && found || matchOption.equals(MatchSetOptionsRestrictedType.INVERT) && !found;
}
Also used : MatchSetOptionsRestrictedType(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.MatchSetOptionsRestrictedType) OriginatorIdSet(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev180109.originator.id.set.OriginatorIdSet) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 67 with Ipv4Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address in project bgpcep by opendaylight.

the class ExportAttributeTestUtil method createClusterId.

private static ClusterId createClusterId() {
    final ClusterIdentifier cluster1 = new ClusterIdentifier(new Ipv4Address("1.1.1.1"));
    final ClusterIdentifier cluster2 = new ClusterIdentifier(new Ipv4Address("1.1.1.2"));
    return new ClusterIdBuilder().setCluster(Arrays.asList(CLUSTER, cluster1, cluster2)).build();
}
Also used : ClusterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier) ClusterIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ClusterIdBuilder) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 68 with Ipv4Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address in project bgpcep by opendaylight.

the class IPAddressesAndPrefixesTest method testInetAddressToIpAddress.

@Test
public void testInetAddressToIpAddress() {
    final IpAddress ipAddress = Ipv4Util.getIpAddress(InetAddresses.forString("123.42.13.8"));
    Assert.assertNotNull(ipAddress.getIpv4Address());
    Assert.assertEquals(new Ipv4Address("123.42.13.8"), ipAddress.getIpv4Address());
    final IpAddress ipAddress2 = Ipv4Util.getIpAddress(InetAddresses.forString("2001:db8:1:2::"));
    Assert.assertNotNull(ipAddress2.getIpv6Address());
    Assert.assertEquals(new Ipv6Address("2001:db8:1:2::"), ipAddress2.getIpv6Address());
}
Also used : IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 69 with Ipv4Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address in project openflowplugin by opendaylight.

the class Ipv4SourceEntryDeserializer method deserializeEntry.

@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
    final boolean hasMask = processHeader(message);
    final Ipv4Address address = ByteBufUtils.readIetfIpv4Address(message);
    if (hasMask) {
        final byte[] mask = OxmDeserializerHelper.convertMask(message, EncodeConstants.GROUPS_IN_IPV4_ADDRESS);
        if (IpConversionUtil.isArbitraryBitMask(mask)) {
            setArbitraryMatch(builder, address, mask);
        } else {
            setPrefixMatch(builder, address, mask);
        }
    } else {
        setPrefixMatch(builder, address, null);
    }
}
Also used : Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 70 with Ipv4Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address in project openflowplugin by opendaylight.

the class AbstractMatchEntryDeserializer method readPrefix.

/**
 * Read Ipv4Prefix from message.
 * @param message buffered message
 * @param hasMask determines if prefix has mask or not
 * @return IPv4 prefix
 */
protected static Ipv4Prefix readPrefix(ByteBuf message, boolean hasMask) {
    final Ipv4Address address = ByteBufUtils.readIetfIpv4Address(message);
    int mask = 32;
    if (hasMask) {
        mask = IpConversionUtil.countBits(OxmDeserializerHelper.convertMask(message, EncodeConstants.GROUPS_IN_IPV4_ADDRESS));
    }
    return IpConversionUtil.createPrefix(address, mask);
}
Also used : Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Aggregations

Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)206 Test (org.junit.Test)116 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)59 ByteBuf (io.netty.buffer.ByteBuf)58 ArrayList (java.util.ArrayList)34 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)29 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)25 BigInteger (java.math.BigInteger)21 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)20 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)20 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)18 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)18 Ipv4NextHopCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv4NextHopCaseBuilder)18 Ipv4NextHopBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder)18 FlowWildcardsV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10)16 MatchV10Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder)14 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match)13 OriginBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.OriginBuilder)13 UpdateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.UpdateBuilder)12 ArpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch)11