Search in sources :

Example 21 with Weight

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.Weight in project lispflowmapping by opendaylight.

the class LispSouthboundHandlerTest method mapRegister__Ipv6Rloc.

@Test
public void mapRegister__Ipv6Rloc() throws Exception {
    // P bit (Proxy-Map-Reply): Set
    // M bit (Want-Map-Notify): Set
    // Record Counter: 1
    // Nonce: 0
    // Key ID: 1
    // AuthLength: 20
    // Authentication Data: 5bc4d44a57e2a55d577a6f89779c004f5da713fb
    // EID prefix: 2610:d0:ffff:192::1/128, TTL: 10, Authoritative,
    // No-Action
    // Local RLOC: 10.0.58.156, Reachable, Priority/Weight: 1/100, Multicast
    // Priority/Weight: 255/0
    mapRegisterPacket = extractWSUdpByteArray("0000   00 0c 29 34 3e 1b 00 0c 29 f6 d6 0d 08 00 45 00 " + "0010   00 68 00 00 40 00 40 11 ea c3 0a 00 3a 9c 0a 00 " + "0020   01 26 10 f6 10 f6 00 54 f5 9a 38 00 03 01 00 00 " + "0030   00 00 00 00 00 00 00 01 00 14 22 97 ff 61 ec d8 " + "0040   0f 91 c6 c4 01 ef 7f bb 77 58 39 5c 92 23 00 00 " + "0050   00 0a 01 80 10 00 00 00 00 02 26 10 00 d0 ff ff " + "0060   01 92 00 00 00 00 00 00 00 01 01 64 ff 00 00 05 " + "0070   00 01 0a 00 3a 9c");
    ArgumentCaptor<AddMapping> captor = ArgumentCaptor.forClass(AddMapping.class);
    handleMapRegisterPacket(mapRegisterPacket);
    Mockito.verify(mockLispSouthboundPlugin).sendNotificationIfPossible(captor.capture());
    MappingRecord eidToLocatorRecord = captor.getValue().getMapRegister().getMappingRecordItem().get(0).getMappingRecord();
    assertEquals(LispAddressUtil.asIpv6PrefixBinaryEid("2610:d0:ffff:192:0:0:0:1/128"), eidToLocatorRecord.getEid());
    assertEquals(Ipv6PrefixBinaryAfi.class, eidToLocatorRecord.getEid().getAddressType());
    assertEquals(LispAddressUtil.asIpv4Rloc("10.0.58.156"), eidToLocatorRecord.getLocatorRecord().get(0).getRloc());
}
Also used : AddMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) Test(org.junit.Test)

Example 22 with Weight

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.Weight 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 23 with Weight

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.Weight in project lispflowmapping by opendaylight.

the class MultiSiteScenario method checkActionAndRloc.

