-
/*
* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
*
import org.opendaylight.controller.sal.packet.PacketResult;
import org.opendaylight.controller.sal.packet.RawPacket;
import org.opendaylight.controller.sal.utils.GlobalConstants;
+import org.opendaylight.controller.sal.utils.HexEncode;
public class DataPacketMuxDemux implements IContainerListener,
IMessageListener, IDataPacketMux, IInventoryShimExternalListener {
private ConcurrentMap<Long, ISwitch> swID2ISwitch = new ConcurrentHashMap<Long, ISwitch>();
// Gives a map between a Container and all the DataPacket listeners on SAL
private ConcurrentMap<String, IPluginOutDataPacketService> pluginOutDataPacketServices = new ConcurrentHashMap<String, IPluginOutDataPacketService>();
- // Gives a map between a NodeConnector and the containers to which it belongs
+ // Gives a map between a NodeConnector and the containers to which it
+ // belongs
private ConcurrentMap<NodeConnector, List<String>> nc2Container = new ConcurrentHashMap<NodeConnector, List<String>>();
// Gives a map between a Container and the FlowSpecs on it
private ConcurrentMap<String, List<ContainerFlow>> container2FlowSpecs = new ConcurrentHashMap<String, List<ContainerFlow>>();
/**
* Function called by the dependency manager when all the required
* dependencies are satisfied
- *
+ *
*/
void init() {
this.controller.addMessageListener(OFType.PACKET_IN, this);
}
/**
- * Function called by the dependency manager when at least one
- * dependency become unsatisfied or when the component is shutting
- * down because for example bundle is being stopped.
- *
+ * Function called by the dependency manager when at least one dependency
+ * become unsatisfied or when the component is shutting down because for
+ * example bundle is being stopped.
+ *
*/
void destroy() {
this.controller.removeMessageListener(OFType.PACKET_IN, this);
if (sw == null || msg == null
|| this.pluginOutDataPacketServices == null) {
// Something fishy, we cannot do anything
- logger.debug("sw: {} and/or msg: {} and/or pluginOutDataPacketServices: {} is null!",
- new Object[]{sw, msg, this.pluginOutDataPacketServices});
+ logger.debug(
+ "sw: {} and/or msg: {} and/or pluginOutDataPacketServices: {} is null!",
+ new Object[] { sw, msg, this.pluginOutDataPacketServices });
return;
}
if (msg instanceof OFPacketIn) {
.get(GlobalConstants.DEFAULT.toString());
if (defaultOutService != null) {
defaultOutService.receiveDataPacket(dataPacket);
- logger.trace("Dispatched to apps a frame of size: {} on container: {}",
- ofPacket.getPacketData().length, GlobalConstants.DEFAULT.toString());
+ logger.trace(
+ "Dispatched to apps a frame of size: {} on container: {}: {}",
+ new Object[] {
+ ofPacket.getPacketData().length,
+ GlobalConstants.DEFAULT.toString(),
+ HexEncode.bytesToHexString(dataPacket
+ .getPacketData()) });
}
// Now check the mapping between nodeConnector and
- // Container and later on optinally filter based on
+ // Container and later on optimally filter based on
// flowSpec
List<String> containersRX = this.nc2Container.get(p);
if (containersRX != null) {
if (s != null) {
// TODO add filtering on a per-flowSpec base
s.receiveDataPacket(dataPacket);
- logger.trace("Dispatched to apps a frame of size: {} on container: {}",
- ofPacket.getPacketData().length, GlobalConstants.DEFAULT.toString());
+ logger.trace(
+ "Dispatched to apps a frame of size: {} on container: {}: {}",
+ new Object[] {
+ ofPacket.getPacketData().length,
+ GlobalConstants.DEFAULT.toString(),
+ HexEncode
+ .bytesToHexString(dataPacket
+ .getPacketData()) });
}
}
public void transmitDataPacket(RawPacket outPkt) {
// Sanity check area
if (outPkt == null) {
- logger.debug("outPkt is null!");
+ logger.debug("outPkt is null!");
return;
}
NodeConnector outPort = outPkt.getOutgoingNodeConnector();
if (outPort == null) {
- logger.debug("outPort is null! outPkt: {}", outPkt);
+ logger.debug("outPort is null! outPkt: {}", outPkt);
return;
}
if (!outPort.getType().equals(
NodeConnector.NodeConnectorIDType.OPENFLOW)) {
// The output Port is not of type OpenFlow
- logger.debug("outPort is not OF Type! outPort: {}", outPort);
+ logger.debug("outPort is not OF Type! outPort: {}", outPort);
return;
}
if (sw == null) {
// If we cannot get the controller descriptor we cannot even
// send out the frame
- logger.debug("swID: {} - sw is null!", swID);
+ logger.debug("swID: {} - sw is null!", swID);
return;
}
// build action
OFActionOutput action = new OFActionOutput().setPort(port);
// build packet out
- OFPacketOut po = new OFPacketOut().setBufferId(
- OFPacketOut.BUFFER_ID_NONE).setInPort(OFPort.OFPP_NONE)
+ OFPacketOut po = new OFPacketOut()
+ .setBufferId(OFPacketOut.BUFFER_ID_NONE)
+ .setInPort(OFPort.OFPP_NONE)
.setActions(Collections.singletonList((OFAction) action))
.setActionsLength((short) OFActionOutput.MINIMUM_LENGTH);
public void addNode(Node node, Set<Property> props) {
if (node == null) {
- logger.debug("node is null!");
+ logger.debug("node is null!");
return;
- }
+ }
long sid = (Long) node.getID();
ISwitch sw = controller.getSwitches().get(sid);
if (sw == null) {
- logger.debug("sid: {} - sw is null!", sid);
- return;
+ logger.debug("sid: {} - sw is null!", sid);
+ return;
}
this.swID2ISwitch.put(sw.getId(), sw);
}
public void removeNode(Node node) {
if (node == null) {
- logger.debug("node is null!");
+ logger.debug("node is null!");
return;
}
long sid = (Long) node.getID();
ISwitch sw = controller.getSwitches().get(sid);
if (sw == null) {
- logger.debug("sid: {} - sw is null!", sid);
- return;
+ logger.debug("sid: {} - sw is null!", sid);
+ return;
}
this.swID2ISwitch.remove(sw.getId());
}
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import org.opendaylight.controller.sal.utils.HexEncode;
import org.opendaylight.controller.sal.utils.NetUtils;
/**
int lldpOffset = bitOffset; // LLDP start
int lldpSize = size; // LLDP size
+ logger.trace("LLDP: {} (offset {} bitsize {})", new Object[] {
+ HexEncode.bytesToHexString(data), lldpOffset, lldpSize });
/*
* Deserialize the TLVs until we reach the end of the packet
*/
throw new PacketException(e.getMessage());
}
+ logger.trace("LLDP: serialized: {}",
+ HexEncode.bytesToHexString(serializedBytes));
return serializedBytes;
}
* Store the raw read value, checks the payload type and set the
* payloadClass accordingly
*/
+ logger.trace("{}: {}: {} (offset {} bitsize {})",
+ new Object[] { this.getClass().getSimpleName(), hdrField,
+ HexEncode.bytesToHexString(hdrFieldBytes),
+ startOffset, numBits });
+
this.setHeaderField(hdrField, hdrFieldBytes);
}
* packet class, into a single stream of bytes to be sent on the wire
*
* @return byte[] - serialized bytes
- * @throws PacketException
+ * @throws PacketException
*/
public byte[] serialize() throws PacketException {
}
postSerializeCustomOperation(headerBytes);
+ logger.trace("{}: {}", this.getClass().getSimpleName(),
+ HexEncode.bytesToHexString(headerBytes));
return headerBytes;
}
-
/*
* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
*
import org.opendaylight.controller.sal.core.TimeStamp;
/**
- *
- * Describe a raw Data Packet, this is how a packet is
- * received from the network and how it will be transmitted. It
- * essentially wraps the raw bytestream
- *
+ *
+ * Describe a raw Data Packet, this is how a packet is received from the network
+ * and how it will be transmitted. It essentially wraps the raw bytestream
+ *
*/
public class RawPacket {
private byte[] packetData;
private NodeConnector outgoingNodeConnector;
/**
- * If the packet is being sent this parameter tells where the
- * packet is sent toward
- *
- *
+ * If the packet is being sent this parameter tells where the packet is sent
+ * toward
+ *
+ *
* @return the NodeConnector toward where the packet is being sent
*/
public NodeConnector getOutgoingNodeConnector() {
/**
* Setter method for OutGoing NodeConnector
- *
- * @param outgoingNodeConnector NodeConnector toward where the
- * packet is travelling
+ *
+ * @param outgoingNodeConnector
+ * NodeConnector toward where the packet is travelling
*/
public void setOutgoingNodeConnector(NodeConnector outgoingNodeConnector) {
this.outgoingNodeConnector = outgoingNodeConnector;
/**
* Return the incoming NodeConnector if the packet was received
- *
+ *
* @return NodeConnector where the packet was received from
*/
public NodeConnector getIncomingNodeConnector() {
/**
* Setter for Incoming NodeConnector
- *
- * @param incomingNodeConnector NodeConnector to be used and incoming one
+ *
+ * @param incomingNodeConnector
+ * NodeConnector to be used and incoming one
*/
public void setIncomingNodeConnector(NodeConnector incomingNodeConnector) {
this.incomingNodeConnector = incomingNodeConnector;
/**
* Retrieve a given property attached to the packet, if exits of course
- *
- * @param key Key to retrieve the wanted property attached to the packet
- *
+ *
+ * @param key
+ * Key to retrieve the wanted property attached to the packet
+ *
* @return The property attached to the packet
*/
public Object getProps(Object key) {
/**
* Generic data associated to the data packet
- *
- * @param key key for the association
- * @param value value associated to the key
+ *
+ * @param key
+ * key for the association
+ * @param value
+ * value associated to the key
*/
public void setProps(Object key, Object value) {
if (this.props == null) {
/**
* Constructor for RawPacket
- *
- * @param data content of the packet as bytestream
- * @param e datalink encapsulation for the packet
- *
+ *
+ * @param data
+ * content of the packet as bytestream
+ * @param e
+ * datalink encapsulation for the packet
+ *
*/
public RawPacket(byte[] data, LinkEncap e) throws ConstructionException {
if (data == null) {
}
/**
- * Copy Constructor for RawPacket, it perform a copy of the packet
- * so each packet can be modified indipendently without worrying
- * that source packet content is touched
- *
- * @param src packet to copy data from
- *
+ * Copy Constructor for RawPacket, it performs a copy of the packet so each
+ * packet can be modified independently without worrying that source packet
+ * content is touched
+ *
+ * @param src
+ * packet to copy data from
+ *
*/
public RawPacket(RawPacket src) throws ConstructionException {
if (src == null) {
}
if (src.getPacketData() != null) {
this.packetData = new byte[src.getPacketData().length];
- System.arraycopy(src.getPacketData(), 0, this.packetData, 0, src
- .getPacketData().length);
+ System.arraycopy(src.getPacketData(), 0, this.packetData, 0,
+ src.getPacketData().length);
} else {
throw new ConstructionException("Empty packetData");
}
/**
* Constructor for RawPacket with Ethernet encapsulation
- *
- * @param data content of the packet as bytestream
- *
+ *
+ * @param data
+ * content of the packet as bytestream
+ *
*/
public RawPacket(byte[] data) throws ConstructionException {
this(data, LinkEncap.ETHERNET);
/**
* Read the timestamp when the packet has entered the system
- *
+ *
* @return The timestamp when the packet has entered the system
*/
public TimeStamp getIncomingTime() {
/**
* Read the packet encapsulation
- *
- * @return The encapsulation for the raw packet, necessary to
- * start parsing the packet
+ *
+ * @return The encapsulation for the raw packet, necessary to start parsing
+ * the packet
*/
public LinkEncap getEncap() {
return this.encap;
/**
* Get bytestream of the packet body
- *
+ *
* @return The raw bytestream composing the packet
*/
public byte[] getPacketData() {