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


Java Host.mac方法代码示例

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


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

示例1: getMacFromHostService

import org.onosproject.net.Host; //导入方法依赖的package包/类
/**
 * Returns MAC address of a host with a given target IP address by asking to
 * host service. It does not support overlapping IP.
 *
 * @param targetIp target ip
 * @return mac address, or null if it fails to find the mac
 */
private MacAddress getMacFromHostService(IpAddress targetIp) {
    checkNotNull(targetIp);

    Host host = hostService.getHostsByIp(targetIp)
            .stream()
            .findFirst()
            .orElse(null);

    if (host != null) {
        log.debug("Found MAC from host service for {}", targetIp.toString());
        return host.mac();
    } else {
        return null;
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:OpenstackArpHandler.java

示例2: cleanupDevice

import org.onosproject.net.Host; //导入方法依赖的package包/类
private Collection<? extends FlowRule> cleanupDevice(Device device, Host host) {
    List<FlowRule> flowRules = Lists.newLinkedList();
    MacAddress mac = host.mac();
    for (FlowRule rule : flowRuleService.getFlowEntries(device.id())) {
        for (Criterion c : rule.selector().criteria()) {
            if (c.type() == Type.ETH_DST || c.type() == Type.ETH_SRC) {
                EthCriterion eth = (EthCriterion) c;
                if (eth.mac().equals(mac)) {
                    flowRules.add(rule);
                }
            }
        }
    }
    return flowRules;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:16,代码来源:HostMobility.java

示例3: processHostAdded

import org.onosproject.net.Host; //导入方法依赖的package包/类
protected void processHostAdded(Host host) {
    MacAddress mac = host.mac();
    VlanId vlanId = host.vlan();
    HostLocation location = host.location();
    DeviceId deviceId = location.deviceId();
    PortNumber port = location.port();
    Set<IpAddress> ips = host.ipAddresses();
    log.debug("Host {}/{} is added at {}:{}", mac, vlanId, deviceId, port);

    if (accepted(host)) {
        // Populate bridging table entry
        log.debug("Populate L2 table entry for host {} at {}:{}",
                mac, deviceId, port);
        ForwardingObjective.Builder fob =
                hostFwdObjBuilder(deviceId, mac, vlanId, port);
        if (fob == null) {
            log.warn("Fail to create fwd obj for host {}/{}. Abort.", mac, vlanId);
            return;
        }
        ObjectiveContext context = new DefaultObjectiveContext(
                (objective) -> log.debug("Host rule for {}/{} populated", mac, vlanId),
                (objective, error) ->
                        log.warn("Failed to populate host rule for {}/{}: {}", mac, vlanId, error));
        flowObjectiveService.forward(deviceId, fob.add(context));

        ips.forEach(ip -> {
            // Populate IP table entry
            if (ip.isIp4()) {
                addPerHostRoute(location, ip.getIp4Address());
                srManager.routingRulePopulator.populateIpRuleForHost(
                        deviceId, ip.getIp4Address(), mac, port);
            }
        });
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:36,代码来源:HostHandler.java

示例4: processHostRemoved

import org.onosproject.net.Host; //导入方法依赖的package包/类
protected void processHostRemoved(Host host) {
    MacAddress mac = host.mac();
    VlanId vlanId = host.vlan();
    HostLocation location = host.location();
    DeviceId deviceId = location.deviceId();
    PortNumber port = location.port();
    Set<IpAddress> ips = host.ipAddresses();
    log.debug("Host {}/{} is removed from {}:{}", mac, vlanId, deviceId, port);

    if (accepted(host)) {
        // Revoke bridging table entry
        ForwardingObjective.Builder fob =
                hostFwdObjBuilder(deviceId, mac, vlanId, port);
        if (fob == null) {
            log.warn("Fail to create fwd obj for host {}/{}. Abort.", mac, vlanId);
            return;
        }
        ObjectiveContext context = new DefaultObjectiveContext(
                (objective) -> log.debug("Host rule for {} revoked", host),
                (objective, error) ->
                        log.warn("Failed to revoke host rule for {}: {}", host, error));
        flowObjectiveService.forward(deviceId, fob.remove(context));

        // Revoke IP table entry
        ips.forEach(ip -> {
            if (ip.isIp4()) {
                removePerHostRoute(location, ip.getIp4Address());
                srManager.routingRulePopulator.revokeIpRuleForHost(
                        deviceId, ip.getIp4Address(), mac, port);
            }
        });
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:34,代码来源:HostHandler.java

示例5: setUpConnectivityHostToHost

import org.onosproject.net.Host; //导入方法依赖的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

示例6: description

import org.onosproject.net.Host; //导入方法依赖的package包/类
/**
 * Produces a host description from the given host.
 *
 * @param host host to copy
 * @return host description
 */
static DefaultHostDescription description(Host host) {
    return new DefaultHostDescription(host.mac(), host.vlan(), host.location(),
                                      host.ipAddresses());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:11,代码来源:TopologySimulator.java


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