Search in sources :

Example 21 with MappingRecordItem

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem in project lispflowmapping by opendaylight.

the class MapNotifySerializationTest method serialize__NoPrefixInEidToLocator.

@Test
public void serialize__NoPrefixInEidToLocator() throws Exception {
    MapNotifyBuilder mnBuilder = new MapNotifyBuilder();
    mnBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
    mnBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(new MappingRecordBuilder().build()).build());
    mnBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(new MappingRecordBuilder().setEid(null).build()).build());
    mnBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(new MappingRecordBuilder().setEid(LispAddressUtil.getNoAddressEid()).build()).build());
    ByteBuffer bb = MapNotifySerializer.getInstance().serialize(mnBuilder.build());
    // jump to first record prefix AFI
    bb.position(bb.position() + 16);
    assertEquals(0, bb.getShort());
    // jump to second record prefix AFI
    bb.position(bb.position() + 10);
    assertEquals(0, bb.getShort());
    // jump to third record prefix AFI
    bb.position(bb.position() + 10);
    assertEquals(0, bb.getShort());
}
Also used : MappingRecordItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder) MappingRecordItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) MapNotifyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 22 with MappingRecordItem

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem in project lispflowmapping by opendaylight.

the class MapNotifySerializationTest method serialize__Fields.

@Test
public void serialize__Fields() throws Exception {
    MapNotifyBuilder mnBuilder = new MapNotifyBuilder();
    mnBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
    mnBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(new MappingRecordBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32")).build()).build());
    mnBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(new MappingRecordBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.73/32")).build()).build());
    mnBuilder.setNonce(6161616161L);
    mnBuilder.setKeyId((short) 0x0001);
    byte[] authenticationData = new byte[] { (byte) 0x16, (byte) 0x98, (byte) 0x96, (byte) 0xeb, (byte) 0x88, (byte) 0x2d, (byte) 0x4d, (byte) 0x22, (byte) 0xe5, (byte) 0x8f, (byte) 0xe6, (byte) 0x89, (byte) 0x64, (byte) 0xb9, (byte) 0x17, (byte) 0xa4, (byte) 0xba, (byte) 0x4e, (byte) 0x8c, (byte) 0x41 };
    mnBuilder.setAuthenticationData(authenticationData);
    ByteBuffer bb = MapNotifySerializer.getInstance().serialize(mnBuilder.build());
    // Type + MSByte of reserved
    assertHexEquals((byte) 0x40, bb.get());
    // Rest of reserved
    assertEquals(0, bb.getShort());
    // Record Count
    assertEquals(2, bb.get());
    // Nonce
    assertEquals(6161616161L, bb.getLong());
    // Key ID
    assertHexEquals((short) 0x0001, bb.getShort());
    assertEquals(authenticationData.length, bb.getShort());
    byte[] actualAuthenticationData = new byte[20];
    bb.get(actualAuthenticationData);
    ArrayAssert.assertEquals(authenticationData, actualAuthenticationData);
    bb.position(bb.position() + 12);
    /* EID in first record */
    assertEquals(0x1, bb.getInt());
    bb.position(bb.position() + 12);
    /* EID in second record */
    assertEquals(73, bb.getInt());
    assertEquals(bb.position(), bb.capacity());
}
Also used : MappingRecordItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder) MappingRecordItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) MapNotifyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 23 with MappingRecordItem

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem in project lispflowmapping by opendaylight.

the class MapNotifySerializationTest method serialize__NoAuthenticationData.

@Test
public void serialize__NoAuthenticationData() throws Exception {
    MapNotifyBuilder mnBuilder = new MapNotifyBuilder();
    mnBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
    mnBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(new MappingRecordBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32")).setRecordTtl(55).build()).build());
    ByteBuffer bb = MapNotifySerializer.getInstance().serialize(mnBuilder.build());
    // jump to AuthenticationDataLength
    bb.position(bb.position() + 14);
    assertEquals(0, bb.getShort());
    assertEquals(55, bb.getInt());
    mnBuilder.setAuthenticationData(null);
    bb = MapNotifySerializer.getInstance().serialize(mnBuilder.build());
    // jump to AuthenticationDataLength
    bb.position(bb.position() + 14);
    assertEquals(0, bb.getShort());
    assertEquals(55, bb.getInt());
    mnBuilder.setAuthenticationData(new byte[0]);
    bb = MapNotifySerializer.getInstance().serialize(mnBuilder.build());
    // jump to AuthenticationDataLength
    bb.position(bb.position() + 14);
    assertEquals(0, bb.getShort());
    assertEquals(55, bb.getInt());
}
Also used : MappingRecordItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder) MappingRecordItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) MapNotifyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 24 with MappingRecordItem

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem in project lispflowmapping by opendaylight.

the class MapRegisterSerializationTest method serialize__NoAuthenticationData.

