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


Java OFVersion.getWireVersion方法代码示例

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


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

示例1: computeOFVersionFromBitmap

import org.projectfloodlight.openflow.protocol.OFVersion; //导入方法依赖的package包/类
/**
 * Determine the highest supported version of OpenFlow in common
 * between both our OFVersion bitmap and the switch's.
 * 
 * @param theirs, the version bitmaps of the switch
 * @return the highest OFVersion in common b/t the two
 */
private OFVersion computeOFVersionFromBitmap(List<U32> theirs) {		
	Iterator<U32> theirsItr = theirs.iterator();
	Iterator<U32> oursItr = ofBitmaps.iterator();
	OFVersion version = null;
	int pos = 0;
	int size = 32;
	while (theirsItr.hasNext() && oursItr.hasNext()) {
		int t = theirsItr.next().getRaw();
		int o = oursItr.next().getRaw();

		int common = t & o; /* Narrow down the results to the common bits */
		for (int i = 0; i < size; i++) { /* Iterate over and locate the 1's */
			int tmp = common & (1 << i); /* Select the bit of interest, 0-31 */
			if (tmp != 0) { /* Is the version of this bit in common? */
				for (OFVersion v : OFVersion.values()) { /* Which version does this bit represent? */
					if (v.getWireVersion() == i + (size * pos)) {
						version = v;
					}
				}
			}
		}
		pos++; /* OFVersion position. 1-31 = 1, 32 - 63 = 2, etc. Inc at end so it starts at 0. */
	}
	return version;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:33,代码来源:OFChannelHandler.java

示例2: computeOurVersionBitmaps

import org.projectfloodlight.openflow.protocol.OFVersion; //导入方法依赖的package包/类
/**
 * Based on the list of OFVersions provided as input (or from Loxi),
 * create a list of bitmaps for use in version negotiation during a
 * cross-version OpenFlow handshake where both parties support 
 * OpenFlow versions >= 1.3.1.
 * 
 * Type Set is used as input to guarantee all unique versions.
 * 
 * @param ofVersions, the list of bitmaps. Supply to an OFHello message.
 * @return list of bitmaps for the versions of OpenFlow we support
 */
private List<U32> computeOurVersionBitmaps(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.");
	}

	int pos = 1; /* initial bitmap in list */
	int size = 32; /* size of a U32 */
	int tempBitmap = 0; /* maintain the current bitmap we're working on */
	List<U32> bitmaps = new ArrayList<U32>();
	ArrayList<OFVersion> sortedVersions = new ArrayList<OFVersion>(ofVersions);
	Collections.sort(sortedVersions);
	for (OFVersion v : sortedVersions) {
		/* Move on to another bitmap */
		if (v.getWireVersion() > pos * size - 1 ) {
			bitmaps.add(U32.ofRaw(tempBitmap));
			tempBitmap = 0;
			pos++;
		}
		tempBitmap = tempBitmap | (1 << (v.getWireVersion() % size));
	}
	if (tempBitmap != 0) {
		bitmaps.add(U32.ofRaw(tempBitmap));
	}
	log.info("Computed OpenFlow version bitmap as {}", Arrays.asList(tempBitmap));
	return bitmaps;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:39,代码来源:OFSwitchManager.java


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