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


Java MatchField类代码示例

本文整理汇总了Java中org.projectfloodlight.openflow.protocol.match.MatchField的典型用法代码示例。如果您正苦于以下问题:Java MatchField类的具体用法?Java MatchField怎么用?Java MatchField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: transitFlowMod

import org.projectfloodlight.openflow.protocol.match.MatchField; //导入依赖的package包/类
default OFFlowAdd transitFlowMod(int inputPort, int outputPort, int transitVlan, long cookie) {
    return ofFactory.buildFlowAdd()
            .setCookie(U64.of(cookie & FLOW_COOKIE_MASK))
            .setHardTimeout(FlowModUtils.INFINITE_TIMEOUT)
            .setIdleTimeout(FlowModUtils.INFINITE_TIMEOUT)
            .setBufferId(OFBufferId.NO_BUFFER)
            .setPriority(FlowModUtils.PRIORITY_VERY_HIGH)
            .setMatch(ofFactory.buildMatch()
                    .setExact(MatchField.IN_PORT, OFPort.of(inputPort))
                    .setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(transitVlan))
                    .build())
            .setInstructions(singletonList(
                    ofFactory.instructions().applyActions(singletonList(
                            ofFactory.actions().buildOutput()
                                    .setMaxLen(0xFFFFFFFF)
                                    .setPort(OFPort.of(outputPort))
                                    .build()))
                            .createBuilder()
                            .build()))
            .setXid(0L)
            .build();
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:23,代码来源:OutputCommands.java

示例2: oneSwitchNoneFlowMod

