Search in sources :

Example 1 with SourceDestKeyBuilder

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKeyBuilder in project lispflowmapping by opendaylight.

the class LispAddressUtil method asSrcDst.

public static SourceDestKey asSrcDst(String src, String dst, int smask, int dmask) {
    SourceDestKeyBuilder builder = new SourceDestKeyBuilder();
    builder.setSource(new SimpleAddress(asIpPrefix(src, smask)));
    builder.setDest(new SimpleAddress(asIpPrefix(dst, dmask)));
    return builder.build();
}
Also used : SourceDestKeyBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKeyBuilder) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)

Example 2 with SourceDestKeyBuilder

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKeyBuilder in project lispflowmapping by opendaylight.

the class MaskUtil method normalizeSrcDst.

private static Eid normalizeSrcDst(Eid eid) throws UnknownHostException {
    final SimpleAddress normalizedSrc = normalizeSimpleAddress(((SourceDestKey) eid.getAddress()).getSourceDestKey().getSource());
    final SimpleAddress normalizedDst = normalizeSimpleAddress(((SourceDestKey) eid.getAddress()).getSourceDestKey().getDest());
    return LispAddressUtil.asSrcDstEid(new SourceDestKeyBuilder().setSource(normalizedSrc).setDest(normalizedDst).build(), eid.getVirtualNetworkId());
}
Also used : SourceDestKeyBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKeyBuilder) SourceDestKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)

Example 3 with SourceDestKeyBuilder

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKeyBuilder in project lispflowmapping by opendaylight.

the class LispAddressUtilTest method asSrcDstEid_addressesAsSrcDstKey.

/**
 * Tests {@link LispAddressUtil#asSrcDstEid(SourceDestKey, InstanceIdType)}  method.
 */
@Test
public void asSrcDstEid_addressesAsSrcDstKey() {
    final SourceDestKey expectedSourceDestKey = new SourceDestKeyBuilder().setSource(SIMPLE_ADDRESS_IPV4_PREFIX_TEST).setDest(SIMPLE_ADDRESS_IPV6_PREFIX_TEST).build();
    final Eid srcDstEid = LispAddressUtil.asSrcDstEid(expectedSourceDestKey, INSTANCE_ID_TYPE_TEST);
    assertNotNull(srcDstEid);
    assertEquals(SourceDestKeyLcaf.class, srcDstEid.getAddressType());
    final SourceDestKey testedSourceDestKey = ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey) srcDstEid.getAddress()).getSourceDestKey();
    assertNotNull(testedSourceDestKey);
    assertEquals(SIMPLE_ADDRESS_IPV4_PREFIX_TEST, testedSourceDestKey.getSource());
    assertEquals(SIMPLE_ADDRESS_IPV6_PREFIX_TEST, testedSourceDestKey.getDest());
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) SourceDestKeyBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKeyBuilder) SourceDestKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKey) Test(org.junit.Test)

Example 4 with SourceDestKeyBuilder

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKeyBuilder in project lispflowmapping by opendaylight.

the class SourceDestKeySerializer method deserializeData.

private Address deserializeData(ByteBuffer buffer, LispAddressSerializerContext ctx) {
    // reserved bytes
    buffer.getShort();
    short srcMaskLength = (short) ByteUtil.getUnsignedByte(buffer);
    short dstMaskLength = (short) ByteUtil.getUnsignedByte(buffer);
    ctx.setMaskLen(srcMaskLength);
    SimpleAddress srcAddress = SimpleAddressSerializer.getInstance().deserialize(buffer, ctx);
    ctx.setMaskLen(dstMaskLength);
    SimpleAddress dstAddress = SimpleAddressSerializer.getInstance().deserialize(buffer, ctx);
    SourceDestKeyBuilder sdb = new SourceDestKeyBuilder();
    sdb.setSource(srcAddress);
    sdb.setDest(dstAddress);
    return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKeyBuilder().setSourceDestKey(sdb.build()).build();
}
Also used : SourceDestKeyBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKeyBuilder) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)

Example 5 with SourceDestKeyBuilder

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKeyBuilder in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTest method registerAndQuery__SrcDestLCAF.

// ------------------------------- LCAF Tests ---------------------------
public void registerAndQuery__SrcDestLCAF() throws SocketTimeoutException {
    cleanUP();
    String ipPrefix = "10.20.30.200/32";
    String macString = "01:02:03:04:05:06";
    SourceDestKeyBuilder builder = new SourceDestKeyBuilder();
    builder.setSource(new SimpleAddress(new IpPrefix(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix(ipPrefix))));
    builder.setDest(new SimpleAddress(new MacAddress(macString)));
    EidBuilder eb = new EidBuilder();
    eb.setAddressType(SourceDestKeyLcaf.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.SourceDestKeyBuilder().setSourceDestKey(builder.build()).build());
    MapReply reply = registerAddressAndQuery(eb.build());
    Eid fromNetwork = reply.getMappingRecordItem().get(0).getMappingRecord().getEid();
    assertEquals(SourceDestKeyLcaf.class, fromNetwork.getAddressType());
    SourceDestKey sourceDestFromNetwork = (SourceDestKey) fromNetwork.getAddress();
    SimpleAddress receivedAddr1 = sourceDestFromNetwork.getSourceDestKey().getSource();
    SimpleAddress receivedAddr2 = sourceDestFromNetwork.getSourceDestKey().getDest();
    assertNotNull(receivedAddr1.getIpPrefix().getIpv4Prefix());
    assertNotNull(receivedAddr2.getMacAddress());
    IpPrefix receivedIP = receivedAddr1.getIpPrefix();
    MacAddress receivedMAC = receivedAddr2.getMacAddress();
    assertEquals(ipPrefix, receivedIP.getIpv4Prefix().getValue());
    assertEquals(macString, receivedMAC.getValue());
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) SourceDestKeyBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKeyBuilder) 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) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) 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) SourceDestKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)

Aggregations

SourceDestKeyBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKeyBuilder)7 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)6 Test (org.junit.Test)2 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)2 SourceDestKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey)2 SourceDestKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKey)2 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)2 EidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder)2 Preconditions (com.google.common.base.Preconditions)1 ByteBuffer (java.nio.ByteBuffer)1 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)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 LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)1 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)1 SourceEidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder)1