Java 类org.projectfloodlight.openflow.protocol.OFPortConfig 实例源码

项目:fast-failover-demo    文件:FastFailoverDemo.java   
private long portDown(IOFSwitch sw) {
    long config = 0;
    switch (sw.getOFFactory().getVersion()) {
    case OF_10:
        config = OFPortConfigSerializerVer10.toWireValue(Collections.singleton(OFPortConfig.PORT_DOWN));
        break;
    case OF_11:
        config = OFPortConfigSerializerVer11.toWireValue(Collections.singleton(OFPortConfig.PORT_DOWN));
        break;
    case OF_12:
        config = OFPortConfigSerializerVer12.toWireValue(Collections.singleton(OFPortConfig.PORT_DOWN));
        break;
    case OF_13:
        config = OFPortConfigSerializerVer13.toWireValue(Collections.singleton(OFPortConfig.PORT_DOWN));
        break;
    case OF_14:
        config = OFPortConfigSerializerVer14.toWireValue(Collections.singleton(OFPortConfig.PORT_DOWN));
        break;
    default:
        log.error("Bad OFVersion {}", sw.getOFFactory().getVersion().toString());
        break;
    }
    return config;
}
项目:ravikumaran201504    文件:OpenFlowLinkProvider.java   
@Override
public void portChanged(Dpid dpid, OFPortStatus status) {
    LinkDiscovery ld = discoverers.get(dpid);
    if (ld == null) {
        return;
    }
    final OFPortDesc port = status.getDesc();
    final boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN) &&
            !port.getConfig().contains(OFPortConfig.PORT_DOWN);
    if (enabled) {
        ld.addPort(port);
    } else {
        /*
         * remove port calls linkVanished
         */
        ld.removePort(port);
    }

}
项目:openflowj-otn    文件:OFPortConfigSerializerVer12.java   
public static int toWireValue(Set<OFPortConfig> set) {
    int wireValue = 0;

    for(OFPortConfig e: set) {
        switch(e) {
            case PORT_DOWN:
                wireValue |= PORT_DOWN_VAL;
                break;
            case NO_RECV:
                wireValue |= NO_RECV_VAL;
                break;
            case NO_FWD:
                wireValue |= NO_FWD_VAL;
                break;
            case NO_PACKET_IN:
                wireValue |= NO_PACKET_IN_VAL;
                break;
            case BSN_MIRROR_DEST:
                wireValue |= BSN_MIRROR_DEST_VAL;
                break;
            default:
                throw new IllegalArgumentException("Illegal enum value for type OFPortConfig in version 1.2: " + e);
        }
    }
    return wireValue;
}
项目:openflowj-otn    文件:OFPortConfigSerializerVer13.java   
public static int toWireValue(Set<OFPortConfig> set) {
    int wireValue = 0;

    for(OFPortConfig e: set) {
        switch(e) {
            case PORT_DOWN:
                wireValue |= PORT_DOWN_VAL;
                break;
            case NO_RECV:
                wireValue |= NO_RECV_VAL;
                break;
            case NO_FWD:
                wireValue |= NO_FWD_VAL;
                break;
            case NO_PACKET_IN:
                wireValue |= NO_PACKET_IN_VAL;
                break;
            case BSN_MIRROR_DEST:
                wireValue |= BSN_MIRROR_DEST_VAL;
                break;
            default:
                throw new IllegalArgumentException("Illegal enum value for type OFPortConfig in version 1.3: " + e);
        }
    }
    return wireValue;
}
项目:openflowj-otn    文件:OFPortConfigSerializerVer10.java   
public static Set<OFPortConfig> ofWireValue(int val) {
    EnumSet<OFPortConfig> set = EnumSet.noneOf(OFPortConfig.class);

    if((val & PORT_DOWN_VAL) != 0)
        set.add(OFPortConfig.PORT_DOWN);
    if((val & NO_STP_VAL) != 0)
        set.add(OFPortConfig.NO_STP);
    if((val & NO_RECV_VAL) != 0)
        set.add(OFPortConfig.NO_RECV);
    if((val & NO_RECV_STP_VAL) != 0)
        set.add(OFPortConfig.NO_RECV_STP);
    if((val & NO_FLOOD_VAL) != 0)
        set.add(OFPortConfig.NO_FLOOD);
    if((val & NO_FWD_VAL) != 0)
        set.add(OFPortConfig.NO_FWD);
    if((val & NO_PACKET_IN_VAL) != 0)
        set.add(OFPortConfig.NO_PACKET_IN);
    if((val & BSN_MIRROR_DEST_VAL) != 0)
        set.add(OFPortConfig.BSN_MIRROR_DEST);
    return Collections.unmodifiableSet(set);
}
项目:openflowj-otn    文件:OFPortConfigSerializerVer11.java   
public static int toWireValue(Set<OFPortConfig> set) {
    int wireValue = 0;

    for(OFPortConfig e: set) {
        switch(e) {
            case PORT_DOWN:
                wireValue |= PORT_DOWN_VAL;
                break;
            case NO_RECV:
                wireValue |= NO_RECV_VAL;
                break;
            case NO_FWD:
                wireValue |= NO_FWD_VAL;
                break;
            case NO_PACKET_IN:
                wireValue |= NO_PACKET_IN_VAL;
                break;
            case BSN_MIRROR_DEST:
                wireValue |= BSN_MIRROR_DEST_VAL;
                break;
            default:
                throw new IllegalArgumentException("Illegal enum value for type OFPortConfig in version 1.1: " + e);
        }
    }
    return wireValue;
}
项目:openflowj-otn    文件:OFPortConfigSerializerVer14.java   
public static int toWireValue(Set<OFPortConfig> set) {
    int wireValue = 0;

    for(OFPortConfig e: set) {
        switch(e) {
            case PORT_DOWN:
                wireValue |= PORT_DOWN_VAL;
                break;
            case NO_RECV:
                wireValue |= NO_RECV_VAL;
                break;
            case NO_FWD:
                wireValue |= NO_FWD_VAL;
                break;
            case NO_PACKET_IN:
                wireValue |= NO_PACKET_IN_VAL;
                break;
            case BSN_MIRROR_DEST:
                wireValue |= BSN_MIRROR_DEST_VAL;
                break;
            default:
                throw new IllegalArgumentException("Illegal enum value for type OFPortConfig in version 1.4: " + e);
        }
    }
    return wireValue;
}
项目:spring-open    文件:LinkDiscoveryManagerTest.java   
private OFPortDesc createMockPortWithState(short portNumber,
        Set<OFPortState> state) {
    OFPort ofPort = createMock(OFPort.class);
    expect(ofPort.getShortPortNumber()).andReturn(portNumber).anyTimes();

    OFPortDesc ofPortDesc = createMock(OFPortDesc.class);
    expect(ofPortDesc.getPortNo()).andReturn(ofPort).anyTimes();
    expect(ofPortDesc.getHwAddr()).andReturn(
            MacAddress.of(DEFAULT_MAC_ADDRESS)).anyTimes();
    expect(ofPortDesc.getConfig()).
            andReturn(Collections.<OFPortConfig>emptySet()).anyTimes();
    expect(ofPortDesc.getState()).andReturn(state).anyTimes();

    replay(ofPort);
    replay(ofPortDesc);

    return ofPortDesc;
}
项目:onos    文件:OpenFlowPowerConfig.java   
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;
}
项目:onos    文件:OpenFlowDeviceProvider.java   
/**
 * Build a portDescription from a given Ethernet port description.
 *
 * @param port the port to build from.
 * @return portDescription for the port.
 */
