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

项目:athena    文件:OFChannelHandler.java   
@Override
void processOFFeaturesReply(OFChannelHandler h, OFFeaturesReply  m)
        throws IOException {
    h.thisdpid = m.getDatapathId().getLong();
    log.debug("Received features reply for switch at {} with dpid {}",
            h.getSwitchInfoString(), h.thisdpid);

    h.featuresReply = m; //temp store
    if (h.ofVersion == OFVersion.OF_10) {
        h.sendHandshakeSetConfig();
        h.setState(WAIT_CONFIG_REPLY);
    } else {
        //version is 1.3, must get switchport information
        h.sendHandshakeOFPortDescRequest();
        h.setState(WAIT_PORT_DESC_REPLY);
    }
}
项目:fresco_floodlight    文件:SwitchResourceBase.java   
protected OFFeaturesReply getSwitchFeaturesReply(DatapathId switchId) {
    IOFSwitchService switchService =
            (IOFSwitchService) getContext().getAttributes().
            get(IOFSwitchService.class.getCanonicalName());

    IOFSwitch sw = switchService.getSwitch(switchId);
    Future<OFFeaturesReply> future;
    OFFeaturesReply featuresReply = null;
    OFFeaturesRequest featuresRequest = sw.getOFFactory().buildFeaturesRequest().build();
    if (sw != null) {
        try {
            future = sw.writeRequest(featuresRequest);
            featuresReply = future.get(10, TimeUnit.SECONDS);
        } catch (Exception e) {
            log.error("Failure getting features reply from switch" + sw, e);
        }
    }

    return featuresReply;
}
项目:fresco_floodlight    文件:StatsReplySerializer.java   
public static void serializeFeaturesReply(OFFeaturesReply fr, JsonGenerator jGen) throws IOException, JsonProcessingException {
    /* Common to All OF Versions */         
    jGen.writeStringField("capabilities", fr.getCapabilities().toString());
    jGen.writeStringField("dpid", fr.getDatapathId().toString());
    jGen.writeNumberField("buffers", fr.getNBuffers());
    jGen.writeNumberField("tables", fr.getNTables());
    jGen.writeStringField("version", fr.getVersion().toString());

    if (fr.getVersion().compareTo(OFVersion.OF_13) < 0) { // OF1.3+ break this out into port_config
        serializePortDesc(fr.getPorts(), jGen);
    }
    if (fr.getVersion().compareTo(OFVersion.OF_10) == 0) {
        String actions = "[";
        for (OFActionType action : fr.getActions()) {
            actions =  actions + action.toString() + ", ";
        }
        actions = actions.substring(0, actions.length() - 2); // remove ending space+comma
        actions = actions + "]";
        jGen.writeStringField("actions", actions);
    }
}
项目:fresco_floodlight    文件:SwitchSyncRepresentation.java   
@JsonIgnore
public OFFeaturesReply getFeaturesReply(OFFactory factory) {
    /**
     * FIXME Icky work around; if a null actions got written to storage
     * then fake up an empty one so the builder() doesn't throw
     * a NPE.  Need to root cause why someone would write a null actions.
     * This code will all be removed shortly -- needed to unblock BVS team.
     */
    Set<OFActionType> workAroundActions;
    if (actions != null)
        workAroundActions = actions;
    else
        workAroundActions = Collections.<OFActionType> emptySet();

    OFFeaturesReply featuresReply = factory.buildFeaturesReply()
            .setXid(0)
            .setDatapathId(dpid)
            .setNBuffers(buffers)
            .setNTables(tables)
            .setCapabilities(capabilities)
            .setActions(workAroundActions)
            .setPorts(toOFPortDescList(factory, ports))
            .build();
    return featuresReply;
}
项目:fresco_floodlight    文件:OFSwitch.java   
@Override
public void setFeaturesReply(OFFeaturesReply featuresReply) {
    if (portManager.getPorts().isEmpty() && featuresReply.getVersion().compareTo(OFVersion.OF_13) < 0) {
        /* ports are updated via port status message, so we
         * only fill in ports on initial connection.
         */
        List<OFPortDesc> OFPortDescs = featuresReply.getPorts();
        portManager.updatePorts(OFPortDescs);
    }
    this.capabilities = featuresReply.getCapabilities();
    this.buffers = featuresReply.getNBuffers();

    if (featuresReply.getVersion().compareTo(OFVersion.OF_13) < 0 ) {
        /* OF1.3+ Per-table actions are set later in the OFTableFeaturesRequest/Reply */
        this.actions = featuresReply.getActions();
    }

    this.nTables = featuresReply.getNTables();
}
项目:fresco_floodlight    文件:OFSwitchManagerTest.java   
/**
 * Create and activate a switch, either completely new or reconnected
 * The mocked switch instance will be returned. It will be reset.
 */
