本文整理汇总了Java中org.projectfloodlight.openflow.protocol.action.OFActionOutput.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java OFActionOutput.Builder方法的具体用法?Java OFActionOutput.Builder怎么用?Java OFActionOutput.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.projectfloodlight.openflow.protocol.action.OFActionOutput
的用法示例。
在下文中一共展示了OFActionOutput.Builder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createHubPacketOut
import org.projectfloodlight.openflow.protocol.action.OFActionOutput; //导入方法依赖的package包/类
private OFMessage createHubPacketOut(IOFSwitch sw, OFMessage msg) {
OFPacketIn pi = (OFPacketIn) msg;
OFPacketOut.Builder pob = sw.getOFFactory().buildPacketOut();
pob.setBufferId(pi.getBufferId()).setXid(pi.getXid()).setInPort((pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)));
// set actions
OFActionOutput.Builder actionBuilder = sw.getOFFactory().actions().buildOutput();
actionBuilder.setPort(OFPort.FLOOD);
pob.setActions(Collections.singletonList((OFAction) actionBuilder.build()));
// set data if it is included in the packetin
if (pi.getBufferId() == OFBufferId.NO_BUFFER) {
byte[] packetData = pi.getData();
pob.setData(packetData);
}
return pob.build();
}
示例2: createHubPacketOut
import org.projectfloodlight.openflow.protocol.action.OFActionOutput; //导入方法依赖的package包/类
private OFMessage createHubPacketOut(IOFSwitch sw, OFMessage msg) {
OFPacketIn pi = (OFPacketIn) msg;
OFPacketOut.Builder pob = sw.getOFFactory().buildPacketOut();
pob.setBufferId(pi.getBufferId()).setXid(pi.getXid()).setInPort((pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)));
// set actions
OFActionOutput.Builder actionBuilder = sw.getOFFactory().actions().buildOutput();
actionBuilder.setPort(OFPort.FLOOD);
pob.setActions(Collections.singletonList((OFAction) actionBuilder.build()));
// set data if it is included in the packetin
if (pi.getBufferId() == OFBufferId.NO_BUFFER) {
byte[] packetData = pi.getData();
pob.setData(packetData);
}
return pob.build();
}
示例3: createBDDPPacketOut
import org.projectfloodlight.openflow.protocol.action.OFActionOutput; //导入方法依赖的package包/类
/**
* Creates packet_out BDDP for specified output port.
*
* @param port the port
* @return Packet_out message with LLDP data
*/
private OFPacketOut createBDDPPacketOut(final OFPortDesc port) {
if (port == null) {
return null;
}
OFPacketOut.Builder packetOut = sw.factory().buildPacketOut();
packetOut.setBufferId(OFBufferId.NO_BUFFER);
OFActionOutput.Builder act = sw.factory().actions().buildOutput()
.setPort(port.getPortNo());
OFAction out = act.build();
packetOut.setActions(Collections.singletonList(out));
this.lldpPacket.setPort(port.getPortNo().getPortNumber());
this.bddpEth.setSourceMACAddress(port.getHwAddr().getBytes());
final byte[] bddp = this.bddpEth.serialize();
packetOut.setData(bddp);
return packetOut.build();
}
示例4: createHubPacketOut
import org.projectfloodlight.openflow.protocol.action.OFActionOutput; //导入方法依赖的package包/类
private OFMessage createHubPacketOut(IOFSwitch sw, OFMessage msg) {
OFPacketIn pi = (OFPacketIn) msg;
OFPacketOut.Builder pob = sw.getOFFactory().buildPacketOut();
pob.setBufferId(pi.getBufferId()).setXid(pi.getXid()).setInPort((pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)));
// set actions
OFActionOutput.Builder actionBuilder = sw.getOFFactory().actions().buildOutput();
actionBuilder.setPort(OFPort.FLOOD);
pob.setActions(Collections.singletonList((OFAction) actionBuilder.build()));
// set data if it is included in the packetin
if (pi.getBufferId() == OFBufferId.NO_BUFFER) {
byte[] packetData = pi.getData();
pob.setData(packetData);
}
return pob.build();
}
示例5: createHubFlowMod
import org.projectfloodlight.openflow.protocol.action.OFActionOutput; //导入方法依赖的package包/类
private OFMessage createHubFlowMod(IOFSwitch sw, OFMessage msg) {
OFPacketIn pi = (OFPacketIn) msg;
OFFlowAdd.Builder fmb = sw.getOFFactory().buildFlowAdd();
fmb.setBufferId(pi.getBufferId())
.setXid(pi.getXid());
// set actions
OFActionOutput.Builder actionBuilder = sw.getOFFactory().actions().buildOutput();
actionBuilder.setPort(OFPort.FLOOD);
fmb.setActions(Collections.singletonList((OFAction) actionBuilder.build()));
return fmb.build();
}
示例6: decode_output
import org.projectfloodlight.openflow.protocol.action.OFActionOutput; //导入方法依赖的package包/类
/**
* Parse string and numerical port representations.
* The key and delimiter for the action should be omitted, and only the
* data should be presented to this decoder. Data can be any signed integer
* as a string or the strings 'controller', 'local', 'ingress-port', 'normal',
* or 'flood'.
* @param actionToDecode; The action as a string to decode
* @param version; The OF version to create the action for
* @param log
* @return
*/
private static OFActionOutput decode_output(String actionToDecode, OFVersion version, Logger log) {
Matcher n = Pattern.compile("((all)|(controller)|(local)|(ingress-port)|(normal)|(flood))").matcher(actionToDecode);
OFActionOutput.Builder ab = OFFactories.getFactory(version).actions().buildOutput();
OFPort port = OFPort.ANY;
if (n.matches()) {
if (n.group(1) != null && n.group(1).equals("all"))
port = OFPort.ALL;
else if (n.group(1) != null && n.group(1).equals("controller"))
port = OFPort.CONTROLLER;
else if (n.group(1) != null && n.group(1).equals("local"))
port = OFPort.LOCAL;
else if (n.group(1) != null && n.group(1).equals("ingress-port"))
port = OFPort.IN_PORT;
else if (n.group(1) != null && n.group(1).equals("normal"))
port = OFPort.NORMAL;
else if (n.group(1) != null && n.group(1).equals("flood"))
port = OFPort.FLOOD;
ab.setPort(port);
ab.setMaxLen(Integer.MAX_VALUE);
log.debug("action {}", ab.build());
return ab.build();
}
else {
try {
port = OFPort.of(Integer.parseInt(actionToDecode));
ab.setPort(port);
ab.setMaxLen(Integer.MAX_VALUE);
return ab.build();
} catch (NumberFormatException e) {
log.error("Could not parse Integer port: '{}'", actionToDecode);
return null;
}
}
}
示例7: switchAdded
import org.projectfloodlight.openflow.protocol.action.OFActionOutput; //导入方法依赖的package包/类
@Override
public void switchAdded(DatapathId dpid) {
/* Insert static flows on all ports of the switch to redirect
* DHCP client --> DHCP DHCPServer traffic to the controller.
* DHCP client's operate on UDP port 67
*/
IOFSwitch sw = switchService.getSwitch(dpid);
//fix concurrency flaw
if (sw == null){
return;
}
OFFlowAdd.Builder flow = sw.getOFFactory().buildFlowAdd();
Match.Builder match = sw.getOFFactory().buildMatch();
ArrayList<OFAction> actionList = new ArrayList<OFAction>();
OFActionOutput.Builder action = sw.getOFFactory().actions().buildOutput();
for (OFPortDesc port : sw.getPorts()) {
match.setExact(MatchField.IN_PORT, port.getPortNo());
match.setExact(MatchField.ETH_TYPE, EthType.IPv4);
match.setExact(MatchField.IP_PROTO, IpProtocol.UDP);
match.setExact(MatchField.UDP_SRC, UDP.DHCP_CLIENT_PORT);
action.setMaxLen(0xffFFffFF);
action.setPort(OFPort.CONTROLLER);
actionList.add(action.build());
flow.setBufferId(OFBufferId.NO_BUFFER);
flow.setHardTimeout(0);
flow.setIdleTimeout(0);
flow.setOutPort(OFPort.CONTROLLER);
flow.setActions(actionList);
flow.setMatch(match.build());
flow.setPriority(32767);
sfp.addFlow("dhcp-port---" + port.getPortNo().getPortNumber() + "---(" + port.getName() + ")", flow.build(), sw.getId());
}
}
示例8: decode_output
import org.projectfloodlight.openflow.protocol.action.OFActionOutput; //导入方法依赖的package包/类
/**
* Parse string and numerical port representations.
* The key and delimiter for the action should be omitted, and only the
* data should be presented to this decoder. Data can be any signed integer
* as a string or the strings 'controller', 'local', 'ingress-port', 'normal',
* or 'flood'.
* @param actionToDecode; The action as a string to decode
* @param version; The OF version to create the action for
* @param log
* @return
*/
@LogMessageDoc(level="ERROR",
message="Invalid subaction: '{subaction}'",
explanation="A static flow entry contained an invalid subaction",
recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG)
private static OFActionOutput decode_output(String actionToDecode, OFVersion version, Logger log) {
Matcher n = Pattern.compile("((all)|(controller)|(local)|(ingress-port)|(normal)|(flood))").matcher(actionToDecode);
OFActionOutput.Builder ab = OFFactories.getFactory(version).actions().buildOutput();
OFPort port = OFPort.ANY;
if (n.matches()) {
if (n.group(1) != null && n.group(1).equals("all"))
port = OFPort.ALL;
else if (n.group(1) != null && n.group(1).equals("controller"))
port = OFPort.CONTROLLER;
else if (n.group(1) != null && n.group(1).equals("local"))
port = OFPort.LOCAL;
else if (n.group(1) != null && n.group(1).equals("ingress-port"))
port = OFPort.IN_PORT;
else if (n.group(1) != null && n.group(1).equals("normal"))
port = OFPort.NORMAL;
else if (n.group(1) != null && n.group(1).equals("flood"))
port = OFPort.FLOOD;
ab.setPort(port);
ab.setMaxLen(Integer.MAX_VALUE);
log.debug("action {}", ab.build());
return ab.build();
}
else {
try {
port = OFPort.of(Integer.parseInt(actionToDecode));
ab.setPort(port);
ab.setMaxLen(Integer.MAX_VALUE);
return ab.build();
} catch (NumberFormatException e) {
log.error("Could not parse Integer port: '{}'", actionToDecode);
return null;
}
}
}
示例9: switchAdded
import org.projectfloodlight.openflow.protocol.action.OFActionOutput; //导入方法依赖的package包/类
@Override
public void switchAdded(DatapathId dpid) {
/* Insert static flows on all ports of the switch to redirect
* DHCP client --> DHCP DHCPServer traffic to the controller.
* DHCP client's operate on UDP port 67
*/
IOFSwitch sw = switchService.getSwitch(dpid);
OFFlowAdd.Builder flow = sw.getOFFactory().buildFlowAdd();
Match.Builder match = sw.getOFFactory().buildMatch();
ArrayList<OFAction> actionList = new ArrayList<OFAction>();
OFActionOutput.Builder action = sw.getOFFactory().actions().buildOutput();
for (OFPortDesc port : sw.getPorts()) {
match.setExact(MatchField.IN_PORT, port.getPortNo());
match.setExact(MatchField.ETH_TYPE, EthType.IPv4);
match.setExact(MatchField.IP_PROTO, IpProtocol.UDP);
match.setExact(MatchField.UDP_SRC, UDP.DHCP_CLIENT_PORT);
action.setMaxLen(0xffFFffFF);
action.setPort(OFPort.CONTROLLER);
actionList.add(action.build());
flow.setBufferId(OFBufferId.NO_BUFFER);
flow.setHardTimeout(0);
flow.setIdleTimeout(0);
flow.setOutPort(OFPort.CONTROLLER);
flow.setActions(actionList);
flow.setMatch(match.build());
flow.setPriority(32767);
sfp.addFlow("dhcp-port---" + port.getPortNo().getPortNumber() + "---(" + port.getName() + ")", flow.build(), sw.getId());
}
}
示例10: decode_output
import org.projectfloodlight.openflow.protocol.action.OFActionOutput; //导入方法依赖的package包/类
/**
* Parse string and numerical port representations.
* The key and delimiter for the action should be omitted, and only the
* data should be presented to this decoder. Data can be any signed integer
* as a string or the strings 'controller', 'local', 'ingress-port', 'normal',
* or 'flood'.
* @param actionToDecode; The action as a string to decode
* @param version; The OF version to create the action for
* @param log
* @return
*/
private static OFActionOutput decode_output(String actionToDecode, OFVersion version, Logger log) {
Matcher n = Pattern.compile("((all)|(controller)|(local)|(ingress-port)|(normal)|(flood))").matcher(actionToDecode);
OFActionOutput.Builder ab = OFFactories.getFactory(version).actions().buildOutput();
OFPort port = OFPort.ANY;
if (n.matches()) {
if (n.group(1) != null && n.group(1).equals("all"))
port = OFPort.ALL;
else if (n.group(1) != null && n.group(1).equals("controller"))
port = OFPort.CONTROLLER;
else if (n.group(1) != null && n.group(1).equals("local"))
port = OFPort.LOCAL;
else if (n.group(1) != null && n.group(1).equals("ingress-port"))
port = OFPort.IN_PORT;
else if (n.group(1) != null && n.group(1).equals("normal"))
port = OFPort.NORMAL;
else if (n.group(1) != null && n.group(1).equals("flood"))
port = OFPort.FLOOD;
ab.setPort(port);
ab.setMaxLen(Integer.MAX_VALUE);
log.debug("action {}", ab.build());
return ab.build();
}
else {
try {
port = OFPort.of(Integer.parseInt(actionToDecode));
ab.setPort(port);
ab.setMaxLen(Integer.MAX_VALUE);
return ab.build();
} catch (NumberFormatException e) {
log.error("Could not parse Integer port: '{}'", actionToDecode);
return null;
}
}
}
示例11: switchAdded
import org.projectfloodlight.openflow.protocol.action.OFActionOutput; //导入方法依赖的package包/类
@Override
public void switchAdded(DatapathId dpid) {
/* Insert static flows on all ports of the switch to redirect
* DHCP client --> DHCP DHCPServer traffic to the controller.
* DHCP client's operate on UDP port 67
*/
IOFSwitch sw = switchService.getSwitch(dpid);
//fix concurrency flaw
if (sw == null){
return;
}
OFFlowAdd.Builder flow = sw.getOFFactory().buildFlowAdd();
Match.Builder match = sw.getOFFactory().buildMatch();
ArrayList<OFAction> actionList = new ArrayList<OFAction>();
OFActionOutput.Builder action = sw.getOFFactory().actions().buildOutput();
for (OFPortDesc port : sw.getPorts()) {
match.setExact(MatchField.IN_PORT, port.getPortNo());
match.setExact(MatchField.ETH_TYPE, EthType.IPv4);
match.setExact(MatchField.IP_PROTO, IpProtocol.UDP);
match.setExact(MatchField.UDP_SRC, UDP.DHCP_CLIENT_PORT);
action.setMaxLen(0xffFFffFF);
action.setPort(OFPort.CONTROLLER);
actionList.add(action.build());
flow.setBufferId(OFBufferId.NO_BUFFER);
flow.setHardTimeout(0);
flow.setIdleTimeout(0);
flow.setOutPort(OFPort.CONTROLLER);
flow.setActions(actionList);
flow.setMatch(match.build());
flow.setPriority(32767);
sfp.addFlow("dhcp-port---" + port.getPortNo().getPortNumber() + "---(" + port.getName() + ")", flow.build(), sw.getId());
}
}
示例12: buildActions
import org.projectfloodlight.openflow.protocol.action.OFActionOutput; //导入方法依赖的package包/类
private List<OFAction> buildActions() {
List<OFAction> acts = new LinkedList<>();
if (treatment == null) {
return acts;
}
for (Instruction i : treatment.immediate()) {
switch (i.type()) {
case DROP:
log.warn("Saw drop action; assigning drop action");
return new LinkedList<>();
case L2MODIFICATION:
acts.add(buildL2Modification(i));
break;
case L3MODIFICATION:
acts.add(buildL3Modification(i));
break;
case OUTPUT:
OutputInstruction out = (OutputInstruction) i;
OFActionOutput.Builder action = factory().actions().buildOutput()
.setPort(OFPort.of((int) out.port().toLong()));
if (out.port().equals(PortNumber.CONTROLLER)) {
action.setMaxLen(OFPCML_NO_BUFFER);
}
acts.add(action.build());
break;
case L0MODIFICATION:
case GROUP:
log.warn("Instruction type {} not supported with protocol version {}",
i.type(), factory().getVersion());
break;
default:
log.warn("Instruction type {} not yet implemented.", i.type());
}
}
return acts;
}
示例13: buildActions
import org.projectfloodlight.openflow.protocol.action.OFActionOutput; //导入方法依赖的package包/类
private List<OFAction> buildActions(TrafficTreatment treatment) {
List<OFAction> actions = new LinkedList<>();
if (treatment == null) {
return actions;
}
for (Instruction i : treatment.allInstructions()) {
switch (i.type()) {
case DROP:
log.warn("Saw drop action; assigning drop action");
return new LinkedList<>();
case L0MODIFICATION:
actions.add(buildL0Modification(i));
break;
case L2MODIFICATION:
actions.add(buildL2Modification(i));
break;
case L3MODIFICATION:
actions.add(buildL3Modification(i));
break;
case OUTPUT:
Instructions.OutputInstruction out =
(Instructions.OutputInstruction) i;
OFActionOutput.Builder action = factory.actions().buildOutput()
.setPort(OFPort.of((int) out.port().toLong()));
if (out.port().equals(PortNumber.CONTROLLER)) {
action.setMaxLen(OFPCML_NO_BUFFER);
}
actions.add(action.build());
break;
case GROUP:
default:
log.warn("Instruction type {} not yet implemented.", i.type());
}
}
return actions;
}
示例14: buildActions
import org.projectfloodlight.openflow.protocol.action.OFActionOutput; //导入方法依赖的package包/类
private List<OFAction> buildActions(List<Instruction> treatments) {
if (treatment == null) {
return Collections.emptyList();
}
boolean tableFound = false;
List<OFAction> actions = new LinkedList<>();
for (Instruction i : treatments) {
switch (i.type()) {
case NOACTION:
return Collections.emptyList();
case L0MODIFICATION:
actions.add(buildL0Modification(i));
break;
case L1MODIFICATION:
actions.add(buildL1Modification(i));
break;
case L2MODIFICATION:
actions.add(buildL2Modification(i));
break;
case L3MODIFICATION:
actions.add(buildL3Modification(i));
break;
case L4MODIFICATION:
actions.add(buildL4Modification(i));
break;
case OUTPUT:
OutputInstruction out = (OutputInstruction) i;
OFActionOutput.Builder action = factory().actions().buildOutput()
.setPort(OFPort.of((int) out.port().toLong()));
if (out.port().equals(PortNumber.CONTROLLER)) {
action.setMaxLen(OFPCML_NO_BUFFER);
}
actions.add(action.build());
break;
case GROUP:
GroupInstruction group = (GroupInstruction) i;
OFActionGroup.Builder groupBuilder = factory().actions().buildGroup()
.setGroup(OFGroup.of(group.groupId().id()));
actions.add(groupBuilder.build());
break;
case QUEUE:
SetQueueInstruction queue = (SetQueueInstruction) i;
OFActionSetQueue.Builder queueBuilder = factory().actions().buildSetQueue()
.setQueueId(queue.queueId());
actions.add(queueBuilder.build());
break;
case TABLE:
//FIXME: should not occur here.
tableFound = true;
break;
case EXTENSION:
actions.add(buildExtensionAction(((Instructions.ExtensionInstructionWrapper) i)
.extensionInstruction()));
break;
default:
log.warn("Instruction type {} not yet implemented.", i.type());
}
}
if (tableFound && actions.isEmpty()) {
// handles the case where there are no actions, but there is
// a goto instruction for the next table
return Collections.emptyList();
}
return actions;
}
示例15: buildActions
import org.projectfloodlight.openflow.protocol.action.OFActionOutput; //导入方法依赖的package包/类
private List<OFAction> buildActions() {
List<OFAction> acts = new LinkedList<>();
OFAction act;
if (treatment == null) {
return acts;
}
for (Instruction i : treatment.immediate()) {
switch (i.type()) {
case NOACTION:
return Collections.emptyList();
case L2MODIFICATION:
act = buildL2Modification(i);
if (act != null) {
acts.add(buildL2Modification(i));
}
break;
case L3MODIFICATION:
act = buildL3Modification(i);
if (act != null) {
acts.add(buildL3Modification(i));
}
break;
case OUTPUT:
OutputInstruction out = (OutputInstruction) i;
OFActionOutput.Builder action = factory().actions().buildOutput()
.setPort(OFPort.of((int) out.port().toLong()));
if (out.port().equals(PortNumber.CONTROLLER)) {
action.setMaxLen(OFPCML_NO_BUFFER);
}
acts.add(action.build());
break;
case QUEUE:
SetQueueInstruction queue = (SetQueueInstruction) i;
if (queue.port() == null) {
log.warn("Required argument 'port' undefined for OFActionEnqueue");
}
OFActionEnqueue.Builder queueBuilder = factory().actions().buildEnqueue()
.setQueueId(queue.queueId())
.setPort(OFPort.ofInt((int) queue.port().toLong()));
acts.add(queueBuilder.build());
break;
case L0MODIFICATION:
case L1MODIFICATION:
case GROUP:
case TABLE:
case METADATA:
log.warn("Instruction type {} not supported with protocol version {}",
i.type(), factory().getVersion());
break;
default:
log.warn("Instruction type {} not yet implemented.", i.type());
}
}
return acts;
}