本文整理汇总了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;
}
}
示例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;
}
示例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);
}
});
}
}
示例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);
}
});
}
}
示例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);
}
}
示例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());
}