private IOFSwitchBackend doActivateSwitchInt(DatapathId datapathId,
                                      SwitchDescription description,
                                      OFFeaturesReply featuresReply,
                                      boolean clearFlows)
                                      throws Exception {

    IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
    if (featuresReply == null) {
        featuresReply = createOFFeaturesReply(datapathId);
    }
    if (description == null) {
        description = createSwitchDescription();
    }
    setupSwitchForAddSwitch(sw, datapathId, description, featuresReply);
    replay(sw);
    switchManager.switchAdded(sw);
    switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
    verify(sw);
    assertEquals(sw, switchManager.getSwitch(datapathId));
    // drain updates and ignore
    controller.processUpdateQueueForTesting();

    reset(sw);
    return sw;
}
项目:iTAP-controller    文件:OFSwitch.java   
@Override
public void setFeaturesReply(OFFeaturesReply featuresReply) {
    if (portManager.getPorts().isEmpty() && featuresReply.getVersion().compareTo(OFVersion.OF_13) < 0) {
        /* ports are updated via port status message, so we
         * only fill in ports on initial connection.
         */
        List<OFPortDesc> OFPortDescs = featuresReply.getPorts();
        portManager.updatePorts(OFPortDescs);
    }
    this.capabilities = featuresReply.getCapabilities();
    this.buffers = featuresReply.getNBuffers();

    if (featuresReply.getVersion().compareTo(OFVersion.OF_13) < 0 ) {
        // FIXME:LOJI: OF1.3 has per table actions. This needs to be modeled / handled here
        this.actions = featuresReply.getActions();
    }
    this.tables = featuresReply.getNTables();
}
项目:iTAP-controller    文件:SwitchResourceBase.java   
protected OFFeaturesReply getSwitchFeaturesReply(DatapathId switchId) {
    IOFSwitchService switchService =
            (IOFSwitchService) getContext().getAttributes().
            get(IOFSwitchService.class.getCanonicalName());

    IOFSwitch sw = switchService.getSwitch(switchId);
    Future<OFFeaturesReply> future;
    OFFeaturesReply featuresReply = null;
    OFFeaturesRequest featuresRequest = sw.getOFFactory().buildFeaturesRequest().build();
    if (sw != null) {
        try {
            future = sw.writeRequest(featuresRequest);
            featuresReply = future.get(10, TimeUnit.SECONDS);
        } catch (Exception e) {
            log.error("Failure getting features reply from switch" + sw, e);
        }
    }

    return featuresReply;
}
项目:iTAP-controller    文件:StatsReplySerializer.java   
public static void serializeFeaturesReply(OFFeaturesReply fr, JsonGenerator jGen) throws IOException, JsonProcessingException {
    /* Common to All OF Versions */         
    jGen.writeStringField("capabilities", fr.getCapabilities().toString());
    jGen.writeStringField("dpid", fr.getDatapathId().toString());
    jGen.writeNumberField("buffers", fr.getNBuffers());
    jGen.writeNumberField("tables", fr.getNTables());
    jGen.writeStringField("version", fr.getVersion().toString());

    if (fr.getVersion().compareTo(OFVersion.OF_13) < 0) { // OF1.3+ break this out into port_config
        serializePortDesc(fr.getPorts(), jGen);
    }
    if (fr.getVersion().compareTo(OFVersion.OF_10) == 0) {
        String actions = "[";
        for (OFActionType action : fr.getActions()) {
            actions =  actions + action.toString() + ", ";
        }
        actions = actions.substring(0, actions.length() - 2); // remove ending space+comma
        actions = actions + "]";
        jGen.writeStringField("actions", actions);
    }
}
项目:iTAP-controller    文件:SwitchSyncRepresentation.java   
@JsonIgnore
public OFFeaturesReply getFeaturesReply(OFFactory factory) {
    /**
     * FIXME Icky work around; if a null actions got written to storage
     * then fake up an empty one so the builder() doesn't throw
     * a NPE.  Need to root cause why someone would write a null actions.
     * This code will all be removed shortly -- needed to unblock BVS team.
     */
    Set<OFActionType> workAroundActions;
    if (actions != null)
        workAroundActions = actions;
    else
        workAroundActions = Collections.<OFActionType> emptySet();

    OFFeaturesReply featuresReply = factory.buildFeaturesReply()
            .setXid(0)
            .setDatapathId(dpid)
            .setNBuffers(buffers)
            .setNTables(tables)
            .setCapabilities(capabilities)
            .setActions(workAroundActions)
            .setPorts(toOFPortDescList(factory, ports))
            .build();
    return featuresReply;
}
项目:iTAP-controller    文件:OFSwitchManagerTest.java   
/**
 * Create and activate a switch, either completely new or reconnected
 * The mocked switch instance will be returned. It will be reset.
 */
