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

项目:athena    文件:OpenFlowDeviceProvider.java   
/**
 * Build a portDescription from a given a port description describing some
 * Optical port.
 *
 * @param ptype description property type.
 * @param port  the port to build from.
 * @return portDescription for the port.
 */
private PortDescription buildPortDescription(PortDescPropertyType ptype, OFExpPort port) {
    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());

    OFExpPortDescPropOpticalTransport firstProp = port.getProperties().get(0);
    OFPortOpticalTransportSignalType sigType = firstProp.getPortSignalType();

    PortDescription portDes = null;
    switch (sigType) {
        case OMSN:
            portDes = omsPortDescription(portNo, enabled,
                    FREQ191_7, FREQ191_7.add(FREQ4_4), FREQ50, annotations);
            break;
        case OCH:
            OFExpPortOpticalTransportLayerEntry entry = firstProp.getFeatures().get(0).getValue().get(0);
            OFPortOpticalTransportLayerClass layerClass = entry.getLayerClass();
            if (!OFPortOpticalTransportLayerClass.ODU.equals(layerClass)) {
                LOG.error("Unsupported layer Class {} ", layerClass);
                return null;
            }

            // convert to ONOS OduSignalType
            OduSignalType oduSignalType = OpenFlowDeviceValueMapper.
                    lookupOduSignalType((byte) entry.getSignalType());
            //OchSignal is needed for OchPortDescription constructor,
            //yet not relevant for tunable OCH port, creating with default parameters
            OchSignal signalId = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 1, 1);

            portDes = ochPortDescription(portNo, enabled,
                    oduSignalType, true,
                    signalId, annotations);

            break;
        case OTU2:
        case OTU4:
            entry = firstProp.getFeatures().get(0).getValue().get(0);
            layerClass = entry.getLayerClass();
            if (!OFPortOpticalTransportLayerClass.ODU.equals(layerClass)) {
                LOG.error("Unsupported layer Class {} ", layerClass);
                return null;
            }

            // convert to ONOS OduSignalType
            OduSignalType oduSignalTypeOtuPort = OpenFlowDeviceValueMapper.
                    lookupOduSignalType((byte) entry.getSignalType());
            if (!matchingOtuPortSignalTypes(sigType, oduSignalTypeOtuPort)) {
                LOG.error("Wrong oduSignalType {} for OTU Port sigType {} ", oduSignalTypeOtuPort, sigType);
                return null;
            }
            OtuSignalType otuSignalType =
                    ((sigType == OFPortOpticalTransportSignalType.OTU2) ? OtuSignalType.OTU2 :
                            OtuSignalType.OTU4);
            portDes = otuPortDescription(portNo, enabled, otuSignalType, annotations);
            break;
        default:
            break;
    }

    return portDes;
}
项目:onos    文件:OpenFlowDeviceProvider.java   
/**
 * Build a portDescription from a given a port description describing some
 * Optical port.
 *
 * @param ptype description property type.
 * @param port the port to build from.
 * @return portDescription for the port.
 */
private PortDescription buildPortDescription(PortDescPropertyType ptype, OFExpPort port) {
    PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
    boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN)
            && !port.getConfig().contains(OFPortConfig.PORT_DOWN);
    boolean adminDown = port.getConfig().contains(OFPortConfig.PORT_DOWN);
    SparseAnnotations annotations = makePortAnnotation(port.getName(),
                                                       port.getHwAddr().toString(),
                                                       adminDown).build();

    OFExpPortDescPropOpticalTransport firstProp = port.getProperties().get(0);
    OFPortOpticalTransportSignalType sigType = firstProp.getPortSignalType();

    PortDescription portDes = null;
    switch (sigType) {
    case OMSN:
        portDes = omsPortDescription(portNo, enabled,
                FREQ191_7, FREQ191_7.add(FREQ4_4), FREQ50, annotations);
        break;
    case OCH:
        OFExpPortOpticalTransportLayerEntry entry = firstProp.getFeatures().get(0).getValue().get(0);
        OFPortOpticalTransportLayerClass layerClass =  entry.getLayerClass();
        if (!OFPortOpticalTransportLayerClass.ODU.equals(layerClass)) {
            LOG.error("Unsupported layer Class {} ", layerClass);
            return null;
        }

        // convert to ONOS OduSignalType
        OduSignalType oduSignalType = OpenFlowDeviceValueMapper.
                lookupOduSignalType((byte) entry.getSignalType());
        //OchSignal is needed for OchPortDescription constructor,
        //yet not relevant for tunable OCH port, creating with default parameters
        OchSignal signalId = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 1, 1);

        portDes = ochPortDescription(portNo, enabled,
                                     oduSignalType, true,
                                     signalId, annotations);

        break;
    case OTU2:
    case OTU4:
        entry = firstProp.getFeatures().get(0).getValue().get(0);
        layerClass =  entry.getLayerClass();
        if (!OFPortOpticalTransportLayerClass.ODU.equals(layerClass)) {
            LOG.error("Unsupported layer Class {} ", layerClass);
            return null;
        }

        // convert to ONOS OduSignalType
        OduSignalType oduSignalTypeOtuPort = OpenFlowDeviceValueMapper.
                lookupOduSignalType((byte) entry.getSignalType());
        if (!matchingOtuPortSignalTypes(sigType, oduSignalTypeOtuPort)) {
            LOG.error("Wrong oduSignalType {} for OTU Port sigType {} ", oduSignalTypeOtuPort, sigType);
            return null;
        }
        OtuSignalType otuSignalType =
                ((sigType == OFPortOpticalTransportSignalType.OTU2) ? OtuSignalType.OTU2 :
                    OtuSignalType.OTU4);
        portDes = otuPortDescription(portNo, enabled, otuSignalType, annotations);
        break;
    default:
        break;
    }

    return portDes;
}