Search in sources :

Example 1 with DefaultNotifyBuilder

use of org.onosproject.lisp.msg.protocols.DefaultLispMapNotify.DefaultNotifyBuilder in project onos by opennetworkinglab.

the class LispMapServer method processMapRegister.

/**
 * Handles map-register message and replies with map-notify message.
 *
 * @param message map-register message
 * @return map-notify message
 */
LispMapNotify processMapRegister(LispMessage message) {
    LispMapRegister register = (LispMapRegister) message;
    if (!checkMapRegisterAuthData(register)) {
        log.warn(INVALID_AUTHENTICATION_DATA_MSG, "Map-Register");
        return null;
    }
    register.getMapRecords().forEach(mapRecord -> {
        LispEidRecord eidRecord = new LispEidRecord(mapRecord.getMaskLength(), mapRecord.getEidPrefixAfi());
        LispMapRecord oldMapRecord = mapDb.getMapRecordByEidRecord(eidRecord, register.isProxyMapReply());
        if (oldMapRecord == null) {
            mapDb.putMapRecord(eidRecord, mapRecord, register.isProxyMapReply());
        } else {
            if (oldMapRecord.getMapVersionNumber() <= mapRecord.getMapVersionNumber()) {
                mapDb.putMapRecord(eidRecord, mapRecord, register.isProxyMapReply());
                if (enableSmr) {
                    sendSmrMessage(eidRecord);
                }
            }
        }
    });
    // otherwise, we do not acknowledge back to ETR
    if (register.isWantMapNotify()) {
        NotifyBuilder notifyBuilder = new DefaultNotifyBuilder();
        notifyBuilder.withKeyId(authConfig.lispAuthKeyId());
        notifyBuilder.withAuthDataLength(valueOf(authConfig.lispAuthKeyId()).getHashLength());
        notifyBuilder.withAuthKey(authConfig.lispAuthKey());
        notifyBuilder.withNonce(register.getNonce());
        notifyBuilder.withMapRecords(register.getMapRecords());
        LispMapNotify notify = notifyBuilder.build();
        InetSocketAddress address = new InetSocketAddress(register.getSender().getAddress(), MAP_NOTIFY_PORT);
        notify.configSender(address);
        return notify;
    }
    return null;
}
Also used : NotifyBuilder(org.onosproject.lisp.msg.protocols.LispMapNotify.NotifyBuilder) DefaultNotifyBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapNotify.DefaultNotifyBuilder) LispMapRegister(org.onosproject.lisp.msg.protocols.LispMapRegister) LispMapNotify(org.onosproject.lisp.msg.protocols.LispMapNotify) InetSocketAddress(java.net.InetSocketAddress) LispMapRecord(org.onosproject.lisp.msg.protocols.LispMapRecord) DefaultNotifyBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapNotify.DefaultNotifyBuilder) LispEidRecord(org.onosproject.lisp.msg.protocols.LispEidRecord)

Example 2 with DefaultNotifyBuilder

use of org.onosproject.lisp.msg.protocols.DefaultLispMapNotify.DefaultNotifyBuilder in project onos by opennetworkinglab.

the class LispControllerImplTest method testLispMessagePopulate.

/**
 * Tests adding and removing LISP messages.
 */
@Test
public void testLispMessagePopulate() throws InterruptedException {
    RegisterBuilder registerBuilder = new DefaultRegisterBuilder();
    List<LispMapRecord> records = ImmutableList.of(getMapRecord(), getMapRecord());
    LispMapRegister register = registerBuilder.withIsProxyMapReply(true).withIsWantMapNotify(false).withKeyId((short) 1).withAuthKey("onos").withNonce(1L).withMapRecords(records).build();
    NotifyBuilder notifyBuilder = new DefaultNotifyBuilder();
    LispMapNotify notify = notifyBuilder.withKeyId((short) 1).withAuthKey("onos").withNonce(1L).withMapRecords(records).build();
    // Test the callback methods that contained in message listener is fired
    agent.processUpstreamMessage(routerId1, register);
    // Following line will be ignored
    agent.processUpstreamMessage(routerId1, notify);
    agent.processDownstreamMessage(routerId1, notify);
    // Following line will be ignored
    agent.processDownstreamMessage(routerId1, register);
    messageListener.waitUntilUpdateIsCalled();
    assertThat(messageListener.incomingMessages, hasSize(1));
    assertThat(messageListener.incomingMessages, hasItems(register));
    assertThat(messageListener.outgoingMessages, hasSize(1));
    assertThat(messageListener.outgoingMessages, hasItems(notify));
}
Also used : NotifyBuilder(org.onosproject.lisp.msg.protocols.LispMapNotify.NotifyBuilder) DefaultNotifyBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapNotify.DefaultNotifyBuilder) LispMapRegister(org.onosproject.lisp.msg.protocols.LispMapRegister) LispMapNotify(org.onosproject.lisp.msg.protocols.LispMapNotify) RegisterBuilder(org.onosproject.lisp.msg.protocols.LispMapRegister.RegisterBuilder) DefaultRegisterBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapRegister.DefaultRegisterBuilder) DefaultRegisterBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapRegister.DefaultRegisterBuilder) LispMapRecord(org.onosproject.lisp.msg.protocols.LispMapRecord) DefaultNotifyBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapNotify.DefaultNotifyBuilder) Test(org.junit.Test)

