本文整理汇总了Java中net.floodlightcontroller.packet.Ethernet.getVlanID方法的典型用法代码示例。如果您正苦于以下问题:Java Ethernet.getVlanID方法的具体用法?Java Ethernet.getVlanID怎么用?Java Ethernet.getVlanID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.floodlightcontroller.packet.Ethernet
的用法示例。
在下文中一共展示了Ethernet.getVlanID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSourceEntityFromPacket
import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
/**
* Parse an entity from an {@link Ethernet} packet.
* @param eth the packet to parse
* @param sw the switch on which the packet arrived
* @param pi the original packetin
* @return the entity from the packet
*/
protected Entity getSourceEntityFromPacket(Ethernet eth,
long swdpid,
int port) {
byte[] dlAddrArr = eth.getSourceMACAddress();
long dlAddr = Ethernet.toLong(dlAddrArr);
// Ignore broadcast/multicast source
if ((dlAddrArr[0] & 0x1) != 0)
return null;
// Ignore 0 source mac
if (dlAddr == 0)
return null;
short vlan = eth.getVlanID();
int nwSrc = getSrcNwAddr(eth, dlAddr);
return new Entity(dlAddr,
((vlan >= 0) ? vlan : null),
((nwSrc != 0) ? nwSrc : null),
swdpid,
port,
new Date());
}
示例2: getDestEntityFromPacket
import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
/**
* Get a (partial) entity for the destination from the packet.
* @param eth
* @return
*/
protected Entity getDestEntityFromPacket(Ethernet eth) {
byte[] dlAddrArr = eth.getDestinationMACAddress();
long dlAddr = Ethernet.toLong(dlAddrArr);
short vlan = eth.getVlanID();
int nwDst = 0;
// Ignore broadcast/multicast destination
if ((dlAddrArr[0] & 0x1) != 0)
return null;
// Ignore zero dest mac
if (dlAddr == 0)
return null;
if (eth.getPayload() instanceof IPv4) {
IPv4 ipv4 = (IPv4) eth.getPayload();
nwDst = ipv4.getDestinationAddress();
}
return new Entity(dlAddr,
((vlan >= 0) ? vlan : null),
((nwDst != 0) ? nwDst : null),
null,
null,
null);
}
示例3: learnDeviceFromArpResponseData
import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的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,
long swdpid,
int port) {
if (!(eth.getPayload() instanceof ARP)) return;
ARP arp = (ARP) eth.getPayload();
byte[] dlAddrArr = eth.getSourceMACAddress();
long dlAddr = Ethernet.toLong(dlAddrArr);
byte[] senderHardwareAddr = arp.getSenderHardwareAddress();
long senderAddr = Ethernet.toLong(senderHardwareAddr);
if (dlAddr == senderAddr) return;
// Ignore broadcast/multicast source
if ((senderHardwareAddr[0] & 0x1) != 0)
return;
// Ignore zero sender mac
if (senderAddr == 0)
return;
short vlan = eth.getVlanID();
int nwSrc = IPv4.toIPv4Address(arp.getSenderProtocolAddress());
Entity e = new Entity(senderAddr,
((vlan >= 0) ? vlan : null),
((nwSrc != 0) ? nwSrc : null),
swdpid,
port,
new Date());
learnDeviceByEntity(e);
}