private PortDescription buildPortDescription(OFPortDesc port) {
    if (port.getVersion().wireVersion >= OFVersion.OF_14.getWireVersion()) {
        return buildPortDescription14(port);
    }
    PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
    boolean enabled =
            !port.getState().contains(OFPortState.LINK_DOWN) &&
                    !port.getConfig().contains(OFPortConfig.PORT_DOWN);
    Port.Type type = port.getCurr().contains(OFPortFeatures.PF_FIBER) ? FIBER : COPPER;
    boolean adminDown = port.getConfig().contains(OFPortConfig.PORT_DOWN);
    SparseAnnotations annotations = makePortAnnotation(port.getName(),
                                                       port.getHwAddr().toString(),
                                                       adminDown).build();
    return new DefaultPortDescription(portNo, enabled, type,
                                      portSpeed(port), annotations);
}
项目:loxigen-artifacts    文件:OFPortConfigSerializerVer12.java   
public static int toWireValue(Set<OFPortConfig> set) {
    int wireValue = 0;

    for(OFPortConfig e: set) {
        switch(e) {
            case PORT_DOWN:
                wireValue |= PORT_DOWN_VAL;
                break;
            case NO_RECV:
                wireValue |= NO_RECV_VAL;
                break;
            case NO_FWD:
                wireValue |= NO_FWD_VAL;
                break;
            case NO_PACKET_IN:
                wireValue |= NO_PACKET_IN_VAL;
                break;
            case BSN_MIRROR_DEST:
                wireValue |= BSN_MIRROR_DEST_VAL;
                break;
            default:
                throw new IllegalArgumentException("Illegal enum value for type OFPortConfig in version 1.2: " + e);
        }
    }
    return wireValue;
}
项目:loxigen-artifacts    文件:OFPortConfigSerializerVer13.java   
public static int toWireValue(Set<OFPortConfig> set) {
    int wireValue = 0;

    for(OFPortConfig e: set) {
        switch(e) {
            case PORT_DOWN:
                wireValue |= PORT_DOWN_VAL;
                break;
            case NO_RECV:
                wireValue |= NO_RECV_VAL;
                break;
            case NO_FWD:
                wireValue |= NO_FWD_VAL;
                break;
            case NO_PACKET_IN:
                wireValue |= NO_PACKET_IN_VAL;
                break;
            case BSN_MIRROR_DEST:
                wireValue |= BSN_MIRROR_DEST_VAL;
                break;
            default:
                throw new IllegalArgumentException("Illegal enum value for type OFPortConfig in version 1.3: " + e);
        }
    }
    return wireValue;
}
项目:loxigen-artifacts    文件:OFPortConfigSerializerVer10.java   
public static Set<OFPortConfig> ofWireValue(int val) {
    EnumSet<OFPortConfig> set = EnumSet.noneOf(OFPortConfig.class);

    if((val & PORT_DOWN_VAL) != 0)
        set.add(OFPortConfig.PORT_DOWN);
    if((val & NO_STP_VAL) != 0)
        set.add(OFPortConfig.NO_STP);
    if((val & NO_RECV_VAL) != 0)
        set.add(OFPortConfig.NO_RECV);
    if((val & NO_RECV_STP_VAL) != 0)
        set.add(OFPortConfig.NO_RECV_STP);
    if((val & NO_FLOOD_VAL) != 0)
        set.add(OFPortConfig.NO_FLOOD);
    if((val & NO_FWD_VAL) != 0)
        set.add(OFPortConfig.NO_FWD);
    if((val & NO_PACKET_IN_VAL) != 0)
        set.add(OFPortConfig.NO_PACKET_IN);
    if((val & BSN_MIRROR_DEST_VAL) != 0)
        set.add(OFPortConfig.BSN_MIRROR_DEST);
    return Collections.unmodifiableSet(set);
}
项目:loxigen-artifacts    文件:OFPortConfigSerializerVer15.java   
public static int toWireValue(Set<OFPortConfig> set) {
    int wireValue = 0;

    for(OFPortConfig e: set) {
        switch(e) {
            case PORT_DOWN:
                wireValue |= PORT_DOWN_VAL;
                break;
            case NO_RECV:
                wireValue |= NO_RECV_VAL;
                break;
            case NO_FWD:
                wireValue |= NO_FWD_VAL;
                break;
            case NO_PACKET_IN:
                wireValue |= NO_PACKET_IN_VAL;
                break;
            case BSN_MIRROR_DEST:
                wireValue |= BSN_MIRROR_DEST_VAL;
                break;
            default:
                throw new IllegalArgumentException("Illegal enum value for type OFPortConfig in version 1.5: " + e);
        }
    }
    return wireValue;
}
项目:loxigen-artifacts    文件:OFPortConfigSerializerVer11.java   
public static int toWireValue(Set<OFPortConfig> set) {
    int wireValue = 0;

    for(OFPortConfig e: set) {
        switch(e) {
            case PORT_DOWN:
                wireValue |= PORT_DOWN_VAL;
                break;
            case NO_RECV:
                wireValue |= NO_RECV_VAL;
                break;
            case NO_FWD:
                wireValue |= NO_FWD_VAL;
                break;
            case NO_PACKET_IN:
                wireValue |= NO_PACKET_IN_VAL;
                break;
            case BSN_MIRROR_DEST:
                wireValue |= BSN_MIRROR_DEST_VAL;
                break;
            default:
                throw new IllegalArgumentException("Illegal enum value for type OFPortConfig in version 1.1: " + e);
        }
    }
    return wireValue;
}
项目:loxigen-artifacts    文件:OFPortConfigSerializerVer14.java   
public static int toWireValue(Set<OFPortConfig> set) {
    int wireValue = 0;

    for(OFPortConfig e: set) {
        switch(e) {
            case PORT_DOWN:
                wireValue |= PORT_DOWN_VAL;
                break;
            case NO_RECV:
                wireValue |= NO_RECV_VAL;
                break;
            case NO_FWD:
                wireValue |= NO_FWD_VAL;
                break;
            case NO_PACKET_IN:
                wireValue |= NO_PACKET_IN_VAL;
                break;
            case BSN_MIRROR_DEST:
                wireValue |= BSN_MIRROR_DEST_VAL;
                break;
            default:
                throw new IllegalArgumentException("Illegal enum value for type OFPortConfig in version 1.4: " + e);
        }
    }
    return wireValue;
}
项目:loxigen-artifacts    文件:OFPortDescTest.java   
public void testIsEnabledForFactory(OFFactory factory) {
    // Default
    OFPortDesc desc = factory.buildPortDesc()
            .build();
    assertThat(desc.isEnabled(), is(true));

    // Partially disabled
    desc = factory.buildPortDesc()
            .setConfig(new HashSet<OFPortConfig>(Arrays.asList(OFPortConfig.PORT_DOWN)))
            .build();
    assertThat(desc.isEnabled(), is(false));

    // Fully disabled
    desc = factory.buildPortDesc()
            .setConfig(new HashSet<OFPortConfig>(Arrays.asList(OFPortConfig.PORT_DOWN)))
            .setState(new HashSet<OFPortState>(Arrays.asList(OFPortState.LINK_DOWN)))
            .build();
    assertThat(desc.isEnabled(), is(false));
}
项目:athena    文件:OpenFlowDeviceProvider.java   
private PortDescription buildOduCltPortDescription(OFPortDesc port) {
    PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
    boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN) &&
            !port.getConfig().contains(OFPortConfig.PORT_DOWN);
    Long portSpeedInMbps = portSpeed(port);
    CltSignalType sigType = null;

    switch (portSpeedInMbps.toString()) {
        case "1000":
            sigType = CltSignalType.CLT_1GBE;
            break;
        case "10000":
            sigType = CltSignalType.CLT_10GBE;
            break;
        case "40000":
            sigType = CltSignalType.CLT_40GBE;
            break;
        case "100000":
            sigType = CltSignalType.CLT_100GBE;
            break;
        default:
            throw new RuntimeException("Un recognize OduClt speed: " + portSpeedInMbps.toString());
    }

    SparseAnnotations annotations = buildOduCltAnnotation(port);
    return oduCltPortDescription(portNo, enabled, sigType, annotations);
}
项目:athena    文件:OpenFlowDeviceProvider.java   
/**
 * Build a portDescription from a given Ethernet port description.
 *
 * @param port the port to build from.
 * @return portDescription for the port.
 */
