Search in sources :

Example 6 with MapNotifyBuilder

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

the class LispSouthboundHandlerTest method before.

@Override
@Before
public void before() throws Exception {
    super.before();
    mockLispSouthboundPlugin = Mockito.mock(LispSouthboundPlugin.class);
    contextMockLispSouthboundPlugin = context.mock(LispSouthboundPlugin.class);
    Mockito.when(mockLispSouthboundPlugin.isMapRegisterCacheEnabled()).thenReturn(true);
    Mockito.when(mockLispSouthboundPlugin.getMapRegisterCacheTimeout()).thenReturn(CACHE_RECORD_TIMEOUT);
    mapRegisterCache = new MapRegisterCache();
    Mockito.when(mockLispSouthboundPlugin.getMapRegisterCache()).thenReturn(mapRegisterCache);
    Mockito.when(mockLispSouthboundPlugin.getDataBroker()).thenReturn(Mockito.mock(DataBroker.class));
    Mockito.when(mockLispSouthboundPlugin.getAkdb()).thenReturn(akdb);
    Mockito.when(mockLispSouthboundPlugin.getAuthenticationKeyDataListener()).thenReturn(akdl);
    ConcurrentLispSouthboundStats lispSouthboundStats = new ConcurrentLispSouthboundStats();
    Mockito.when(mockLispSouthboundPlugin.getStats()).thenReturn(lispSouthboundStats);
    testedLispService = new LispSouthboundHandler(mockLispSouthboundPlugin);
    // SRC: 127.0.0.1:58560 to 127.0.0.1:4342
    // LISP(Type = 8 - Encapsulated)
    // IP: 192.168.136.10 -> 1.2.3.4
    // UDP: 56756
    // LISP(Type = 1 Map-Request
    // Record Count: 1
    // ITR-RLOC count: 0
    // Source EID AFI: 0
    // Source EID not present
    // Nonce: 0x3d8d2acd39c8d608
    // ITR-RLOC AFI=1 Address=192.168.136.10
    // Record 1: 1.2.3.4/32
    mapRequestPacket = extractWSUdpByteArray("0000   00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 " + "0010   00 58 00 00 40 00 40 11 3c 93 7f 00 00 01 7f 00 " + "0020   00 01 e4 c0 10 f6 00 44 fe 57 80 00 00 00 45 00 " + "0030   00 38 d4 31 00 00 ff 11 56 f3 c0 a8 88 0a 01 02 " + "0040   03 04 dd b4 10 f6 00 24 ef 3a 10 00 00 01 3d 8d " + "0050   2a cd 39 c8 d6 08 00 01 01 02 03 04 00 01 c0 a8 88 0a 00 20 " + "0060   00 01 01 02 03 04");
    mapReplyBuilder = new MapReplyBuilder();
    mapReplyBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
    mapReplyBuilder.setNonce((long) 0);
    mapReplyBuilder.setEchoNonceEnabled(false);
    mapReplyBuilder.setProbe(true);
    mapReplyBuilder.setSecurityEnabled(true);
    mappingRecordBuilder = new MappingRecordBuilder();
    String ip = "0.0.0.0";
    mappingRecordBuilder.setEid(LispAddressUtil.asIpv4PrefixEid(ip + "/0"));
    mappingRecordBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
    mappingRecordBuilder.setRecordTtl(10);
    mappingRecordBuilder.setMapVersion((short) 0);
    mappingRecordBuilder.setAction(Action.NativelyForward);
    mappingRecordBuilder.setAuthoritative(false);
    // eidToLocatorBuilder.setPrefix(new LispIpv4Address(0));
    // mapReply.addEidToLocator(eidToLocatorBuilder);
    // IP: 192.168.136.10 -> 128.223.156.35
    // UDP: 49289 -> 4342
    // LISP(Type = 3 Map-Register, P=1, M=1
    // Record Counter: 1
    // Nonce: 0
    // Key ID: 0x0001
    // AuthDataLength: 20 Data:
    // e8:f5:0b:c5:c5:f2:b0:21:27:a8:21:41:04:f3:46:5a:a5:68:89:ec
    // 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
    // 
    mapRegisterPacket = extractWSUdpByteArray("0000   00 50 56 ee d1 4f 00 0c 29 7a ce 79 08 00 45 00 " + "0010   00 5c 00 00 40 00 40 11 d4 db c0 a8 88 0a 80 df " + "0020   9c 23 d6 40 10 f6 00 48 59 a4 38 00 01 01 00 00 " + "0030   00 00 00 00 00 00 00 01 00 14 0e a4 c6 d8 a4 06 " + "0040   71 7c 33 a4 5c 4a 83 1c de 74 53 03 0c ad 00 00 " + "0050   00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " + "0060   ff 00 00 05 00 01 c0 a8 88 0a");
    mapNotifyBuilder = new MapNotifyBuilder();
    mapNotifyBuilder.setAuthenticationData(new byte[0]);
}
Also used : 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) MapReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord) LispSouthboundPlugin(org.opendaylight.lispflowmapping.southbound.LispSouthboundPlugin) ConcurrentLispSouthboundStats(org.opendaylight.lispflowmapping.southbound.ConcurrentLispSouthboundStats) MapNotifyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder) MapRegisterCache(org.opendaylight.lispflowmapping.southbound.lisp.cache.MapRegisterCache) Before(org.junit.Before)

