Search in sources :

Example 1 with MapRegister

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

the class MapRegisterSerializationTest method deserialize__SHA1.

@Test
public void deserialize__SHA1() throws Exception {
    // LISP(Type = 3 Map-Register, P=1, M=1
    // Record Counter: 1
    // Nonce: (something)
    // Key ID: 0x0001
    // AuthDataLength: 20 Data:
    // b2:dd:1a:25:c0:60:b1:46:e8:dc:6d:a6:ae:2e:92:92:a6:ca:b7:9d
    // EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
    // No-Action
    // Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
    // Priority/Weight: 1/100, Multicast Priority/Weight: 255/0
    // 
    MapRegister mr = MapRegisterSerializer.getInstance().deserialize(hexToByteBuffer("38 00 01 01 FF BB " + // 
    "00 00 00 00 00 00 00 01 00 14 2c 61 b9 c9 9a 20 " + // 
    "ba d8 f5 40 d3 55 6f 5f 6e 5a b2 0a bf b5 00 00 " + // 
    "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " + // 
    "ff 00 00 05 00 01 c0 a8 88 0a"), null);
    assertTrue(mr.isProxyMapReply());
    assertTrue(mr.isWantMapNotify());
    assertEquals(1, mr.getMappingRecordItem().size());
    assertEquals(0xFFBB000000000000L, mr.getNonce().longValue());
    assertEquals(0x0001, mr.getKeyId().shortValue());
    byte[] expectedAuthenticationData = { (byte) 0x2c, (byte) 0x61, (byte) 0xb9, (byte) 0xc9, (byte) 0x9a, (byte) 0x20, (byte) 0xba, (byte) 0xd8, (byte) 0xf5, (byte) 0x40, (byte) 0xd3, (byte) 0x55, (byte) 0x6f, (byte) 0x5f, (byte) 0x6e, (byte) 0x5a, (byte) 0xb2, (byte) 0x0a, (byte) 0xbf, (byte) 0xb5 };
    ArrayAssert.assertEquals(expectedAuthenticationData, mr.getAuthenticationData());
}
Also used : MapRegister(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister) Test(org.junit.Test)

Example 2 with MapRegister

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

the class MapRegisterSerializationTest method deserialize__SomeEidToLocatorFiels.

@Test
public void deserialize__SomeEidToLocatorFiels() throws Exception {
    // LISP(Type = 3 Map-Register, P=1, M=1
    // Record Counter: 4
    // EID prefixes: 153.16.254.1 -- 152.16.254.1 -- 151.16.254.1 --
    // 150.16.254.1
    // Local RLOCs: 192.168.136.10 -- 192.168.136.11 -- 192.168.136.12 --
    // 192.168.136.13
    // 
    MapRegister mr = MapRegisterSerializer.getInstance().deserialize(hexToByteBuffer("38 00 01 " + // 
    "04 " + // Record count
    "FF BB 00 00 00 00 00 00 00 01 00 14 b9 cd 7b 89 " + // 
    "65 c2 56 03 be dd 81 20 47 e5 c3 4f 56 02 e1 59 " + // 
    "00 00 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " + // 0
    "ff 00 00 05 00 01 c0 a8 88 0a " + // contd
    "00 00 00 0b 01 17 50 00 01 11 00 01 98 10 fe 01 01 64 " + // 1
    "ff 00 00 05 00 01 c0 a8 88 0b " + // contd
    "00 00 00 0c 01 20 00 00 02 22 00 01 97 10 fe 01 01 64 " + // 2
    "ff 00 00 05 00 01 c0 a8 88 0c " + // contd
    "00 00 00 0d 01 20 20 00 03 33 00 01 96 10 fe 01 01 64 " + // 3
    "ff 00 00 05 00 01 c0 a8 88 0d "), null);
    assertEquals(4, mr.getMappingRecordItem().size());
    final MappingRecord record0 = mr.getMappingRecordItem().get(0).getMappingRecord();
    final MappingRecord record1 = mr.getMappingRecordItem().get(1).getMappingRecord();
    final MappingRecord record2 = mr.getMappingRecordItem().get(2).getMappingRecord();
    final MappingRecord record3 = mr.getMappingRecordItem().get(3).getMappingRecord();
    assertEquals(10, record0.getRecordTtl().intValue());
    assertEquals(13, record3.getRecordTtl().intValue());
    assertEquals(32, MaskUtil.getMaskForAddress(record0.getEid().getAddress()));
    assertEquals(23, MaskUtil.getMaskForAddress(record1.getEid().getAddress()));
    assertEquals(Action.NoAction, record0.getAction());
    assertEquals(Action.SendMapRequest, record1.getAction());
    assertEquals(Action.NoAction, record2.getAction());
    assertEquals(Action.NativelyForward, record3.getAction());
    assertTrue(record0.isAuthoritative());
    assertTrue(record1.isAuthoritative());
    assertFalse(record2.isAuthoritative());
    assertFalse(record3.isAuthoritative());
    assertEquals(0x000, record0.getMapVersion().shortValue());
    assertEquals(0x111, record1.getMapVersion().shortValue());
    assertEquals(0x222, record2.getMapVersion().shortValue());
    assertEquals(0x333, record3.getMapVersion().shortValue());
}
Also used : MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MapRegister(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister) Test(org.junit.Test)

Example 3 with MapRegister

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

the class MapRegisterSerializationTest method deserialize__AllFields.