private PortDescription buildPortDescription(OFPortDesc port) {
    PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
    boolean enabled =
            !port.getState().contains(OFPortState.LINK_DOWN) &&
                    !port.getConfig().contains(OFPortConfig.PORT_DOWN);
    Port.Type type = port.getCurr().contains(OFPortFeatures.PF_FIBER) ? FIBER : COPPER;
    SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString());
    return new DefaultPortDescription(portNo, enabled, type,
            portSpeed(port), annotations);
}
项目:athena    文件:OpenFlowDeviceProvider.java   
/**
 * Build a portDescription from a given a port description describing some
 * Optical port.
 *
 * @param port description property type.
 * @param port the port to build from.
 * @return portDescription for the port.
 */
private PortDescription buildPortDescription(PortDescPropertyType ptype, OFPortOptical port) {
    checkArgument(port.getDesc().size() >= 1);

    // Minimally functional fixture. This needs to be fixed as we add better support.
    PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());

    boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN)
            && !port.getConfig().contains(OFPortConfig.PORT_DOWN);
    SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString());

    if (port.getVersion() == OFVersion.OF_13
            && ptype == PortDescPropertyType.OPTICAL_TRANSPORT) {
        // At this point, not much is carried in the optical port message.
        LOG.debug("Optical transport port message {}", port.toString());
    } else {
        // removable once 1.4+ support complete.
        LOG.debug("Unsupported optical port properties");
    }

    OFPortDescPropOpticalTransport desc = port.getDesc().get(0);
    switch (desc.getPortSignalType()) {
        // FIXME: use constants once loxi has full optical extensions
        case 2:     // OMS port
            // Assume complete optical spectrum and 50 GHz grid
            // LINC-OE is only supported optical OF device for now
            return omsPortDescription(portNo, enabled,
                    Spectrum.U_BAND_MIN, Spectrum.O_BAND_MAX, Frequency.ofGHz(50), annotations);
        case 5:     // OCH port
            OchSignal signal = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 0, 4);
            return ochPortDescription(portNo, enabled, OduSignalType.ODU4,
                    true, signal, annotations);
        default:
            break;
    }

    return new DefaultPortDescription(portNo, enabled, FIBER, 0, annotations);
}
项目:fresco_floodlight    文件:OFSwitch.java   
/**
 * Set the internal data structure storing this switch's port
 * to the ports specified by newPortsByNumber
 *
 * CALLER MUST HOLD WRITELOCK
 *
 * @param newPortsByNumber
 * @throws IllegaalStateException if called without holding the
 * writelock
 */
