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


Java IPv4Address.getInt方法代码示例

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


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

示例1: getSrcIP

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

import org.projectfloodlight.openflow.types.IPv4Address; //导入方法依赖的package包/类
@Override
public void deviceIPV4AddrChanged(IDevice device) {

	SwitchPort[] switchPort = device.getAttachmentPoints();
	IPv4Address[] ips = device.getIPv4Addresses();

	String dpid = HexString.toHexString(switchPort[0].getSwitchDPID()
			.getLong());
	String ip = null;
	// some device may first appear with no IP address(default set to
	// 0.0.0.0), ignore it
	for (IPv4Address i : ips) {
		if (i.getInt() != 0) {
			ip = IPv4.fromIPv4Address(i.getInt());
			break;
		}
	}

	logger.debug("AP(dpid:{},ip:{}) is added", dpid, ip);
	AP ap = new AP(ip, dpid);
	apManager.addAP(ap);
	processAPAdded(ap);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:24,代码来源:ACL.java

示例4: findDevice

import org.projectfloodlight.openflow.types.IPv4Address; //导入方法依赖的package包/类
@Override
public IDevice findDevice(MacAddress macAddress, VlanVid vlan,
		IPv4Address ipv4Address, DatapathId switchDPID,
		OFPort switchPort)
				throws IllegalArgumentException {
	if (vlan != null && vlan.getVlan() <= 0)
		vlan = null;
	if (ipv4Address != null && ipv4Address.getInt() == 0)
		ipv4Address = null;
	Entity e = new Entity(macAddress, vlan, ipv4Address, switchDPID,
			switchPort, null);
	if (!allKeyFieldsPresent(e, entityClassifier.getKeyFields())) {
		throw new IllegalArgumentException("Not all key fields specified."
				+ " Required fields: " + entityClassifier.getKeyFields());
	}
	return findDeviceByEntity(e);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:18,代码来源:DeviceManagerImpl.java

示例5: findClassDevice

import org.projectfloodlight.openflow.types.IPv4Address; //导入方法依赖的package包/类
@Override
public IDevice findClassDevice(IEntityClass entityClass, MacAddress macAddress,
		VlanVid vlan, IPv4Address ipv4Address)
				throws IllegalArgumentException {
	if (vlan != null && vlan.getVlan() <= 0)
		vlan = null;
	if (ipv4Address != null && ipv4Address.getInt() == 0)
		ipv4Address = null;
	Entity e = new Entity(macAddress, vlan, ipv4Address,
			null, null, null);
	if (entityClass == null ||
			!allKeyFieldsPresent(e, entityClass.getKeyFields())) {
		throw new IllegalArgumentException("Not all key fields and/or "
				+ " no source device specified. Required fields: " +
				entityClassifier.getKeyFields());
	}
	return findDestByEntity(entityClass, e);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:19,代码来源:DeviceManagerImpl.java

示例6: deviceIPV4AddrChanged

import org.projectfloodlight.openflow.types.IPv4Address; //导入方法依赖的package包/类
@Override
public void deviceIPV4AddrChanged(IDevice device) {
	
	SwitchPort[] switchPort = device.getAttachmentPoints();
	IPv4Address[] ips = device.getIPv4Addresses();
	
	String dpid = HexString.toHexString(switchPort[0].getSwitchDPID().getLong());
	String ip = null;
	
	// some device may first appear with no IP address(default set to 0.0.0.0), ignore it
	for(IPv4Address i : ips){
		if(i.getInt() != 0){
			ip = IPv4.fromIPv4Address(i.getInt());
			break;
		}
	}
	
	logger.info("New AP added. [dpid:" + dpid + " ip:" + ip + "]");
	AP ap = new AP(ip, dpid);
	apManager.addAP(ap);
	processAPAdded(ap);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:23,代码来源:ACL.java

示例7: createNetwork

import org.projectfloodlight.openflow.types.IPv4Address; //导入方法依赖的package包/类
@Override
public void createNetwork(String guid, String network, IPv4Address gateway) {
	if (log.isDebugEnabled()) {
		String gw = null;
		try {
			gw = gateway.toString();
		} catch (Exception e) {
			// fail silently
		}
		log.debug("Creating network {} with ID {} and gateway {}",
				new Object[] {network, guid, gw});
	}

	if (!nameToGuid.isEmpty()) {
		// We have to iterate all the networks to handle name/gateway changes
		for (Entry<String, String> entry : nameToGuid.entrySet()) {
			if (entry.getValue().equals(guid)) {
				nameToGuid.remove(entry.getKey());
				break;
			}
		}
	}
	if(network != null)
		nameToGuid.put(network, guid);
	if (vNetsByGuid.containsKey(guid))
		vNetsByGuid.get(guid).setName(network); //network already exists, just updating name
	else
		vNetsByGuid.put(guid, new VirtualNetwork(network, guid)); //new network

	// If they don't specify a new gateway the old one will be preserved
	if ((gateway != null) && (gateway.getInt() != 0)) {
		addGateway(guid, gateway);
		if (vNetsByGuid.get(guid) != null)
			vNetsByGuid.get(guid).setGateway(gateway.toString());
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:37,代码来源:VirtualNetworkFilter.java

示例8: DHCPPool

import org.projectfloodlight.openflow.types.IPv4Address; //导入方法依赖的package包/类
/**
 * Constructor for a DHCPPool of DHCPBinding's. Each DHCPBinding object is initialized with a
 * null MAC address and the lease is set to inactive (i.e. false).
 * @param {@code byte[]} startingIPv4Address: The lowest IP address to lease.
 * @param {@code integer} size: (startingIPv4Address + size) is the highest IP address to lease.
 * @return none
 */
public DHCPPool(IPv4Address startingIPv4Address, int size, Logger log) {
	this.log = log;
	int IPv4AsInt = startingIPv4Address.getInt();
	this.setPoolSize(size);
	this.setPoolAvailability(size);
	STARTING_ADDRESS = startingIPv4Address;
	for (int i = 0; i < size; i++) { 
		DHCP_POOL.add(new DHCPBinding(IPv4Address.of(IPv4AsInt + i), UNASSIGNED_MAC));
	}

}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:19,代码来源:DHCPPool.java

示例9: learnDeviceFromArpResponseData

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

示例10: getARPSenderIP

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

示例11: getARPTargetIP

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


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