本文整理汇总了Java中org.projectfloodlight.openflow.types.EthType.ARP属性的典型用法代码示例。如果您正苦于以下问题:Java EthType.ARP属性的具体用法?Java EthType.ARP怎么用?Java EthType.ARP使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.projectfloodlight.openflow.types.EthType
的用法示例。
在下文中一共展示了EthType.ARP属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSrcIP
@Override
public int getSrcIP(FPContext cntx) {
FloodlightContext flCntx = cntx.getFlowContext();
Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
IPv4Address srcIP;
if(eth.getEtherType() == EthType.IPv4)
{
IPv4 ipv4 = (IPv4) eth.getPayload();
srcIP = ipv4.getSourceAddress();
return srcIP.getInt();
}
else if (eth.getEtherType() == EthType.ARP){
ARP arp = (ARP) eth.getPayload();
srcIP = arp.getSenderProtocolAddress();
return srcIP.getInt();
}
//for other packets without source IP information
return 0;
}
示例2: getDstIP
@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;
}
示例3: getARPSenderMAC
@Override
public long getARPSenderMAC(FPContext cntx){
FloodlightContext flCntx = cntx.getFlowContext();
Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
MacAddress senderMAC;
if (eth.getEtherType() == EthType.ARP){
ARP arp = (ARP) eth.getPayload();
senderMAC = arp.getSenderHardwareAddress();
return senderMAC.getLong();
}
//for other non-arp packets
return 0;
}
示例4: getARPTargetMAC
@Override
public long getARPTargetMAC(FPContext cntx){
FloodlightContext flCntx = cntx.getFlowContext();
Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
MacAddress senderMAC;
if (eth.getEtherType() == EthType.ARP){
ARP arp = (ARP) eth.getPayload();
senderMAC = arp.getTargetHardwareAddress();
return senderMAC.getLong();
}
//for other non-arp packets
return 0;
}
示例5: getARPSenderIP
@Override
public int getARPSenderIP(FPContext cntx){
FloodlightContext flCntx = cntx.getFlowContext();
Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
IPv4Address senderIP;
if (eth.getEtherType() == EthType.ARP){
ARP arp = (ARP) eth.getPayload();
senderIP = arp.getSenderProtocolAddress();
return senderIP.getInt();
}
//for other non-arp packets
return 0;
}
示例6: getARPTargetIP
@Override
public int getARPTargetIP(FPContext cntx){
FloodlightContext flCntx = cntx.getFlowContext();
Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
IPv4Address senderIP;
if (eth.getEtherType() == EthType.ARP){
ARP arp = (ARP) eth.getPayload();
senderIP = arp.getTargetProtocolAddress();
return senderIP.getInt();
}
//for other non-arp packets
return 0;
}
示例7: createMatchFromPacket
/**
* Instead of using the Firewall's routing decision Match, which might be as general
* as "in_port" and inadvertently Match packets erroneously, construct a more
* specific Match based on the deserialized OFPacketIn's payload, which has been
* placed in the FloodlightContext already by the Controller.
*
* @param sw, the switch on which the packet was received
* @param inPort, the ingress switch port on which the packet was received
* @param cntx, the current context which contains the deserialized packet
* @return a composed Match object based on the provided information
*/
protected Match createMatchFromPacket(IOFSwitch sw, OFPort inPort, FloodlightContext cntx) {
// The packet in match will only contain the port number.
// We need to add in specifics for the hosts we're routing between.
Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
VlanVid vlan = VlanVid.ofVlan(eth.getVlanID());
MacAddress srcMac = eth.getSourceMACAddress();
MacAddress dstMac = eth.getDestinationMACAddress();
// A retentive builder will remember all MatchFields of the parent the builder was generated from
// With a normal builder, all parent MatchFields will be lost if any MatchFields are added, mod, del
// TODO (This is a bug in Loxigen and the retentive builder is a workaround.)
Match.Builder mb = sw.getOFFactory().buildMatch();
mb.setExact(MatchField.IN_PORT, inPort)
.setExact(MatchField.ETH_SRC, srcMac)
.setExact(MatchField.ETH_DST, dstMac);
if (!vlan.equals(VlanVid.ZERO)) {
mb.setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlanVid(vlan));
}
// TODO Detect switch type and match to create hardware-implemented flow
// TODO Set option in config file to support specific or MAC-only matches
if (eth.getEtherType() == EthType.IPv4) { /* shallow check for equality is okay for EthType */
IPv4 ip = (IPv4) eth.getPayload();
IPv4Address srcIp = ip.getSourceAddress();
IPv4Address dstIp = ip.getDestinationAddress();
mb.setExact(MatchField.IPV4_SRC, srcIp)
.setExact(MatchField.IPV4_DST, dstIp)
.setExact(MatchField.ETH_TYPE, EthType.IPv4);
if (ip.getProtocol().equals(IpProtocol.TCP)) {
TCP tcp = (TCP) ip.getPayload();
mb.setExact(MatchField.IP_PROTO, IpProtocol.TCP)
.setExact(MatchField.TCP_SRC, tcp.getSourcePort())
.setExact(MatchField.TCP_DST, tcp.getDestinationPort());
} else if (ip.getProtocol().equals(IpProtocol.UDP)) {
UDP udp = (UDP) ip.getPayload();
mb.setExact(MatchField.IP_PROTO, IpProtocol.UDP)
.setExact(MatchField.UDP_SRC, udp.getSourcePort())
.setExact(MatchField.UDP_DST, udp.getDestinationPort());
}
} else if (eth.getEtherType() == EthType.ARP) { /* shallow check for equality is okay for EthType */
mb.setExact(MatchField.ETH_TYPE, EthType.ARP);
}
return mb.build();
}
示例8: processPacketInMessage
@Override
public Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi, IRoutingDecision decision, FloodlightContext cntx) {
Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
/**********************************************************
* ARSCHEDULER MODIFICATION
* ADDED IF STATEMENT: FORWARDING MODULE ONLY HANDLES ARP
* PACKETS NOW. REMOVE THIS IF STATEMENT IF NOT USING
* ARSCHEDULER.
*
**********************************************************/
if(eth.getEtherType() != EthType.ARP){
return Command.CONTINUE;
}
// We found a routing decision (i.e. Firewall is enabled... it's the only thing that makes RoutingDecisions)
if (decision != null) {
if (log.isTraceEnabled()) {
log.trace("Forwarding decision={} was made for PacketIn={}", decision.getRoutingAction().toString(), pi);
}
switch(decision.getRoutingAction()) {
case NONE:
// don't do anything
return Command.CONTINUE;
case FORWARD_OR_FLOOD:
case FORWARD:
doForwardFlow(sw, pi, cntx, false);
return Command.CONTINUE;
case MULTICAST:
// treat as broadcast
doFlood(sw, pi, cntx);
return Command.CONTINUE;
case DROP:
doDropFlow(sw, pi, decision, cntx);
return Command.CONTINUE;
default:
log.error("Unexpected decision made for this packet-in={}", pi, decision.getRoutingAction());
return Command.CONTINUE;
}
} else { // No routing decision was found. Forward to destination or flood if bcast or mcast.
if (log.isTraceEnabled()) {
log.trace("No decision was made for PacketIn={}, forwarding", pi);
}
if (eth.isBroadcast() || eth.isMulticast()) {
doFlood(sw, pi, cntx);
} else {
doForwardFlow(sw, pi, cntx, false);
}
}
return Command.CONTINUE;
}
示例9: createMatchFromPacket
/**
* Instead of using the Firewall's routing decision Match, which might be as general
* as "in_port" and inadvertently Match packets erroneously, construct a more
* specific Match based on the deserialized OFPacketIn's payload, which has been
* placed in the FloodlightContext already by the Controller.
*
* @param sw, the switch on which the packet was received
* @param inPort, the ingress switch port on which the packet was received
* @param cntx, the current context which contains the deserialized packet
* @return a composed Match object based on the provided information
*/
protected Match createMatchFromPacket(IOFSwitch sw, OFPort inPort, FloodlightContext cntx) {
// The packet in match will only contain the port number.
// We need to add in specifics for the hosts we're routing between.
Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
VlanVid vlan = VlanVid.ofVlan(eth.getVlanID());
MacAddress srcMac = eth.getSourceMACAddress();
MacAddress dstMac = eth.getDestinationMACAddress();
Match.Builder mb = sw.getOFFactory().buildMatch();
mb.setExact(MatchField.IN_PORT, inPort);
if (FLOWMOD_DEFAULT_MATCH_MAC) {
mb.setExact(MatchField.ETH_SRC, srcMac)
.setExact(MatchField.ETH_DST, dstMac);
}
if (FLOWMOD_DEFAULT_MATCH_VLAN) {
if (!vlan.equals(VlanVid.ZERO)) {
mb.setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlanVid(vlan));
}
}
// TODO Detect switch type and match to create hardware-implemented flow
// TODO Allow for IPv6 matches
if (eth.getEtherType() == EthType.IPv4) { /* shallow check for equality is okay for EthType */
IPv4 ip = (IPv4) eth.getPayload();
IPv4Address srcIp = ip.getSourceAddress();
IPv4Address dstIp = ip.getDestinationAddress();
if (FLOWMOD_DEFAULT_MATCH_IP_ADDR) {
mb.setExact(MatchField.ETH_TYPE, EthType.IPv4)
.setExact(MatchField.IPV4_SRC, srcIp)
.setExact(MatchField.IPV4_DST, dstIp);
}
if (FLOWMOD_DEFAULT_MATCH_TRANSPORT) {
/*
* Take care of the ethertype if not included earlier,
* since it's a prerequisite for transport ports.
*/
if (!FLOWMOD_DEFAULT_MATCH_IP_ADDR) {
mb.setExact(MatchField.ETH_TYPE, EthType.IPv4);
}
if (ip.getProtocol().equals(IpProtocol.TCP)) {
TCP tcp = (TCP) ip.getPayload();
mb.setExact(MatchField.IP_PROTO, IpProtocol.TCP)
.setExact(MatchField.TCP_SRC, tcp.getSourcePort())
.setExact(MatchField.TCP_DST, tcp.getDestinationPort());
} else if (ip.getProtocol().equals(IpProtocol.UDP)) {
UDP udp = (UDP) ip.getPayload();
mb.setExact(MatchField.IP_PROTO, IpProtocol.UDP)
.setExact(MatchField.UDP_SRC, udp.getSourcePort())
.setExact(MatchField.UDP_DST, udp.getDestinationPort());
}
}
} else if (eth.getEtherType() == EthType.ARP) { /* shallow check for equality is okay for EthType */
mb.setExact(MatchField.ETH_TYPE, EthType.ARP);
}
return mb.build();
}
示例10: isARP
@Override
public boolean isARP(FPContext cntx) {
FloodlightContext flCntx = cntx.getFlowContext();
Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
return (eth.getEtherType() == EthType.ARP);
}