private void updatePortsWithNewPortsByNumber(
        Map<OFPort,OFPortDesc> newPortsByNumber) {
    if (!lock.writeLock().isHeldByCurrentThread()) {
        throw new IllegalStateException("Method called without " +
                "holding writeLock");
    }
    Map<String,OFPortDesc> newPortsByName =
            new HashMap<String, OFPortDesc>();
    List<OFPortDesc> newPortList =
            new ArrayList<OFPortDesc>();
    List<OFPortDesc> newEnabledPortList =
            new ArrayList<OFPortDesc>();
    List<OFPort> newEnabledPortNumbers = new ArrayList<OFPort>();

    for(OFPortDesc p: newPortsByNumber.values()) {
        newPortList.add(p);
        newPortsByName.put(p.getName().toLowerCase(), p);
        if (!p.getState().contains(OFPortState.LINK_DOWN) 
                && !p.getConfig().contains(OFPortConfig.PORT_DOWN)) {
            if (!newEnabledPortList.contains(p)) {
                newEnabledPortList.add(p);
            }
            if (!newEnabledPortNumbers.contains(p.getPortNo())) {
                newEnabledPortNumbers.add(p.getPortNo());
            }
        }
    }
    portsByName = Collections.unmodifiableMap(newPortsByName);
    portsByNumber =
            Collections.unmodifiableMap(newPortsByNumber);
    enabledPortList =
            Collections.unmodifiableList(newEnabledPortList);
    enabledPortNumbers =
            Collections.unmodifiableList(newEnabledPortNumbers);
    portList = Collections.unmodifiableList(newPortList);
}
项目:iTAP-controller    文件:OFSwitch.java   
/**
 * Set the internal data structure storing this switch's port
 * to the ports specified by newPortsByNumber
 *
 * CALLER MUST HOLD WRITELOCK
 *
 * @param newPortsByNumber
 * @throws IllegaalStateException if called without holding the
 * writelock
 */
private void updatePortsWithNewPortsByNumber(
        Map<OFPort,OFPortDesc> newPortsByNumber) {
    if (!lock.writeLock().isHeldByCurrentThread()) {
        throw new IllegalStateException("Method called without " +
                "holding writeLock");
    }
    Map<String,OFPortDesc> newPortsByName =
            new HashMap<String, OFPortDesc>();
    List<OFPortDesc> newPortList =
            new ArrayList<OFPortDesc>();
    List<OFPortDesc> newEnabledPortList =
            new ArrayList<OFPortDesc>();
    List<OFPort> newEnabledPortNumbers = new ArrayList<OFPort>();

    for(OFPortDesc p: newPortsByNumber.values()) {
        newPortList.add(p);
        newPortsByName.put(p.getName().toLowerCase(), p);
        if (!p.getState().contains(OFPortState.LINK_DOWN) 
                && !p.getConfig().contains(OFPortConfig.PORT_DOWN)) {
            newEnabledPortList.add(p);
            newEnabledPortNumbers.add(p.getPortNo());
        }
    }
    portsByName = Collections.unmodifiableMap(newPortsByName);
    portsByNumber =
            Collections.unmodifiableMap(newPortsByNumber);
    enabledPortList =
            Collections.unmodifiableList(newEnabledPortList);
    enabledPortNumbers =
            Collections.unmodifiableList(newEnabledPortNumbers);
    portList = Collections.unmodifiableList(newPortList);
}
项目:SDN-Multicast    文件:OFSwitch.java   
/**
 * Set the internal data structure storing this switch's port
 * to the ports specified by newPortsByNumber
 *
 * CALLER MUST HOLD WRITELOCK
 *
 * @param newPortsByNumber
 * @throws IllegaalStateException if called without holding the
 * writelock
 */
