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


Java IOFSwitch.getPort方法代码示例

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


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

示例1: generateSwitchPortStatusUpdate

import net.floodlightcontroller.core.IOFSwitch; //导入方法依赖的package包/类
private void generateSwitchPortStatusUpdate(DatapathId sw, OFPort port) {
	UpdateOperation operation;

	IOFSwitch iofSwitch = switchService.getSwitch(sw);
	if (iofSwitch == null) return;

	OFPortDesc ofp = iofSwitch.getPort(port);
	if (ofp == null) return;

	Set<OFPortState> srcPortState = ofp.getState();
	boolean portUp = !srcPortState.contains(OFPortState.STP_BLOCK);

	if (portUp) {
		operation = UpdateOperation.PORT_UP;
	} else {
		operation = UpdateOperation.PORT_DOWN;
	}

	updates.add(new LDUpdate(sw, port, operation));
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:21,代码来源:LinkDiscoveryManager.java

示例2: sendDiscoveryMessage

import net.floodlightcontroller.core.IOFSwitch; //导入方法依赖的package包/类
/**
 * Send link discovery message out of a given switch port. The discovery
 * message may be a standard LLDP or a modified LLDP, where the dst mac
 * address is set to :ff. TODO: The modified LLDP will updated in the future
 * and may use a different eth-type.
 *
 * @param sw
 * @param port
 * @param isStandard
 *            indicates standard or modified LLDP
 * @param isReverse
 *            indicates whether the LLDP was sent as a response
 */
protected void sendDiscoveryMessage(DatapathId sw, OFPort port,
		boolean isStandard, boolean isReverse) {

	// Takes care of all checks including null pointer checks.
	if (!isOutgoingDiscoveryAllowed(sw, port, isStandard, isReverse))
		return;

	IOFSwitch iofSwitch = switchService.getSwitch(sw);
	if (iofSwitch == null)             //fix dereference violations in case race conditions
		return;
	OFPortDesc ofpPort = iofSwitch.getPort(port);

	OFPacketOut po = generateLLDPMessage(iofSwitch, port, isStandard, isReverse);
	OFPacketOut.Builder pob = po.createBuilder();

	// Add actions
	List<OFAction> actions = getDiscoveryActions(iofSwitch, ofpPort.getPortNo());
	pob.setActions(actions);

	// no need to set length anymore

	// send
	// no more try-catch. switch will silently fail
	iofSwitch.write(pob.build());
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:39,代码来源:LinkDiscoveryManager.java

示例3: generateSwitchPortStatusUpdate

import net.floodlightcontroller.core.IOFSwitch; //导入方法依赖的package包/类
private void generateSwitchPortStatusUpdate(DatapathId sw, OFPort port) {
	UpdateOperation operation;

	IOFSwitch iofSwitch = switchService.getSwitch(sw);
	if (iofSwitch == null) return;

	OFPortDesc ofp = iofSwitch.getPort(port);
	if (ofp == null) return;

	Set<OFPortState> srcPortState = ofp.getState();
	boolean portUp = !srcPortState.contains(OFPortState.STP_BLOCK);

	if (portUp) {
		operation = UpdateOperation.PORT_UP;
	} else {
		operation = UpdateOperation.PORT_DOWN;
	}
	
	updates.add(new LDUpdate(sw, port, operation));
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:21,代码来源:LinkDiscoveryManager.java

示例4: enforceMirrorAction

import net.floodlightcontroller.core.IOFSwitch; //导入方法依赖的package包/类
private void enforceMirrorAction(FPContext cntx, MirrorAction ma){
	//check if the mirrored switch and port are still active
	IOFSwitch sw = switchService.getSwitch(DatapathId.of(ma.getDPID()));
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(cntx.getFlowContext(),
				   IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	
	if (sw == null){
		log.error("[FRESCO] Cannot mirrow packet since the destination switch is offline");
		return;
	}
	
	if (sw.getPort(OFPort.of(ma.getPortID())) == null){
		log.error("[FRESCO] Cannot mirrow packet since the destination port is closed");
		return;
	}	
	
	//use packet-out to send out packet to a specific switch port
	OFPacketOut.Builder pob = sw.getOFFactory().buildPacketOut();

	ArrayList<OFAction> actions = new ArrayList<OFAction>();
	   	actions.add(sw.getOFFactory().actions().output(OFPort.of(ma.getPortID()),Integer.MAX_VALUE));

	   byte[] packetData = eth.serialize();
      pob.setData(packetData);
	   	
	sw.write(pob.build());
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:29,代码来源:FP_FloodlightRTE.java

示例5: isIncomingDiscoveryAllowed

import net.floodlightcontroller.core.IOFSwitch; //导入方法依赖的package包/类
/**
 * Check if incoming discovery messages are enabled or not.
 * @param sw
 * @param port
 * @param isStandard
 * @return
 */
protected boolean isIncomingDiscoveryAllowed(DatapathId sw, OFPort port,
		boolean isStandard) {

	if (isLinkDiscoverySuppressed(sw, port)) {
		/* Do not process LLDPs from this port as suppressLLDP is set */
		return false;
	}

	IOFSwitch iofSwitch = switchService.getSwitch(sw);
	if (iofSwitch == null) {
		return false;
	}

	if (port == OFPort.LOCAL) return false;

	OFPortDesc ofpPort = iofSwitch.getPort(port);
	if (ofpPort == null) {
		if (log.isTraceEnabled()) {
			log.trace("Null physical port. sw={}, port={}",
					sw.toString(), port.getPortNumber());
		}
		return false;
	}

	return true;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:34,代码来源:LinkDiscoveryManager.java

示例6: isOutgoingDiscoveryAllowed

import net.floodlightcontroller.core.IOFSwitch; //导入方法依赖的package包/类
/**
 * Check if outgoing discovery messages are enabled or not.
 * @param sw
 * @param port
 * @param isStandard
 * @param isReverse
 * @return
 */
protected boolean isOutgoingDiscoveryAllowed(DatapathId sw, OFPort port,
		boolean isStandard,
		boolean isReverse) {

	if (isLinkDiscoverySuppressed(sw, port)) {
		/* Dont send LLDPs out of this port as suppressLLDP is set */
		return false;
	}

	IOFSwitch iofSwitch = switchService.getSwitch(sw);
	if (iofSwitch == null) {
		return false;
	}

	if (port == OFPort.LOCAL) return false;

	OFPortDesc ofpPort = iofSwitch.getPort(port);
	if (ofpPort == null) {
		if (log.isTraceEnabled()) {
			log.trace("Null physical port. sw={}, port={}",
					sw.toString(), port.getPortNumber());
		}
		return false;
	} else {
		return true;
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:36,代码来源:LinkDiscoveryManager.java

示例7: sendDiscoveryMessage

import net.floodlightcontroller.core.IOFSwitch; //导入方法依赖的package包/类
/**
 * Send link discovery message out of a given switch port. The discovery
 * message may be a standard LLDP or a modified LLDP, where the dst mac
 * address is set to :ff. TODO: The modified LLDP will updated in the future
 * and may use a different eth-type.
 *
 * @param sw
 * @param port
 * @param isStandard
 *            indicates standard or modified LLDP
 * @param isReverse
 *            indicates whether the LLDP was sent as a response
 */
@LogMessageDoc(level = "ERROR",
		message = "Failure sending LLDP out port {port} on switch {switch}",
		explanation = "An I/O error occured while sending LLDP message "
				+ "to the switch.",
				recommendation = LogMessageDoc.CHECK_SWITCH)
protected void sendDiscoveryMessage(DatapathId sw, OFPort port,
		boolean isStandard, boolean isReverse) {

	// Takes care of all checks including null pointer checks.
	if (!isOutgoingDiscoveryAllowed(sw, port, isStandard, isReverse))
		return;

	IOFSwitch iofSwitch = switchService.getSwitch(sw);
	OFPortDesc ofpPort = iofSwitch.getPort(port);

	if (log.isTraceEnabled()) {
		log.trace("Sending LLDP packet out of swich: {}, port: {}",
				sw.toString(), port.getPortNumber());
	}
	OFPacketOut po = generateLLDPMessage(sw, port, isStandard, isReverse);
	OFPacketOut.Builder pob = po.createBuilder();

	// Add actions
	List<OFAction> actions = getDiscoveryActions(iofSwitch, ofpPort.getPortNo());
	pob.setActions(actions);
	
	// no need to set length anymore

	// send
	// no more try-catch. switch will silently fail
	iofSwitch.write(pob.build());
	iofSwitch.flush();
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:47,代码来源:LinkDiscoveryManager.java


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