private IOFSwitchBackend doActivateSwitchInt(DatapathId datapathId,
                                      SwitchDescription description,
                                      OFFeaturesReply featuresReply,
                                      boolean clearFlows)
                                      throws Exception {

    IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
    if (featuresReply == null) {
        featuresReply = createOFFeaturesReply(datapathId);
    }
    if (description == null) {
        description = createSwitchDescription();
    }
    setupSwitchForAddSwitch(sw, datapathId, description, featuresReply);
    replay(sw);
    switchManager.switchAdded(sw);
    switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
    verify(sw);
    assertEquals(sw, switchManager.getSwitch(datapathId));
    // drain updates and ignore
    controller.processUpdateQueueForTesting();

    reset(sw);
    return sw;
}
项目:SDN-Multicast    文件:SwitchSyncRepresentation.java   
@JsonIgnore
public OFFeaturesReply getFeaturesReply(OFFactory factory) {
    /**
     * FIXME Icky work around; if a null actions got written to storage
     * then fake up an empty one so the builder() doesn't throw
     * a NPE.  Need to root cause why someone would write a null actions.
     * This code will all be removed shortly -- needed to unblock BVS team.
     */
    Set<OFActionType> workAroundActions;
    if (actions != null)
        workAroundActions = actions;
    else
        workAroundActions = Collections.<OFActionType> emptySet();

    OFFeaturesReply featuresReply = factory.buildFeaturesReply()
            .setXid(0)
            .setDatapathId(dpid)
            .setNBuffers(buffers)
            .setNTables(tables)
            .setCapabilities(capabilities)
            .setActions(workAroundActions)
            .setPorts(toOFPortDescList(factory, ports))
            .build();
    return featuresReply;
}
项目:SDN-Multicast    文件:OFSwitch.java   
@Override
public void setFeaturesReply(OFFeaturesReply featuresReply) {
    if (portManager.getPorts().isEmpty() && featuresReply.getVersion().compareTo(OFVersion.OF_13) < 0) {
        /* ports are updated via port status message, so we
         * only fill in ports on initial connection.
         */
        List<OFPortDesc> OFPortDescs = featuresReply.getPorts();
        portManager.updatePorts(OFPortDescs);
    }
    this.capabilities = featuresReply.getCapabilities();
    this.buffers = featuresReply.getNBuffers();

    if (featuresReply.getVersion().compareTo(OFVersion.OF_13) < 0 ) {
        /* OF1.3+ Per-table actions are set later in the OFTableFeaturesRequest/Reply */
        this.actions = featuresReply.getActions();
    }

    this.nTables = featuresReply.getNTables();
}
项目:SDN-Multicast    文件:OFSwitchManagerTest.java   
/**
 * Create and activate a switch, either completely new or reconnected
 * The mocked switch instance will be returned. It will be reset.
 */