private void updatePortsWithNewPortsByNumber(
        Map<OFPort,OFPortDesc> newPortsByNumber) {
    if (!lock.writeLock().isHeldByCurrentThread()) {
        throw new IllegalStateException("Method called without " +
                "holding writeLock");
    }
    Map<String,OFPortDesc> newPortsByName =
            new HashMap<String, OFPortDesc>();
    List<OFPortDesc> newPortList =
            new ArrayList<OFPortDesc>();
    List<OFPortDesc> newEnabledPortList =
            new ArrayList<OFPortDesc>();
    List<OFPort> newEnabledPortNumbers = new ArrayList<OFPort>();

    for(OFPortDesc p: newPortsByNumber.values()) {
        newPortList.add(p);
        newPortsByName.put(p.getName().toLowerCase(), p);
        if (!p.getState().contains(OFPortState.LINK_DOWN) 
                && !p.getConfig().contains(OFPortConfig.PORT_DOWN)) {
            if (!newEnabledPortList.contains(p)) {
                newEnabledPortList.add(p);
            }
            if (!newEnabledPortNumbers.contains(p.getPortNo())) {
                newEnabledPortNumbers.add(p.getPortNo());
            }
        }
    }
    portsByName = Collections.unmodifiableMap(newPortsByName);
    portsByNumber =
            Collections.unmodifiableMap(newPortsByNumber);
    enabledPortList =
            Collections.unmodifiableList(newEnabledPortList);
    enabledPortNumbers =
            Collections.unmodifiableList(newEnabledPortNumbers);
    portList = Collections.unmodifiableList(newPortList);
}
项目:arscheduler    文件:OFSwitch.java   
/**
 * Set the internal data structure storing this switch's port
 * to the ports specified by newPortsByNumber
 *
 * CALLER MUST HOLD WRITELOCK
 *
 * @param newPortsByNumber
 * @throws IllegaalStateException if called without holding the
 * writelock
 */
private void updatePortsWithNewPortsByNumber(
        Map<OFPort,OFPortDesc> newPortsByNumber) {
    if (!lock.writeLock().isHeldByCurrentThread()) {
        throw new IllegalStateException("Method called without " +
                "holding writeLock");
    }
    Map<String,OFPortDesc> newPortsByName =
            new HashMap<String, OFPortDesc>();
    List<OFPortDesc> newPortList =
            new ArrayList<OFPortDesc>();
    List<OFPortDesc> newEnabledPortList =
            new ArrayList<OFPortDesc>();
    List<OFPort> newEnabledPortNumbers = new ArrayList<OFPort>();

    for(OFPortDesc p: newPortsByNumber.values()) {
        newPortList.add(p);
        newPortsByName.put(p.getName().toLowerCase(), p);
        if (!p.getState().contains(OFPortState.LINK_DOWN) 
                && !p.getConfig().contains(OFPortConfig.PORT_DOWN)) {
            if (!newEnabledPortList.contains(p)) {
                newEnabledPortList.add(p);
            }
            if (!newEnabledPortNumbers.contains(p.getPortNo())) {
                newEnabledPortNumbers.add(p.getPortNo());
            }
        }
    }
    portsByName = Collections.unmodifiableMap(newPortsByName);
    portsByNumber =
            Collections.unmodifiableMap(newPortsByNumber);
    enabledPortList =
            Collections.unmodifiableList(newEnabledPortList);
    enabledPortNumbers =
            Collections.unmodifiableList(newEnabledPortNumbers);
    portList = Collections.unmodifiableList(newPortList);
}
项目:floodlight1.2-delay    文件:OFSwitch.java   
/**
 * Set the internal data structure storing this switch's port
 * to the ports specified by newPortsByNumber
 *
 * CALLER MUST HOLD WRITELOCK
 *
 * @param newPortsByNumber
 * @throws IllegaalStateException if called without holding the
 * writelock
 */
private void updatePortsWithNewPortsByNumber(
        Map<OFPort,OFPortDesc> newPortsByNumber) {
    if (!lock.writeLock().isHeldByCurrentThread()) {
        throw new IllegalStateException("Method called without " +
                "holding writeLock");
    }
    Map<String,OFPortDesc> newPortsByName =
            new HashMap<String, OFPortDesc>();
    List<OFPortDesc> newPortList =
            new ArrayList<OFPortDesc>();
    List<OFPortDesc> newEnabledPortList =
            new ArrayList<OFPortDesc>();
    List<OFPort> newEnabledPortNumbers = new ArrayList<OFPort>();

    for(OFPortDesc p: newPortsByNumber.values()) {
        newPortList.add(p);
        newPortsByName.put(p.getName().toLowerCase(), p);
        if (!p.getState().contains(OFPortState.LINK_DOWN) 
                && !p.getConfig().contains(OFPortConfig.PORT_DOWN)) {
            if (!newEnabledPortList.contains(p)) {
                newEnabledPortList.add(p);
            }
            if (!newEnabledPortNumbers.contains(p.getPortNo())) {
                newEnabledPortNumbers.add(p.getPortNo());
            }
        }
    }
    portsByName = Collections.unmodifiableMap(newPortsByName);
    portsByNumber =
            Collections.unmodifiableMap(newPortsByNumber);
    enabledPortList =
            Collections.unmodifiableList(newEnabledPortList);
    enabledPortNumbers =
            Collections.unmodifiableList(newEnabledPortNumbers);
    portList = Collections.unmodifiableList(newPortList);
}
项目:floodlight-hardware    文件:OFSwitch.java   
/**
 * Set the internal data structure storing this switch's port
 * to the ports specified by newPortsByNumber
 *
 * CALLER MUST HOLD WRITELOCK
 *
 * @param newPortsByNumber
 * @throws IllegaalStateException if called without holding the
 * writelock
 */
