Search in sources :

Example 1 with LispMapRequest

use of org.onosproject.lisp.msg.protocols.LispMapRequest 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);
        }
    });
}
Also used : LispRouter(org.onosproject.lisp.ctl.LispRouter) DefaultRequestBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapRequest.DefaultRequestBuilder) RequestBuilder(org.onosproject.lisp.msg.protocols.LispMapRequest.RequestBuilder) InfoRequestBuilder(org.onosproject.lisp.msg.protocols.LispInfoRequest.InfoRequestBuilder) DefaultInfoRequestBuilder(org.onosproject.lisp.msg.protocols.DefaultLispInfoRequest.DefaultInfoRequestBuilder) UnknownHostException(java.net.UnknownHostException) LispIpv4Address(org.onosproject.lisp.msg.types.LispIpv4Address) LispRouterFactory(org.onosproject.lisp.ctl.LispRouterFactory) DefaultRequestBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapRequest.DefaultRequestBuilder) LispAfiAddress(org.onosproject.lisp.msg.types.LispAfiAddress) LispMapRequest(org.onosproject.lisp.msg.protocols.LispMapRequest)

Example 2 with LispMapRequest

use of org.onosproject.lisp.msg.protocols.LispMapRequest 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();
}
Also used : LispEncapsulatedControl(org.onosproject.lisp.msg.protocols.LispEncapsulatedControl) LispMessage(org.onosproject.lisp.msg.protocols.LispMessage) InetSocketAddress(java.net.InetSocketAddress) LispMapReply(org.onosproject.lisp.msg.protocols.LispMapReply) LispMapRequest(org.onosproject.lisp.msg.protocols.LispMapRequest) DefaultReplyBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapReply.DefaultReplyBuilder) ReplyBuilder(org.onosproject.lisp.msg.protocols.LispMapReply.ReplyBuilder) LispMapRecord(org.onosproject.lisp.msg.protocols.LispMapRecord)

Aggregations

LispMapRequest (org.onosproject.lisp.msg.protocols.LispMapRequest)2 InetSocketAddress (java.net.InetSocketAddress)1 UnknownHostException (java.net.UnknownHostException)1 LispRouter (org.onosproject.lisp.ctl.LispRouter)1 LispRouterFactory (org.onosproject.lisp.ctl.LispRouterFactory)1 DefaultInfoRequestBuilder (org.onosproject.lisp.msg.protocols.DefaultLispInfoRequest.DefaultInfoRequestBuilder)1 DefaultReplyBuilder (org.onosproject.lisp.msg.protocols.DefaultLispMapReply.DefaultReplyBuilder)1 DefaultRequestBuilder (org.onosproject.lisp.msg.protocols.DefaultLispMapRequest.DefaultRequestBuilder)1 LispEncapsulatedControl (org.onosproject.lisp.msg.protocols.LispEncapsulatedControl)1 InfoRequestBuilder (org.onosproject.lisp.msg.protocols.LispInfoRequest.InfoRequestBuilder)1 LispMapRecord (org.onosproject.lisp.msg.protocols.LispMapRecord)1 LispMapReply (org.onosproject.lisp.msg.protocols.LispMapReply)1 ReplyBuilder (org.onosproject.lisp.msg.protocols.LispMapReply.ReplyBuilder)1 RequestBuilder (org.onosproject.lisp.msg.protocols.LispMapRequest.RequestBuilder)1 LispMessage (org.onosproject.lisp.msg.protocols.LispMessage)1 LispAfiAddress (org.onosproject.lisp.msg.types.LispAfiAddress)1 LispIpv4Address (org.onosproject.lisp.msg.types.LispIpv4Address)1