use of org.onosproject.lisp.msg.types.lcaf.LispNatLcafAddress in project onos by opennetworkinglab.
the class DefaultLispInfoReplyTest method testConstruction.
@Test
public void testConstruction() {
DefaultLispInfoReply reply = (DefaultLispInfoReply) reply1;
LispIpv4Address address = new LispIpv4Address(IpAddress.valueOf("192.168.1.4"));
short msUdpPortNumber1 = 80;
short etrUdpPortNumber1 = 100;
LispIpv4Address globalEtrRlocAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
LispIpv4Address msRlocAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.2"));
LispIpv4Address privateEtrRlocAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.3"));
LispNatLcafAddress natLcafAddress = new NatAddressBuilder().withLength((short) 0).withMsUdpPortNumber(msUdpPortNumber1).withEtrUdpPortNumber(etrUdpPortNumber1).withGlobalEtrRlocAddress(globalEtrRlocAddress1).withMsRlocAddress(msRlocAddress1).withPrivateEtrRlocAddress(privateEtrRlocAddress1).build();
assertThat(reply.isInfoReply(), is(true));
assertThat(reply.getNonce(), is(1L));
assertThat(reply.getKeyId(), is((short) 1));
assertThat(reply.getMaskLength(), is((byte) 1));
assertThat(reply.getPrefix(), is(address));
assertThat(reply.getNatLcafAddress(), is(natLcafAddress));
}
use of org.onosproject.lisp.msg.types.lcaf.LispNatLcafAddress in project onos by opennetworkinglab.
the class LispExtensionMappingAddressInterpreter method mapLcafAddress.
@Override
public ExtensionMappingAddress mapLcafAddress(LispLcafAddress lcafAddress) {
switch(lcafAddress.getType()) {
case LIST:
LispListLcafAddress lcafListAddress = (LispListLcafAddress) lcafAddress;
MappingAddress ipv4Ma = afi2mapping(lcafListAddress.getAddresses().get(0));
MappingAddress ipv6Ma = afi2mapping(lcafListAddress.getAddresses().get(1));
return new LispListAddress.Builder().withIpv4(ipv4Ma).withIpv6(ipv6Ma).build();
case SEGMENT:
LispSegmentLcafAddress segmentLcafAddress = (LispSegmentLcafAddress) lcafAddress;
return new LispSegmentAddress.Builder().withInstanceId(segmentLcafAddress.getInstanceId()).withAddress(getMappingAddress(segmentLcafAddress.getAddress())).build();
case AS:
LispAsLcafAddress asLcafAddress = (LispAsLcafAddress) lcafAddress;
return new org.onosproject.drivers.lisp.extensions.LispAsAddress.Builder().withAsNumber(asLcafAddress.getAsNumber()).withAddress(getMappingAddress(asLcafAddress.getAddress())).build();
case APPLICATION_DATA:
LispAppDataLcafAddress appLcafAddress = (LispAppDataLcafAddress) lcafAddress;
return new LispAppDataAddress.Builder().withProtocol(appLcafAddress.getProtocol()).withIpTos(appLcafAddress.getIpTos()).withLocalPortLow(appLcafAddress.getLocalPortLow()).withLocalPortHigh(appLcafAddress.getLocalPortHigh()).withRemotePortLow(appLcafAddress.getRemotePortLow()).withRemotePortHigh(appLcafAddress.getRemotePortHigh()).withAddress(getMappingAddress(appLcafAddress.getAddress())).build();
case GEO_COORDINATE:
LispGeoCoordinateLcafAddress gcLcafAddress = (LispGeoCoordinateLcafAddress) lcafAddress;
return new LispGcAddress.Builder().withIsNorth(gcLcafAddress.isNorth()).withLatitudeDegree(gcLcafAddress.getLatitudeDegree()).withLatitudeMinute(gcLcafAddress.getLatitudeMinute()).withLatitudeSecond(gcLcafAddress.getLatitudeSecond()).withIsEast(gcLcafAddress.isEast()).withLongitudeDegree(gcLcafAddress.getLongitudeDegree()).withLongitudeMinute(gcLcafAddress.getLongitudeMinute()).withLongitudeSecond(gcLcafAddress.getLongitudeSecond()).withAltitude(gcLcafAddress.getAltitude()).withAddress(getMappingAddress(gcLcafAddress.getAddress())).build();
case NAT:
LispNatLcafAddress natLcafAddress = (LispNatLcafAddress) lcafAddress;
List<MappingAddress> mas = Lists.newArrayList();
natLcafAddress.getRtrRlocAddresses().forEach(rtr -> mas.add(getMappingAddress(rtr)));
return new LispNatAddress.Builder().withMsUdpPortNumber(natLcafAddress.getMsUdpPortNumber()).withEtrUdpPortNumber(natLcafAddress.getEtrUdpPortNumber()).withMsRlocAddress(getMappingAddress(natLcafAddress.getMsRlocAddress())).withGlobalEtrRlocAddress(getMappingAddress(natLcafAddress.getGlobalEtrRlocAddress())).withPrivateEtrRlocAddress(getMappingAddress(natLcafAddress.getPrivateEtrRlocAddress())).withRtrRlocAddresses(mas).build();
case NONCE:
LispNonceLcafAddress nonceLcafAddress = (LispNonceLcafAddress) lcafAddress;
return new LispNonceAddress.Builder().withNonce(nonceLcafAddress.getNonce()).withAddress(getMappingAddress(nonceLcafAddress.getAddress())).build();
case MULTICAST:
LispMulticastLcafAddress multiLcafAddress = (LispMulticastLcafAddress) lcafAddress;
return new LispMulticastAddress.Builder().withInstanceId(multiLcafAddress.getInstanceId()).withSrcAddress(getMappingAddress(multiLcafAddress.getSrcAddress())).withSrcMaskLength(multiLcafAddress.getSrcMaskLength()).withGrpAddress(getMappingAddress(multiLcafAddress.getGrpAddress())).withGrpMaskLength(multiLcafAddress.getGrpMaskLength()).build();
case TRAFFIC_ENGINEERING:
LispTeLcafAddress teLcafAddress = (LispTeLcafAddress) lcafAddress;
List<LispTeAddress.TeRecord> records = Lists.newArrayList();
teLcafAddress.getTeRecords().forEach(record -> {
LispTeAddress.TeRecord teRecord = new LispTeAddress.TeRecord.Builder().withIsLookup(record.isLookup()).withIsRlocProbe(record.isRlocProbe()).withIsStrict(record.isStrict()).withRtrRlocAddress(getMappingAddress(record.getRtrRlocAddress())).build();
records.add(teRecord);
});
return new LispTeAddress.Builder().withTeRecords(records).build();
case SECURITY:
// TODO: need to implement security type later
log.warn("security type will be implemented later");
return null;
case SOURCE_DEST:
LispSourceDestLcafAddress srcDstLcafAddress = (LispSourceDestLcafAddress) lcafAddress;
return new LispSrcDstAddress.Builder().withSrcPrefix(getMappingAddress(srcDstLcafAddress.getSrcPrefix())).withSrcMaskLength(srcDstLcafAddress.getSrcMaskLength()).withDstPrefix(getMappingAddress(srcDstLcafAddress.getDstPrefix())).withDstMaskLength(srcDstLcafAddress.getDstMaskLength()).build();
case UNSPECIFIED:
case UNKNOWN:
default:
log.error("Unsupported LCAF type {}", lcafAddress.getType());
return null;
}
}
use of org.onosproject.lisp.msg.types.lcaf.LispNatLcafAddress in project onos by opennetworkinglab.
the class DefaultLispInfoReplyTest method setup.
@Before
public void setup() {
InfoReplyBuilder builder1 = new DefaultInfoReplyBuilder();
short msUdpPortNumber1 = 80;
short etrUdpPortNumber1 = 100;
LispIpv4Address globalEtrRlocAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
LispIpv4Address msRlocAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.2"));
LispIpv4Address privateEtrRlocAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.3"));
LispIpv4Address address1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.4"));
LispNatLcafAddress natLcafAddress1 = new NatAddressBuilder().withLength((short) 0).withMsUdpPortNumber(msUdpPortNumber1).withEtrUdpPortNumber(etrUdpPortNumber1).withGlobalEtrRlocAddress(globalEtrRlocAddress1).withMsRlocAddress(msRlocAddress1).withPrivateEtrRlocAddress(privateEtrRlocAddress1).build();
reply1 = builder1.withNonce(1L).withKeyId((short) 1).withAuthKey(AUTH_KEY).withIsInfoReply(true).withMaskLength((byte) 1).withEidPrefix(address1).withNatLcafAddress(natLcafAddress1).build();
InfoReplyBuilder builder2 = new DefaultInfoReplyBuilder();
sameAsReply1 = builder2.withNonce(1L).withKeyId((short) 1).withAuthKey(AUTH_KEY).withIsInfoReply(true).withMaskLength((byte) 1).withEidPrefix(address1).withNatLcafAddress(natLcafAddress1).build();
InfoReplyBuilder builder3 = new DefaultInfoReplyBuilder();
short msUdpPortNumber2 = 81;
short etrUdpPortNumber2 = 101;
LispIpv4Address globalEtrRlocAddress2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.1"));
LispIpv4Address msRlocAddress2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.2"));
LispIpv4Address privateEtrRlocAddress2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.3"));
LispIpv4Address address2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.4"));
LispNatLcafAddress natLcafAddress2 = new NatAddressBuilder().withLength((short) 0).withMsUdpPortNumber(msUdpPortNumber2).withEtrUdpPortNumber(etrUdpPortNumber2).withGlobalEtrRlocAddress(globalEtrRlocAddress2).withMsRlocAddress(msRlocAddress2).withPrivateEtrRlocAddress(privateEtrRlocAddress2).build();
reply2 = builder3.withNonce(2L).withKeyId((short) 2).withAuthKey(AUTH_KEY).withIsInfoReply(true).withMaskLength((byte) 1).withEidPrefix(address2).withNatLcafAddress(natLcafAddress2).build();
}
Aggregations