Search in sources :

Example 36 with Counter

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.data.change.counter.rev160315.data.change.counter.Counter in project lispflowmapping by opendaylight.

the class MapRegisterSerializationTest method deserialize__MultipleRecords.

@Test
public void deserialize__MultipleRecords() 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 87 c1 33 cd " + // 
    "d1 1e bc 80 fd 3e 71 11 81 17 40 74 26 25 44 bd " + // 
    "00 00 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " + // 1
    "ff 00 00 05 00 01 c0 a8 88 0a " + // contd
    "00 00 00 0a 01 20 10 00 00 00 00 01 98 10 fe 01 01 64 " + // 2
    "ff 00 00 05 00 01 c0 a8 88 0b " + // contd
    "00 00 00 0a 01 20 10 00 00 00 00 01 97 10 fe 01 01 64 " + // 3
    "ff 00 00 05 00 01 c0 a8 88 0c " + // contd
    "00 00 00 0a 01 20 10 00 00 00 00 01 96 10 fe 01 01 64 " + // 4
    "ff 00 00 05 00 01 c0 a8 88 0d "), null);
    assertEquals(4, mr.getMappingRecordItem().size());
    assertEquals(LispAddressUtil.asIpv4PrefixBinaryEid("153.16.254.1/32"), mr.getMappingRecordItem().get(0).getMappingRecord().getEid());
    assertEquals(LispAddressUtil.asIpv4PrefixBinaryEid("151.16.254.1/32"), mr.getMappingRecordItem().get(2).getMappingRecord().getEid());
    assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.11"), mr.getMappingRecordItem().get(1).getMappingRecord().getLocatorRecord().get(0).getRloc());
    assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.13"), mr.getMappingRecordItem().get(3).getMappingRecord().getLocatorRecord().get(0).getRloc());
}
Also used : MapRegister(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister) Test(org.junit.Test)

Example 37 with Counter

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.data.change.counter.rev160315.data.change.counter.Counter in project lispflowmapping by opendaylight.

the class MapRegisterSerializationTest method deserialize__SHA256.

@Test
public void deserialize__SHA256() throws Exception {
    // LISP(Type = 3 Map-Register, P=1, M=1
    // Record Counter: 1
    // Nonce: (something)
    // Key ID: 0x0002
    // AuthDataLength: 32 Data:
    // 70 30 d4 c6 10 44 0d 83 be 4d bf fd a9 8c 57 6d 68 a5 bf 32 11 c9 7b
    // 58 c4 b9 9f 06 11 23 b9 38
    // 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 02 00 20 70 30 d4 c6 10 44 0d 83 be 4d bf fd a9 8c 57 6d 68 a5 bf 32 " + // 
    "11 c9 7b 58 c4 b9 9f 06 11 23 b9 38 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(0x0002, mr.getKeyId().shortValue());
    byte[] expectedAuthenticationData = { (byte) 0x70, (byte) 0x30, (byte) 0xd4, (byte) 0xc6, (byte) 0x10, (byte) 0x44, (byte) 0x0d, (byte) 0x83, (byte) 0xbe, (byte) 0x4d, (byte) 0xbf, (byte) 0xfd, (byte) 0xa9, (byte) 0x8c, (byte) 0x57, (byte) 0x6d, (byte) 0x68, (byte) 0xa5, (byte) 0xbf, (byte) 0x32, (byte) 0x11, (byte) 0xc9, (byte) 0x7b, (byte) 0x58, (byte) 0xc4, (byte) 0xb9, (byte) 0x9f, (byte) 0x06, (byte) 0x11, (byte) 0x23, (byte) 0xb9, (byte) 0x38 };
    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 38 with Counter

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.data.change.counter.rev160315.data.change.counter.Counter in project lispflowmapping by opendaylight.

the class LispAuthenticationTest method validate__SHA256.

@Test
public void validate__SHA256() throws Exception {
    // LISP(Type = 3 Map-Register, P=1, M=1
    // Record Counter: 1
    // Nonce: (something)
    // Key ID: 0x0002
    // AuthDataLength: 32 Data:
    // 70 30 d4 c6 10 44 0d 83 be 4d bf fd a9 8c 57 6d 68 a5 bf 32 11 c9 7b
    // 58 c4 b9 9f 06 11 23 b9 38
    // 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
    // 
    final ByteBuffer byteBuffer = hexToByteBuffer("38 00 01 01 FF BB " + "00 00 00 00 00 00 00 02 00 20 " + "70 30 d4 c6 10 44 0d 83 be 4d bf fd a9 8c 57 6d " + "68 a5 bf 32 11 c9 7b 58 c4 b9 9f 06 11 23 b9 38 " + "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");
    MapRegister mapRegister = MapRegisterSerializer.getInstance().deserialize(byteBuffer, null);
    assertTrue(validate(mapRegister, byteBuffer, EID, 2, PASSWORD));
    assertFalse(validate(mapRegister, byteBuffer, EID, 2, WRONG_PASSWORD));
}
Also used : MapRegister(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 39 with Counter

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.data.change.counter.rev160315.data.change.counter.Counter in project lispflowmapping by opendaylight.

the class LispAuthenticationTest method validate__SHA1.

@Test
public void validate__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
    // 
    final ByteBuffer byteBuffer = 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");
    MapRegister mapRegister = MapRegisterSerializer.getInstance().deserialize(byteBuffer, null);
    assertTrue(validate(mapRegister, byteBuffer, EID, 1, PASSWORD));
    assertFalse(validate(mapRegister, byteBuffer, EID, 1, WRONG_PASSWORD));
}
Also used : MapRegister(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 40 with Counter

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.data.change.counter.rev160315.data.change.counter.Counter in project lispflowmapping by opendaylight.

the class LispAuthenticationTest method validate_WrongAuthentication.

@Test
public void validate_WrongAuthentication() throws Exception {
    // LISP(Type = 3 Map-Register, P=1, M=1
    // Record Counter: 1
    // Nonce: (something)
    // Key ID: 0x0001
    // AuthDataLength: 20 Data:
    // e8:f5:0b:c5:c5:f2:b0:21:27:a8:21:41:04:f3:46:5a:5a:5b:5c:5d
    // 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
    final ByteBuffer byteBuffer = hexToByteBuffer("38 00 01 01 FF BB " + "00 00 00 00 00 00 00 01 00 14 e8 f5 0b c5 c5 f2 " + "b0 21 27 a8 21 41 04 f3 46 5a 5a 5b 5c 5d 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");
    MapRegister mapRegister = MapRegisterSerializer.getInstance().deserialize(byteBuffer, null);
    assertFalse(validate(mapRegister, byteBuffer, EID, 1, PASSWORD));
}
Also used : MapRegister(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)19 ExecutionException (java.util.concurrent.ExecutionException)13 Counter (org.opendaylight.infrautils.metrics.Counter)12 ArrayList (java.util.ArrayList)11 BigInteger (java.math.BigInteger)9 MapRegister (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister)9 List (java.util.List)7 Logger (org.slf4j.Logger)6 LoggerFactory (org.slf4j.LoggerFactory)6 Optional (java.util.Optional)5 ReadFailedException (org.opendaylight.mdsal.common.api.ReadFailedException)5 CounterResult (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.CounterResult)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Future (java.util.concurrent.Future)4 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)4 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)4 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)4 Optional (com.google.common.base.Optional)3 FutureCallback (com.google.common.util.concurrent.FutureCallback)3