Search in sources :

Example 1 with RequestBuilder

use of org.onosproject.lisp.msg.protocols.LispMapRequest.RequestBuilder 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 RequestBuilder

use of org.onosproject.lisp.msg.protocols.LispMapRequest.RequestBuilder in project onos by opennetworkinglab.

the class DefaultLispMapRequestTest method setup.

@Before
public void setup() {
    RequestBuilder builder1 = new DefaultRequestBuilder();
    LispIpv4Address ipv4Eid1 = new LispIpv4Address(IpAddress.valueOf(EID_IP_ADDRESS_1));
    LispIpv4Address ipv4Rloc1 = new LispIpv4Address(IpAddress.valueOf(RLOC_IP_ADDRESS_1_1));
    LispIpv4Address ipv4Rloc2 = new LispIpv4Address(IpAddress.valueOf(RLOC_IP_ADDRESS_1_2));
    List<LispAfiAddress> rlocs1 = ImmutableList.of(ipv4Rloc1, ipv4Rloc2);
    List<LispEidRecord> records1 = ImmutableList.of(getEidRecord(), getEidRecord());
    request1 = builder1.withIsAuthoritative(true).withIsMapDataPresent(true).withIsPitr(false).withIsProbe(false).withIsSmr(true).withIsSmrInvoked(false).withSourceEid(ipv4Eid1).withItrRlocs(rlocs1).withEidRecords(records1).withNonce(1L).withReplyRecord(1).build();
    RequestBuilder builder2 = new DefaultRequestBuilder();
    List<LispEidRecord> records2 = ImmutableList.of(getEidRecord(), getEidRecord());
    sameAsRequest1 = builder2.withIsAuthoritative(true).withIsMapDataPresent(true).withIsPitr(false).withIsProbe(false).withIsSmr(true).withIsSmrInvoked(false).withSourceEid(ipv4Eid1).withItrRlocs(rlocs1).withEidRecords(records2).withNonce(1L).withReplyRecord(1).build();
    RequestBuilder builder3 = new DefaultRequestBuilder();
    LispIpv4Address ipv4Eid2 = new LispIpv4Address(IpAddress.valueOf(EID_IP_ADDRESS_2));
    LispIpv4Address ipv4Rloc3 = new LispIpv4Address(IpAddress.valueOf(RLOC_IP_ADDRESS_2_1));
    LispIpv4Address ipv4Rloc4 = new LispIpv4Address(IpAddress.valueOf(RLOC_IP_ADDRESS_2_2));
    List<LispAfiAddress> rlocs2 = ImmutableList.of(ipv4Rloc3, ipv4Rloc4);
    request2 = builder3.withIsAuthoritative(false).withIsMapDataPresent(false).withIsPitr(true).withIsProbe(true).withIsSmr(false).withIsSmrInvoked(true).withSourceEid(ipv4Eid2).withItrRlocs(rlocs2).withNonce(2L).withReplyRecord(2).build();
}
Also used : DefaultRequestBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapRequest.DefaultRequestBuilder) RequestBuilder(org.onosproject.lisp.msg.protocols.LispMapRequest.RequestBuilder) LispIpv4Address(org.onosproject.lisp.msg.types.LispIpv4Address) DefaultRequestBuilder(org.onosproject.lisp.msg.protocols.DefaultLispMapRequest.DefaultRequestBuilder) LispAfiAddress(org.onosproject.lisp.msg.types.LispAfiAddress) Before(org.junit.Before)

Aggregations

DefaultRequestBuilder (org.onosproject.lisp.msg.protocols.DefaultLispMapRequest.DefaultRequestBuilder)2 RequestBuilder (org.onosproject.lisp.msg.protocols.LispMapRequest.RequestBuilder)2 LispAfiAddress (org.onosproject.lisp.msg.types.LispAfiAddress)2 LispIpv4Address (org.onosproject.lisp.msg.types.LispIpv4Address)2 UnknownHostException (java.net.UnknownHostException)1 Before (org.junit.Before)1 LispRouter (org.onosproject.lisp.ctl.LispRouter)1 LispRouterFactory (org.onosproject.lisp.ctl.LispRouterFactory)1 DefaultInfoRequestBuilder (org.onosproject.lisp.msg.protocols.DefaultLispInfoRequest.DefaultInfoRequestBuilder)1 InfoRequestBuilder (org.onosproject.lisp.msg.protocols.LispInfoRequest.InfoRequestBuilder)1 LispMapRequest (org.onosproject.lisp.msg.protocols.LispMapRequest)1