import java.math.BigInteger;
import java.util.Collections;
import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
import org.opendaylight.openflowplugin.openflow.md.core.IMDMessageTranslator;
import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
protected static final Logger LOG = LoggerFactory
.getLogger(PacketInTranslator.class);
@Override
- public List<DataObject> translate(SwitchConnectionDistinguisher cookie,
- SessionContext sc, OfHeader msg) {
-
+ public List<DataObject> translate(final SwitchConnectionDistinguisher cookie,
+ final SessionContext sc, final OfHeader msg) {
+
List<DataObject> salPacketIn = Collections.emptyList();
-
+
if (sc != null && msg instanceof PacketInMessage) {
PacketInMessage message = (PacketInMessage)msg;
LOG.trace("PacketIn[v{}]: Cookie: {} Match.type: {}",
- message.getVersion(), message.getCookie(),
+ message.getVersion(), message.getCookie(),
message.getMatch() != null ? message.getMatch().getType() : message.getMatch());
// create a packet received event builder
LOG.warn("Received packet_in, but there is no device datapathId received yet");
} else {
BigInteger dpid = features.getDatapathId();
-
+
// get the Cookie if it exists
if(message.getCookie() != null) {
pktInBuilder.setFlowCookie(new FlowCookie(message.getCookie()));
}
//TODO: use either canonical mapping or suitable hash -> 32b
//pktInBuilder.setConnectionCookie(cookie);
-
+
// extract the port number
Long port = null;
if (message.getMatch() != null && message.getMatch().getMatchEntries() != null) {
}
}
}
-
+
if (port == null) {
// no incoming port, so drop the event
LOG.warn("Received packet_in, but couldn't find an input port");
} else {
LOG.trace("Received packet_in from {} on port {}", dpid, port);
-
+
Match match = MatchConvertorImpl.fromOFMatchToSALMatch(message.getMatch(),dpid);
MatchBuilder matchBuilder = new MatchBuilder(match);
pktInBuilder.setMatch(matchBuilder.build());
-
+
pktInBuilder.setPacketInReason(PacketInUtil.getMdSalPacketInReason(message.getReason()));
pktInBuilder.setTableId(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId(message.getTableId().getValue().shortValue()));
pktInBuilder.setIngress(InventoryDataServiceUtil.nodeConnectorRefFromDatapathIdPortno(dpid,port));
PacketReceived pktInEvent = pktInBuilder.build();
- salPacketIn = new CopyOnWriteArrayList<DataObject>();
- salPacketIn.add(pktInEvent);
+ salPacketIn = Collections.<DataObject>singletonList(pktInEvent);
}
- }
- }
+ }
+ }
return salPacketIn;
}
}
import java.math.BigInteger;
import java.util.Collections;
import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
import org.opendaylight.openflowplugin.openflow.md.core.IMDMessageTranslator;
import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
protected static final Logger LOG = LoggerFactory
.getLogger(PacketInV10Translator.class);
@Override
- public List<DataObject> translate(SwitchConnectionDistinguisher cookie,
- SessionContext sc, OfHeader msg) {
-
+ public List<DataObject> translate(final SwitchConnectionDistinguisher cookie,
+ final SessionContext sc, final OfHeader msg) {
+
List<DataObject> salPacketIn = Collections.emptyList();
-
+
if (sc != null && msg instanceof PacketInMessage) {
PacketInMessage message = (PacketInMessage)msg;
LOG.trace("PacketIn[v{}]: InPort: {}",
pktInBuilder.setPacketInReason(PacketInUtil.getMdSalPacketInReason(message.getReason()));
pktInBuilder.setIngress(InventoryDataServiceUtil.nodeConnectorRefFromDatapathIdPortno(dpid, port));
PacketReceived pktInEvent = pktInBuilder.build();
- salPacketIn = new CopyOnWriteArrayList<DataObject>();
- salPacketIn.add(pktInEvent);
+ salPacketIn = Collections.<DataObject>singletonList(pktInEvent);
}
- }
- }
+ }
+ }
return salPacketIn;
}
}