Example 7 with MapNotifyBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder 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 8 with MapNotifyBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder 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 9 with MapNotifyBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder 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 10 with MapNotifyBuilder

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

the class LispAuthenticationTest method authenticate__MapNotifyNoAuthenticationData.

// @Test
// public void authenticate__MapNotifySHA1() throws Exception {
// MapNotify mapNotify = new MapNotify();
// mapNotify.addEidToLocator(new EidToLocatorRecord().setPrefix(new
// LispIpv4Address(1)));
// 
// mapNotify.addEidToLocator(new EidToLocatorRecord().setPrefix(new
// LispIpv4Address(73)));
// mapNotify.setNonce(6161616161L);
// mapNotify.setKeyId((short) 0x0001);
// byte[] wantedAuthenticationData = new byte[] { (byte) 0x66, (byte) 0x69,
// (byte) 0x2c, (byte) 0xb8, (byte) 0xb8, (byte) 0x58, (byte) 0x7c,
// (byte) 0x8f, (byte) 0x4c, (byte) 0xd4, (byte) 0x8b, (byte) 0x77, (byte)
// 0x46, (byte) 0xf0, (byte) 0x6b, (byte) 0x9f, (byte) 0x66,
// (byte) 0xd2, (byte) 0xaa, (byte) 0x2c };
// ArrayAssert.assertEquals(wantedAuthenticationData,
// LispAuthenticationUtil.createAuthenticationData(mapNotify, "password"));
// 
// }
// 
// @Test
// public void authenticate__MapNotifySHA256() throws Exception {
// MapNotify mapNotify = new MapNotify();
// mapNotify.addEidToLocator(new EidToLocatorRecord().setPrefix(new
// LispIpv4Address(1)));
// 
// mapNotify.addEidToLocator(new EidToLocatorRecord().setPrefix(new
// LispIpv4Address(73)));
// mapNotify.setNonce(6161616161L);
// mapNotify.setKeyId((short) 0x0002);
// byte[] wantedAuthenticationData = new byte[] { (byte) 0x4c, (byte) 0xf1,
// (byte) 0x5a, (byte) 0x4c, (byte) 0xdb, (byte) 0x8d, (byte) 0x88,
// (byte) 0x47, (byte) 0xf1, (byte) 0x7f, (byte) 0x27, (byte) 0x81, (byte)
// 0x1e, (byte) 0xbf, (byte) 0x22, (byte) 0xc7, (byte) 0xe6,
// (byte) 0x70, (byte) 0x16, (byte) 0x5e, (byte) 0xa1, (byte) 0x59, (byte)
// 0xe4, (byte) 0x06, (byte) 0x3f, (byte) 0xc2, (byte) 0x6a,
// (byte) 0x1c, (byte) 0x86, (byte) 0xa5, (byte) 0x8d, (byte) 0x63 };
// ArrayAssert.assertEquals(wantedAuthenticationData,
// LispAuthenticationUtil.createAuthenticationData(mapNotify, "password"));
// 
// }
@Test
public void authenticate__MapNotifyNoAuthenticationData() throws Exception {
    MapNotifyBuilder mapNotifyBuilder = new MapNotifyBuilder();
    mapNotifyBuilder.setKeyId((short) 0x0000);
    mapNotifyBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
    MappingRecordBuilder etlrBuilder = new MappingRecordBuilder();
    etlrBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
    etlrBuilder.setEid(LispAddressUtil.asIpv4PrefixEid("1.1.1.1/32"));
    etlrBuilder.setRecordTtl(55);
    mapNotifyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(etlrBuilder.build()).build());
    final ByteBuffer serializedMapNotifyMsg = MapNotifySerializer.getInstance().serialize(mapNotifyBuilder.build());
    ArrayAssert.assertEquals(new byte[0], LispAuthenticationUtil.createAuthenticationData(serializedMapNotifyMsg, "password"));
}
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) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord) Test(org.junit.Test)

Aggregations

MapNotifyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder)13 MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)9 Test (org.junit.Test)8 MappingRecordItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem)8 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)7 ByteBuffer (java.nio.ByteBuffer)4 ArrayList (java.util.ArrayList)3 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)2 MapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify)2 LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)2 TransportAddress (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress)2 SendMapNotifyInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapNotifyInputBuilder)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Before (org.junit.Before)1 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)1 LispSerializationException (org.opendaylight.lispflowmapping.lisp.serializer.exception.LispSerializationException)1 ConcurrentLispSouthboundStats (org.opendaylight.lispflowmapping.southbound.ConcurrentLispSouthboundStats)1 LispSouthboundPlugin (org.opendaylight.lispflowmapping.southbound.LispSouthboundPlugin)1 MapRegisterCache (org.opendaylight.lispflowmapping.southbound.lisp.cache.MapRegisterCache)1