本文整理汇总了Java中net.floodlightcontroller.devicemanager.SwitchPort类的典型用法代码示例。如果您正苦于以下问题:Java SwitchPort类的具体用法?Java SwitchPort怎么用?Java SwitchPort使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SwitchPort类属于net.floodlightcontroller.devicemanager包,在下文中一共展示了SwitchPort类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getOldAP
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的package包/类
@Override
public SwitchPort[] getOldAP() {
List<SwitchPort> sp = new ArrayList<SwitchPort>();
SwitchPort[] returnSwitchPorts = new SwitchPort[] {};
if (oldAPs == null)
return returnSwitchPorts;
if (oldAPs.isEmpty())
return returnSwitchPorts;
// copy ap list.
List<AttachmentPoint> oldAPList;
oldAPList = new ArrayList<AttachmentPoint>();
if (oldAPs != null)
oldAPList.addAll(oldAPs);
removeExpiredAttachmentPoints(oldAPList);
if (oldAPList != null) {
for (AttachmentPoint ap : oldAPList) {
SwitchPort swport = new SwitchPort(ap.getSw(), ap.getPort());
sp.add(swport);
}
}
return sp.toArray(new SwitchPort[sp.size()]);
}
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:26,代码来源:Device.java
示例2: generateDeviceEvent
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的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: DeviceSyncRepresentation
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的package包/类
public DeviceSyncRepresentation(Device device) {
this.key = computeKey(device);
this.entities = new ArrayList<SyncEntity>();
// FIXME: do we need the APs with errors as well??
// FIXME
SwitchPort[] aps = device.getAttachmentPoints();
for (Entity e : device.getEntities()) {
// Add the entities from the device only if they either don't
// have a switch/port or if they are an attachment point or
// if they have an IP address.
if (!e.hasSwitchPort()) {
this.entities.add(new SyncEntity(e));
} else if (isAttachmentPointEntity(aps, e)) {
this.entities.add(new SyncEntity(e));
} else if (!e.getIpv4Address().equals(IPv4Address.NONE)) {
this.entities.add(new SyncEntity(e));
}
}
Collections.sort(this.entities);
}
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:21,代码来源:DeviceSyncRepresentation.java
示例4: customFormat
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的package包/类
@Override
public EventResourceBuilder
customFormat(@Nullable Collection<SwitchPort> aps2, String name,
EventResourceBuilder edb) {
if (aps2 != null) {
StringBuilder apsStr2 = new StringBuilder();
if (aps2.size() == 0) {
apsStr2.append("--");
} else {
for (SwitchPort ap : aps2) {
apsStr2.append(ap.getSwitchDPID().toString());
apsStr2.append("/");
apsStr2.append(ap.getPort());
apsStr2.append(" ");
}
// remove trailing space
apsStr2.deleteCharAt(apsStr2.length());
}
edb.dataFields.add(new Metadata(name, apsStr2.toString()));
}
return edb;
}
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:23,代码来源:CustomFormatters.java
示例5: deviceAdded
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的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
示例6: deviceIPV4AddrChanged
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的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
示例7: verifyDevice
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的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
示例8: testGetSwitchPortVlanId
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的package包/类
@Test
public void testGetSwitchPortVlanId() {
Entity entity1 = new Entity(MacAddress.of(1L), VlanVid.ofVlan(1), IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(10L), OFPort.of(1), new Date());
Entity entity2 = new Entity(MacAddress.of(1L), VlanVid.ZERO, IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(10L), OFPort.of(1), new Date());
Entity entity3 = new Entity(MacAddress.of(1L), VlanVid.ofVlan(3), IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(1L), OFPort.of(1), new Date());
Entity entity4 = new Entity(MacAddress.of(1L), VlanVid.ofVlan(42), IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(1L), OFPort.of(1), new Date());
Entity[] entities = new Entity[] { entity1, entity2,
entity3, entity4
};
Device d = new Device(null,1L, null, null, null,
Arrays.asList(entities), null);
SwitchPort swp1x1 = new SwitchPort(DatapathId.of(1L), OFPort.of(1));
SwitchPort swp1x2 = new SwitchPort(DatapathId.of(1L), OFPort.of(2));
SwitchPort swp2x1 = new SwitchPort(DatapathId.of(2L), OFPort.of(1));
SwitchPort swp10x1 = new SwitchPort(DatapathId.of(10L), OFPort.of(1));
assertArrayEquals(new VlanVid[] { VlanVid.ZERO, VlanVid.ofVlan(1)},
d.getSwitchPortVlanIds(swp10x1));
assertArrayEquals(new VlanVid[] { VlanVid.ofVlan(3), VlanVid.ofVlan(42)},
d.getSwitchPortVlanIds(swp1x1));
assertArrayEquals(new VlanVid[0],
d.getSwitchPortVlanIds(swp1x2));
assertArrayEquals(new VlanVid[0],
d.getSwitchPortVlanIds(swp2x1));
}
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:25,代码来源:DeviceManagerImplTest.java
示例9: getOldAP
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的package包/类
@Override
public SwitchPort[] getOldAP() {
List<SwitchPort> sp = new ArrayList<SwitchPort>();
SwitchPort [] returnSwitchPorts = new SwitchPort[] {};
if (oldAPs == null) return returnSwitchPorts;
if (oldAPs.isEmpty()) return returnSwitchPorts;
// copy ap list.
List<AttachmentPoint> oldAPList;
oldAPList = new ArrayList<AttachmentPoint>();
if (oldAPs != null) oldAPList.addAll(oldAPs);
removeExpiredAttachmentPoints(oldAPList);
if (oldAPList != null) {
for(AttachmentPoint ap: oldAPList) {
SwitchPort swport = new SwitchPort(ap.getSw(),
ap.getPort());
sp.add(swport);
}
}
return sp.toArray(new SwitchPort[sp.size()]);
}
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:24,代码来源:Device.java
示例10: generateDeviceEvent
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的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: DeviceSyncRepresentation
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的package包/类
public DeviceSyncRepresentation(Device device) {
this.key = computeKey(device);
this.entities = new ArrayList<SyncEntity>();
// FIXME: do we need the APs with errors as well??
// FIXME
SwitchPort[] aps = device.getAttachmentPoints();
for(Entity e: device.getEntities()) {
// Add the entities from the device only if they either don't
// have a switch/port or if they are an attachment point or
// if they have an IP address.
if (!e.hasSwitchPort()) {
this.entities.add(new SyncEntity(e));
} else if (isAttachmentPointEntity(aps, e)) {
this.entities.add(new SyncEntity(e));
} else if (e.getIpv4Address() != null) {
this.entities.add(new SyncEntity(e));
}
}
Collections.sort(this.entities);
}
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:21,代码来源:DeviceSyncRepresentation.java
示例12: deviceAdded
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的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
示例13: deviceIPV4AddrChanged
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的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
示例14: verifyDevice
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的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: testGetSwitchPortVlanId
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的package包/类
@Test
public void testGetSwitchPortVlanId() {
Entity entity1 = new Entity(MacAddress.of(1L), VlanVid.ofVlan(1), null, DatapathId.of(10L), OFPort.of(1), new Date());
Entity entity2 = new Entity(MacAddress.of(1L), null, null, DatapathId.of(10L), OFPort.of(1), new Date());
Entity entity3 = new Entity(MacAddress.of(1L), VlanVid.ofVlan(3), null, DatapathId.of(1L), OFPort.of(1), new Date());
Entity entity4 = new Entity(MacAddress.of(1L), VlanVid.ofVlan(42), null, DatapathId.of(1L), OFPort.of(1), new Date());
Entity[] entities = new Entity[] { entity1, entity2,
entity3, entity4
};
Device d = new Device(null,1L, null, null, null,
Arrays.asList(entities), null);
SwitchPort swp1x1 = new SwitchPort(DatapathId.of(1L), OFPort.of(1));
SwitchPort swp1x2 = new SwitchPort(DatapathId.of(1L), OFPort.of(2));
SwitchPort swp2x1 = new SwitchPort(DatapathId.of(2L), OFPort.of(1));
SwitchPort swp10x1 = new SwitchPort(DatapathId.of(10L), OFPort.of(1));
assertArrayEquals(new VlanVid[] { VlanVid.ofVlan(-1), VlanVid.ofVlan(1)},
d.getSwitchPortVlanIds(swp10x1));
assertArrayEquals(new VlanVid[] { VlanVid.ofVlan(3), VlanVid.ofVlan(42)},
d.getSwitchPortVlanIds(swp1x1));
assertArrayEquals(new VlanVid[0],
d.getSwitchPortVlanIds(swp1x2));
assertArrayEquals(new VlanVid[0],
d.getSwitchPortVlanIds(swp2x1));
}
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:25,代码来源:DeviceManagerImplTest.java
示例16: generateDeviceEvent
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的package包/类
private void generateDeviceEvent(IDevice device, String reason) {
List<Integer> ipv4Addresses =
new ArrayList<Integer>(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<Short> vlanIds =
new ArrayList<Short>(Arrays.asList(device.getVlanId()));
evDevice.updateEventNoFlush(
new DeviceEvent(device.getMACAddress(),
ipv4Addresses,
oldAps,
currentAps,
vlanIds, reason));
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:18,代码来源:DeviceManagerImpl.java
示例17: checkPerSourceMacRate
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的package包/类
/**
* Check if we have sampled this mac in the last second.
* Since we check every packetInRatePerMacThreshold packets,
* the presence of the mac in the macCache means the rate is
* above the threshold in a statistical sense.
*
* Take care not to block topology probing packets. Also don't
* push blocking flow mod if we have already done so within the
* last 5 seconds.
*
* @param pin
* @return
*/
private void checkPerSourceMacRate(OFPacketIn pin) {
byte[] data = pin.getPacketData();
byte[] mac = Arrays.copyOfRange(data, 6, 12);
MACAddress srcMac = MACAddress.valueOf(mac);
short ethType = (short) (((data[12] & 0xff) << 8) + (data[13] & 0xff));
if (ethType != Ethernet.TYPE_LLDP && ethType != Ethernet.TYPE_BSN &&
macCache.update(srcMac.toLong())) {
// Check if we already pushed a flow in the last 5 seconds
if (macBlockedCache.update(srcMac.toLong())) {
return;
}
// write out drop flow per srcMac
int port = pin.getInPort();
SwitchPort swPort = new SwitchPort(getId(), port);
ForwardingBase.blockHost(floodlightProvider,
swPort, srcMac.toLong(), (short) 5,
AppCookie.makeCookie(OFSWITCH_APP_ID, 0));
floodlightProvider.addSwitchEvent(this.datapathId,
"SWITCH_PORT_BLOCKED_TEMPORARILY " +
"OFPort " + port + " mac " + srcMac, false);
log.info("Excessive packet in from {} on {}, block host for 5 sec",
srcMac.toString(), swPort);
}
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:38,代码来源:OFSwitchBase.java
示例18: verifyDevice
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的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(mac, d.getMACAddress());
if (vlan == null)
assertArrayEquals(new Short[0], d.getVlanId());
else
assertArrayEquals(new Short[] { vlan }, d.getVlanId());
if (ip == null)
assertArrayEquals(new Integer[0], d.getIPv4Addresses());
else
assertArrayEquals(new Integer[] { ip }, d.getIPv4Addresses());
SwitchPort expectedAp = new SwitchPort(swId, port);
assertArrayEquals(new SwitchPort[] { expectedAp },
d.getAttachmentPoints());
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:26,代码来源:DeviceManagerImplTest.java
示例19: testGetSwitchPortVlanId
import net.floodlightcontroller.devicemanager.SwitchPort; //导入依赖的package包/类
@Test
public void testGetSwitchPortVlanId() {
Entity entity1 = new Entity(1L, (short)1, null, 10L, 1, new Date());
Entity entity2 = new Entity(1L, null, null, 10L, 1, new Date());
Entity entity3 = new Entity(1L, (short)3, null, 1L, 1, new Date());
Entity entity4 = new Entity(1L, (short)42, null, 1L, 1, new Date());
Entity[] entities = new Entity[] { entity1, entity2,
entity3, entity4
};
Device d = new Device(null,1L, null, null, null,
Arrays.asList(entities), null);
SwitchPort swp1x1 = new SwitchPort(1L, 1);
SwitchPort swp1x2 = new SwitchPort(1L, 2);
SwitchPort swp2x1 = new SwitchPort(2L, 1);
SwitchPort swp10x1 = new SwitchPort(10L, 1);
assertArrayEquals(new Short[] { -1, 1},
d.getSwitchPortVlanIds(swp10x1));
assertArrayEquals(new Short[] { 3, 42},
d.getSwitchPortVlanIds(swp1x1));
assertArrayEquals(new Short[0],
d.getSwitchPortVlanIds(swp1x2));
assertArrayEquals(new Short[0],
d.getSwitchPortVlanIds(swp2x1));
}
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:25,代码来源:DeviceManagerImplTest.java
注:本文中的net.floodlightcontroller.devicemanager.SwitchPort类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论