Search in sources :

Example 1 with LispAfiAddress

use of org.onosproject.lisp.msg.types.LispAfiAddress 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;
}
Also used : NatAddressBuilder(org.onosproject.lisp.msg.types.lcaf.LispNatLcafAddress.NatAddressBuilder) DefaultInfoReplyBuilder(org.onosproject.lisp.msg.protocols.DefaultLispInfoReply.DefaultInfoReplyBuilder) LispIpv6Address(org.onosproject.lisp.msg.types.LispIpv6Address) LispInfoRequest(org.onosproject.lisp.msg.protocols.LispInfoRequest) LispNoAddress(org.onosproject.lisp.msg.types.LispNoAddress) UnknownHostException(java.net.UnknownHostException) LispIpv4Address(org.onosproject.lisp.msg.types.LispIpv4Address) InfoReplyBuilder(org.onosproject.lisp.msg.protocols.LispInfoReply.InfoReplyBuilder) DefaultInfoReplyBuilder(org.onosproject.lisp.msg.protocols.DefaultLispInfoReply.DefaultInfoReplyBuilder) IpAddress(org.onlab.packet.IpAddress) LispAfiAddress(org.onosproject.lisp.msg.types.LispAfiAddress) LispInfoReply(org.onosproject.lisp.msg.protocols.LispInfoReply)

Example 2 with LispAfiAddress

use of org.onosproject.lisp.msg.types.LispAfiAddress 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 3 with LispAfiAddress

use of org.onosproject.lisp.msg.types.LispAfiAddress in project onos by opennetworkinglab.

the class DefaultLispGenericLocator method deserialize.

/**
 * Deserializes LispGenericLocator message portion.
 *
 * @param byteBuf byte buffer
 * @return LispGenericLocator
 * @throws LispParseError      LISP message parse error
 * @throws LispReaderException LISP message reader exception
 */
public static LispGenericLocator deserialize(ByteBuf byteBuf) throws LispParseError, LispReaderException {
    // priority -> 8 bits
    byte priority = (byte) byteBuf.readUnsignedByte();
    // weight -> 8 bits
    byte weight = (byte) byteBuf.readUnsignedByte();
    // multi-cast priority -> 8 bits
    byte multicastPriority = (byte) byteBuf.readUnsignedByte();
    // multi-cast weight -> 8 bits
    byte multicastWeight = (byte) byteBuf.readUnsignedByte();
    // let's skip unused flags
    byteBuf.skipBytes(SKIP_UNUSED_FLAG_LENGTH);
    byte flags = byteBuf.readByte();
    // local locator flag -> 1 bit
    boolean localLocator = ByteOperator.getBit(flags, LOCAL_LOCATOR_INDEX);
    // rloc probe flag -> 1 bit
    boolean rlocProbed = ByteOperator.getBit(flags, RLOC_PROBED_INDEX);
    // routed flag -> 1 bit
    boolean routed = ByteOperator.getBit(flags, ROUTED_INDEX);
    LispAfiAddress address = new LispAfiAddress.AfiAddressReader().readFrom(byteBuf);
    return new DefaultLispGenericLocator(priority, weight, multicastPriority, multicastWeight, localLocator, rlocProbed, routed, address);
}
Also used : LispAfiAddress(org.onosproject.lisp.msg.types.LispAfiAddress)

Example 4 with LispAfiAddress

use of org.onosproject.lisp.msg.types.LispAfiAddress in project onos by opennetworkinglab.

the class DefaultLispInfo method deserialize.

public static LispInfo deserialize(ByteBuf byteBuf) throws LispParseError, LispReaderException {
    if (byteBuf.readerIndex() != 0) {
        return null;
    }
    // infoReply -> 1 bit
    boolean infoReplyFlag = ByteOperator.getBit(byteBuf.readByte(), INFO_REPLY_INDEX);
    // let's skip the reserved field
    byteBuf.skipBytes(RESERVED_SKIP_LENGTH_1);
    // nonce -> 64 bits
    long nonce = byteBuf.readLong();
    // keyId -> 16 bits
    short keyId = byteBuf.readShort();
    // authenticationDataLength -> 16 bits
    short authLength = byteBuf.readShort();
    // authData -> depends on the authenticationDataLength
    byte[] authData = new byte[authLength];
    byteBuf.readBytes(authData);
    // ttl -> 32 bits
    int ttl = byteBuf.readInt();
    // let's skip the reserved field
    byteBuf.skipBytes(RESERVED_SKIP_LENGTH_2);
    // mask length -> 8 bits
    short maskLength = byteBuf.readUnsignedByte();
    LispAfiAddress prefix = new LispAfiAddress.AfiAddressReader().readFrom(byteBuf);
    return new DefaultLispInfo(infoReplyFlag, nonce, keyId, authLength, authData, ttl, (byte) maskLength, prefix);
}
Also used : LispAfiAddress(org.onosproject.lisp.msg.types.LispAfiAddress)

