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


Java SwitchPort.getPort方法代码示例

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


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

示例1: makeHostSwitchLinkPair

import net.floodlightcontroller.devicemanager.SwitchPort; //导入方法依赖的package包/类
/**
 * Construct a link between a host and a switch
 * @param topoNodes
 * @param device
 * @param ap
 * @param switchMap
 * @param switchPortMap
 * @return the link which connects given device and access point
 */
public ArrayList<FlowLink> makeHostSwitchLinkPair(ArrayList<Node> topoNodes, IDevice device, SwitchPort ap, Map<DatapathId, IOFSwitch> switchMap, 
		HashMap<IOFSwitch, ArrayList<OFPortDesc>> switchPortMap){
	
	String deviceName = device.getMACAddressString();
			
	DatapathId switchId = ap.getSwitchDPID();
	String switchName = switchId.toString();
	
	IOFSwitch connectingSwitch = switchMap.get(switchId);
	ArrayList<OFPortDesc> ports = switchPortMap.get(connectingSwitch);
	
	OFPort portOnSwitch = ap.getPort();
	int switchPortNum = portOnSwitch.getPortNumber();
	
	String hostSwitchLinkName = "(" + deviceName + ", " + switchName + ")";
	String switchHostLinkName = "(" + switchName + ", " + deviceName + ")";
	

	Node src = getNodeWithName(topoNodes, deviceName);
	Node dst = getNodeWithName(topoNodes, switchName);
	
	Port srcP = src.getPortByID(1);
	Port dstP = dst.getPortByID(switchPortNum);
	
	long bandWidth = 0;
	
	for(OFPortDesc portDesc : ports){
		if(portDesc.getPortNo().equals(portOnSwitch)){
			bandWidth = convertBandwidth(portDesc.getCurrSpeed());
		}
	}
	
	ArrayList<FlowLink> hostSwitchLinks = new ArrayList<FlowLink>();
	hostSwitchLinks.add(new FlowLink(hostSwitchLinkName, src, dst, srcP, dstP, bandWidth));
	hostSwitchLinks.add(new FlowLink(switchHostLinkName, dst, src, dstP, srcP, bandWidth));
	
	return hostSwitchLinks;
}
 
开发者ID:DylanAPDavis,项目名称:arscheduler,代码行数:48,代码来源:TopologyBuilder.java

示例2: getSwitchPortVlanIds