@Test
public void deserialize__AllFields() throws Exception {
    // LISP(Type = 3 Map-Register, P=1, M=1
    // Record Counter: 1
    // Nonce: (something)
    // Key ID: 0x0000
    // AuthDataLength: 00 Data:
    // EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
    // No-Action
    // Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
    // Priority/Weight: 1/100, Multicast Priority/Weight: 255/0
    // 
    MapRegister mr = MapRegisterSerializer.getInstance().deserialize(hexToByteBuffer("38 00 01 01 FF BB " + // 
    "00 00 00 00 00 00 00 00 00 00 00 00 " + // 
    "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " + // 
    "ff 00 00 05 00 01 c0 a8 88 0a"), null);
    assertTrue(mr.isProxyMapReply());
    assertTrue(mr.isWantMapNotify());
    assertEquals(1, mr.getMappingRecordItem().size());
    assertEquals(0xFFBB000000000000L, mr.getNonce().longValue());
    assertEquals(0x0000, mr.getKeyId().shortValue());
    byte[] expectedAuthenticationData = {};
    ArrayAssert.assertEquals(expectedAuthenticationData, mr.getAuthenticationData());
}
Also used : MapRegister(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister) Test(org.junit.Test)

Example 4 with MapRegister

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

the class MapRegisterSerializationTest method deserialize__Locators.

@Test
public void deserialize__Locators() throws Exception {
    MapRegister mr = MapRegisterSerializer.getInstance().deserialize(hexToByteBuffer("38 00 01 01 " + // 
    "FF BB 00 00 00 00 00 00 00 01 00 14 f1 b8 ab f0 " + // 
    "66 bb 2e ef 12 70 74 46 6f 6b 8e ca bf 1e 68 40 " + // 
    "00 00 00 0a " + // 
    "03 " + // Locator Count
    "20 10 00 00 00 00 01 99 10 fe 01 " + // Locator 1
    "01 64 1f 00 " + // priorities + weights
    "00 05 " + // Flags
    "00 01 c0 a8 88 0a " + // Locator 2
    "67 00 30 34 " + // priorities + weights
    "00 02 " + // Flags
    "00 01 cc aa AA 11 " + // Locator 3
    "60 11 34 A4 " + // priorities + weights
    "00 03 " + // Flags
    "00 01 c0 a8 88 0a "), null);
    assertEquals(1, mr.getMappingRecordItem().size());
    MappingRecordItem eidToLocator = mr.getMappingRecordItem().get(0);
    assertEquals(3, eidToLocator.getMappingRecord().getLocatorRecord().size());
    LocatorRecord loc0 = eidToLocator.getMappingRecord().getLocatorRecord().get(0);
    LocatorRecord loc1 = eidToLocator.getMappingRecord().getLocatorRecord().get(1);
    LocatorRecord loc2 = eidToLocator.getMappingRecord().getLocatorRecord().get(2);
    assertEquals((byte) 0x01, loc0.getPriority().byteValue());
    assertEquals((byte) 0x67, loc1.getPriority().byteValue());
    assertEquals((byte) 0x60, loc2.getPriority().byteValue());
    assertEquals((byte) 0x64, loc0.getWeight().byteValue());
    assertEquals((byte) 0x00, loc1.getWeight().byteValue());
    assertEquals((byte) 0x11, loc2.getWeight().byteValue());
    assertEquals((byte) 0x1F, loc0.getMulticastPriority().byteValue());
    assertEquals((byte) 0x30, loc1.getMulticastPriority().byteValue());
    assertEquals((byte) 0x34, loc2.getMulticastPriority().byteValue());
    assertEquals((byte) 0x00, loc0.getMulticastWeight().byteValue());
    assertEquals((byte) 0x34, loc1.getMulticastWeight().byteValue());
    assertEquals((byte) 0xA4, loc2.getMulticastWeight().byteValue());
    assertTrue(loc0.isLocalLocator());
    assertFalse(loc1.isLocalLocator());
    assertFalse(loc2.isLocalLocator());
    assertFalse(loc0.isRlocProbed());
    assertTrue(loc1.isRlocProbed());
    assertTrue(loc2.isRlocProbed());
    assertTrue(loc0.isRouted());
    assertFalse(loc1.isRouted());
    assertTrue(loc2.isRouted());
    assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.10"), loc0.getRloc());
    assertEquals(LispAddressUtil.asIpv4Rloc("204.170.170.17"), loc1.getRloc());
}
Also used : MappingRecordItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem) MapRegister(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord) Test(org.junit.Test)

Example 5 with MapRegister

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

the class MapRegisterSerializationTest method serialize__deserialize.

@Test
public void serialize__deserialize() 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());
    recordBuilder.setAction(Action.NoAction);
    recordBuilder.setMapVersion((short) 0);
    recordBuilder.setRecordTtl(0);
    mrBuilder.setNonce(6161616161L);
    mrBuilder.setKeyId((short) 0x0001);
    mrBuilder.setWantMapNotify(true);
    mrBuilder.setProxyMapReply(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);
    MapRegister mapRegister = mrBuilder.build();
    ArrayAssert.assertEquals(MapRegisterSerializer.getInstance().serialize(mapRegister).array(), MapRegisterSerializer.getInstance().serialize(MapRegisterSerializer.getInstance().deserialize(MapRegisterSerializer.getInstance().serialize(mapRegister), null)).array());
}
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) MapRegister(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister) 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) Test(org.junit.Test)

Aggregations

MapRegister (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister)22 Test (org.junit.Test)19 MappingRecordItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem)8 GotMapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapNotify)7 MapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify)7 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)7 ByteBuffer (java.nio.ByteBuffer)6 MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)6 ArrayList (java.util.ArrayList)5 MapRequest (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest)5 MapNotifyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder)5 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)4 MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)4 LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)4 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)4 MappingAuthkey (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey)3 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)3 MapRegisterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregisternotification.MapRegisterBuilder)3 TransportAddress (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress)3 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)2