当前位置: 首页>>代码示例>>Java>>正文


Java OFVersion.OF_10属性代码示例

本文整理汇总了Java中org.projectfloodlight.openflow.protocol.OFVersion.OF_10属性的典型用法代码示例。如果您正苦于以下问题:Java OFVersion.OF_10属性的具体用法?Java OFVersion.OF_10怎么用?Java OFVersion.OF_10使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.projectfloodlight.openflow.protocol.OFVersion的用法示例。


在下文中一共展示了OFVersion.OF_10属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: DhcpDiscoveryRequestOFPacketIn

/**
 * Generates a DHCP request OFPacketIn.
 * @param hostMac The host MAC address of for the request.
 * @return An OFPacketIn that contains a DHCP request packet.
 */
public static OFPacketIn DhcpDiscoveryRequestOFPacketIn(IOFSwitch sw,
        MacAddress hostMac) {
    byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
    OFFactory factory = sw.getOFFactory();
    OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
    if (factory.getVersion() == OFVersion.OF_10) {
    	packetInBuilder
    		.setInPort(OFPort.of(1))
            .setData(serializedPacket)
            .setReason(OFPacketInReason.NO_MATCH);
    } else {
    	packetInBuilder
    	.setMatch(factory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build())
        .setData(serializedPacket)
        .setReason(OFPacketInReason.NO_MATCH);
    }
    return packetInBuilder.build();
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:23,代码来源:PacketFactory.java

示例2: sendRoleRequest

@Override
public synchronized boolean sendRoleRequest(RoleState role, RoleRecvStatus exp)
        throws IOException {
    this.expectation = exp;

    if (sw.factory().getVersion() == OFVersion.OF_10) {
        Boolean supportsNxRole = sw.supportNxRole();
        if (!supportsNxRole) {
            log.debug("Switch driver indicates no support for Nicira "
                    + "role request messages. Not sending ...");
            handleUnsentRoleMessage(role,
                    expectation);
            return false;
        }
        // OF1.0 switch with support for NX_ROLE_REQUEST vendor extn.
        // make Role.EQUAL become Role.SLAVE
        RoleState roleToSend = (role == RoleState.EQUAL) ? RoleState.SLAVE : role;
        pendingReplies.put(sendNxRoleRequest(roleToSend), role);
    } else {
        // OF1.3 switch, use OFPT_ROLE_REQUEST message
        pendingReplies.put(sendOF13RoleRequest(role), role);
    }
    return true;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:RoleManager.java

示例3: startDriverHandshake

@Override
public void startDriverHandshake() {
    if (factory().getVersion() == OFVersion.OF_10) {
        OFFlowAdd.Builder fmBuilder = factory().buildFlowAdd();
        fmBuilder.setPriority(LOWEST_PRIORITY);
        sendHandshakeMessage(fmBuilder.build());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:8,代码来源:DefaultSwitchHandshaker.java

示例4: getPorts

@Override
public List<OFPortDesc> getPorts() {
    if (this.factory().getVersion() == OFVersion.OF_10) {
        return Collections.unmodifiableList(features.getPorts());
    } else {
        return Collections.unmodifiableList(
                ports.stream().flatMap(p -> p.getEntries().stream())
                        .collect(Collectors.toList()));
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:DefaultSwitchHandshaker.java

示例5: supportNxRole

@Override
public Boolean supportNxRole() {
    if (this.factory().getVersion() == OFVersion.OF_10) {
        return true;
    }
    return false;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:7,代码来源:NiciraSwitchHandshaker.java

示例6: cookie

@Override
public Optional<Long> cookie() {
    checkPermission(PACKET_READ);
    if (pktin.getVersion() != OFVersion.OF_10) {
        return Optional.of(pktin.getCookie().getValue());
    } else {
        return Optional.empty();
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:DefaultOpenFlowPacketContext.java

示例7: processOFHello

@Override
void processOFHello(OFChannelHandler h, OFHello m)
        throws IOException {
    // TODO We could check for the optional bitmap, but for now
    // we are just checking the version number.
    if (m.getVersion().getWireVersion() >= OFVersion.OF_13.getWireVersion()) {
        log.debug("Received {} Hello from {} - switching to OF "
                + "version 1.3", m.getVersion(),
                h.channel.getRemoteAddress());
        h.sendHandshakeHelloMessage();
        h.ofVersion = OFVersion.OF_13;
    } else if (m.getVersion().getWireVersion() >= OFVersion.OF_10.getWireVersion()) {
        log.debug("Received {} Hello from {} - switching to OF "
                + "version 1.0", m.getVersion(),
                h.channel.getRemoteAddress());
        OFHello hi =
                h.factory10.buildHello()
                        .setXid(h.handshakeTransactionIds--)
                        .build();
        h.channel.write(Collections.singletonList(hi));
        h.ofVersion = OFVersion.OF_10;
    } else {
        log.error("Received Hello of version {} from switch at {}. "
                + "This controller works with OF1.0 and OF1.3 "
                + "switches. Disconnecting switch ...",
                m.getVersion(), h.channel.getRemoteAddress());
        h.channel.disconnect();
        return;
    }
    h.sendHandshakeFeaturesRequestMessage();
    h.setState(WAIT_FEATURES_REPLY);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:32,代码来源:OFChannelHandler.java

示例8: isGroupSupported

private boolean isGroupSupported(OpenFlowSwitch sw) {
    if (sw.factory().getVersion() == OFVersion.OF_10 ||
            sw.factory().getVersion() == OFVersion.OF_11 ||
            sw.factory().getVersion() == OFVersion.OF_12) {
        return false;
    }

    return true;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:OpenFlowGroupProvider.java

示例9: isMeterSupported

private boolean isMeterSupported(OpenFlowSwitch sw) {
    if (sw.factory().getVersion() == OFVersion.OF_10 ||
            sw.factory().getVersion() == OFVersion.OF_11 ||
            sw.factory().getVersion() == OFVersion.OF_12 ||
            sw.softwareDescription().equals("OF-DPA 2.0")) {
        return false;
    }

    return true;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:OpenFlowMeterProvider.java

示例10: pktinInPort

private OFPort pktinInPort() {
    if (pktin.getVersion() == OFVersion.OF_10) {
        return pktin.getInPort();
    }
    return pktin.getMatch().get(MatchField.IN_PORT);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:6,代码来源:DefaultOpenFlowPacketContext.java

示例11: build

public FlowEntry build(FlowEntryState... state) {
    FlowRule.Builder builder;
    try {
        switch (this.type) {
            case STAT:
                builder = DefaultFlowRule.builder()
                        .forDevice(deviceId)
                        .withSelector(buildSelector())
                        .withTreatment(buildTreatment())
                        .withPriority(stat.getPriority())
                        .makeTemporary(stat.getIdleTimeout())
                        .withCookie(stat.getCookie().getValue());
                if (stat.getVersion() != OFVersion.OF_10) {
                    builder.forTable(stat.getTableId().getValue());
                }

                return new DefaultFlowEntry(builder.build(), FlowEntryState.ADDED,
                                            stat.getDurationSec(),
                                            stat.getPacketCount().getValue(),
                                            stat.getByteCount().getValue());
            case REMOVED:
                builder = DefaultFlowRule.builder()
                        .forDevice(deviceId)
                        .withSelector(buildSelector())
                        .withPriority(removed.getPriority())
                        .makeTemporary(removed.getIdleTimeout())
                        .withCookie(removed.getCookie().getValue());
                if (removed.getVersion() != OFVersion.OF_10) {
                    builder.forTable(removed.getTableId().getValue());
                }

                return new DefaultFlowEntry(builder.build(), FlowEntryState.REMOVED,
                                            removed.getDurationSec(),
                                            removed.getPacketCount().getValue(),
                                            removed.getByteCount().getValue());
            case MOD:
                FlowEntryState flowState = state.length > 0 ? state[0] : FlowEntryState.FAILED;
                builder = DefaultFlowRule.builder()
                        .forDevice(deviceId)
                        .withSelector(buildSelector())
                        .withTreatment(buildTreatment())
                        .withPriority(flowMod.getPriority())
                        .makeTemporary(flowMod.getIdleTimeout())
                        .withCookie(flowMod.getCookie().getValue());
                if (flowMod.getVersion() != OFVersion.OF_10) {
                    builder.forTable(flowMod.getTableId().getValue());
                }

                return new DefaultFlowEntry(builder.build(), flowState, 0, 0, 0);
            default:
                log.error("Unknown flow type : {}", this.type);
                return null;
        }
    } catch (UnsupportedOperationException e) {
        log.warn("Error building flow entry", e);
        return null;
    }

}
 
开发者ID:shlee89,项目名称:athena,代码行数:59,代码来源:FlowEntryBuilder.java

示例12: serializePorts

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

                jGen.writeFieldName("curr");
                jGen.writeStartArray();
                for(OFPortFeatures curr : port.getCurr()){
                    jGen.writeString(curr.toString());
                }
                jGen.writeEndArray();
                jGen.writeFieldName("advertised");
                jGen.writeStartArray();
                for(OFPortFeatures advertised : port.getAdvertised()){
                    jGen.writeString(advertised.toString());
                }
                jGen.writeEndArray();
                jGen.writeFieldName("supported");
                jGen.writeStartArray();
                for(OFPortFeatures support : port.getSupported()){
                    jGen.writeString(support.toString());
                }
                jGen.writeEndArray();
                jGen.writeFieldName("peer");
                jGen.writeStartArray();
                for(OFPortFeatures peer : port.getPeer()){
                    jGen.writeString(peer.toString());
                }
                jGen.writeEndArray();
                jGen.writeEndObject();
            }
            jGen.writeEndArray();
    
        }
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:59,代码来源:IOFSwitchSerializer.java

示例13: serializeFlowMod

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();
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:56,代码来源:OFFlowModSerializer.java

示例14: serializeFlowReply

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();
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:57,代码来源:StatsReplySerializer.java

示例15: serializePortDesc

public static void serializePortDesc(List<OFPortDesc> portDescList, JsonGenerator jGen) throws IOException, JsonProcessingException {
	jGen.writeFieldName("portDesc");
	jGen.writeStartArray();
	for(OFPortDesc entry : portDescList) {
		jGen.writeStartObject();
		jGen.writeStringField("portNumber",entry.getPortNo().toString());
		jGen.writeStringField("hardwareAddress", entry.getHwAddr().toString());
		jGen.writeStringField("name", entry.getName());
		switch(entry.getVersion()) {
		case OF_10:
			jGen.writeNumberField("config", OFPortConfigSerializerVer10.toWireValue(entry.getConfig()));
			jGen.writeNumberField("state", OFPortStateSerializerVer10.toWireValue(entry.getState()));
			jGen.writeNumberField("currentFeatures", OFPortFeaturesSerializerVer10.toWireValue(entry.getCurr()));
			jGen.writeNumberField("advertisedFeatures", OFPortFeaturesSerializerVer10.toWireValue(entry.getAdvertised()));
			jGen.writeNumberField("supportedFeatures", OFPortFeaturesSerializerVer10.toWireValue(entry.getSupported()));
			jGen.writeNumberField("peerFeatures", OFPortFeaturesSerializerVer10.toWireValue(entry.getPeer()));
			break;
		case OF_11:
			jGen.writeNumberField("config", OFPortConfigSerializerVer11.toWireValue(entry.getConfig()));
			jGen.writeNumberField("state", OFPortStateSerializerVer11.toWireValue(entry.getState()));
			jGen.writeNumberField("currentFeatures", OFPortFeaturesSerializerVer11.toWireValue(entry.getCurr()));
			jGen.writeNumberField("advertisedFeatures", OFPortFeaturesSerializerVer11.toWireValue(entry.getAdvertised()));
			jGen.writeNumberField("supportedFeatures", OFPortFeaturesSerializerVer11.toWireValue(entry.getSupported()));
			jGen.writeNumberField("peerFeatures", OFPortFeaturesSerializerVer11.toWireValue(entry.getPeer()));
			break;
		case OF_12:
			jGen.writeNumberField("config", OFPortConfigSerializerVer12.toWireValue(entry.getConfig()));
			jGen.writeNumberField("state", OFPortStateSerializerVer12.toWireValue(entry.getState()));
			jGen.writeNumberField("currentFeatures", OFPortFeaturesSerializerVer12.toWireValue(entry.getCurr()));
			jGen.writeNumberField("advertisedFeatures", OFPortFeaturesSerializerVer12.toWireValue(entry.getAdvertised()));
			jGen.writeNumberField("supportedFeatures", OFPortFeaturesSerializerVer12.toWireValue(entry.getSupported()));
			jGen.writeNumberField("peerFeatures", OFPortFeaturesSerializerVer12.toWireValue(entry.getPeer()));
			break;
		case OF_13:
			jGen.writeNumberField("config", OFPortConfigSerializerVer13.toWireValue(entry.getConfig()));
			jGen.writeNumberField("state", OFPortStateSerializerVer13.toWireValue(entry.getState()));
			jGen.writeNumberField("currentFeatures", OFPortFeaturesSerializerVer13.toWireValue(entry.getCurr()));
			jGen.writeNumberField("advertisedFeatures", OFPortFeaturesSerializerVer13.toWireValue(entry.getAdvertised()));
			jGen.writeNumberField("supportedFeatures", OFPortFeaturesSerializerVer13.toWireValue(entry.getSupported()));
			jGen.writeNumberField("peerFeatures", OFPortFeaturesSerializerVer13.toWireValue(entry.getPeer()));
			break;
		case OF_14:
			// TODO
			logger.error("OF1.4 OFPortDesc serializer not implemented");
		}
		if (OFVersion.OF_10 != entry.getVersion()) {
			jGen.writeNumberField("currSpeed",entry.getCurrSpeed());
			jGen.writeNumberField("maxSpeed",entry.getMaxSpeed());
		}
		jGen.writeEndObject();
	}
	jGen.writeEndArray();
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:53,代码来源:StatsReplySerializer.java


注:本文中的org.projectfloodlight.openflow.protocol.OFVersion.OF_10属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。