Search in sources :

Example 26 with Notify

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify 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 27 with Notify

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTest method registerAddressAndQuery.

// takes an address, packs it in a MapRegister, sends it, returns the
// MapReply
private MapReply registerAddressAndQuery(Eid eid) throws SocketTimeoutException {
    mapService.addAuthenticationKey(eid, NULL_AUTH_KEY);
    sleepForSeconds(1);
    MapRegister mapRegister = MappingServiceIntegrationTestUtil.getDefaultMapRegisterBuilder(eid).build();
    LOG.trace("Sending Map-Register via socket: {}", mapRegister);
    sendMapRegister(mapRegister);
    MapNotify mapNotify = receiveMapNotify();
    LOG.trace("Received Map-Notify via socket: {}", mapNotify);
    assertEquals(8, mapNotify.getNonce().longValue());
    // wait for the notifications to propagate
    sleepForSeconds(1);
    MapRequest mapRequest = MappingServiceIntegrationTestUtil.getDefaultMapRequestBuilder(eid).build();
    sendMapRequest(mapRequest);
    return receiveMapReply();
}
Also used : MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest) GotMapNotify(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapNotify) MapNotify(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify) MapRegister(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister)

Example 28 with Notify

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify 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 29 with Notify

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify 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)

Example 30 with Notify

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify 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

Test (org.junit.Test)16 Notify (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify)12 MapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify)8 Notification (org.opendaylight.yangtools.yang.binding.Notification)6 ArrayList (java.util.ArrayList)5 JAXBException (javax.xml.bind.JAXBException)5 Notify (org.oasis_open.docs.wsn.b_2.Notify)5 Open (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Open)5 JMSException (javax.jms.JMSException)4 AclInterface (org.opendaylight.netvirt.aclservice.api.utils.AclInterface)4 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)4 Message (javax.jms.Message)3 TextMessage (javax.jms.TextMessage)3 NotificationMessageHolderType (org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType)3 BGPDocumentedException (org.opendaylight.protocol.bgp.parser.BGPDocumentedException)3 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)3 OpenBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.OpenBuilder)3 Optional (com.google.common.base.Optional)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 ByteBuf (io.netty.buffer.ByteBuf)2