本文整理汇总了Java中org.onosproject.net.packet.PacketContext.send方法的典型用法代码示例。如果您正苦于以下问题:Java PacketContext.send方法的具体用法?Java PacketContext.send怎么用?Java PacketContext.send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onosproject.net.packet.PacketContext
的用法示例。
在下文中一共展示了PacketContext.send方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import org.onosproject.net.packet.PacketContext; //导入方法依赖的package包/类
@Override
public void process(PacketContext context) {
if (context.isHandled()) {
return;
}
InboundPacket pkt = context.inPacket();
Ethernet ethPkt = pkt.parsed();
if (ethPkt == null) {
return;
}
if (ethPkt.getEtherType() == EtherType.ARP.ethType().toShort()) {
context.treatmentBuilder().setOutput(PortNumber.FLOOD);
context.send();
}
}
示例2: packetOut
import org.onosproject.net.packet.PacketContext; //导入方法依赖的package包/类
private void packetOut(PacketContext context, PortNumber portNumber) {
context.treatmentBuilder().setOutput(portNumber);
context.send();
}
示例3: actLikeSwitch
import org.onosproject.net.packet.PacketContext; //导入方法依赖的package包/类
/**
* Ensures packet is of required type. Obtain the PortNumber associated with the inPackets DeviceId.
* If this port has previously been learned (in initMacTable method) build a flow using the packet's
* out port, treatment, destination, and other properties. Send the flow to the learned out port.
* Otherwise, flood packet to all ports if out port is not learned.
*
* @param pc the PacketContext object passed through from activate() method
*/
public void actLikeSwitch(PacketContext pc) {
/*
* Ensures the type of packet being processed is only of type IPV4 (not LLDP or BDDP). If it is not, return
* and do nothing with the packet. actLikeSwitch can only process IPV4 packets.
*/
Short type = pc.inPacket().parsed().getEtherType();
if (type != Ethernet.TYPE_IPV4) {
return;
}
/*
* Learn the destination, source, and output port of the packet using a ConnectPoint and the
* associated macTable. If there is a known port associated with the packet's destination MAC Address,
* the output port will not be null.
*/
ConnectPoint cp = pc.inPacket().receivedFrom();
Map<MacAddress, PortNumber> macTable = macTables.get(cp.deviceId());
MacAddress srcMac = pc.inPacket().parsed().getSourceMAC();
MacAddress dstMac = pc.inPacket().parsed().getDestinationMAC();
macTable.put(srcMac, cp.port());
PortNumber outPort = macTable.get(dstMac);
/*
* If port is known, set pc's out port to the packet's learned output port and construct a
* FlowRule using a source, destination, treatment and other properties. Send the FlowRule
* to the designated output port.
*/
if (outPort != null) {
pc.treatmentBuilder().setOutput(outPort);
FlowRule fr = DefaultFlowRule.builder()
.withSelector(DefaultTrafficSelector.builder().matchEthDst(dstMac).build())
.withTreatment(DefaultTrafficTreatment.builder().setOutput(outPort).build())
.forDevice(cp.deviceId()).withPriority(PacketPriority.REACTIVE.priorityValue())
.makeTemporary(60)
.fromApp(appId).build();
flowRuleService.applyFlowRules(fr);
pc.send();
} else {
/*
* else, the output port has not been learned yet. Flood the packet to all ports using
* the actLikeHub method
*/
actLikeHub(pc);
}
}
示例4: packetOut
import org.onosproject.net.packet.PacketContext; //导入方法依赖的package包/类
private void packetOut(PacketContext context, PortNumber portNumber, ReactiveForwardMetrics macMetrics) {
replyPacket(macMetrics);
context.treatmentBuilder().setOutput(portNumber);
context.send();
}
示例5: actLikeHub
import org.onosproject.net.packet.PacketContext; //导入方法依赖的package包/类
/**
* Example method. Floods packet out of all switch ports.
*
* @param pc the PacketContext object passed through from activate method
*/
public void actLikeHub(PacketContext pc) {
pc.treatmentBuilder().setOutput(PortNumber.FLOOD);
pc.send();
}
示例6: actLikeHub
import org.onosproject.net.packet.PacketContext; //导入方法依赖的package包/类
/**
* Example method. Floods packet out of all switch ports.
*
* @param pc the PacketContext object passed through from activate() method
*/
public void actLikeHub(PacketContext pc) {
pc.treatmentBuilder().setOutput(PortNumber.FLOOD);
pc.send();
}