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


Java OFFactory类代码示例

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


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

示例1: dumpMeters

import org.projectfloodlight.openflow.protocol.OFFactory; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public OFMeterConfigStatsReply dumpMeters(final DatapathId dpid) {
    OFMeterConfigStatsReply values = null;
    IOFSwitch sw = ofSwitchService.getSwitch(dpid);
    if (sw == null) {
        throw new IllegalArgumentException(String.format("Switch %s was not found", dpid.toString()));
    }

    OFFactory ofFactory = sw.getOFFactory();
    OFMeterConfigStatsRequest meterRequest = ofFactory.buildMeterConfigStatsRequest()
            .setMeterId(0xffffffff)
            .build();

    try {
        ListenableFuture<OFMeterConfigStatsReply> future = sw.writeRequest(meterRequest);
        values = future.get(5, TimeUnit.SECONDS);
    } catch (ExecutionException | InterruptedException | TimeoutException e) {
        logger.error("Could not get meter config stats: {}", e.getMessage());
    }

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

示例2: installLegacyMeter

import org.projectfloodlight.openflow.protocol.OFFactory; //导入依赖的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: deleteMeter

import org.projectfloodlight.openflow.protocol.OFFactory; //导入依赖的package包/类
public ImmutablePair<Long, Boolean> deleteMeter(IOFSwitch sw, final DatapathId dpid, final long meterId) {
    logger.debug("deleting meter {} from switch {}", meterId, dpid);

    OFFactory ofFactory = sw.getOFFactory();

    OFMeterMod.Builder meterDeleteBuilder = ofFactory.buildMeterMod()
            .setMeterId(meterId)
            .setCommand(OFMeterModCommand.DELETE);

    if (sw.getOFFactory().getVersion().compareTo(OF_13) > 0) {
        meterDeleteBuilder.setBands(emptyList());
    } else {
        meterDeleteBuilder.setMeters(emptyList());
    }

    OFMeterMod meterDelete = meterDeleteBuilder.build();

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

示例4: actionReplaceVlan

import org.projectfloodlight.openflow.protocol.OFFactory; //导入依赖的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

示例5: DhcpDiscoveryRequestOFPacketIn

import org.projectfloodlight.openflow.protocol.OFFactory; //导入依赖的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

示例6: mapSelector

import org.projectfloodlight.openflow.protocol.OFFactory; //导入依赖的package包/类
@Override
public OFOxm<?> mapSelector(OFFactory factory, ExtensionSelector extensionSelector) {
    ExtensionSelectorType type = extensionSelector.type();
    if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.OFDPA_MATCH_VLAN_VID.type())) {
        VlanId vlanId = ((OfdpaMatchVlanVid) extensionSelector).vlanId();
        // Special VLAN 0x0000/0x1FFF required by OFDPA
        if (vlanId.equals(VlanId.NONE)) {
            OFVlanVidMatch vid = OFVlanVidMatch.ofRawVid((short) 0x0000);
            OFVlanVidMatch mask = OFVlanVidMatch.ofRawVid((short) 0x1FFF);
            return factory.oxms().vlanVidMasked(vid, mask);
        // Normal case
        } else if (vlanId.equals(VlanId.ANY)) {
            return factory.oxms().vlanVidMasked(OFVlanVidMatch.PRESENT, OFVlanVidMatch.PRESENT);
        } else {
            return factory.oxms().vlanVid(OFVlanVidMatch.ofVlanVid(VlanVid.ofVlan(vlanId.toShort())));
        }
    }
    throw new UnsupportedOperationException(
            "Unexpected ExtensionSelector: " + extensionSelector.toString());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:OfdpaExtensionSelectorInterpreter.java

示例7: processOFEchoRequest

import org.projectfloodlight.openflow.protocol.OFFactory; //导入依赖的package包/类
void processOFEchoRequest(OFChannelHandler h, OFEchoRequest m)
        throws IOException {
    if (h.ofVersion == null) {
        log.error("No OF version set for {}. Not sending Echo REPLY",
                h.channel.getRemoteAddress());
        return;
    }
    OFFactory factory = (h.ofVersion == OFVersion.OF_13) ?
            h.controller.getOFMessageFactory13() : h.controller.getOFMessageFactory10();
            OFEchoReply reply = factory
                    .buildEchoReply()
                    .setXid(m.getXid())
                    .setData(m.getData())
                    .build();
            h.channel.write(Collections.singletonList(reply));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:OFChannelHandler.java

示例8: getFeaturesReply

import org.projectfloodlight.openflow.protocol.OFFactory; //导入依赖的package包/类
@JsonIgnore
public OFFeaturesReply getFeaturesReply(OFFactory factory) {
	/**
     * FIXME Icky work around; if a null actions got written to storage
     * then fake up an empty one so the builder() doesn't throw
     * a NPE.  Need to root cause why someone would write a null actions.
     * This code will all be removed shortly -- needed to unblock BVS team.
     */
    Set<OFActionType> workAroundActions;
    if (actions != null)
        workAroundActions = actions;
    else
        workAroundActions = Collections.<OFActionType> emptySet();

    OFFeaturesReply featuresReply = factory.buildFeaturesReply()
            .setXid(0)
            .setDatapathId(dpid)
            .setNBuffers(buffers)
            .setNTables(tables)
            .setCapabilities(capabilities)
            .setActions(workAroundActions)
            .setPorts(toOFPortDescList(factory, ports))
            .build();
    return featuresReply;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:26,代码来源:SwitchSyncRepresentation.java

示例9: OFChannelInitializer

import org.projectfloodlight.openflow.protocol.OFFactory; //导入依赖的package包/类
public OFChannelInitializer(IOFSwitchManager switchManager,
		INewOFConnectionListener connectionListener,
		IDebugCounterService debugCounters,
		Timer timer,
		List<U32> ofBitmaps,
		OFFactory defaultFactory,
		String keyStore, 
		String keyStorePassword) {
	super();
	this.switchManager = switchManager;
	this.connectionListener = connectionListener;
	this.timer = timer;
	this.debugCounters = debugCounters;
	this.defaultFactory = defaultFactory;
	this.ofBitmaps = ofBitmaps;
	this.keyStore = keyStore;
	this.keyStorePassword = keyStorePassword;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:19,代码来源:OFChannelInitializer.java

示例10: OFConnection

import org.projectfloodlight.openflow.protocol.OFFactory; //导入依赖的package包/类
public OFConnection(@Nonnull DatapathId dpid,
		@Nonnull OFFactory factory,
		@Nonnull Channel channel,
		@Nonnull OFAuxId auxId,
		@Nonnull IDebugCounterService debugCounters,
		@Nonnull Timer timer) {
	Preconditions.checkNotNull(dpid, "dpid");
	Preconditions.checkNotNull(factory, "factory");
	Preconditions.checkNotNull(channel, "channel");
	Preconditions.checkNotNull(timer, "timer");
	Preconditions.checkNotNull(debugCounters);

	this.listener = NullConnectionListener.INSTANCE;
	this.dpid = dpid;
	this.factory = factory;
	this.channel = channel;
	this.auxId = auxId;
	this.connectedSince = new Date();
	this.xidDeliverableMap = new ConcurrentHashMap<>();
	this.counters = new OFConnectionCounters(debugCounters, dpid, this.auxId);
	this.timer = timer;
	this.latency = U64.ZERO;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:24,代码来源:OFConnection.java

示例11: OFChannelHandler

import org.projectfloodlight.openflow.protocol.OFFactory; //导入依赖的package包/类
/**
 * Creates a handler for interacting with the switch channel
 *
 * @param controller
 *            the controller
 * @param newConnectionListener
 *            the class that listens for new OF connections (switchManager)
 * @param pipeline
 *            the channel pipeline
 * @param threadPool
 *            the thread pool
 * @param idleTimer
 *            the hash wheeled timer used to send idle messages (echo).
 *            passed to constructor to modify in case of aux connection.
 * @param debugCounters
 */
OFChannelHandler(@Nonnull IOFSwitchManager switchManager,
		@Nonnull INewOFConnectionListener newConnectionListener,
		@Nonnull ChannelPipeline pipeline,
		@Nonnull IDebugCounterService debugCounters,
		@Nonnull Timer timer,
		@Nonnull List<U32> ofBitmaps,
		@Nonnull OFFactory defaultFactory) {

	Preconditions.checkNotNull(switchManager, "switchManager");
	Preconditions.checkNotNull(newConnectionListener, "connectionOpenedListener");
	Preconditions.checkNotNull(pipeline, "pipeline");
	Preconditions.checkNotNull(timer, "timer");
	Preconditions.checkNotNull(debugCounters, "debugCounters");

	this.pipeline = pipeline;
	this.debugCounters = debugCounters;
	this.newConnectionListener = newConnectionListener;
	this.counters = switchManager.getCounters();
	this.state = new InitState();
	this.timer = timer;
	this.ofBitmaps = ofBitmaps;
	this.factory = defaultFactory;

	log.debug("constructor on OFChannelHandler {}", String.format("%08x", System.identityHashCode(this)));
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:42,代码来源:OFChannelHandler.java

示例12: computeInitialFactory

import org.projectfloodlight.openflow.protocol.OFFactory; //导入依赖的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

示例13: OFConnection

import org.projectfloodlight.openflow.protocol.OFFactory; //导入依赖的package包/类
public OFConnection(@Nonnull DatapathId dpid,
                    @Nonnull OFFactory factory,
                    @Nonnull Channel channel,
                    @Nonnull OFAuxId auxId,
                    @Nonnull IDebugCounterService debugCounters,
                    @Nonnull Timer timer) {
    Preconditions.checkNotNull(dpid, "dpid");
    Preconditions.checkNotNull(factory, "factory");
    Preconditions.checkNotNull(channel, "channel");
    Preconditions.checkNotNull(timer, "timer");
    Preconditions.checkNotNull(debugCounters);

    this.listener = NullConnectionListener.INSTANCE;
    this.dpid = dpid;
    this.factory = factory;
    this.channel = channel;
    this.auxId = auxId;
    this.connectedSince = new Date();
    this.xidDeliverableMap = new ConcurrentHashMap<>();
    this.counters = new OFConnectionCounters(debugCounters, dpid, this.auxId);
    this.timer = timer;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:23,代码来源:OFConnection.java

示例14: dumpFlowTable

import org.projectfloodlight.openflow.protocol.OFFactory; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public OFFlowStatsReply dumpFlowTable(final DatapathId dpid) {
    OFFlowStatsReply values = null;
    IOFSwitch sw = ofSwitchService.getSwitch(dpid);
    if (sw == null) {
        throw new IllegalArgumentException(String.format("Switch %s was not found", dpid.toString()));
    }

    OFFactory ofFactory = sw.getOFFactory();
    OFFlowStatsRequest flowRequest = ofFactory.buildFlowStatsRequest()
            .setMatch(sw.getOFFactory().matchWildcardAll())
            .setTableId(TableId.ALL)
            .setOutPort(OFPort.ANY)
            .setOutGroup(OFGroup.ANY)
            .setCookieMask(U64.ZERO)
            .build();

    try {
        ListenableFuture<OFFlowStatsReply> future = sw.writeRequest(flowRequest);
        values = future.get(10, TimeUnit.SECONDS);
    } catch (ExecutionException | InterruptedException | TimeoutException e) {
        logger.error("Could not get flow stats: {}", e.getMessage());
    }

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

示例15: installMeter

import org.projectfloodlight.openflow.protocol.OFFactory; //导入依赖的package包/类
private ImmutablePair<Long, Boolean> installMeter(final IOFSwitch sw, final DatapathId dpid, final long bandwidth,
                                                 final long burstSize, final long meterId) {
    logger.debug("installing meter {} on switch {} width bandwidth {}", meterId, dpid, bandwidth);

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

    OFMeterBandDrop.Builder bandBuilder = ofFactory.meterBands()
            .buildDrop()
            .setRate(bandwidth)
            .setBurstSize(burstSize);

    OFMeterMod.Builder meterModBuilder = ofFactory.buildMeterMod()
            .setMeterId(meterId)
            .setCommand(OFMeterModCommand.ADD)
            .setFlags(flags);

    if (sw.getOFFactory().getVersion().compareTo(OF_13) > 0) {
        meterModBuilder.setBands(singletonList(bandBuilder.build()));
    } else {
        meterModBuilder.setMeters(singletonList(bandBuilder.build()));
    }

    OFMeterMod meterMod = meterModBuilder.build();

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


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