import org.projectfloodlight.openflow.protocol.match.MatchField; //导入依赖的package包/类
default OFFlowAdd oneSwitchNoneFlowMod(int inputPort, int outputPort, long meterId, long cookie) {
    return ofFactory.buildFlowAdd()
            .setCookie(U64.of(cookie & FLOW_COOKIE_MASK))
            .setHardTimeout(FlowModUtils.INFINITE_TIMEOUT)
            .setIdleTimeout(FlowModUtils.INFINITE_TIMEOUT)
            .setBufferId(OFBufferId.NO_BUFFER)
            .setPriority(FlowModUtils.PRIORITY_VERY_HIGH)
            .setMatch(ofFactory.buildMatch()
                    .setExact(MatchField.IN_PORT, OFPort.of(inputPort))
                    .build())
            .setInstructions(Arrays.asList(
                    ofFactory.instructions().buildMeter().setMeterId(meterId).build(),
                    ofFactory.instructions().applyActions(singletonList(
                            ofFactory.actions().buildOutput()
                                    .setMaxLen(0xFFFFFFFF)
                                    .setPort(OFPort.of(outputPort))
                                    .build()))
                            .createBuilder()
                            .build()))
            .setXid(0L)
            .build();
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:23,代码来源:OutputCommands.java

示例3: oneSwitchPopFlowMod

import org.projectfloodlight.openflow.protocol.match.MatchField; //导入依赖的package包/类
default OFFlowAdd oneSwitchPopFlowMod(int inputPort, int outputPort, int inputVlan, long meterId, long cookie) {
    return ofFactory.buildFlowAdd()
            .setCookie(U64.of(cookie & FLOW_COOKIE_MASK))
            .setHardTimeout(FlowModUtils.INFINITE_TIMEOUT)
            .setIdleTimeout(FlowModUtils.INFINITE_TIMEOUT)
            .setBufferId(OFBufferId.NO_BUFFER)
            .setPriority(FlowModUtils.PRIORITY_VERY_HIGH)
            .setMatch(ofFactory.buildMatch()
                    .setExact(MatchField.IN_PORT, OFPort.of(inputPort))
                    .setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(inputVlan))
                    .build())
            .setInstructions(Arrays.asList(
                    ofFactory.instructions().buildMeter().setMeterId(meterId).build(),
                    ofFactory.instructions().applyActions(Arrays.asList(
                            ofFactory.actions().popVlan(),
                            ofFactory.actions().buildOutput()
                                    .setMaxLen(0xFFFFFFFF)
                                    .setPort(OFPort.of(outputPort))
                                    .build()))
                            .createBuilder()
                            .build()))
            .setXid(0L)
            .build();
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:25,代码来源:OutputCommands.java

示例4: egressPopFlowMod

import org.projectfloodlight.openflow.protocol.match.MatchField; //导入依赖的package包/类
@Override
public OFFlowAdd egressPopFlowMod(int inputPort, int outputPort, int transitVlan, long cookie) {
    return ofFactory.buildFlowAdd()
            .setCookie(U64.of(cookie & FLOW_COOKIE_MASK))
            .setHardTimeout(FlowModUtils.INFINITE_TIMEOUT)
            .setIdleTimeout(FlowModUtils.INFINITE_TIMEOUT)
            .setBufferId(OFBufferId.NO_BUFFER)
            .setPriority(FlowModUtils.PRIORITY_VERY_HIGH)
            .setMatch(ofFactory.buildMatch()
                    .setExact(MatchField.IN_PORT, OFPort.of(inputPort))
                    .setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(transitVlan))
                    .build())
            .setInstructions(singletonList(
                    ofFactory.instructions().applyActions(Arrays.asList(
                            ofFactory.actions().popVlan(),
                            ofFactory.actions().popVlan(),
                            ofFactory.actions().buildOutput()
                                    .setMaxLen(0xFFFFFFFF)
                                    .setPort(OFPort.of(outputPort))
                                    .build()))
                            .createBuilder()
                            .build()))
            .setXid(0L)
            .build();
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:26,代码来源:PushSchemeOutputCommands.java

示例5: egressNoneFlowMod

import org.projectfloodlight.openflow.protocol.match.MatchField; //导入依赖的package包/类
@Override
public OFFlowAdd egressNoneFlowMod(int inputPort, int outputPort, int transitVlan, long cookie) {
    return ofFactory.buildFlowAdd()
            .setCookie(U64.of(cookie & FLOW_COOKIE_MASK))
            .setHardTimeout(FlowModUtils.INFINITE_TIMEOUT)
            .setIdleTimeout(FlowModUtils.INFINITE_TIMEOUT)
            .setBufferId(OFBufferId.NO_BUFFER)
            .setPriority(FlowModUtils.PRIORITY_VERY_HIGH)
            .setMatch(ofFactory.buildMatch()
                    .setExact(MatchField.IN_PORT, OFPort.of(inputPort))
                    .setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(transitVlan))
                    .build())
            .setInstructions(singletonList(
                    ofFactory.instructions().applyActions(Arrays.asList(
                            ofFactory.actions().popVlan(),
                            ofFactory.actions().buildOutput()
                                    .setMaxLen(0xFFFFFFFF)
                                    .setPort(OFPort.of(outputPort))
                                    .build()))
                            .createBuilder()
                            .build()))
            .setXid(0L)
            .build();
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:25,代码来源:PushSchemeOutputCommands.java

示例6: DhcpDiscoveryRequestOFPacketIn

import org.projectfloodlight.openflow.protocol.match.MatchField; //导入依赖的package包/类
/**
 * 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,代码行数:24,代码来源:PacketFactory.java

示例7: rewriteMatch

import org.projectfloodlight.openflow.protocol.match.MatchField; //导入依赖的package包/类
/**
 * Rewrite match object to use LINC OF optical extensions.
 *
 * @param match original match
 * @return rewritten match
 */
private Match rewriteMatch(Match match) {
    Match.Builder mBuilder = factory().buildMatch();
    for (MatchField mf : match.getMatchFields()) {
        if (mf == MatchField.EXP_OCH_SIG_ID) {
            mBuilder.setExact(MatchField.OCH_SIGID, (CircuitSignalID) match.get(mf));
            continue;
        }
        if (mf == MatchField.EXP_OCH_SIGTYPE) {
            mBuilder.setExact(MatchField.OCH_SIGTYPE, (U8) match.get(mf));
            continue;
        }
        mBuilder.setExact(mf, match.get(mf));
    }

    return mBuilder.build();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:OfOpticalSwitchImplLinc13.java

示例8: createHubPacketOut

import org.projectfloodlight.openflow.protocol.match.MatchField; //导入依赖的package包/类
private OFMessage createHubPacketOut(IOFSwitch sw, OFMessage msg) {
	OFPacketIn pi = (OFPacketIn) msg;
    OFPacketOut.Builder pob = sw.getOFFactory().buildPacketOut();
    pob.setBufferId(pi.getBufferId()).setXid(pi.getXid()).setInPort((pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)));
    
    // set actions
    OFActionOutput.Builder actionBuilder = sw.getOFFactory().actions().buildOutput();
    actionBuilder.setPort(OFPort.FLOOD);
    pob.setActions(Collections.singletonList((OFAction) actionBuilder.build()));

    // set data if it is included in the packetin
    if (pi.getBufferId() == OFBufferId.NO_BUFFER) {
        byte[] packetData = pi.getData();
        pob.setData(packetData);
    }
    return pob.build();  
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:18,代码来源:Hub.java

示例9: createMatchFromPacket

import org.projectfloodlight.openflow.protocol.match.MatchField; //导入依赖的package包/类
protected Match createMatchFromPacket(IOFSwitch sw, OFPort inPort, FloodlightContext cntx) {
	// The packet in match will only contain the port number.
	// We need to add in specifics for the hosts we're routing between.
	Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	VlanVid vlan = VlanVid.ofVlan(eth.getVlanID());
	MacAddress srcMac = eth.getSourceMACAddress();
	MacAddress dstMac = eth.getDestinationMACAddress();

	Match.Builder mb = sw.getOFFactory().buildMatch();
	mb.setExact(MatchField.IN_PORT, inPort)
	.setExact(MatchField.ETH_SRC, srcMac)
	.setExact(MatchField.ETH_DST, dstMac);

	if (!vlan.equals(VlanVid.ZERO)) {
		mb.setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlanVid(vlan));
	}

	return mb.build();
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:20,代码来源:LearningSwitch.java

示例10: maskL4AndUp

import org.projectfloodlight.openflow.protocol.match.MatchField; //导入依赖的package包/类
/**
 * Create a point-to-point match for two devices at the IP layer.
 * Takes an existing match (e.g. from a PACKET_IN), and masks all
 * MatchFields leaving behind:
 * 		IN_PORT
 * 		VLAN_VID
 * 		ETH_TYPE
 * 		ETH_SRC
 * 		ETH_DST
 * 		IPV4_SRC
 * 		IPV4_DST
 * 		IP_PROTO (might remove this)
 * 
 * If one of the above MatchFields is wildcarded in Match m,
 * that MatchField will be wildcarded in the returned Match.
 * 
 * @param m The match to remove all L4+ MatchFields from
 * @return A new Match object with all MatchFields masked/wildcared
 * except for those listed above.
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Match maskL4AndUp(Match m) {
	Match.Builder mb = m.createBuilder(); 
	Iterator<MatchField<?>> itr = m.getMatchFields().iterator(); // only get exact or masked fields (not fully wildcarded)
	while(itr.hasNext()) {
		MatchField mf = itr.next();
		// restrict MatchFields only to L3 and below: IN_PORT, ETH_TYPE, ETH_SRC, ETH_DST, IPV4_SRC, IPV4_DST, IP_PROTO (this one debatable...)
		// if a MatchField is not in the access list below, it will not be set --> it will be left wildcarded (default)
		if (mf.equals(MatchField.IN_PORT) || mf.equals(MatchField.ETH_TYPE) || mf.equals(MatchField.ETH_SRC) || mf.equals(MatchField.ETH_DST) ||
				mf.equals(MatchField.IPV4_SRC) || mf.equals(MatchField.IPV4_DST) || mf.equals(MatchField.IP_PROTO)) {
			if (m.isExact(mf)) {
				mb.setExact(mf, m.get(mf));
			} else if (m.isPartiallyMasked(mf)) {
				mb.setMasked(mf, m.getMasked(mf));
			} else {
				// it's either exact, masked, or wildcarded
				// itr only contains exact and masked MatchFields
				// we should never get here
			} 
		}
	}
	return mb.build();
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:44,代码来源:MatchUtils.java

示例11: checkMatchFields

import org.projectfloodlight.openflow.protocol.match.MatchField; //导入依赖的package包/类
/**
 * Examine all the MatchFields in a Match object and pick out
 * the MatchFields that are not supported by OF-DPA.
 * 
 * @param m
 * @return
 */
public static List<MatchFields> checkMatchFields(Match m) {
	List<MatchFields> unsupported = null;
	Iterator<MatchField<?>> mfi = m.getMatchFields().iterator();

	while (mfi.hasNext()) {
		MatchField<?> mf = mfi.next();
		if (!getSupportedMatchFields().contains(mf.id)) {
			if (unsupported == null) {
				unsupported = new ArrayList<MatchFields>();
			}
			unsupported.add(mf.id);
		}
	}

	return unsupported;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:24,代码来源:OFDPAUtils.java

示例12: dropFilter

import org.projectfloodlight.openflow.protocol.match.MatchField; //导入依赖的package包/类
/**
 * If the packet-in switch port is disabled for all data traffic, then
 * the packet will be dropped.  Otherwise, the packet will follow the
 * normal processing chain.
 * @param sw
 * @param pi
 * @param cntx
 * @return
 */
protected Command dropFilter(DatapathId sw, OFPacketIn pi,
		FloodlightContext cntx) {
	Command result = Command.CONTINUE;
	OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT));

	// If the input port is not allowed for data traffic, drop everything.
	// BDDP packets will not reach this stage.
	if (isAllowed(sw, inPort) == false) {
		if (log.isTraceEnabled()) {
			log.trace("Ignoring packet because of topology " +
					"restriction on switch={}, port={}", sw.getLong(), inPort.getPortNumber());
			result = Command.STOP;
		}
	}
	return result;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:26,代码来源:TopologyManager.java

示例13: updateTopologyMappings

import org.projectfloodlight.openflow.protocol.match.MatchField; //导入依赖的package包/类
public void updateTopologyMappings(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
	Ethernet eth = IFloodlightProviderService.bcStore.get(cntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	
	if (eth.getPayload() instanceof IPv4) {
		IPv4 ip_pkt = (IPv4) eth.getPayload();
		
		if (ip_pkt.getSourceAddress().getInt() > 0) {
			IpToMac.put(ip_pkt.getSourceAddress(), eth.getSourceMACAddress());
			IpToSwitch.put(ip_pkt.getSourceAddress(),new SwitchHostInfo(sw,pi.getMatch().get(MatchField.IN_PORT)));
		}
	}
	else if (eth.getPayload() instanceof ARP) {
		ARP arp_pkt = (ARP) eth.getPayload();
		
		if (IPv4Address.of(arp_pkt.getSenderProtocolAddress()).getInt() > 0) {
		
			if (!IPv4Address.of(arp_pkt.getSenderProtocolAddress()).toString().contentEquals("10.0.0.111")) {// ignore crafted requests from switches 
				IpToMac.put(IPv4Address.of(arp_pkt.getSenderProtocolAddress()), eth.getSourceMACAddress());
				IpToSwitch.put(IPv4Address.of(arp_pkt.getSenderProtocolAddress()),new SwitchHostInfo(sw,pi.getMatch().get(MatchField.IN_PORT)));
			}
		}
	}
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:24,代码来源:ObfuscationTopologyManager.java

示例14: writePacketOutForPacketIn

import org.projectfloodlight.openflow.protocol.match.MatchField; //导入依赖的package包/类
/**
 * Writes an OFPacketOut message to a switch.
 * @param sw The switch to write the PacketOut to.
 * @param packetInMessage The corresponding PacketIn.
 * @param egressPort The switchport to output the PacketOut.
 */
private void writePacketOutForPacketIn(IOFSwitch sw, OFPacketIn packetInMessage, OFPort egressPort) {
	OFPacketOut.Builder pob = sw.getOFFactory().buildPacketOut();

	// Set buffer_id, in_port, actions_len
	pob.setBufferId(packetInMessage.getBufferId());
	pob.setInPort(packetInMessage.getVersion().compareTo(OFVersion.OF_12) < 0 ? packetInMessage.getInPort() : packetInMessage.getMatch().get(MatchField.IN_PORT));

	// set actions
	List<OFAction> actions = new ArrayList<OFAction>(1);
	actions.add(sw.getOFFactory().actions().buildOutput().setPort(egressPort).setMaxLen(0xffFFffFF).build());
	pob.setActions(actions);

	// set data - only if buffer_id == -1
	if (packetInMessage.getBufferId() == OFBufferId.NO_BUFFER) {
		byte[] packetData = packetInMessage.getData();
		pob.setData(packetData);
	}

	// and write it out
	counterPacketOut.increment();
	sw.write(pob.build());

}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:30,代码来源:LearningSwitch.java

示例15: checkMatchFields

import org.projectfloodlight.openflow.protocol.match.MatchField; //导入依赖的package包/类
/**
 * Examine all the MatchFields in a Match object and pick out
 * the MatchFields that are not supported by OF-DPA.
 *
 * @param m
 * @return
 */
public static List<MatchFields> checkMatchFields(Match m) {
	List<MatchFields> unsupported = null;
	Iterator<MatchField<?>> mfi = m.getMatchFields().iterator();

	while (mfi.hasNext()) {
		MatchField<?> mf = mfi.next();
		if (!getSupportedMatchFields().contains(mf.id)) {
			if (unsupported == null) {
				unsupported = new ArrayList<MatchFields>();
			}
			unsupported.add(mf.id);
		}
	}

	return unsupported;
}
 
开发者ID:zhenshengcai,项目名称:floodlight-hardware,代码行数:24,代码来源:OFDPAUtils.java


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