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


Java IOFSwitch类代码示例

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


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

示例1: testRemovedSwitchSelf

import net.floodlightcontroller.core.IOFSwitch; //导入依赖的package包/类
@Test
public void testRemovedSwitchSelf() {
    LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager();
    IOFSwitch sw1 = createMockSwitch(1L);
    replay(sw1);
    Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(1L), OFPort.of(3), U64.ZERO);
    LinkInfo info = new LinkInfo(new Date(),
                                 new Date(), null);
    linkDiscovery.addOrUpdateLink(lt, info);

    // Mock up our expected behavior
    linkDiscovery.switchRemoved(sw1.getId());

    verify(sw1);
    // check invariants hold
    assertNull(linkDiscovery.switchLinks.get(lt.getSrc()));
    assertNull(linkDiscovery.portLinks.get(lt.getSrc()));
    assertNull(linkDiscovery.portLinks.get(lt.getDst()));
    assertTrue(linkDiscovery.links.isEmpty());
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:21,代码来源:LinkDiscoveryManagerTest.java

示例2: installLegacyMeter

import net.floodlightcontroller.core.IOFSwitch; //导入依赖的package包/类
private ImmutablePair<Long, Boolean> installLegacyMeter(final IOFSwitch sw, final DatapathId dpid,
                                                        final long bandwidth, final long burstSize,
                                                        final long meterId) {
    logger.debug("installing legacy meter {} on OVS switch {} width bandwidth {}", meterId, dpid, bandwidth);

    Set<OFLegacyMeterFlags> flags = new HashSet<>(Arrays.asList(OFLegacyMeterFlags.KBPS, OFLegacyMeterFlags.BURST));
    OFFactory ofFactory = sw.getOFFactory();

    OFLegacyMeterBandDrop.Builder bandBuilder = ofFactory.legacyMeterBandDrop(bandwidth, burstSize).createBuilder();

    OFLegacyMeterMod meterMod = ofFactory.buildLegacyMeterMod()
            .setMeterId(meterId)
            .setCommand(OFLegacyMeterModCommand.ADD)
            .setMeters(singletonList(bandBuilder.build()))
            .setFlags(flags)
            .build();

    boolean response = sw.write(meterMod);
    return new ImmutablePair<>(meterMod.getXid(), response);
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:21,代码来源:SwitchManager.java

示例3: createMatchFromPacket

import net.floodlightcontroller.core.IOFSwitch; //导入依赖的package包/类
protected Match createMatchFromPacket(IOFSwitch sw, OFPort inPort, FloodlightContext cntx) {
	// The packet in match will only contain the port number.
	// We need to add in specifics for the hosts we're routing between.
	Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	VlanVid vlan = VlanVid.ofVlan(eth.getVlanID());
	MacAddress srcMac = eth.getSourceMACAddress();
	MacAddress dstMac = eth.getDestinationMACAddress();

	Match.Builder mb = sw.getOFFactory().buildMatch();
	mb.setExact(MatchField.IN_PORT, inPort)
	.setExact(MatchField.ETH_SRC, srcMac)
	.setExact(MatchField.ETH_DST, dstMac);

	if (!vlan.equals(VlanVid.ZERO)) {
		mb.setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlanVid(vlan));
	}

	return mb.build();
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:20,代码来源:LearningSwitch.java

示例4: pushSchemeOutputVlanTypeToOFActionList

import net.floodlightcontroller.core.IOFSwitch; //导入依赖的package包/类
/**
 * Builds OFAction list based on flow parameters for push scheme.
 *
 * @param sw             IOFSwitch instance
 * @param outputVlanId   set vlan on packet before forwarding via outputPort; 0 means not to set
 * @param outputVlanType type of action to apply to the outputVlanId if greater than 0
 * @return list of {@link OFAction}
 */
private List<OFAction> pushSchemeOutputVlanTypeToOFActionList(IOFSwitch sw, int outputVlanId,
                                                              OutputVlanType outputVlanType) {
    List<OFAction> actionList = new ArrayList<>(2);

    switch (outputVlanType) {
        case PUSH:      // No VLAN on packet so push a new one
            actionList.add(actionPushVlan(sw, ETH_TYPE));
            actionList.add(actionReplaceVlan(sw, outputVlanId));
            break;
        case REPLACE:   // VLAN on packet but needs to be replaced
            actionList.add(actionReplaceVlan(sw, outputVlanId));
            break;
        case POP:       // VLAN on packet, so remove it
            // TODO:  can i do this?  pop two vlan's back to back...
            actionList.add(actionPopVlan(sw));
            break;
        case NONE:
            break;
        default:
            logger.error("Unknown OutputVlanType: " + outputVlanType);
    }

    return actionList;
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:33,代码来源:SwitchManager.java

示例5: actionReplaceVlan

import net.floodlightcontroller.core.IOFSwitch; //导入依赖的package包/类
/**
 * Create an OFAction to change the outer most vlan.
 *
 * @param sw      switch object
 * @param newVlan final VLAN to be set on the packet
 * @return {@link OFAction}
 */
private OFAction actionReplaceVlan(final IOFSwitch sw, final int newVlan) {
    OFFactory factory = sw.getOFFactory();
    OFOxms oxms = factory.oxms();
    OFActions actions = factory.actions();

    if (OF_12.compareTo(factory.getVersion()) == 0) {
        return actions.buildSetField().setField(oxms.buildVlanVid()
                .setValue(OFVlanVidMatch.ofRawVid((short) newVlan))
                .build()).build();
    } else {
        return actions.buildSetField().setField(oxms.buildVlanVid()
                .setValue(OFVlanVidMatch.ofVlan(newVlan))
                .build()).build();
    }
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:23,代码来源:SwitchManager.java

示例6: switchActivated

import net.floodlightcontroller.core.IOFSwitch; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void switchActivated(final DatapathId switchId) {
    final IOFSwitch sw = switchService.getSwitch(switchId);

    Message message = buildSwitchMessage(sw, SwitchState.ACTIVATED);
    kafkaProducer.postMessage(TOPO_EVENT_TOPIC, message);

    ImmutablePair<Long, Boolean> metersDeleted;
    metersDeleted = switchManager.deleteMeter(switchId, ALL_VAL);
    if (!metersDeleted.getRight()) {
        logger.error("Could not delete meters from switch={} xid={}", switchId, metersDeleted.getLeft());
    }

    boolean defaultRulesInstalled = switchManager.installDefaultRules(switchId);
    if (!defaultRulesInstalled) {
        logger.error("Could not install default rules on switch={}", switchId);
    }

    if (sw.getEnabledPortNumbers() != null) {
        for (OFPort p : sw.getEnabledPortNumbers()) {
            kafkaProducer.postMessage(TOPO_EVENT_TOPIC, buildPortMessage(sw.getId(), p, PortChangeType.UP));
        }
    }
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:28,代码来源:SwitchEventCollector.java

示例7: receive

import net.floodlightcontroller.core.IOFSwitch; //导入依赖的package包/类
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
	if (!this.enabled) {
		return Command.CONTINUE;
	}

	switch (msg.getType()) {
	case PACKET_IN:
		IRoutingDecision decision = null;
		if (cntx != null) {
			decision = IRoutingDecision.rtStore.get(cntx, IRoutingDecision.CONTEXT_DECISION);
			return this.processPacketInMessage(sw, (OFPacketIn) msg, decision, cntx);
		}
		break;
	default:
		break;
	}

	return Command.CONTINUE;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:21,代码来源:Firewall.java

示例8: setSwitchRole

import net.floodlightcontroller.core.IOFSwitch; //导入依赖的package包/类
/**
 * Set the role for this switch / channel.
 *
 * If the status indicates that we received a reply we set the role.
 * If the status indicates otherwise we disconnect the switch if
 * the role is SLAVE.
 *
 * "Setting a role" means setting the appropriate ChannelState,
 * setting the flags on the switch and
 * notifying Controller.java about new role of the switch
 *
 * @param role The role to set.
 * @param status How we derived at the decision to set this status.
 */
synchronized private void setSwitchRole(OFControllerRole role, RoleRecvStatus status) {
	requestPending = false;
	if (status == RoleRecvStatus.RECEIVED_REPLY)
		sw.setAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE, true);
	else
		sw.setAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE, false);
	sw.setControllerRole(role);

	if (role != OFControllerRole.ROLE_SLAVE) {
		OFSwitchHandshakeHandler.this.setState(new MasterState());
	} else {
		if (status != RoleRecvStatus.RECEIVED_REPLY) {
			if (log.isDebugEnabled()) {
				log.debug("Disconnecting switch {}. Doesn't support role"
						+ "({}) request and controller is now SLAVE",
						getSwitchInfoString(), status);
			}
			// the disconnect will trigger a switch removed to
			// controller so no need to signal anything else
			sw.disconnect();
		} else {
			OFSwitchHandshakeHandler.this.setState(new SlaveState());
		}
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:40,代码来源:OFSwitchHandshakeHandler.java

示例9: writeOFMessagesToSwitch

import net.floodlightcontroller.core.IOFSwitch; //导入依赖的package包/类
/**
 * Writes a list of OFMessages to a switch
 * @param dpid The datapath ID of the switch to write to
 * @param messages The list of OFMessages to write.
 */
@LogMessageDoc(level="ERROR",
		message="Tried to write to switch {switch} but got {error}",
		explanation="An I/O error occured while trying to write a " +
				"static flow to a switch",
				recommendation=LogMessageDoc.CHECK_SWITCH)
private void writeOFMessagesToSwitch(DatapathId dpid, List<OFMessage> messages) {
	IOFSwitch ofswitch = switchService.getSwitch(dpid);
	if (ofswitch != null) {  // is the switch connected
		if (log.isDebugEnabled()) {
			log.debug("Sending {} new entries to {}", messages.size(), dpid);
		}
		ofswitch.write(messages);
		ofswitch.flush();
	}
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:21,代码来源:StaticFlowEntryPusher.java

示例10: handleOutgoingMessage

import net.floodlightcontroller.core.IOFSwitch; //导入依赖的package包/类
@Override
public void handleOutgoingMessage(IOFSwitch sw, OFMessage m) {
    if (sw == null)
        throw new NullPointerException("Switch must not be null");
    if (m == null)
        throw new NullPointerException("OFMessage must not be null");

    FloodlightContext bc = new FloodlightContext();

    List<IOFMessageListener> listeners = null;
    if (messageListeners.containsKey(m.getType())) {
        listeners = messageListeners.get(m.getType()).getOrderedListeners();
    }

    if (listeners != null) {
        for (IOFMessageListener listener : listeners) {
            if (Command.STOP.equals(listener.receive(sw, m, bc))) {
                break;
            }
        }
    }
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:23,代码来源:Controller.java

示例11: processNewPort

import net.floodlightcontroller.core.IOFSwitch; //导入依赖的package包/类
/**
 * Process a new port. If link discovery is disabled on the port, then do
 * nothing. If autoportfast feature is enabled and the port is a fast port,
 * then do nothing. Otherwise, send LLDP message. Add the port to
 * quarantine.
 *
 * @param sw
 * @param p
 */
private void processNewPort(DatapathId sw, OFPort p) {
	if (isLinkDiscoverySuppressed(sw, p)) {
		// Do nothing as link discovery is suppressed.
		return;
	}

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

	NodePortTuple npt = new NodePortTuple(sw, p);
	discover(sw, p);
	addToQuarantineQueue(npt);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:25,代码来源:LinkDiscoveryManager.java

示例12: isAttachmentPointPort

import net.floodlightcontroller.core.IOFSwitch; //导入依赖的package包/类
@Override
public boolean isAttachmentPointPort(DatapathId switchid, OFPort port, boolean tunnelEnabled) {

	// If the switch port is 'tun-bsn' port, it is not
	// an attachment point port, irrespective of whether
	// a link is found through it or not.
	if (linkDiscoveryService.isTunnelPort(switchid, port))
		return false;

	TopologyInstance ti = getCurrentInstance(tunnelEnabled);

	// if the port is not attachment point port according to
	// topology instance, then return false
	if (ti.isAttachmentPointPort(switchid, port) == false)
		return false;

	// Check whether the port is a physical port. We should not learn
	// attachment points on "special" ports.
	if ((port.getShortPortNumber() & 0xff00) == 0xff00 && port.getShortPortNumber() != (short)0xfffe) return false;

	// Make sure that the port is enabled.
	IOFSwitch sw = switchService.getActiveSwitch(switchid);
	if (sw == null) return false;
	return (sw.portEnabled(port));
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:26,代码来源:TopologyManager.java

示例13: enforceSecurityAcitions

import net.floodlightcontroller.core.IOFSwitch; //导入依赖的package包/类
void enforceSecurityAcitions(IOFSwitch sw, FPContext cntx, SecurityAction sa){
	switch(sa.getType()){
	case REDIRECT:
		RedirectAction ra = (RedirectAction)sa;
		enforceRedirectAction(ra, library.isARP(cntx), ra.isIgnorePort());
		break;
	case MIRROR:
		MirrorAction ma = (MirrorAction)sa;
		enforceMirrorAction(cntx, ma);
		break;
	case QUARANTINE:
		QuarantineAction qa = (QuarantineAction)sa;
		//proxy arp
		if (library.isARP(cntx)){
		}
		enforceQuarantineAction(qa);
		break;
	case BLOCK:
		BlockAction ba = (BlockAction)sa;
		enforceBlockAction(ba);
		break;
	}
		
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:25,代码来源:FP_FloodlightRTE.java

示例14: handleOutgoingMessage

import net.floodlightcontroller.core.IOFSwitch; //导入依赖的package包/类
@Override
public void handleOutgoingMessage(IOFSwitch sw, OFMessage m) {
    FloodlightContext bc = new FloodlightContext();
    List<IOFMessageListener> msgListeners = null;
    if (listeners.containsKey(m.getType())) {
        msgListeners = listeners.get(m.getType()).getOrderedListeners();
    }

    if (msgListeners != null) {
        for (IOFMessageListener listener : msgListeners) {
            if (Command.STOP.equals(listener.receive(sw, m, bc))) {
                break;
            }
        }
    }
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:17,代码来源:MockFloodlightProvider.java

示例15: getObfuscationMask

import net.floodlightcontroller.core.IOFSwitch; //导入依赖的package包/类
public ObfuscationMask getObfuscationMask(long dst, IOFSwitch sw, Route route) {
	//System.out.println("get mask for " + dst);
	
	if (!checkMaskID(dst, route)) { // need new mask
		if (obfuscationMasks.containsKey(dst)) { // remove because mask must not be used anymore
			//System.out.println("*** remove mask !***");
			obfuscationMasks.remove(dst);
			oLinkStateManager.resetNumberOfMaskUsages(dst);
		}
	}
	
	if (!obfuscationMasks.containsKey(dst)) {
		System.out.println("*** create new mask ***");
		obfuscationMasks.put(dst, createNewObfuscationMask(dst));
	}
	return obfuscationMasks.get(dst);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:18,代码来源:ObfuscationMaskManager.java


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