本文整理汇总了Java中org.onlab.packet.IpAddress.equals方法的典型用法代码示例。如果您正苦于以下问题:Java IpAddress.equals方法的具体用法?Java IpAddress.equals怎么用?Java IpAddress.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onlab.packet.IpAddress
的用法示例。
在下文中一共展示了IpAddress.equals方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fixedIpIsUsed
import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
@Override
public boolean fixedIpIsUsed(IpAddress fixedIpAddr, TenantId tenantId,
FloatingIpId floatingIpId) {
checkNotNull(fixedIpAddr, "Fixed IP address cannot be null");
checkNotNull(tenantId, "Tenant Id cannot be null");
checkNotNull(floatingIpId, "Floating IP Id cannot be null");
Collection<FloatingIp> floatingIps = getFloatingIps();
for (FloatingIp floatingIp : floatingIps) {
IpAddress fixedIp = floatingIp.fixedIp();
if (fixedIp != null) {
if (fixedIp.equals(fixedIpAddr)
&& floatingIp.tenantId().equals(tenantId)
&& !floatingIp.id().equals(floatingIpId)) {
return true;
}
}
}
return false;
}
示例2: getSubnetOfFloatingIP
import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
private Subnet getSubnetOfFloatingIP(FloatingIp floatingIp) {
DeviceId exVmPortId = DeviceId
.deviceId(floatingIp.id().floatingIpId().toString());
Collection<VirtualPort> exVmPortList = virtualPortService
.getPorts(exVmPortId);
VirtualPort exVmPort = null;
if (exVmPortList != null) {
exVmPort = exVmPortList.iterator().next();
}
if (exVmPort == null) {
return null;
}
Set<FixedIp> fixedIps = exVmPort.fixedIps();
SubnetId subnetId = null;
for (FixedIp f : fixedIps) {
IpAddress fp = f.ip();
if (fp.equals(floatingIp.floatingIp())) {
subnetId = f.subnetId();
break;
}
}
if (subnetId == null) {
return null;
}
Subnet subnet = subnetService.getSubnet(subnetId);
return subnet;
}
示例3: isConnectedToPeer
import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
/**
* Examines if BGP peer is connected.
*
* @param peer IP address of peer
* @return result of search
*/
public boolean isConnectedToPeer(IpAddress peer) {
for (final IpAddress entry : peers()) {
if (entry.equals(peer)) {
return true;
}
}
return false;
}
示例4: processRouteAdd
import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
/**
* Processes adding a route entry.
* <p>
* The route entry is added to the radix tree. If there was an existing
* next hop for this prefix, but the next hop was different, then the
* old route entry is deleted.
* </p>
* <p>
* NOTE: Currently, we don't handle routes if the next hop is within the
* SDN domain.
* </p>
*
* @param routeEntry the route entry to add
* @param withdrawPrefixes the collection of accumulated prefixes whose
* intents will be withdrawn
* @return the corresponding FIB entry change, or null
*/
private FibEntry processRouteAdd(RouteEntry routeEntry,
Collection<IpPrefix> withdrawPrefixes) {
log.debug("Processing route add: {}", routeEntry);
// Find the old next-hop if we are updating an old route entry
IpAddress oldNextHop = null;
RouteEntry oldRouteEntry = findRibRoute(routeEntry.prefix());
if (oldRouteEntry != null) {
oldNextHop = oldRouteEntry.nextHop();
}
// Add the new route to the RIB
addRibRoute(routeEntry);
if (oldNextHop != null) {
if (oldNextHop.equals(routeEntry.nextHop())) {
return null; // No change
}
//
// Update an existing nexthop for the prefix.
// We need to remove the old flows for this prefix from the
// switches before the new flows are added.
//
withdrawPrefixes.add(routeEntry.prefix());
}
if (routingConfigurationService.isIpPrefixLocal(routeEntry.prefix())) {
// Route originated by local SDN domain
// We don't handle these here, reactive routing APP will handle
// these
log.debug("Own route {} to {}",
routeEntry.prefix(), routeEntry.nextHop());
return null;
}
//
// Find the MAC address of next hop router for this route entry.
// If the MAC address can not be found in ARP cache, then this prefix
// will be put in routesWaitingOnArp queue. Otherwise, generate
// a new route intent.
//
// Monitor the IP address for updates of the MAC address
hostService.startMonitoringIp(routeEntry.nextHop());
// Check if we know the MAC address of the next hop
MacAddress nextHopMacAddress = ip2Mac.get(routeEntry.nextHop());
if (nextHopMacAddress == null) {
Set<Host> hosts = hostService.getHostsByIp(routeEntry.nextHop());
if (!hosts.isEmpty()) {
nextHopMacAddress = hosts.iterator().next().mac();
}
if (nextHopMacAddress != null) {
ip2Mac.put(routeEntry.nextHop(), nextHopMacAddress);
}
}
if (nextHopMacAddress == null) {
routesWaitingOnArp.put(routeEntry.nextHop(), routeEntry);
return null;
}
return new FibEntry(routeEntry.prefix(), routeEntry.nextHop(),
nextHopMacAddress);
}
示例5: upStreamPacketProcessor
import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
private void upStreamPacketProcessor(IPv4 ipPacket, DeviceId deviceId) {
IpAddress srcIp = IpAddress.valueOf(ipPacket.getSourceAddress());
IpAddress dstIp = IpAddress.valueOf(ipPacket.getDestinationAddress());
FloatingIp floatingIp = null;
Collection<FloatingIp> floatingIps = floatingIpService
.getFloatingIps();
Set<FloatingIp> floatingIpSet = Sets.newHashSet(floatingIps)
.stream().collect(Collectors.toSet());
for (FloatingIp f : floatingIpSet) {
IpAddress fixIp = f.fixedIp();
if (fixIp != null && fixIp.equals(srcIp)) {
floatingIp = f;
break;
}
}
if (floatingIp == null) {
return;
}
Subnet subnet = getSubnetOfFloatingIP(floatingIp);
IpAddress gwIp = subnet.gatewayIp();
Port exportPort = exPortOfDevice.get(deviceId);
MacAddress exPortMac = MacAddress.valueOf(exportPort.annotations()
.value(AnnotationKeys.PORT_MAC));
IpPrefix ipPrefix = subnet.cidr();
if (ipPrefix == null) {
return;
}
int mask = ipPrefix.prefixLength();
if (mask <= 0) {
return;
}
Ethernet ethernet = null;
// if the same ip segment
if (IpUtil.checkSameSegment(floatingIp.floatingIp(), dstIp, mask)) {
ethernet = buildArpRequest(dstIp, floatingIp.floatingIp(),
exPortMac);
} else {
ethernet = buildArpRequest(gwIp, floatingIp.floatingIp(),
exPortMac);
}
if (ethernet != null) {
sendPacketOut(deviceId, exportPort.number(), ethernet);
}
}
示例6: downloadSnatRules
import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
private boolean downloadSnatRules(DeviceId deviceId, MacAddress srcMac,
IpAddress srcIp, MacAddress dstMac,
IpAddress dstIp, FloatingIp floatingIp) {
TenantNetwork exNetwork = tenantNetworkService
.getNetwork(floatingIp.networkId());
IpAddress fixedIp = floatingIp.fixedIp();
VirtualPortId vmPortId = floatingIp.portId();
VirtualPort vmPort = virtualPortService.getPort(vmPortId);
if (vmPort == null) {
vmPort = VtnData.getPort(vPortStore, vmPortId);
}
Subnet subnet = getSubnetOfFloatingIP(floatingIp);
IpPrefix ipPrefix = subnet.cidr();
IpAddress gwIp = subnet.gatewayIp();
if (ipPrefix == null) {
return false;
}
int mask = ipPrefix.prefixLength();
if (mask <= 0) {
return false;
}
TenantRouter tenantRouter = TenantRouter
.tenantRouter(floatingIp.tenantId(), floatingIp.routerId());
SegmentationId l3vni = vtnRscService.getL3vni(tenantRouter);
// if the same ip segment
if (IpUtil.checkSameSegment(srcIp, dstIp, mask)) {
snatService.programSnatSameSegmentRules(deviceId, l3vni, fixedIp,
dstIp, dstMac, srcMac,
srcIp,
exNetwork.segmentationId(),
Objective.Operation.ADD);
if (dstIp.equals(gwIp)) {
snatService
.programSnatDiffSegmentRules(deviceId, l3vni, fixedIp,
dstMac, srcMac, srcIp,
exNetwork.segmentationId(),
Objective.Operation.ADD);
}
}
return true;
}
示例7: processPacketIn
import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
/**
* Processes ARP request packets.
* It checks if the target IP is owned by a known host first and then ask to
* OpenStack if it's not. This ARP proxy does not support overlapping IP.
*
* @param pkt ARP request packet
* @param openstackPortInfoCollection collection of port information
*/
public void processPacketIn(InboundPacket pkt, Collection<OpenstackPortInfo> openstackPortInfoCollection) {
Ethernet ethRequest = pkt.parsed();
ARP arp = (ARP) ethRequest.getPayload();
if (arp.getOpCode() != ARP.OP_REQUEST) {
return;
}
IpAddress sourceIp = Ip4Address.valueOf(arp.getSenderProtocolAddress());
MacAddress srcMac = MacAddress.valueOf(arp.getSenderHardwareAddress());
OpenstackPortInfo portInfo = openstackPortInfoCollection.stream()
.filter(p -> p.ip().equals(sourceIp) && p.mac().equals(srcMac)).findFirst().orElse(null);
IpAddress targetIp = Ip4Address.valueOf(arp.getTargetProtocolAddress());
MacAddress dstMac;
if (targetIp.equals(portInfo == null ? null : portInfo.gatewayIP())) {
dstMac = GATEWAY_MAC;
} else {
dstMac = getMacFromHostService(targetIp);
if (dstMac == null) {
dstMac = getMacFromOpenstack(targetIp);
}
}
if (dstMac == null) {
log.debug("Failed to find MAC address for {}", targetIp.toString());
return;
}
Ethernet ethReply = ARP.buildArpReply(targetIp.getIp4Address(),
dstMac,
ethRequest);
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
.setOutput(pkt.receivedFrom().port())
.build();
packetService.emit(new DefaultOutboundPacket(
pkt.receivedFrom().deviceId(),
treatment,
ByteBuffer.wrap(ethReply.serialize())));
}
示例8: processHello
import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
/**
* Process an incoming PIM Hello message. There are a few things going on in
* this method:
* <ul>
* <li>We <em>may</em> have to create a new neighbor if one does not already exist</li>
* <li>We <em>may</em> need to re-elect a new DR if new information is received</li>
* <li>We <em>may</em> need to send an existing neighbor all joins if the genid changed</li>
* <li>We will refresh the neighbor's timestamp</li>
* </ul>
*
* @param ethPkt the Ethernet packet header
*/
public void processHello(Ethernet ethPkt) {
if (log.isTraceEnabled()) {
log.trace("Received a PIM hello packet");
}
// We'll need to save our neighbors MAC address
MacAddress nbrmac = ethPkt.getSourceMAC();
// And we'll need to save neighbors IP Address.
IPv4 iphdr = (IPv4) ethPkt.getPayload();
IpAddress srcip = IpAddress.valueOf(iphdr.getSourceAddress());
PIM pimhdr = (PIM) iphdr.getPayload();
if (pimhdr.getPimMsgType() != PIM.TYPE_HELLO) {
log.error("process Hello has received a non hello packet type: " + pimhdr.getPimMsgType());
return;
}
// get the DR values for later calculation
PimNeighbor dr = pimNeighbors.get(drIpaddress);
checkNotNull(dr);
IpAddress drip = drIpaddress;
int drpri = dr.priority();
// Assume we do not need to run a DR election
boolean reElectDr = false;
boolean genidChanged = false;
PIMHello hello = (PIMHello) pimhdr.getPayload();
// Determine if we already have a PIMNeighbor
PimNeighbor nbr = pimNeighbors.getOrDefault(srcip, null);
PimNeighbor newNbr = PimNeighbor.createPimNeighbor(srcip, nbrmac, hello.getOptions().values());
if (nbr == null) {
pimNeighbors.putIfAbsent(srcip, newNbr);
nbr = newNbr;
} else if (!nbr.equals(newNbr)) {
if (newNbr.holdtime() == 0) {
// Neighbor has shut down. Remove them and clean up
pimNeighbors.remove(srcip, nbr);
return;
} else {
// Neighbor has changed one of their options.
pimNeighbors.put(srcip, newNbr);
nbr = newNbr;
}
}
// Refresh this neighbor's timestamp
nbr.refreshTimestamp();
/*
* the election method will first determine if an election
* needs to be run, if so it will run the election. The
* IP address of the DR will be returned. If the IP address
* of the DR is different from what we already have we know a
* new DR has been elected.
*/
IpAddress electedIp = election(nbr, drip, drpri);
if (!drip.equals(electedIp)) {
// we have a new DR.
drIpaddress = electedIp;
}
}