Example 5 with LispAfiAddress

use of org.onosproject.lisp.msg.types.LispAfiAddress in project onos by opennetworkinglab.

the class LispAppDataLcafAddressTest method setup.

@Before
public void setup() {
    AppDataAddressBuilder builder1 = new AppDataAddressBuilder();
    LispAfiAddress ipv4Address1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
    address1 = builder1.withProtocol((byte) 0x01).withIpTos((short) 10).withLocalPortLow((short) 1).withLocalPortHigh((short) 255).withRemotePortLow((short) 2).withRemotePortHigh((short) 254).withAddress(ipv4Address1).build();
    AppDataAddressBuilder builder2 = new AppDataAddressBuilder();
    sameAsAddress1 = builder2.withProtocol((byte) 0x01).withIpTos((short) 10).withLocalPortLow((short) 1).withLocalPortHigh((short) 255).withRemotePortLow((short) 2).withRemotePortHigh((short) 254).withAddress(ipv4Address1).build();
    AppDataAddressBuilder builder3 = new AppDataAddressBuilder();
    LispAfiAddress ipv4Address2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.1"));
    address2 = builder3.withProtocol((byte) 0x02).withIpTos((short) 20).withLocalPortLow((short) 1).withLocalPortHigh((short) 255).withRemotePortLow((short) 2).withRemotePortHigh((short) 254).withAddress(ipv4Address2).build();
}
Also used : LispIpv4Address(org.onosproject.lisp.msg.types.LispIpv4Address) LispAfiAddress(org.onosproject.lisp.msg.types.LispAfiAddress) AppDataAddressBuilder(org.onosproject.lisp.msg.types.lcaf.LispAppDataLcafAddress.AppDataAddressBuilder) Before(org.junit.Before)

Aggregations

LispAfiAddress (org.onosproject.lisp.msg.types.LispAfiAddress)16 LispIpv4Address (org.onosproject.lisp.msg.types.LispIpv4Address)10 Before (org.junit.Before)4 LispIpv6Address (org.onosproject.lisp.msg.types.LispIpv6Address)4 LispListLcafAddress (org.onosproject.lisp.msg.types.lcaf.LispListLcafAddress)3 LispTeRecord (org.onosproject.lisp.msg.types.lcaf.LispTeRecord)3 UnknownHostException (java.net.UnknownHostException)2 Test (org.junit.Test)2 DefaultRequestBuilder (org.onosproject.lisp.msg.protocols.DefaultLispMapRequest.DefaultRequestBuilder)2 LispLocator (org.onosproject.lisp.msg.protocols.LispLocator)2 RequestBuilder (org.onosproject.lisp.msg.protocols.LispMapRequest.RequestBuilder)2 LispAsLcafAddress (org.onosproject.lisp.msg.types.lcaf.LispAsLcafAddress)2 LispGeoCoordinateLcafAddress (org.onosproject.lisp.msg.types.lcaf.LispGeoCoordinateLcafAddress)2 NatAddressBuilder (org.onosproject.lisp.msg.types.lcaf.LispNatLcafAddress.NatAddressBuilder)2 LispNonceLcafAddress (org.onosproject.lisp.msg.types.lcaf.LispNonceLcafAddress)2 IpAddress (org.onlab.packet.IpAddress)1 LispRouter (org.onosproject.lisp.ctl.LispRouter)1 LispRouterFactory (org.onosproject.lisp.ctl.LispRouterFactory)1 DefaultInfoReplyBuilder (org.onosproject.lisp.msg.protocols.DefaultLispInfoReply.DefaultInfoReplyBuilder)1 DefaultInfoRequestBuilder (org.onosproject.lisp.msg.protocols.DefaultLispInfoRequest.DefaultInfoRequestBuilder)1