Java 类org.projectfloodlight.openflow.protocol.ver13.OFFlowModFlagsSerializerVer13 实例源码

项目:fresco_floodlight    文件:OFFlowModSerializer.java   
public static void serializeFlowMod(JsonGenerator jGen, OFFlowMod flowMod) throws IOException, JsonProcessingException {

       jGen.configure(Feature.WRITE_NUMBERS_AS_STRINGS, true); // IMHO this just looks nicer and is easier to read if everything is quoted

    jGen.writeStartObject();
    jGen.writeStringField("version", flowMod.getVersion().toString()); // return the enum names
    jGen.writeStringField("command", flowMod.getCommand().toString());
    jGen.writeNumberField("cookie", flowMod.getCookie().getValue());
    jGen.writeNumberField("priority", flowMod.getPriority());
    jGen.writeNumberField("idleTimeoutSec", flowMod.getIdleTimeout());
    jGen.writeNumberField("hardTimeoutSec", flowMod.getHardTimeout());
    jGen.writeStringField("outPort", flowMod.getOutPort().toString());

    switch (flowMod.getVersion()) {
    case OF_10:
        break;
    case OF_11:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    case OF_12:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    case OF_13:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        break;
    case OF_14:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    default:
        logger.error("Could not decode OFVersion {}", flowMod.getVersion());
        break;
    }

    MatchSerializer.serializeMatch(jGen, flowMod.getMatch());

    // handle OF1.1+ instructions with actions within
    if (flowMod.getVersion() == OFVersion.OF_10) {
        jGen.writeObjectFieldStart("actions");
        OFActionListSerializer.serializeActions(jGen, flowMod.getActions());
        jGen.writeEndObject();
    } else {
        OFInstructionListSerializer.serializeInstructionList(jGen, flowMod.getInstructions());
    } // end not-empty instructions (else)
    jGen.writeEndObject();
}
项目:fresco_floodlight    文件:StatsReplySerializer.java   
public static void serializeFlowReply(List<OFFlowStatsReply> flowReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    /* start the array before each reply */
    jGen.writeFieldName("flows"); 
    jGen.writeStartArray();
    for (OFFlowStatsReply flowReply : flowReplies) { // for each flow stats reply
        List<OFFlowStatsEntry> entries = flowReply.getEntries();
        for (OFFlowStatsEntry entry : entries) { // for each flow
            jGen.writeStartObject();
            // list flow stats/info
            jGen.writeStringField("version", entry.getVersion().toString()); // return the enum name
            jGen.writeNumberField("cookie", entry.getCookie().getValue());
            jGen.writeStringField("tableId", entry.getTableId().toString());
            jGen.writeNumberField("packetCount", entry.getPacketCount().getValue());
            jGen.writeNumberField("byteCount", entry.getByteCount().getValue());
            jGen.writeNumberField("durationSeconds", entry.getDurationSec());
            jGen.writeNumberField("durationNSeconds", entry.getDurationNsec());
            jGen.writeNumberField("priority", entry.getPriority());
            jGen.writeNumberField("idleTimeoutSec", entry.getIdleTimeout());
            jGen.writeNumberField("hardTimeoutSec", entry.getHardTimeout());
            switch (entry.getVersion()) {
            case OF_10:
                // flags not supported
                break;
            case OF_11:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(entry.getFlags()));
                break;
            case OF_12:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(entry.getFlags()));
                break;
            case OF_13:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(entry.getFlags()));
                break;
            case OF_14:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(entry.getFlags()));
                break;
            default:
                logger.error("Could not decode OFVersion {}", entry.getVersion());
                break;
            }

            MatchSerializer.serializeMatch(jGen, entry.getMatch());

            // handle OF1.1+ instructions with actions within
            if (entry.getVersion() == OFVersion.OF_10) {
                jGen.writeObjectFieldStart("actions");
                OFActionListSerializer.serializeActions(jGen, entry.getActions());
                jGen.writeEndObject();
            } else {
                OFInstructionListSerializer.serializeInstructionList(jGen, entry.getInstructions());
            }

            jGen.writeEndObject();
        } // end for each OFFlowStatsReply entry */
    } // end for each OFStatsReply
    //jGen.writeEndObject();
    jGen.writeEndArray();
}
项目:iTAP-controller    文件:OFFlowModSerializer.java   
public static void serializeFlowMod(JsonGenerator jGen, OFFlowMod flowMod) throws IOException, JsonProcessingException {

       jGen.configure(Feature.WRITE_NUMBERS_AS_STRINGS, true); // IMHO this just looks nicer and is easier to read if everything is quoted

    jGen.writeStartObject();
    jGen.writeStringField("version", flowMod.getVersion().toString()); // return the enum names
    jGen.writeStringField("command", flowMod.getCommand().toString());
    jGen.writeNumberField("cookie", flowMod.getCookie().getValue());
    jGen.writeNumberField("priority", flowMod.getPriority());
    jGen.writeNumberField("idleTimeoutSec", flowMod.getIdleTimeout());
    jGen.writeNumberField("hardTimeoutSec", flowMod.getHardTimeout());
    jGen.writeStringField("outPort", flowMod.getOutPort().toString());

    switch (flowMod.getVersion()) {
    case OF_10:
        break;
    case OF_11:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    case OF_12:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    case OF_13:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        break;
    case OF_14:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    default:
        logger.error("Could not decode OFVersion {}", flowMod.getVersion());
        break;
    }

    MatchSerializer.serializeMatch(jGen, flowMod.getMatch());

    // handle OF1.1+ instructions with actions within
    if (flowMod.getVersion() == OFVersion.OF_10) {
        jGen.writeObjectFieldStart("actions");
        OFActionListSerializer.serializeActions(jGen, flowMod.getActions());
        jGen.writeEndObject();
    } else {
        OFInstructionListSerializer.serializeInstructionList(jGen, flowMod.getInstructions());
    } // end not-empty instructions (else)
    jGen.writeEndObject();
}
项目:iTAP-controller    文件:StatsReplySerializer.java   
public static void serializeFlowReply(List<OFFlowStatsReply> flowReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    /* start the array before each reply */
    jGen.writeFieldName("flows"); 
    jGen.writeStartArray();
    for (OFFlowStatsReply flowReply : flowReplies) { // for each flow stats reply
        List<OFFlowStatsEntry> entries = flowReply.getEntries();
        for (OFFlowStatsEntry entry : entries) { // for each flow
            jGen.writeStartObject();
            // list flow stats/info
            jGen.writeStringField("version", entry.getVersion().toString()); // return the enum name
            jGen.writeNumberField("cookie", entry.getCookie().getValue());
            jGen.writeStringField("tableId", entry.getTableId().toString());
            jGen.writeNumberField("packetCount", entry.getPacketCount().getValue());
            jGen.writeNumberField("byteCount", entry.getByteCount().getValue());
            jGen.writeNumberField("durationSeconds", entry.getDurationSec());
            jGen.writeNumberField("priority", entry.getPriority());
            jGen.writeNumberField("idleTimeoutSec", entry.getIdleTimeout());
            jGen.writeNumberField("hardTimeoutSec", entry.getHardTimeout());
            switch (entry.getVersion()) {
            case OF_10:
                // flags not supported
                break;
            case OF_11:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(entry.getFlags()));
                break;
            case OF_12:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(entry.getFlags()));
                break;
            case OF_13:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(entry.getFlags()));
                break;
            case OF_14:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(entry.getFlags()));
                break;
            default:
                logger.error("Could not decode OFVersion {}", entry.getVersion());
                break;
            }

            MatchSerializer.serializeMatch(jGen, entry.getMatch());

            // handle OF1.1+ instructions with actions within
            if (entry.getVersion() == OFVersion.OF_10) {
                jGen.writeObjectFieldStart("actions");
                OFActionListSerializer.serializeActions(jGen, entry.getActions());
                jGen.writeEndObject();
            } else {
                OFInstructionListSerializer.serializeInstructionList(jGen, entry.getInstructions());
            }

            jGen.writeEndObject();
        } // end for each OFFlowStatsReply entry */
    } // end for each OFStatsReply
    //jGen.writeEndObject();
    jGen.writeEndArray();
}
项目:SDN-Multicast    文件:OFFlowModSerializer.java   
public static void serializeFlowMod(JsonGenerator jGen, OFFlowMod flowMod) throws IOException, JsonProcessingException {

       jGen.configure(Feature.WRITE_NUMBERS_AS_STRINGS, true); // IMHO this just looks nicer and is easier to read if everything is quoted

    jGen.writeStartObject();
    jGen.writeStringField("version", flowMod.getVersion().toString()); // return the enum names
    jGen.writeStringField("command", flowMod.getCommand().toString());
    jGen.writeNumberField("cookie", flowMod.getCookie().getValue());
    jGen.writeNumberField("priority", flowMod.getPriority());
    jGen.writeNumberField("idleTimeoutSec", flowMod.getIdleTimeout());
    jGen.writeNumberField("hardTimeoutSec", flowMod.getHardTimeout());
    jGen.writeStringField("outPort", flowMod.getOutPort().toString());

    switch (flowMod.getVersion()) {
    case OF_10:
        break;
    case OF_11:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    case OF_12:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    case OF_13:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        break;
    case OF_14:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    default:
        logger.error("Could not decode OFVersion {}", flowMod.getVersion());
        break;
    }

    MatchSerializer.serializeMatch(jGen, flowMod.getMatch());

    // handle OF1.1+ instructions with actions within
    if (flowMod.getVersion() == OFVersion.OF_10) {
        jGen.writeObjectFieldStart("actions");
        OFActionListSerializer.serializeActions(jGen, flowMod.getActions());
        jGen.writeEndObject();
    } else {
        OFInstructionListSerializer.serializeInstructionList(jGen, flowMod.getInstructions());
    } // end not-empty instructions (else)
    jGen.writeEndObject();
}
项目:SDN-Multicast    文件:StatsReplySerializer.java   
public static void serializeFlowReply(List<OFFlowStatsReply> flowReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    /* start the array before each reply */
    jGen.writeFieldName("flows"); 
    jGen.writeStartArray();
    for (OFFlowStatsReply flowReply : flowReplies) { // for each flow stats reply
        List<OFFlowStatsEntry> entries = flowReply.getEntries();
        for (OFFlowStatsEntry entry : entries) { // for each flow
            jGen.writeStartObject();
            // list flow stats/info
            jGen.writeStringField("version", entry.getVersion().toString()); // return the enum name
            jGen.writeNumberField("cookie", entry.getCookie().getValue());
            jGen.writeStringField("tableId", entry.getTableId().toString());
            jGen.writeNumberField("packetCount", entry.getPacketCount().getValue());
            jGen.writeNumberField("byteCount", entry.getByteCount().getValue());
            jGen.writeNumberField("durationSeconds", entry.getDurationSec());
            jGen.writeNumberField("durationNSeconds", entry.getDurationNsec());
            jGen.writeNumberField("priority", entry.getPriority());
            jGen.writeNumberField("idleTimeoutSec", entry.getIdleTimeout());
            jGen.writeNumberField("hardTimeoutSec", entry.getHardTimeout());
            switch (entry.getVersion()) {
            case OF_10:
                // flags not supported
                break;
            case OF_11:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(entry.getFlags()));
                break;
            case OF_12:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(entry.getFlags()));
                break;
            case OF_13:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(entry.getFlags()));
                break;
            case OF_14:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(entry.getFlags()));
                break;
            default:
                logger.error("Could not decode OFVersion {}", entry.getVersion());
                break;
            }

            MatchSerializer.serializeMatch(jGen, entry.getMatch());

            // handle OF1.1+ instructions with actions within
            if (entry.getVersion() == OFVersion.OF_10) {
                jGen.writeObjectFieldStart("actions");
                OFActionListSerializer.serializeActions(jGen, entry.getActions());
                jGen.writeEndObject();
            } else {
                OFInstructionListSerializer.serializeInstructionList(jGen, entry.getInstructions());
            }

            jGen.writeEndObject();
        } // end for each OFFlowStatsReply entry */
    } // end for each OFStatsReply
    //jGen.writeEndObject();
    jGen.writeEndArray();
}
项目:arscheduler    文件:OFFlowModSerializer.java   
public static void serializeFlowMod(JsonGenerator jGen, OFFlowMod flowMod) throws IOException, JsonProcessingException {

       jGen.configure(Feature.WRITE_NUMBERS_AS_STRINGS, true); // IMHO this just looks nicer and is easier to read if everything is quoted

    jGen.writeStartObject();
    jGen.writeStringField("version", flowMod.getVersion().toString()); // return the enum names
    jGen.writeStringField("command", flowMod.getCommand().toString());
    jGen.writeNumberField("cookie", flowMod.getCookie().getValue());
    jGen.writeNumberField("priority", flowMod.getPriority());
    jGen.writeNumberField("idleTimeoutSec", flowMod.getIdleTimeout());
    jGen.writeNumberField("hardTimeoutSec", flowMod.getHardTimeout());
    jGen.writeStringField("outPort", flowMod.getOutPort().toString());

    switch (flowMod.getVersion()) {
    case OF_10:
        break;
    case OF_11:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    case OF_12:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    case OF_13:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        break;
    case OF_14:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    default:
        logger.error("Could not decode OFVersion {}", flowMod.getVersion());
        break;
    }

    MatchSerializer.serializeMatch(jGen, flowMod.getMatch());

    // handle OF1.1+ instructions with actions within
    if (flowMod.getVersion() == OFVersion.OF_10) {
        jGen.writeObjectFieldStart("actions");
        OFActionListSerializer.serializeActions(jGen, flowMod.getActions());
        jGen.writeEndObject();
    } else {
        OFInstructionListSerializer.serializeInstructionList(jGen, flowMod.getInstructions());
    } // end not-empty instructions (else)
    jGen.writeEndObject();
}
项目:arscheduler    文件:StatsReplySerializer.java   
public static void serializeFlowReply(List<OFFlowStatsReply> flowReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    /* start the array before each reply */
    jGen.writeFieldName("flows"); 
    jGen.writeStartArray();
    for (OFFlowStatsReply flowReply : flowReplies) { // for each flow stats reply
        List<OFFlowStatsEntry> entries = flowReply.getEntries();
        for (OFFlowStatsEntry entry : entries) { // for each flow
            jGen.writeStartObject();
            // list flow stats/info
            jGen.writeStringField("version", entry.getVersion().toString()); // return the enum name
            jGen.writeNumberField("cookie", entry.getCookie().getValue());
            jGen.writeStringField("tableId", entry.getTableId().toString());
            jGen.writeNumberField("packetCount", entry.getPacketCount().getValue());
            jGen.writeNumberField("byteCount", entry.getByteCount().getValue());
            jGen.writeNumberField("durationSeconds", entry.getDurationSec());
            jGen.writeNumberField("durationNSeconds", entry.getDurationNsec());
            jGen.writeNumberField("priority", entry.getPriority());
            jGen.writeNumberField("idleTimeoutSec", entry.getIdleTimeout());
            jGen.writeNumberField("hardTimeoutSec", entry.getHardTimeout());
            switch (entry.getVersion()) {
            case OF_10:
                // flags not supported
                break;
            case OF_11:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(entry.getFlags()));
                break;
            case OF_12:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(entry.getFlags()));
                break;
            case OF_13:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(entry.getFlags()));
                break;
            case OF_14:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(entry.getFlags()));
                break;
            default:
                logger.error("Could not decode OFVersion {}", entry.getVersion());
                break;
            }

            MatchSerializer.serializeMatch(jGen, entry.getMatch());

            // handle OF1.1+ instructions with actions within
            if (entry.getVersion() == OFVersion.OF_10) {
                jGen.writeObjectFieldStart("actions");
                OFActionListSerializer.serializeActions(jGen, entry.getActions());
                jGen.writeEndObject();
            } else {
                OFInstructionListSerializer.serializeInstructionList(jGen, entry.getInstructions());
            }

            jGen.writeEndObject();
        } // end for each OFFlowStatsReply entry */
    } // end for each OFStatsReply
    //jGen.writeEndObject();
    jGen.writeEndArray();
}
项目:floodlight1.2-delay    文件:OFFlowModSerializer.java   
public static void serializeFlowMod(JsonGenerator jGen, OFFlowMod flowMod) throws IOException, JsonProcessingException {

       jGen.configure(Feature.WRITE_NUMBERS_AS_STRINGS, true); // IMHO this just looks nicer and is easier to read if everything is quoted

    jGen.writeStartObject();
    jGen.writeStringField("version", flowMod.getVersion().toString()); // return the enum names
    jGen.writeStringField("command", flowMod.getCommand().toString());
    jGen.writeNumberField("cookie", flowMod.getCookie().getValue());
    jGen.writeNumberField("priority", flowMod.getPriority());
    jGen.writeNumberField("idleTimeoutSec", flowMod.getIdleTimeout());
    jGen.writeNumberField("hardTimeoutSec", flowMod.getHardTimeout());
    jGen.writeStringField("outPort", flowMod.getOutPort().toString());

    switch (flowMod.getVersion()) {
    case OF_10:
        break;
    case OF_11:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    case OF_12:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    case OF_13:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        break;
    case OF_14:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    default:
        logger.error("Could not decode OFVersion {}", flowMod.getVersion());
        break;
    }

    MatchSerializer.serializeMatch(jGen, flowMod.getMatch());

    // handle OF1.1+ instructions with actions within
    if (flowMod.getVersion() == OFVersion.OF_10) {
        jGen.writeObjectFieldStart("actions");
        OFActionListSerializer.serializeActions(jGen, flowMod.getActions());
        jGen.writeEndObject();
    } else {
        OFInstructionListSerializer.serializeInstructionList(jGen, flowMod.getInstructions());
    } // end not-empty instructions (else)
    jGen.writeEndObject();
}
项目:floodlight1.2-delay    文件:StatsReplySerializer.java   
public static void serializeFlowReply(List<OFFlowStatsReply> flowReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    /* start the array before each reply */
    jGen.writeFieldName("flows"); 
    jGen.writeStartArray();
    for (OFFlowStatsReply flowReply : flowReplies) { // for each flow stats reply
        List<OFFlowStatsEntry> entries = flowReply.getEntries();
        for (OFFlowStatsEntry entry : entries) { // for each flow
            jGen.writeStartObject();
            // list flow stats/info
            jGen.writeStringField("version", entry.getVersion().toString()); // return the enum name
            jGen.writeNumberField("cookie", entry.getCookie().getValue());
            jGen.writeStringField("tableId", entry.getTableId().toString());
            jGen.writeNumberField("packetCount", entry.getPacketCount().getValue());
            jGen.writeNumberField("byteCount", entry.getByteCount().getValue());
            jGen.writeNumberField("durationSeconds", entry.getDurationSec());
            jGen.writeNumberField("durationNSeconds", entry.getDurationNsec());
            jGen.writeNumberField("priority", entry.getPriority());
            jGen.writeNumberField("idleTimeoutSec", entry.getIdleTimeout());
            jGen.writeNumberField("hardTimeoutSec", entry.getHardTimeout());
            switch (entry.getVersion()) {
            case OF_10:
                // flags not supported
                break;
            case OF_11:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(entry.getFlags()));
                break;
            case OF_12:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(entry.getFlags()));
                break;
            case OF_13:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(entry.getFlags()));
                break;
            case OF_14:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(entry.getFlags()));
                break;
            default:
                logger.error("Could not decode OFVersion {}", entry.getVersion());
                break;
            }

            MatchSerializer.serializeMatch(jGen, entry.getMatch());

            // handle OF1.1+ instructions with actions within
            if (entry.getVersion() == OFVersion.OF_10) {
                jGen.writeObjectFieldStart("actions");
                OFActionListSerializer.serializeActions(jGen, entry.getActions());
                jGen.writeEndObject();
            } else {
                OFInstructionListSerializer.serializeInstructionList(jGen, entry.getInstructions());
            }

            jGen.writeEndObject();
        } // end for each OFFlowStatsReply entry */
    } // end for each OFStatsReply
    //jGen.writeEndObject();
    jGen.writeEndArray();
}
项目:floodlight-hardware    文件:OFFlowModSerializer.java   
public static void serializeFlowMod(JsonGenerator jGen, OFFlowMod flowMod) throws IOException, JsonProcessingException {

        jGen.configure(Feature.WRITE_NUMBERS_AS_STRINGS, true); // IMHO this just looks nicer and is easier to read if everything is quoted

        jGen.writeStartObject();
        jGen.writeStringField("version", flowMod.getVersion().toString()); // return the enum names
        jGen.writeStringField("command", flowMod.getCommand().toString());
        jGen.writeNumberField("cookie", flowMod.getCookie().getValue());
        jGen.writeNumberField("priority", flowMod.getPriority());
        jGen.writeNumberField("idleTimeoutSec", flowMod.getIdleTimeout());
        jGen.writeNumberField("hardTimeoutSec", flowMod.getHardTimeout());
        jGen.writeStringField("outPort", flowMod.getOutPort().toString());

        switch (flowMod.getVersion()) {
        case OF_10:
            break;
        case OF_11:
            jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(flowMod.getFlags()));
            jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
            jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
            jGen.writeStringField("tableId", flowMod.getTableId().toString());
            break;
        case OF_12:
            jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(flowMod.getFlags()));
            jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
            jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
            jGen.writeStringField("tableId", flowMod.getTableId().toString());
            break;
        case OF_13:
            jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(flowMod.getFlags()));
            jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
            jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
            break;
        case OF_14:
            jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(flowMod.getFlags()));
            jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
            jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
            jGen.writeStringField("tableId", flowMod.getTableId().toString());
            break;
        default:
            logger.error("Could not decode OFVersion {}", flowMod.getVersion());
            break;
        }

        MatchSerializer.serializeMatch(jGen, flowMod.getMatch());

        // handle OF1.1+ instructions with actions within
        if (flowMod.getVersion() == OFVersion.OF_10) {
            jGen.writeObjectFieldStart("actions");
            OFActionListSerializer.serializeActions(jGen, flowMod.getActions());
            jGen.writeEndObject();
        } else {
            OFInstructionListSerializer.serializeInstructionList(jGen, flowMod.getInstructions());
        } // end not-empty instructions (else)
        jGen.writeEndObject();
    }
