Commit d60dceca authored by Michele Santuari's avatar Michele Santuari
Browse files

Packet In processor

parent 38a7af64
......@@ -18,7 +18,14 @@ package org.geant;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onlab.packet.Ethernet;
import org.onosproject.net.packet.InboundPacket;
import org.onosproject.net.packet.PacketContext;
import org.onosproject.net.packet.PacketProcessor;
import org.onosproject.net.packet.PacketService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -30,14 +37,50 @@ public class AppComponent {
private final Logger log = LoggerFactory.getLogger(getClass());
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected PacketService packetService;
PacketProcessor packetProcessor = new Processor();
@Activate
protected void activate() {
log.info("Started");
packetService.addProcessor(packetProcessor,
PacketProcessor.ADVISOR_MAX + 1);
}
@Deactivate
protected void deactivate() {
// We need to remove the packet processor, otherwise the app will
// continue to process packets!
packetService.removeProcessor(packetProcessor);
log.info("Stopped");
}
private class Processor implements PacketProcessor {
@Override
public void process(PacketContext context) {
// Stop processing if the packet has been handled, since we
// can't do any more to it. This check avoid the reception of
// packets that are managed by ONOS (e.g., LLDP)
if (context.isHandled()) {
return;
}
InboundPacket pkt = context.inPacket();
if (pkt == null) {
return;
}
log.info("PacketIn recieved: {}", pkt);
Ethernet ethPkt = pkt.parsed();
if (ethPkt == null) {
return;
}
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment