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


Java ARP.getSenderHardwareAddress方法代码示例

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


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

示例1: getARPSenderMAC

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

示例2: 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

示例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,
                                        long swdpid,
                                        int port) {

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

    byte[] dlAddrArr = eth.getSourceMACAddress();
    long dlAddr = Ethernet.toLong(dlAddrArr);

    byte[] senderHardwareAddr = arp.getSenderHardwareAddress();
    long senderAddr = Ethernet.toLong(senderHardwareAddr);

    if (dlAddr == senderAddr) return;

    // Ignore broadcast/multicast source
    if ((senderHardwareAddr[0] & 0x1) != 0)
        return;
    // Ignore zero sender mac
    if (senderAddr == 0)
        return;

    short vlan = eth.getVlanID();
    int nwSrc = IPv4.toIPv4Address(arp.getSenderProtocolAddress());

    Entity e =  new Entity(senderAddr,
            ((vlan >= 0) ? vlan : null),
            ((nwSrc != 0) ? nwSrc : null),
            swdpid,
            port,
            new Date());

    learnDeviceByEntity(e);
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:40,代码来源:DeviceManagerImpl.java

示例4: 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,
                                        long swdpid,
                                        int port) {

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

    byte[] dlAddrArr = eth.getSourceMACAddress();
    long dlAddr = Ethernet.toLong(dlAddrArr);

    byte[] senderHardwareAddr = arp.getSenderHardwareAddress();
    long senderAddr = Ethernet.toLong(senderHardwareAddr);

    if (dlAddr == senderAddr) return;

    // Ignore broadcast/multicast source
    if ((senderHardwareAddr[0] & 0x1) != 0)
        return;

    short vlan = eth.getVlanID();
    int nwSrc = IPv4.toIPv4Address(arp.getSenderProtocolAddress());

    Entity e =  new Entity(senderAddr,
            ((vlan >= 0) ? vlan : null),
            ((nwSrc != 0) ? nwSrc : null),
            swdpid,
            port,
            new Date());

    learnDeviceByEntity(e);
}
 
开发者ID:dana-i2cat,项目名称:floodlight-nfv,代码行数:37,代码来源:DeviceManagerImpl.java

示例5: testDeviceLearningFromArpResponseData

import net.floodlightcontroller.packet.ARP; //导入方法依赖的package包/类
/**
 * This test ensures the device manager learns the source device
 * corresponding to the senderHardwareAddress and senderProtocolAddress
 * in an ARP response whenever the senderHardwareAddress is different
 * from the source MAC address of the Ethernet frame.
 *
 * @throws Exception
 */
@Test
public void testDeviceLearningFromArpResponseData() throws Exception {
	ARP arp = (ARP)((Ethernet)this.testARPReplyPacket_2).getPayload();
	MacAddress senderMac = arp.getSenderHardwareAddress();
	MacAddress sourceMac =
			((Ethernet)this.testARPReplyPacket_2)
			.getSourceMACAddress();
	IPv4Address ipaddr = IPv4Address.of("192.168.1.1");
	OFPacketIn packetIn = testARPReplyPacketIn_2;

	// Mock up our expected behavior
	ITopologyService mockTopology = createMock(ITopologyService.class);
	deviceManager.topology = mockTopology;
	mockTopologyForPacketInTests(mockTopology);
	replay(mockTopology);


	FloodlightContext cntx = new FloodlightContext();
	Command cmd = dispatchPacketIn(1L, packetIn, cntx);
	verify(mockTopology);
	assertEquals(Command.CONTINUE, cmd);
	// Verify the device for the sender HW address
	IDevice senderDev = (Device)
			deviceManager.findDevice(senderMac, VlanVid.ofVlan(5), IPv4Address.NONE, IPv6Address.NONE, DatapathId.NONE, OFPort.ZERO);
	verifyDevice(senderDev, senderMac, VlanVid.ofVlan(5), ipaddr, IPv6Address.NONE, DatapathId.of(1), OFPort.of(1));

	IDevice result = null;
	Iterator<? extends IDevice> dstiter =
			deviceManager.queryDevices(MacAddress.NONE, null /* any VLAN here */, ipaddr,
					IPv6Address.NONE, DatapathId.NONE, OFPort.ZERO);
	if (dstiter.hasNext()) {
		result = (Device)dstiter.next();
	}
	assertFalse("There shouldn't be more than 1 device", dstiter.hasNext());
	assertEquals(senderDev, result);



	// Verify the device for the source MAC
	IDevice srcDev = (Device)
			deviceManager.findDevice(sourceMac, VlanVid.ofVlan(5), IPv4Address.NONE, IPv6Address.NONE, DatapathId.NONE, OFPort.ZERO);
	// must NOT learn IP on this device
	verifyDevice(srcDev, sourceMac, VlanVid.ofVlan(5), IPv4Address.NONE, IPv6Address.NONE, DatapathId.NONE, OFPort.of(1));
	assertFalse("Device must differ", srcDev.equals(senderDev));
	// Context is annotated with this device, not the device associated
	// with ARP sender address
	IDevice cntxSrcDev = IDeviceService.fcStore.get(cntx,
			IDeviceService.CONTEXT_SRC_DEVICE);
	assertEquals(srcDev, cntxSrcDev);

	assertEquals(2, deviceManager.getAllDevices().size());
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:61,代码来源:DeviceManagerImplTest.java

示例6: testDeviceLearningFromArpResponseData

import net.floodlightcontroller.packet.ARP; //导入方法依赖的package包/类
/**
 * This test ensures the device manager learns the source device
 * corresponding to the senderHardwareAddress and senderProtocolAddress
 * in an ARP response whenever the senderHardwareAddress is different
 * from the source MAC address of the Ethernet frame.
 *
 * This test is the same as testPacketIn method, except for the
 * packet-in that's used.
 * @throws Exception
 */
@Test
public void testDeviceLearningFromArpResponseData() throws Exception {
    ARP arp = (ARP)((Ethernet)this.testARPReplyPacket_2).getPayload();
    byte[] deviceMac2 = arp.getSenderHardwareAddress();

    testPacketInBasic(deviceMac2, packetIn_2);
}
 
开发者ID:dana-i2cat,项目名称:floodlight-nfv,代码行数:18,代码来源:DeviceManagerImplTest.java


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