Search in sources :

Example 1 with RegisterBuilder

use of org.onosproject.lisp.msg.protocols.LispMapRegister.RegisterBuilder in project onos by opennetworkinglab.

the class DefaultLispMapRegisterTest method setup.

@Before
public void setup() {
    RegisterBuilder builder1 = new DefaultRegisterBuilder();
    List<LispMapRecord> records1 = ImmutableList.of(getMapRecord(), getMapRecord());
    register1 = builder1.withIsProxyMapReply(true).withIsWantMapNotify(false).withKeyId((short) 1).withAuthKey(AUTH_KEY).withNonce(1L).withMapRecords(records1).build();
    RegisterBuilder builder2 = new DefaultRegisterBuilder();
    List<LispMapRecord> records2 = ImmutableList.of(getMapRecord(), getMapRecord());
    sameAsRegister1 = builder2.withIsProxyMapReply(true).withIsWantMapNotify(false).withKeyId((short) 1).withAuthKey(AUTH_KEY).withNonce(1L).withMapRecords(records2).build();
    RegisterBuilder builder3 = new DefaultRegisterBuilder();
    register2 = builder3.withIsProxyMapReply(true).withIsWantMapNotify(false).withKeyId((short) 2).withAuthKey(AUTH_KEY).withNonce(2L).build();
}
Also used : RegisterBuilder(org.onosproject.lisp.msg.protocols.LispMapRegister.RegisterBuilder) DefaultRegisterBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapRegister.DefaultRegisterBuilder) DefaultRegisterBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapRegister.DefaultRegisterBuilder) Before(org.junit.Before)

Example 2 with RegisterBuilder

use of org.onosproject.lisp.msg.protocols.LispMapRegister.RegisterBuilder in project onos by opennetworkinglab.

the class LispMapServer method checkMapRegisterAuthData.

/**
 * Checks the integrity of the received map-register message by calculating
 * authentication data from received map-register message.
 *
 * @param register map-register message
 * @return evaluation result
 */
private boolean checkMapRegisterAuthData(LispMapRegister register) {
    RegisterBuilder registerBuilder = new DefaultRegisterBuilder();
    registerBuilder.withKeyId(register.getKeyId());
    registerBuilder.withAuthKey(authConfig.lispAuthKey());
    registerBuilder.withNonce(register.getNonce());
    registerBuilder.withIsProxyMapReply(register.isProxyMapReply());
    registerBuilder.withIsWantMapNotify(register.isWantMapNotify());
    registerBuilder.withMapRecords(register.getMapRecords());
    LispMapRegister authRegister = registerBuilder.build();
    return Arrays.equals(authRegister.getAuthData(), register.getAuthData());
}
Also used : LispMapRegister(org.onosproject.lisp.msg.protocols.LispMapRegister) RegisterBuilder(org.onosproject.lisp.msg.protocols.LispMapRegister.RegisterBuilder) DefaultRegisterBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapRegister.DefaultRegisterBuilder) DefaultRegisterBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapRegister.DefaultRegisterBuilder)

Example 3 with RegisterBuilder

use of org.onosproject.lisp.msg.protocols.LispMapRegister.RegisterBuilder 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 4 with RegisterBuilder

use of org.onosproject.lisp.msg.protocols.LispMapRegister.RegisterBuilder in project onos by opennetworkinglab.

the class DefaultLispEncapsulatedControlTest method setup.

