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

项目: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);
}
项目: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   
private PortDescription buildPortDescription(OFPortStatus status) {
    OFPortDesc port = status.getDesc();
    if (status.getReason() != OFPortReason.DELETE) {
        return buildPortDescription(port);
    } else {
        PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
        Port.Type type = port.getCurr().contains(OFPortFeatures.PF_FIBER) ? FIBER : COPPER;
        SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString());
        return new DefaultPortDescription(portNo, false, type,
                portSpeed(port), annotations);
    }
}
项目: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    文件:OpenFlowDeviceProvider.java   
private PortDescription buildPortDescription(OFPortStatus status) {
    OFPortDesc port = status.getDesc();
    if (status.getReason() != OFPortReason.DELETE) {
        return buildPortDescription(port);
    } else {
        PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
        Port.Type type = port.getCurr().contains(OFPortFeatures.PF_FIBER) ? FIBER : COPPER;
        SparseAnnotations annotations = makePortNameAnnotation(port);
        return new DefaultPortDescription(portNo, false, type,
                                          portSpeed(port), annotations);
    }
}
项目:openflowj-otn    文件:OFPortFeaturesSerializerVer12.java   
public static Set<OFPortFeatures> readFrom(ChannelBuffer bb) throws OFParseError {
    try {
        return ofWireValue(bb.readInt());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:openflowj-otn    文件:OFPortFeaturesSerializerVer12.java   
public static Set<OFPortFeatures> ofWireValue(int val) {
    EnumSet<OFPortFeatures> set = EnumSet.noneOf(OFPortFeatures.class);

    if((val & PF_10MB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_10MB_HD);
    if((val & PF_10MB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_10MB_FD);
    if((val & PF_100MB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_100MB_HD);
    if((val & PF_100MB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_100MB_FD);
    if((val & PF_1GB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_1GB_HD);
    if((val & PF_1GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_1GB_FD);
    if((val & PF_10GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_10GB_FD);
    if((val & PF_COPPER_VAL) != 0)
        set.add(OFPortFeatures.PF_COPPER);
    if((val & PF_FIBER_VAL) != 0)
        set.add(OFPortFeatures.PF_FIBER);
    if((val & PF_AUTONEG_VAL) != 0)
        set.add(OFPortFeatures.PF_AUTONEG);
    if((val & PF_PAUSE_VAL) != 0)
        set.add(OFPortFeatures.PF_PAUSE);
    if((val & PF_PAUSE_ASYM_VAL) != 0)
        set.add(OFPortFeatures.PF_PAUSE_ASYM);
    if((val & PF_40GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_40GB_FD);
    if((val & PF_100GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_100GB_FD);
    if((val & PF_1TB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_1TB_FD);
    if((val & PF_OTHER_VAL) != 0)
        set.add(OFPortFeatures.PF_OTHER);
    return Collections.unmodifiableSet(set);
}
项目:openflowj-otn    文件:OFPortFeaturesSerializerVer13.java   
public static Set<OFPortFeatures> readFrom(ChannelBuffer bb) throws OFParseError {
    try {
        return ofWireValue(bb.readInt());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:openflowj-otn    文件:OFPortFeaturesSerializerVer13.java   
public static Set<OFPortFeatures> ofWireValue(int val) {
    EnumSet<OFPortFeatures> set = EnumSet.noneOf(OFPortFeatures.class);

    if((val & PF_10MB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_10MB_HD);
    if((val & PF_10MB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_10MB_FD);
    if((val & PF_100MB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_100MB_HD);
    if((val & PF_100MB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_100MB_FD);
    if((val & PF_1GB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_1GB_HD);
    if((val & PF_1GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_1GB_FD);
    if((val & PF_10GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_10GB_FD);
    if((val & PF_COPPER_VAL) != 0)
        set.add(OFPortFeatures.PF_COPPER);
    if((val & PF_FIBER_VAL) != 0)
        set.add(OFPortFeatures.PF_FIBER);
    if((val & PF_AUTONEG_VAL) != 0)
        set.add(OFPortFeatures.PF_AUTONEG);
    if((val & PF_PAUSE_VAL) != 0)
        set.add(OFPortFeatures.PF_PAUSE);
    if((val & PF_PAUSE_ASYM_VAL) != 0)
        set.add(OFPortFeatures.PF_PAUSE_ASYM);
    if((val & PF_40GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_40GB_FD);
    if((val & PF_100GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_100GB_FD);
    if((val & PF_1TB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_1TB_FD);
    if((val & PF_OTHER_VAL) != 0)
        set.add(OFPortFeatures.PF_OTHER);
    if((val & PF_BSN_BREAKOUT_CAPABLE_VAL) != 0)
        set.add(OFPortFeatures.PF_BSN_BREAKOUT_CAPABLE);
    return Collections.unmodifiableSet(set);
}
项目:openflowj-otn    文件:OFPortFeaturesSerializerVer10.java   
public static Set<OFPortFeatures> readFrom(ChannelBuffer bb) throws OFParseError {
    try {
        return ofWireValue(bb.readInt());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:openflowj-otn    文件:OFPortFeaturesSerializerVer10.java   
public static Set<OFPortFeatures> ofWireValue(int val) {
    EnumSet<OFPortFeatures> set = EnumSet.noneOf(OFPortFeatures.class);

    if((val & PF_10MB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_10MB_HD);
    if((val & PF_10MB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_10MB_FD);
    if((val & PF_100MB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_100MB_HD);
    if((val & PF_100MB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_100MB_FD);
    if((val & PF_1GB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_1GB_HD);
    if((val & PF_1GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_1GB_FD);
    if((val & PF_10GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_10GB_FD);
    if((val & PF_COPPER_VAL) != 0)
        set.add(OFPortFeatures.PF_COPPER);
    if((val & PF_FIBER_VAL) != 0)
        set.add(OFPortFeatures.PF_FIBER);
    if((val & PF_AUTONEG_VAL) != 0)
        set.add(OFPortFeatures.PF_AUTONEG);
    if((val & PF_PAUSE_VAL) != 0)
        set.add(OFPortFeatures.PF_PAUSE);
    if((val & PF_PAUSE_ASYM_VAL) != 0)
        set.add(OFPortFeatures.PF_PAUSE_ASYM);
    return Collections.unmodifiableSet(set);
}
项目:openflowj-otn    文件:OFPortFeaturesSerializerVer11.java   
public static Set<OFPortFeatures> readFrom(ChannelBuffer bb) throws OFParseError {
    try {
        return ofWireValue(bb.readInt());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:openflowj-otn    文件:OFPortFeaturesSerializerVer11.java   
public static Set<OFPortFeatures> ofWireValue(int val) {
    EnumSet<OFPortFeatures> set = EnumSet.noneOf(OFPortFeatures.class);

    if((val & PF_10MB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_10MB_HD);
    if((val & PF_10MB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_10MB_FD);
    if((val & PF_100MB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_100MB_HD);
    if((val & PF_100MB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_100MB_FD);
    if((val & PF_1GB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_1GB_HD);
    if((val & PF_1GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_1GB_FD);
    if((val & PF_10GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_10GB_FD);
    if((val & PF_COPPER_VAL) != 0)
        set.add(OFPortFeatures.PF_COPPER);
    if((val & PF_FIBER_VAL) != 0)
        set.add(OFPortFeatures.PF_FIBER);
    if((val & PF_AUTONEG_VAL) != 0)
        set.add(OFPortFeatures.PF_AUTONEG);
    if((val & PF_PAUSE_VAL) != 0)
        set.add(OFPortFeatures.PF_PAUSE);
    if((val & PF_PAUSE_ASYM_VAL) != 0)
        set.add(OFPortFeatures.PF_PAUSE_ASYM);
    if((val & PF_40GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_40GB_FD);
    if((val & PF_100GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_100GB_FD);
    if((val & PF_1TB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_1TB_FD);
    if((val & PF_OTHER_VAL) != 0)
        set.add(OFPortFeatures.PF_OTHER);
    return Collections.unmodifiableSet(set);
}
项目:openflowj-otn    文件:OFPortFeaturesSerializerVer14.java   
public static Set<OFPortFeatures> readFrom(ChannelBuffer bb) throws OFParseError {
    try {
        return ofWireValue(bb.readInt());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:openflowj-otn    文件:OFPortFeaturesSerializerVer14.java   
public static Set<OFPortFeatures> ofWireValue(int val) {
    EnumSet<OFPortFeatures> set = EnumSet.noneOf(OFPortFeatures.class);

    if((val & PF_10MB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_10MB_HD);
    if((val & PF_10MB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_10MB_FD);
    if((val & PF_100MB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_100MB_HD);
    if((val & PF_100MB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_100MB_FD);
    if((val & PF_1GB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_1GB_HD);
    if((val & PF_1GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_1GB_FD);
    if((val & PF_10GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_10GB_FD);
    if((val & PF_COPPER_VAL) != 0)
        set.add(OFPortFeatures.PF_COPPER);
    if((val & PF_FIBER_VAL) != 0)
        set.add(OFPortFeatures.PF_FIBER);
    if((val & PF_AUTONEG_VAL) != 0)
        set.add(OFPortFeatures.PF_AUTONEG);
    if((val & PF_PAUSE_VAL) != 0)
        set.add(OFPortFeatures.PF_PAUSE);
    if((val & PF_PAUSE_ASYM_VAL) != 0)
        set.add(OFPortFeatures.PF_PAUSE_ASYM);
    if((val & PF_40GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_40GB_FD);
    if((val & PF_100GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_100GB_FD);
    if((val & PF_1TB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_1TB_FD);
    if((val & PF_OTHER_VAL) != 0)
        set.add(OFPortFeatures.PF_OTHER);
    return Collections.unmodifiableSet(set);
}
项目:Engine    文件:NetIDEDeviceProvider.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);
}
项目:Engine    文件:NetIDEDeviceProvider.java   
private PortDescription buildPortDescription(OFPortStatus status) {
    OFPortDesc port = status.getDesc();
    if (status.getReason() != OFPortReason.DELETE) {
        return buildPortDescription(port);
    } else {
        PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
        Port.Type type = port.getCurr().contains(OFPortFeatures.PF_FIBER) ? FIBER : COPPER;
        SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString());
        return new DefaultPortDescription(portNo, false, type,
                                          portSpeed(port), annotations);
    }
}
项目:loxigen-artifacts    文件:OFPortFeaturesSerializerVer12.java   
public static Set<OFPortFeatures> readFrom(ByteBuf bb) throws OFParseError {
    try {
        return ofWireValue(bb.readInt());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:loxigen-artifacts    文件:OFPortFeaturesSerializerVer12.java   
public static Set<OFPortFeatures> ofWireValue(int val) {
    EnumSet<OFPortFeatures> set = EnumSet.noneOf(OFPortFeatures.class);

    if((val & PF_10MB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_10MB_HD);
    if((val & PF_10MB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_10MB_FD);
    if((val & PF_100MB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_100MB_HD);
    if((val & PF_100MB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_100MB_FD);
    if((val & PF_1GB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_1GB_HD);
    if((val & PF_1GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_1GB_FD);
    if((val & PF_10GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_10GB_FD);
    if((val & PF_COPPER_VAL) != 0)
        set.add(OFPortFeatures.PF_COPPER);
    if((val & PF_FIBER_VAL) != 0)
        set.add(OFPortFeatures.PF_FIBER);
    if((val & PF_AUTONEG_VAL) != 0)
        set.add(OFPortFeatures.PF_AUTONEG);
    if((val & PF_PAUSE_VAL) != 0)
        set.add(OFPortFeatures.PF_PAUSE);
    if((val & PF_PAUSE_ASYM_VAL) != 0)
        set.add(OFPortFeatures.PF_PAUSE_ASYM);
    if((val & PF_40GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_40GB_FD);
    if((val & PF_100GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_100GB_FD);
    if((val & PF_1TB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_1TB_FD);
    if((val & PF_OTHER_VAL) != 0)
        set.add(OFPortFeatures.PF_OTHER);
    return Collections.unmodifiableSet(set);
}
项目:loxigen-artifacts    文件:OFPortFeaturesSerializerVer13.java   
public static Set<OFPortFeatures> readFrom(ByteBuf bb) throws OFParseError {
    try {
        return ofWireValue(bb.readInt());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:loxigen-artifacts    文件:OFPortFeaturesSerializerVer13.java   
public static Set<OFPortFeatures> ofWireValue(int val) {
    EnumSet<OFPortFeatures> set = EnumSet.noneOf(OFPortFeatures.class);

    if((val & PF_10MB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_10MB_HD);
    if((val & PF_10MB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_10MB_FD);
    if((val & PF_100MB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_100MB_HD);
    if((val & PF_100MB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_100MB_FD);
    if((val & PF_1GB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_1GB_HD);
    if((val & PF_1GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_1GB_FD);
    if((val & PF_10GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_10GB_FD);
    if((val & PF_COPPER_VAL) != 0)
        set.add(OFPortFeatures.PF_COPPER);
    if((val & PF_FIBER_VAL) != 0)
        set.add(OFPortFeatures.PF_FIBER);
    if((val & PF_AUTONEG_VAL) != 0)
        set.add(OFPortFeatures.PF_AUTONEG);
    if((val & PF_PAUSE_VAL) != 0)
        set.add(OFPortFeatures.PF_PAUSE);
    if((val & PF_PAUSE_ASYM_VAL) != 0)
        set.add(OFPortFeatures.PF_PAUSE_ASYM);
    if((val & PF_40GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_40GB_FD);
    if((val & PF_100GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_100GB_FD);
    if((val & PF_1TB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_1TB_FD);
    if((val & PF_OTHER_VAL) != 0)
        set.add(OFPortFeatures.PF_OTHER);
    if((val & PF_BSN_BREAKOUT_CAPABLE_VAL) != 0)
        set.add(OFPortFeatures.PF_BSN_BREAKOUT_CAPABLE);
    return Collections.unmodifiableSet(set);
}
项目:loxigen-artifacts    文件:OFPortFeaturesSerializerVer10.java   
public static Set<OFPortFeatures> readFrom(ByteBuf bb) throws OFParseError {
    try {
        return ofWireValue(bb.readInt());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:loxigen-artifacts    文件:OFPortFeaturesSerializerVer10.java   
public static Set<OFPortFeatures> ofWireValue(int val) {
    EnumSet<OFPortFeatures> set = EnumSet.noneOf(OFPortFeatures.class);

    if((val & PF_10MB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_10MB_HD);
    if((val & PF_10MB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_10MB_FD);
    if((val & PF_100MB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_100MB_HD);
    if((val & PF_100MB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_100MB_FD);
    if((val & PF_1GB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_1GB_HD);
    if((val & PF_1GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_1GB_FD);
    if((val & PF_10GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_10GB_FD);
    if((val & PF_COPPER_VAL) != 0)
        set.add(OFPortFeatures.PF_COPPER);
    if((val & PF_FIBER_VAL) != 0)
        set.add(OFPortFeatures.PF_FIBER);
    if((val & PF_AUTONEG_VAL) != 0)
        set.add(OFPortFeatures.PF_AUTONEG);
    if((val & PF_PAUSE_VAL) != 0)
        set.add(OFPortFeatures.PF_PAUSE);
    if((val & PF_PAUSE_ASYM_VAL) != 0)
        set.add(OFPortFeatures.PF_PAUSE_ASYM);
    return Collections.unmodifiableSet(set);
}
项目:loxigen-artifacts    文件:OFPortFeaturesSerializerVer15.java   
public static Set<OFPortFeatures> readFrom(ByteBuf bb) throws OFParseError {
    try {
        return ofWireValue(bb.readInt());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:loxigen-artifacts    文件:OFPortFeaturesSerializerVer15.java   
public static Set<OFPortFeatures> ofWireValue(int val) {
    EnumSet<OFPortFeatures> set = EnumSet.noneOf(OFPortFeatures.class);

    if((val & PF_10MB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_10MB_HD);
    if((val & PF_10MB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_10MB_FD);
    if((val & PF_100MB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_100MB_HD);
    if((val & PF_100MB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_100MB_FD);
    if((val & PF_1GB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_1GB_HD);
    if((val & PF_1GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_1GB_FD);
    if((val & PF_10GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_10GB_FD);
    if((val & PF_COPPER_VAL) != 0)
        set.add(OFPortFeatures.PF_COPPER);
    if((val & PF_FIBER_VAL) != 0)
        set.add(OFPortFeatures.PF_FIBER);
    if((val & PF_AUTONEG_VAL) != 0)
        set.add(OFPortFeatures.PF_AUTONEG);
    if((val & PF_PAUSE_VAL) != 0)
        set.add(OFPortFeatures.PF_PAUSE);
    if((val & PF_PAUSE_ASYM_VAL) != 0)
        set.add(OFPortFeatures.PF_PAUSE_ASYM);
    if((val & PF_40GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_40GB_FD);
    if((val & PF_100GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_100GB_FD);
    if((val & PF_1TB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_1TB_FD);
    if((val & PF_OTHER_VAL) != 0)
        set.add(OFPortFeatures.PF_OTHER);
    if((val & PF_BSN_BREAKOUT_CAPABLE_VAL) != 0)
        set.add(OFPortFeatures.PF_BSN_BREAKOUT_CAPABLE);
    return Collections.unmodifiableSet(set);
}
项目:loxigen-artifacts    文件:OFPortFeaturesSerializerVer11.java   
public static Set<OFPortFeatures> readFrom(ByteBuf bb) throws OFParseError {
    try {
        return ofWireValue(bb.readInt());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:loxigen-artifacts    文件:OFPortFeaturesSerializerVer11.java   
public static Set<OFPortFeatures> ofWireValue(int val) {
    EnumSet<OFPortFeatures> set = EnumSet.noneOf(OFPortFeatures.class);

    if((val & PF_10MB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_10MB_HD);
    if((val & PF_10MB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_10MB_FD);
    if((val & PF_100MB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_100MB_HD);
    if((val & PF_100MB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_100MB_FD);
    if((val & PF_1GB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_1GB_HD);
    if((val & PF_1GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_1GB_FD);
    if((val & PF_10GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_10GB_FD);
    if((val & PF_COPPER_VAL) != 0)
        set.add(OFPortFeatures.PF_COPPER);
    if((val & PF_FIBER_VAL) != 0)
        set.add(OFPortFeatures.PF_FIBER);
    if((val & PF_AUTONEG_VAL) != 0)
        set.add(OFPortFeatures.PF_AUTONEG);
    if((val & PF_PAUSE_VAL) != 0)
        set.add(OFPortFeatures.PF_PAUSE);
    if((val & PF_PAUSE_ASYM_VAL) != 0)
        set.add(OFPortFeatures.PF_PAUSE_ASYM);
    if((val & PF_40GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_40GB_FD);
    if((val & PF_100GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_100GB_FD);
    if((val & PF_1TB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_1TB_FD);
    if((val & PF_OTHER_VAL) != 0)
        set.add(OFPortFeatures.PF_OTHER);
    return Collections.unmodifiableSet(set);
}
项目:loxigen-artifacts    文件:OFPortFeaturesSerializerVer14.java   
public static Set<OFPortFeatures> readFrom(ByteBuf bb) throws OFParseError {
    try {
        return ofWireValue(bb.readInt());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:loxigen-artifacts    文件:OFPortFeaturesSerializerVer14.java   
public static Set<OFPortFeatures> ofWireValue(int val) {
    EnumSet<OFPortFeatures> set = EnumSet.noneOf(OFPortFeatures.class);

    if((val & PF_10MB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_10MB_HD);
    if((val & PF_10MB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_10MB_FD);
    if((val & PF_100MB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_100MB_HD);
    if((val & PF_100MB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_100MB_FD);
    if((val & PF_1GB_HD_VAL) != 0)
        set.add(OFPortFeatures.PF_1GB_HD);
    if((val & PF_1GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_1GB_FD);
    if((val & PF_10GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_10GB_FD);
    if((val & PF_COPPER_VAL) != 0)
        set.add(OFPortFeatures.PF_COPPER);
    if((val & PF_FIBER_VAL) != 0)
        set.add(OFPortFeatures.PF_FIBER);
    if((val & PF_AUTONEG_VAL) != 0)
        set.add(OFPortFeatures.PF_AUTONEG);
    if((val & PF_PAUSE_VAL) != 0)
        set.add(OFPortFeatures.PF_PAUSE);
    if((val & PF_PAUSE_ASYM_VAL) != 0)
        set.add(OFPortFeatures.PF_PAUSE_ASYM);
    if((val & PF_40GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_40GB_FD);
    if((val & PF_100GB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_100GB_FD);
    if((val & PF_1TB_FD_VAL) != 0)
        set.add(OFPortFeatures.PF_1TB_FD);
    if((val & PF_OTHER_VAL) != 0)
        set.add(OFPortFeatures.PF_OTHER);
    if((val & PF_BSN_BREAKOUT_CAPABLE_VAL) != 0)
        set.add(OFPortFeatures.PF_BSN_BREAKOUT_CAPABLE);
    return Collections.unmodifiableSet(set);
}
项目:fresco_floodlight    文件:IOFSwitchSerializer.java   
public void serializePorts(Collection<OFPortDesc> portDecs, JsonGenerator jGen)
        throws IOException, JsonProcessingException {
        if ( portDecs == null)
            jGen.writeStringField("ports","null");
        else{
            jGen.writeFieldName("ports");
            jGen.writeStartArray();
            for(OFPortDesc port : portDecs){
                jGen.writeStartObject();
                jGen.writeNumberField("PortNo",port.getPortNo().getPortNumber());
                jGen.writeStringField("HwAddr",port.getHwAddr().toString());
                jGen.writeStringField("Name",port.getName());
                if ( port.getVersion() != OFVersion.OF_10){
                    jGen.writeNumberField("CurrSpeed",port.getCurrSpeed());
                    jGen.writeNumberField("MaxSpeed",port.getMaxSpeed());
                }
                jGen.writeFieldName("config");
                jGen.writeStartArray();
                for(OFPortConfig config : port.getConfig()){
                    jGen.writeString(config.toString());
                }
                jGen.writeEndArray();
                jGen.writeFieldName("state");
                jGen.writeStartArray();
                for(OFPortState state : port.getState()){
                    jGen.writeString(state.toString());
                }
                jGen.writeEndArray();

                jGen.writeFieldName("curr");
                jGen.writeStartArray();
                for(OFPortFeatures curr : port.getCurr()){
                    jGen.writeString(curr.toString());
                }
                jGen.writeEndArray();
                jGen.writeFieldName("advertised");
                jGen.writeStartArray();
                for(OFPortFeatures advertised : port.getAdvertised()){
                    jGen.writeString(advertised.toString());
                }
                jGen.writeEndArray();
                jGen.writeFieldName("supported");
                jGen.writeStartArray();
                for(OFPortFeatures support : port.getSupported()){
                    jGen.writeString(support.toString());
                }
                jGen.writeEndArray();
                jGen.writeFieldName("peer");
                jGen.writeStartArray();
                for(OFPortFeatures peer : port.getPeer()){
                    jGen.writeString(peer.toString());
                }
                jGen.writeEndArray();
                jGen.writeEndObject();
            }
            jGen.writeEndArray();

        }
}
项目:fresco_floodlight    文件:LinkDiscoveryManagerTest.java   
@Test
public void testSwitchAdded() throws Exception {
    LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager();
    linkDiscovery.switchService = getMockSwitchService();
    Capture<OFMessage> wc;
    Set<OFPort> qPorts;
    OFPortDesc ofpp = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc()
    .setName("eth4242")
    .setPortNo(OFPort.of(4242))
    .setHwAddr(MacAddress.of("5c:16:c7:00:00:01"))
    .setCurr(new HashSet<OFPortFeatures>()) // random
    .build();
    IOFSwitch sw1 = createMockSwitch(1L);

    // Set switch map in floodlightProvider.
    Map<DatapathId, IOFSwitch> switches = new HashMap<DatapathId, IOFSwitch>();
    switches.put(DatapathId.of(1L), sw1);
    getMockSwitchService().setSwitches(switches);

    // Create the set of ports
    List<OFPort> ports = new ArrayList<OFPort>();
    for(short p=1; p<=20; ++p) {
        ports.add(OFPort.of(p));
    }

    // Set the captures.
    wc = new Capture<OFMessage>(CaptureType.ALL);

    // Expect switch to return those ports.
    expect(sw1.getEnabledPortNumbers()).andReturn(ports).anyTimes();
    expect(sw1.getPort(OFPort.of(EasyMock.anyInt()))).andReturn(ofpp).anyTimes();
    expect(sw1.getOFFactory()).andReturn(OFFactories.getFactory(OFVersion.OF_13)).anyTimes();
    expect(sw1.getLatency()).andReturn(U64.ZERO).anyTimes();
    expect(sw1.write(capture(wc))).andReturn(true).anyTimes();
    replay(sw1);

    linkDiscovery.switchActivated(sw1.getId());
    verify(sw1);

    qPorts = linkDiscovery.getQuarantinedPorts(sw1.getId());
    assertNotNull(qPorts);
    assertFalse(qPorts.isEmpty());

    Thread.sleep(100);
    qPorts = linkDiscovery.getQuarantinedPorts(sw1.getId());
    assertNotNull(qPorts);
    assertFalse(qPorts.isEmpty());

    Thread.sleep(200);
    qPorts = linkDiscovery.getQuarantinedPorts(sw1.getId());
    assertNotNull(qPorts);
    assertTrue(qPorts.isEmpty());

    // Ensure that through every switch port, an LLDP and BDDP
    // packet was sent out.  Total # of packets = # of ports * 2.
    assertTrue(wc.hasCaptured());
    List<OFMessage> msgList = wc.getValues();
    assertTrue(msgList.size() == ports.size() * 2);
}
项目:fresco_floodlight    文件:OFSwitchManagerTest.java   
/**
 * Test that notifyPortChanged() results in an IOFSwitchListener
 * update and that its arguments are passed through to
 * the listener call
 */
@Test
public void testNotifySwitchPortChanged() throws Exception {
    DatapathId dpid = DatapathId.of(42);

    OFPortDesc p1 = factory.buildPortDesc()
            .setName("Port1")
            .setPortNo(OFPort.of(1))
            .build();
    OFFeaturesReply fr1 = factory.buildFeaturesReply()
            .setXid(0)
            .setDatapathId(dpid)
            .setPorts(ImmutableList.<OFPortDesc>of(p1))
            .build();

    OFPortDesc p2 = factory.buildPortDesc()
            .setName("Port1")
            .setPortNo(OFPort.of(1))
            .setAdvertised(ImmutableSet.<OFPortFeatures>of(OFPortFeatures.PF_100MB_FD))
            .build();
    OFFeaturesReply fr2 = factory.buildFeaturesReply()
            .setXid(0)
            .setDatapathId(dpid)
            .setPorts(ImmutableList.<OFPortDesc>of(p2))
            .build();

    SwitchDescription desc = createSwitchDescription();

    // activate switch
    IOFSwitchBackend sw = doActivateNewSwitch(dpid, desc, fr1);

    IOFSwitchListener listener = createMock(IOFSwitchListener.class);
    switchManager.addOFSwitchListener(listener);
    // setup switch with the new, second features reply (and thus ports)
    setupSwitchForAddSwitch(sw, dpid, desc, fr2);
    listener.switchPortChanged(dpid, p2,
                               PortChangeType.OTHER_UPDATE);
    expectLastCall().once();
    replay(listener);
    replay(sw);
    switchManager.notifyPortChanged(sw, p2,
                                 PortChangeType.OTHER_UPDATE);
    controller.processUpdateQueueForTesting();
    verify(listener);
    verify(sw);

}
项目:fresco_floodlight    文件:OFSwitchBaseTest.java   
public void setUpPorts() {
    OFPortDesc.Builder pdb = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc();
    // p1a is disabled
    pdb.setName("port1");
    pdb.setPortNo(OFPort.of(1));
    Set<OFPortState> portState = new HashSet<OFPortState>();
    portState.add(OFPortState.LINK_DOWN);
    pdb.setState(portState);
    p1a = pdb.build();
    assertFalse("Sanity check portEnabled", !p1a.getState().contains(OFPortState.LINK_DOWN));

    // p1b is enabled
    // p1b has different feature from p1a
    pdb = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc();
    pdb.setName("port1");
    pdb.setPortNo(OFPort.of(1));
    Set<OFPortFeatures> portFeatures = new HashSet<OFPortFeatures>();
    portFeatures.add(OFPortFeatures.PF_1GB_FD);
    pdb.setCurr(portFeatures);
    p1b = pdb.build();
    assertTrue("Sanity check portEnabled", !p1b.getState().contains(OFPortState.LIVE));

    // p2 is disabled
    // p2 has mixed case
    pdb = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc();
    portState = new HashSet<OFPortState>();
    Set<OFPortConfig> portConfig = new HashSet<OFPortConfig>();
    portFeatures = new HashSet<OFPortFeatures>();
    pdb.setName("Port2");
    pdb.setPortNo(OFPort.of(2));
    portConfig.add(OFPortConfig.PORT_DOWN);
    pdb.setConfig(portConfig);
    p2a = pdb.build();
    // p2b only differs in PortFeatures
    pdb = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc();
    portState = new HashSet<OFPortState>();
    portConfig = new HashSet<OFPortConfig>();
    portFeatures = new HashSet<OFPortFeatures>();
    pdb.setName("Port2");
    pdb.setPortNo(OFPort.of(2));
    portConfig.add(OFPortConfig.PORT_DOWN);
    pdb.setConfig(portConfig);
    portFeatures.add(OFPortFeatures.PF_100MB_HD);
    pdb.setCurr(portFeatures);
    p2b = pdb.build();
    assertFalse("Sanity check portEnabled", p2a.getState().contains(OFPortState.LIVE));
    // p3 is enabled
    // p3 has mixed case
    pdb = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc();
    pdb.setName("porT3");
    pdb.setPortNo(OFPort.of(3));
    p3 = pdb.build();
    assertTrue("Sanity check portEnabled", !p3.getState().contains(OFPortState.LINK_DOWN));

}
项目:iTAP-controller    文件:IOFSwitchSerializer.java   
public void serializePorts(Collection<OFPortDesc> portDecs, JsonGenerator jGen)
        throws IOException, JsonProcessingException {
        if ( portDecs == null)
            jGen.writeStringField("ports","null");
        else{
            jGen.writeFieldName("ports");
            jGen.writeStartArray();
            for(OFPortDesc port : portDecs){
                jGen.writeStartObject();
                jGen.writeNumberField("PortNo",port.getPortNo().getPortNumber());
                jGen.writeStringField("HwAddr",port.getHwAddr().toString());
                jGen.writeStringField("Name",port.getName());
                if ( port.getVersion() != OFVersion.OF_10){
                    jGen.writeNumberField("CurrSpeed",port.getCurrSpeed());
                    jGen.writeNumberField("MaxSpeed",port.getMaxSpeed());
                }
                jGen.writeFieldName("config");
                jGen.writeStartArray();
                for(OFPortConfig config : port.getConfig()){
                    jGen.writeString(config.toString());
                }
                jGen.writeEndArray();
                jGen.writeFieldName("state");
                jGen.writeStartArray();
                for(OFPortState state : port.getState()){
                    jGen.writeString(state.toString());
                }
                jGen.writeEndArray();

                jGen.writeFieldName("curr");
                jGen.writeStartArray();
                for(OFPortFeatures curr : port.getCurr()){
                    jGen.writeString(curr.toString());
                }
                jGen.writeEndArray();
                jGen.writeFieldName("advertised");
                jGen.writeStartArray();
                for(OFPortFeatures advertised : port.getAdvertised()){
                    jGen.writeString(advertised.toString());
                }
                jGen.writeEndArray();
                jGen.writeFieldName("supported");
                jGen.writeStartArray();
                for(OFPortFeatures support : port.getSupported()){
                    jGen.writeString(support.toString());
                }
                jGen.writeEndArray();
                jGen.writeFieldName("peer");
                jGen.writeStartArray();
                for(OFPortFeatures peer : port.getPeer()){
                    jGen.writeString(peer.toString());
                }
                jGen.writeEndArray();
                jGen.writeEndObject();
            }
            jGen.writeEndArray();

        }
}
项目:iTAP-controller    文件:LinkDiscoveryManagerTest.java   
@Test
public void testSwitchAdded() throws Exception {
    LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager();
    linkDiscovery.switchService = getMockSwitchService();
    Capture<OFMessage> wc;
    Set<OFPort> qPorts;
    OFPortDesc ofpp = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc()
    .setName("eth4242")
    .setPortNo(OFPort.of(4242))
    .setHwAddr(MacAddress.of("5c:16:c7:00:00:01"))
    .setCurr(new HashSet<OFPortFeatures>()) // random
    .build();
    IOFSwitch sw1 = createMockSwitch(1L);

    // Set switch map in floodlightProvider.
    Map<DatapathId, IOFSwitch> switches = new HashMap<DatapathId, IOFSwitch>();
    switches.put(DatapathId.of(1L), sw1);
    getMockSwitchService().setSwitches(switches);

    // Create the set of ports
    List<OFPort> ports = new ArrayList<OFPort>();
    for(short p=1; p<=20; ++p) {
        ports.add(OFPort.of(p));
    }

    // Set the captures.
    wc = new Capture<OFMessage>(CaptureType.ALL);

    // Expect switch to return those ports.
    expect(sw1.getEnabledPortNumbers()).andReturn(ports).anyTimes();
    expect(sw1.getPort(OFPort.of(EasyMock.anyInt()))).andReturn(ofpp).anyTimes();
    expect(sw1.getOFFactory()).andReturn(OFFactories.getFactory(OFVersion.OF_13)).anyTimes();
    sw1.write(capture(wc));
    expectLastCall().anyTimes();
    replay(sw1);

    linkDiscovery.switchActivated(sw1.getId());
    verify(sw1);

    qPorts = linkDiscovery.getQuarantinedPorts(sw1.getId());
    assertNotNull(qPorts);
    assertFalse(qPorts.isEmpty());

    Thread.sleep(100);
    qPorts = linkDiscovery.getQuarantinedPorts(sw1.getId());
    assertNotNull(qPorts);
    assertFalse(qPorts.isEmpty());

    Thread.sleep(200);
    qPorts = linkDiscovery.getQuarantinedPorts(sw1.getId());
    assertNotNull(qPorts);
    assertTrue(qPorts.isEmpty());

    // Ensure that through every switch port, an LLDP and BDDP
    // packet was sent out.  Total # of packets = # of ports * 2.
    assertTrue(wc.hasCaptured());
    List<OFMessage> msgList = wc.getValues();
    assertTrue(msgList.size() == ports.size() * 2);
}
项目:iTAP-controller    文件:OFSwitchBaseTest.java   
@Before
public void setUpPorts() {
    OFPortDesc.Builder pdb = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc();
    // p1a is disabled
    pdb.setName("port1");
    pdb.setPortNo(OFPort.of(1));
    Set<OFPortState> portState = new HashSet<OFPortState>();
    portState.add(OFPortState.LINK_DOWN);
    pdb.setState(portState);
    p1a = pdb.build();
    assertFalse("Sanity check portEnabled", !p1a.getState().contains(OFPortState.LINK_DOWN));

    // p1b is enabled
    // p1b has different feature from p1a
    pdb = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc();
    pdb.setName("port1");
    pdb.setPortNo(OFPort.of(1));
    Set<OFPortFeatures> portFeatures = new HashSet<OFPortFeatures>();
    portFeatures.add(OFPortFeatures.PF_1GB_FD);
    pdb.setCurr(portFeatures);
    p1b = pdb.build();
    assertTrue("Sanity check portEnabled", !p1b.getState().contains(OFPortState.LIVE));

    // p2 is disabled
    // p2 has mixed case
    pdb = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc();
    portState = new HashSet<OFPortState>();
    Set<OFPortConfig> portConfig = new HashSet<OFPortConfig>();
    portFeatures = new HashSet<OFPortFeatures>();
    pdb.setName("Port2");
    pdb.setPortNo(OFPort.of(2));
    portConfig.add(OFPortConfig.PORT_DOWN);
    pdb.setConfig(portConfig);
    p2a = pdb.build();
    // p2b only differs in PortFeatures
    pdb = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc();
    portState = new HashSet<OFPortState>();
    portConfig = new HashSet<OFPortConfig>();
    portFeatures = new HashSet<OFPortFeatures>();
    pdb.setName("Port2");
    pdb.setPortNo(OFPort.of(2));
    portConfig.add(OFPortConfig.PORT_DOWN);
    pdb.setConfig(portConfig);
    portFeatures.add(OFPortFeatures.PF_100MB_HD);
    pdb.setCurr(portFeatures);
    p2b = pdb.build();
    assertFalse("Sanity check portEnabled", p2a.getState().contains(OFPortState.LIVE));
    // p3 is enabled
    // p3 has mixed case
    pdb = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc();
    pdb.setName("porT3");
    pdb.setPortNo(OFPort.of(3));
    p3 = pdb.build();
    assertTrue("Sanity check portEnabled", !p3.getState().contains(OFPortState.LINK_DOWN));

}
项目:iTAP-controller    文件:OFSwitchManagerTest.java   
/**
 * Test that notifyPortChanged() results in an IOFSwitchListener
 * update and that its arguments are passed through to
 * the listener call
 */
@Test
public void testNotifySwitchPortChanged() throws Exception {
    DatapathId dpid = DatapathId.of(42);

    OFPortDesc p1 = factory.buildPortDesc()
            .setName("Port1")
            .setPortNo(OFPort.of(1))
            .build();
    OFFeaturesReply fr1 = factory.buildFeaturesReply()
            .setXid(0)
            .setDatapathId(dpid)
            .setPorts(ImmutableList.<OFPortDesc>of(p1))
            .build();

    OFPortDesc p2 = factory.buildPortDesc()
            .setName("Port1")
            .setPortNo(OFPort.of(1))
            .setAdvertised(ImmutableSet.<OFPortFeatures>of(OFPortFeatures.PF_100MB_FD))
            .build();
    OFFeaturesReply fr2 = factory.buildFeaturesReply()
            .setXid(0)
            .setDatapathId(dpid)
            .setPorts(ImmutableList.<OFPortDesc>of(p2))
            .build();

    SwitchDescription desc = createSwitchDescription();

    // activate switch
    IOFSwitchBackend sw = doActivateNewSwitch(dpid, desc, fr1);

    IOFSwitchListener listener = createMock(IOFSwitchListener.class);
    switchManager.addOFSwitchListener(listener);
    // setup switch with the new, second features reply (and thus ports)
    setupSwitchForAddSwitch(sw, dpid, desc, fr2);
    listener.switchPortChanged(dpid, p2,
                               PortChangeType.OTHER_UPDATE);
    expectLastCall().once();
    replay(listener);
    replay(sw);
    switchManager.notifyPortChanged(sw, p2,
                                 PortChangeType.OTHER_UPDATE);
    controller.processUpdateQueueForTesting();
    verify(listener);
    verify(sw);

}
项目:SDN-Multicast    文件:IOFSwitchSerializer.java   
public void serializePorts(Collection<OFPortDesc> portDecs, JsonGenerator jGen)
        throws IOException, JsonProcessingException {
        if ( portDecs == null)
            jGen.writeStringField("ports","null");
        else{
            jGen.writeFieldName("ports");
            jGen.writeStartArray();
            for(OFPortDesc port : portDecs){
                jGen.writeStartObject();
                jGen.writeNumberField("PortNo",port.getPortNo().getPortNumber());
                jGen.writeStringField("HwAddr",port.getHwAddr().toString());
                jGen.writeStringField("Name",port.getName());
                if ( port.getVersion() != OFVersion.OF_10){
                    jGen.writeNumberField("CurrSpeed",port.getCurrSpeed());
                    jGen.writeNumberField("MaxSpeed",port.getMaxSpeed());
                }
                jGen.writeFieldName("config");
                jGen.writeStartArray();
                for(OFPortConfig config : port.getConfig()){
                    jGen.writeString(config.toString());
                }
                jGen.writeEndArray();
                jGen.writeFieldName("state");
                jGen.writeStartArray();
                for(OFPortState state : port.getState()){
                    jGen.writeString(state.toString());
                }
                jGen.writeEndArray();

                jGen.writeFieldName("curr");
                jGen.writeStartArray();
                for(OFPortFeatures curr : port.getCurr()){
                    jGen.writeString(curr.toString());
                }
                jGen.writeEndArray();
                jGen.writeFieldName("advertised");
                jGen.writeStartArray();
                for(OFPortFeatures advertised : port.getAdvertised()){
                    jGen.writeString(advertised.toString());
                }
                jGen.writeEndArray();
                jGen.writeFieldName("supported");
                jGen.writeStartArray();
                for(OFPortFeatures support : port.getSupported()){
                    jGen.writeString(support.toString());
                }
                jGen.writeEndArray();
                jGen.writeFieldName("peer");
                jGen.writeStartArray();
                for(OFPortFeatures peer : port.getPeer()){
                    jGen.writeString(peer.toString());
                }
                jGen.writeEndArray();
                jGen.writeEndObject();
            }
            jGen.writeEndArray();

        }
}
项目:SDN-Multicast    文件:LinkDiscoveryManagerTest.java   
@Test
public void testSwitchAdded() throws Exception {
    LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager();
    linkDiscovery.switchService = getMockSwitchService();
    Capture<OFMessage> wc;
    Set<OFPort> qPorts;
    OFPortDesc ofpp = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc()
    .setName("eth4242")
    .setPortNo(OFPort.of(4242))
    .setHwAddr(MacAddress.of("5c:16:c7:00:00:01"))
    .setCurr(new HashSet<OFPortFeatures>()) // random
    .build();
    IOFSwitch sw1 = createMockSwitch(1L);

    // Set switch map in floodlightProvider.
    Map<DatapathId, IOFSwitch> switches = new HashMap<DatapathId, IOFSwitch>();
    switches.put(DatapathId.of(1L), sw1);
    getMockSwitchService().setSwitches(switches);

    // Create the set of ports
    List<OFPort> ports = new ArrayList<OFPort>();
    for(short p=1; p<=20; ++p) {
        ports.add(OFPort.of(p));
    }

    // Set the captures.
    wc = new Capture<OFMessage>(CaptureType.ALL);

    // Expect switch to return those ports.
    expect(sw1.getEnabledPortNumbers()).andReturn(ports).anyTimes();
    expect(sw1.getPort(OFPort.of(EasyMock.anyInt()))).andReturn(ofpp).anyTimes();
    expect(sw1.getOFFactory()).andReturn(OFFactories.getFactory(OFVersion.OF_13)).anyTimes();
    expect(sw1.getLatency()).andReturn(U64.ZERO).anyTimes();
    expect(sw1.write(capture(wc))).andReturn(true).anyTimes();
    replay(sw1);

    linkDiscovery.switchActivated(sw1.getId());
    verify(sw1);

    qPorts = linkDiscovery.getQuarantinedPorts(sw1.getId());
    assertNotNull(qPorts);
    assertFalse(qPorts.isEmpty());

    Thread.sleep(100);
    qPorts = linkDiscovery.getQuarantinedPorts(sw1.getId());
    assertNotNull(qPorts);
    assertFalse(qPorts.isEmpty());

    Thread.sleep(200);
    qPorts = linkDiscovery.getQuarantinedPorts(sw1.getId());
    assertNotNull(qPorts);
    assertTrue(qPorts.isEmpty());

    // Ensure that through every switch port, an LLDP and BDDP
    // packet was sent out.  Total # of packets = # of ports * 2.
    assertTrue(wc.hasCaptured());
    List<OFMessage> msgList = wc.getValues();
    assertTrue(msgList.size() == ports.size() * 2);
}
项目:SDN-Multicast    文件:OFSwitchManagerTest.java   
/**
 * Test that notifyPortChanged() results in an IOFSwitchListener
 * update and that its arguments are passed through to
 * the listener call
 */
@Test
public void testNotifySwitchPortChanged() throws Exception {
    DatapathId dpid = DatapathId.of(42);

    OFPortDesc p1 = factory.buildPortDesc()
            .setName("Port1")
            .setPortNo(OFPort.of(1))
            .build();
    OFFeaturesReply fr1 = factory.buildFeaturesReply()
            .setXid(0)
            .setDatapathId(dpid)
            .setPorts(ImmutableList.<OFPortDesc>of(p1))
            .build();

    OFPortDesc p2 = factory.buildPortDesc()
            .setName("Port1")
            .setPortNo(OFPort.of(1))
            .setAdvertised(ImmutableSet.<OFPortFeatures>of(OFPortFeatures.PF_100MB_FD))
            .build();
    OFFeaturesReply fr2 = factory.buildFeaturesReply()
            .setXid(0)
            .setDatapathId(dpid)
            .setPorts(ImmutableList.<OFPortDesc>of(p2))
            .build();

    SwitchDescription desc = createSwitchDescription();

    // activate switch
    IOFSwitchBackend sw = doActivateNewSwitch(dpid, desc, fr1);

    IOFSwitchListener listener = createMock(IOFSwitchListener.class);
    switchManager.addOFSwitchListener(listener);
    // setup switch with the new, second features reply (and thus ports)
    setupSwitchForAddSwitch(sw, dpid, desc, fr2);
    listener.switchPortChanged(dpid, p2,
                               PortChangeType.OTHER_UPDATE);
    expectLastCall().once();
    replay(listener);
    replay(sw);
    switchManager.notifyPortChanged(sw, p2,
                                 PortChangeType.OTHER_UPDATE);
    controller.processUpdateQueueForTesting();
    verify(listener);
    verify(sw);

}