Example 3 with DefaultNotifyBuilder

use of org.onosproject.lisp.msg.protocols.DefaultLispMapNotify.DefaultNotifyBuilder in project onos by opennetworkinglab.

the class DefaultLispMapNotifyTest method setup.

@Before
public void setup() {
    NotifyBuilder builder1 = new DefaultNotifyBuilder();
    List<LispMapRecord> records1 = ImmutableList.of(getMapRecord(), getMapRecord());
    notify1 = builder1.withKeyId((short) 1).withAuthKey(AUTH_KEY).withNonce(1L).withMapRecords(records1).build();
    NotifyBuilder builder2 = new DefaultNotifyBuilder();
    List<LispMapRecord> records2 = ImmutableList.of(getMapRecord(), getMapRecord());
    sameAsNotify1 = builder2.withKeyId((short) 1).withAuthKey(AUTH_KEY).withNonce(1L).withMapRecords(records2).build();
    NotifyBuilder builder3 = new DefaultNotifyBuilder();
    notify2 = builder3.withKeyId((short) 2).withAuthKey(AUTH_KEY).withNonce(2L).build();
}
Also used : NotifyBuilder(org.onosproject.lisp.msg.protocols.LispMapNotify.NotifyBuilder) DefaultNotifyBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapNotify.DefaultNotifyBuilder) DefaultNotifyBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapNotify.DefaultNotifyBuilder) Before(org.junit.Before)

Example 4 with DefaultNotifyBuilder

use of org.onosproject.lisp.msg.protocols.DefaultLispMapNotify.DefaultNotifyBuilder in project onos by opennetworkinglab.

the class MappingEntryBuilderTest method testMapNotifyConversion.

@Test
public void testMapNotifyConversion() {
    List<LispMapRecord> records = ImmutableList.of(getMapRecord(IP4, UNKNOWN));
    NotifyBuilder notifyBuilder = new DefaultNotifyBuilder();
    LispMapNotify mapNotify = notifyBuilder.withKeyId(UNIQUE_SHORT).withAuthKey(AUTH_KEY).withNonce(UNIQUE_LONG).withMapRecords(records).build();
    List<LispMapRecord> notifyRecords = mapNotify.getMapRecords();
    assertThat(notifyRecords.size(), is(1));
    testMapRecordConversion(notifyRecords.get(0));
}
Also used : NotifyBuilder(org.onosproject.lisp.msg.protocols.LispMapNotify.NotifyBuilder) DefaultNotifyBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapNotify.DefaultNotifyBuilder) LispMapNotify(org.onosproject.lisp.msg.protocols.LispMapNotify) LispMapRecord(org.onosproject.lisp.msg.protocols.LispMapRecord) DefaultNotifyBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapNotify.DefaultNotifyBuilder) Test(org.junit.Test)

Aggregations

DefaultNotifyBuilder (org.onosproject.lisp.msg.protocols.DefaultLispMapNotify.DefaultNotifyBuilder)4 NotifyBuilder (org.onosproject.lisp.msg.protocols.LispMapNotify.NotifyBuilder)4 LispMapNotify (org.onosproject.lisp.msg.protocols.LispMapNotify)3 LispMapRecord (org.onosproject.lisp.msg.protocols.LispMapRecord)3 Test (org.junit.Test)2 LispMapRegister (org.onosproject.lisp.msg.protocols.LispMapRegister)2 InetSocketAddress (java.net.InetSocketAddress)1 Before (org.junit.Before)1 DefaultRegisterBuilder (org.onosproject.lisp.msg.protocols.DefaultLispMapRegister.DefaultRegisterBuilder)1 LispEidRecord (org.onosproject.lisp.msg.protocols.LispEidRecord)1 RegisterBuilder (org.onosproject.lisp.msg.protocols.LispMapRegister.RegisterBuilder)1