@Test
public void serialize__NoAuthenticationData() throws Exception {
    MapRegisterBuilder mrBuilder = new MapRegisterBuilder();
    mrBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
    mrBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(new MappingRecordBuilder().setRecordTtl(55).setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32")).build()).build());
    // mrBuilder.addEidToLocator(new EidToLocatorRecord().setPrefix(new
    // LispIpv4Address(1)).setRecordTtl(55));
    ByteBuffer bb = MapRegisterSerializer.getInstance().serialize(mrBuilder.build());
    // jump to AuthenticationDataLength
    bb.position(bb.position() + 14);
    assertEquals(0, bb.getShort());
    assertEquals(55, bb.getInt());
    mrBuilder.setAuthenticationData(null);
    bb = MapRegisterSerializer.getInstance().serialize(mrBuilder.build());
    // jump to AuthenticationDataLength
    bb.position(bb.position() + 14);
    assertEquals(0, bb.getShort());
    assertEquals(55, bb.getInt());
    mrBuilder.setAuthenticationData(new byte[0]);
    bb = MapRegisterSerializer.getInstance().serialize(mrBuilder.build());
    // jump to AuthenticationDataLength
    bb.position(bb.position() + 14);
    assertEquals(0, bb.getShort());
    assertEquals(55, bb.getInt());
}
Also used : MappingRecordItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder) MappingRecordItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) ByteBuffer(java.nio.ByteBuffer) MapRegisterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregisternotification.MapRegisterBuilder) Test(org.junit.Test)

Example 25 with MappingRecordItem

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem in project lispflowmapping by opendaylight.

the class MapRegisterSerializationTest method serialize__Fields.

@Test
public void serialize__Fields() throws Exception {
    MapRegisterBuilder mrBuilder = new MapRegisterBuilder();
    mrBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
    MappingRecordBuilder recordBuilder = new MappingRecordBuilder();
    recordBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
    recordBuilder.setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32"));
    mrBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(recordBuilder.build()).build());
    recordBuilder.setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.73/32"));
    mrBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(recordBuilder.build()).build());
    mrBuilder.setNonce(6161616161L);
    mrBuilder.setKeyId((short) 0x0001);
    mrBuilder.setWantMapNotify(true);
    mrBuilder.setProxyMapReply(true);
    mrBuilder.setXtrSiteIdPresent(true);
    byte[] authenticationData = new byte[] { (byte) 0x16, (byte) 0x98, (byte) 0x96, (byte) 0xeb, (byte) 0x88, (byte) 0x2d, (byte) 0x4d, (byte) 0x22, (byte) 0xe5, (byte) 0x8f, (byte) 0xe6, (byte) 0x89, (byte) 0x64, (byte) 0xb9, (byte) 0x17, (byte) 0xa4, (byte) 0xba, (byte) 0x4e, (byte) 0x8c, (byte) 0x41 };
    mrBuilder.setAuthenticationData(authenticationData);
    XtrId xtrId = new XtrId(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01 });
    mrBuilder.setXtrId(xtrId);
    SiteId siteId = new SiteId(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01 });
    mrBuilder.setSiteId(siteId);
    ByteBuffer bb = MapRegisterSerializer.getInstance().serialize(mrBuilder.build());
    // Type + MSByte of reserved
    assertHexEquals((byte) 0x3a, bb.get());
    // Rest of reserved + want map notify
    assertEquals(1, bb.getShort());
    // Record Count
    assertEquals(2, bb.get());
    // Nonce
    assertEquals(6161616161L, bb.getLong());
    // Key ID
    assertHexEquals((short) 0x0001, bb.getShort());
    assertEquals(authenticationData.length, bb.getShort());
    byte[] actualAuthenticationData = new byte[20];
    bb.get(actualAuthenticationData);
    ArrayAssert.assertEquals(authenticationData, actualAuthenticationData);
    // EID in first record
    bb.position(bb.position() + 12);
    assertEquals(0x1, bb.getInt());
    // EID in second record
    bb.position(bb.position() + 12);
    assertEquals(73, bb.getInt());
    byte[] actualXtrId = new byte[Length.XTRID_SIZE];
    bb.get(actualXtrId);
    ArrayAssert.assertEquals(xtrId.getValue(), actualXtrId);
    byte[] actualSiteId = new byte[Length.SITEID_SIZE];
    bb.get(actualSiteId);
    ArrayAssert.assertEquals(siteId.getValue(), actualSiteId);
    assertEquals(bb.position(), bb.capacity());
}
Also used : MappingRecordItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder) SiteId(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.SiteId) MappingRecordItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) ByteBuffer(java.nio.ByteBuffer) MapRegisterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregisternotification.MapRegisterBuilder) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord) XtrId(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId) Test(org.junit.Test)

Aggregations

MappingRecordItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem)33 MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)23 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)20 Test (org.junit.Test)19 ByteBuffer (java.nio.ByteBuffer)17 LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)8 MapNotifyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder)8 MapReplyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder)8 MapRegisterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregisternotification.MapRegisterBuilder)7 ArrayList (java.util.ArrayList)4 MapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify)4 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)4 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)4 LispSerializationException (org.opendaylight.lispflowmapping.lisp.serializer.exception.LispSerializationException)3 MapRegister (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister)3 SiteId (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.SiteId)3 XtrId (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId)3 GotMapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapNotify)2 LocatorRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder)2 MappingAuthkey (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey)2