Add neighbor lifecycle management.

 * Made PIMNeighbor mostly immutable (apart from updatable timestamp)
 * Equals and hashCode for PIMNeighbor
 * Remove neighbor when we see a HELLO with holdTime==0
 * Periodic task to time out neighbors who haven't sent a HELLO in a while
 * Added a CLI command to view PIM neighbors

Change-Id: I59e52a847f7abcb8e9ac660c2cccace53e46867b
diff --git a/apps/pim/src/main/java/org/onosproject/pim/cli/PimNeighborsListCommand.java b/apps/pim/src/main/java/org/onosproject/pim/cli/PimNeighborsListCommand.java
new file mode 100644
index 0000000..605ec81
--- /dev/null
+++ b/apps/pim/src/main/java/org/onosproject/pim/cli/PimNeighborsListCommand.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.pim.cli;
+
+import org.apache.karaf.shell.commands.Command;
+import org.onlab.util.Tools;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.pim.impl.PIMInterface;
+import org.onosproject.pim.impl.PIMInterfaceService;
+import org.onosproject.pim.impl.PIMNeighbor;
+
+import java.util.Set;
+
+/**
+ * Lists PIM neighbors.
+ */
+@Command(scope = "onos", name = "pim-neighbors",
+        description = "Lists the PIM neighbors")
+public class PimNeighborsListCommand extends AbstractShellCommand {
+
+    private static final String INTF_FORMAT = "interface=%s, address=%s";
+    private static final String NEIGHBOR_FORMAT = "  neighbor=%s, uptime=%s, holdtime=%s, drPriority=%s, genId=%s";
+
+    @Override
+    protected void execute() {
+        PIMInterfaceService interfaceService = get(PIMInterfaceService.class);
+
+        Set<PIMInterface> interfaces = interfaceService.getPimInterfaces();
+
+        for (PIMInterface intf : interfaces) {
+            print(INTF_FORMAT, intf.getInterface().name(), intf.getIpAddress());
+            for (PIMNeighbor neighbor : intf.getNeighbors()) {
+                // Filter out the PIM neighbor representing 'us'
+                if (!neighbor.ipAddress().equals(intf.getIpAddress())) {
+                    print(NEIGHBOR_FORMAT, neighbor.ipAddress(),
+                            Tools.timeAgo(neighbor.upTime()), neighbor.holdtime(),
+                            neighbor.priority(), neighbor.generationId());
+                }
+            }
+        }
+    }
+
+}