ARP Packet Activator. Also, fixed some of the package names. 83/7883/1
authorAlex Fan <railor33@gmail.com>
Tue, 10 Jun 2014 20:50:47 +0000 (13:50 -0700)
committerAlex Fan <railor33@gmail.com>
Tue, 10 Jun 2014 20:50:47 +0000 (13:50 -0700)
Change-Id: Ica96347da0adbe4aa203b471db7a191562938043
Signed-off-by: Alex Fan <railor33@gmail.com>
arppacket/implementation/src/main/java/org/opendaylight/l2switch/arppacket/ArpDecoder.java
arppacket/implementation/src/main/java/org/opendaylight/l2switch/arppacket/ArpPacketProvider.java

index 0ef59a042ac8196b33da7f6e9c2b9f18a6c41c25..8442bbd88415cdc3299b01633ef5e9949ec42a91 100644 (file)
@@ -1,9 +1,9 @@
-package org.opendaylight.l2switch.packethandler.decoders;
+package org.opendaylight.l2switch.arppacket;
 
 import org.opendaylight.controller.sal.packet.BitBufferHelper;
 import org.opendaylight.controller.sal.packet.BufferException;
 import org.opendaylight.controller.sal.utils.HexEncode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.arp.rev140528.ArpPacket;
+import org.opendaylight.l2switch.packethandler.decoders.PacketDecoder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.arp.rev140528.ArpPacketBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.arp.rev140528.KnownHardwareType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.arp.rev140528.KnownOperation;
index a626c49866135a1f51ae95e28f40c74929228fb2..b130bdab9af041cbbcf3d4155f8d886087135ae2 100644 (file)
@@ -5,12 +5,15 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.l2switch.packethandler;
+package org.opendaylight.l2switch.arppacket;
 
 import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareConsumer;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.controller.sal.binding.api.NotificationService;
 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
+import org.opendaylight.l2switch.packethandler.decoders.PacketDecoderService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.arp.rev140528.ArpPacketReceived;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.ethernet.rev140528.KnownEtherType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
 //import org.opendaylight.yangtools.concepts.Registration;
 //import org.opendaylight.yangtools.yang.binding.NotificationListener;
@@ -18,40 +21,28 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * ArpPacketProvider serves as the Activator for our L2Switch OSGI bundle.
+ * ArpPacketProvider serves as the Activator for our ArpPacket OSGI bundle.
  */
 public class ArpPacketProvider extends AbstractBindingAwareConsumer
     implements AutoCloseable {
 
   private final static Logger _logger = LoggerFactory.getLogger(ArpPacketProvider.class);
 
-//  private Registration<NotificationListener> rawPacketListenerRegistration;
-
-
   /**
-   * Setup the packet handler.
-   *
+   * Setup the ARP packet handler.
    * @param consumerContext The context of the L2Switch.
    */
   @Override
   public void onSessionInitialized(BindingAwareBroker.ConsumerContext consumerContext) {
-    /*DataBrokerService dataService = consumerContext.<DataBrokerService>getSALService(DataBrokerService.class);
-    NotificationService notificationService =
-        consumerContext.<NotificationService>getSALService(NotificationService.class);
-    PacketProcessingService packetProcessingService =
-        consumerContext.<PacketProcessingService>getRpcService(PacketProcessingService.class);
-    RawPacketHandler rawPacketHandler = new RawPacketHandler();
-    this.rawPacketListenerRegistration = notificationService.registerNotificationListener(rawPacketHandler);*/
+    //ToDo: Replace with config subsystem call
+    PacketDecoderService packetDecoderService = consumerContext.getSALService(PacketDecoderService.class);
+    packetDecoderService.registerDecoder(KnownEtherType.Arp, new ArpDecoder(), ArpPacketReceived.class);
   }
 
   /**
-   * Cleanup the packet handler..
-   *
-   * @throws Exception occurs when the NotificationListener is closed
+   * Cleanup the ARP packet handler
    */
   @Override
-  public void close() throws Exception {
-    //if(rawPacketListenerRegistration != null)
-    //  rawPacketListenerRegistration.close();
+  public void close() {
   }
 }
\ No newline at end of file