本文整理汇总了Java中net.floodlightcontroller.devicemanager.IDevice类的典型用法代码示例。如果您正苦于以下问题:Java IDevice类的具体用法?Java IDevice怎么用?Java IDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDevice类属于net.floodlightcontroller.devicemanager包,在下文中一共展示了IDevice类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getDeviceEntities
import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
@Get("json")
public Iterator<Entity[]> getDeviceEntities() {
final Iterator<? extends IDevice> devices = super.getDevices();
return new Iterator<Entity[]>() {
@Override
public boolean hasNext() {
return devices.hasNext();
}
@Override
public Entity[] next() {
Device d = (Device)devices.next();
return d.getEntities();
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:23,代码来源:DeviceEntityResource.java
示例2: generateDeviceEvent
import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
private void generateDeviceEvent(IDevice device, String reason) {
List<IPv4Address> ipv4Addresses =
new ArrayList<IPv4Address>(Arrays.asList(device.getIPv4Addresses()));
List<IPv6Address> ipv6Addresses =
new ArrayList<IPv6Address>(Arrays.asList(device.getIPv6Addresses()));
List<SwitchPort> oldAps =
new ArrayList<SwitchPort>(Arrays.asList(device.getOldAP()));
List<SwitchPort> currentAps =
new ArrayList<SwitchPort>(Arrays.asList(device.getAttachmentPoints()));
List<VlanVid> vlanIds =
new ArrayList<VlanVid>(Arrays.asList(device.getVlanId()));
debugEventCategory.newEventNoFlush(new DeviceEvent(device.getMACAddress(),
ipv4Addresses,
ipv6Addresses,
oldAps,
currentAps,
vlanIds, reason));
}
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:20,代码来源:DeviceManagerImpl.java
示例3: deviceAdded
import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
@Override
public void deviceAdded(IDevice device) {
SwitchPort[] switchPort = device.getAttachmentPoints();
if (switchPort.length == 0) {
//Device manager does not yet know an attachment point for a device (Bug Fix)
return;
}
IPv4Address[] ips = device.getIPv4Addresses();
if (ips.length == 0) {
// A new no-ip device added
return;
}
String dpid = HexString.toHexString(switchPort[0].getSwitchDPID()
.getLong());
String ip = IPv4.fromIPv4Address(ips[0].getInt());
logger.debug("AP(dpid:{},ip:{}) is added", dpid, ip);
AP ap = new AP(ip, dpid);
apManager.addAP(ap);
processAPAdded(ap);
}
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:23,代码来源:ACL.java
示例4: deviceIPV4AddrChanged
import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的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
示例5: testLastSeen
import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
@Test
public void testLastSeen() throws Exception {
Calendar c = Calendar.getInstance();
Date d1 = c.getTime();
Entity entity1 = new Entity(MacAddress.of(1L), VlanVid.ZERO /* untagged*/, IPv4Address.NONE, IPv6Address.NONE, DatapathId.NONE, OFPort.ZERO, d1);
c.add(Calendar.SECOND, 1);
Entity entity2 = new Entity(MacAddress.of(1L), VlanVid.ZERO /* untagged*/, IPv4Address.of(1), IPv6Address.NONE, DatapathId.NONE, OFPort.ZERO, c.getTime());
IDevice d = deviceManager.learnDeviceByEntity(entity2);
assertEquals(c.getTime(), d.getLastSeen());
d = deviceManager.learnDeviceByEntity(entity1);
assertEquals(c.getTime(), d.getLastSeen());
deviceManager.startUp(null);
d = deviceManager.learnDeviceByEntity(entity1);
assertEquals(d1, d.getLastSeen());
d = deviceManager.learnDeviceByEntity(entity2);
assertEquals(c.getTime(), d.getLastSeen());
}
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:20,代码来源:DeviceManagerImplTest.java
示例6: verifyDevice
import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的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
示例7: learnEntity
import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
/**
* Learn a device using the given characteristics.
* @param macAddress the MAC
* @param vlan the VLAN (can be VlanVid.ZERO for untagged)
* @param ipv4Address the IPv4 (can be IPv4Address.NONE)
* @param ipv6Address the IPv6 (can be IPv6Address.NONE)
* @param switchDPID the attachment point switch DPID (can be DatapathId.NONE)
* @param switchPort the attachment point switch port (can be OFPort.ZERO)
* @param processUpdates if false, will not send updates. Note that this
* method is not thread safe if this is false
* @return the device, either new or not
*/
public IDevice learnEntity(MacAddress macAddress, VlanVid vlan,
IPv4Address ipv4Address, IPv6Address ipv6Address, DatapathId switchDPID,
OFPort switchPort,
boolean processUpdates) {
List<IDeviceListener> listeners = deviceListeners.getOrderedListeners();
if (!processUpdates) {
deviceListeners.clearListeners();
}
/* Entity will enforce all but VLAN be non-null */
IDevice res = learnDeviceByEntity(new Entity(macAddress,
vlan, ipv4Address, ipv6Address, switchDPID, switchPort, new Date()));
// Restore listeners
if (listeners != null) {
for (IDeviceListener listener : listeners) {
deviceListeners.addListener("device", listener);
}
}
return res;
}
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:33,代码来源:MockDeviceManager.java
示例8: findDevice
import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的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
示例9: findClassDevice
import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的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
示例10: generateDeviceEvent
import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
private void generateDeviceEvent(IDevice device, String reason) {
List<IPv4Address> ipv4Addresses =
new ArrayList<IPv4Address>(Arrays.asList(device.getIPv4Addresses()));
List<SwitchPort> oldAps =
new ArrayList<SwitchPort>(Arrays.asList(device.getOldAP()));
List<SwitchPort> currentAps =
new ArrayList<SwitchPort>(Arrays.asList(device.getAttachmentPoints()));
List<VlanVid> vlanIds =
new ArrayList<VlanVid>(Arrays.asList(device.getVlanId()));
debugEventCategory.newEventNoFlush(new DeviceEvent(device.getMACAddress(),
ipv4Addresses,
oldAps,
currentAps,
vlanIds, reason));
}
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:17,代码来源:DeviceManagerImpl.java
示例11: deviceAdded
import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
/**
* listen for new device
*/
@Override
public void deviceAdded(IDevice device) {
SwitchPort[] switchPort = device.getAttachmentPoints();
IPv4Address[] ips = device.getIPv4Addresses();
if(ips.length == 0){
// A new no-ip device added
return;
}
String dpid = HexString.toHexString(switchPort[0].getSwitchDPID().getLong());
String ip = IPv4.fromIPv4Address(ips[0].getInt());
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,代码行数:20,代码来源:ACL.java
示例12: deviceIPV4AddrChanged
import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的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
示例13: testLastSeen
import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
@Test
public void testLastSeen() throws Exception {
Calendar c = Calendar.getInstance();
Date d1 = c.getTime();
Entity entity1 = new Entity(MacAddress.of(1L), null, null, null, null, d1);
c.add(Calendar.SECOND, 1);
Entity entity2 = new Entity(MacAddress.of(1L), null, IPv4Address.of(1), null, null, c.getTime());
IDevice d = deviceManager.learnDeviceByEntity(entity2);
assertEquals(c.getTime(), d.getLastSeen());
d = deviceManager.learnDeviceByEntity(entity1);
assertEquals(c.getTime(), d.getLastSeen());
deviceManager.startUp(null);
d = deviceManager.learnDeviceByEntity(entity1);
assertEquals(d1, d.getLastSeen());
d = deviceManager.learnDeviceByEntity(entity2);
assertEquals(c.getTime(), d.getLastSeen());
}
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:20,代码来源:DeviceManagerImplTest.java
示例14: verifyDevice
import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的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, long mac, Short vlan, Integer ip,
long swId, int port) {
assertNotNull(d);
assertEquals(MacAddress.of(mac), d.getMACAddress());
if (vlan == null)
assertArrayEquals(new VlanVid[] { VlanVid.ofVlan(-1) }, d.getVlanId());
else
assertArrayEquals(new VlanVid[] { VlanVid.ofVlan(vlan) }, d.getVlanId());
if (ip == null)
assertArrayEquals(new IPv4Address[] { IPv4Address.of(0) }, d.getIPv4Addresses());
else
assertArrayEquals(new IPv4Address[] { IPv4Address.of(ip) }, d.getIPv4Addresses());
SwitchPort expectedAp = new SwitchPort(DatapathId.of(swId), OFPort.of(port));
assertArrayEquals(new SwitchPort[] { expectedAp },
d.getAttachmentPoints());
}
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:26,代码来源:DeviceManagerImplTest.java
示例15: getDeviceFromIP
import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
private IDevice getDeviceFromIP(int ip){
IDevice device = null;
for (IDevice d : deviceService.getAllDevices()) {
for (int j = 0; j < d.getIPv4Addresses().length; j++) {
if (device == null &&
(ip == d.getIPv4Addresses()[j].getInt())){
device = d;
}
}
}
return device;
}
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:14,代码来源:FP_FloodlightRTE.java
示例16: enforceBlockAction
import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
private void enforceBlockAction(BlockAction ba){
//block flow rule lists to instaled in data plane
ArrayList<OFFlowMod> blockFMs = new ArrayList<>();
OFFlowMod blockFM;
IDevice blockedDevice = getDeviceFromIP(ba.getBlockedIP());
if (blockedDevice == null){
log.error("[FRESCO] Block host " + IPv4Address.of(ba.getBlockedIP()) + " fail because cannot locate the host location");
return;
}
SwitchPort blockedLocation = getLocationFromDevice(blockedDevice);
IOFSwitch inSW = switchService.getSwitch(blockedLocation.getSwitchDPID());
Match.Builder mb = inSW.getOFFactory().buildMatch();
mb.setExact(MatchField.IPV4_SRC, IPv4Address.of(ba.getBlockedIP()));
List<OFAction> blockActions = new ArrayList<OFAction>();
blockFM = createFRESCOFlowMod(inSW, mb.build(), blockActions, SEC_PRIORITY_0);
blockFMs.add(blockFM);
//enforce block flow rules
for (OFFlowMod fm : blockFMs){
try {
messageDamper.write(inSW, fm);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:37,代码来源:FP_FloodlightRTE.java
示例17: findDevice
import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
@Override
public IDevice findDevice(@Nonnull MacAddress macAddress, VlanVid vlan,
@Nonnull IPv4Address ipv4Address, @Nonnull IPv6Address ipv6Address,
@Nonnull DatapathId switchDPID, @Nonnull OFPort switchPort)
throws IllegalArgumentException {
if (macAddress == null) {
throw new IllegalArgumentException("MAC address cannot be null. Try MacAddress.NONE if intention is 'no MAC'");
}
if (ipv4Address == null) {
throw new IllegalArgumentException("IPv4 address cannot be null. Try IPv4Address.NONE if intention is 'no IPv4'");
}
if (ipv6Address == null) {
throw new IllegalArgumentException("IPv6 address cannot be null. Try IPv6Address.NONE if intention is 'no IPv6'");
}
if (vlan == null) {
throw new IllegalArgumentException("VLAN cannot be null. Try VlanVid.ZERO if intention is 'no VLAN / untagged'");
}
if (switchDPID == null) {
throw new IllegalArgumentException("Switch DPID cannot be null. Try DatapathId.NONE if intention is 'no DPID'");
}
if (switchPort == null) {
throw new IllegalArgumentException("Switch port cannot be null. Try OFPort.ZERO if intention is 'no port'");
}
Entity e = new Entity(macAddress, vlan,
ipv4Address, ipv6Address,
switchDPID, switchPort, Entity.NO_DATE);
/*
* allKeyFieldsPresent() will check if the entity key fields (e.g. MAC and VLAN)
* have non-"zero" values i.e. are not set to e.g. MacAddress.NONE and VlanVid.ZERO
*/
if (!allKeyFieldsPresent(e, entityClassifier.getKeyFields())) {
throw new IllegalArgumentException("Not all key fields specified."
+ " Required fields: " + entityClassifier.getKeyFields());
}
return findDeviceByEntity(e);
}
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:39,代码来源:DeviceManagerImpl.java
示例18: findClassDevice
import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
@Override
public IDevice findClassDevice(@Nonnull IEntityClass entityClass, @Nonnull MacAddress macAddress,
@Nonnull VlanVid vlan, @Nonnull IPv4Address ipv4Address, @Nonnull IPv6Address ipv6Address)
throws IllegalArgumentException {
if (entityClass == null) {
throw new IllegalArgumentException("Entity class cannot be null.");
}
if (macAddress == null) {
throw new IllegalArgumentException("MAC address cannot be null. Try MacAddress.NONE if intention is 'no MAC'");
}
if (ipv4Address == null) {
throw new IllegalArgumentException("IPv4 address cannot be null. Try IPv4Address.NONE if intention is 'no IPv4'");
}
if (ipv6Address == null) {
throw new IllegalArgumentException("IPv6 address cannot be null. Try IPv6Address.NONE if intention is 'no IPv6'");
}
if (vlan == null) {
throw new IllegalArgumentException("VLAN cannot be null. Try VlanVid.ZERO if intention is 'no VLAN / untagged'");
}
Entity e = new Entity(macAddress, vlan, ipv4Address, ipv6Address, DatapathId.NONE, OFPort.ZERO, Entity.NO_DATE);
if (!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:xuraylei,项目名称:fresco_floodlight,代码行数:29,代码来源:DeviceManagerImpl.java
示例19: RoutingDecision
import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
public RoutingDecision(DatapathId swDipd,
OFPort inPort,
IDevice srcDevice,
RoutingAction action) {
this.srcPort = new SwitchPort(swDipd, inPort);
this.srcDevice = srcDevice;
this.destDevices = Collections.synchronizedList(new ArrayList<IDevice>());
this.broadcastIntertfaces = Collections.synchronizedList(new ArrayList<SwitchPort>());
this.action = action;
this.match = null;
this.hardTimeout = ForwardingBase.FLOWMOD_DEFAULT_HARD_TIMEOUT;
}
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:13,代码来源:RoutingDecision.java
示例20: deviceAdded
import net.floodlightcontroller.devicemanager.IDevice; //导入依赖的package包/类
@Override
public void deviceAdded(IDevice device) {
if (device.getIPv4Addresses() == null) return;
for (IPv4Address i : device.getIPv4Addresses()) {
if (gatewayToGuid.containsKey(i)) {
MacAddress mac = device.getMACAddress();
if (log.isDebugEnabled())
log.debug("Adding MAC {} with IP {} a a gateway",
mac.toString(),
i.toString());
macToGateway.put(mac, i);
}
}
}
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:15,代码来源:VirtualNetworkFilter.java
注:本文中的net.floodlightcontroller.devicemanager.IDevice类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论