Search in sources :

Example 1 with LrsBits

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop.LrsBits in project lispflowmapping by opendaylight.

the class LispAddressUtil method asTeLcafRloc.

public static Rloc asTeLcafRloc(List<IpAddress> hopList) {
    ExplicitLocatorPathBuilder teAddrBuilder = new ExplicitLocatorPathBuilder();
    teAddrBuilder.setHop(new ArrayList<Hop>());
    for (IpAddress hop : hopList) {
        HopBuilder hopBuilder = new HopBuilder();
        hopBuilder.setAddress(new SimpleAddress(hop));
        hopBuilder.setHopId("Hop " + teAddrBuilder.getHop().size());
        hopBuilder.setLrsBits(new LrsBits(false, false, false));
        teAddrBuilder.getHop().add(hopBuilder.build());
    }
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPathBuilder elpBuilder = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPathBuilder();
    elpBuilder.setExplicitLocatorPath(teAddrBuilder.build());
    RlocBuilder teBuilder = new RlocBuilder();
    teBuilder.setAddress(elpBuilder.build());
    teBuilder.setAddressType(ExplicitLocatorPathLcaf.class);
    return teBuilder.build();
}
Also used : LrsBits(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop.LrsBits) Preconditions(com.google.common.base.Preconditions) HopBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.HopBuilder) Hop(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop) ExplicitLocatorPathBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.ExplicitLocatorPathBuilder) RlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)

Example 2 with LrsBits

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop.LrsBits in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTest method registerAndQuery__TrafficEngineering.

public void registerAndQuery__TrafficEngineering() throws SocketTimeoutException {
    cleanUP();
    String macString = "01:02:03:04:05:06";
    String ipString = "10.20.255.30";
    HopBuilder hopBuilder = new HopBuilder();
    hopBuilder.setAddress(new SimpleAddress(new IpAddress(new Ipv4Address(ipString))));
    hopBuilder.setLrsBits(new LrsBits(true, false, true));
    Hop hop1 = hopBuilder.build();
    hopBuilder.setAddress(new SimpleAddress(new MacAddress(macString)));
    hopBuilder.setLrsBits(new LrsBits(false, true, false));
    Hop hop2 = hopBuilder.build();
    ExplicitLocatorPathBuilder elpBuilder = new ExplicitLocatorPathBuilder();
    elpBuilder.setHop(new ArrayList<Hop>());
    elpBuilder.getHop().add(hop1);
    elpBuilder.getHop().add(hop2);
    EidBuilder eb = new EidBuilder();
    eb.setAddressType(ExplicitLocatorPathLcaf.class);
    eb.setVirtualNetworkId(null);
    eb.setAddress(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPathBuilder().setExplicitLocatorPath(elpBuilder.build()).build());
    MapReply reply = registerAddressAndQuery(eb.build());
    assertEquals(ExplicitLocatorPathLcaf.class, reply.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddressType());
    ExplicitLocatorPath receivedAddress = (ExplicitLocatorPath) reply.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddress();
    Hop receivedHop1 = (Hop) receivedAddress.getExplicitLocatorPath().getHop().get(0);
    Hop receivedHop2 = (Hop) receivedAddress.getExplicitLocatorPath().getHop().get(1);
    assertEquals(true, receivedHop1.getLrsBits().isLookup());
    assertEquals(false, receivedHop1.getLrsBits().isRlocProbe());
    assertEquals(true, receivedHop1.getLrsBits().isStrict());
    assertEquals(false, receivedHop2.getLrsBits().isLookup());
    assertEquals(true, receivedHop2.getLrsBits().isRlocProbe());
    assertEquals(false, receivedHop2.getLrsBits().isStrict());
    assertNotNull(receivedHop1.getAddress().getIpAddress().getIpv4Address());
    assertNotNull(receivedHop2.getAddress().getMacAddress());
    assertEquals(ipString, receivedHop1.getAddress().getIpAddress().getIpv4Address().getValue());
    assertEquals(macString, receivedHop2.getAddress().getMacAddress().getValue());
}
Also used : LrsBits(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop.LrsBits) HopBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.HopBuilder) MapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply) GotMapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply) Hop(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ExplicitLocatorPathBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.ExplicitLocatorPathBuilder) SourceEidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder) EidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) ExplicitLocatorPath(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPath)

Example 3 with LrsBits

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop.LrsBits in project lispflowmapping by opendaylight.

the class LispAddressUtilTest method asTeLcafRloc.

/**
 * Tests {@link LispAddressUtil#asSrcDstEid(SourceDestKey, InstanceIdType)}  method.
 */
