ProxyArpManager: Factor out common logic for handling ARP and NDP packets.
Change-Id: I0709f9cda2506f01dbc912b8c3e12443ec217fed
diff --git a/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java b/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java
index fe25236..d437bf3 100644
--- a/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java
+++ b/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java
@@ -33,8 +33,6 @@
import org.onosproject.net.Host;
import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.flow.instructions.Instruction;
-import org.onosproject.net.flow.instructions.Instructions;
import org.onosproject.net.host.HostProvider;
import org.onosproject.net.host.InterfaceIpAddress;
import org.onosproject.net.packet.DefaultOutboundPacket;
@@ -43,9 +41,7 @@
import org.onosproject.net.provider.ProviderId;
import java.nio.ByteBuffer;
-import java.util.ArrayList;
import java.util.Collections;
-import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -149,7 +145,7 @@
Set<Host> hosts = hostManager.getHostsByIp(ip);
if (hosts.isEmpty()) {
- sendArpNdpRequest(ip);
+ sendRequest(ip);
} else {
for (Host host : hosts) {
HostProvider provider = hostProviders.get(host.providerId());
@@ -166,12 +162,11 @@
}
/**
- * Sends an ARP or Neighbor Discovery Protocol request for the given IP
- * address.
+ * Sends an ARP or NDP request for the given IP address.
*
* @param targetIp IP address to send the request for
*/
- private void sendArpNdpRequest(IpAddress targetIp) {
+ private void sendRequest(IpAddress targetIp) {
Interface intf = interfaceService.getMatchingInterface(targetIp);
if (intf == null) {
@@ -180,31 +175,26 @@
for (InterfaceIpAddress ia : intf.ipAddresses()) {
if (ia.subnetAddress().contains(targetIp)) {
- sendArpNdpProbe(intf.connectPoint(), targetIp, ia.ipAddress(),
+ sendProbe(intf.connectPoint(), targetIp, ia.ipAddress(),
intf.mac(), intf.vlan());
}
}
}
- private void sendArpNdpProbe(ConnectPoint connectPoint,
- IpAddress targetIp,
- IpAddress sourceIp, MacAddress sourceMac,
- VlanId vlan) {
+ 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);
+ probePacket = buildArpRequest(targetIp, sourceIp, sourceMac, vlan);
} else {
// IPv6: Use Neighbor Discovery
- probePacket = buildNdpRequest(targetIp, sourceIp, sourceMac,
- vlan);
+ probePacket = buildNdpRequest(targetIp, sourceIp, sourceMac, vlan);
}
- List<Instruction> instructions = new ArrayList<>();
- instructions.add(Instructions.createOutput(connectPoint.port()));
-
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
.setOutput(connectPoint.port())
.build();
@@ -273,7 +263,7 @@
icmp6.setIcmpType(ICMP6.NEIGHBOR_SOLICITATION);
icmp6.setIcmpCode((byte) 0);
- // Create the Neighbor Solication packet
+ // Create the Neighbor Solicitation packet
NeighborSolicitation ns = new NeighborSolicitation();
ns.setTargetAddress(targetIp.toOctets());
ns.addOption(NeighborDiscoveryOptions.TYPE_SOURCE_LL_ADDRESS,