import net.floodlightcontroller.devicemanager.SwitchPort; //导入方法依赖的package包/类
@Override
public Short[] getSwitchPortVlanIds(SwitchPort swp) {
    TreeSet<Short> vals = new TreeSet<Short>();
    for (Entity e : entities) {
        if (e.switchDPID == swp.getSwitchDPID()
                && e.switchPort == swp.getPort()) {
            if (e.getVlan() == null)
                vals.add(Ethernet.VLAN_UNTAGGED);
            else
                vals.add(e.getVlan());
        }
    }
    return vals.toArray(new Short[vals.size()]);
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:15,代码来源:Device.java

示例3: blockHost

import net.floodlightcontroller.devicemanager.SwitchPort; //导入方法依赖的package包/类
public static boolean blockHost(IOFSwitchService switchService,
		SwitchPort sw_tup, MacAddress host_mac, short hardTimeout, U64 cookie) {

	if (sw_tup == null) {
		return false;
	}

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

	OFPort inputPort = sw_tup.getPort();
	log.debug("blockHost sw={} port={} mac={}",
			new Object[] { sw, sw_tup.getPort(), host_mac.getLong() });

	// Create flow-mod based on packet-in and src-switch
	OFFlowMod.Builder fmb = sw.getOFFactory().buildFlowAdd();

	Match.Builder mb = sw.getOFFactory().buildMatch();
	List<OFAction> actions = new ArrayList<OFAction>(); // Set no action to drop
	mb.setExact(MatchField.IN_PORT, inputPort);
	if (host_mac.getLong() != -1L) {
		mb.setExact(MatchField.ETH_SRC, host_mac);
	}

	fmb.setCookie(cookie)
	.setHardTimeout(hardTimeout)
	.setIdleTimeout(FLOWMOD_DEFAULT_IDLE_TIMEOUT)
	.setPriority(FLOWMOD_DEFAULT_PRIORITY)
	.setBufferId(OFBufferId.NO_BUFFER)
	.setMatch(mb.build());
	
	FlowModUtils.setActions(fmb, actions, sw);

	log.debug("write drop flow-mod sw={} match={} flow-mod={}",
				new Object[] { sw, mb.build(), fmb.build() });
	// TODO: can't use the message damper since this method is static
	sw.write(fmb.build());
	
	return true;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:43,代码来源:ForwardingBase.java

示例4: blockHost

import net.floodlightcontroller.devicemanager.SwitchPort; //导入方法依赖的package包/类
@LogMessageDocs({
	@LogMessageDoc(level="ERROR",
			message="Failure writing deny flow mod",
			explanation="An I/O error occurred while writing a " +
					"deny flow mod to a switch",
					recommendation=LogMessageDoc.CHECK_SWITCH)
})
public static boolean blockHost(IOFSwitchService switchService,
		SwitchPort sw_tup, MacAddress host_mac, short hardTimeout, U64 cookie) {

	if (sw_tup == null) {
		return false;
	}

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

	OFPort inputPort = sw_tup.getPort();
	log.debug("blockHost sw={} port={} mac={}",
			new Object[] { sw, sw_tup.getPort(), host_mac.getLong() });

	// Create flow-mod based on packet-in and src-switch
	OFFlowMod.Builder fmb = sw.getOFFactory().buildFlowAdd();

	Match.Builder mb = sw.getOFFactory().buildMatch();
	List<OFAction> actions = new ArrayList<OFAction>(); // Set no action to drop
	mb.setExact(MatchField.IN_PORT, inputPort);
	if (host_mac.getLong() != -1L) {
		mb.setExact(MatchField.ETH_SRC, host_mac);
	}

	fmb.setCookie(cookie)
	.setHardTimeout(hardTimeout)
	.setIdleTimeout(FLOWMOD_DEFAULT_IDLE_TIMEOUT)
	.setPriority(FLOWMOD_DEFAULT_PRIORITY)
	.setBufferId(OFBufferId.NO_BUFFER)
	.setMatch(mb.build())
	.setActions(actions);

	log.debug("write drop flow-mod sw={} match={} flow-mod={}",
				new Object[] { sw, mb.build(), fmb.build() });
	// TODO: can't use the message damper sine this method is static
	sw.write(fmb.build());
	
	return true;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:49,代码来源:ForwardingBase.java

示例5: matches

import net.floodlightcontroller.devicemanager.SwitchPort; //导入方法依赖的package包/类
@Override
protected boolean matches(Device value) {
    boolean match;
    if (entityClasses != null) {
        IEntityClass clazz = value.getEntityClass();
        if (clazz == null) return false;

        match = false;
        for (IEntityClass entityClass : entityClasses) {
            if (clazz.equals(entityClass)) {
                match = true;
                break;
            }
        }
        if (!match) return false;                
    }
    if (macAddress != null) {
        if (macAddress.longValue() != value.getMACAddress())
            return false;
    }
    if (vlan != null) {
        Short[] vlans = value.getVlanId();
        if (Arrays.binarySearch(vlans, vlan) < 0) 
            return false;
    }
    if (ipv4Address != null) {
        Integer[] ipv4Addresses = value.getIPv4Addresses();
        if (Arrays.binarySearch(ipv4Addresses, ipv4Address) < 0) 
            return false;
    }
    if (switchDPID != null || switchPort != null) {
        SwitchPort[] sps = value.getAttachmentPoints();
        if (sps == null) return false;
        
        match = false;
        for (SwitchPort sp : sps) {
            if (switchDPID != null) {
                if (switchDPID.longValue() != sp.getSwitchDPID())
                    return false;
            }
            if (switchPort != null) {
                if (switchPort.intValue() != sp.getPort())
                    return false;
            }
            match = true;
            break;
        }
        if (!match) return false;
    }
    return true;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:52,代码来源:DeviceIterator.java

示例6: blockHost

import net.floodlightcontroller.devicemanager.SwitchPort; //导入方法依赖的package包/类
@LogMessageDocs({
    @LogMessageDoc(level="ERROR",
        message="Failure writing deny flow mod",
        explanation="An I/O error occurred while writing a " +
                "deny flow mod to a switch",
        recommendation=LogMessageDoc.CHECK_SWITCH)
})
public static boolean
        blockHost(IFloodlightProviderService floodlightProvider,
                  SwitchPort sw_tup, long host_mac,
                  short hardTimeout, long cookie) {

    if (sw_tup == null) {
        return false;
    }

    IOFSwitch sw =
            floodlightProvider.getSwitch(sw_tup.getSwitchDPID());
    if (sw == null) return false;
    int inputPort = sw_tup.getPort();
    log.debug("blockHost sw={} port={} mac={}",
              new Object[] { sw, sw_tup.getPort(), Long.valueOf(host_mac) });

    // Create flow-mod based on packet-in and src-switch
    OFFlowMod fm =
            (OFFlowMod) floodlightProvider.getOFMessageFactory()
                                          .getMessage(OFType.FLOW_MOD);
    OFMatch match = new OFMatch();
    List<OFAction> actions = new ArrayList<OFAction>(); // Set no action to
                                                        // drop
    match.setInputPort((short)inputPort);
    if (host_mac != -1L) {
        match.setDataLayerSource(Ethernet.toByteArray(host_mac))
            .setWildcards(OFMatch.OFPFW_ALL & ~OFMatch.OFPFW_DL_SRC
                           & ~OFMatch.OFPFW_IN_PORT);
    } else {
        match.setWildcards(OFMatch.OFPFW_ALL & ~OFMatch.OFPFW_IN_PORT);
    }
    fm.setCookie(cookie)
      .setHardTimeout(hardTimeout)
      .setIdleTimeout(FLOWMOD_DEFAULT_IDLE_TIMEOUT)
      .setBufferId(OFPacketOut.BUFFER_ID_NONE)
      .setMatch(match)
      .setActions(actions)
      .setLengthU(OFFlowMod.MINIMUM_LENGTH); // +OFActionOutput.MINIMUM_LENGTH);

    try {
        log.debug("write drop flow-mod sw={} match={} flow-mod={}",
                  new Object[] { sw, match, fm });
        // TODO: can't use the message damper sine this method is static
        sw.write(fm, null);
    } catch (IOException e) {
        log.error("Failure writing deny flow mod", e);
        return false;
    }
    return true;

}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:59,代码来源:ForwardingBase.java

示例7: blockHost

import net.floodlightcontroller.devicemanager.SwitchPort; //导入方法依赖的package包/类
public static boolean blockHost(IOFSwitchService switchService,
		SwitchPort sw_tup, MacAddress host_mac, short hardTimeout, U64 cookie) {

	if (sw_tup == null) {
		return false;
	}

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

	OFPort inputPort = sw_tup.getPort();
	log.debug("blockHost sw={} port={} mac={}",
			new Object[] { sw, sw_tup.getPort(), host_mac.getLong() });

	// Create flow-mod based on packet-in and src-switch
	OFFlowMod.Builder fmb = sw.getOFFactory().buildFlowAdd();

	Match.Builder mb = sw.getOFFactory().buildMatch();
	List<OFAction> actions = new ArrayList<OFAction>(); // Set no action to drop
	mb.setExact(MatchField.IN_PORT, inputPort);
	if (host_mac.getLong() != -1L) {
		mb.setExact(MatchField.ETH_SRC, host_mac);
	}

	fmb.setCookie(cookie)
	.setHardTimeout(hardTimeout)
	.setIdleTimeout(FLOWMOD_DEFAULT_IDLE_TIMEOUT)
	.setPriority(FLOWMOD_DEFAULT_PRIORITY)
	.setBufferId(OFBufferId.NO_BUFFER)
	.setMatch(mb.build());

	FlowModUtils.setActions(fmb, actions, sw);

	log.debug("write drop flow-mod sw={} match={} flow-mod={}",
				new Object[] { sw, mb.build(), fmb.build() });
	// TODO: can't use the message damper since this method is static
	sw.write(fmb.build());

	return true;
}
 
开发者ID:zhenshengcai,项目名称:floodlight-hardware,代码行数:43,代码来源:ForwardingBase.java


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