本文整理汇总了Java中org.openflow.protocol.action.OFActionNetworkTypeOfService类的典型用法代码示例。如果您正苦于以下问题:Java OFActionNetworkTypeOfService类的具体用法?Java OFActionNetworkTypeOfService怎么用?Java OFActionNetworkTypeOfService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFActionNetworkTypeOfService类属于org.openflow.protocol.action包,在下文中一共展示了OFActionNetworkTypeOfService类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decode_set_tos_bits
import org.openflow.protocol.action.OFActionNetworkTypeOfService; //导入依赖的package包/类
private static SubActionStruct decode_set_tos_bits(String subaction, Logger log) {
SubActionStruct sa = null;
Matcher n = Pattern.compile("set-tos-bits=((?:0x)?\\d+)").matcher(subaction);
if (n.matches()) {
if (n.group(1) != null) {
try {
byte tosbits = get_byte(n.group(1));
OFActionNetworkTypeOfService action = new OFActionNetworkTypeOfService();
action.setNetworkTypeOfService(tosbits);
log.debug(" action {}", action);
sa = new SubActionStruct();
sa.action = action;
sa.len = OFActionNetworkTypeOfService.MINIMUM_LENGTH;
}
catch (NumberFormatException e) {
log.debug("Invalid dst-port in: {} (error ignored)", subaction);
return null;
}
}
}
else {
log.debug("Invalid action: '{}'", subaction);
return null;
}
return sa;
}
示例2: getAction
import org.openflow.protocol.action.OFActionNetworkTypeOfService; //导入依赖的package包/类
/**
* Returns a JSON object of the provided OF Action
* @param action to be serialized to JSON
* @return
*/
public static JSONObject getAction(OFAction action) {
JSONObject json = new JSONObject();
switch (action.getType()) {
case OUTPUT:
json.put("outport", (0x0FFFF&(((OFActionOutput)action).getPort())));
break;
case SET_DL_DST:
json.put("dstmac", ((OFActionDataLayerDestination)action).getDataLayerAddress());
break;
case SET_DL_SRC:
json.put("srcmac", ((OFActionDataLayerSource)action).getDataLayerAddress());
break;
case SET_NW_DST:
int ipDst = ((OFActionNetworkLayerDestination)action).getNetworkAddress();
json.put("dstip", IPv4.toIPv4AddressBytes(ipDst));
break;
case SET_NW_SRC:
int ipSrc = ((OFActionNetworkLayerSource)action).getNetworkAddress();
json.put("dstmac", IPv4.toIPv4AddressBytes(ipSrc));
break;
case SET_NW_TOS:
json.put("tos", ((OFActionNetworkTypeOfService)action).getNetworkTypeOfService());
case SET_TP_DST:
json.put("dstport", (0x0FFFF&((OFActionTransportLayer)action).getTransportPort()));
break;
case SET_TP_SRC:
json.put("srcport", (0x0FFFF&((OFActionTransportLayer)action).getTransportPort()));
break;
case SET_VLAN_ID:
case SET_VLAN_PCP:
case STRIP_VLAN:
case VENDOR:
case OPAQUE_ENQUEUE:
}
return json;
}
示例3: decode_set_tos_bits
import org.openflow.protocol.action.OFActionNetworkTypeOfService; //导入依赖的package包/类
private static SubActionStruct decode_set_tos_bits(String subaction, Logger log) {
SubActionStruct sa = null;
Matcher n = Pattern.compile("set-tos-bits=((?:0x)?\\d+)").matcher(subaction);
if (n.matches()) {
if (n.group(1) != null) {
try {
byte tosbits = get_byte(n.group(1));
OFActionNetworkTypeOfService action = new OFActionNetworkTypeOfService();
action.setNetworkTypeOfService(tosbits);
log.debug(" action {}", action);
sa = new SubActionStruct();
sa.action = action;
sa.len = OFActionNetworkTypeOfService.MINIMUM_LENGTH;
}
catch (NumberFormatException e) {
log.debug("Invalid dst-port in: {} (error ignored)", subaction);
return null;
}
}
}
else {
log.debug("Invalid action: '{}'", subaction);
return null;
}
return sa;
}
示例4: flowModActionsToString
import org.openflow.protocol.action.OFActionNetworkTypeOfService; //导入依赖的package包/类
/**
* Returns a String representation of all the openflow actions.
* @param fmActions A list of OFActions to encode into one string
* @return A string of the actions encoded for our database
*/
@LogMessageDoc(level="ERROR",
message="Could not decode action {action}",
explanation="A static flow entry contained an invalid action",
recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG)
private static String flowModActionsToString(List<OFAction> fmActions) {
StringBuilder sb = new StringBuilder();
for (OFAction a : fmActions) {
if (sb.length() > 0) {
sb.append(',');
}
switch(a.getType()) {
case OUTPUT:
sb.append("output=" + Short.toString(((OFActionOutput)a).getPort()));
break;
case OPAQUE_ENQUEUE:
int queue = ((OFActionEnqueue)a).getQueueId();
short port = ((OFActionEnqueue)a).getPort();
sb.append("enqueue=" + Short.toString(port) + ":0x" + String.format("%02x", queue));
break;
case STRIP_VLAN:
sb.append("strip-vlan");
break;
case SET_VLAN_ID:
sb.append("set-vlan-id=" +
Short.toString(((OFActionVirtualLanIdentifier)a).getVirtualLanIdentifier()));
break;
case SET_VLAN_PCP:
sb.append("set-vlan-priority=" +
Byte.toString(((OFActionVirtualLanPriorityCodePoint)a).getVirtualLanPriorityCodePoint()));
break;
case SET_DL_SRC:
sb.append("set-src-mac=" +
HexString.toHexString(((OFActionDataLayerSource)a).getDataLayerAddress()));
break;
case SET_DL_DST:
sb.append("set-dst-mac=" +
HexString.toHexString(((OFActionDataLayerDestination)a).getDataLayerAddress()));
break;
case SET_NW_TOS:
sb.append("set-tos-bits=" +
Byte.toString(((OFActionNetworkTypeOfService)a).getNetworkTypeOfService()));
break;
case SET_NW_SRC:
sb.append("set-src-ip=" +
IPv4.fromIPv4Address(((OFActionNetworkLayerSource)a).getNetworkAddress()));
break;
case SET_NW_DST:
sb.append("set-dst-ip=" +
IPv4.fromIPv4Address(((OFActionNetworkLayerDestination)a).getNetworkAddress()));
break;
case SET_TP_SRC:
sb.append("set-src-port=" +
Short.toString(((OFActionTransportLayerSource)a).getTransportPort()));
break;
case SET_TP_DST:
sb.append("set-dst-port=" +
Short.toString(((OFActionTransportLayerDestination)a).getTransportPort()));
break;
default:
log.error("Could not decode action: {}", a);
break;
}
}
return sb.toString();
}
示例5: flowModActionsToString
import org.openflow.protocol.action.OFActionNetworkTypeOfService; //导入依赖的package包/类
/**
* Returns a String representation of all the openflow actions.
* @param fmActions A list of OFActions to encode into one string
* @return A string of the actions encoded for our database
*/
@LogMessageDoc(level="ERROR",
message="Could not decode action {action}",
explanation="A static flow entry contained an invalid action",
recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG)
private static String flowModActionsToString(List<OFAction> fmActions) {
StringBuilder sb = new StringBuilder();
for (OFAction a : fmActions) {
if (sb.length() > 0) {
sb.append(',');
}
switch(a.getType()) {
case OUTPUT:
sb.append("output=" + Short.toString(((OFActionOutput)a).getPort()));
break;
case OPAQUE_ENQUEUE:
int queue = ((OFActionEnqueue)a).getQueueId();
short port = ((OFActionEnqueue)a).getPort();
sb.append("enqueue=" + Short.toString(port) + ":0x" + String.format("%02x", queue));
break;
case STRIP_VLAN:
sb.append("strip-vlan");
break;
case SET_VLAN_ID:
sb.append("set-vlan-id=" +
Short.toString(((OFActionVirtualLanIdentifier)a).getVirtualLanIdentifier()));
break;
case SET_VLAN_PCP:
sb.append("set-vlan-priority=" +
Byte.toString(((OFActionVirtualLanPriorityCodePoint)a).getVirtualLanPriorityCodePoint()));
break;
case SET_DL_SRC:
sb.append("set-src-mac=" +
HexString.toHexString(((OFActionDataLayerSource)a).getDataLayerAddress()));
break;
case SET_DL_DST:
sb.append("set-dst-mac=" +
HexString.toHexString(((OFActionDataLayerDestination)a).getDataLayerAddress()));
break;
case SET_NW_TOS:
sb.append("set-tos-bits=" +
Byte.toString(((OFActionNetworkTypeOfService)a).getNetworkTypeOfService()));
break;
case SET_NW_SRC:
sb.append("set-src-ip=" +
IPv4.fromIPv4Address(((OFActionNetworkLayerSource)a).getNetworkAddress()));
break;
case SET_NW_DST:
sb.append("set-dst-ip=" +
IPv4.fromIPv4Address(((OFActionNetworkLayerDestination)a).getNetworkAddress()));
break;
case SET_TP_SRC:
sb.append("set-src-port=" +
Short.toString(((OFActionTransportLayerSource)a).getTransportPort()));
break;
case SET_TP_DST:
sb.append("set-dst-port=" +
Short.toString(((OFActionTransportLayerDestination)a).getTransportPort()));
break;
default:
log.error("Could not decode action: {}", a);
break;
}
}
return sb.toString();
}