Search in sources :

Example 1 with MappingRecord

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.

the class MapNotifySerializationTest method deserialize__SomeEidToLocatorFiels.

@Test
public void deserialize__SomeEidToLocatorFiels() throws Exception {
    // LISP(Type = 4 Map-Notify, I=0
    // 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
    // 
    MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("40 00 00 " + // 
    "04 " + // Record count
    "FF BB 00 00 00 00 00 00 00 01 00 14 b9 cd 7b 89 " + // 
    "65 c2 56 03 be dd 81 20 47 e5 c3 4f 56 02 e1 59 " + // 
    "00 00 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " + // 0
    "ff 00 00 05 00 01 c0 a8 88 0a " + // contd
    "00 00 00 0b 01 17 50 00 01 11 00 01 98 10 fe 01 01 64 " + // 1
    "ff 00 00 05 00 01 c0 a8 88 0b " + // contd
    "00 00 00 0c 01 20 00 00 02 22 00 01 97 10 fe 01 01 64 " + // 2
    "ff 00 00 05 00 01 c0 a8 88 0c " + // contd
    "00 00 00 0d 01 20 20 00 03 33 00 01 96 10 fe 01 01 64 " + // 3
    "ff 00 00 05 00 01 c0 a8 88 0d "));
    assertEquals(4, mn.getMappingRecordItem().size());
    final MappingRecord record0 = mn.getMappingRecordItem().get(0).getMappingRecord();
    final MappingRecord record1 = mn.getMappingRecordItem().get(1).getMappingRecord();
    final MappingRecord record2 = mn.getMappingRecordItem().get(2).getMappingRecord();
    final MappingRecord record3 = mn.getMappingRecordItem().get(3).getMappingRecord();
    assertEquals(10, record0.getRecordTtl().intValue());
    assertEquals(13, record3.getRecordTtl().intValue());
    assertEquals(32, MaskUtil.getMaskForAddress(record0.getEid().getAddress()));
    assertEquals(23, MaskUtil.getMaskForAddress(record1.getEid().getAddress()));
    assertEquals(Action.NoAction, record0.getAction());
    assertEquals(Action.SendMapRequest, record1.getAction());
    assertEquals(Action.NoAction, record2.getAction());
    assertEquals(Action.NativelyForward, record3.getAction());
    assertTrue(record0.isAuthoritative());
    assertTrue(record1.isAuthoritative());
    assertFalse(record2.isAuthoritative());
    assertFalse(record3.isAuthoritative());
    assertEquals(0x000, record0.getMapVersion().shortValue());
    assertEquals(0x111, record1.getMapVersion().shortValue());
    assertEquals(0x222, record2.getMapVersion().shortValue());
    assertEquals(0x333, record3.getMapVersion().shortValue());
}
Also used : MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MapNotify(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify) Test(org.junit.Test)

Example 2 with MappingRecord

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.

the class MapRegisterSerializationTest method deserialize__SomeEidToLocatorFiels.

@Test
public void deserialize__SomeEidToLocatorFiels() 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 b9 cd 7b 89 " + // 
    "65 c2 56 03 be dd 81 20 47 e5 c3 4f 56 02 e1 59 " + // 
    "00 00 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " + // 0
    "ff 00 00 05 00 01 c0 a8 88 0a " + // contd
    "00 00 00 0b 01 17 50 00 01 11 00 01 98 10 fe 01 01 64 " + // 1
    "ff 00 00 05 00 01 c0 a8 88 0b " + // contd
    "00 00 00 0c 01 20 00 00 02 22 00 01 97 10 fe 01 01 64 " + // 2
    "ff 00 00 05 00 01 c0 a8 88 0c " + // contd
    "00 00 00 0d 01 20 20 00 03 33 00 01 96 10 fe 01 01 64 " + // 3
    "ff 00 00 05 00 01 c0 a8 88 0d "), null);
    assertEquals(4, mr.getMappingRecordItem().size());
    final MappingRecord record0 = mr.getMappingRecordItem().get(0).getMappingRecord();
    final MappingRecord record1 = mr.getMappingRecordItem().get(1).getMappingRecord();
    final MappingRecord record2 = mr.getMappingRecordItem().get(2).getMappingRecord();
    final MappingRecord record3 = mr.getMappingRecordItem().get(3).getMappingRecord();
    assertEquals(10, record0.getRecordTtl().intValue());
    assertEquals(13, record3.getRecordTtl().intValue());
    assertEquals(32, MaskUtil.getMaskForAddress(record0.getEid().getAddress()));
    assertEquals(23, MaskUtil.getMaskForAddress(record1.getEid().getAddress()));
    assertEquals(Action.NoAction, record0.getAction());
    assertEquals(Action.SendMapRequest, record1.getAction());
    assertEquals(Action.NoAction, record2.getAction());
    assertEquals(Action.NativelyForward, record3.getAction());
    assertTrue(record0.isAuthoritative());
    assertTrue(record1.isAuthoritative());
    assertFalse(record2.isAuthoritative());
    assertFalse(record3.isAuthoritative());
    assertEquals(0x000, record0.getMapVersion().shortValue());
    assertEquals(0x111, record1.getMapVersion().shortValue());
    assertEquals(0x222, record2.getMapVersion().shortValue());
    assertEquals(0x333, record3.getMapVersion().shortValue());
}
Also used : MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MapRegister(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister) Test(org.junit.Test)

Example 3 with MappingRecord

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.

the class MapRequestSerializationTest method deserialize__ContainsMapReply.