private IOFSwitchBackend doActivateSwitchInt(DatapathId datapathId,
                                      SwitchDescription description,
                                      OFFeaturesReply featuresReply,
                                      boolean clearFlows)
                                      throws Exception {

    IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
    if (featuresReply == null) {
        featuresReply = createOFFeaturesReply(datapathId);
    }
    if (description == null) {
        description = createSwitchDescription();
    }
    setupSwitchForAddSwitch(sw, datapathId, description, featuresReply);
    replay(sw);
    switchManager.switchAdded(sw);
    switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
    verify(sw);
    assertEquals(sw, switchManager.getSwitch(datapathId));
    // drain updates and ignore
    controller.processUpdateQueueForTesting();

    reset(sw);
    return sw;
}
项目:ACAMPController    文件:SwitchResourceBase.java   
protected OFFeaturesReply getSwitchFeaturesReply(DatapathId switchId) {
    IOFSwitchService switchService =
            (IOFSwitchService) getContext().getAttributes().
            get(IOFSwitchService.class.getCanonicalName());

    IOFSwitch sw = switchService.getSwitch(switchId);
    Future<OFFeaturesReply> future;
    OFFeaturesReply featuresReply = null;
    OFFeaturesRequest featuresRequest = sw.getOFFactory().buildFeaturesRequest().build();
    if (sw != null) {
        try {
            future = sw.writeRequest(featuresRequest);
            featuresReply = future.get(10, TimeUnit.SECONDS);
        } catch (Exception e) {
            log.error("Failure getting features reply from switch" + sw, e);
        }
    }

    return featuresReply;
}
项目:arscheduler    文件:SwitchResourceBase.java   
protected OFFeaturesReply getSwitchFeaturesReply(DatapathId switchId) {
    IOFSwitchService switchService =
            (IOFSwitchService) getContext().getAttributes().
            get(IOFSwitchService.class.getCanonicalName());

    IOFSwitch sw = switchService.getSwitch(switchId);
    Future<OFFeaturesReply> future;
    OFFeaturesReply featuresReply = null;
    OFFeaturesRequest featuresRequest = sw.getOFFactory().buildFeaturesRequest().build();
    if (sw != null) {
        try {
            future = sw.writeRequest(featuresRequest);
            featuresReply = future.get(10, TimeUnit.SECONDS);
        } catch (Exception e) {
            log.error("Failure getting features reply from switch" + sw, e);
        }
    }

    return featuresReply;
}
项目:arscheduler    文件:StatsReplySerializer.java   
public static void serializeFeaturesReply(OFFeaturesReply fr, JsonGenerator jGen) throws IOException, JsonProcessingException {
    /* Common to All OF Versions */         
    jGen.writeStringField("capabilities", fr.getCapabilities().toString());
    jGen.writeStringField("dpid", fr.getDatapathId().toString());
    jGen.writeNumberField("buffers", fr.getNBuffers());
    jGen.writeNumberField("tables", fr.getNTables());
    jGen.writeStringField("version", fr.getVersion().toString());

    if (fr.getVersion().compareTo(OFVersion.OF_13) < 0) { // OF1.3+ break this out into port_config
        serializePortDesc(fr.getPorts(), jGen);
    }
    if (fr.getVersion().compareTo(OFVersion.OF_10) == 0) {
        String actions = "[";
        for (OFActionType action : fr.getActions()) {
            actions =  actions + action.toString() + ", ";
        }
        actions = actions.substring(0, actions.length() - 2); // remove ending space+comma
        actions = actions + "]";
        jGen.writeStringField("actions", actions);
    }
}
项目:arscheduler    文件:OFSwitch.java   
@Override
public void setFeaturesReply(OFFeaturesReply featuresReply) {
    if (portManager.getPorts().isEmpty() && featuresReply.getVersion().compareTo(OFVersion.OF_13) < 0) {
        /* ports are updated via port status message, so we
         * only fill in ports on initial connection.
         */
        List<OFPortDesc> OFPortDescs = featuresReply.getPorts();
        portManager.updatePorts(OFPortDescs);
    }
    this.capabilities = featuresReply.getCapabilities();
    this.buffers = featuresReply.getNBuffers();

    if (featuresReply.getVersion().compareTo(OFVersion.OF_13) < 0 ) {
        /* OF1.3+ Per-table actions are set later in the OFTableFeaturesRequest/Reply */
        this.actions = featuresReply.getActions();
    }

    this.nTables = featuresReply.getNTables();
}
项目:floodlight1.2-delay    文件:SwitchResourceBase.java   
protected OFFeaturesReply getSwitchFeaturesReply(DatapathId switchId) {
    IOFSwitchService switchService =
            (IOFSwitchService) getContext().getAttributes().
            get(IOFSwitchService.class.getCanonicalName());

    IOFSwitch sw = switchService.getSwitch(switchId);
    Future<OFFeaturesReply> future;
    OFFeaturesReply featuresReply = null;
    OFFeaturesRequest featuresRequest = sw.getOFFactory().buildFeaturesRequest().build();
    if (sw != null) {
        try {
            future = sw.writeRequest(featuresRequest);
            featuresReply = future.get(10, TimeUnit.SECONDS);
        } catch (Exception e) {
            log.error("Failure getting features reply from switch" + sw, e);
        }
    }

    return featuresReply;
}
项目:floodlight1.2-delay    文件:StatsReplySerializer.java   
public static void serializeFeaturesReply(OFFeaturesReply fr, JsonGenerator jGen) throws IOException, JsonProcessingException {
    /* Common to All OF Versions */         
    jGen.writeStringField("capabilities", fr.getCapabilities().toString());
    jGen.writeStringField("dpid", fr.getDatapathId().toString());
    jGen.writeNumberField("buffers", fr.getNBuffers());
    jGen.writeNumberField("tables", fr.getNTables());
    jGen.writeStringField("version", fr.getVersion().toString());

    if (fr.getVersion().compareTo(OFVersion.OF_13) < 0) { // OF1.3+ break this out into port_config
        serializePortDesc(fr.getPorts(), jGen);
    }
    if (fr.getVersion().compareTo(OFVersion.OF_10) == 0) {
        String actions = "[";
        for (OFActionType action : fr.getActions()) {
            actions =  actions + action.toString() + ", ";
        }
        actions = actions.substring(0, actions.length() - 2); // remove ending space+comma
        actions = actions + "]";
        jGen.writeStringField("actions", actions);
    }
}
项目:floodlight1.2-delay    文件:SwitchSyncRepresentation.java   
@JsonIgnore
public OFFeaturesReply getFeaturesReply(OFFactory factory) {
    /**
     * FIXME Icky work around; if a null actions got written to storage
     * then fake up an empty one so the builder() doesn't throw
     * a NPE.  Need to root cause why someone would write a null actions.
     * This code will all be removed shortly -- needed to unblock BVS team.
     */
    Set<OFActionType> workAroundActions;
    if (actions != null)
        workAroundActions = actions;
    else
        workAroundActions = Collections.<OFActionType> emptySet();

    OFFeaturesReply featuresReply = factory.buildFeaturesReply()
            .setXid(0)
            .setDatapathId(dpid)
            .setNBuffers(buffers)
            .setNTables(tables)
            .setCapabilities(capabilities)
            .setActions(workAroundActions)
            .setPorts(toOFPortDescList(factory, ports))
            .build();
    return featuresReply;
}
项目:floodlight1.2-delay    文件:OFSwitchManagerTest.java   
/**
 * Create and activate a switch, either completely new or reconnected
 * The mocked switch instance will be returned. It will be reset.
 */
