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


Java MacAddress.equals方法代码示例

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


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

示例1: verifyDevice

import org.projectfloodlight.openflow.types.MacAddress; //导入方法依赖的package包/类
/**
 * Verify that the given device exactly matches the given fields. E.g.,
 * if ip is not null we expect the device to have exactly one IP address.
 * swId and port are the attachment point port.
 * Vlan and ip are optional all other fields must be specified.
 * @return
 */
private static void verifyDevice(IDevice d, MacAddress mac, VlanVid vlan, IPv4Address ipv4,
		IPv6Address ipv6, DatapathId swId, OFPort port) {
	assertNotNull(d);
	if (!mac.equals(MacAddress.NONE)) {
		assertEquals(mac, d.getMACAddress());
	}
	if (vlan != null) {
		assertArrayEquals(new VlanVid[] { vlan }, d.getVlanId());
	}
	if (!ipv4.equals(IPv4Address.NONE)) {
		assertArrayEquals(new IPv4Address[] { ipv4 }, d.getIPv4Addresses());
	}
	if (!ipv6.equals(IPv6Address.NONE)) {
		assertArrayEquals(new IPv6Address[] { ipv6 }, d.getIPv6Addresses());
	}
	if (!swId.equals(DatapathId.NONE) && !port.equals(OFPort.ZERO)) {
		SwitchPort expectedAp = new SwitchPort(swId, port);
		assertArrayEquals(new SwitchPort[] { expectedAp }, d.getAttachmentPoints());
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:28,代码来源:DeviceManagerImplTest.java

示例2: learnDeviceFromArpResponseData

import org.projectfloodlight.openflow.types.MacAddress; //导入方法依赖的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: getDestEntityFromPacket

import org.projectfloodlight.openflow.types.MacAddress; //导入方法依赖的package包/类
/**
 * Get a (partial) entity for the destination from the packet.
 * @param eth
 * @return
 */
protected Entity getDestEntityFromPacket(Ethernet eth) {
	MacAddress dlAddr = eth.getDestinationMACAddress();
	VlanVid vlan = VlanVid.ofVlan(eth.getVlanID());
	IPv4Address ipv4Dst = IPv4Address.NONE;
	IPv6Address ipv6Dst = IPv6Address.NONE;

	// Ignore broadcast/multicast destination
	if (dlAddr.isBroadcast() || dlAddr.isMulticast())
		return null;
	// Ignore zero dest mac
	if (dlAddr.equals(MacAddress.of(0)))
		return null;

	if (eth.getPayload() instanceof IPv4) {
		IPv4 ipv4 = (IPv4) eth.getPayload();
		ipv4Dst = ipv4.getDestinationAddress();
	} else if (eth.getPayload() instanceof IPv6) {
		IPv6 ipv6 = (IPv6) eth.getPayload();
		ipv6Dst = ipv6.getDestinationAddress();
	}
	
	return new Entity(dlAddr,
			vlan,
			ipv4Dst,
			ipv6Dst,
			DatapathId.NONE,
			OFPort.ZERO,
			Entity.NO_DATE);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:35,代码来源:DeviceManagerImpl.java

示例4: getEntityKeys

import org.projectfloodlight.openflow.types.MacAddress; //导入方法依赖的package包/类
private EnumSet<DeviceField> getEntityKeys(@Nonnull MacAddress macAddress,
	 VlanVid vlan, /* A null VLAN means 'don't care'; VlanVid.ZERO means 'untagged' */
	 @Nonnull IPv4Address ipv4Address,
	 @Nonnull IPv6Address ipv6Address,
	 @Nonnull DatapathId switchDPID,
	 @Nonnull OFPort switchPort) {
 EnumSet<DeviceField> keys = EnumSet.noneOf(DeviceField.class);
 if (!macAddress.equals(MacAddress.NONE)) keys.add(DeviceField.MAC);
 if (vlan != null) keys.add(DeviceField.VLAN); /* TODO verify fix. null means 'don't care' and will conduct full search; VlanVid.ZERO means 'untagged' and only uses untagged index */
 if (!ipv4Address.equals(IPv4Address.NONE)) keys.add(DeviceField.IPv4);
 if (!ipv6Address.equals(IPv6Address.NONE)) keys.add(DeviceField.IPv6);
 if (!switchDPID.equals(DatapathId.NONE)) keys.add(DeviceField.SWITCH);
 if (!switchPort.equals(OFPort.ZERO)) keys.add(DeviceField.PORT);
 return keys;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:16,代码来源:DeviceManagerImpl.java

示例5: getSpecificAvailableLease

import org.projectfloodlight.openflow.types.MacAddress; //导入方法依赖的package包/类
/**
 * Returns a specific available IP address binding for lease. The MAC and IP will be queried
 * against the DHCP pool. (1) If the MAC is found in an available, fixed binding, and that binding
 * is not for the provided IP, the fixed binding associated with the MAC will be returned. (2) If the
 * IP is found in an available, fixed binding, and that binding also contains the MAC address provided, 
 * then the binding will be returned -- this is true only if the IP and MAC result in the same available, 
 * fixed binding. (3) If the IP is found in the pool and it is available and not fixed, then its
 * binding will be returned. (4) If the IP provided does not match any available entries or is invalid, 
 * null will be returned. If this is the case, run getAnyAvailableLease(mac) to resolve.
 * @param {@code byte[]}: The IP address on which to try and obtain a lease
 * @param {@code byte[]}: The MAC address on which to try and obtain a lease.
 * @return {@code DHCPBinding}: Reference to the DHCPBinding object if successful, null if unsuccessful.
 */
public DHCPBinding getSpecificAvailableLease(IPv4Address ip, MacAddress mac) {
	if (ip == null || mac == null || isPoolFull()) return null;

	DHCPBinding binding = this.getDHCPbindingFromIPv4(ip);
	DHCPBinding binding2 = this.getDHCPbindingFromMAC(mac);

	// For all of the following, the binding is also determined to be inactive:
	
	// If configured, we must return a fixed binding for a MAC address even if it's requesting another IP
	if (binding2 != null && !binding2.isActiveLease() && binding2.isStaticIPLease() && binding != binding2) {
		if (log != null) log.info("Fixed DHCP entry for MAC trumps requested IP. Returning binding for MAC");
		return binding2;
	// If configured, we must return a fixed binding for an IP if the binding is fixed to the provided MAC (ideal static request case)
	} else if (binding != null && !binding.isActiveLease() && binding.isStaticIPLease() && mac.equals(binding.getMACAddress())) {
		if (log != null) log.info("Found matching fixed DHCP entry for IP with MAC. Returning binding for IP with MAC");
		return binding;
	// The IP and MAC are not a part of a fixed binding, so return the binding of the requested IP
	} else if (binding != null && !binding.isActiveLease() && !binding.isStaticIPLease()) {
		if (log != null) log.info("No fixed DHCP entry for IP or MAC found. Returning dynamic binding for IP.");
		return binding;
	// Otherwise, the binding is fixed for both MAC and IP and this MAC does not match either, so we can't return it as available
	} else {
		if (log != null) log.debug("Invalid IP address request or IP is actively leased...check for any available lease to resolve");
		return null;
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:40,代码来源:DHCPPool.java

示例6: learnDeviceFromArpResponseData

import org.projectfloodlight.openflow.types.MacAddress; //导入方法依赖的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 = MacAddress.of(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.getLong() == 0)
		return;

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

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

	learnDeviceByEntity(e);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:38,代码来源:DeviceManagerImpl.java


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