private void updatePortsWithNewPortsByNumber(
        Map<OFPort,OFPortDesc> newPortsByNumber) {
    if (!lock.writeLock().isHeldByCurrentThread()) {
        throw new IllegalStateException("Method called without " +
                "holding writeLock");
    }
    Map<String,OFPortDesc> newPortsByName =
            new HashMap<String, OFPortDesc>();
    List<OFPortDesc> newPortList =
            new ArrayList<OFPortDesc>();
    List<OFPortDesc> newEnabledPortList =
            new ArrayList<OFPortDesc>();
    List<OFPort> newEnabledPortNumbers = new ArrayList<OFPort>();

    for(OFPortDesc p: newPortsByNumber.values()) {
        newPortList.add(p);
        newPortsByName.put(p.getName().toLowerCase(), p);
        if (!p.getState().contains(OFPortState.LINK_DOWN)
                && !p.getConfig().contains(OFPortConfig.PORT_DOWN)) {
            if (!newEnabledPortList.contains(p)) {
                newEnabledPortList.add(p);
            }
            if (!newEnabledPortNumbers.contains(p.getPortNo())) {
                newEnabledPortNumbers.add(p.getPortNo());
            }
        }
    }
    portsByName = Collections.unmodifiableMap(newPortsByName);
    portsByNumber =
            Collections.unmodifiableMap(newPortsByNumber);
    enabledPortList =
            Collections.unmodifiableList(newEnabledPortList);
    enabledPortNumbers =
            Collections.unmodifiableList(newEnabledPortNumbers);
    portList = Collections.unmodifiableList(newPortList);
}
项目:ACAMPController    文件:OFSwitch.java   
/**
 * Set the internal data structure storing this switch's port
 * to the ports specified by newPortsByNumber
 *
 * CALLER MUST HOLD WRITELOCK
 *
 * @param newPortsByNumber
 * @throws IllegaalStateException if called without holding the
 * writelock
 */
private void updatePortsWithNewPortsByNumber(
        Map<OFPort,OFPortDesc> newPortsByNumber) {
    if (!lock.writeLock().isHeldByCurrentThread()) {
        throw new IllegalStateException("Method called without " +
                "holding writeLock");
    }
    Map<String,OFPortDesc> newPortsByName =
            new HashMap<String, OFPortDesc>();
    List<OFPortDesc> newPortList =
            new ArrayList<OFPortDesc>();
    List<OFPortDesc> newEnabledPortList =
            new ArrayList<OFPortDesc>();
    List<OFPort> newEnabledPortNumbers = new ArrayList<OFPort>();

    for(OFPortDesc p: newPortsByNumber.values()) {
        newPortList.add(p);
        newPortsByName.put(p.getName().toLowerCase(), p);
        if (!p.getState().contains(OFPortState.LINK_DOWN) 
                && !p.getConfig().contains(OFPortConfig.PORT_DOWN)) {
            if (!newEnabledPortList.contains(p)) {
                newEnabledPortList.add(p);
            }
            if (!newEnabledPortNumbers.contains(p.getPortNo())) {
                newEnabledPortNumbers.add(p.getPortNo());
            }
        }
    }
    portsByName = Collections.unmodifiableMap(newPortsByName);
    portsByNumber =
            Collections.unmodifiableMap(newPortsByNumber);
    enabledPortList =
            Collections.unmodifiableList(newEnabledPortList);
    enabledPortNumbers =
            Collections.unmodifiableList(newEnabledPortNumbers);
    portList = Collections.unmodifiableList(newPortList);
}
项目:fast-failover-demo    文件:OFSwitch.java   
/**
 * Set the internal data structure storing this switch's port
 * to the ports specified by newPortsByNumber
 *
 * CALLER MUST HOLD WRITELOCK
 *
 * @param newPortsByNumber
 * @throws IllegaalStateException if called without holding the
 * writelock
 */
private void updatePortsWithNewPortsByNumber(
        Map<OFPort,OFPortDesc> newPortsByNumber) {
    if (!lock.writeLock().isHeldByCurrentThread()) {
        throw new IllegalStateException("Method called without " +
                "holding writeLock");
    }
    Map<String,OFPortDesc> newPortsByName =
            new HashMap<String, OFPortDesc>();
    List<OFPortDesc> newPortList =
            new ArrayList<OFPortDesc>();
    List<OFPortDesc> newEnabledPortList =
            new ArrayList<OFPortDesc>();
    List<OFPort> newEnabledPortNumbers = new ArrayList<OFPort>();

    for(OFPortDesc p: newPortsByNumber.values()) {
        newPortList.add(p);
        newPortsByName.put(p.getName().toLowerCase(), p);
        if (!p.getState().contains(OFPortState.LINK_DOWN) 
                && !p.getConfig().contains(OFPortConfig.PORT_DOWN)) {
            newEnabledPortList.add(p);
            newEnabledPortNumbers.add(p.getPortNo());
        }
    }
    portsByName = Collections.unmodifiableMap(newPortsByName);
    portsByNumber =
            Collections.unmodifiableMap(newPortsByNumber);
    enabledPortList =
            Collections.unmodifiableList(newEnabledPortList);
    enabledPortNumbers =
            Collections.unmodifiableList(newEnabledPortNumbers);
    portList = Collections.unmodifiableList(newPortList);
}
项目:ravikumaran201504    文件:OpenFlowDeviceProvider.java   
/**
 * Build a portDescription from a given port.
 *
 * @param port the port to build from.
 * @return portDescription for the port.
 */