private IOFSwitchBackend doActivateSwitchInt(DatapathId datapathId,
                                      SwitchDescription description,
                                      OFFeaturesReply featuresReply,
                                      boolean clearFlows)
                                      throws Exception {

    IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
    if (featuresReply == null) {
        featuresReply = createOFFeaturesReply(datapathId);
    }
    if (description == null) {
        description = createSwitchDescription();
    }
    setupSwitchForAddSwitch(sw, datapathId, description, featuresReply);
    replay(sw);
    switchManager.switchAdded(sw);
    switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
    verify(sw);
    assertEquals(sw, switchManager.getSwitch(datapathId));
    // drain updates and ignore
    controller.processUpdateQueueForTesting();

    reset(sw);
    return sw;
}
项目:ACAMPController    文件:OFSwitchManagerTest.java   
/**
 * Create and activate a switch, either completely new or reconnected
 * The mocked switch instance will be returned. It will be reset.
 */
private IOFSwitchBackend doActivateSwitchInt(DatapathId datapathId,
                                      SwitchDescription description,
                                      OFFeaturesReply featuresReply,
                                      boolean clearFlows)
                                      throws Exception {

    IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
    if (featuresReply == null) {
        featuresReply = createOFFeaturesReply(datapathId);
    }
    if (description == null) {
        description = createSwitchDescription();
    }
    setupSwitchForAddSwitch(sw, datapathId, description, featuresReply);
    replay(sw);
    switchManager.switchAdded(sw);
    switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
    verify(sw);
    assertEquals(sw, switchManager.getSwitch(datapathId));
    // drain updates and ignore
    controller.processUpdateQueueForTesting();

    reset(sw);
    return sw;
}
项目:floodlight-hardware    文件:SwitchResourceBase.java   
protected OFFeaturesReply getSwitchFeaturesReply(DatapathId switchId) {
    IOFSwitchService switchService =
            (IOFSwitchService) getContext().getAttributes().
            get(IOFSwitchService.class.getCanonicalName());

    IOFSwitch sw = switchService.getSwitch(switchId);
    Future<OFFeaturesReply> future;
    OFFeaturesReply featuresReply = null;
    OFFeaturesRequest featuresRequest = sw.getOFFactory().buildFeaturesRequest().build();
    if (sw != null) {
        try {
            future = sw.writeRequest(featuresRequest);
            featuresReply = future.get(10, TimeUnit.SECONDS);
        } catch (Exception e) {
            log.error("Failure getting features reply from switch" + sw, e);
        }
    }

    return featuresReply;
}
项目:floodlight-hardware    文件:StatsReplySerializer.java   
public static void serializeFeaturesReply(OFFeaturesReply fr, JsonGenerator jGen) throws IOException, JsonProcessingException {
    /* Common to All OF Versions */
    jGen.writeStringField("capabilities", fr.getCapabilities().toString());
    jGen.writeStringField("dpid", fr.getDatapathId().toString());
    jGen.writeNumberField("buffers", fr.getNBuffers());
    jGen.writeNumberField("tables", fr.getNTables());
    jGen.writeStringField("version", fr.getVersion().toString());

    if (fr.getVersion().compareTo(OFVersion.OF_13) < 0) { // OF1.3+ break this out into port_config
        serializePortDesc(fr.getPorts(), jGen);
    }
    if (fr.getVersion().compareTo(OFVersion.OF_10) == 0) {
        String actions = "[";
        for (OFActionType action : fr.getActions()) {
            actions =  actions + action.toString() + ", ";
        }
        actions = actions.substring(0, actions.length() - 2); // remove ending space+comma
        actions = actions + "]";
        jGen.writeStringField("actions", actions);
    }
}
项目:floodlight-hardware    文件:SwitchSyncRepresentation.java   
@JsonIgnore
public OFFeaturesReply getFeaturesReply(OFFactory factory) {
    /**
     * FIXME Icky work around; if a null actions got written to storage
     * then fake up an empty one so the builder() doesn't throw
     * a NPE.  Need to root cause why someone would write a null actions.
     * This code will all be removed shortly -- needed to unblock BVS team.
     */
    Set<OFActionType> workAroundActions;
    if (actions != null)
        workAroundActions = actions;
    else
        workAroundActions = Collections.<OFActionType> emptySet();

    OFFeaturesReply featuresReply = factory.buildFeaturesReply()
            .setXid(0)
            .setDatapathId(dpid)
            .setNBuffers(buffers)
            .setNTables(tables)
            .setCapabilities(capabilities)
            .setActions(workAroundActions)
            .setPorts(toOFPortDescList(factory, ports))
            .build();
    return featuresReply;
}
项目:floodlight-hardware    文件:OFSwitch.java   
@Override
public void setFeaturesReply(OFFeaturesReply featuresReply) {
    if (portManager.getPorts().isEmpty() && featuresReply.getVersion().compareTo(OFVersion.OF_13) < 0) {
        /* ports are updated via port status message, so we
         * only fill in ports on initial connection.
         */
        List<OFPortDesc> OFPortDescs = featuresReply.getPorts();
        portManager.updatePorts(OFPortDescs);
    }
    this.capabilities = featuresReply.getCapabilities();
    this.buffers = featuresReply.getNBuffers();

    if (featuresReply.getVersion().compareTo(OFVersion.OF_13) < 0 ) {
        /* OF1.3+ Per-table actions are set later in the OFTableFeaturesRequest/Reply */
        this.actions = featuresReply.getActions();
    }

    this.nTables = featuresReply.getNTables();
}
项目:ACAMPController    文件:StatsReplySerializer.java   
public static void serializeFeaturesReply(OFFeaturesReply fr, JsonGenerator jGen) throws IOException, JsonProcessingException {
    /* Common to All OF Versions */         
    jGen.writeStringField("capabilities", fr.getCapabilities().toString());
    jGen.writeStringField("dpid", fr.getDatapathId().toString());
    jGen.writeNumberField("buffers", fr.getNBuffers());
    jGen.writeNumberField("tables", fr.getNTables());
    jGen.writeStringField("version", fr.getVersion().toString());

    if (fr.getVersion().compareTo(OFVersion.OF_13) < 0) { // OF1.3+ break this out into port_config
        serializePortDesc(fr.getPorts(), jGen);
    }
    if (fr.getVersion().compareTo(OFVersion.OF_10) == 0) {
        String actions = "[";
        for (OFActionType action : fr.getActions()) {
            actions =  actions + action.toString() + ", ";
        }
        actions = actions.substring(0, actions.length() - 2); // remove ending space+comma
        actions = actions + "]";
        jGen.writeStringField("actions", actions);
    }
}
项目:floodlight-hardware    文件:OFSwitchManagerTest.java   
/**
 * Create and activate a switch, either completely new or reconnected
 * The mocked switch instance will be returned. It will be reset.
 */
