use of org.onosproject.lisp.msg.types.LispIpv6Address in project onos by opennetworkinglab.
the class LispExtensionMappingAddressInterpreter method afi2mapping.
/**
* Converts AFI address to generalized mapping address.
*
* @param afi IP typed AFI address
* @return generalized mapping address
*/
private MappingAddress afi2mapping(LispAfiAddress afi) {
switch(afi.getAfi()) {
case IP4:
IpAddress ipv4Address = ((LispIpv4Address) afi).getAddress();
IpPrefix ipv4Prefix = IpPrefix.valueOf(ipv4Address, IPV4_PREFIX_LENGTH);
return MappingAddresses.ipv4MappingAddress(ipv4Prefix);
case IP6:
IpAddress ipv6Address = ((LispIpv6Address) afi).getAddress();
IpPrefix ipv6Prefix = IpPrefix.valueOf(ipv6Address, IPV6_PREFIX_LENGTH);
return MappingAddresses.ipv6MappingAddress(ipv6Prefix);
default:
log.warn("Only support to convert IP address type");
break;
}
return null;
}
use of org.onosproject.lisp.msg.types.LispIpv6Address 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.LispIpv6Address in project onos by opennetworkinglab.
the class MappingAddressBuilder method afi2mapping.
/**
* Converts AFI address to generalized mapping address.
*
* @param afiAddress IP typed AFI address
* @return generalized mapping address
*/
private static MappingAddress afi2mapping(LispAfiAddress afiAddress) {
switch(afiAddress.getAfi()) {
case IP4:
IpAddress ipv4Address = ((LispIpv4Address) afiAddress).getAddress();
IpPrefix ipv4Prefix = IpPrefix.valueOf(ipv4Address, IPV4_PREFIX_LENGTH);
return MappingAddresses.ipv4MappingAddress(ipv4Prefix);
case IP6:
IpAddress ipv6Address = ((LispIpv6Address) afiAddress).getAddress();
IpPrefix ipv6Prefix = IpPrefix.valueOf(ipv6Address, IPV6_PREFIX_LENGTH);
return MappingAddresses.ipv6MappingAddress(ipv6Prefix);
default:
log.warn("Only support to convert IP address type");
break;
}
return null;
}
use of org.onosproject.lisp.msg.types.LispIpv6Address in project onos by opennetworkinglab.
the class LispExtensionMappingAddressInterpreterTest method getLcafMappingAddress.
private LispLcafAddress getLcafMappingAddress(ExtensionMappingAddressType type) {
LispLcafAddress address = null;
LispAfiAddress ipv4Addr = new LispIpv4Address(IPV4_ADDRESS);
LispAfiAddress ipv6Addr = new LispIpv6Address(IPV6_ADDRESS);
if (type.equals(LIST_ADDRESS.type())) {
address = new LispListLcafAddress(ImmutableList.of(ipv4Addr, ipv6Addr));
}
if (type.equals(SEGMENT_ADDRESS.type())) {
address = new LispSegmentLcafAddress.SegmentAddressBuilder().withInstanceId(UNIQUE_INT).withAddress(ipv4Addr).build();
}
if (type.equals(AS_ADDRESS.type())) {
address = new LispAsLcafAddress.AsAddressBuilder().withAsNumber(UNIQUE_INT).withAddress(ipv4Addr).build();
}
if (type.equals(APPLICATION_DATA_ADDRESS.type())) {
address = new LispAppDataLcafAddress.AppDataAddressBuilder().withProtocol(UNIQUE_BYTE).withIpTos(UNIQUE_INT).withLocalPortLow(UNIQUE_SHORT).withLocalPortHigh(UNIQUE_SHORT).withRemotePortLow(UNIQUE_SHORT).withRemotePortHigh(UNIQUE_SHORT).withAddress(ipv4Addr).build();
}
if (type.equals(GEO_COORDINATE_ADDRESS.type())) {
address = new LispGeoCoordinateLcafAddress.GeoCoordinateAddressBuilder().withIsNorth(UNIQUE_BOOLEAN).withLatitudeDegree(UNIQUE_SHORT).withLatitudeMinute(UNIQUE_BYTE).withLatitudeSecond(UNIQUE_BYTE).withIsEast(UNIQUE_BOOLEAN).withLongitudeDegree(UNIQUE_SHORT).withLongitudeMinute(UNIQUE_BYTE).withLongitudeSecond(UNIQUE_BYTE).withAltitude(UNIQUE_INT).withAddress(ipv4Addr).build();
}
if (type.equals(NAT_ADDRESS.type())) {
address = new LispNatLcafAddress.NatAddressBuilder().withMsUdpPortNumber(UNIQUE_SHORT).withEtrUdpPortNumber(UNIQUE_SHORT).withGlobalEtrRlocAddress(ipv4Addr).withMsRlocAddress(ipv4Addr).withPrivateEtrRlocAddress(ipv4Addr).withRtrRlocAddresses(ImmutableList.of(ipv4Addr, ipv6Addr)).build();
}
if (type.equals(NONCE_ADDRESS.type())) {
address = new LispNonceLcafAddress.NonceAddressBuilder().withNonce(UNIQUE_INT).withAddress(ipv4Addr).build();
}
if (type.equals(MULTICAST_ADDRESS.type())) {
address = new LispMulticastLcafAddress.MulticastAddressBuilder().withInstanceId(UNIQUE_INT).withSrcMaskLength(UNIQUE_BYTE).withSrcAddress(ipv4Addr).withGrpMaskLength(UNIQUE_BYTE).withGrpAddress(ipv4Addr).build();
}
if (type.equals(TRAFFIC_ENGINEERING_ADDRESS.type())) {
LispTeRecord tr = new LispTeRecord.TeRecordBuilder().withIsLookup(UNIQUE_BOOLEAN).withIsRlocProbe(UNIQUE_BOOLEAN).withIsStrict(UNIQUE_BOOLEAN).withRtrRlocAddress(ipv4Addr).build();
address = new LispTeLcafAddress.TeAddressBuilder().withTeRecords(ImmutableList.of(tr)).build();
}
if (type.equals(SOURCE_DEST_ADDRESS.type())) {
address = new LispSourceDestLcafAddress.SourceDestAddressBuilder().withSrcMaskLength(UNIQUE_BYTE).withSrcPrefix(ipv4Addr).withDstMaskLength(UNIQUE_BYTE).withDstPrefix(ipv4Addr).build();
}
return address;
}
use of org.onosproject.lisp.msg.types.LispIpv6Address in project onos by opennetworkinglab.
the class LispListLcafAddressTest method setup.
@Before
public void setup() {
LispAfiAddress ipv4Address1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
LispAfiAddress ipv6Address1 = new LispIpv6Address(IpAddress.valueOf("1111:2222:3333:4444:5555:6666:7777:8885"));
List<LispAfiAddress> afiAddresses1 = Lists.newArrayList();
afiAddresses1.add(ipv4Address1);
afiAddresses1.add(ipv6Address1);
address1 = new LispListLcafAddress(afiAddresses1);
sameAsAddress1 = new LispListLcafAddress(afiAddresses1);
LispAfiAddress ipv4Address2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.1"));
LispAfiAddress ipv6Address2 = new LispIpv6Address(IpAddress.valueOf("1111:2222:3333:4444:5555:6666:7777:8886"));
List<LispAfiAddress> afiAddresses2 = Lists.newArrayList();
afiAddresses2.add(ipv4Address2);
afiAddresses2.add(ipv6Address2);
address2 = new LispListLcafAddress(afiAddresses2);
}
Aggregations