Search in sources :

Example 1 with LispNoAddress

use of org.onosproject.lisp.msg.types.LispNoAddress 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)

Aggregations

UnknownHostException (java.net.UnknownHostException)1 IpAddress (org.onlab.packet.IpAddress)1 DefaultInfoReplyBuilder (org.onosproject.lisp.msg.protocols.DefaultLispInfoReply.DefaultInfoReplyBuilder)1 LispInfoReply (org.onosproject.lisp.msg.protocols.LispInfoReply)1 InfoReplyBuilder (org.onosproject.lisp.msg.protocols.LispInfoReply.InfoReplyBuilder)1 LispInfoRequest (org.onosproject.lisp.msg.protocols.LispInfoRequest)1 LispAfiAddress (org.onosproject.lisp.msg.types.LispAfiAddress)1 LispIpv4Address (org.onosproject.lisp.msg.types.LispIpv4Address)1 LispIpv6Address (org.onosproject.lisp.msg.types.LispIpv6Address)1 LispNoAddress (org.onosproject.lisp.msg.types.LispNoAddress)1 NatAddressBuilder (org.onosproject.lisp.msg.types.lcaf.LispNatLcafAddress.NatAddressBuilder)1