private PortDescription buildPortDescription(OFPortDesc port) {
    PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
    boolean enabled =
            !port.getState().contains(OFPortState.LINK_DOWN) &&
                    !port.getConfig().contains(OFPortConfig.PORT_DOWN);
    Port.Type type = port.getCurr().contains(OFPortFeatures.PF_FIBER) ? FIBER : COPPER;
    SparseAnnotations annotations = makePortNameAnnotation(port);
    return new DefaultPortDescription(portNo, enabled, type,
                                      portSpeed(port), annotations);
}
项目:ravikumaran201504    文件:OpenFlowLinkProviderTest.java   
private static OFPortDesc portDesc(int port, boolean up) {
    OFPortDesc.Builder builder = OFFactoryVer10.INSTANCE.buildPortDesc();
    builder.setPortNo(OFPort.of(port));
    if (!up) {
        builder.setConfig(Collections.singleton(OFPortConfig.PORT_DOWN));
    }
    return builder.build();
}
项目:floodlightLB    文件:OFSwitch.java   
/**
 * Set the internal data structure storing this switch's port
 * to the ports specified by newPortsByNumber
 *
 * CALLER MUST HOLD WRITELOCK
 *
 * @param newPortsByNumber
 * @throws IllegaalStateException if called without holding the
 * writelock
 */
private void updatePortsWithNewPortsByNumber(
        Map<OFPort,OFPortDesc> newPortsByNumber) {
    if (!lock.writeLock().isHeldByCurrentThread()) {
        throw new IllegalStateException("Method called without " +
                "holding writeLock");
    }
    Map<String,OFPortDesc> newPortsByName =
            new HashMap<String, OFPortDesc>();
    List<OFPortDesc> newPortList =
            new ArrayList<OFPortDesc>();
    List<OFPortDesc> newEnabledPortList =
            new ArrayList<OFPortDesc>();
    List<OFPort> newEnabledPortNumbers = new ArrayList<OFPort>();

    for(OFPortDesc p: newPortsByNumber.values()) {
        newPortList.add(p);
        newPortsByName.put(p.getName().toLowerCase(), p);
        if (!p.getState().contains(OFPortState.LINK_DOWN) 
                && !p.getConfig().contains(OFPortConfig.PORT_DOWN)) {
            if (!newEnabledPortList.contains(p)) {
                newEnabledPortList.add(p);
            }
            if (!newEnabledPortNumbers.contains(p.getPortNo())) {
                newEnabledPortNumbers.add(p.getPortNo());
            }
        }
    }
    portsByName = Collections.unmodifiableMap(newPortsByName);
    portsByNumber =
            Collections.unmodifiableMap(newPortsByNumber);
    enabledPortList =
            Collections.unmodifiableList(newEnabledPortList);
    enabledPortNumbers =
            Collections.unmodifiableList(newEnabledPortNumbers);
    portList = Collections.unmodifiableList(newPortList);
}
项目:DSC    文件:OFSwitch.java   
/**
 * Set the internal data structure storing this switch's port
 * to the ports specified by newPortsByNumber
 *  设置一个内部数据结构来储存这个交换机端口根据新端口号
 * CALLER MUST HOLD WRITELOCK
 *
 * @param newPortsByNumber
 * @throws IllegaalStateException if called without holding the
 * writelock
 */
private void updatePortsWithNewPortsByNumber(
        Map<OFPort,OFPortDesc> newPortsByNumber) {
    if (!lock.writeLock().isHeldByCurrentThread()) {
        throw new IllegalStateException("Method called without " +
                "holding writeLock");
    }
    Map<String,OFPortDesc> newPortsByName =
            new HashMap<String, OFPortDesc>();
    List<OFPortDesc> newPortList =
            new ArrayList<OFPortDesc>();
    List<OFPortDesc> newEnabledPortList =
            new ArrayList<OFPortDesc>();
    List<OFPort> newEnabledPortNumbers = new ArrayList<OFPort>();

    for(OFPortDesc p: newPortsByNumber.values()) {
        newPortList.add(p);
        newPortsByName.put(p.getName().toLowerCase(), p);
        if (!p.getState().contains(OFPortState.LINK_DOWN) 
                && !p.getConfig().contains(OFPortConfig.PORT_DOWN)) {
            newEnabledPortList.add(p);
            newEnabledPortNumbers.add(p.getPortNo());
        }
    }
    portsByName = Collections.unmodifiableMap(newPortsByName);
    portsByNumber =
            Collections.unmodifiableMap(newPortsByNumber);
    enabledPortList =
            Collections.unmodifiableList(newEnabledPortList);
    enabledPortNumbers =
            Collections.unmodifiableList(newEnabledPortNumbers);
    portList = Collections.unmodifiableList(newPortList);
}
项目:floodlight    文件:OFSwitch.java   
/**
 * Set the internal data structure storing this switch's port
 * to the ports specified by newPortsByNumber
 *
 * CALLER MUST HOLD WRITELOCK
 *
 * @param newPortsByNumber
 * @throws IllegaalStateException if called without holding the
 * writelock
 */
