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


Java OFPortMod类代码示例

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


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

示例1: makePortMod

import org.projectfloodlight.openflow.protocol.OFPortMod; //导入依赖的package包/类
private OFPortMod.Builder makePortMod(OpenFlowSwitch sw, PortNumber portNumber,
                            boolean enable) {
    OFPortMod.Builder pmb = sw.factory().buildPortMod();
    OFPort port = OFPort.of((int) portNumber.toLong());
    pmb.setPortNo(port);
    Set<OFPortConfig> portConfig = EnumSet.noneOf(OFPortConfig.class);
    if (!enable) {
        portConfig.add(OFPortConfig.PORT_DOWN);
    }
    pmb.setConfig(portConfig);
    Set<OFPortConfig> portMask = EnumSet.noneOf(OFPortConfig.class);
    portMask.add(OFPortConfig.PORT_DOWN);
    pmb.setMask(portMask);
    pmb.setAdvertise(0x0);
    for (OFPortDesc pd : sw.getPorts()) {
        if (pd.getPortNo().equals(port)) {
            pmb.setHwAddr(pd.getHwAddr());
            break;
        }
    }
    return pmb;
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:23,代码来源:OpenFlowPowerConfig.java

示例2: changePortState

import org.projectfloodlight.openflow.protocol.OFPortMod; //导入依赖的package包/类
@Override
public void changePortState(DeviceId deviceId, PortNumber portNumber,
                            boolean enable) {
    final Dpid dpid = dpid(deviceId.uri());
    OpenFlowSwitch sw = controller.getSwitch(dpid);
    if (sw == null || !sw.isConnected()) {
        LOG.error("Failed to change portState on device {}", deviceId);
        return;
    }
    OFPortMod.Builder pmb = sw.factory().buildPortMod();
    OFPort port = OFPort.of((int) portNumber.toLong());
    pmb.setPortNo(port);
    if (enable) {
        pmb.setConfig(0x0); // port_down bit 0
    } else {
        pmb.setConfig(0x1); // port_down bit 1
    }
    pmb.setMask(0x1);
    pmb.setAdvertise(0x0);
    for (OFPortDesc pd : sw.getPorts()) {
        if (pd.getPortNo().equals(port)) {
            pmb.setHwAddr(pd.getHwAddr());
            break;
        }
    }
    sw.sendMsg(Collections.singletonList(pmb.build()));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:OpenFlowDeviceProvider.java

示例3: setPortTargetPower

import org.projectfloodlight.openflow.protocol.OFPortMod; //导入依赖的package包/类
private boolean setPortTargetPower(PortNumber port, long power) {
    DeviceId deviceId = handler().data().deviceId();
    final Dpid dpid = dpid(deviceId.uri());
    OpenFlowSwitch sw = handler().get(OpenFlowController.class).getSwitch(dpid);
    if (sw == null || !sw.isConnected()) {
        log.error("Failed to change port on device {}", deviceId);
        return false;
    }
    boolean enable = false;
    for (OFPortDesc pd : getPortDescs()) {
        if (pd.getPortNo().getPortNumber() == port.toLong()) {
            enable = pd.getConfig().contains(OFPortConfig.PORT_DOWN);
            break;
        }
    }
    OFPortMod.Builder pmb = makePortMod(sw, port, enable);
    long configure = OFOpticalPortFeaturesSerializerVer14.TX_PWR_VAL;
    OFPortModPropOptical.Builder property = sw.factory().buildPortModPropOptical();
    property.setTxPwr(power);

    List<OFPortModProp> properties = new ArrayList<>();
    properties.add(property.build());
    pmb.setProperties(properties);

    sw.sendMsg(Collections.singletonList(pmb.build()));
    // TODO: We would need to report false in case of port mod failure.
    return true;
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:29,代码来源:OpenFlowPowerConfig.java

示例4: changePortState

import org.projectfloodlight.openflow.protocol.OFPortMod; //导入依赖的package包/类
@Override
public void changePortState(DeviceId deviceId, PortNumber portNumber,
                            boolean enable) {
    final Dpid dpid = dpid(deviceId.uri());
    OpenFlowSwitch sw = controller.getSwitch(dpid);
    if (sw == null || !sw.isConnected()) {
        LOG.error("Failed to change portState on device {}", deviceId);
        return;
    }
    OFPortMod.Builder pmb = sw.factory().buildPortMod();
    OFPort port = OFPort.of((int) portNumber.toLong());
    pmb.setPortNo(port);
    Set<OFPortConfig> portConfig = EnumSet.noneOf(OFPortConfig.class);
    if (!enable) {
        portConfig.add(OFPortConfig.PORT_DOWN);
    }
    pmb.setConfig(portConfig);
    Set<OFPortConfig> portMask = EnumSet.noneOf(OFPortConfig.class);
    portMask.add(OFPortConfig.PORT_DOWN);
    pmb.setMask(portMask);
    pmb.setAdvertise(0x0);
    for (OFPortDesc pd : sw.getPorts()) {
        if (pd.getPortNo().equals(port)) {
            pmb.setHwAddr(pd.getHwAddr());
            break;
        }
    }
    sw.sendMsg(Collections.singletonList(pmb.build()));
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:30,代码来源:OpenFlowDeviceProvider.java

示例5: processPortMod

import org.projectfloodlight.openflow.protocol.OFPortMod; //导入依赖的package包/类
private void processPortMod(OFPortMod portMod) {
    // process specified port
    PortNumber portNumber = PortNumber.portNumber(portMod.getPortNo().getPortNumber());
    boolean disablePort = portMod.getConfig().contains(OFPortConfig.PORT_DOWN);
    log.debug("processing PORT_MOD message - setting port {} state to {}",
              portNumber, !disablePort);
    virtualNetworkAdminService.updatePortState(networkId, deviceId, portNumber, !disablePort);
    // TODO what side effects (e.g. cleaning flow mods) needs to be handled?
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:10,代码来源:DefaultOFSwitch.java

示例6: processControllerCommand

import org.projectfloodlight.openflow.protocol.OFPortMod; //导入依赖的package包/类
@Override
public void processControllerCommand(Channel channel, OFMessage msg) {

    OFControllerRole myRole = role(channel);
    if (OFControllerRole.ROLE_SLAVE.equals(myRole)) {
        OFBadRequestErrorMsg errorMsg = FACTORY.errorMsgs()
                .buildBadRequestErrorMsg()
                .setXid(msg.getXid())
                .setCode(OFBadRequestCode.IS_SLAVE)
                .build();
        channel.writeAndFlush(Collections.singletonList(errorMsg));
        return;
    }

    switch (msg.getType()) {
        case PORT_MOD:
            OFPortMod portMod = (OFPortMod) msg;
            processPortMod(portMod);
            break;
        case FLOW_MOD:
            OFFlowMod flowMod = (OFFlowMod) msg;
            processFlowMod(flowMod);
            break;
        case GROUP_MOD:
            OFGroupMod groupMod = (OFGroupMod) msg;
            processGroupMod(groupMod);
            break;
        case METER_MOD:
            OFMeterMod meterMod = (OFMeterMod) msg;
            processMeterMod(meterMod, channel);
            break;
        case TABLE_MOD:
            log.debug("processControllerCommand: {} not yet supported for {}",
                      msg.getType(), msg);
            break;
        default:
            log.warn("Unexpected message {} received for switch {}",
                     msg.getType(), this);
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:41,代码来源:DefaultOFSwitch.java

示例7: usePathA

import org.projectfloodlight.openflow.protocol.OFPortMod; //导入依赖的package包/类
private void usePathA() {
	/*
	 * Take down path B ports at sw1 and sw3
	 */
	IOFSwitch sw = switchService.getSwitch(dpid1);
	/* Set down */
	OFPortMod portMod = sw.getOFFactory().buildPortMod()
			.setPortNo(link_dpid1_to_dpid2b.getSrcPort())
			.setConfig(portDown(sw))
			.setMask(portDown(sw))
			.setHwAddr(sw.getPort(link_dpid1_to_dpid2b.getSrcPort()).getHwAddr())
			.build();
	sw.write(portMod);
	/* Set up */
	portMod = sw.getOFFactory().buildPortMod()
			.setPortNo(link_dpid1_to_dpid2a.getSrcPort())
			.setConfig(0)
			.setMask(portDown(sw))
			.setHwAddr(sw.getPort(link_dpid1_to_dpid2a.getSrcPort()).getHwAddr())
			.build();
	sw.write(portMod);
	
	sw = switchService.getSwitch(dpid3);
	/* Set down */
	portMod = sw.getOFFactory().buildPortMod()
			.setPortNo(link_dpid2b_to_dpid3.getDstPort())
			.setConfig(portDown(sw))
			.setMask(portDown(sw))
			.setHwAddr(sw.getPort(link_dpid2b_to_dpid3.getDstPort()).getHwAddr())
			.build();
	sw.write(portMod);
	/* Set up */
	portMod = sw.getOFFactory().buildPortMod()
			.setPortNo(link_dpid2a_to_dpid3.getDstPort())
			.setConfig(0)
			.setMask(portDown(sw))
			.setHwAddr(sw.getPort(link_dpid2a_to_dpid3.getDstPort()).getHwAddr())
			.build();
	sw.write(portMod);
	
	log.info("Took down ports on path sw1--sw2b--sw3 and brought up ports on sw1--sw2a--sw3");
}
 
开发者ID:rizard,项目名称:fast-failover-demo,代码行数:43,代码来源:FastFailoverDemo.java

示例8: usePathB

import org.projectfloodlight.openflow.protocol.OFPortMod; //导入依赖的package包/类
private void usePathB() {
	/*
	 * Take down path B ports at sw1 and sw3
	 */
	IOFSwitch sw = switchService.getSwitch(dpid1);
	/* Set down */
	OFPortMod portMod = sw.getOFFactory().buildPortMod()
			.setPortNo(link_dpid1_to_dpid2a.getSrcPort())
			.setConfig(portDown(sw))
			.setMask(portDown(sw))
			.setHwAddr(sw.getPort(link_dpid1_to_dpid2a.getSrcPort()).getHwAddr())
			.build();
	sw.write(portMod);
	/* Set up */
	portMod = sw.getOFFactory().buildPortMod()
			.setPortNo(link_dpid1_to_dpid2b.getSrcPort())
			.setConfig(0)
			.setMask(portDown(sw))
			.setHwAddr(sw.getPort(link_dpid1_to_dpid2b.getSrcPort()).getHwAddr())
			.build();
	sw.write(portMod);
	
	sw = switchService.getSwitch(dpid3);
	/* Set down */
	portMod = sw.getOFFactory().buildPortMod()
			.setPortNo(link_dpid2a_to_dpid3.getDstPort())
			.setConfig(portDown(sw))
			.setMask(portDown(sw))
			.setHwAddr(sw.getPort(link_dpid2a_to_dpid3.getDstPort()).getHwAddr())
			.build();
	sw.write(portMod);
	/* Set up */
	portMod = sw.getOFFactory().buildPortMod()
			.setPortNo(link_dpid2b_to_dpid3.getDstPort())
			.setConfig(0)
			.setMask(portDown(sw))
			.setHwAddr(sw.getPort(link_dpid2b_to_dpid3.getDstPort()).getHwAddr())
			.build();
	sw.write(portMod);
	
	log.info("Took down ports on path sw1--sw2a--sw3 and brought up ports on sw1--sw2b--sw3");
}
 
开发者ID:rizard,项目名称:fast-failover-demo,代码行数:43,代码来源:FastFailoverDemo.java


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