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


Java OFFlowMod类代码示例

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


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

示例1: installTransitFlow

import org.projectfloodlight.openflow.protocol.OFFlowMod; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public ImmutablePair<Long, Boolean> installTransitFlow(final DatapathId dpid, final String flowId,
                                                       final Long cookie, final int inputPort, final int outputPort,
                                                       final int transitVlanId) {
    List<OFAction> actionList = new ArrayList<>();
    IOFSwitch sw = ofSwitchService.getSwitch(dpid);

    // build match by input port and transit vlan id
    Match match = matchFlow(sw, inputPort, transitVlanId);

    // transmit packet from outgoing port
    actionList.add(actionSetOutputPort(sw, outputPort));

    // build instruction with action list
    OFInstructionApplyActions actions = buildInstructionApplyActions(sw, actionList);

    // build FLOW_MOD command, no meter
    OFFlowMod flowMod = buildFlowMod(sw, match, null, actions,
            cookie & FLOW_COOKIE_MASK, FlowModUtils.PRIORITY_VERY_HIGH);

    // send FLOW_MOD to the switch
    boolean response = pushFlow(flowId, dpid, flowMod);
    return new ImmutablePair<>(flowMod.getXid(), response);
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:28,代码来源:SwitchManager.java

示例2: buildFlowMod

import org.projectfloodlight.openflow.protocol.OFFlowMod; //导入依赖的package包/类
/**
 * Create an OFFlowMod that can be passed to StaticEntryPusher.
 *
 * @param sw       switch object
 * @param match    match for the flow
 * @param meter    meter for the flow
 * @param actions  actions for the flow
 * @param cookie   cookie for the flow
 * @param priority priority to set on the flow
 * @return {@link OFFlowMod}
 */
private OFFlowMod buildFlowMod(final IOFSwitch sw, final Match match, final OFInstructionMeter meter,
                               final OFInstructionApplyActions actions, final long cookie, final int priority) {
    OFFlowMod.Builder fmb = sw.getOFFactory().buildFlowAdd();
    fmb.setIdleTimeout(FlowModUtils.INFINITE_TIMEOUT);
    fmb.setHardTimeout(FlowModUtils.INFINITE_TIMEOUT);
    fmb.setBufferId(OFBufferId.NO_BUFFER);
    fmb.setCookie(U64.of(cookie));
    fmb.setPriority(priority);
    List<OFInstruction> instructions = new ArrayList<>(2);

    if (meter != null) {              // If no meter then no bandwidth limit
        instructions.add(meter);
    }

    if (actions != null) {       // If no instruction then Drops packet
        instructions.add(actions);
    }

    if (match != null) {              // If no then match everything
        fmb.setMatch(match);
    }

    return fmb.setInstructions(instructions).build();
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:36,代码来源:SwitchManager.java

示例3: installVerificationRule

import org.projectfloodlight.openflow.protocol.OFFlowMod; //导入依赖的package包/类
/**
 * Installs the verification rule
 *
 * @param dpid        datapathId of switch
 * @param isBroadcast if broadcast then set a generic match; else specific to switch Id
 * @return true if the command is accepted to be sent to switch, false otherwise - switch is disconnected or in
 * SLAVE mode
 */
private boolean installVerificationRule(final DatapathId dpid, final boolean isBroadcast) {
    IOFSwitch sw = ofSwitchService.getSwitch(dpid);

    Match match = matchVerification(sw, isBroadcast);
    ArrayList<OFAction> actionList = new ArrayList<>(2);
    actionList.add(actionSendToController(sw));
    actionList.add(actionSetDstMac(sw, dpidToMac(sw)));
    OFInstructionApplyActions instructionApplyActions = sw.getOFFactory().instructions()
            .applyActions(actionList).createBuilder().build();
    final long cookie = isBroadcast ? 0x8000000000000002L : 0x8000000000000003L;
    OFFlowMod flowMod = buildFlowMod(sw, match, null, instructionApplyActions,
            cookie, FlowModUtils.PRIORITY_VERY_HIGH);
    String flowname = (isBroadcast) ? "Broadcast" : "Unicast";
    flowname += "--VerificationFlow--" + dpid.toString();
    return pushFlow(flowname, dpid, flowMod);
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:25,代码来源:SwitchManager.java

示例4: sendMsg

import org.projectfloodlight.openflow.protocol.OFFlowMod; //导入依赖的package包/类
@Override
public void sendMsg(OFMessage msg) {
    // Ignore everything but flow mods and stat requests
    if (!(msg instanceof OFFlowMod || msg instanceof OFFlowStatsRequest)) {
        super.sendMsg(msg);
        return;
    }

    Match newMatch;
    OFMessage newMsg = null;

    if (msg instanceof OFFlowStatsRequest) {
        // Rewrite match only
        OFFlowStatsRequest fsr = (OFFlowStatsRequest) msg;
        newMatch = rewriteMatch(fsr.getMatch());
        newMsg = fsr.createBuilder().setMatch(newMatch).build();
    } else if (msg instanceof OFFlowMod) {
        // Rewrite match and actions
        OFFlowMod fm = (OFFlowMod) msg;
        newMatch = rewriteMatch(fm.getMatch());
        List<OFAction> actions = rewriteActions(fm.getActions());
        newMsg = fm.createBuilder().setMatch(newMatch).setActions(actions).build();
    }

    super.sendMsg(newMsg);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:OfOpticalSwitchImplLinc13.java

示例5: buildFlowDel

import org.projectfloodlight.openflow.protocol.OFFlowMod; //导入依赖的package包/类
@Override
public OFFlowMod buildFlowDel() {
    Match match = buildMatch();

    long cookie = flowRule().id().value();

    OFFlowDeleteStrict fm = factory().buildFlowDeleteStrict()
            .setXid(xid)
            .setCookie(U64.of(cookie))
            .setBufferId(OFBufferId.NO_BUFFER)
            .setMatch(match)
            .setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM))
            .setPriority(flowRule().priority())
            .setTableId(TableId.of(flowRule().tableId()))
            .build();

    return fm;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:FlowModBuilderVer13.java

示例6: buildFlowMod

import org.projectfloodlight.openflow.protocol.OFFlowMod; //导入依赖的package包/类
@Override
public OFFlowMod buildFlowMod() {
    Match match = buildMatch();
    List<OFAction> actions = buildActions();

    long cookie = flowRule().id().value();

    OFFlowMod fm = factory().buildFlowModify()
            .setXid(xid)
            .setCookie(U64.of(cookie))
            .setBufferId(OFBufferId.NO_BUFFER)
            .setActions(actions)
            .setMatch(match)
            .setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM))
            .setPriority(flowRule().priority())
            .build();

    return fm;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:FlowModBuilderVer10.java

示例7: createFRESCOFlowMod

import org.projectfloodlight.openflow.protocol.OFFlowMod; //导入依赖的package包/类
private OFFlowMod createFRESCOFlowMod(IOFSwitch sw, Match match, List<OFAction> actions, int priority){
	OFFlowMod.Builder fmb = sw.getOFFactory().buildFlowAdd();;
	
	fmb.setIdleTimeout(FlowModUtils.INFINITE_TIMEOUT);
	fmb.setHardTimeout(FlowModUtils.INFINITE_TIMEOUT);
	fmb.setBufferId(OFBufferId.NO_BUFFER);
	fmb.setOutPort(OFPort.ANY);
	fmb.setCookie(U64.of(0));  
	
	fmb.setPriority(U16.t(priority));
	fmb.setMatch(match);
	fmb.setActions(actions);
	
	return fmb.build();
	
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:17,代码来源:FP_FloodlightRTE.java

示例8: sendEntriesToSwitch

import org.projectfloodlight.openflow.protocol.OFFlowMod; //导入依赖的package包/类
/**
 * Reads from our entriesFromStorage for the specified switch and
 * sends the FlowMods down to the controller in <b>sorted</b> order.
 *
 * Sorted is important to maintain correctness of the switch:
 * if a packet would match both a lower and a higher priority
 * rule, then we want it to match the higher priority or nothing,
 * but never just the lower priority one.  Inserting from high to
 * low priority fixes this.
 *
 * TODO consider adding a "block all" flow mod and then removing it
 * while starting up.
 *
 * @param sw The switch to send entries to
 */
protected void sendEntriesToSwitch(DatapathId switchId) {
	IOFSwitch sw = switchService.getSwitch(switchId);
	if (sw == null)
		return;
	String stringId = sw.getId().toString();

	if ((entriesFromStorage != null) && (entriesFromStorage.containsKey(stringId))) {
		Map<String, OFFlowMod> entries = entriesFromStorage.get(stringId);
		List<String> sortedList = new ArrayList<String>(entries.keySet());
		// weird that Collections.sort() returns void
		Collections.sort( sortedList, new FlowModSorter(stringId));
		for (String entryName : sortedList) {
			OFFlowMod flowMod = entries.get(entryName);
			if (flowMod != null) {
				if (log.isDebugEnabled()) {
					log.debug("Pushing static entry {} for {}", stringId, entryName);
				}
				writeFlowModToSwitch(sw, flowMod);
			}
		}
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:38,代码来源:StaticFlowEntryPusher.java

示例9: readEntriesFromStorage

import org.projectfloodlight.openflow.protocol.OFFlowMod; //导入依赖的package包/类
/**
 * Read entries from storageSource, and store them in a hash
 *
 * @return
 */
private Map<String, Map<String, OFFlowMod>> readEntriesFromStorage() {
	Map<String, Map<String, OFFlowMod>> entries = new ConcurrentHashMap<String, Map<String, OFFlowMod>>();
	try {
		Map<String, Object> row;
		// null1=no predicate, null2=no ordering
		IResultSet resultSet = storageSourceService.executeQuery(TABLE_NAME, ColumnNames, null, null);
		for (Iterator<IResultSet> it = resultSet.iterator(); it.hasNext();) {
			row = it.next().getRow();
			parseRow(row, entries);
		}
	} catch (StorageException e) {
		log.error("failed to access storage: {}", e.getMessage());
		// if the table doesn't exist, then wait to populate later via
		// setStorageSource()
	}
	return entries;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:23,代码来源:StaticFlowEntryPusher.java

示例10: appendInstruction

import org.projectfloodlight.openflow.protocol.OFFlowMod; //导入依赖的package包/类
/** 
 * Adds the instructions to the list of OFInstructions in the OFFlowMod. Any pre-existing
 * instruction of the same type is replaced with OFInstruction inst.
 * @param fmb, the flow mod to append the instruction to
 * @param inst, the instuction to append
 */
public static void appendInstruction(OFFlowMod.Builder fmb, OFInstruction inst) {
	List<OFInstruction> newIl = new ArrayList<OFInstruction>();
	List<OFInstruction> oldIl = fmb.getInstructions();
	if (oldIl != null) { // keep any existing instructions that were added earlier
		newIl.addAll(fmb.getInstructions());
	}

	for (OFInstruction i : newIl) { // remove any duplicates. Only one of each instruction.
		if (i.getType() == inst.getType()) {
			newIl.remove(i);
		}
	}	
	newIl.add(inst);
	fmb.setInstructions(newIl);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:22,代码来源:InstructionUtils.java

示例11: gotoTableFromString

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

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

	OFInstructionGotoTable.Builder ib = OFFactories.getFactory(fmb.getVersion()).instructions().buildGotoTable();

	// Get the table ID
	if (inst.startsWith("0x")) {
		ib.setTableId(TableId.of(Integer.parseInt(inst.replaceFirst("0x", ""), 16)));
	} else {
		ib.setTableId(TableId.of(Integer.parseInt(inst))).build();
	}

	log.debug("Appending GotoTable instruction: {}", ib.build());
	appendInstruction(fmb, ib.build());
	log.debug("All instructions after append: {}", fmb.getInstructions());	
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:33,代码来源:InstructionUtils.java

示例12: clearActionsFromString

import org.projectfloodlight.openflow.protocol.OFFlowMod; //导入依赖的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:xuraylei,项目名称:fresco_floodlight,代码行数:26,代码来源:InstructionUtils.java

示例13: experimenterFromString

import org.projectfloodlight.openflow.protocol.OFFlowMod; //导入依赖的package包/类
/**
 * Convert the string representation of an OFInstructionExperimenter to
 * an OFInstructionExperimenter. 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 experimenterFromString(OFFlowMod.Builder fmb, String inst, Logger log) {
	/* TODO This is a no-op right now. */

	/*
	if (inst == null || inst.equals("")) {
		return; // TODO @Ryan quietly fail?
	}

	OFInstructionExperimenter.Builder ib = OFFactories.getFactory(fmb.getVersion()).instructions().buildExperimenter();

	String[] keyValue = inst.split("=");	
	if (keyValue.length != 2) {
		throw new IllegalArgumentException("[Key, Value] " + keyValue + " does not have form 'key=value' parsing " + inst);
	}
	switch (keyValue[0]) {
	case STR_SUB_GOTO_METER_METER_ID:
		ib.setExperimenter(Long.parseLong(keyValue[1]));
		break;
	default:
		log.error("Invalid String key for OFInstructionExperimenter: {}", keyValue[0]);
	}

	appendInstruction(fmb, ib.build());
	 */
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:35,代码来源:InstructionUtils.java

示例14: meterFromString

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

示例15: ListStaticFlowEntries

import org.projectfloodlight.openflow.protocol.OFFlowMod; //导入依赖的package包/类
@Get("json")
public OFFlowModMap ListStaticFlowEntries() {
    IStaticFlowEntryPusherService sfpService =
            (IStaticFlowEntryPusherService)getContext().getAttributes().
                get(IStaticFlowEntryPusherService.class.getCanonicalName());
    
    String param = (String) getRequestAttributes().get("switch");
    if (log.isDebugEnabled())
        log.debug("Listing all static flow entires for switch: " + param);
    
    if (param.toLowerCase().equals("all")) {
        return new OFFlowModMap(sfpService.getFlows());
    } else {
        try {
            Map<String, Map<String, OFFlowMod>> retMap = new HashMap<String, Map<String, OFFlowMod>>();
            retMap.put(param, sfpService.getFlows(DatapathId.of(param)));
            return new OFFlowModMap(retMap);
            
        } catch (NumberFormatException e){
            setStatus(Status.CLIENT_ERROR_BAD_REQUEST, ControllerSwitchesResource.DPID_ERROR);
        }
    }
    return null;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:25,代码来源:ListStaticFlowEntriesResource.java


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