本文整理汇总了Java中org.projectfloodlight.openflow.protocol.OFExperimenter.getExperimenter方法的典型用法代码示例。如果您正苦于以下问题:Java OFExperimenter.getExperimenter方法的具体用法?Java OFExperimenter.getExperimenter怎么用?Java OFExperimenter.getExperimenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.projectfloodlight.openflow.protocol.OFExperimenter
的用法示例。
在下文中一共展示了OFExperimenter.getExperimenter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractNiciraRoleReply
import org.projectfloodlight.openflow.protocol.OFExperimenter; //导入方法依赖的package包/类
/**
* Extract the role from an OFVendor message.
*
* Extract the role from an OFVendor message if the message is a
* Nicira role reply. Otherwise return null.
*
* @param experimenterMsg message
* @return The role in the message if the message is a Nicira role
* reply, null otherwise.
* @throws SwitchStateException If the message is a Nicira role reply
* but the numeric role value is unknown.
*/
@Override
public RoleState extractNiciraRoleReply(OFExperimenter experimenterMsg)
throws SwitchStateException {
int vendor = (int) experimenterMsg.getExperimenter();
if (vendor != 0x2320) {
return null;
}
OFNiciraControllerRoleReply nrr =
(OFNiciraControllerRoleReply) experimenterMsg;
RoleState role = null;
OFNiciraControllerRole ncr = nrr.getRole();
switch (ncr) {
case ROLE_MASTER:
role = RoleState.MASTER;
break;
case ROLE_OTHER:
role = RoleState.EQUAL;
break;
case ROLE_SLAVE:
role = RoleState.SLAVE;
break;
default: //handled below
}
if (role == null) {
String msg = String.format("Switch: [%s], "
+ "received NX_ROLE_REPLY with invalid role "
+ "value %s",
sw.getStringId(),
nrr.getRole());
throw new SwitchStateException(msg);
}
return role;
}
示例2: extractNiciraRoleReply
import org.projectfloodlight.openflow.protocol.OFExperimenter; //导入方法依赖的package包/类
/**
* Extract the role from an OFVendor message.
*
* Extract the role from an OFVendor message if the message is a Nicira
* role reply. Otherwise return null.
*
* @param h The channel handler receiving the message
* @param vendorMessage The vendor message to parse.
* @return The role in the message if the message is a Nicira role
* reply, null otherwise.
* @throws SwitchStateException If the message is a Nicira role reply
* but the numeric role value is unknown.
*/
protected Role extractNiciraRoleReply(OFChannelHandler h,
OFExperimenter experimenterMsg) throws SwitchStateException {
int vendor = (int) experimenterMsg.getExperimenter();
if (vendor != 0x2320) // magic number representing nicira
return null;
OFNiciraControllerRoleReply nrr =
(OFNiciraControllerRoleReply) experimenterMsg;
Role role = null;
OFNiciraControllerRole ncr = nrr.getRole();
switch (ncr) {
case ROLE_MASTER:
role = Role.MASTER;
break;
case ROLE_OTHER:
role = Role.EQUAL;
break;
case ROLE_SLAVE:
role = Role.SLAVE;
break;
default: // handled below
}
if (role == null) {
String msg = String.format("Switch: [%s], State: [%s], "
+ "received NX_ROLE_REPLY with invalid role "
+ "value %d",
h.getSwitchInfoString(),
this.toString(),
nrr.getRole());
throw new SwitchStateException(msg);
}
return role;
}
示例3: handleMessage
import org.projectfloodlight.openflow.protocol.OFExperimenter; //导入方法依赖的package包/类
private void handleMessage(OFMessage msg) {
logger.debug("Message received channel handler: " + msg.getType().toString() + " switch datapathID: "
+ dummySwitch.getDatapathId());
if (msg.getType().equals(OFType.FLOW_MOD) || msg.getType().equals(OFType.PACKET_OUT)) {
dummySwitch.setHandshakeCompleted(true);
}
if (msg.getType().equals(OFType.HELLO)) {
Relay.sendToController(future,
OFFactories.getFactory(agreedVersion).buildHello().setXid(msg.getXid()).build());
} else if (msg.getType().equals(OFType.FEATURES_REQUEST)) {
Relay.sendToController(future, dummySwitch.getFeatures());
dummySwitch.setConnectionHandshake(true);
} else if (msg.getType().equals(OFType.ECHO_REQUEST)) {
Relay.sendToController(future, OFFactories.getFactory(msg.getVersion()).buildEchoReply()
.setXid(msg.getXid()).setData(((OFEchoRequest) msg).getData()).build());
} else if (msg.getType().equals(OFType.SET_CONFIG)) {
OFGetConfigRequest.Builder configReqBuilder = OFFactories.getFactory(msg.getVersion())
.buildGetConfigRequest();
configReqBuilder.setXid(msg.getXid());
Relay.sendToCore(coreConnector, configReqBuilder.build(), dummySwitch.getDatapathId(),
moduleHandler.getModuleId(-1, moduleName));
Relay.sendToCore(coreConnector, msg, dummySwitch.getDatapathId(),
moduleHandler.getModuleId(-1, moduleName));
} else if (msg.getType().equals(OFType.EXPERIMENTER)) {
OFExperimenter experimenter = (OFExperimenter) msg;
if (experimenter.getExperimenter() == 8992) {
OFNiciraControllerRoleRequest roleRequest = (OFNiciraControllerRoleRequest) experimenter;
Relay.sendToController(future, OFFactories.getFactory(msg.getVersion()).buildNiciraControllerRoleReply()
.setXid(roleRequest.getXid()).setRole(roleRequest.getRole()).build());
dummySwitch.setHandshakeCompleted(true);
}
} else if (msg.getType().equals(OFType.ROLE_REQUEST)) {
OFRoleRequest ofRoleRequest = (OFRoleRequest) msg;
Relay.sendToController(future, OFFactories.getFactory(msg.getVersion()).buildRoleReply()
.setXid(msg.getXid()).setRole(ofRoleRequest.getRole()).build());
dummySwitch.setHandshakeCompleted(true);
} else {
Relay.sendToCore(coreConnector, msg, dummySwitch.getDatapathId(),
moduleHandler.getModuleId(-1, moduleName));
}
}
示例4: verifyNiciraMessage
import org.projectfloodlight.openflow.protocol.OFExperimenter; //导入方法依赖的package包/类
/**
* Helper
* Verify that the given OFMessage is a correct Nicira RoleRequest message
*/
private void verifyNiciraMessage(OFExperimenter ofMessage) {
int vendor = (int) ofMessage.getExperimenter();
assertEquals(vendor, 0x2320);// magic number representing nicira
}