项目:floodlight-hardware    文件:StatsReplySerializer.java   
public static void serializeFlowReply(List<OFFlowStatsReply> flowReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    /* start the array before each reply */
    jGen.writeFieldName("flows");
    jGen.writeStartArray();
    for (OFFlowStatsReply flowReply : flowReplies) { // for each flow stats reply
        List<OFFlowStatsEntry> entries = flowReply.getEntries();
        for (OFFlowStatsEntry entry : entries) { // for each flow
            jGen.writeStartObject();
            // list flow stats/info
            jGen.writeStringField("version", entry.getVersion().toString()); // return the enum name
            jGen.writeNumberField("cookie", entry.getCookie().getValue());
            jGen.writeStringField("tableId", entry.getTableId().toString());
            jGen.writeNumberField("packetCount", entry.getPacketCount().getValue());
            jGen.writeNumberField("byteCount", entry.getByteCount().getValue());
            jGen.writeNumberField("durationSeconds", entry.getDurationSec());
            jGen.writeNumberField("durationNSeconds", entry.getDurationNsec());
            jGen.writeNumberField("priority", entry.getPriority());
            jGen.writeNumberField("idleTimeoutSec", entry.getIdleTimeout());
            jGen.writeNumberField("hardTimeoutSec", entry.getHardTimeout());
            switch (entry.getVersion()) {
            case OF_10:
                // flags not supported
                break;
            case OF_11:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(entry.getFlags()));
                break;
            case OF_12:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(entry.getFlags()));
                break;
            case OF_13:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(entry.getFlags()));
                break;
            case OF_14:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(entry.getFlags()));
                break;
            default:
                logger.error("Could not decode OFVersion {}", entry.getVersion());
                break;
            }

            MatchSerializer.serializeMatch(jGen, entry.getMatch());

            // handle OF1.1+ instructions with actions within
            if (entry.getVersion() == OFVersion.OF_10) {
                jGen.writeObjectFieldStart("actions");
                OFActionListSerializer.serializeActions(jGen, entry.getActions());
                jGen.writeEndObject();
            } else {
                OFInstructionListSerializer.serializeInstructionList(jGen, entry.getInstructions());
            }

            jGen.writeEndObject();
        } // end for each OFFlowStatsReply entry */
    } // end for each OFStatsReply
    //jGen.writeEndObject();
    jGen.writeEndArray();
}
项目:ACAMPController    文件:OFFlowModSerializer.java   
public static void serializeFlowMod(JsonGenerator jGen, OFFlowMod flowMod) throws IOException, JsonProcessingException {

       jGen.configure(Feature.WRITE_NUMBERS_AS_STRINGS, true); // IMHO this just looks nicer and is easier to read if everything is quoted

    jGen.writeStartObject();
    jGen.writeStringField("version", flowMod.getVersion().toString()); // return the enum names
    jGen.writeStringField("command", flowMod.getCommand().toString());
    jGen.writeNumberField("cookie", flowMod.getCookie().getValue());
    jGen.writeNumberField("priority", flowMod.getPriority());
    jGen.writeNumberField("idleTimeoutSec", flowMod.getIdleTimeout());
    jGen.writeNumberField("hardTimeoutSec", flowMod.getHardTimeout());
    jGen.writeStringField("outPort", flowMod.getOutPort().toString());

    switch (flowMod.getVersion()) {
    case OF_10:
        break;
    case OF_11:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    case OF_12:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    case OF_13:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        break;
    case OF_14:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    default:
        logger.error("Could not decode OFVersion {}", flowMod.getVersion());
        break;
    }

    MatchSerializer.serializeMatch(jGen, flowMod.getMatch());

    // handle OF1.1+ instructions with actions within
    if (flowMod.getVersion() == OFVersion.OF_10) {
        jGen.writeObjectFieldStart("actions");
        OFActionListSerializer.serializeActions(jGen, flowMod.getActions());
        jGen.writeEndObject();
    } else {
        OFInstructionListSerializer.serializeInstructionList(jGen, flowMod.getInstructions());
    } // end not-empty instructions (else)
    jGen.writeEndObject();
}
项目:ACAMPController    文件:StatsReplySerializer.java   
public static void serializeFlowReply(List<OFFlowStatsReply> flowReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    /* start the array before each reply */
    jGen.writeFieldName("flows"); 
    jGen.writeStartArray();
    for (OFFlowStatsReply flowReply : flowReplies) { // for each flow stats reply
        List<OFFlowStatsEntry> entries = flowReply.getEntries();
        for (OFFlowStatsEntry entry : entries) { // for each flow
            jGen.writeStartObject();
            // list flow stats/info
            jGen.writeStringField("version", entry.getVersion().toString()); // return the enum name
            jGen.writeNumberField("cookie", entry.getCookie().getValue());
            jGen.writeStringField("tableId", entry.getTableId().toString());
            jGen.writeNumberField("packetCount", entry.getPacketCount().getValue());
            jGen.writeNumberField("byteCount", entry.getByteCount().getValue());
            jGen.writeNumberField("durationSeconds", entry.getDurationSec());
            jGen.writeNumberField("durationNSeconds", entry.getDurationNsec());
            jGen.writeNumberField("priority", entry.getPriority());
            jGen.writeNumberField("idleTimeoutSec", entry.getIdleTimeout());
            jGen.writeNumberField("hardTimeoutSec", entry.getHardTimeout());
            switch (entry.getVersion()) {
            case OF_10:
                // flags not supported
                break;
            case OF_11:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(entry.getFlags()));
                break;
            case OF_12:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(entry.getFlags()));
                break;
            case OF_13:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(entry.getFlags()));
                break;
            case OF_14:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(entry.getFlags()));
                break;
            default:
                logger.error("Could not decode OFVersion {}", entry.getVersion());
                break;
            }

            MatchSerializer.serializeMatch(jGen, entry.getMatch());

            // handle OF1.1+ instructions with actions within
            if (entry.getVersion() == OFVersion.OF_10) {
                jGen.writeObjectFieldStart("actions");
                OFActionListSerializer.serializeActions(jGen, entry.getActions());
                jGen.writeEndObject();
            } else {
                OFInstructionListSerializer.serializeInstructionList(jGen, entry.getInstructions());
            }

            jGen.writeEndObject();
        } // end for each OFFlowStatsReply entry */
    } // end for each OFStatsReply
    //jGen.writeEndObject();
    jGen.writeEndArray();
}
项目:fast-failover-demo    文件:OFFlowModSerializer.java   
public static void serializeFlowMod(JsonGenerator jGen, OFFlowMod flowMod) throws IOException, JsonProcessingException {

       jGen.configure(Feature.WRITE_NUMBERS_AS_STRINGS, true); // IMHO this just looks nicer and is easier to read if everything is quoted

    jGen.writeStartObject();
    jGen.writeStringField("version", flowMod.getVersion().toString()); // return the enum names
    jGen.writeStringField("command", flowMod.getCommand().toString());
    jGen.writeNumberField("cookie", flowMod.getCookie().getValue());
    jGen.writeNumberField("priority", flowMod.getPriority());
    jGen.writeNumberField("idleTimeoutSec", flowMod.getIdleTimeout());
    jGen.writeNumberField("hardTimeoutSec", flowMod.getHardTimeout());
    jGen.writeStringField("outPort", flowMod.getOutPort().toString());

    switch (flowMod.getVersion()) {
    case OF_10:
        break;
    case OF_11:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    case OF_12:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    case OF_13:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        break;
    case OF_14:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    default:
        logger.error("Could not decode OFVersion {}", flowMod.getVersion());
        break;
    }

    MatchSerializer.serializeMatch(jGen, flowMod.getMatch());

    // handle OF1.1+ instructions with actions within
    if (flowMod.getVersion() == OFVersion.OF_10) {
        jGen.writeObjectFieldStart("actions");
        OFActionListSerializer.serializeActions(jGen, flowMod.getActions());
        jGen.writeEndObject();
    } else {
        OFInstructionListSerializer.serializeInstructionList(jGen, flowMod.getInstructions());
    } // end not-empty instructions (else)
    jGen.writeEndObject();
}
项目:fast-failover-demo    文件:StatsReplySerializer.java   
public static void serializeFlowReply(List<OFFlowStatsReply> flowReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    /* start the array before each reply */
    jGen.writeFieldName("flows"); 
    jGen.writeStartArray();
    for (OFFlowStatsReply flowReply : flowReplies) { // for each flow stats reply
        List<OFFlowStatsEntry> entries = flowReply.getEntries();
        for (OFFlowStatsEntry entry : entries) { // for each flow
            jGen.writeStartObject();
            // list flow stats/info
            jGen.writeStringField("version", entry.getVersion().toString()); // return the enum name
            jGen.writeNumberField("cookie", entry.getCookie().getValue());
            jGen.writeStringField("tableId", entry.getTableId().toString());
            jGen.writeNumberField("packetCount", entry.getPacketCount().getValue());
            jGen.writeNumberField("byteCount", entry.getByteCount().getValue());
            jGen.writeNumberField("durationSeconds", entry.getDurationSec());
            jGen.writeNumberField("priority", entry.getPriority());
            jGen.writeNumberField("idleTimeoutSec", entry.getIdleTimeout());
            jGen.writeNumberField("hardTimeoutSec", entry.getHardTimeout());
            switch (entry.getVersion()) {
            case OF_10:
                // flags not supported
                break;
            case OF_11:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(entry.getFlags()));
                break;
            case OF_12:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(entry.getFlags()));
                break;
            case OF_13:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(entry.getFlags()));
                break;
            case OF_14:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(entry.getFlags()));
                break;
            default:
                logger.error("Could not decode OFVersion {}", entry.getVersion());
                break;
            }

            MatchSerializer.serializeMatch(jGen, entry.getMatch());

            // handle OF1.1+ instructions with actions within
            if (entry.getVersion() == OFVersion.OF_10) {
                jGen.writeObjectFieldStart("actions");
                OFActionListSerializer.serializeActions(jGen, entry.getActions());
                jGen.writeEndObject();
            } else {
                OFInstructionListSerializer.serializeInstructionList(jGen, entry.getInstructions());
            }

            jGen.writeEndObject();
        } // end for each OFFlowStatsReply entry */
    } // end for each OFStatsReply
    //jGen.writeEndObject();
    jGen.writeEndArray();
}
项目:floodlightLB    文件:OFFlowModSerializer.java   
public static void serializeFlowMod(JsonGenerator jGen, OFFlowMod flowMod) throws IOException, JsonProcessingException {

       jGen.configure(Feature.WRITE_NUMBERS_AS_STRINGS, true); // IMHO this just looks nicer and is easier to read if everything is quoted

    jGen.writeStartObject();
    jGen.writeStringField("version", flowMod.getVersion().toString()); // return the enum names
    jGen.writeStringField("command", flowMod.getCommand().toString());
    jGen.writeNumberField("cookie", flowMod.getCookie().getValue());
    jGen.writeNumberField("priority", flowMod.getPriority());
    jGen.writeNumberField("idleTimeoutSec", flowMod.getIdleTimeout());
    jGen.writeNumberField("hardTimeoutSec", flowMod.getHardTimeout());
    jGen.writeStringField("outPort", flowMod.getOutPort().toString());

    switch (flowMod.getVersion()) {
    case OF_10:
        break;
    case OF_11:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    case OF_12:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    case OF_13:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        break;
    case OF_14:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    default:
        logger.error("Could not decode OFVersion {}", flowMod.getVersion());
        break;
    }

    MatchSerializer.serializeMatch(jGen, flowMod.getMatch());

    // handle OF1.1+ instructions with actions within
    if (flowMod.getVersion() == OFVersion.OF_10) {
        jGen.writeObjectFieldStart("actions");
        OFActionListSerializer.serializeActions(jGen, flowMod.getActions());
        jGen.writeEndObject();
    } else {
        OFInstructionListSerializer.serializeInstructionList(jGen, flowMod.getInstructions());
    } // end not-empty instructions (else)
    jGen.writeEndObject();
}
项目:floodlightLB    文件:StatsReplySerializer.java   
public static void serializeFlowReply(List<OFFlowStatsReply> flowReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    /* start the array before each reply */
    jGen.writeFieldName("flows"); 
    jGen.writeStartArray();
    for (OFFlowStatsReply flowReply : flowReplies) { // for each flow stats reply
        List<OFFlowStatsEntry> entries = flowReply.getEntries();
        for (OFFlowStatsEntry entry : entries) { // for each flow
            jGen.writeStartObject();
            // list flow stats/info
            jGen.writeStringField("version", entry.getVersion().toString()); // return the enum name
            jGen.writeNumberField("cookie", entry.getCookie().getValue());
            jGen.writeStringField("tableId", entry.getTableId().toString());
            jGen.writeNumberField("packetCount", entry.getPacketCount().getValue());
            jGen.writeNumberField("byteCount", entry.getByteCount().getValue());
            jGen.writeNumberField("durationSeconds", entry.getDurationSec());
            jGen.writeNumberField("priority", entry.getPriority());
            jGen.writeNumberField("idleTimeoutSec", entry.getIdleTimeout());
            jGen.writeNumberField("hardTimeoutSec", entry.getHardTimeout());
            switch (entry.getVersion()) {
            case OF_10:
                // flags not supported
                break;
            case OF_11:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(entry.getFlags()));
                break;
            case OF_12:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(entry.getFlags()));
                break;
            case OF_13:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(entry.getFlags()));
                break;
            case OF_14:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(entry.getFlags()));
                break;
            default:
                logger.error("Could not decode OFVersion {}", entry.getVersion());
                break;
            }

            MatchSerializer.serializeMatch(jGen, entry.getMatch());

            // handle OF1.1+ instructions with actions within
            if (entry.getVersion() == OFVersion.OF_10) {
                jGen.writeObjectFieldStart("actions");
                OFActionListSerializer.serializeActions(jGen, entry.getActions());
                jGen.writeEndObject();
            } else {
                OFInstructionListSerializer.serializeInstructionList(jGen, entry.getInstructions());
            }

            jGen.writeEndObject();
        } // end for each OFFlowStatsReply entry */
    } // end for each OFStatsReply
    //jGen.writeEndObject();
    jGen.writeEndArray();
}
项目:DSC    文件:OFFlowModSerializer.java   
public static void serializeFlowMod(JsonGenerator jGen, OFFlowMod flowMod) throws IOException, JsonProcessingException {

       jGen.configure(Feature.WRITE_NUMBERS_AS_STRINGS, true); // IMHO this just looks nicer and is easier to read if everything is quoted

    jGen.writeStartObject();
    jGen.writeStringField("version", flowMod.getVersion().toString()); // return the enum names
    jGen.writeStringField("command", flowMod.getCommand().toString());
    jGen.writeNumberField("cookie", flowMod.getCookie().getValue());
    jGen.writeNumberField("priority", flowMod.getPriority());
    jGen.writeNumberField("idleTimeoutSec", flowMod.getIdleTimeout());
    jGen.writeNumberField("hardTimeoutSec", flowMod.getHardTimeout());
    jGen.writeStringField("outPort", flowMod.getOutPort().toString());

    switch (flowMod.getVersion()) {
    case OF_10:
        break;
    case OF_11:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    case OF_12:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    case OF_13:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        break;
    case OF_14:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(flowMod.getFlags()));
        jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
        jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
        jGen.writeStringField("tableId", flowMod.getTableId().toString());
        break;
    default:
        logger.error("Could not decode OFVersion {}", flowMod.getVersion());
        break;
    }

    MatchSerializer.serializeMatch(jGen, flowMod.getMatch());

    // handle OF1.1+ instructions with actions within
    if (flowMod.getVersion() == OFVersion.OF_10) {
        jGen.writeObjectFieldStart("actions");
        OFActionListSerializer.serializeActions(jGen, flowMod.getActions());
        jGen.writeEndObject();
    } else {
        OFInstructionListSerializer.serializeInstructionList(jGen, flowMod.getInstructions());
    } // end not-empty instructions (else)
    jGen.writeEndObject();
}
项目:DSC    文件:StatsReplySerializer.java   
public static void serializeFlowReply(List<OFFlowStatsReply> flowReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    /* start the array before each reply */
    jGen.writeFieldName("flows"); 
    jGen.writeStartArray();
    for (OFFlowStatsReply flowReply : flowReplies) { // for each flow stats reply
        List<OFFlowStatsEntry> entries = flowReply.getEntries();
        for (OFFlowStatsEntry entry : entries) { // for each flow
            jGen.writeStartObject();
            // list flow stats/info
            jGen.writeStringField("version", entry.getVersion().toString()); // return the enum name
            jGen.writeNumberField("cookie", entry.getCookie().getValue());
            jGen.writeStringField("tableId", entry.getTableId().toString());
            jGen.writeNumberField("packetCount", entry.getPacketCount().getValue());
            jGen.writeNumberField("byteCount", entry.getByteCount().getValue());
            jGen.writeNumberField("durationSeconds", entry.getDurationSec());
            jGen.writeNumberField("priority", entry.getPriority());
            jGen.writeNumberField("idleTimeoutSec", entry.getIdleTimeout());
            jGen.writeNumberField("hardTimeoutSec", entry.getHardTimeout());
            switch (entry.getVersion()) {
            case OF_10:
                // flags not supported
                break;
            case OF_11:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(entry.getFlags()));
                break;
            case OF_12:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(entry.getFlags()));
                break;
            case OF_13:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(entry.getFlags()));
                break;
            case OF_14:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(entry.getFlags()));
                break;
            default:
                logger.error("Could not decode OFVersion {}", entry.getVersion());
                break;
            }

            MatchSerializer.serializeMatch(jGen, entry.getMatch());

            // handle OF1.1+ instructions with actions within
            if (entry.getVersion() == OFVersion.OF_10) {
                jGen.writeObjectFieldStart("actions");
                OFActionListSerializer.serializeActions(jGen, entry.getActions());
                jGen.writeEndObject();
            } else {
                OFInstructionListSerializer.serializeInstructionList(jGen, entry.getInstructions());
            }

            jGen.writeEndObject();
        } // end for each OFFlowStatsReply entry */
    } // end for each OFStatsReply
    //jGen.writeEndObject();
    jGen.writeEndArray();
}
项目:floodlight    文件:OFFlowModSerializer.java   
public static void serializeFlowMod(JsonGenerator jGen, OFFlowMod flowMod) throws IOException, JsonProcessingException {

       jGen.configure(Feature.WRITE_NUMBERS_AS_STRINGS, true); // IMHO this just looks nicer and is easier to read if everything is quoted

    jGen.writeStartObject();
    jGen.writeStringField("version", flowMod.getVersion().toString()); // return the enum names
    jGen.writeStringField("command", flowMod.getCommand().toString());
    jGen.writeNumberField("cookie", flowMod.getCookie().getValue());
    jGen.writeNumberField("cookieMask", flowMod.getCookieMask().getValue());
    jGen.writeStringField("tableId", flowMod.getTableId().toString());
    jGen.writeNumberField("priority", flowMod.getPriority());
    jGen.writeNumberField("idleTimeoutSec", flowMod.getIdleTimeout());
    jGen.writeNumberField("hardTimeoutSec", flowMod.getHardTimeout());
    jGen.writeStringField("outGroup", flowMod.getOutGroup().toString());
    jGen.writeStringField("outPort", flowMod.getOutPort().toString());

    switch (flowMod.getVersion()) {
    case OF_10:
        break;
    case OF_11:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(flowMod.getFlags()));
        break;
    case OF_12:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(flowMod.getFlags()));
        break;
    case OF_13:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(flowMod.getFlags()));
        break;
    case OF_14:
        jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(flowMod.getFlags()));
        break;
    default:
        logger.error("Could not decode OFVersion {}", flowMod.getVersion());
        break;
    }

    MatchSerializer.serializeMatch(jGen, flowMod.getMatch());

    // handle OF1.1+ instructions with actions within
    if (flowMod.getVersion() == OFVersion.OF_10) {
        jGen.writeObjectFieldStart("actions");
        OFActionListSerializer.serializeActions(jGen, flowMod.getActions());
        jGen.writeEndObject();
    } else {
        OFInstructionListSerializer.serializeInstructionList(jGen, flowMod.getInstructions());
    } // end not-empty instructions (else)
    jGen.writeEndObject();
}
项目:floodlight    文件:StatsReplySerializer.java   
public static void serializeFlowReply(List<OFFlowStatsReply> flowReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    for (OFFlowStatsReply flowReply : flowReplies) { // for each flow stats reply
        //Dose the switch will reply multiple OFFlowStatsReply ?
        //Or we juse need to use the first item of the list.
        List<OFFlowStatsEntry> entries = flowReply.getEntries();
        jGen.writeFieldName("flows");
        jGen.writeStartArray();
        for (OFFlowStatsEntry entry : entries) { // for each flow
            jGen.writeStartObject();
            // list flow stats/info
            jGen.writeStringField("version", entry.getVersion().toString()); // return the enum name
            jGen.writeNumberField("cookie", entry.getCookie().getValue());
            jGen.writeStringField("tableId", entry.getTableId().toString());
            jGen.writeNumberField("packetCount", entry.getPacketCount().getValue());
            jGen.writeNumberField("byteCount", entry.getByteCount().getValue());
            jGen.writeNumberField("durationSeconds", entry.getDurationSec());
            jGen.writeNumberField("priority", entry.getPriority());
            jGen.writeNumberField("idleTimeoutSec", entry.getIdleTimeout());
            jGen.writeNumberField("hardTimeoutSec", entry.getHardTimeout());
            switch (entry.getVersion()) {
            case OF_10:
                // flags not supported
                break;
            case OF_11:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(entry.getFlags()));
                break;
            case OF_12:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(entry.getFlags()));
                break;
            case OF_13:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(entry.getFlags()));
                break;
            case OF_14:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(entry.getFlags()));
                break;
            default:
                logger.error("Could not decode OFVersion {}", entry.getVersion());
                break;
            }

            MatchSerializer.serializeMatch(jGen, entry.getMatch());

            // handle OF1.1+ instructions with actions within
            if (entry.getVersion() == OFVersion.OF_10) {
                jGen.writeObjectFieldStart("actions");
                OFActionListSerializer.serializeActions(jGen, entry.getActions());
                jGen.writeEndObject();
            } else {
                OFInstructionListSerializer.serializeInstructionList(jGen, entry.getInstructions());
            }

            jGen.writeEndObject();
        } // end for each OFFlowStatsReply entry
        jGen.writeEndArray();
    } // end for each OFStatsReply
}