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


Java IpAddress.isIp4方法代码示例

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


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

示例1: getLongestMatchableRouteEntry

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
@Override
public RouteEntry getLongestMatchableRouteEntry(IpAddress ipAddress) {
    RouteEntry routeEntry = null;
    Iterable<RouteEntry> routeEntries;

    if (ipAddress.isIp4()) {
        routeEntries = ribTable4.getValuesForKeysPrefixing(
                createBinaryString(
                IpPrefix.valueOf(ipAddress, Ip4Address.BIT_LENGTH)));
    } else {
        routeEntries = ribTable6.getValuesForKeysPrefixing(
                createBinaryString(
                IpPrefix.valueOf(ipAddress, Ip6Address.BIT_LENGTH)));
    }
    if (routeEntries == null) {
        return null;
    }
    Iterator<RouteEntry> it = routeEntries.iterator();
    while (it.hasNext()) {
        routeEntry = it.next();
    }
    return routeEntry;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:DefaultRouter.java

示例2: sendProbe

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
private void sendProbe(ConnectPoint connectPoint,
                       IpAddress targetIp,
                       IpAddress sourceIp, MacAddress sourceMac,
                       VlanId vlan) {
    Ethernet probePacket = null;

    if (targetIp.isIp4()) {
        // IPv4: Use ARP
        probePacket = buildArpRequest(targetIp, sourceIp, sourceMac, vlan);
    } else {
        // IPv6: Use Neighbor Discovery
        probePacket = buildNdpRequest(targetIp, sourceIp, sourceMac, vlan);
    }

    TrafficTreatment treatment = DefaultTrafficTreatment.builder()
        .setOutput(connectPoint.port())
        .build();

    OutboundPacket outboundPacket =
        new DefaultOutboundPacket(connectPoint.deviceId(), treatment,
                                  ByteBuffer.wrap(probePacket.serialize()));

    packetService.emit(outboundPacket);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:HostMonitor.java

示例3: setChannel

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
@Override
public final void setChannel(Channel channel) {
    this.channel = channel;
    final SocketAddress address = channel.getRemoteAddress();
    if (address instanceof InetSocketAddress) {
        final InetSocketAddress inetAddress = (InetSocketAddress) address;
        final IpAddress ipAddress = IpAddress.valueOf(inetAddress.getAddress());
        if (ipAddress.isIp4()) {
            channelId = ipAddress.toString() + ':' + inetAddress.getPort();
        } else {
            channelId = '[' + ipAddress.toString() + "]:" + inetAddress.getPort();
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:15,代码来源:AbstractOpenFlowSwitch.java

示例4: isIpAddressLocal

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
@Override
public boolean isIpAddressLocal(IpAddress ipAddress) {
    if (ipAddress.isIp4()) {
        return localPrefixTable4.getValuesForKeysPrefixing(
                createBinaryString(
                IpPrefix.valueOf(ipAddress, Ip4Address.BIT_LENGTH)))
                .iterator().hasNext();
    } else {
        return localPrefixTable6.getValuesForKeysPrefixing(
                createBinaryString(
                IpPrefix.valueOf(ipAddress, Ip6Address.BIT_LENGTH)))
                .iterator().hasNext();
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:15,代码来源:RoutingConfigurationImpl.java

示例5: buildSelector

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
/**
 * Builds a traffic selector based on the set of input parameters.
 *
 * @param ipProto IP protocol
 * @param srcIp source IP address
 * @param dstIp destination IP address
 * @param srcTcpPort source TCP port, or null if shouldn't be set
 * @param dstTcpPort destination TCP port, or null if shouldn't be set
 * @return the new traffic selector
 */
private TrafficSelector buildSelector(byte ipProto, VlanId ingressVlanId,
                                      IpAddress srcIp,
                                      IpAddress dstIp, Short srcTcpPort,
                                      Short dstTcpPort) {
    TrafficSelector.Builder builder = DefaultTrafficSelector.builder().matchIPProtocol(ipProto);

    // Match on any VLAN Id if a VLAN Id configured on the ingress interface
    if (!ingressVlanId.equals(VlanId.NONE)) {
        builder.matchVlanId(VlanId.ANY);
    }

    if (dstIp.isIp4()) {
        builder.matchEthType(Ethernet.TYPE_IPV4)
                .matchIPSrc(IpPrefix.valueOf(srcIp, IpPrefix.MAX_INET_MASK_LENGTH))
                .matchIPDst(IpPrefix.valueOf(dstIp, IpPrefix.MAX_INET_MASK_LENGTH));
    } else {
        builder.matchEthType(Ethernet.TYPE_IPV6)
                .matchIPv6Src(IpPrefix.valueOf(srcIp, IpPrefix.MAX_INET6_MASK_LENGTH))
                .matchIPv6Dst(IpPrefix.valueOf(dstIp, IpPrefix.MAX_INET6_MASK_LENGTH));
    }

    if (srcTcpPort != null) {
        builder.matchTcpSrc(TpPort.tpPort(srcTcpPort));
    }

    if (dstTcpPort != null) {
        builder.matchTcpDst(TpPort.tpPort(dstTcpPort));
    }

    return builder.build();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:42,代码来源:PeerConnectivityManager.java

示例6: getDefaultRouteTable

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
private RouteTable getDefaultRouteTable(IpAddress ip) {
    RouteTableId routeTableId = (ip.isIp4()) ? IPV4 : IPV6;
    return routeTables.get(routeTableId);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:5,代码来源:LocalRouteStore.java

示例7: packetReactiveProcessor

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
/**
 * Routes packet reactively.
 *
 * @param dstIpAddress the destination IP address of a packet
 * @param srcIpAddress the source IP address of a packet
 * @param srcConnectPoint the connect point where a packet comes from
 * @param srcMacAddress the source MAC address of a packet
 */
private void packetReactiveProcessor(IpAddress dstIpAddress,
                                    IpAddress srcIpAddress,
                                    ConnectPoint srcConnectPoint,
                                    MacAddress srcMacAddress) {
    checkNotNull(dstIpAddress);
    checkNotNull(srcIpAddress);
    checkNotNull(srcConnectPoint);
    checkNotNull(srcMacAddress);

    //
    // Step1: Try to update the existing intent first if it exists.
    //
    IpPrefix ipPrefix = null;
    Route route = null;
    if (config.isIpAddressLocal(dstIpAddress)) {
        if (dstIpAddress.isIp4()) {
            ipPrefix = IpPrefix.valueOf(dstIpAddress,
                    Ip4Address.BIT_LENGTH);
        } else {
            ipPrefix = IpPrefix.valueOf(dstIpAddress,
                    Ip6Address.BIT_LENGTH);
        }
    } else {
        // Get IP prefix from BGP route table
        route = routeService.longestPrefixMatch(dstIpAddress);
        if (route != null) {
            ipPrefix = route.prefix();
        }
    }
    if (ipPrefix != null
            && intentRequestListener.mp2pIntentExists(ipPrefix)) {
        intentRequestListener.updateExistingMp2pIntent(ipPrefix,
                srcConnectPoint);
        return;
    }

    //
    // Step2: There is no existing intent for the destination IP address.
    // Check whether it is necessary to create a new one. If necessary then
    // create a new one.
    //
    TrafficType trafficType =
            trafficTypeClassifier(srcConnectPoint, dstIpAddress);

    switch (trafficType) {
    case HOST_TO_INTERNET:
        // If the destination IP address is outside the local SDN network.
        // The Step 1 has already handled it. We do not need to do anything here.
        intentRequestListener.setUpConnectivityHostToInternet(srcIpAddress,
                ipPrefix, route.nextHop());
        break;
    case INTERNET_TO_HOST:
        intentRequestListener.setUpConnectivityInternetToHost(dstIpAddress);
        break;
    case HOST_TO_HOST:
        intentRequestListener.setUpConnectivityHostToHost(dstIpAddress,
                srcIpAddress, srcMacAddress, srcConnectPoint);
        break;
    case INTERNET_TO_INTERNET:
        log.trace("This is transit traffic, "
                + "the intent should be preinstalled already");
        break;
    case DROP:
        // TODO here should setUpDropPacketIntent(...);
        // We need a new type of intent here.
        break;
    case UNKNOWN:
        log.trace("This is unknown traffic, so we do nothing");
        break;
    default:
        break;
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:82,代码来源:SdnIpReactiveRouting.java

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