Search in sources :

Example 1 with ReplyBuilder

use of org.onosproject.lisp.msg.protocols.LispMapReply.ReplyBuilder in project onos by opennetworkinglab.

the class DefaultLispMapReplyTest method setup.

@Before
public void setup() {
    ReplyBuilder builder1 = new DefaultReplyBuilder();
    List<LispMapRecord> records1 = ImmutableList.of(getMapRecord(), getMapRecord());
    reply1 = builder1.withIsEtr(true).withIsProbe(false).withIsSecurity(true).withNonce(1L).withMapRecords(records1).build();
    ReplyBuilder builder2 = new DefaultReplyBuilder();
    List<LispMapRecord> records2 = ImmutableList.of(getMapRecord(), getMapRecord());
    sameAsReply1 = builder2.withIsEtr(true).withIsProbe(false).withIsSecurity(true).withNonce(1L).withMapRecords(records2).build();
    ReplyBuilder builder3 = new DefaultReplyBuilder();
    reply2 = builder3.withIsEtr(false).withIsProbe(true).withIsSecurity(false).withNonce(2L).build();
}
Also used : DefaultReplyBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapReply.DefaultReplyBuilder) ReplyBuilder(org.onosproject.lisp.msg.protocols.LispMapReply.ReplyBuilder) DefaultReplyBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapReply.DefaultReplyBuilder) Before(org.junit.Before)

Example 2 with ReplyBuilder

use of org.onosproject.lisp.msg.protocols.LispMapReply.ReplyBuilder in project onos by opennetworkinglab.

the class LispMapResolver method initMapReplyBuilder.

/**
 * Initializes MapReply builder without specifying map records.
 *
 * @param request received map request from ITR
 * @return initialized MapReply builder
 */
private ReplyBuilder initMapReplyBuilder(LispMapRequest request) {
    ReplyBuilder replyBuilder = new DefaultReplyBuilder();
    replyBuilder.withNonce(request.getNonce());
    replyBuilder.withIsEtr(false);
    replyBuilder.withIsSecurity(false);
    replyBuilder.withIsProbe(request.isProbe());
    return replyBuilder;
}
Also used : DefaultReplyBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapReply.DefaultReplyBuilder) DefaultReplyBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapReply.DefaultReplyBuilder) ReplyBuilder(org.onosproject.lisp.msg.protocols.LispMapReply.ReplyBuilder)

Example 3 with ReplyBuilder

use of org.onosproject.lisp.msg.protocols.LispMapReply.ReplyBuilder 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)

Example 4 with ReplyBuilder

use of org.onosproject.lisp.msg.protocols.LispMapReply.ReplyBuilder in project onos by opennetworkinglab.

the class MappingEntryBuilderTest method testMapReplyConversion.

@Test
public void testMapReplyConversion() {
    ReplyBuilder replyBuilder = new DefaultReplyBuilder();
    List<LispMapRecord> records = ImmutableList.of(getMapRecord(IP4, UNKNOWN));
    LispMapReply mapReply = replyBuilder.withIsEtr(true).withIsProbe(false).withIsSecurity(true).withNonce(UNIQUE_LONG).withMapRecords(records).build();
    List<LispMapRecord> replyRecords = mapReply.getMapRecords();
    assertThat(replyRecords.size(), is(1));
    testMapRecordConversion(replyRecords.get(0));
}
Also used : DefaultReplyBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapReply.DefaultReplyBuilder) LispMapReply(org.onosproject.lisp.msg.protocols.LispMapReply) ReplyBuilder(org.onosproject.lisp.msg.protocols.LispMapReply.ReplyBuilder) DefaultReplyBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapReply.DefaultReplyBuilder) LispMapRecord(org.onosproject.lisp.msg.protocols.LispMapRecord) Test(org.junit.Test)

Aggregations

DefaultReplyBuilder (org.onosproject.lisp.msg.protocols.DefaultLispMapReply.DefaultReplyBuilder)4 ReplyBuilder (org.onosproject.lisp.msg.protocols.LispMapReply.ReplyBuilder)4 LispMapRecord (org.onosproject.lisp.msg.protocols.LispMapRecord)2 LispMapReply (org.onosproject.lisp.msg.protocols.LispMapReply)2 InetSocketAddress (java.net.InetSocketAddress)1 Before (org.junit.Before)1 Test (org.junit.Test)1 LispEncapsulatedControl (org.onosproject.lisp.msg.protocols.LispEncapsulatedControl)1 LispMapRequest (org.onosproject.lisp.msg.protocols.LispMapRequest)1 LispMessage (org.onosproject.lisp.msg.protocols.LispMessage)1