Search in sources :

Example 16 with ItrRloc

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc in project lispflowmapping by opendaylight.

the class MapRequestUtilTest method selectItrRlocTest_Ipv4Binary.

/**
 * Tests {@link MapRequestUtil#selectItrRloc} method with Ipv4Binary.
 */
@Test
public void selectItrRlocTest_Ipv4Binary() {
    final ItrRlocBuilder itrRloc = new ItrRlocBuilder().setRloc(new RlocBuilder().setAddress(IPV4_ADDRESS_BINARY).build());
    final MapRequest request = new MapRequestBuilder().setItrRloc(Lists.newArrayList(itrRloc.build())).build();
    // expected result
    InetAddress expectedResult = InetAddresses.forString(IPV4_STRING);
    // result
    InetAddress result = MapRequestUtil.selectItrRloc(request);
    assertEquals(expectedResult, result);
}
Also used : MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest) ItrRlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder) RlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder) ItrRlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder) MapRequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestmessage.MapRequestBuilder) InetAddress(java.net.InetAddress) Test(org.junit.Test)

Example 17 with ItrRloc

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc in project lispflowmapping by opendaylight.

the class MapRequestSerializationTest method serialize__All.

@Test
public void serialize__All() throws Exception {
    MapRequestBuilder mrBuilder = new MapRequestBuilder();
    mrBuilder.setProbe(true);
    mrBuilder.setPitr(true);
    mrBuilder.setNonce((long) 13);
    mrBuilder.setSourceEid(new SourceEidBuilder().setEid(LispAddressUtil.asIpv4Eid(("10.0.0.1"))).build());
    mrBuilder.setItrRloc(new ArrayList<ItrRloc>());
    mrBuilder.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc("1.2.3.4")).build());
    mrBuilder.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv6Rloc("1:2:3:4:5:6:7:8")).build());
    mrBuilder.setEidItem(new ArrayList<EidItem>());
    mrBuilder.getEidItem().add(new EidItemBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("1.2.3.4/32")).build());
    ByteBuffer expected = hexToByteBuffer(// 
    "12 80 01 01 00 00 " + "00 00 00 00 00 0D 00 01 0a 00 00 01 00 01 01 02 03 04 00 02 00 01 00 02 00 03 00 04 00 05 00 06 " + "00 07 00 08 00 20 00 01 01 02 03 04");
    assertArrayEquals(expected.array(), MapRequestSerializer.getInstance().serialize(mrBuilder.build()).array());
}
Also used : ItrRloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc) ItrRlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder) SourceEidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder) MapRequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder) EidItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder) EidItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItem) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 18 with ItrRloc

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc in project lispflowmapping by opendaylight.

the class MapRequestSerializationTest method serialize__SingleItrRloc.

@Test
public void serialize__SingleItrRloc() throws Exception {
    MapRequestBuilder mrBuilder = new MapRequestBuilder();
    mrBuilder.setItrRloc(new ArrayList<ItrRloc>());
    mrBuilder.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc("1.2.3.4")).build());
    ByteBuffer expected = hexToByteBuffer(// 
    "10 00 00 00 00 00 " + "00 00 00 00 00 00 00 00 00 01 01 02 03 04");
    assertArrayEquals(expected.array(), MapRequestSerializer.getInstance().serialize(mrBuilder.build()).array());
}
Also used : ItrRloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc) ItrRlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder) MapRequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 19 with ItrRloc

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc in project lispflowmapping by opendaylight.

the class MapRequestSerializationTest method serialize__AllWithMapReply.

@Test
public void serialize__AllWithMapReply() throws Exception {
    MapRequestBuilder mapRequestBuilder = new MapRequestBuilder();
    mapRequestBuilder.setProbe(true);
    mapRequestBuilder.setMapDataPresent(true);
    mapRequestBuilder.setPitr(true);
    mapRequestBuilder.setNonce((long) 13);
    mapRequestBuilder.setSourceEid(new SourceEidBuilder().setEid(LispAddressUtil.asIpv4Eid(("10.0.0.1"))).build());
    mapRequestBuilder.setItrRloc(new ArrayList<ItrRloc>());
    mapRequestBuilder.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc("1.2.3.4")).build());
    mapRequestBuilder.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv6Rloc("1:2:3:4:5:6:7:8")).build());
    mapRequestBuilder.setEidItem(new ArrayList<EidItem>());
    mapRequestBuilder.getEidItem().add(new EidItemBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("1.2.3.4/32")).build());
    MappingRecordBuilder recordBuilder = new MappingRecordBuilder();
    recordBuilder.setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/0"));
    recordBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
    LocatorRecordBuilder locatorBuilder = new LocatorRecordBuilder();
    locatorBuilder.setRloc(LispAddressUtil.asIpv4Rloc("0.0.0.2"));
    recordBuilder.getLocatorRecord().add(locatorBuilder.build());
    MapReplyBuilder mapreplyBuilder = new MapReplyBuilder();
    mapreplyBuilder.setMappingRecord(recordBuilder.build());
    mapRequestBuilder.setMapReply(mapreplyBuilder.build());
    ByteBuffer expected = hexToByteBuffer("16 80 01 01 00 00 " + "00 00 00 00 00 0D 00 01 0a 00 00 01 00 01 01 02 03 04 00 02 00 01 00 02 00 03 00 04 00 05 00 06 " + // map
    "00 07 00 08 00 20 00 01 01 02 03 04 " + "00 00 00 00 01 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 01 00 00 00 02");
    assertArrayEquals(expected.array(), MapRequestSerializer.getInstance().serialize(mapRequestBuilder.build()).array());
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) MapReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.MapReplyBuilder) MapRequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder) EidItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder) EidItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItem) ByteBuffer(java.nio.ByteBuffer) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord) ItrRloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc) ItrRlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder) SourceEidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder) Test(org.junit.Test)

Example 20 with ItrRloc

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc in project lispflowmapping by opendaylight.

the class MapRequestUtil method prepareSMR.

public static MapRequestBuilder prepareSMR(Eid srcEid, Rloc itrRloc) {
    MapRequestBuilder builder = new MapRequestBuilder();
    builder.setAuthoritative(false);
    builder.setMapDataPresent(false);
    builder.setPitr(false);
    builder.setProbe(false);
    builder.setSmr(true);
    builder.setSmrInvoked(false);
    builder.setSourceEid(new SourceEidBuilder().setEid(srcEid).build());
    builder.setItrRloc(new ArrayList<ItrRloc>());
    builder.getItrRloc().add(new ItrRlocBuilder().setRloc(itrRloc).build());
    builder.setMapReply(null);
    builder.setNonce(new Random().nextLong());
    return builder;
}
Also used : ItrRloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc) Random(java.util.Random) ItrRlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder) SourceEidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder) MapRequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder)

Aggregations

ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)17 ItrRlocBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder)16 Test (org.junit.Test)11 MapRequestBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder)9 EidItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItem)8 EidItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder)7 SourceEidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder)7 MapRequest (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest)6 RlocBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder)6 ByteBuffer (java.nio.ByteBuffer)5 LocatorRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder)5 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)5 MapRequestBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestmessage.MapRequestBuilder)5 InetAddress (java.net.InetAddress)4 Subscriber (org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)3 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)3 LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)3 MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)3 ArrayList (java.util.ArrayList)2 Ignore (org.junit.Ignore)2