private IOFSwitchBackend doActivateSwitchInt(DatapathId datapathId,
                                      SwitchDescription description,
                                      OFFeaturesReply featuresReply,
                                      boolean clearFlows)
                                      throws Exception {

    IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
    if (featuresReply == null) {
        featuresReply = createOFFeaturesReply(datapathId);
    }
    if (description == null) {
        description = createSwitchDescription();
    }
    setupSwitchForAddSwitch(sw, datapathId, description, featuresReply);
    replay(sw);
    switchManager.switchAdded(sw);
    switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
    verify(sw);
    assertEquals(sw, switchManager.getSwitch(datapathId));
    // drain updates and ignore
    controller.processUpdateQueueForTesting();

    reset(sw);
    return sw;
}
项目:fresco_floodlight    文件:SwitchSyncRepresentation.java   
public SwitchSyncRepresentation(OFFeaturesReply fr,
                                SwitchDescription d) {
    this.dpid = fr.getDatapathId();
    this.buffers = fr.getNBuffers();
    this.tables = fr.getNTables();
    this.capabilities = fr.getCapabilities();
    this.actions = fr.getActions();
    this.ports = toSyncedPortList(fr.getPorts());

    this.manufacturerDescription = d.getManufacturerDescription();
    this.hardwareDescription = d.getHardwareDescription();
    this.softwareDescription = d.getSoftwareDescription();
    this.serialNumber = d.getSerialNumber();
    this.datapathDescription = d.getDatapathDescription();
}
项目:fresco_floodlight    文件:OFSwitchHandshakeHandler.java   
/**
 * Create a new unconnected OFChannelHandler.
 * @param controller
 * @param broker
 * @throws SwitchHandshakeHandlerException
 */