@Test
public void asTeLcafRloc() {
    final List<IpAddress> ipAddresses = Arrays.asList(IP_ADDRESS_IPV4_TEST, IP_ADDRESS_IPV6_TEST);
    final Rloc rloc = LispAddressUtil.asTeLcafRloc(ipAddresses);
    assertNotNull(rloc);
    assertEquals(ExplicitLocatorPathLcaf.class, rloc.getAddressType());
    final List<Hop> hops = ((ExplicitLocatorPath) rloc.getAddress()).getExplicitLocatorPath().getHop();
    assertEquals(hops.size(), ipAddresses.size());
    for (IpAddress ipAddress : ipAddresses) {
        assertTrue("Ip address " + ipAddress + "should be part of hops list.", isIpAddressInHops(ipAddress, hops));
    }
    for (Hop hop : hops) {
        final Hop.LrsBits lrsBits = hop.getLrsBits();
        assertFalse(lrsBits.isLookup());
        assertFalse(lrsBits.isRlocProbe());
        assertFalse(lrsBits.isStrict());
        final IpAddress ipAddressFromHop = hop.getAddress().getIpAddress();
        assertNotNull(ipAddressFromHop);
    }
}
Also used : Rloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc) Hop(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Test(org.junit.Test)

Example 4 with LrsBits

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop.LrsBits in project lispflowmapping by opendaylight.

the class ExplicitLocatorPathSerializer method deserializeData.

private Address deserializeData(ByteBuffer buffer, short lcafLength, LispAddressSerializerContext ctx) {
    List<Hop> hops = new ArrayList<Hop>();
    short length = lcafLength;
    while (length > 0) {
        byte flags = (byte) buffer.getShort();
        boolean lookup = ByteUtil.extractBit(flags, Flags.LOOKUP);
        boolean rlocProbe = ByteUtil.extractBit(flags, Flags.RLOC_PROBE);
        boolean strict = ByteUtil.extractBit(flags, Flags.STRICT);
        SimpleAddress address = SimpleAddressSerializer.getInstance().deserialize(buffer, ctx);
        HopBuilder builder = new HopBuilder();
        builder.setLrsBits(new LrsBits(lookup, rlocProbe, strict));
        builder.setAddress(address);
        builder.setHopId("Hop " + (hops.size() + 1));
        length -= SimpleAddressSerializer.getInstance().getAddressSize(address) + 2;
        hops.add(builder.build());
    }
    return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPathBuilder().setExplicitLocatorPath(new ExplicitLocatorPathBuilder().setHop(hops).build()).build();
}
Also used : LrsBits(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop.LrsBits) HopBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.HopBuilder) Hop(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop) ArrayList(java.util.ArrayList) ExplicitLocatorPathBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.ExplicitLocatorPathBuilder) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)

Example 5 with LrsBits

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop.LrsBits in project lispflowmapping by opendaylight.

the class LispAddressStringifier method getStringFromExplicitLocatorPath.

protected static String getStringFromExplicitLocatorPath(Destination dst, ExplicitLocatorPath addr) {
    // AFI = 16387, LCAF Type 10, Explicit Locator Path
    // Example rendering:
    // {192.0.2.1->192.0.2.2|lps->192.0.2.3}
    List<Hop> hops = addr.getExplicitLocatorPath().getHop();
    StringBuilder sb = new StringBuilder();
    sb.append("{");
    boolean needArrow = false;
    for (Hop hop : hops) {
        if (needArrow) {
            sb.append("->");
        }
        sb.append(LispSimpleAddressStringifier.getString(dst, hop.getAddress()));
        LrsBits lrs = hop.getLrsBits();
        if (lrs.isLookup() || lrs.isRlocProbe() || lrs.isStrict()) {
            sb.append("|");
        }
        if (lrs.isLookup()) {
            sb.append("l");
        }
        if (lrs.isRlocProbe()) {
            sb.append("p");
        }
        if (lrs.isStrict()) {
            sb.append("s");
        }
        needArrow = true;
    }
    sb.append("}");
    return sb.toString();
}
Also used : LrsBits(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop.LrsBits) Hop(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop)

Aggregations

Hop (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop)5 LrsBits (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop.LrsBits)4 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)3 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)3 ExplicitLocatorPathBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.ExplicitLocatorPathBuilder)3 HopBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.HopBuilder)3 Preconditions (com.google.common.base.Preconditions)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)1 ExplicitLocatorPath (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPath)1 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)1 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)1 MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)1 EidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder)1 SourceEidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder)1 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)1 RlocBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder)1