当前位置: 首页>>代码示例>>Java>>正文


Java IpAddress.toIpPrefix方法代码示例

本文整理汇总了Java中org.onlab.packet.IpAddress.toIpPrefix方法的典型用法代码示例。如果您正苦于以下问题:Java IpAddress.toIpPrefix方法的具体用法?Java IpAddress.toIpPrefix怎么用?Java IpAddress.toIpPrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.onlab.packet.IpAddress的用法示例。


在下文中一共展示了IpAddress.toIpPrefix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUpConnectivityHostToHost

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
@Override
public void setUpConnectivityHostToHost(IpAddress dstIpAddress,
                                        IpAddress srcIpAddress,
                                        MacAddress srcMacAddress,
                                        ConnectPoint srcConnectPoint) {
    checkNotNull(dstIpAddress);
    checkNotNull(srcIpAddress);
    checkNotNull(srcMacAddress);
    checkNotNull(srcConnectPoint);

    IpPrefix srcIpPrefix = srcIpAddress.toIpPrefix();
    IpPrefix dstIpPrefix = dstIpAddress.toIpPrefix();
    ConnectPoint dstConnectPoint = null;
    MacAddress dstMacAddress = null;

    for (Host host : hostService.getHostsByIp(dstIpAddress)) {
        if (host.mac() != null) {
            dstMacAddress = host.mac();
            dstConnectPoint = host.location();
            break;
        }
    }
    if (dstMacAddress == null) {
        hostService.startMonitoringIp(dstIpAddress);
        return;
    }

    //
    // Handle intent from source host to destination host
    //
    MultiPointToSinglePointIntent srcToDstIntent =
            hostToHostIntentGenerator(dstIpAddress, dstConnectPoint,
                    dstMacAddress, srcConnectPoint);
    submitReactiveIntent(dstIpPrefix, srcToDstIntent);

    //
    // Handle intent from destination host to source host
    //

    // Since we proactively handle the intent from destination host to
    // source host, we should check whether there is an exiting intent
    // first.
    if (mp2pIntentExists(srcIpPrefix)) {
        updateExistingMp2pIntent(srcIpPrefix, dstConnectPoint);
        return;
    } else {
        // There is no existing intent, create a new one.
        MultiPointToSinglePointIntent dstToSrcIntent =
                hostToHostIntentGenerator(srcIpAddress, srcConnectPoint,
                        srcMacAddress, dstConnectPoint);
        submitReactiveIntent(srcIpPrefix, dstToSrcIntent);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:54,代码来源:ReactiveRoutingFib.java

示例2: hostToHostIntentGenerator

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
/**
 * Generates MultiPointToSinglePointIntent for both source host and
 * destination host located in local SDN network.
 *
 * @param dstIpAddress the destination IP address
 * @param dstConnectPoint the destination host connect point
 * @param dstMacAddress the MAC address of destination host
 * @param srcConnectPoint the connect point where packet-in from
 * @return the generated MultiPointToSinglePointIntent
 */
private MultiPointToSinglePointIntent hostToHostIntentGenerator(
        IpAddress dstIpAddress,
        ConnectPoint dstConnectPoint,
        MacAddress dstMacAddress,
        ConnectPoint srcConnectPoint) {
    checkNotNull(dstIpAddress);
    checkNotNull(dstConnectPoint);
    checkNotNull(dstMacAddress);
    checkNotNull(srcConnectPoint);

    Set<ConnectPoint> ingressPoints = new HashSet<>();
    ingressPoints.add(srcConnectPoint);
    IpPrefix dstIpPrefix = dstIpAddress.toIpPrefix();

    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
    if (dstIpAddress.isIp4()) {
        selector.matchEthType(Ethernet.TYPE_IPV4);
        selector.matchIPDst(dstIpPrefix);
    } else {
        selector.matchEthType(Ethernet.TYPE_IPV6);
        selector.matchIPv6Dst(dstIpPrefix);
    }

    // Rewrite the destination MAC address
    TrafficTreatment.Builder treatment =
            DefaultTrafficTreatment.builder().setEthDst(dstMacAddress);

    Key key = Key.of(dstIpPrefix.toString(), appId);
    int priority = dstIpPrefix.prefixLength() * PRIORITY_MULTIPLIER
            + PRIORITY_OFFSET;
    MultiPointToSinglePointIntent intent =
            MultiPointToSinglePointIntent.builder()
                    .appId(appId)
                    .key(key)
                    .selector(selector.build())
                    .treatment(treatment.build())
                    .ingressPoints(ingressPoints)
                    .egressPoint(dstConnectPoint)
                    .priority(priority)
                    .constraints(CONSTRAINTS)
                    .build();

    log.trace("Generates ConnectivityHostToHost = {} ", intent);
    return intent;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:56,代码来源:ReactiveRoutingFib.java


注:本文中的org.onlab.packet.IpAddress.toIpPrefix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。