@Test
public void deserialize__ContainsMapReply() throws Exception {
    MapRequest mr = MapRequestSerializer.getInstance().deserialize(hexToByteBuffer("16 80 00 " + // single record
    "01 " + "3d 8d 2a cd 39 c8 d6 08 00 00 00 01 c0 a8 88 0a " + // end of map request
    "00 20 00 01 01 02 03 04 " + "00 00 " + "00 02 01 20 00 00 00 00 " + "00 01 01 02 03 04 01 02 " + "03 04 00 06 00 01 0a 0a " + "0a 0a"), null);
    assertEquals(1, mr.getEidItem().size());
    assertEquals(LispAddressUtil.asIpv4PrefixBinaryEid("1.2.3.4/32"), mr.getEidItem().get(0).getEid());
    MappingRecord record = mr.getMapReply().getMappingRecord();
    assertEquals(LispAddressUtil.asIpv4PrefixBinaryEid("1.2.3.4/32"), record.getEid());
    assertEquals(false, record.isAuthoritative());
    assertEquals(Action.NoAction, record.getAction());
    assertEquals(0, record.getMapVersion().shortValue());
    assertEquals(32, MaskUtil.getMaskForAddress(record.getEid().getAddress()));
    assertEquals(2, record.getRecordTtl().byteValue());
    assertArrayEquals(new byte[] { 10, 10, 10, 10 }, ((Ipv4Binary) record.getLocatorRecord().get(0).getRloc().getAddress()).getIpv4Binary().getValue());
    assertEquals(1, record.getLocatorRecord().get(0).getPriority().byteValue());
    assertEquals(2, record.getLocatorRecord().get(0).getWeight().byteValue());
    assertEquals(3, record.getLocatorRecord().get(0).getMulticastPriority().byteValue());
    assertEquals(4, record.getLocatorRecord().get(0).getMulticastWeight().byteValue());
    assertEquals(true, record.getLocatorRecord().get(0).isLocalLocator());
    assertEquals(true, record.getLocatorRecord().get(0).isRlocProbed());
    assertEquals(false, record.getLocatorRecord().get(0).isRouted());
}
Also used : MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) Ipv4Binary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4Binary) Test(org.junit.Test)

Example 4 with MappingRecord

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.

the class Stringifier method getString.

public static String getString(MappingRecord mapping, int indentation) {
    final String indent = getSpacesAsString(indentation);
    StringBuilder mrsb = new StringBuilder(indent);
    // Main information, EID prefix and TTL (for now)
    mrsb.append(LispAddressStringifier.getString(mapping.getEid()));
    mrsb.append(", TTL: ");
    mrsb.append(mapping.getRecordTtl().toString());
    mrsb.append(NEW_LINE);
    // Locator records
    // Regular indentation for the mapping record
    mrsb.append(indent);
    // Extra indentation for locator records
    mrsb.append(indent);
    if (mapping.getLocatorRecord() == null || mapping.getLocatorRecord().isEmpty()) {
        // We only print the action for negative mappings (0 locator records)
        mrsb.append("-> Negative entry, action: ");
        mrsb.append(mapping.getAction().getName());
    } else {
        mrsb.append("-> Locator                                         State     Pri/Wgt");
        mrsb.append(NEW_LINE);
        mrsb.append(indent);
        boolean first = true;
        for (LocatorRecord record : mapping.getLocatorRecord()) {
            if (first) {
                first = false;
            } else {
                mrsb.append(NEW_LINE);
                mrsb.append(indent);
            }
            mrsb.append(getString(record, indentation + 3));
        }
    }
    return mrsb.toString();
}
Also used : LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)

Example 5 with MappingRecord

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.

the class LispSouthboundHandler method tryToAuthenticateMessage.

/**
 * Checks whether authentication data is valid.
 *
 * <p>Methods pass through all records from map register message. For the EID of the first record it gets
 * authentication key and does validation of authentication data again this authentication key. If it pass
 * it just checks for remaining records (and its EID) whether they have the same authentication key stored in
 * the authentication key database.
 *
 * @return Returns authentication key if all of EIDs have the same authentication key or null otherwise
 */
private MappingAuthkey tryToAuthenticateMessage(final MapRegister mapRegister, final ByteBuffer byteBuffer) {
    if (lispSbPlugin.getAkdb() == null) {
        LOG.debug("Simple map cache wasn't instantieted and set.");
        return null;
    }
    MappingAuthkey firstAuthKey = null;
    final List<MappingRecordItem> mappingRecords = mapRegister.getMappingRecordItem();
    for (int i = 0; i < mappingRecords.size(); i++) {
        final MappingRecordItem recordItem = mappingRecords.get(i);
        final MappingRecord mappingRecord = recordItem.getMappingRecord();
        if (i == 0) {
            firstAuthKey = lispSbPlugin.getAkdb().getAuthenticationKey(mappingRecord.getEid());
            if (!LispAuthenticationUtil.validate(mapRegister, byteBuffer, mappingRecord.getEid(), firstAuthKey)) {
                return null;
            }
        } else {
            final Eid eid = mappingRecord.getEid();
            final MappingAuthkey authKey = lispSbPlugin.getAkdb().getAuthenticationKey(eid);
            if (!firstAuthKey.equals(authKey)) {
                LOG.debug("Map register packet contained several eids. Authentication keys for first one and for " + "{} are different.", LispAddressStringifier.getString(eid));
                return null;
            }
        }
    }
    return firstAuthKey;
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) MappingRecordItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingAuthkey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey)

Aggregations

MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)56 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)31 Test (org.junit.Test)28 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)22 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)11 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)10 MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)10 LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)9 MappingRecordItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem)6 MappingBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder)6 ArrayList (java.util.ArrayList)5 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)5 EidUri (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.EidUri)5 Subscriber (org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)4 InstanceIdType (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType)4 AddMapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping)4 XtrId (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId)4 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)3 SourceDestKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey)3