当前位置: 首页>>代码示例>>Java>>正文


Java OFVersion类代码示例

本文整理汇总了Java中org.projectfloodlight.openflow.protocol.OFVersion的典型用法代码示例。如果您正苦于以下问题:Java OFVersion类的具体用法?Java OFVersion怎么用?Java OFVersion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OFVersion类属于org.projectfloodlight.openflow.protocol包,在下文中一共展示了OFVersion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: DhcpDiscoveryRequestOFPacketIn

import org.projectfloodlight.openflow.protocol.OFVersion; //导入依赖的package包/类
/**
 * Generates a DHCP request OFPacketIn.
 * @param hostMac The host MAC address of for the request.
 * @return An OFPacketIn that contains a DHCP request packet.
 */
public static OFPacketIn DhcpDiscoveryRequestOFPacketIn(IOFSwitch sw,
        MacAddress hostMac) {
    byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
    OFFactory factory = sw.getOFFactory();
    OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
    if (factory.getVersion() == OFVersion.OF_10) {
    	packetInBuilder
    		.setInPort(OFPort.of(1))
            .setData(serializedPacket)
            .setReason(OFPacketInReason.NO_MATCH);
    } else {
    	packetInBuilder
    	.setMatch(factory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build())
        .setData(serializedPacket)
        .setReason(OFPacketInReason.NO_MATCH);
    }
    return packetInBuilder.build();
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:24,代码来源:PacketFactory.java

示例2: decode_set_vlan_id

import org.projectfloodlight.openflow.protocol.OFVersion; //导入依赖的package包/类
/**
 * Parse set_vlan_id actions.
 * The key and delimiter for the action should be omitted, and only the
 * data should be presented to this decoder. Data with a leading 0x is permitted.
 * 
 * @param actionToDecode; The action as a string to decode
 * @param version; The OF version to create the action for
 * @param log
 * @return
 */
private static OFActionSetVlanVid decode_set_vlan_id(String actionToDecode, OFVersion version, Logger log) {
	Matcher n = Pattern.compile("((?:0x)?\\d+)").matcher(actionToDecode);
	if (n.matches()) {            
		if (n.group(1) != null) {
			try {
				VlanVid vlanid = VlanVid.ofVlan(get_short(n.group(1)));
				OFActionSetVlanVid.Builder ab = OFFactories.getFactory(version).actions().buildSetVlanVid();
				ab.setVlanVid(vlanid);
				log.debug("action {}", ab.build());
				return ab.build();
			}
			catch (NumberFormatException e) {
				log.debug("Invalid VLAN in: {} (error ignored)", actionToDecode);
				return null;
			}
		}          
	}
	else {
		log.debug("Invalid action: '{}'", actionToDecode);
		return null;
	}
	return null;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:34,代码来源:ActionUtils.java

示例3: writePacketOutForPacketIn

import org.projectfloodlight.openflow.protocol.OFVersion; //导入依赖的package包/类
/**
 * Writes an OFPacketOut message to a switch.
 * @param sw The switch to write the PacketOut to.
 * @param packetInMessage The corresponding PacketIn.
 * @param egressPort The switchport to output the PacketOut.
 */
private void writePacketOutForPacketIn(IOFSwitch sw, OFPacketIn packetInMessage, OFPort egressPort) {
	OFPacketOut.Builder pob = sw.getOFFactory().buildPacketOut();

	// Set buffer_id, in_port, actions_len
	pob.setBufferId(packetInMessage.getBufferId());
	pob.setInPort(packetInMessage.getVersion().compareTo(OFVersion.OF_12) < 0 ? packetInMessage.getInPort() : packetInMessage.getMatch().get(MatchField.IN_PORT));

	// set actions
	List<OFAction> actions = new ArrayList<OFAction>(1);
	actions.add(sw.getOFFactory().actions().buildOutput().setPort(egressPort).setMaxLen(0xffFFffFF).build());
	pob.setActions(actions);

	// set data - only if buffer_id == -1
	if (packetInMessage.getBufferId() == OFBufferId.NO_BUFFER) {
		byte[] packetData = packetInMessage.getData();
		pob.setData(packetData);
	}

	// and write it out
	counterPacketOut.increment();
	sw.write(pob.build());

}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:30,代码来源:LearningSwitch.java

示例4: computeInitialFactory

import org.projectfloodlight.openflow.protocol.OFVersion; //导入依赖的package包/类
/**
 * Find the max version supplied in the supported
 * versions list and use it as the default, which
 * will subsequently be used in our hello message
 * header's version field.
 * 
 * The factory can be later "downgraded" to a lower
 * version depending on what's computed during the
 * version-negotiation part of the handshake.
 * 
 * Assumption: The Set of OFVersion ofVersions
 * variable has been set already and is NOT EMPTY.
 * 
 * @return the highest-version OFFactory we support
 */
private OFFactory computeInitialFactory(Set<OFVersion> ofVersions) {
	/* This should NEVER happen. Double-checking. */
	if (ofVersions == null || ofVersions.isEmpty()) {
		throw new IllegalStateException("OpenFlow version list should never be null or empty at this point. Make sure it's set in the OFSwitchManager.");
	}
	OFVersion highest = null;
	for (OFVersion v : ofVersions) {
		if (highest == null) {
			highest = v;
		} else if (v.compareTo(highest) > 0) {
			highest = v;
		}
	}
	/* 
	 * This assumes highest != null, which
	 * it won't be if the list of versions
	 * is not empty.
	 */
	return OFFactories.getFactory(highest);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:36,代码来源:OFSwitchManager.java

示例5: clearActionsFromString

import org.projectfloodlight.openflow.protocol.OFVersion; //导入依赖的package包/类
/**
 * Convert the string representation of an OFInstructionClearActions to
 * an OFInstructionClearActions. 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 clearActionsFromString(OFFlowMod.Builder fmb, String inst, Logger log) {

	if (fmb.getVersion().compareTo(OFVersion.OF_11) < 0) {
		log.error("Clear Actions Instruction not supported in OpenFlow 1.0");
		return;
	}

	if (inst != null && inst.trim().isEmpty()) { /* Allow the empty string, since this is what specifies clear (i.e. key clear does not have any defined values). */
		OFInstructionClearActions i = OFFactories.getFactory(fmb.getVersion()).instructions().clearActions();
		log.debug("Appending ClearActions instruction: {}", i);
		appendInstruction(fmb, i);
		log.debug("All instructions after append: {}", fmb.getInstructions());		
	} else {
		log.error("Got non-empty or null string, but ClearActions should not have any String sub-fields: {}", inst);
	}
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:26,代码来源:InstructionUtils.java

示例6: decode_set_src_port

import org.projectfloodlight.openflow.protocol.OFVersion; //导入依赖的package包/类
/**
 * Parse set_tp_src actions.
 * The key and delimiter for the action should be omitted, and only the
 * data should be presented to this decoder. A leading 0x is permitted.
 * 
 * @param actionToDecode; The action as a string to decode
 * @param version; The OF version to create the action for
 * @param log
 * @return
 */
private static OFActionSetTpSrc decode_set_src_port(String actionToDecode, OFVersion version, Logger log) {
	Matcher n = Pattern.compile("((?:0x)?\\d+)").matcher(actionToDecode); 
	if (n.matches()) {
		if (n.group(1) != null) {
			try {
				TransportPort portnum = TransportPort.of(get_short(n.group(1)));
				OFActionSetTpSrc.Builder ab = OFFactories.getFactory(version).actions().buildSetTpSrc();
				ab.setTpPort(portnum);
				log.debug("action {}", ab.build());
				return ab.build();
			} 
			catch (NumberFormatException e) {
				log.debug("Invalid src-port in: {} (error ignored)", actionToDecode);
				return null;
			}
		}
	}
	else {
		log.debug("Invalid action: '{}'", actionToDecode);
		return null;
	}
	return null;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:34,代码来源:ActionUtils.java

示例7: setFeaturesReply

import org.projectfloodlight.openflow.protocol.OFVersion; //导入依赖的package包/类
@Override
public void setFeaturesReply(OFFeaturesReply featuresReply) {
	if (portManager.getPorts().isEmpty() && featuresReply.getVersion().compareTo(OFVersion.OF_13) < 0) {
		/* ports are updated via port status message, so we
		 * only fill in ports on initial connection.
		 */
		List<OFPortDesc> OFPortDescs = featuresReply.getPorts();
		portManager.updatePorts(OFPortDescs);
	}
	this.capabilities = featuresReply.getCapabilities();
	this.buffers = featuresReply.getNBuffers();

	if (featuresReply.getVersion().compareTo(OFVersion.OF_13) < 0 ) {
		// FIXME:LOJI: OF1.3 has per table actions. This needs to be modeled / handled here
		this.actions = featuresReply.getActions();
	}
	this.tables = featuresReply.getNTables();
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:19,代码来源:OFSwitch.java

示例8: serializeFeaturesReply

import org.projectfloodlight.openflow.protocol.OFVersion; //导入依赖的package包/类
public static void serializeFeaturesReply(OFFeaturesReply fr, JsonGenerator jGen) throws IOException, JsonProcessingException {
	/* Common to All OF Versions */			
	jGen.writeStringField("capabilities", fr.getCapabilities().toString());
	jGen.writeStringField("dpid", fr.getDatapathId().toString());
	jGen.writeNumberField("buffers", fr.getNBuffers());
	jGen.writeNumberField("tables", fr.getNTables());
	jGen.writeStringField("version", fr.getVersion().toString());
	
	if (fr.getVersion().compareTo(OFVersion.OF_13) < 0) { // OF1.3+ break this out into port_config
		serializePortDesc(fr.getPorts(), jGen);
	}
	if (fr.getVersion().compareTo(OFVersion.OF_10) == 0) {
		String actions = "[";
		for (OFActionType action : fr.getActions()) {
			actions =  actions + action.toString() + ", ";
		}
		actions = actions.substring(0, actions.length() - 2); // remove ending space+comma
		actions = actions + "]";
		jGen.writeStringField("actions", actions);
	}
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:22,代码来源:StatsReplySerializer.java

示例9: decode_set_vlan_priority

import org.projectfloodlight.openflow.protocol.OFVersion; //导入依赖的package包/类
/**
 * Parse set_vlan_pcp actions.
 * The key and delimiter for the action should be omitted, and only the
 * data should be presented to this decoder. Data with a leading 0x is permitted.
 * 
 * @param actionToDecode; The action as a string to decode
 * @param version; The OF version to create the action for
 * @param log
 * @return
 */
private static OFActionSetVlanPcp decode_set_vlan_priority(String actionToDecode, OFVersion version, Logger log) {
	Matcher n = Pattern.compile("((?:0x)?\\d+)").matcher(actionToDecode); 
	if (n.matches()) {            
		if (n.group(1) != null) {
			try {
				VlanPcp prior = VlanPcp.of(get_byte(n.group(1)));
				OFActionSetVlanPcp.Builder ab = OFFactories.getFactory(version).actions().buildSetVlanPcp();
				ab.setVlanPcp(prior);
				log.debug("action {}", ab.build());
				return ab.build();
			}
			catch (NumberFormatException e) {
				log.debug("Invalid VLAN priority in: {} (error ignored)", actionToDecode);
				return null;
			}
		}
	}
	else {
		log.debug("Invalid action: '{}'", actionToDecode);
		return null;
	}
	return null;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:34,代码来源:ActionUtils.java

示例10: groupStatsEvent

import org.projectfloodlight.openflow.protocol.OFVersion; //导入依赖的package包/类
@Test
public void groupStatsEvent() {
    TestOpenFlowGroupProviderService testProviderService =
            (TestOpenFlowGroupProviderService) providerService;

    OFGroupStatsReply.Builder rep1 =
            OFFactories.getFactory(OFVersion.OF_13).buildGroupStatsReply();
    rep1.setXid(1);
    controller.processPacket(dpid1, rep1.build());
    OFGroupDescStatsReply.Builder rep2 =
            OFFactories.getFactory(OFVersion.OF_13).buildGroupDescStatsReply();
    assertNull("group entries is not set yet", testProviderService.getGroupEntries());

    rep2.setXid(2);
    controller.processPacket(dpid1, rep2.build());
    assertNotNull("group entries should be set", testProviderService.getGroupEntries());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:OpenFlowGroupProviderTest.java

示例11: meterFromString

import org.projectfloodlight.openflow.protocol.OFVersion; //导入依赖的package包/类
/**
 * Convert the string representation of an OFInstructionMeter to
 * an OFInstructionMeter. 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 meterFromString(OFFlowMod.Builder fmb, String inst, Logger log) {
	if (inst == null || inst.isEmpty()) {
		return;
	}

	if (fmb.getVersion().compareTo(OFVersion.OF_13) < 0) {
		log.error("Goto Meter Instruction not supported in OpenFlow 1.0, 1.1, or 1.2");
		return;
	}

	OFInstructionMeter.Builder ib = OFFactories.getFactory(fmb.getVersion()).instructions().buildMeter();

	if (inst.startsWith("0x")) {
		ib.setMeterId(Long.valueOf(inst.replaceFirst("0x", ""), 16));
	} else {
		ib.setMeterId(Long.valueOf(inst));
	}		

	log.debug("Appending (Goto)Meter instruction: {}", ib.build());
	appendInstruction(fmb, ib.build());
	log.debug("All instructions after append: {}", fmb.getInstructions());
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:32,代码来源:InstructionUtils.java

示例12: createHubPacketOut

import org.projectfloodlight.openflow.protocol.OFVersion; //导入依赖的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();  
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:18,代码来源:Hub.java

示例13: decode_set_src_mac

import org.projectfloodlight.openflow.protocol.OFVersion; //导入依赖的package包/类
/**
 * Parse set_dl_src actions.
 * The key and delimiter for the action should be omitted, and only the
 * data should be presented to this decoder.
 * 
 * TODO should consider using MacAddress's built-in parser....
 * 
 * @param actionToDecode; The action as a string to decode
 * @param version; The OF version to create the action for
 * @param log
 * @return
 */
private static OFActionSetDlSrc decode_set_src_mac(String actionToDecode, OFVersion version, Logger log) {
	Matcher n = Pattern.compile("(?:(\\p{XDigit}+)\\:(\\p{XDigit}+)\\:(\\p{XDigit}+)\\:(\\p{XDigit}+)\\:(\\p{XDigit}+)\\:(\\p{XDigit}+))").matcher(actionToDecode); 
	if (n.matches()) {
		MacAddress macaddr = MacAddress.of(get_mac_addr(n, actionToDecode, log));
		if (macaddr != null) {
			OFActionSetDlSrc.Builder ab = OFFactories.getFactory(version).actions().buildSetDlSrc();
			ab.setDlAddr(macaddr);
			log.debug("action {}", ab.build());
			return ab.build();
		}            
	}
	else {
		log.debug("Invalid action: '{}'", actionToDecode);
		return null;
	}
	return null;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:30,代码来源:ActionUtils.java

示例14: decode_set_tos_bits

import org.projectfloodlight.openflow.protocol.OFVersion; //导入依赖的package包/类
/**
 * Parse set_tos actions.
 * The key and delimiter for the action should be omitted, and only the
 * data should be presented to this decoder. A leading 0x is permitted.
 * 
 * @param actionToDecode; The action as a string to decode
 * @param version; The OF version to create the action for
 * @param log
 * @return
 */
private static OFActionSetNwTos decode_set_tos_bits(String actionToDecode, OFVersion version, Logger log) {
	Matcher n = Pattern.compile("((?:0x)?\\d+)").matcher(actionToDecode); 
	if (n.matches()) {
		if (n.group(1) != null) {
			try {
				byte tosbits = get_byte(n.group(1));
				OFActionSetNwTos.Builder ab = OFFactories.getFactory(version).actions().buildSetNwTos();
				ab.setNwTos(tosbits);
				log.debug("action {}", ab.build());
				return ab.build();
			}
			catch (NumberFormatException e) {
				log.debug("Invalid dst-port in: {} (error ignored)", actionToDecode);
				return null;
			}
		}
	}
	else {
		log.debug("Invalid action: '{}'", actionToDecode);
		return null;
	}
	return null;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:34,代码来源:ActionUtils.java

示例15: getConnectionInfoString

import org.projectfloodlight.openflow.protocol.OFVersion; //导入依赖的package包/类
/**
 * Return a string describing this switch based on the already available
 * information (DPID and/or remote socket)
 * @return
 */
private String getConnectionInfoString() {

	String channelString;
	if (channel == null || channel.getRemoteAddress() == null) {
		channelString = "?";
	} else {
		channelString = channel.getRemoteAddress().toString();
		if(channelString.startsWith("/"))
			channelString = channelString.substring(1);
	}
	String dpidString;
	if (featuresReply == null) {
		dpidString = "?";
	} else {
		StringBuilder b = new StringBuilder();
		b.append(featuresReply.getDatapathId());
		if(featuresReply.getVersion().compareTo(OFVersion.OF_13) >= 0) {
			b.append("(").append(featuresReply.getAuxiliaryId()).append(")");
		}
		dpidString = b.toString();
	}
	return String.format("[%s from %s]", dpidString, channelString );
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:29,代码来源:OFChannelHandler.java


注:本文中的org.projectfloodlight.openflow.protocol.OFVersion类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。