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


Java Ethernet.getEtherType方法代码示例

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


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

示例1: getSrcIP

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
@Override
public int getSrcIP(FPContext cntx) {
	FloodlightContext flCntx = cntx.getFlowContext();
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	IPv4Address srcIP;
	
	if(eth.getEtherType() == EthType.IPv4)
	{		
		IPv4 ipv4 = (IPv4) eth.getPayload();
		srcIP = ipv4.getSourceAddress();
		
		return srcIP.getInt();
	}
	else if (eth.getEtherType() == EthType.ARP){
		ARP arp = (ARP) eth.getPayload();
		srcIP = arp.getSenderProtocolAddress();
		
		return srcIP.getInt();
	}
		
	//for other packets without source IP information	
	return 0;
	
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:26,代码来源:FP_LibFloodlight.java

示例2: getDstIP

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
@Override
public int getDstIP(FPContext cntx) {
	FloodlightContext flCntx = cntx.getFlowContext();
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	IPv4Address dstIP;
	
	if(eth.getEtherType() == EthType.IPv4)
	{		
		IPv4 ipv4 = (IPv4) eth.getPayload();
		dstIP = ipv4.getDestinationAddress();
		return dstIP.getInt();
	}
	else if (eth.getEtherType() == EthType.ARP){
		ARP arp = (ARP) eth.getPayload();

		dstIP = arp.getTargetProtocolAddress();

		return dstIP.getInt();
	}
	
	//for other packets without destination IP information
	return 0;
	
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:26,代码来源:FP_LibFloodlight.java

示例3: getARPSenderMAC

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
@Override
public long getARPSenderMAC(FPContext cntx){
	FloodlightContext flCntx = cntx.getFlowContext();
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	MacAddress senderMAC;
	
	if (eth.getEtherType() == EthType.ARP){
		ARP arp = (ARP) eth.getPayload();
		
		senderMAC = arp.getSenderHardwareAddress();
		
		return senderMAC.getLong();
	}
	
	//for other non-arp packets
	return 0;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:19,代码来源:FP_LibFloodlight.java

示例4: getARPTargetMAC

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
@Override
public long getARPTargetMAC(FPContext cntx){
	FloodlightContext flCntx = cntx.getFlowContext();
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	MacAddress senderMAC;
	
	if (eth.getEtherType() == EthType.ARP){
		ARP arp = (ARP) eth.getPayload();
		
		senderMAC = arp.getTargetHardwareAddress();
		
		return senderMAC.getLong();
	}
	
	//for other non-arp packets
	return 0;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:19,代码来源:FP_LibFloodlight.java

示例5: isIPv4

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
@Override
public boolean isIPv4(FPContext cntx) {
	FloodlightContext flCntx = cntx.getFlowContext();
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	if(eth.getEtherType() == EthType.IPv4)
	{		
		return true;
	}
	else
	{
		return false;
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:15,代码来源:FP_LibFloodlight.java

示例6: isICMP

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
@Override
public boolean isICMP(FPContext cntx) {
	FloodlightContext flCntx = cntx.getFlowContext();
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	if(eth.getEtherType() == EthType.IPv4)
	{	
		IPv4 ipv4 = (IPv4) eth.getPayload();
		return (ipv4.getProtocol() == IpProtocol.ICMP);
	}
	else
	{
		return false;
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:16,代码来源:FP_LibFloodlight.java

示例7: isTCP

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
@Override
public boolean isTCP(FPContext cntx) {
	FloodlightContext flCntx = cntx.getFlowContext();
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	if(eth.getEtherType() == EthType.IPv4)
	{	
		IPv4 ipv4 = (IPv4) eth.getPayload();
		return (ipv4.getProtocol() == IpProtocol.TCP);
	}
	else
	{
		return false;
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:16,代码来源:FP_LibFloodlight.java

示例8: isUDP

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
@Override
public boolean isUDP(FPContext cntx) {
	FloodlightContext flCntx = cntx.getFlowContext();
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	if(eth.getEtherType() == EthType.IPv4)
	{	
		IPv4 ipv4 = (IPv4) eth.getPayload();
		return (ipv4.getProtocol() == IpProtocol.UDP);
	}
	else
	{
		return false;
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:16,代码来源:FP_LibFloodlight.java

示例9: getDstPort

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
@Override
public int getDstPort(FPContext cntx) {
	FloodlightContext flCntx = cntx.getFlowContext();
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	if(eth.getEtherType() == EthType.IPv4)
	{		
		IPv4 ipv4 = (IPv4) eth.getPayload();
		if( isTCP(cntx) )
		{
			TCP tcp = (TCP) ipv4.getPayload();
			return tcp.getDestinationPort().getPort();	
		}
		else if ( isUDP(cntx) )
		{
			UDP udp = (UDP) ipv4.getPayload();
			return udp.getDestinationPort().getPort();
		}
		else
		{
			return 0;
		}
	}
	else
	{
		return 0;
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:29,代码来源:FP_LibFloodlight.java

示例10: getSrcPort

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
@Override
public int getSrcPort(FPContext cntx) {
	FloodlightContext flCntx = cntx.getFlowContext();
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	if(eth.getEtherType() == EthType.IPv4)
	{		
		IPv4 ipv4 = (IPv4) eth.getPayload();
		if( isTCP(cntx) )
		{
			TCP tcp = (TCP) ipv4.getPayload();
			return tcp.getSourcePort().getPort();	
		}
		else if ( isUDP(cntx) )
		{
			UDP udp = (UDP) ipv4.getPayload();
			return udp.getSourcePort().getPort();
		}
		else
		{
			return 0;
		}
	}
	else
	{
		return 0;
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:29,代码来源:FP_LibFloodlight.java

示例11: getCountersKey

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
protected CounterKeyTuple getCountersKey(IOFSwitch sw, OFMessage m, Ethernet eth) {
    byte mtype = m.getType().getTypeValue();
    short l3type = 0;
    byte l4type = 0;

    if (eth != null) {
        l3type = eth.getEtherType();
        if (eth.getPayload() instanceof IPv4) {
            IPv4 ipV4 = (IPv4)eth.getPayload();
            l4type = ipV4.getProtocol();
        }
    }
    return new CounterKeyTuple(mtype, sw.getId(), l3type, l4type);
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:15,代码来源:CounterStore.java

示例12: processTCP

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
public FP_Event processTCP(FPContext cntx){ 
	FloodlightContext flCntx = cntx.getFlowContext();
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	if(eth.getEtherType() == EthType.IPv4)
	{	
		IPv4 ipv4 = (IPv4) eth.getPayload();
		
		if (ipv4.getProtocol() == IpProtocol.TCP){
			TCP tcp = (TCP) ipv4.getPayload();
			short flag = tcp.getFlags();
			
			//We assume here we have visibility of all TCP handshake messages
			TCPSession session;
			
			if (flag == 2){
				session = new TCPSession(ipv4.getSourceAddress().getInt(),
					tcp.getSourcePort().getPort(), ipv4.getDestinationAddress().getInt(),
					tcp.getDestinationPort().getPort());
			}
			else{
				session = new TCPSession(ipv4.getDestinationAddress().getInt(),
						tcp.getDestinationPort().getPort(), ipv4.getSourceAddress().getInt(),
						tcp.getSourcePort().getPort());
			}
				
			//store current TCP session into runtime context
			curTCPSession.put(cntx, session);
			
			TCPSTATE state = tcpState.get(session);
			
			if (flag == 2){//SYN
				if (state == null){ 
					state = TCPSTATE.SYN;
					session = new TCPSession(ipv4.getSourceAddress().getInt(),
							tcp.getSourcePort().getPort(), ipv4.getDestinationAddress().getInt(),
							tcp.getDestinationPort().getPort());
					tcpState.put(session, state);
					return FP_Event.TCP;
				 }
			}
			else if (flag == 16){//ACK
				if (state == TCPSTATE.SYNACK){
					 state = TCPSTATE.ESTABLISHED;
					 tcpState.put(session, state);
					 return FP_Event.TCP_CONNECTION_SUCCESS;
				 }
			}
			else if (flag == 18){ //SYNACK
				 if (state == TCPSTATE.SYN){
					 state = TCPSTATE.SYNACK;
					 tcpState.put(session, state);
				 }
			 }
			else if (flag == 20){//RSTACK
				state = TCPSTATE.OTHERS;
			 	tcpState.put(session, state);
			 	return FP_Event.TCP_CONNECTION_FAIL;
			}
			 // we consider other flags are TCP connection disruptions
			 // we will raise TCP connection disruption events
			 //TODO: More options to distinguish different TCP flags
			 else { 
				 if (state != TCPSTATE.ESTABLISHED){
					state = TCPSTATE.OTHERS;
				 	tcpState.put(session, state);
				 	return FP_Event.TCP_CONNECTION_FAIL;
				 }
				 else{//state is TCPSTATE.ESTABLISHED
					 if (flag == 1){ // TCP FIN
						 state = TCPSTATE.OTHERS;
						 tcpState.put(session, state);
						 return FP_Event.TCP_CONNECTION_FAIL;
					 }
				 }
			 }
			 return FP_Event.TCP;
		}
	}
	return FP_Event.PACKET;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:82,代码来源:FP_LibFloodlight.java

示例13: getARPSenderIP

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
@Override
public int getARPSenderIP(FPContext cntx){
	FloodlightContext flCntx = cntx.getFlowContext();
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	
	IPv4Address senderIP;
	
	if (eth.getEtherType() == EthType.ARP){
		ARP arp = (ARP) eth.getPayload();
		
		senderIP = arp.getSenderProtocolAddress();
		
		return senderIP.getInt();
	}
	
	//for other non-arp packets
	return 0;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:20,代码来源:FP_LibFloodlight.java

示例14: getARPTargetIP

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
@Override
public int getARPTargetIP(FPContext cntx){
	FloodlightContext flCntx = cntx.getFlowContext();
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	
	IPv4Address senderIP;
	
	if (eth.getEtherType() == EthType.ARP){
		ARP arp = (ARP) eth.getPayload();
		
		senderIP = arp.getTargetProtocolAddress();
		
		return senderIP.getInt();
	}
	
	//for other non-arp packets
	return 0;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:20,代码来源:FP_LibFloodlight.java

示例15: createMatchFromPacket

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
/**
 * Instead of using the Firewall's routing decision Match, which might be as general
 * as "in_port" and inadvertently Match packets erroneously, construct a more
 * specific Match based on the deserialized OFPacketIn's payload, which has been 
 * placed in the FloodlightContext already by the Controller.
 * 
 * @param sw, the switch on which the packet was received
 * @param inPort, the ingress switch port on which the packet was received
 * @param cntx, the current context which contains the deserialized packet
 * @return a composed Match object based on the provided information
 */
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();

	// A retentive builder will remember all MatchFields of the parent the builder was generated from
	// With a normal builder, all parent MatchFields will be lost if any MatchFields are added, mod, del
	// TODO (This is a bug in Loxigen and the retentive builder is a workaround.)
	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));
	}

	// TODO Detect switch type and match to create hardware-implemented flow
	// TODO Set option in config file to support specific or MAC-only matches
	if (eth.getEtherType() == EthType.IPv4) { /* shallow check for equality is okay for EthType */
		IPv4 ip = (IPv4) eth.getPayload();
		IPv4Address srcIp = ip.getSourceAddress();
		IPv4Address dstIp = ip.getDestinationAddress();
		mb.setExact(MatchField.IPV4_SRC, srcIp)
		.setExact(MatchField.IPV4_DST, dstIp)
		.setExact(MatchField.ETH_TYPE, EthType.IPv4);

		if (ip.getProtocol().equals(IpProtocol.TCP)) {
			TCP tcp = (TCP) ip.getPayload();
			mb.setExact(MatchField.IP_PROTO, IpProtocol.TCP)
			.setExact(MatchField.TCP_SRC, tcp.getSourcePort())
			.setExact(MatchField.TCP_DST, tcp.getDestinationPort());
		} else if (ip.getProtocol().equals(IpProtocol.UDP)) {
			UDP udp = (UDP) ip.getPayload();
			mb.setExact(MatchField.IP_PROTO, IpProtocol.UDP)
			.setExact(MatchField.UDP_SRC, udp.getSourcePort())
			.setExact(MatchField.UDP_DST, udp.getDestinationPort());
		}	
	} else if (eth.getEtherType() == EthType.ARP) { /* shallow check for equality is okay for EthType */
		mb.setExact(MatchField.ETH_TYPE, EthType.ARP);
	}
	return mb.build();
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:58,代码来源:Forwarding.java


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