private void updatePortsWithNewPortsByNumber(
        Map<OFPort,OFPortDesc> newPortsByNumber) {
    if (!lock.writeLock().isHeldByCurrentThread()) {
        throw new IllegalStateException("Method called without " +
                                        "holding writeLock");
    }
    Map<String,OFPortDesc> newPortsByName =
            new HashMap<String, OFPortDesc>();
    List<OFPortDesc> newPortList =
            new ArrayList<OFPortDesc>();
    List<OFPortDesc> newEnabledPortList =
            new ArrayList<OFPortDesc>();
    List<OFPort> newEnabledPortNumbers = new ArrayList<OFPort>();

    for(OFPortDesc p: newPortsByNumber.values()) {
        newPortList.add(p);
        newPortsByName.put(p.getName().toLowerCase(), p);
        if (!p.getState().contains(OFPortState.LINK_DOWN) 
                && !p.getConfig().contains(OFPortConfig.PORT_DOWN)) {
            newEnabledPortList.add(p);
            newEnabledPortNumbers.add(p.getPortNo());
        }
    }
    portsByName = Collections.unmodifiableMap(newPortsByName);
    portsByNumber =
            Collections.unmodifiableMap(newPortsByNumber);
    enabledPortList =
            Collections.unmodifiableList(newEnabledPortList);
    enabledPortNumbers =
            Collections.unmodifiableList(newEnabledPortNumbers);
    portList = Collections.unmodifiableList(newPortList);
}
项目:openflowj-otn    文件:OFPortConfigSerializerVer12.java   
public static Set<OFPortConfig> readFrom(ChannelBuffer bb) throws OFParseError {
    try {
        return ofWireValue(bb.readInt());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:openflowj-otn    文件:OFPortConfigSerializerVer12.java   
public static Set<OFPortConfig> ofWireValue(int val) {
    EnumSet<OFPortConfig> set = EnumSet.noneOf(OFPortConfig.class);

    if((val & PORT_DOWN_VAL) != 0)
        set.add(OFPortConfig.PORT_DOWN);
    if((val & NO_RECV_VAL) != 0)
        set.add(OFPortConfig.NO_RECV);
    if((val & NO_FWD_VAL) != 0)
        set.add(OFPortConfig.NO_FWD);
    if((val & NO_PACKET_IN_VAL) != 0)
        set.add(OFPortConfig.NO_PACKET_IN);
    if((val & BSN_MIRROR_DEST_VAL) != 0)
        set.add(OFPortConfig.BSN_MIRROR_DEST);
    return Collections.unmodifiableSet(set);
}
项目:openflowj-otn    文件:OFPortConfigSerializerVer13.java   
public static Set<OFPortConfig> readFrom(ChannelBuffer bb) throws OFParseError {
    try {
        return ofWireValue(bb.readInt());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:openflowj-otn    文件:OFPortConfigSerializerVer13.java   
public static Set<OFPortConfig> ofWireValue(int val) {
    EnumSet<OFPortConfig> set = EnumSet.noneOf(OFPortConfig.class);

    if((val & PORT_DOWN_VAL) != 0)
        set.add(OFPortConfig.PORT_DOWN);
    if((val & NO_RECV_VAL) != 0)
        set.add(OFPortConfig.NO_RECV);
    if((val & NO_FWD_VAL) != 0)
        set.add(OFPortConfig.NO_FWD);
    if((val & NO_PACKET_IN_VAL) != 0)
        set.add(OFPortConfig.NO_PACKET_IN);
    if((val & BSN_MIRROR_DEST_VAL) != 0)
        set.add(OFPortConfig.BSN_MIRROR_DEST);
    return Collections.unmodifiableSet(set);
}
项目:openflowj-otn    文件:OFPortConfigSerializerVer10.java   
public static Set<OFPortConfig> readFrom(ChannelBuffer bb) throws OFParseError {
    try {
        return ofWireValue(bb.readInt());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:openflowj-otn    文件:OFPortConfigSerializerVer10.java   
public static int toWireValue(Set<OFPortConfig> set) {
    int wireValue = 0;

    for(OFPortConfig e: set) {
        switch(e) {
            case PORT_DOWN:
                wireValue |= PORT_DOWN_VAL;
                break;
            case NO_STP:
                wireValue |= NO_STP_VAL;
                break;
            case NO_RECV:
                wireValue |= NO_RECV_VAL;
                break;
            case NO_RECV_STP:
                wireValue |= NO_RECV_STP_VAL;
                break;
            case NO_FLOOD:
                wireValue |= NO_FLOOD_VAL;
                break;
            case NO_FWD:
                wireValue |= NO_FWD_VAL;
                break;
            case NO_PACKET_IN:
                wireValue |= NO_PACKET_IN_VAL;
                break;
            case BSN_MIRROR_DEST:
                wireValue |= BSN_MIRROR_DEST_VAL;
                break;
            default:
                throw new IllegalArgumentException("Illegal enum value for type OFPortConfig in version 1.0: " + e);
        }
    }
    return wireValue;
}
项目:openflowj-otn    文件:OFPortConfigSerializerVer11.java   
public static Set<OFPortConfig> readFrom(ChannelBuffer bb) throws OFParseError {
    try {
        return ofWireValue(bb.readInt());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}