本文整理汇总了Java中org.projectfloodlight.openflow.types.TableId类的典型用法代码示例。如果您正苦于以下问题:Java TableId类的具体用法?Java TableId怎么用?Java TableId使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TableId类属于org.projectfloodlight.openflow.types包,在下文中一共展示了TableId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTableType
import org.projectfloodlight.openflow.types.TableId; //导入依赖的package包/类
@Override
public TableType getTableType(TableId tid) {
switch (tid.getValue()) {
case DELL_TABLE_IPV4_UNICAST:
return TableType.IP;
case DELL_TABLE_MPLS:
return TableType.MPLS;
case DELL_TABLE_ACL:
return TableType.ACL;
case DELL_TABLE_VLAN:
return TableType.VLAN;
case DELL_TABLE_TMAC:
return TableType.ETHER;
default:
log.error("Table type for Table id {} is not supported in the driver", tid);
return TableType.NONE;
}
}
示例2: sendFlowStatistic
import org.projectfloodlight.openflow.types.TableId; //导入依赖的package包/类
private void sendFlowStatistic() {
if (sw.getRole() != RoleState.MASTER) {
return;
}
Match match = sw.factory().buildMatch().build();
//Long statsXid = xidAtomic.getAndIncrement();
OFFlowStatsRequest statsRequest = sw.factory()
.buildFlowStatsRequest()
.setXid(1127)
.setMatch(match)
.setOutPort(OFPort.ANY)
.setTableId(TableId.ALL)
.build();
sw.sendMsg(statsRequest);
}
示例3: buildFlowDel
import org.projectfloodlight.openflow.types.TableId; //导入依赖的package包/类
@Override
public OFFlowMod buildFlowDel() {
Match match = buildMatch();
long cookie = flowRule().id().value();
OFFlowDeleteStrict fm = factory().buildFlowDeleteStrict()
.setXid(xid)
.setCookie(U64.of(cookie))
.setBufferId(OFBufferId.NO_BUFFER)
.setMatch(match)
.setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM))
.setPriority(flowRule().priority())
.setTableId(TableId.of(flowRule().tableId()))
.build();
return fm;
}
示例4: ofFlowStatsRequestAllSend
import org.projectfloodlight.openflow.types.TableId; //导入依赖的package包/类
private void ofFlowStatsRequestAllSend() {
OFFlowStatsRequest request = sw.factory().buildFlowStatsRequest()
.setMatch(sw.factory().matchWildcardAll())
.setTableId(TableId.ALL)
.setOutPort(OFPort.NO_MASK)
.build();
synchronized (this) {
// set the request xid to check the reply in OpenFlowRuleProvider
// After processing the reply of this request message,
// this must be set to NO_FLOW_MISSING_XID(-1) by provider
setFlowMissingXid(request.getXid());
log.debug("ofFlowStatsRequestAllSend: request={}, dpid={}",
request.toString(), sw.getStringId());
sw.sendMsg(request);
}
}
示例5: gotoTableFromString
import org.projectfloodlight.openflow.types.TableId; //导入依赖的package包/类
/**
* Convert the string representation of an OFInstructionGotoTable to
* an OFInstructionGotoTable. The instruction will be set within the
* OFFlowMod.Builder provided. Notice nothing is returned, but the
* side effect is the addition of an instruction in the OFFlowMod.Builder.
* @param fmb; The FMB in which to append the new instruction
* @param instStr; The string to parse the instruction from
* @param log
*/
public static void gotoTableFromString(OFFlowMod.Builder fmb, String inst, Logger log) {
if (inst == null || inst.equals("")) {
return;
}
if (fmb.getVersion().compareTo(OFVersion.OF_11) < 0) {
log.error("Goto Table Instruction not supported in OpenFlow 1.0");
return;
}
OFInstructionGotoTable.Builder ib = OFFactories.getFactory(fmb.getVersion()).instructions().buildGotoTable();
// Get the table ID
if (inst.startsWith("0x")) {
ib.setTableId(TableId.of(Integer.parseInt(inst.replaceFirst("0x", ""), 16)));
} else {
ib.setTableId(TableId.of(Integer.parseInt(inst))).build();
}
log.debug("Appending GotoTable instruction: {}", ib.build());
appendInstruction(fmb, ib.build());
log.debug("All instructions after append: {}", fmb.getInstructions());
}
示例6: createTableFeaturesStatsReply
import org.projectfloodlight.openflow.types.TableId; //导入依赖的package包/类
protected OFTableFeaturesStatsReply createTableFeaturesStatsReply() {
OFTableFeaturesStatsReply statsReply = factory.buildTableFeaturesStatsReply()
.setEntries(Collections.singletonList(factory.buildTableFeatures()
.setConfig(0)
.setMaxEntries(100)
.setMetadataMatch(U64.NO_MASK)
.setMetadataWrite(U64.NO_MASK)
.setName("MyTable")
.setTableId(TableId.of(1))
.setProperties(Collections.singletonList((OFTableFeatureProp)factory.buildTableFeaturePropMatch()
.setOxmIds(Collections.singletonList(U32.of(100)))
.build())
).build()
)
).build();
return statsReply;
}
示例7: gotoTableFromString
import org.projectfloodlight.openflow.types.TableId; //导入依赖的package包/类
/**
* Convert the string representation of an OFInstructionGotoTable to
* an OFInstructionGotoTable. The instruction will be set within the
* OFFlowMod.Builder provided. Notice nothing is returned, but the
* side effect is the addition of an instruction in the OFFlowMod.Builder.
* @param fmb; The FMB in which to append the new instruction
* @param instStr; The string to parse the instruction from
* @param log
*/
public static void gotoTableFromString(OFFlowMod.Builder fmb, String inst, Logger log) {
if (inst == null || inst.equals("")) {
return;
}
if (fmb.getVersion().compareTo(OFVersion.OF_11) < 0) {
log.error("Goto Table Instruction not supported in OpenFlow 1.0");
return;
}
OFInstructionGotoTable.Builder ib = OFFactories.getFactory(fmb.getVersion()).instructions().buildGotoTable();
// Get the table ID
if (inst.startsWith("0x")) {
ib.setTableId(TableId.of(Integer.parseInt(inst.replaceFirst("0x", ""), 16)));
} else {
ib.setTableId(TableId.of(Integer.parseInt(inst))).build();
}
log.debug("Appending GotoTable instruction: {}", ib.build());
appendInstruction(fmb, ib.build());
log.debug("All instructions after append: {}", fmb.getInstructions());
}
示例8: dumpFlowTable
import org.projectfloodlight.openflow.types.TableId; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public OFFlowStatsReply dumpFlowTable(final DatapathId dpid) {
OFFlowStatsReply values = null;
IOFSwitch sw = ofSwitchService.getSwitch(dpid);
if (sw == null) {
throw new IllegalArgumentException(String.format("Switch %s was not found", dpid.toString()));
}
OFFactory ofFactory = sw.getOFFactory();
OFFlowStatsRequest flowRequest = ofFactory.buildFlowStatsRequest()
.setMatch(sw.getOFFactory().matchWildcardAll())
.setTableId(TableId.ALL)
.setOutPort(OFPort.ANY)
.setOutGroup(OFGroup.ANY)
.setCookieMask(U64.ZERO)
.build();
try {
ListenableFuture<OFFlowStatsReply> future = sw.writeRequest(flowRequest);
values = future.get(10, TimeUnit.SECONDS);
} catch (ExecutionException | InterruptedException | TimeoutException e) {
logger.error("Could not get flow stats: {}", e.getMessage());
}
return values;
}
示例9: startDriverHandshake
import org.projectfloodlight.openflow.types.TableId; //导入依赖的package包/类
@Override
public void startDriverHandshake() {
if (startDriverHandshakeCalled) {
throw new SwitchDriverSubHandshakeAlreadyStarted();
}
startDriverHandshakeCalled = true;
OFFlowMod fm = factory().buildFlowDelete()
.setTableId(TableId.ALL)
.setOutGroup(OFGroup.ANY)
.build();
sendMsg(Collections.singletonList(fm));
OFGroupMod gm = factory().buildGroupDelete()
.setGroup(OFGroup.ALL)
.setGroupType(OFGroupType.ALL)
.build();
sendMsg(Collections.singletonList(gm));
OFMeterMod mm = factory().buildMeterMod()
.setMeterId(MeterId.ALL.id())
.build();
sendMsg(Collections.singletonList(mm));
barrierXid = getNextTransactionId();
OFBarrierRequest barrier = factory().buildBarrierRequest()
.setXid(barrierXid).build();
sendHandshakeMessage(barrier);
}
示例10: sendMsg
import org.projectfloodlight.openflow.types.TableId; //导入依赖的package包/类
@Override
public final void sendMsg(OFMessage m) {
OFMessage newMsg = m;
if (m.getType() == OFType.STATS_REQUEST) {
OFStatsRequest sr = (OFStatsRequest) m;
log.debug("Rebuilding stats request type {}", sr.getStatsType());
switch (sr.getStatsType()) {
case FLOW:
OFCalientFlowStatsRequest request = this.factory().buildCalientFlowStatsRequest()
.setCookie(((OFFlowStatsRequest) sr).getCookie())
.setCookieMask(((OFFlowStatsRequest) sr).getCookieMask())
.setMatch(this.factory().matchWildcardAll())
.setOutGroup(((OFFlowStatsRequest) sr).getOutGroup().getGroupNumber())
.setOutPort(OFPort.ANY)
.setTableId(TableId.ALL)
.setXid(sr.getXid())
.setFlags(sr.getFlags())
.build();
newMsg = request;
break;
case PORT:
// TODO
break;
default:
break;
}
}
super.sendMsg(newMsg);
}
示例11: sendAggregateStatistic
import org.projectfloodlight.openflow.types.TableId; //导入依赖的package包/类
private void sendAggregateStatistic() {
if (sw.getRole() != RoleState.MASTER) {
return;
}
Match match = sw.factory().buildMatch().build();
//Long statsXid = xidAtomic.getAndIncrement();
OFAggregateStatsRequest statsRequest = sw.factory().buildAggregateStatsRequest()
.setMatch(match)
.setOutPort(OFPort.ANY)
.setTableId(TableId.ALL)
.setXid(1126)
.build();
sw.sendMsg(statsRequest);
}
示例12: run
import org.projectfloodlight.openflow.types.TableId; //导入依赖的package包/类
@Override
public void run() {
if (sw.getRole() == RoleState.MASTER) {
log.trace("Collecting stats for {}", sw.getStringId());
OFFlowStatsRequest request = sw.factory().buildFlowStatsRequest()
.setMatch(sw.factory().matchWildcardAll())
.setTableId(TableId.ALL)
.setOutPort(OFPort.NO_MASK)
.build();
sw.sendMsg(request);
}
}
示例13: ofFlowStatsRequestFlowSend
import org.projectfloodlight.openflow.types.TableId; //导入依赖的package包/类
private void ofFlowStatsRequestFlowSend(FlowEntry fe) {
// set find match
Match match = FlowModBuilder.builder(fe, sw.factory(), Optional.empty(),
Optional.of(driverService)).buildMatch();
// set find tableId
TableId tableId = TableId.of(fe.tableId());
// set output port
Instruction ins = fe.treatment().allInstructions().stream()
.filter(i -> (i.type() == Instruction.Type.OUTPUT))
.findFirst()
.orElse(null);
OFPort ofPort = OFPort.NO_MASK;
if (ins != null) {
Instructions.OutputInstruction out = (Instructions.OutputInstruction) ins;
ofPort = OFPort.of((int) ((out.port().toLong())));
}
OFFlowStatsRequest request = sw.factory().buildFlowStatsRequest()
.setMatch(match)
.setTableId(tableId)
.setOutPort(ofPort)
.build();
synchronized (this) {
if (getFlowMissingXid() != NO_FLOW_MISSING_XID) {
log.debug("ofFlowStatsRequestFlowSend: previous FlowStatsRequestAll does not be processed yet,"
+ " set no flow missing xid anyway, for {}",
sw.getStringId());
setFlowMissingXid(NO_FLOW_MISSING_XID);
}
sw.sendMsg(request);
}
}
示例14: switchActivated
import org.projectfloodlight.openflow.types.TableId; //导入依赖的package包/类
@Override
public void switchActivated(DatapathId switchId) {
IOFSwitch sw = switchService.getSwitch(switchId);
if (sw == null) {
log.warn("Switch {} was activated but had no switch object in the switch service. Perhaps it quickly disconnected", switchId);
return;
}
if (OFDPAUtils.isOFDPASwitch(sw)) {
sw.write(sw.getOFFactory().buildFlowDelete()
.setTableId(TableId.ALL)
.build()
);
sw.write(sw.getOFFactory().buildGroupDelete()
.setGroup(OFGroup.ANY)
.setGroupType(OFGroupType.ALL)
.build()
);
sw.write(sw.getOFFactory().buildGroupDelete()
.setGroup(OFGroup.ANY)
.setGroupType(OFGroupType.INDIRECT)
.build()
);
sw.write(sw.getOFFactory().buildBarrierRequest().build());
List<OFPortModeTuple> portModes = new ArrayList<OFPortModeTuple>();
for (OFPortDesc p : sw.getPorts()) {
portModes.add(OFPortModeTuple.of(p.getPortNo(), OFPortMode.ACCESS));
}
if (log.isWarnEnabled()) {
log.warn("For OF-DPA switch {}, initializing VLAN {} on ports {}", new Object[] { switchId, VlanVid.ZERO, portModes});
}
OFDPAUtils.addLearningSwitchPrereqs(sw, VlanVid.ZERO, portModes);
}
}
示例15: getFlows
import org.projectfloodlight.openflow.types.TableId; //导入依赖的package包/类
/**
* @param sw
* the switch object that we wish to get flows from
* @param outPort
* the output action port we wish to find flows with
* @return a list of OFFlowStatisticsReply objects or essentially flows
*/
public List<OFFlowStatsReply> getFlows(IOFSwitch sw, OFPort outPort) {
statsReply = new ArrayList<OFFlowStatsReply>();
List<OFFlowStatsReply> values = null;
Future<List<OFFlowStatsReply>> future;
// Statistics request object for getting flows
OFFlowStatsRequest req = sw.getOFFactory().buildFlowStatsRequest()
.setMatch(sw.getOFFactory().buildMatch().build())
.setOutPort(outPort)
.setTableId(TableId.ALL)
.build();
try {
// System.out.println(sw.getStatistics(req));
future = sw.writeStatsRequest(req);
values = future.get(10, TimeUnit.SECONDS);
if (values != null) {
for (OFFlowStatsReply stat : values) {
statsReply.add(stat);
}
}
} catch (Exception e) {
log.error("Failure retrieving statistics from switch " + sw, e);
}
return statsReply;
}