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


Java ARP.getSenderProtocolAddress方法代码示例

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


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

示例1: getSrcIP

import net.floodlightcontroller.packet.ARP; //导入方法依赖的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: getSrcIPv4AddrFromARP

import net.floodlightcontroller.packet.ARP; //导入方法依赖的package包/类
/**
 * Get sender IPv4 address from packet if the packet is an ARP
 * packet and if the source MAC address matches the ARP packets
 * sender MAC address.
 * @param eth
 * @param dlAddr
 * @return
 */
private IPv4Address getSrcIPv4AddrFromARP(Ethernet eth, MacAddress dlAddr) {
	if (eth.getPayload() instanceof ARP) {
		ARP arp = (ARP) eth.getPayload();
		if ((arp.getProtocolType() == ARP.PROTO_TYPE_IP) && (arp.getSenderHardwareAddress().equals(dlAddr))) {
			return arp.getSenderProtocolAddress();
		}
	}
	return IPv4Address.NONE;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:18,代码来源:DeviceManagerImpl.java

示例3: learnDeviceFromArpResponseData

import net.floodlightcontroller.packet.ARP; //导入方法依赖的package包/类
/**
 * Learn device from ARP data in scenarios where the
 * Ethernet source MAC is different from the sender hardware
 * address in ARP data.
 */
protected void learnDeviceFromArpResponseData(Ethernet eth,
		DatapathId swdpid,
		OFPort port) {

	if (!(eth.getPayload() instanceof ARP)) return;
	ARP arp = (ARP) eth.getPayload();

	MacAddress dlAddr = eth.getSourceMACAddress();

	MacAddress senderAddr = arp.getSenderHardwareAddress();

	if (dlAddr.equals(senderAddr)) return; // arp request

	// Ignore broadcast/multicast source
	if (senderAddr.isBroadcast() || senderAddr.isMulticast())
		return;
	// Ignore zero sender mac
	if (senderAddr.equals(MacAddress.of(0)))
		return;

	VlanVid vlan = VlanVid.ofVlan(eth.getVlanID());
	IPv4Address nwSrc = arp.getSenderProtocolAddress();

	Entity e =  new Entity(senderAddr,
			vlan, /* will either be a valid tag or VlanVid.ZERO if untagged */
			nwSrc,
			IPv6Address.NONE, /* must be none for ARP */
			swdpid,
			port,
			new Date());

	learnDeviceByEntity(e);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:39,代码来源:DeviceManagerImpl.java

示例4: getARPSenderIP

import net.floodlightcontroller.packet.ARP; //导入方法依赖的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


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