OFSwitchHandshakeHandler(@Nonnull IOFConnectionBackend connection,
        @Nonnull OFFeaturesReply featuresReply,
        @Nonnull IOFSwitchManager switchManager,
        @Nonnull RoleManager roleManager,
        @Nonnull Timer timer) {
    Preconditions.checkNotNull(connection, "connection");
    Preconditions.checkNotNull(featuresReply, "featuresReply");
    Preconditions.checkNotNull(switchManager, "switchManager");
    Preconditions.checkNotNull(roleManager, "roleManager");
    Preconditions.checkNotNull(timer, "timer");
    Preconditions.checkArgument(connection.getAuxId().equals(OFAuxId.MAIN),
            "connection must be MAIN connection but is %s", connection);

    this.switchManager = switchManager;
    this.roleManager = roleManager;
    this.mainConnection = connection;
    this.auxConnections = new ConcurrentHashMap<OFAuxId, IOFConnectionBackend>();
    this.featuresReply = featuresReply;
    this.timer = timer;
    this.switchManagerCounters = switchManager.getCounters();
    this.factory = OFFactories.getFactory(featuresReply.getVersion());
    this.roleChanger = new RoleChanger(DEFAULT_ROLE_TIMEOUT_NS);
    setState(new InitState());
    this.pendingPortStatusMsg = new ArrayList<OFPortStatus>();

    connection.setListener(this);
}
项目:fresco_floodlight    文件:OFChannelHandler.java   
@Override
void processOFFeaturesReply(OFFeaturesReply  m)
        throws IOException {
    featuresReply = m;

    featuresLatency = (System.currentTimeMillis() - featuresLatency) / 2;

    // Mark handshake as completed
    setState(new CompleteState());

}
项目:fresco_floodlight    文件:OFSwitchManagerTest.java   
private OFFeaturesReply createOFFeaturesReply(DatapathId datapathId) {
    OFFeaturesReply fr = factory.buildFeaturesReply()
            .setXid(0)
            .setDatapathId(datapathId)
            .setPorts(ImmutableList.<OFPortDesc>of())
            .build();
    return fr;
}
项目:fresco_floodlight    文件:OFSwitchManagerTest.java   
/** Set the mock expectations for sw when sw is passed to addSwitch
 * The same expectations can be used when a new SwitchSyncRepresentation
 * is created from the given mocked switch */
