本文整理汇总了Java中org.opendaylight.controller.sal.packet.Packet.getPayload方法的典型用法代码示例。如果您正苦于以下问题:Java Packet.getPayload方法的具体用法?Java Packet.getPayload怎么用?Java Packet.getPayload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opendaylight.controller.sal.packet.Packet
的用法示例。
在下文中一共展示了Packet.getPayload方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: receiveDataPacket
import org.opendaylight.controller.sal.packet.Packet; //导入方法依赖的package包/类
@Override
public PacketResult receiveDataPacket(RawPacket inPkt) {
if (inPkt == null) {
return PacketResult.IGNORED;
}
logger.trace("Received a frame of size: {}",
inPkt.getPacketData().length);
Packet formattedPak = this.dataPacketService.decodeDataPacket(inPkt);
if (formattedPak instanceof Ethernet) {
Object nextPak = formattedPak.getPayload();
if (nextPak instanceof IPv4) {
handlePuntedIPPacket((IPv4) nextPak, inPkt
.getIncomingNodeConnector());
logger.trace("Handled IP packet");
}
if (nextPak instanceof ARP) {
handleARPPacket((Ethernet) formattedPak, (ARP) nextPak, inPkt
.getIncomingNodeConnector());
logger.trace("Handled ARP packet");
}
}
return PacketResult.IGNORED;
}
示例2: pktToJSON
import org.opendaylight.controller.sal.packet.Packet; //导入方法依赖的package包/类
/**
* Converts a packet to JSON representation.
*
* @param pkt the packet to be converted
* @return JSON representation.
*/
private JSONObject pktToJSON(RawPacket rawPkt) {
log.trace("Received packet-in event.");
JSONObject json = new JSONObject();
// Add incoming node
// The connector, the packet came from ("port")
NodeConnector ingressConnector = rawPkt.getIncomingNodeConnector();
// The node that received the packet ("switch")
Node node = ingressConnector.getNode();
JSONObject nodeJson = new JSONObject();
nodeJson.put(NodeAttributes.Keys.ID.toJSON(), node.getNodeIDString());
nodeJson.put(NodeAttributes.Keys.TYPE.toJSON(), node.getType());
json.put(PacketInAttributes.Keys.NODE.toJSON(), nodeJson);
// Add inport
json.put(PacketInAttributes.Keys.INGRESS_PORT.toJSON(), ingressConnector.getNodeConnectorIDString());
// Add raw packet data
// Use DataPacketService to decode the packet.
Packet pkt = dataPacketService.decodeDataPacket(rawPkt);
while (pkt != null) {
if (pkt instanceof Ethernet) {
Ethernet ethernet = (Ethernet) pkt;
ethernetToJSON(ethernet, json);
} else if(pkt instanceof IEEE8021Q) {
IEEE8021Q ieee802q = (IEEE8021Q) pkt;
ieee8021qToJSON(ieee802q, json);
} else if (pkt instanceof IPv4) {
IPv4 ipv4 = (IPv4) pkt;
ipv4ToJSON(ipv4, json);
} else if (pkt instanceof TCP) {
TCP tcp = (TCP) pkt;
tcpToJSON(tcp, json);
} else if (pkt instanceof UDP) {
UDP udp = (UDP) pkt;
udpToJSON(udp, json);
}
pkt = pkt.getPayload();
}
json.put(PacketInAttributes.Keys.PACKET.toJSON(), DatatypeConverter.printBase64Binary(rawPkt.getPacketData()));
return json;
}