@Before
public void setup() {
    // Creates ecm1
    EcmBuilder builder1 = new DefaultEcmBuilder();
    IP innerIp1 = new IPv4().setSourceAddress(ECM1_SRC_IP).setDestinationAddress(ECM1_DST_IP).setProtocol(IPv4.PROTOCOL_UDP).setVersion((byte) (4 & 0xf));
    UDP innerUdp1 = new UDP().setSourcePort(1).setDestinationPort(2);
    RegisterBuilder msgBuilder = new DefaultRegisterBuilder();
    List<LispMapRecord> records1 = ImmutableList.of(getMapRecord(), getMapRecord());
    LispMapRegister innerMsg1 = msgBuilder.withIsProxyMapReply(true).withIsWantMapNotify(false).withKeyId((short) 1).withAuthKey(AUTH_KEY).withNonce(1L).withMapRecords(records1).build();
    ecm1 = builder1.isSecurity(false).innerIpHeader(innerIp1).innerUdpHeader(innerUdp1).innerLispMessage(innerMsg1).build();
    // Creates sameAsEcm1
    EcmBuilder builder2 = new DefaultEcmBuilder();
    IP innerIp2 = new IPv4().setSourceAddress(ECM1_SRC_IP).setDestinationAddress(ECM1_DST_IP).setProtocol(IPv4.PROTOCOL_UDP);
    UDP innerUdp2 = new UDP().setSourcePort(1).setDestinationPort(2);
    RegisterBuilder msgBuilder2 = new DefaultRegisterBuilder();
    List<LispMapRecord> records2 = ImmutableList.of(getMapRecord(), getMapRecord());
    LispMapRegister innerMsg2 = msgBuilder2.withIsProxyMapReply(true).withIsWantMapNotify(false).withKeyId((short) 1).withAuthKey(AUTH_KEY).withNonce(1L).withMapRecords(records2).build();
    sameAsEcm1 = builder2.isSecurity(false).innerIpHeader(innerIp2).innerUdpHeader(innerUdp2).innerLispMessage(innerMsg2).build();
    // Creates ecm2
    EcmBuilder builder3 = new DefaultEcmBuilder();
    IP innerIp3 = new IPv4().setSourceAddress(ECM2_SRC_IP).setDestinationAddress(ECM2_DST_IP).setProtocol(IPv4.PROTOCOL_UDP);
    UDP innerUdp3 = new UDP().setSourcePort(10).setDestinationPort(20);
    RegisterBuilder msgBuilder3 = new DefaultRegisterBuilder();
    List<LispMapRecord> records3 = ImmutableList.of(getMapRecord(), getMapRecord());
    LispMapRegister innerMsg3 = msgBuilder3.withIsProxyMapReply(true).withIsWantMapNotify(false).withKeyId((short) 2).withAuthKey(AUTH_KEY).withNonce(1L).withMapRecords(records3).build();
    ecm2 = builder3.isSecurity(false).innerIpHeader(innerIp3).innerUdpHeader(innerUdp3).innerLispMessage(innerMsg3).build();
}
Also used : UDP(org.onlab.packet.UDP) DefaultEcmBuilder(org.onosproject.lisp.msg.protocols.DefaultLispEncapsulatedControl.DefaultEcmBuilder) EcmBuilder(org.onosproject.lisp.msg.protocols.LispEncapsulatedControl.EcmBuilder) IP(org.onlab.packet.IP) IPv4(org.onlab.packet.IPv4) DefaultEcmBuilder(org.onosproject.lisp.msg.protocols.DefaultLispEncapsulatedControl.DefaultEcmBuilder) RegisterBuilder(org.onosproject.lisp.msg.protocols.LispMapRegister.RegisterBuilder) DefaultRegisterBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapRegister.DefaultRegisterBuilder) DefaultRegisterBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapRegister.DefaultRegisterBuilder) Before(org.junit.Before)

Aggregations

DefaultRegisterBuilder (org.onosproject.lisp.msg.protocols.DefaultLispMapRegister.DefaultRegisterBuilder)4 RegisterBuilder (org.onosproject.lisp.msg.protocols.LispMapRegister.RegisterBuilder)4 Before (org.junit.Before)2 LispMapRegister (org.onosproject.lisp.msg.protocols.LispMapRegister)2 Test (org.junit.Test)1 IP (org.onlab.packet.IP)1 IPv4 (org.onlab.packet.IPv4)1 UDP (org.onlab.packet.UDP)1 DefaultEcmBuilder (org.onosproject.lisp.msg.protocols.DefaultLispEncapsulatedControl.DefaultEcmBuilder)1 DefaultNotifyBuilder (org.onosproject.lisp.msg.protocols.DefaultLispMapNotify.DefaultNotifyBuilder)1 EcmBuilder (org.onosproject.lisp.msg.protocols.LispEncapsulatedControl.EcmBuilder)1 LispMapNotify (org.onosproject.lisp.msg.protocols.LispMapNotify)1 NotifyBuilder (org.onosproject.lisp.msg.protocols.LispMapNotify.NotifyBuilder)1 LispMapRecord (org.onosproject.lisp.msg.protocols.LispMapRecord)1