本文整理汇总了Java中org.openflow.util.U16类的典型用法代码示例。如果您正苦于以下问题:Java U16类的具体用法?Java U16怎么用?Java U16使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
U16类属于org.openflow.util包,在下文中一共展示了U16类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setType
import org.openflow.util.U16; //导入依赖的package包/类
/**
* @param type the type to set
*/
public void setType(OFQueuePropType type) {
this.type = type;
switch (type) {
case OFPQT_NONE:
this.length = U16.t(NONE_MINIMUM_LENGTH);
break;
case OFPQT_MIN_RATE:
this.length = U16.t(RATE_MINIMUM_LENGTH);
break;
case OFPQT_MAX_RATE:
this.length = U16.t(RATE_MINIMUM_LENGTH);
break;
}
}
示例2: clearFlowMods
import org.openflow.util.U16; //导入依赖的package包/类
/**
* @param sw
* The switch we wish to remove flows from
* @param outPort
* The specific Output Action OutPort of specific flows we wish
* to delete
*/
public void clearFlowMods(IOFSwitch sw, Short outPort) {
// Delete all pre-existing flows with the same output action port or
// outPort
OFMatch match = new OFMatch().setWildcards(OFMatch.OFPFW_ALL);
OFMessage fm = ((OFFlowMod) floodlightProvider.getOFMessageFactory()
.getMessage(OFType.FLOW_MOD)).setMatch(match)
.setCommand(OFFlowMod.OFPFC_DELETE)
.setOutPort(outPort)
.setLength(U16.t(OFFlowMod.MINIMUM_LENGTH));
try {
List<OFMessage> msglist = new ArrayList<OFMessage>(1);
msglist.add(fm);
sw.write(msglist, cntx);
} catch (Exception e) {
log.error("Failed to clear flows on switch {} - {}", this, e);
}
}
示例3: clearAllFlowMods
import org.openflow.util.U16; //导入依赖的package包/类
@LogMessageDoc(level="INFO",
message="Switch {switch} flow cleared",
explanation="The switch flow table has been cleared, " +
"this normally happens on switch connection")
@Override
public void clearAllFlowMods() {
if (channel == null || !isConnected())
return;
// Delete all pre-existing flows
log.info("Clearing all flows on switch {}", this);
OFMatch match = new OFMatch().setWildcards(OFMatch.OFPFW_ALL);
OFMessage fm = ((OFFlowMod) floodlightProvider.getOFMessageFactory()
.getMessage(OFType.FLOW_MOD))
.setMatch(match)
.setCommand(OFFlowMod.OFPFC_DELETE)
.setOutPort(OFPort.OFPP_NONE)
.setLength(U16.t(OFFlowMod.MINIMUM_LENGTH));
fm.setXid(getNextTransactionId());
OFMessage barrierMsg = floodlightProvider.getOFMessageFactory().getMessage(
OFType.BARRIER_REQUEST);
barrierMsg.setXid(getNextTransactionId());
List<OFMessage> msglist = new ArrayList<OFMessage>(2);
msglist.add(fm);
msglist.add(barrierMsg);
channel.write(msglist);
}
示例4: testCreateAndParse
import org.openflow.util.U16; //导入依赖的package包/类
public void testCreateAndParse() throws MessageParseException {
BasicFactory factory = BasicFactory.getInstance();
OFMessage m = factory.getMessage(OFType.HELLO);
m.setVersion((byte) 1);
m.setType(OFType.ECHO_REQUEST);
m.setLength(U16.t(8));
m.setXid(0xdeadbeef);
ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
ChannelBuffer bb2 = ChannelBuffers.dynamicBuffer();
m.writeTo(bb);
bb2.writeBytes(bb, bb.readableBytes()-1);
TestCase.assertNull(factory.parseMessage(bb2));
bb2.writeByte(bb.readByte());
List<OFMessage> message = factory.parseMessage(bb2);
TestCase.assertNotNull(message);
TestCase.assertEquals(message.size(), 1);
TestCase.assertTrue(message.get(0).getType() == OFType.ECHO_REQUEST);
}
示例5: testCurrouptedMsgParse
import org.openflow.util.U16; //导入依赖的package包/类
public void testCurrouptedMsgParse() throws MessageParseException {
BasicFactory factory = BasicFactory.getInstance();
OFMessage m = factory.getMessage(OFType.HELLO);
m.setVersion((byte) 1);
m.setType(OFType.ERROR);
m.setLength(U16.t(8));
m.setXid(0xdeadbeef);
ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
m.writeTo(bb);
try {
factory.parseMessage(bb);
}
catch(Exception e) {
TestCase.assertEquals(MessageParseException.class, e.getClass());
}
}
示例6: clearAllFlowMods
import org.openflow.util.U16; //导入依赖的package包/类
@Override
@LogMessageDoc(level="ERROR",
message="Failed to clear all flows on switch {switch}",
explanation="An I/O error occured while trying to clear " +
"flows on the switch.",
recommendation=LogMessageDoc.CHECK_SWITCH)
public void clearAllFlowMods() {
// Delete all pre-existing flows
OFMatch match = new OFMatch().setWildcards(OFMatch.OFPFW_ALL);
OFMessage fm = ((OFFlowMod) floodlightProvider.getOFMessageFactory()
.getMessage(OFType.FLOW_MOD))
.setMatch(match)
.setCommand(OFFlowMod.OFPFC_DELETE)
.setOutPort(OFPort.OFPP_NONE)
.setLength(U16.t(OFFlowMod.MINIMUM_LENGTH));
try {
List<OFMessage> msglist = new ArrayList<OFMessage>(1);
msglist.add(fm);
channel.write(msglist);
} catch (Exception e) {
log.error("Failed to clear all flows on switch " + this, e);
}
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:24,代码来源:OFSwitchImpl.java
示例7: testCreateAndParse
import org.openflow.util.U16; //导入依赖的package包/类
public void testCreateAndParse() throws MessageParseException {
BasicFactory factory = new BasicFactory();
OFMessage m = factory.getMessage(OFType.HELLO);
m.setVersion((byte) 1);
m.setType(OFType.ECHO_REQUEST);
m.setLength(U16.t(8));
m.setXid(0xdeadbeef);
ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
ChannelBuffer bb2 = ChannelBuffers.dynamicBuffer();
m.writeTo(bb);
bb2.writeBytes(bb, bb.readableBytes()-1);
TestCase.assertNull(factory.parseMessage(bb2));
bb2.writeByte(bb.readByte());
List<OFMessage> message = factory.parseMessage(bb2);
TestCase.assertNotNull(message);
TestCase.assertEquals(message.size(), 1);
TestCase.assertTrue(message.get(0).getType() == OFType.ECHO_REQUEST);
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:19,代码来源:BasicFactoryTest.java
示例8: testCurrouptedMsgParse
import org.openflow.util.U16; //导入依赖的package包/类
public void testCurrouptedMsgParse() throws MessageParseException {
BasicFactory factory = new BasicFactory();
OFMessage m = factory.getMessage(OFType.HELLO);
m.setVersion((byte) 1);
m.setType(OFType.ERROR);
m.setLength(U16.t(8));
m.setXid(0xdeadbeef);
ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
m.writeTo(bb);
try {
factory.parseMessage(bb);
}
catch(Exception e) {
TestCase.assertEquals(MessageParseException.class, e.getClass());
}
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:17,代码来源:BasicFactoryTest.java
示例9: setProperties
import org.openflow.util.U16; //导入依赖的package包/类
/**
* @param properties the properties to set
*/
public void setProperties(List<OFQueueProp> properties) {
this.properties = properties;
this.length = U16.t(MINIMUM_LENGTH);
for (OFQueueProp prop : properties) {
this.length += prop.getLength();
}
}
示例10: toStringUnmasked
import org.openflow.util.U16; //导入依赖的package包/类
/**
* Return a string including all match fields, regardless whether they
* are wildcarded or not.
*/
public String toStringUnmasked() {
String str = "";
// l1
str += STR_IN_PORT + "=" + U16.f(this.inputPort);
// l2
str += "," + STR_DL_DST + "="
+ HexString.toHexString(this.dataLayerDestination);
str += "," + STR_DL_SRC + "="
+ HexString.toHexString(this.dataLayerSource);
str += "," + STR_DL_TYPE + "=0x"
+ Integer.toHexString(U16.f(this.dataLayerType));
str += "," + STR_DL_VLAN + "=0x"
+ Integer.toHexString(U16.f(this.dataLayerVirtualLan));
str += "," + STR_DL_VLAN_PCP + "="
+ Integer.toHexString(U8.f(this.dataLayerVirtualLanPriorityCodePoint));
// l3
str += "," + STR_NW_DST + "="
+ cidrToString(networkDestination,
getNetworkDestinationMaskLen());
str += "," + STR_NW_SRC + "="
+ cidrToString(networkSource,
getNetworkSourceMaskLen());
str += "," + STR_NW_PROTO + "=" + this.networkProtocol;
str += "," + STR_NW_TOS + "=" + this.getNetworkTypeOfService();
// l4
str += "," + STR_TP_DST + "=" + this.transportDestination;
str += "," + STR_TP_SRC + "=" + this.transportSource;
// wildcards
str += ", wildcards=" + debugWildCards(wildcards);
return "OFMatch[" + str + "]";
}
示例11: receive
import org.openflow.util.U16; //导入依赖的package包/类
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
OFPacketIn pi = (OFPacketIn) msg;
OFPacketOut po = (OFPacketOut) floodlightProvider.getOFMessageFactory()
.getMessage(OFType.PACKET_OUT);
po.setBufferId(pi.getBufferId())
.setInPort(pi.getInPort());
// set actions
OFActionOutput action = new OFActionOutput()
.setPort(OFPort.OFPP_FLOOD.getValue());
po.setActions(Collections.singletonList((OFAction)action));
po.setActionsLength((short) OFActionOutput.MINIMUM_LENGTH);
// set data if is is included in the packetin
if (pi.getBufferId() == OFPacketOut.BUFFER_ID_NONE) {
byte[] packetData = pi.getPacketData();
po.setLength(U16.t(OFPacketOut.MINIMUM_LENGTH
+ po.getActionsLength() + packetData.length));
po.setPacketData(packetData);
} else {
po.setLength(U16.t(OFPacketOut.MINIMUM_LENGTH
+ po.getActionsLength()));
}
try {
sw.write(po, cntx);
} catch (IOException e) {
log.error("Failure writing PacketOut", e);
}
return Command.CONTINUE;
}
示例12: compare
import org.openflow.util.U16; //导入依赖的package包/类
@Override
public int compare(String o1, String o2) {
OFFlowMod f1 = entriesFromStorage.get(dpid).get(o1);
OFFlowMod f2 = entriesFromStorage.get(dpid).get(o2);
if (f1 == null || f2 == null) // sort active=false flows by key
return o1.compareTo(o2);
return U16.f(f1.getPriority()) - U16.f(f2.getPriority());
}
示例13: testInvalidMsgParse
import org.openflow.util.U16; //导入依赖的package包/类
public void testInvalidMsgParse() throws MessageParseException {
BasicFactory factory = BasicFactory.getInstance();
OFMessage m = factory.getMessage(OFType.HELLO);
m.setVersion((byte) 1);
m.setType(OFType.ECHO_REQUEST);
m.setLength(U16.t(16));
m.setXid(0xdeadbeef);
ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
m.writeTo(bb);
List<OFMessage> message = factory.parseMessage(bb);
TestCase.assertNull(message);
}
示例14: receive
import org.openflow.util.U16; //导入依赖的package包/类
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
OFPacketIn pi = (OFPacketIn) msg;
OFPacketOut po = (OFPacketOut) floodlightProvider.getOFMessageFactory()
.getMessage(OFType.PACKET_OUT);
po.setBufferId(pi.getBufferId())
.setInPort(pi.getInPort());
// set actions
OFActionOutput action = new OFActionOutput()
.setPort((short) OFPort.OFPP_FLOOD.getValue());
po.setActions(Collections.singletonList((OFAction)action));
po.setActionsLength((short) OFActionOutput.MINIMUM_LENGTH);
// set data if is is included in the packetin
if (pi.getBufferId() == 0xffffffff) {
byte[] packetData = pi.getPacketData();
po.setLength(U16.t(OFPacketOut.MINIMUM_LENGTH
+ po.getActionsLength() + packetData.length));
po.setPacketData(packetData);
} else {
po.setLength(U16.t(OFPacketOut.MINIMUM_LENGTH
+ po.getActionsLength()));
}
try {
sw.write(po, cntx);
} catch (IOException e) {
log.error("Failure writing PacketOut", e);
}
return Command.CONTINUE;
}
示例15: updatePortInfo
import org.openflow.util.U16; //导入依赖的package包/类
protected void updatePortInfo(IOFSwitch sw, OFPhysicalPort port) {
if (role == Role.SLAVE) {
return;
}
String datapathIdString = sw.getStringId();
Map<String, Object> portInfo = new HashMap<String, Object>();
int portNumber = U16.f(port.getPortNumber());
String id = datapathIdString + "|" + portNumber;
portInfo.put(PORT_ID, id);
portInfo.put(PORT_SWITCH, datapathIdString);
portInfo.put(PORT_NUMBER, portNumber);
byte[] hardwareAddress = port.getHardwareAddress();
String hardwareAddressString = HexString.toHexString(hardwareAddress);
portInfo.put(PORT_HARDWARE_ADDRESS, hardwareAddressString);
String name = port.getName();
portInfo.put(PORT_NAME, name);
long config = U32.f(port.getConfig());
portInfo.put(PORT_CONFIG, config);
long state = U32.f(port.getState());
portInfo.put(PORT_STATE, state);
long currentFeatures = U32.f(port.getCurrentFeatures());
portInfo.put(PORT_CURRENT_FEATURES, currentFeatures);
long advertisedFeatures = U32.f(port.getAdvertisedFeatures());
portInfo.put(PORT_ADVERTISED_FEATURES, advertisedFeatures);
long supportedFeatures = U32.f(port.getSupportedFeatures());
portInfo.put(PORT_SUPPORTED_FEATURES, supportedFeatures);
long peerFeatures = U32.f(port.getPeerFeatures());
portInfo.put(PORT_PEER_FEATURES, peerFeatures);
storageSource.updateRowAsync(PORT_TABLE_NAME, portInfo);
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:31,代码来源:Controller.java