protected void setupSwitchForAddSwitch(IOFSwitch sw, DatapathId datapathId,
        SwitchDescription description, OFFeaturesReply featuresReply) {
    if (description == null) {
        description = createSwitchDescription();
    }
    if (featuresReply == null) {
        featuresReply = createOFFeaturesReply(datapathId);
    }
    List<OFPortDesc> ports = featuresReply.getPorts();

    expect(sw.getOFFactory()).andReturn(OFFactories.getFactory(OFVersion.OF_10)).anyTimes();
    expect(sw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
    expect(sw.getId()).andReturn(datapathId).anyTimes();
    expect(sw.getSwitchDescription()).andReturn(description).anyTimes();
    expect(sw.getBuffers())
            .andReturn(featuresReply.getNBuffers()).anyTimes();
    expect(sw.getNumTables())
            .andReturn(featuresReply.getNTables()).anyTimes();
    expect(sw.getCapabilities())
            .andReturn(featuresReply.getCapabilities()).anyTimes();
    expect(sw.getActions())
            .andReturn(featuresReply.getActions()).anyTimes();
    expect(sw.getPorts())
            .andReturn(ports).anyTimes();
    expect(sw.attributeEquals(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE, true))
            .andReturn(false).anyTimes();
    expect(sw.getInetAddress()).andReturn(null).anyTimes();
}
项目:fresco_floodlight    文件:OFSwitchManagerTest.java   
/**
 * Create and activate a new switch with the given dpid, features reply
 * and description. If description and/or features reply are null we'll
 * allocate the default one
 * The mocked switch instance will be returned. It wil be reset.
 */
private IOFSwitchBackend doActivateNewSwitch(DatapathId dpid,
                                      SwitchDescription description,
                                      OFFeaturesReply featuresReply)
                                      throws Exception {
    return doActivateSwitchInt(dpid, description, featuresReply, true);
}
项目:fresco_floodlight    文件:OFSwitchManagerTest.java   
@Test
public void testNewConnectionOpened() {
    MockOFConnection connection = new MockOFConnection(DATAPATH_ID_1, OFAuxId.MAIN);
    OFFeaturesReply featuresReply = createOFFeaturesReply(DATAPATH_ID_1);

    // Assert no switch handlers
    assertTrue(switchManager.getSwitchHandshakeHandlers().isEmpty());
    switchManager.connectionOpened(connection, featuresReply);
    // Ensure a
    assertTrue(switchManager.getSwitchHandshakeHandlers().size() == 1);
    assertTrue(switchManager.getSwitchHandshakeHandlers().get(0).getDpid().equals(DATAPATH_ID_1));
}
项目:fresco_floodlight    文件:OFSwitchManagerTest.java   
@Test
public void testDuplicateConnectionOpened() {
    // Seed with 1 connection and handler
    testNewConnectionOpened();

    MockOFConnection connection = new MockOFConnection(DATAPATH_ID_1, OFAuxId.MAIN);
    OFFeaturesReply featuresReply = createOFFeaturesReply(DATAPATH_ID_1);

    switchManager.connectionOpened(connection, featuresReply);

    // Ensure duplicate connections are
    assertTrue(switchManager.getSwitchHandshakeHandlers().size() == 1);
    assertTrue(switchManager.getSwitchHandshakeHandlers().get(0).getDpid().equals(DATAPATH_ID_1));
}
项目:fresco_floodlight    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
OFFeaturesReply getFeaturesReply() {
    return factory.buildFeaturesReply()
            .setDatapathId(dpid)
            .setNBuffers(1)
            .setNTables((short)1)
            .setCapabilities(EnumSet.<OFCapabilities>of(OFCapabilities.FLOW_STATS, OFCapabilities.TABLE_STATS))
            .setAuxiliaryId(OFAuxId.MAIN)
            .build();
}
项目:fresco_floodlight    文件:ControllerTest.java   
private OFFeaturesReply createOFFeaturesReply(DatapathId datapathId) {
    OFFeaturesReply fr = factory.buildFeaturesReply()
            .setXid(0)
            .setDatapathId(datapathId)
            .setPorts(ImmutableList.<OFPortDesc>of())
            .build();
    return fr;
}
项目:fresco_floodlight    文件:ControllerTest.java   
/** Set the mock expectations for sw when sw is passed to addSwitch
 * The same expectations can be used when a new SwitchSyncRepresentation
 * is created from the given mocked switch */
protected void setupSwitchForAddSwitch(IOFSwitch sw, DatapathId datapathId,
                                       SwitchDescription description,
                                       OFFeaturesReply featuresReply) {
    String dpidString = datapathId.toString();
    if (description == null) {
        description = createSwitchDescription();
    }
    if (featuresReply == null) {
        featuresReply = createOFFeaturesReply(datapathId);
    }
    List<OFPortDesc> ports = featuresReply.getPorts();

    expect(sw.getOFFactory()).andReturn(OFFactories.getFactory(OFVersion.OF_10)).anyTimes();
    expect(sw.getId()).andReturn(datapathId).anyTimes();
    expect(sw.getId().toString()).andReturn(dpidString).anyTimes();
    expect(sw.getSwitchDescription()).andReturn(description).atLeastOnce();
    expect(sw.getBuffers())
            .andReturn(featuresReply.getNBuffers()).atLeastOnce();
    expect(sw.getNumTables())
            .andReturn(featuresReply.getNTables()).atLeastOnce();
    expect(sw.getCapabilities())
            .andReturn(featuresReply.getCapabilities()).atLeastOnce();
    expect(sw.getActions())
            .andReturn(featuresReply.getActions()).atLeastOnce();
    expect(sw.getPorts())
            .andReturn(ports).atLeastOnce();
    expect(sw.attributeEquals(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE, true))
            .andReturn(false).anyTimes();
    expect(sw.getInetAddress()).andReturn(null).anyTimes();
}