boolean checkActionAndRloc(final Site dstSite, boolean expectedPingWorks, MapReply mapReplyFromSrcToDst, final Site... additionalSitesFromMapping) {
    final MappingRecord mappingRecord = verifyMappingRecord(mapReplyFromSrcToDst);
    final boolean isNotDroppendSrcDst = !MappingRecord.Action.Drop.equals(mappingRecord.getAction());
    if (isPossibleAssertPingResultImmediately(expectedPingWorks, isNotDroppendSrcDst, "Drop action has appeared " + "during ping")) {
        return true;
    }
    final List<LocatorRecord> locatorRecords = verifyLocatorRecordExists(mappingRecord);
    for (Site expectedTargetSite : concatenateSites(dstSite, additionalSitesFromMapping)) {
        boolean expectedTargetFound = false;
        for (LocatorRecord locatorRecord : locatorRecords) {
            if (expectedTargetSite.getRloc().equals(rlocToString(locatorRecord))) {
                final byte[] ipv4AddressSrcDst = verifyIpv4Address(locatorRecord).getValue();
                final byte[] rloc = InetAddresses.forString((expectedTargetSite.getRloc())).getAddress();
                final boolean isRlocSrcDstEqual = Arrays.equals(ipv4AddressSrcDst, rloc);
                if (isPossibleAssertPingResultImmediately(expectedPingWorks, isRlocSrcDstEqual, "Unexpected RLOC." + "Expected value " + rloc + ". Real value " + ipv4AddressSrcDst + ".")) {
                    return true;
                }
                final boolean isWeightEquals = expectedTargetSite.getWeight() == locatorRecord.getWeight();
                if (isPossibleAssertPingResultImmediately(expectedPingWorks, isWeightEquals, "Weight isn't equal." + "Expected value " + expectedTargetSite.getWeight() + ". Value from mapping" + locatorRecord.getWeight() + ".")) {
                    return true;
                }
                final boolean isPriorityEquals = expectedTargetSite.getPriority() == locatorRecord.getPriority();
                if (isPossibleAssertPingResultImmediately(expectedPingWorks, isPriorityEquals, "Priority isn't " + "equal. Expected value " + expectedTargetSite.getPriority() + ". Value from mapping" + locatorRecord.getPriority() + ".")) {
                    return true;
                }
                expectedTargetFound = true;
                break;
            }
        }
        if (isPossibleAssertPingResultImmediately(expectedPingWorks, expectedTargetFound, "Mapping for " + expectedTargetSite.getRloc() + " was expected but wasn't returned from mapping service." + expectedTargetFound)) {
            return true;
        }
    }
    return false;
}
Also used : Site(org.opendaylight.lispflowmapping.integrationtest.MultiSiteScenarioUtil.Site) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)

Example 24 with Weight

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.Weight in project lispflowmapping by opendaylight.

the class MapNotifySerializationTest method deserialize__SHA1.

@Test
public void deserialize__SHA1() throws Exception {
    // LISP(Type = 4 Map-Notify, I=0
    // 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
    // 
    MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("40 00 00 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"));
    assertFalse(mn.isXtrSiteIdPresent());
    assertEquals(1, mn.getMappingRecordItem().size());
    assertEquals(0xFFBB000000000000L, mn.getNonce().longValue());
    assertEquals(0x0001, mn.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, mn.getAuthenticationData());
}
Also used : MapNotify(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify) Test(org.junit.Test)

Example 25 with Weight

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.Weight in project lispflowmapping by opendaylight.

the class MapNotifySerializationTest method deserialize__AllFields.

@Test
public void deserialize__AllFields() throws Exception {
    // LISP(Type = 4 Map-Notify, I=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
    // xTR-ID 1
    // Site-ID 1
    MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("48 00 00 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 " + // xTR-ID
    "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 " + // Site-ID
    "00 00 00 00 00 00 00 01 "));
    assertTrue(mn.isXtrSiteIdPresent());
    assertEquals(1, mn.getMappingRecordItem().size());
    assertEquals(0xFFBB000000000000L, mn.getNonce().longValue());
    assertEquals(0x0000, mn.getKeyId().shortValue());
    byte[] expectedAuthenticationData = {};
    ArrayAssert.assertEquals(expectedAuthenticationData, mn.getAuthenticationData());
}
Also used : MapNotify(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)20 Weight (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.Weight)9 ByteBuf (io.netty.buffer.ByteBuf)7 MapRegister (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister)7 ByteBuffer (java.nio.ByteBuffer)4 BitArray (org.opendaylight.protocol.util.BitArray)3 MapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify)3 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)3 SrLanAdjIdsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.attribute.SrLanAdjIdsBuilder)3 ArrayList (java.util.ArrayList)2 AddMapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping)2 LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)2 MappingRecordItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem)2 BucketsList (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList)2 SrAdjIdsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.attribute.SrAdjIdsBuilder)2 Ipv6AddressCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.sid.label.index.sid.label.index.Ipv6AddressCaseBuilder)2 BigInteger (java.math.BigInteger)1 HashMap (java.util.HashMap)1 Before (org.junit.Before)1 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)1