Search in sources :

Example 81 with Eid

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid in project lispflowmapping by opendaylight.

the class LispUtil method buildAddKeyInput.

public static AddKeyInput buildAddKeyInput(Eid eid, String net) {
    AddKeyInputBuilder kib = new AddKeyInputBuilder();
    kib.setEid(eid).setMappingAuthkey(new MappingAuthkeyBuilder().setKeyString(net).setKeyType(1).build());
    return kib.build();
}
Also used : MappingAuthkeyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkeyBuilder) AddKeyInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeyInputBuilder)

Example 82 with Eid

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid in project lispflowmapping by opendaylight.

the class LispUtil method buildAddMappingInput.

// private static final Logger LOG = LoggerFactory.getLogger(LispUtil.class);
public static AddMappingInput buildAddMappingInput(Eid eid, List<LocatorRecord> locators) {
    MappingRecordBuilder mrb = new MappingRecordBuilder();
    mrb.setAction(Action.NoAction).setAuthoritative(true).setEid(eid).setLocatorRecord(locators).setMapVersion((short) 0).setRecordTtl(1440);
    AddMappingInputBuilder mib = new AddMappingInputBuilder();
    mib.setMappingRecord(mrb.build());
    return mib.build();
}
Also used : MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) AddMappingInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddMappingInputBuilder)

Example 83 with Eid

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid 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)

Example 84 with Eid

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid in project lispflowmapping by opendaylight.

the class LispSouthboundHandlerTest method mapRegister__TwoRlocs.

@Test
public void mapRegister__TwoRlocs() throws Exception {
    // P Bit & M Bit set
    // EID prefix: 172.1.1.2/32, TTL: 10, Authoritative, No-Action
    // Local RLOC: 10.1.0.110, Reachable, Priority/Weight: 1/100, Multicast
    // Priority/Weight: 255/0
    // Local RLOC: 192.168.136.51, Reachable, Priority/Weight: 6/100,
    // Multicast Priority/Weight: 255/0
    mapRegisterPacket = extractWSUdpByteArray("0000   00 0c 29 7a ce 8d 00 0c 29 e4 ef 70 08 00 45 00 " + "0010   00 68 00 00 40 00 40 11 26 15 0a 01 00 6e 0a 01 " + "0020   00 01 10 f6 10 f6 00 54 03 3b 38 00 01 01 00 00 " + "0030   00 00 00 00 00 00 00 01 00 14 ae d8 7b d4 9c 59 " + "0040   e9 35 75 6e f1 29 27 a3 45 20 96 06 c2 e1 00 00 " + "0050   00 0a 02 20 10 00 00 00 00 01 ac 01 01 02 01 64 " + "0060   ff 00 00 05 00 01 0a 01 00 6e 06 64 ff 00 00 05 " + "0070   00 01 c0 a8 88 33");
    ArgumentCaptor<AddMapping> captor = ArgumentCaptor.forClass(AddMapping.class);
    handleMapRegisterPacket(mapRegisterPacket);
    Mockito.verify(mockLispSouthboundPlugin).sendNotificationIfPossible(captor.capture());
    List<MappingRecordItem> eidRecords = captor.getValue().getMapRegister().getMappingRecordItem();
    assertEquals(1, eidRecords.size());
    MappingRecord eidRecord = eidRecords.get(0).getMappingRecord();
    assertEquals(2, eidRecord.getLocatorRecord().size());
    assertEquals(LispAddressUtil.asIpv4Rloc("10.1.0.110"), eidRecord.getLocatorRecord().get(0).getRloc());
    assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.51"), eidRecord.getLocatorRecord().get(1).getRloc());
}
Also used : AddMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping) 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) Test(org.junit.Test)

Example 85 with Eid

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid in project lispflowmapping by opendaylight.

the class LispSouthboundHandlerTest method mapRegister_isMappingKeepAliveAndMapNotifyGenerated.

/**
 * Tests whether handling of map-register message will generate mapping-keep-alive notification.
 */
@Test
public void mapRegister_isMappingKeepAliveAndMapNotifyGenerated() throws InterruptedException, UnknownHostException {
    byte[] eidPrefixAfi = new byte[] { // eid-prefix-afi
    0x00, 0x01 };
    byte[] eidPrefix = new byte[] { // ipv4 address
    0x0a, 0x0a, 0x0a, 0x0a };
    // send stream of byte -> map register message
    InOrder inOrder = Mockito.inOrder(mockLispSouthboundPlugin);
    final MapRegisterCacheKey cacheKey = MapRegisterCacheTestUtil.createMapRegisterCacheKey(eidPrefix);
    MapRegisterCacheTestUtil.beforeMapRegisterInvocationValidation(cacheKey, mapRegisterCache);
    ArgumentCaptor<AddMapping> captor = ArgumentCaptor.forClass(AddMapping.class);
    mapRegisterInvocationForCacheTest(eidPrefixAfi, eidPrefix);
    inOrder.verify(mockLispSouthboundPlugin).sendNotificationIfPossible(captor.capture());
    MapRegisterCacheTestUtil.afterMapRegisterInvocationValidation(cacheKey, mapRegisterCache, eidPrefixAfi, eidPrefix);
    // sending the same byte stream -> map register second time
    captor = ArgumentCaptor.forClass(AddMapping.class);
    mapRegisterInvocationForCacheTest(eidPrefixAfi, eidPrefix);
    inOrder.verify(mockLispSouthboundPlugin).sendNotificationIfPossible(captor.capture());
    // mapping-keep-alive message should be generated
    MapRegisterCacheTestUtil.afterSecondMapRegisterInvocationValidation(mockLispSouthboundPlugin, eidPrefixAfi, eidPrefix);
}
Also used : InOrder(org.mockito.InOrder) MapRegisterCacheKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.key.container.MapRegisterCacheKey) AddMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping) Test(org.junit.Test)

Aggregations

Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)173 Test (org.junit.Test)98 EidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder)51 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)28 MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)28 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)27 SourceDestKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey)19 ILispDAO (org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO)18 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)18 MapRegister (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister)17 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)16 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)15 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)14 MapRequest (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest)13 SourceEidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder)13 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)12 MapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify)11 ArrayList (java.util.ArrayList)10 Ipv4PrefixBinary (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary)10 Ipv6PrefixBinary (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinary)10