use of org.onosproject.lisp.msg.protocols.DefaultLispMapRegister.DefaultRegisterBuilder 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();
}
use of org.onosproject.lisp.msg.protocols.DefaultLispMapRegister.DefaultRegisterBuilder 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());
}
use of org.onosproject.lisp.msg.protocols.DefaultLispMapRegister.DefaultRegisterBuilder 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));
}
use of org.onosproject.lisp.msg.protocols.DefaultLispMapRegister.DefaultRegisterBuilder 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();
}
Aggregations