Finish off a couple of things to get PIM to send HELLOs.

Also added packet request to PacketService to get punt flows installed in switches.

Change-Id: I7340d09a1cf2ec06fb33ac0c4fc14eb43e94f496
diff --git a/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterface.java b/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterface.java
index b6ba703..454c431 100644
--- a/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterface.java
+++ b/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterface.java
@@ -24,9 +24,14 @@
 import org.onlab.packet.pim.PIMHello;
 import org.onlab.packet.pim.PIMHelloOption;
 import org.onosproject.incubator.net.intf.Interface;
+import org.onosproject.net.flow.DefaultTrafficTreatment;
+import org.onosproject.net.flow.TrafficTreatment;
 import org.onosproject.net.host.InterfaceIpAddress;
+import org.onosproject.net.packet.DefaultOutboundPacket;
+import org.onosproject.net.packet.PacketService;
 import org.slf4j.Logger;
 
+import java.nio.ByteBuffer;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -42,7 +47,10 @@
 
     private final Logger log = getLogger(getClass());
 
+    private final PacketService packetService;
+
     private Interface onosInterface;
+    private final TrafficTreatment outputTreatment;
 
     // Our hello opt holdtime
     private short holdtime = PIMHelloOption.DEFAULT_HOLDTIME;
@@ -67,8 +75,10 @@
      *
      * @param intf the ONOS Interface.
      */
-    public PIMInterface(Interface intf) {
+    public PIMInterface(Interface intf, PacketService packetService) {
         onosInterface = intf;
+        outputTreatment = createOutputTreatment();
+        this.packetService = packetService;
         IpAddress ourIp = getIpAddress();
         MacAddress mac = intf.mac();
 
@@ -82,6 +92,12 @@
         drIpaddress = ourIp;
     }
 
+    private TrafficTreatment createOutputTreatment() {
+        return DefaultTrafficTreatment.builder()
+                .setOutput(onosInterface.connectPoint().port())
+                .build();
+    }
+
     /**
      * Return the ONOS Interface.
      *
@@ -187,7 +203,10 @@
         // Now set the hello option payload
         pimPacket.setPIMPayload(hello);
 
-        // TODO: How to send the packet.?.
+        packetService.emit(new DefaultOutboundPacket(
+                onosInterface.connectPoint().deviceId(),
+                outputTreatment,
+                ByteBuffer.wrap(pimPacket.getEthernet().serialize())));
     }
 
     /**