use of org.onosproject.lisp.msg.protocols.LispInfoRequest 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.protocols.LispInfoRequest in project onos by opennetworkinglab.
the class LispMapServer method checkInfoRequestAuthData.
/**
* Checks the integrity of the received info-request message by calculating
* authentication data from received info-request message.
*
* @param request info-request message
* @return evaluation result
*/
private boolean checkInfoRequestAuthData(LispInfoRequest request) {
InfoRequestBuilder requestBuilder = new DefaultInfoRequestBuilder();
requestBuilder.withKeyId(request.getKeyId());
requestBuilder.withAuthKey(authConfig.lispAuthKey());
requestBuilder.withNonce(request.getNonce());
requestBuilder.withTtl(request.getTtl());
requestBuilder.withEidPrefix(request.getPrefix());
requestBuilder.withIsInfoReply(request.isInfoReply());
requestBuilder.withMaskLength(request.getMaskLength());
LispInfoRequest authRequest = requestBuilder.build();
return Arrays.equals(authRequest.getAuthData(), request.getAuthData());
}
Aggregations