本文整理汇总了Java中net.floodlightcontroller.util.MACAddress.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java MACAddress.valueOf方法的具体用法?Java MACAddress.valueOf怎么用?Java MACAddress.valueOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.floodlightcontroller.util.MACAddress
的用法示例。
在下文中一共展示了MACAddress.valueOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: LBVip
import net.floodlightcontroller.util.MACAddress; //导入方法依赖的package包/类
public LBVip() {
this.id = String.valueOf((int) (Math.random()*10000));
this.name = null;
this.tenantId = null;
this.netId = null;
this.address = 0;
this.protocol = 0;
this.lbMethod = 0;
this.port = 0;
this.pools = new ArrayList<String>();
this.sessionPersistence = false;
this.connectionLimit = 0;
this.address = 0;
this.status = 0;
this.proxyMac = MACAddress.valueOf(LB_PROXY_MAC);
}
示例2: checkPerSourceMacRate
import net.floodlightcontroller.util.MACAddress; //导入方法依赖的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);
}
}
示例3: flowRemoved
import net.floodlightcontroller.util.MACAddress; //导入方法依赖的package包/类
public void flowRemoved(ShortestPathIntent spfIntent) {
if (log.isTraceEnabled()) {
log.trace("ShortestPathIntent {} was removed", spfIntent.getId());
}
MACAddress srcMacAddress = MACAddress.valueOf(spfIntent.getSrcMac());
MACAddress dstMacAddress = MACAddress.valueOf(spfIntent.getDstMac());
Path removedPath = new Path(srcMacAddress, dstMacAddress);
synchronized (lock) {
// There *shouldn't* be any packets queued if the flow has
// just been removed.
List<PacketToPush> packets = waitingPackets.removeAll(spfIntent.getId());
if (!packets.isEmpty()) {
log.warn("Removed flow {} has packets queued.", spfIntent.getId());
}
pendingFlows.remove(removedPath);
log.debug("Removed from the pendingFlow: Path {}, Flow ID {}", removedPath, spfIntent.getId());
}
}
示例4: deviceAdded
import net.floodlightcontroller.util.MACAddress; //导入方法依赖的package包/类
@Override
public void deviceAdded(IDevice device) {
if (device.getIPv4Addresses() == null) return;
for (Integer i : device.getIPv4Addresses()) {
if (gatewayToGuid.containsKey(i)) {
MACAddress mac = MACAddress.valueOf(device.getMACAddress());
if (log.isDebugEnabled())
log.debug("Adding MAC {} with IP {} a a gateway",
HexString.toHexString(mac.toBytes()),
IPv4.fromIPv4Address(i));
macToGateway.put(mac, i);
}
}
}
示例5: deviceRemoved
import net.floodlightcontroller.util.MACAddress; //导入方法依赖的package包/类
@Override
public void deviceRemoved(IDevice device) {
// if device is a gateway remove
MACAddress mac = MACAddress.valueOf(device.getMACAddress());
if (macToGateway.containsKey(mac)) {
if (log.isDebugEnabled())
log.debug("Removing MAC {} as a gateway",
HexString.toHexString(mac.toBytes()));
macToGateway.remove(mac);
}
}
示例6: deviceAdded
import net.floodlightcontroller.util.MACAddress; //导入方法依赖的package包/类
@Override
public void deviceAdded(IDevice device) {
if (device.getIPv4Addresses() == null) return;
for (Integer i : device.getIPv4Addresses()) {
if (gatewayToGuid.containsKey(i)) {
MACAddress mac = MACAddress.valueOf(device.getMACAddress());
if (log.isDebugEnabled())
log.debug("Adding MAC {} with IP {} a a gateway",
HexString.toHexString(mac.toBytes()),
IPv4.fromIPv4Address(i));
macToGateway.put(mac, i);
}
}
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:15,代码来源:VirtualNetworkFilter.java
示例7: deviceRemoved
import net.floodlightcontroller.util.MACAddress; //导入方法依赖的package包/类
@Override
public void deviceRemoved(IDevice device) {
// if device is a gateway remove
MACAddress mac = MACAddress.valueOf(device.getMACAddress());
if (macToGateway.containsKey(mac)) {
if (log.isDebugEnabled())
log.debug("Removing MAC {} as a gateway",
HexString.toHexString(mac.toBytes()));
macToGateway.remove(mac);
}
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:12,代码来源:VirtualNetworkFilter.java
示例8: HostProber
import net.floodlightcontroller.util.MACAddress; //导入方法依赖的package包/类
public HostProber(){
senderMAC = MACAddress.valueOf("aa:aa:aa:aa:aa:aa");
broadcastMAC = MACAddress.valueOf("ff:ff:ff:ff:ff:ff");
emptyMAC = MACAddress.valueOf("00:00:00:00:00:00");
probedPorts = new HashMap<Port, List<HostEntity>>();
try {
senderIP = InetAddress.getByName(ControllerIP);
} catch (UnknownHostException e) {
logger.error("Cannot construct InetAddress, {}", e.getMessage());
}
}
示例9: testGetHostByMac
import net.floodlightcontroller.util.MACAddress; //导入方法依赖的package包/类
/**
* Test the result of getHostByMac function.
*/
@Test
public void testGetHostByMac() {
for (long switchID = 1; switchID <= TEST_SWITCH_NUM; switchID++) {
MACAddress hostMac = MACAddress.valueOf(switchID);
// Verify the host is in the graphDB
assertNotNull(testTopology.getHostByMac(hostMac));
}
}
示例10: setDestinationMACAddress
import net.floodlightcontroller.util.MACAddress; //导入方法依赖的package包/类
/**
* @param destinationMACAddress the destination MAC to set
*/
public Ethernet setDestinationMACAddress(byte[] destinationMACAddress) {
this.destinationMACAddress = MACAddress.valueOf(destinationMACAddress);
return this;
}
示例11: setSourceMACAddress
import net.floodlightcontroller.util.MACAddress; //导入方法依赖的package包/类
/**
* @param sourceMACAddress the source MAC to set
*/
public Ethernet setSourceMACAddress(byte[] sourceMACAddress) {
this.sourceMACAddress = MACAddress.valueOf(sourceMACAddress);
return this;
}
示例12: deserialize
import net.floodlightcontroller.util.MACAddress; //导入方法依赖的package包/类
@Override
public IPacket deserialize(byte[] data, int offset, int length) {
if (length <= 0)
return null;
ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
if (this.destinationMACAddress == null)
this.destinationMACAddress = MACAddress.valueOf(new byte[6]);
byte[] dstAddr = new byte[MACAddress.MAC_ADDRESS_LENGTH];
bb.get(dstAddr);
this.destinationMACAddress = MACAddress.valueOf(dstAddr);
if (this.sourceMACAddress == null)
this.sourceMACAddress = MACAddress.valueOf(new byte[6]);
byte[] srcAddr = new byte[MACAddress.MAC_ADDRESS_LENGTH];
bb.get(srcAddr);
this.sourceMACAddress = MACAddress.valueOf(srcAddr);
short etherType = bb.getShort();
if (etherType == (short) 0x8100) {
short tci = bb.getShort();
this.priorityCode = (byte) ((tci >> 13) & 0x07);
this.vlanID = (short) (tci & 0x0fff);
etherType = bb.getShort();
} else {
this.vlanID = VLAN_UNTAGGED;
}
this.etherType = etherType;
IPacket payload;
if (Ethernet.etherTypeClassMap.containsKey(this.etherType)) {
Class<? extends IPacket> clazz = Ethernet.etherTypeClassMap.get(this.etherType);
try {
payload = clazz.newInstance();
} catch (Exception e) {
throw new RuntimeException("Error parsing payload for Ethernet packet", e);
}
} else {
payload = new Data();
}
this.payload = payload.deserialize(data, bb.position(), bb.limit()-bb.position());
this.payload.setParent(this);
return this;
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:44,代码来源:Ethernet.java
示例13: deviceMoved
import net.floodlightcontroller.util.MACAddress; //导入方法依赖的package包/类
@Override
public void deviceMoved(IDevice device) {
// convert src mac address to MACAddress
MACAddress src_mac = MACAddress.valueOf(device.getMACAddress());
SwitchPort[] previousLocation = device.getOldAP();
if (previousLocation.length == 1) { // only one location in AP history
long previousDpid= previousLocation[0].getSwitchDPID();
short previousPortID = (short) previousLocation[0].getPort();
Port previousPort = new Port(previousDpid, previousPortID);
Map<MACAddress, Boolean> hosts = this.portManager.port_list
.get(previousPort).hosts;
if (!hosts.containsKey(src_mac)){
//logger.error("can not read previous host location about {}",src_mac);
return;
}
if (hosts.get(src_mac) == false) { // indicating the host is not disabled
//Violation: no port shutdown signal is received during host move
logger.warn("Violation: Host Move from switch {} port {} without Port ShutDown"
, previousDpid, previousPortID);
}
//host prober to send ARP Ping to testify the liveness of host
InetAddress src_ip;
try {
if (device.getIPv4Addresses().length < 1){
return;
}
src_ip = InetAddress.getByAddress(BigInteger.valueOf(device.getIPv4Addresses()[0]).toByteArray());
if (hostProber.sendHostProbe(src_ip, src_mac, previousDpid, previousPortID)){
List<HostEntity> hostEntity = hostProber.probedPorts.get(previousPort);
if (hostEntity == null){
hostEntity = new ArrayList<HostEntity>();
}
hostEntity.add(new HostEntity(src_mac, src_ip));
hostProber.probedPorts.put(previousPort, hostEntity);
}
} catch (UnknownHostException e) {
logger.error("Can not convert string to InetAddress,{}",e.getMessage());
}
}
}
示例14: testConstructor
import net.floodlightcontroller.util.MACAddress; //导入方法依赖的package包/类
@Test
public void testConstructor() {
ModifyDstMacAction action =
new ModifyDstMacAction(MACAddress.valueOf("00:01:02:03:04:05"));
assertEquals(MACAddress.valueOf("00:01:02:03:04:05"), action.getDstMac());
}
示例15: setDestinationMACAddress
import net.floodlightcontroller.util.MACAddress; //导入方法依赖的package包/类
/**
* @param destinationMACAddress the destination MAC to set
*/
public Ethernet setDestinationMACAddress(String destinationMACAddress) {
this.destinationMACAddress = MACAddress.valueOf(destinationMACAddress);
return this;
}