本文整理汇总了Java中net.floodlightcontroller.packet.Ethernet.getPayload方法的典型用法代码示例。如果您正苦于以下问题:Java Ethernet.getPayload方法的具体用法?Java Ethernet.getPayload怎么用?Java Ethernet.getPayload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.floodlightcontroller.packet.Ethernet
的用法示例。
在下文中一共展示了Ethernet.getPayload方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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) {
MacAddress dlAddr = eth.getDestinationMACAddress();
VlanVid vlan = VlanVid.ofVlan(eth.getVlanID());
IPv4Address nwDst = IPv4Address.NONE;
// Ignore broadcast/multicast destination
if (dlAddr.isBroadcast() || dlAddr.isMulticast())
return null;
// Ignore zero dest mac
if (dlAddr.getLong() == 0)
return null;
if (eth.getPayload() instanceof IPv4) {
IPv4 ipv4 = (IPv4) eth.getPayload();
nwDst = ipv4.getDestinationAddress();
}
return new Entity(dlAddr,
vlan,
nwDst,
null,
null,
null);
}
示例2: processPacketInMessage
import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
protected Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
// get the packet-in switch.
Ethernet eth =
IFloodlightProviderService.bcStore.
get(cntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
if (eth.getPayload() instanceof BSN) {
BSN bsn = (BSN) eth.getPayload();
if (bsn == null) return Command.STOP;
if (bsn.getPayload() == null) return Command.STOP;
// It could be a packet other than BSN LLDP, therefore
// continue with the regular processing.
if (bsn.getPayload() instanceof LLDP == false)
return Command.CONTINUE;
doFloodBDDP(sw.getId(), pi, cntx);
return Command.STOP;
} else {
return dropFilter(sw.getId(), pi, cntx);
}
}
示例3: getDstIP
import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的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;
}
示例4: receive
import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
@Override
public net.floodlightcontroller.core.IListener.Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
Ethernet eth = IFloodlightProviderService.bcStore.get(cntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
oTopologyManager.updateTopologyMappings(sw, (OFPacketIn) msg, cntx);
//log.debug("receive {}",eth);
if ((eth.getPayload() instanceof ARP)) {
handleARP(sw, (OFPacketIn) msg, cntx);
}
else if (eth.getPayload() instanceof IPv4) {
handleIP(sw, (OFPacketIn) msg, cntx);
}
else {
//handleCbench(sw, (OFPacketIn) msg, cntx);
//log.warn("could not handle packet {}",eth.toString());
}
return Command.CONTINUE;
}
示例5: snoopDHCPClientName
import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
/**
* Snoop and record client-provided host name from DHCP requests
* @param eth
* @param srcDevice
*/
private void snoopDHCPClientName(Ethernet eth, Device srcDevice) {
if (! (eth.getPayload() instanceof IPv4) )
return;
IPv4 ipv4 = (IPv4) eth.getPayload();
if (! (ipv4.getPayload() instanceof UDP) )
return;
UDP udp = (UDP) ipv4.getPayload();
if (!(udp.getPayload() instanceof DHCP))
return;
DHCP dhcp = (DHCP) udp.getPayload();
byte opcode = dhcp.getOpCode();
if (opcode == DHCP.OPCODE_REQUEST) {
DHCPOption dhcpOption = dhcp.getOption(
DHCPOptionCode.OptionCode_Hostname);
if (dhcpOption != null) {
cntDhcpClientNameSnooped.increment();
srcDevice.dhcpClientName = new String(dhcpOption.getData());
}
}
}
示例6: isICMP
import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
@Override
public boolean isICMP(FPContext cntx) {
FloodlightContext flCntx = cntx.getFlowContext();
Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
if(eth.getEtherType() == EthType.IPv4)
{
IPv4 ipv4 = (IPv4) eth.getPayload();
return (ipv4.getProtocol() == IpProtocol.ICMP);
}
else
{
return false;
}
}
示例7: isTCP
import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
@Override
public boolean isTCP(FPContext cntx) {
FloodlightContext flCntx = cntx.getFlowContext();
Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
if(eth.getEtherType() == EthType.IPv4)
{
IPv4 ipv4 = (IPv4) eth.getPayload();
return (ipv4.getProtocol() == IpProtocol.TCP);
}
else
{
return false;
}
}
示例8: getSrcNwAddr
import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
/**
* Get sender IP address from packet if the packet is an ARP
* packet and if the source MAC address matches the ARP packets
* sender MAC address.
* @param eth
* @param dlAddr
* @return
*/
private IPv4Address getSrcNwAddr(Ethernet eth, MacAddress dlAddr) {
if (eth.getPayload() instanceof ARP) {
ARP arp = (ARP) eth.getPayload();
if ((arp.getProtocolType() == ARP.PROTO_TYPE_IP) && (MacAddress.of(arp.getSenderHardwareAddress()).equals(dlAddr))) {
return IPv4Address.of(arp.getSenderProtocolAddress());
}
}
return IPv4Address.NONE;
}
示例9: vipProxyArpReply
import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
/**
* used to send proxy Arp for load balanced service requests
* @param IOFSwitch sw
* @param OFPacketIn pi
* @param FloodlightContext cntx
* @param String vipId
*/
protected void vipProxyArpReply(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx, String vipId) {
log.debug("vipProxyArpReply");
Ethernet eth = IFloodlightProviderService.bcStore.get(cntx,
IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
// retrieve original arp to determine host configured gw IP address
if (! (eth.getPayload() instanceof ARP))
return;
ARP arpRequest = (ARP) eth.getPayload();
// have to do proxy arp reply since at this point we cannot determine the requesting application type
// generate proxy ARP reply
IPacket arpReply = new Ethernet()
.setSourceMACAddress(vips.get(vipId).proxyMac)
.setDestinationMACAddress(eth.getSourceMACAddress())
.setEtherType(EthType.ARP)
.setVlanID(eth.getVlanID())
.setPriorityCode(eth.getPriorityCode())
.setPayload(
new ARP()
.setHardwareType(ARP.HW_TYPE_ETHERNET)
.setProtocolType(ARP.PROTO_TYPE_IP)
.setHardwareAddressLength((byte) 6)
.setProtocolAddressLength((byte) 4)
.setOpCode(ARP.OP_REPLY)
.setSenderHardwareAddress(vips.get(vipId).proxyMac)
.setSenderProtocolAddress(arpRequest.getTargetProtocolAddress())
.setTargetHardwareAddress(eth.getSourceMACAddress())
.setTargetProtocolAddress(arpRequest.getSenderProtocolAddress()));
// push ARP reply out
pushPacket(arpReply, sw, OFBufferId.NO_BUFFER, OFPort.ANY, (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)), cntx, true);
log.debug("proxy ARP reply pushed as {}", IPv4.fromIPv4Address(vips.get(vipId).address));
return;
}
示例10: getSrcIPv6Addr
import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
/**
* Get sender IPv6 address from packet if the packet is ND
*
* @param eth
* @param dlAddr
* @return
*/
private IPv6Address getSrcIPv6Addr(Ethernet eth) {
if (eth.getPayload() instanceof IPv6) {
IPv6 ipv6 = (IPv6) eth.getPayload();
return ipv6.getSourceAddress();
}
return IPv6Address.NONE;
}
示例11: 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,
DatapathId swdpid,
OFPort port) {
if (!(eth.getPayload() instanceof ARP)) return;
ARP arp = (ARP) eth.getPayload();
MacAddress dlAddr = eth.getSourceMACAddress();
MacAddress senderAddr = 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.equals(MacAddress.of(0)))
return;
VlanVid vlan = VlanVid.ofVlan(eth.getVlanID());
IPv4Address nwSrc = arp.getSenderProtocolAddress();
Entity e = new Entity(senderAddr,
vlan, /* will either be a valid tag or VlanVid.ZERO if untagged */
nwSrc,
IPv6Address.NONE, /* must be none for ARP */
swdpid,
port,
new Date());
learnDeviceByEntity(e);
}
示例12: 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) {
MacAddress dlAddr = eth.getDestinationMACAddress();
VlanVid vlan = VlanVid.ofVlan(eth.getVlanID());
IPv4Address ipv4Dst = IPv4Address.NONE;
IPv6Address ipv6Dst = IPv6Address.NONE;
// Ignore broadcast/multicast destination
if (dlAddr.isBroadcast() || dlAddr.isMulticast())
return null;
// Ignore zero dest mac
if (dlAddr.equals(MacAddress.of(0)))
return null;
if (eth.getPayload() instanceof IPv4) {
IPv4 ipv4 = (IPv4) eth.getPayload();
ipv4Dst = ipv4.getDestinationAddress();
} else if (eth.getPayload() instanceof IPv6) {
IPv6 ipv6 = (IPv6) eth.getPayload();
ipv6Dst = ipv6.getDestinationAddress();
}
return new Entity(dlAddr,
vlan,
ipv4Dst,
ipv6Dst,
DatapathId.NONE,
OFPort.ZERO,
Entity.NO_DATE);
}
示例13: handleARP
import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
private void handleARP(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
if (! (eth.getPayload() instanceof ARP)) // not an ARP packet
return;
ARP arpRequest = (ARP) eth.getPayload();
if (arpRequest.getOpCode() == ARP.OP_REPLY) { // is a reply
oTopologyManager.updateTopologyMappings(sw, pi, cntx);
for (ARP pendingArpRequest : arpRequestBuffer.getPendingRequests(IPv4Address.of(arpRequest.getSenderProtocolAddress()))) {
if (oTopologyManager.knowSwitchForIp(IPv4Address.of(pendingArpRequest.getSenderProtocolAddress()))) {
SwitchHostInfo dstSwitchPort = oTopologyManager.getSwitchForIp(IPv4Address.of(pendingArpRequest.getSenderProtocolAddress()));
sendArpReply(MacAddress.of(arpRequest.getSenderHardwareAddress()), IPv4Address.of(arpRequest.getSenderProtocolAddress()), MacAddress.of(pendingArpRequest.getSenderHardwareAddress()), IPv4Address.of(pendingArpRequest.getSenderProtocolAddress()), dstSwitchPort.getSwitch(), dstSwitchPort.getPort());
arpRequestBuffer.removeRequest(pendingArpRequest);
}
else
log.warn("answering pending ARP request failed because dst switch/port is not known. {}",pendingArpRequest);
}
}
else { // is a request
if (IPv4Address.of(arpRequest.getSenderProtocolAddress()).toString().contentEquals("10.0.0.111")) // ignore crafted requests from switches
return;
if (oTopologyManager.knowMacForIp(IPv4Address.of(arpRequest.getTargetProtocolAddress()))) {
MacAddress senderMac = oTopologyManager.getMacForIp(IPv4Address.of(arpRequest.getTargetProtocolAddress()));
sendArpReply(senderMac, IPv4Address.of(arpRequest.getTargetProtocolAddress()), MacAddress.of(arpRequest.getSenderHardwareAddress()), IPv4Address.of(arpRequest.getSenderProtocolAddress()), sw, pi.getMatch().get(MatchField.IN_PORT));
}
else {
arpRequestBuffer.addRequest(arpRequest);
for (DatapathId swi : switchService.getAllSwitchDpids())
floodArpRequest(switchService.getSwitch(swi),IPv4Address.of(arpRequest.getTargetProtocolAddress()));
}
}
}
示例14: 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) {
MacAddress dlAddr = eth.getDestinationMACAddress();
VlanVid vlan = VlanVid.ofVlan(eth.getVlanID());
IPv4Address ipv4Dst = IPv4Address.NONE;
IPv6Address ipv6Dst = IPv6Address.NONE;
// Ignore broadcast/multicast destination
if (dlAddr.isBroadcast() || dlAddr.isMulticast())
return null;
// Ignore zero dest mac
if (dlAddr.equals(MacAddress.of(0)))
return null;
if (eth.getPayload() instanceof IPv4) {
IPv4 ipv4 = (IPv4) eth.getPayload();
ipv4Dst = ipv4.getDestinationAddress();
} else if (eth.getPayload() instanceof IPv6) {
IPv6 ipv6 = (IPv6) eth.getPayload();
ipv6Dst = ipv6.getDestinationAddress();
}
return new Entity(dlAddr,
vlan,
ipv4Dst,
ipv6Dst,
DatapathId.NONE,
OFPort.ZERO,
Entity.NO_DATE);
}
示例15: isDhcpPacket
import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
/**
* Checks to see if an Ethernet frame is a DHCP packet.
* @param frame The Ethernet frame.
* @return True if it is a DHCP frame, false otherwise.
*/
protected boolean isDhcpPacket(Ethernet frame) {
IPacket payload = frame.getPayload(); // IP
if (payload == null) return false;
IPacket p2 = payload.getPayload(); // TCP or UDP
if (p2 == null) return false;
IPacket p3 = p2.getPayload(); // Application
if ((p3 != null) && (p3 instanceof DHCP)) return true;
return false;
}