use of org.onosproject.lisp.msg.types.LispIpv4Address in project onos by opennetworkinglab.
the class LispTeLcafAddressTest method setup.
@Before
public void setup() {
TeAddressBuilder builder1 = new TeAddressBuilder();
TeRecordBuilder recordBuilder1 = new TeRecordBuilder();
LispIpv4Address rtrRloc1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
recordBuilder1.withIsLookup(false);
recordBuilder1.withIsRlocProbe(false);
recordBuilder1.withIsStrict(false);
recordBuilder1.withRtrRlocAddress(rtrRloc1);
LispTeRecord record1 = recordBuilder1.build();
TeRecordBuilder recordBuilder2 = new TeRecordBuilder();
LispIpv4Address rtrRloc2 = new LispIpv4Address(IpAddress.valueOf("192.168.1.2"));
recordBuilder2.withIsLookup(false);
recordBuilder2.withIsRlocProbe(true);
recordBuilder2.withIsStrict(false);
recordBuilder2.withRtrRlocAddress(rtrRloc2);
LispTeRecord record2 = recordBuilder2.build();
builder1.withTeRecords(ImmutableList.of(record1, record2));
address1 = builder1.build();
TeAddressBuilder builder2 = new TeAddressBuilder();
TeRecordBuilder recordBuilder3 = new TeRecordBuilder();
recordBuilder3.withIsLookup(false);
recordBuilder3.withIsRlocProbe(false);
recordBuilder3.withIsStrict(false);
recordBuilder3.withRtrRlocAddress(rtrRloc1);
LispTeRecord record3 = recordBuilder3.build();
TeRecordBuilder recordBuilder4 = new TeRecordBuilder();
recordBuilder4.withIsLookup(false);
recordBuilder4.withIsRlocProbe(true);
recordBuilder4.withIsStrict(false);
recordBuilder4.withRtrRlocAddress(rtrRloc2);
LispTeRecord record4 = recordBuilder4.build();
builder2.withTeRecords(ImmutableList.of(record3, record4));
sameAsAddress1 = builder2.build();
TeAddressBuilder builder3 = new TeAddressBuilder();
TeRecordBuilder recordBuilder5 = new TeRecordBuilder();
LispIpv4Address rtrRloc3 = new LispIpv4Address(IpAddress.valueOf("192.168.2.1"));
recordBuilder5.withIsLookup(true);
recordBuilder5.withIsRlocProbe(false);
recordBuilder5.withIsStrict(true);
recordBuilder5.withRtrRlocAddress(rtrRloc3);
LispTeRecord record5 = recordBuilder5.build();
TeRecordBuilder recordBuilder6 = new TeRecordBuilder();
LispIpv4Address rtrRloc4 = new LispIpv4Address(IpAddress.valueOf("192.168.2.2"));
recordBuilder6.withIsLookup(true);
recordBuilder6.withIsRlocProbe(true);
recordBuilder6.withIsStrict(true);
recordBuilder6.withRtrRlocAddress(rtrRloc4);
LispTeRecord record6 = recordBuilder6.build();
builder3.withTeRecords(ImmutableList.of(record5, record6));
address2 = builder3.build();
}
use of org.onosproject.lisp.msg.types.LispIpv4Address in project onos by opennetworkinglab.
the class LispMapServer method sendSmrMessage.
/**
* Sends SMR (Solicit Map Request) to their subscribers.
*
* @param eidRecord the updated EID
*/
private void sendSmrMessage(LispEidRecord eidRecord) {
RequestBuilder builder = new DefaultRequestBuilder();
LispAfiAddress msAddress = null;
try {
msAddress = new LispIpv4Address(IpAddress.valueOf(InetAddress.getLocalHost()));
} catch (UnknownHostException e) {
log.warn("Source EID is not found, {}", e.getMessage());
}
LispMapRequest msg = builder.withIsSmr(true).withIsSmrInvoked(true).withIsProbe(false).withIsPitr(false).withIsAuthoritative(false).withIsMapDataPresent(false).withSourceEid(msAddress).withEidRecords(ImmutableList.of(eidRecord)).build();
LispRouterFactory routerFactory = LispRouterFactory.getInstance();
Collection<LispRouter> routers = routerFactory.getRouters();
routers.forEach(router -> {
if (isInEidRecordRange(eidRecord, router.getEidRecords())) {
router.sendMessage(msg);
}
});
}
use of org.onosproject.lisp.msg.types.LispIpv4Address in project onos by opennetworkinglab.
the class LispMapServer method processInfoRequest.
/**
* Handles info-request message and replies with info-reply message.
*
* @param message info-request message
* @return info-reply message
*/
LispInfoReply processInfoRequest(LispMessage message) {
LispInfoRequest request = (LispInfoRequest) message;
if (!checkInfoRequestAuthData(request)) {
log.warn(INVALID_AUTHENTICATION_DATA_MSG, "Info-Request");
return null;
}
NatAddressBuilder natBuilder = new NatAddressBuilder();
try {
LispAfiAddress msAddress = new LispIpv4Address(valueOf(InetAddress.getLocalHost()));
natBuilder.withMsRlocAddress(msAddress);
natBuilder.withMsUdpPortNumber((short) INFO_REPLY_PORT);
// try to extract global ETR RLOC address from info-request
IpAddress globalRlocIp = valueOf(request.getSender().getAddress());
LispAfiAddress globalRlocAddress;
if (globalRlocIp.isIp4()) {
globalRlocAddress = new LispIpv4Address(globalRlocIp);
} else {
globalRlocAddress = new LispIpv6Address(globalRlocIp);
}
natBuilder.withGlobalEtrRlocAddress(globalRlocAddress);
natBuilder.withEtrUdpPortNumber((short) request.getSender().getPort());
natBuilder.withPrivateEtrRlocAddress(new LispNoAddress());
// TODO: need to specify RTR addresses
} catch (UnknownHostException e) {
log.warn(FAILED_TO_FORMULATE_NAT_MSG, e);
}
InfoReplyBuilder replyBuilder = new DefaultInfoReplyBuilder();
replyBuilder.withKeyId(request.getKeyId());
replyBuilder.withAuthDataLength(valueOf(authConfig.lispAuthKeyId()).getHashLength());
replyBuilder.withAuthKey(authConfig.lispAuthKey());
replyBuilder.withNonce(request.getNonce());
replyBuilder.withEidPrefix(request.getPrefix());
replyBuilder.withMaskLength(request.getMaskLength());
replyBuilder.withTtl(request.getTtl());
replyBuilder.withNatLcafAddress(natBuilder.build());
replyBuilder.withIsInfoReply(true);
LispInfoReply reply = replyBuilder.build();
reply.configSender(request.getSender());
return reply;
}
use of org.onosproject.lisp.msg.types.LispIpv4Address in project onos by opennetworkinglab.
the class LispMappingDatabaseTest method test12MaskRange.
@Test
public void test12MaskRange() {
byte cidr32 = (byte) 32;
LispIpv4Address eid = new LispIpv4Address(IpAddress.valueOf(EID_IP_PREFIX_1_32));
LispEidRecord record32 = new LispEidRecord(cidr32, eid);
LispMapRecord mapRecordExpireMap32 = expireMapDb.getMapRecordByEidRecord(record32, true);
LispMapRecord mapRecordRadixTree32 = radixTreeDb.getMapRecordByEidRecord(record32, true);
byte cidr24 = (byte) 24;
LispIpv4Address eid24 = new LispIpv4Address(IpAddress.valueOf(EID_IP_PREFIX_1_24));
LispEidRecord record24 = new LispEidRecord(cidr24, eid24);
LispMapRecord mapRecordExpireMap24 = expireMapDb.getMapRecordByEidRecord(record24, true);
LispMapRecord mapRecordRadixTree24 = radixTreeDb.getMapRecordByEidRecord(record32, true);
byte cidr16 = (byte) 16;
LispIpv4Address eid16 = new LispIpv4Address(IpAddress.valueOf(EID_IP_PREFIX_1_16));
LispEidRecord record16 = new LispEidRecord(cidr16, eid16);
LispMapRecord mapRecordExpireMap16 = expireMapDb.getMapRecordByEidRecord(record16, true);
LispMapRecord mapRecordRadixTree16 = radixTreeDb.getMapRecordByEidRecord(record16, true);
byte cidr12 = (byte) 12;
LispIpv4Address eid12 = new LispIpv4Address(IpAddress.valueOf(EID_IP_PREFIX_1_12));
LispEidRecord record12 = new LispEidRecord(cidr12, eid12);
LispMapRecord mapRecordExpireMap12 = expireMapDb.getMapRecordByEidRecord(record12, true);
LispMapRecord mapRecordRadixTree12 = radixTreeDb.getMapRecordByEidRecord(record12, true);
assertThat("Failed to fetch the RLOCs with /32 EID record", mapRecordExpireMap32.getLocatorCount(), is(2));
assertThat("Failed to fetch the RLOCs with /24 EID record", mapRecordExpireMap24.getLocatorCount(), is(2));
assertThat("Failed to fetch the RLOCs with /16 EID record", mapRecordExpireMap16.getLocatorCount(), is(2));
assertThat("Failed to fetch the RLOCs with /12 EID record", mapRecordExpireMap12.getLocatorCount(), is(1));
assertThat("Failed to fetch the RLOCs with /32 EID record", mapRecordRadixTree32.getLocatorCount(), is(2));
assertThat("Failed to fetch the RLOCs with /24 EID record", mapRecordRadixTree24.getLocatorCount(), is(2));
assertThat("Failed to fetch the RLOCs with /16 EID record", mapRecordRadixTree16.getLocatorCount(), is(2));
assertThat("Failed to fetch the RLOCs with /12 EID record", mapRecordRadixTree12.getLocatorCount(), is(1));
LispIpv4Address wrongEid = new LispIpv4Address(IpAddress.valueOf(EID_IP_PREFIX_3_24));
LispEidRecord wrongRecord = new LispEidRecord(cidr24, wrongEid);
LispMapRecord nullRecord = expireMapDb.getMapRecordByEidRecord(wrongRecord, true);
assertNull("The record should be null", nullRecord);
}
use of org.onosproject.lisp.msg.types.LispIpv4Address in project onos by opennetworkinglab.
the class MappingEntryBuilderTest method getMapRecord.
/**
* Obtains a MapRecord instance.
*
* @param afiType AFI address type
* @param lcafType LCAF address type
* @return a MapRecord instance
*/
private LispMapRecord getMapRecord(AddressFamilyIdentifierEnum afiType, LispCanonicalAddressFormatEnum lcafType) {
MapRecordBuilder recordBuilder = new DefaultMapRecordBuilder();
LispIpv4Address recordAddress = new LispIpv4Address(IpAddress.valueOf(IP_RECORD_ADDRESS));
LocatorBuilder locatorBuilder = new DefaultLocatorBuilder();
LispAfiAddress locatorAddress = getAfiAddress(afiType, lcafType);
LispLocator locator = locatorBuilder.withPriority(UNIQUE_BYTE).withWeight(UNIQUE_BYTE).withMulticastPriority(UNIQUE_BYTE).withMulticastWeight(UNIQUE_BYTE).withLocalLocator(true).withRlocProbed(false).withRouted(true).withLocatorAfi(locatorAddress).build();
return recordBuilder.withRecordTtl(UNIQUE_INT).withIsAuthoritative(true).withMapVersionNumber(UNIQUE_SHORT).withMaskLength((byte) IP_RECORD_MASK_LENGTH).withAction(LispMapReplyAction.NativelyForward).withEidPrefixAfi(recordAddress).withLocators(ImmutableList.of(locator)).build();
}
Aggregations