use of org.onosproject.lisp.msg.protocols.LispMessage in project onos by opennetworkinglab.
the class LispChannelHandler method extractLispMessage.
/**
* Extracts LISP message from encapsulated control message.
*
* @param ecm Encapsulated Control Message
* @return extracted LISP message
*/
private LispMessage extractLispMessage(LispEncapsulatedControl ecm) {
LispMessage message = ecm.getControlMessage();
message.configSender(ecm.getSender());
return message;
}
use of org.onosproject.lisp.msg.protocols.LispMessage in project onos by opennetworkinglab.
the class LispMessageDecoder method decode.
@Override
protected void decode(ChannelHandlerContext ctx, DatagramPacket msg, List<Object> list) throws Exception {
ByteBuf byteBuf = msg.content();
LispMessageReader reader = LispMessageReaderFactory.getReader(byteBuf);
LispMessage message = (LispMessage) reader.readFrom(byteBuf);
message.configSender(msg.sender());
list.add(message);
}
use of org.onosproject.lisp.msg.protocols.LispMessage in project onos by opennetworkinglab.
the class LispMapResolver method processMapRequest.
/**
* Handles encapsulated control message and replies with map-reply message.
*
* @param message encapsulated control message
* @return map-reply message
*/
List<LispMessage> processMapRequest(LispMessage message) {
LispEncapsulatedControl ecm = (LispEncapsulatedControl) message;
LispMapRequest request = (LispMapRequest) ecm.getControlMessage();
List<LispMapRecord> mapReplyRecords = mapDb.getMapRecordByEidRecords(request.getEids(), true);
List<LispMapRecord> mapRequestRecords = mapDb.getMapRecordByEidRecords(request.getEids(), false);
if (mapReplyRecords.size() + mapRequestRecords.size() == 0) {
List<LispMessage> mapReplies = Lists.newArrayList();
// build natively-forward map reply messages based on map-request from ITR
ReplyBuilder replyBuilder = initMapReplyBuilder(request);
replyBuilder.withMapRecords(getNegativeMapRecords(request.getEids()));
LispMessage mapReply = replyBuilder.build();
mapReply.configSender(new InetSocketAddress(ecm.getSender().getAddress(), NEGATIVE_REPLY_DST_PORT));
mapReplies.add(mapReply);
log.warn(NO_MAP_INFO_MSG);
} else {
if (!mapReplyRecords.isEmpty()) {
List<LispMessage> mapReplies = Lists.newArrayList();
// build map-reply message based on map-request from ITR
ReplyBuilder replyBuilder = initMapReplyBuilder(request);
replyBuilder.withMapRecords(mapReplyRecords);
List<InetSocketAddress> addresses = getItrAddresses(request.getItrRlocs(), ecm.innerUdp().getSourcePort());
addresses.forEach(address -> {
if (address != null) {
LispMapReply reply = replyBuilder.build();
reply.configSender(address);
mapReplies.add(reply);
} else {
log.warn(NO_ITR_RLOCS_MSG);
}
});
return mapReplies;
}
if (!mapRequestRecords.isEmpty()) {
List<LispMessage> ecms = Lists.newArrayList();
// re-encapsulate encapsulated control message from ITR
List<InetSocketAddress> addresses = getEtrAddresses(mapRequestRecords, ECM_DST_PORT);
addresses.forEach(address -> {
if (address != null) {
LispEncapsulatedControl reencapEcm = cloneEcm(ecm);
reencapEcm.configSender(address);
ecms.add(reencapEcm);
} else {
log.warn(NO_ETR_RLOCS_MSG);
}
});
return ecms;
}
}
return ImmutableList.of();
}
use of org.onosproject.lisp.msg.protocols.LispMessage in project onos by opennetworkinglab.
the class LispMessageEncoder method encode.
@Override
protected void encode(ChannelHandlerContext ctx, Object msg, List out) throws Exception {
if (!(msg instanceof List)) {
ByteBuf byteBuf = Unpooled.buffer();
((LispMessage) msg).writeTo(byteBuf);
out.add(new DatagramPacket(byteBuf, ((LispMessage) msg).getSender()));
return;
}
List<LispMessage> msgList = (List<LispMessage>) msg;
for (LispMessage message : msgList) {
if (message != null) {
ByteBuf byteBuf = Unpooled.buffer();
message.writeTo(byteBuf);
out.add(new DatagramPacket(byteBuf, message.getSender()));
}
}
}
Aggregations