Search in sources :

Example 1 with MapReply

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

the class MapReplySerializationTest method deserialize__SomeFlags.

@Test
public void deserialize__SomeFlags() throws Exception {
    MapReply mr = MapReplySerializer.getInstance().deserialize(hexToByteBuffer("2A 00 00 00 00 00 " + "00 00 00 00 00 00"));
    assertEquals(true, mr.isProbe());
    assertEquals(false, mr.isEchoNonceEnabled());
    assertEquals(true, mr.isSecurityEnabled());
}
Also used : MapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply) Test(org.junit.Test)

Example 2 with MapReply

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

the class MapReplySerializationTest method deserialize__MultipleRecordsWithoutRLOCs.

@Test
public void deserialize__MultipleRecordsWithoutRLOCs() throws Exception {
    MapReply mr = MapReplySerializer.getInstance().deserialize(hexToByteBuffer("20 00 00 02 00 00 " + "00 00 00 00 00 00 00 00 00 01 00 20 00 00 00 00 " + "00 01 01 02 03 04 00 00 00 00 00 10 30 00 00 02 00 01 04 03 00 00"));
    assertArrayEquals(new byte[] { 1, 2, 3, 4 }, ((Ipv4PrefixBinary) mr.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddress()).getIpv4AddressBinary().getValue());
    // XXX Why here normalized and other cases not normalized?
    assertArrayEquals(new byte[] { 4, 3, 0, 0 }, ((Ipv4PrefixBinary) mr.getMappingRecordItem().get(1).getMappingRecord().getEid().getAddress()).getIpv4AddressBinary().getValue());
    assertEquals(false, mr.getMappingRecordItem().get(0).getMappingRecord().isAuthoritative());
    assertEquals(true, mr.getMappingRecordItem().get(1).getMappingRecord().isAuthoritative());
    assertEquals(Action.NoAction, mr.getMappingRecordItem().get(0).getMappingRecord().getAction());
    assertEquals(Action.NativelyForward, mr.getMappingRecordItem().get(1).getMappingRecord().getAction());
    assertEquals(0, mr.getMappingRecordItem().get(0).getMappingRecord().getMapVersion().shortValue());
    assertEquals(2, mr.getMappingRecordItem().get(1).getMappingRecord().getMapVersion().shortValue());
    assertEquals(32, MaskUtil.getMaskForAddress(mr.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddress()));
    assertEquals(16, MaskUtil.getMaskForAddress(mr.getMappingRecordItem().get(1).getMappingRecord().getEid().getAddress()));
    assertEquals(1, mr.getMappingRecordItem().get(0).getMappingRecord().getRecordTtl().byteValue());
    assertEquals(0, mr.getMappingRecordItem().get(1).getMappingRecord().getRecordTtl().byteValue());
}
Also used : Ipv4PrefixBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary) MapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply) Test(org.junit.Test)

Example 3 with MapReply

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

the class MapReplySerializer method serialize.

public ByteBuffer serialize(MapReply mapReply) {
    int size = Length.HEADER_SIZE;
    for (MappingRecordItem eidToLocatorRecord : mapReply.getMappingRecordItem()) {
        size += MappingRecordSerializer.getInstance().getSerializationSize(eidToLocatorRecord.getMappingRecord());
    }
    ByteBuffer replyBuffer = ByteBuffer.allocate(size);
    replyBuffer.put((byte) ((MessageType.MapReply.getIntValue() << 4) | (BooleanUtils.isTrue(mapReply.isProbe()) ? Flags.PROBE : 0x00) | (BooleanUtils.isTrue(mapReply.isEchoNonceEnabled()) ? Flags.ECHO_NONCE_ENABLED : 0x00)));
    replyBuffer.position(replyBuffer.position() + Length.RES);
    if (mapReply.getMappingRecordItem() != null) {
        replyBuffer.put((byte) mapReply.getMappingRecordItem().size());
    } else {
        replyBuffer.put((byte) 0);
    }
    replyBuffer.putLong(NumberUtil.asLong(mapReply.getNonce()));
    if (mapReply.getMappingRecordItem() != null) {
        for (MappingRecordItem eidToLocatorRecord : mapReply.getMappingRecordItem()) {
            MappingRecordSerializer.getInstance().serialize(replyBuffer, eidToLocatorRecord.getMappingRecord());
        }
    }
    return replyBuffer;
}
Also used : MappingRecordItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem) ByteBuffer(java.nio.ByteBuffer)

Example 4 with MapReply

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

the class LispXtrSouthboundHandler method handleMapReply.

@SuppressWarnings("checkstyle:IllegalCatch")
private void handleMapReply(ByteBuffer buffer) {
    try {
        MapReply reply = MapReplySerializer.getInstance().deserialize(buffer);
        XtrReplyMappingBuilder replyMappingBuilder = new XtrReplyMappingBuilder();
        replyMappingBuilder.setMapReply(LispNotificationHelper.convertMapReply(reply));
        lispSbPlugin.sendNotificationIfPossible(replyMappingBuilder.build());
    } catch (RuntimeException re) {
        throw new LispMalformedPacketException("Couldn't deserialize Map-Reply (len=" + buffer.capacity() + ")", re);
    } catch (InterruptedException e) {
        LOG.warn("Notification publication interrupted!");
    }
}
Also used : MapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply) LispMalformedPacketException(org.opendaylight.lispflowmapping.southbound.lisp.exception.LispMalformedPacketException) XtrReplyMappingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrReplyMappingBuilder)

Example 5 with MapReply

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

the class LispSouthboundRpcTest method sendMapReplyTest_inputNotNull.

/**
 * Tests {@link LispSouthboundRPC#sendMapReply} method.
 */
@Test
public void sendMapReplyTest_inputNotNull() throws ExecutionException, InterruptedException {
    final MapReply mapReply = getDefaultMapReplyBuilder().build();
    final TransportAddress transportAddress = new TransportAddressBuilder().build();
    final SendMapReplyInput sendMapReplyInputMock = Mockito.mock(SendMapReplyInput.class);
    Mockito.when(sendMapReplyInputMock.getTransportAddress()).thenReturn(transportAddress);
    Mockito.when(sendMapReplyInputMock.getMapReply()).thenReturn(mapReply);
    assertEquals(RPC_RESULT_SUCCESS.isSuccessful(), lispSouthboundRPC.sendMapReply(sendMapReplyInputMock).get().isSuccessful());
    Mockito.verify(lispSouthboundPlugin).handleSerializedLispBuffer(transportAddress, MapReplySerializer.getInstance().serialize(mapReply), MessageType.MapReply);
}
Also used : MapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReply) TransportAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress) SendMapReplyInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapReplyInput) TransportAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder) Test(org.junit.Test)

Aggregations

MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)44 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)38 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)25 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)12 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)9 SourceEidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder)9 Test (org.junit.Test)8 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)8 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)8 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)6 MapRequest (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest)6 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)6 GotMapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapNotify)5 MapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify)5 EidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder)5 EidItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder)5 InstanceIdType (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType)4 MapRegister (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister)4 MappingRecordItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem)4 MapRequestBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder)4