Jonathan Hart
Committed by Gerrit Code Review

Add back EtherType switching based on named enums

Change-Id: I7351ca8ee7b80e7a072a6312357599889d6f1f57
...@@ -14,16 +14,13 @@ ...@@ -14,16 +14,13 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 package org.onosproject.reactive.routing; 16 package org.onosproject.reactive.routing;
17 -import static org.slf4j.LoggerFactory.getLogger;
18 -
19 -import java.nio.ByteBuffer;
20 -
21 import org.apache.felix.scr.annotations.Activate; 17 import org.apache.felix.scr.annotations.Activate;
22 import org.apache.felix.scr.annotations.Component; 18 import org.apache.felix.scr.annotations.Component;
23 import org.apache.felix.scr.annotations.Deactivate; 19 import org.apache.felix.scr.annotations.Deactivate;
24 import org.apache.felix.scr.annotations.Reference; 20 import org.apache.felix.scr.annotations.Reference;
25 import org.apache.felix.scr.annotations.ReferenceCardinality; 21 import org.apache.felix.scr.annotations.ReferenceCardinality;
26 import org.onlab.packet.ARP; 22 import org.onlab.packet.ARP;
23 +import org.onlab.packet.EthType;
27 import org.onlab.packet.Ethernet; 24 import org.onlab.packet.Ethernet;
28 import org.onlab.packet.IPv4; 25 import org.onlab.packet.IPv4;
29 import org.onlab.packet.Ip4Address; 26 import org.onlab.packet.Ip4Address;
...@@ -47,6 +44,10 @@ import org.onosproject.routing.RoutingService; ...@@ -47,6 +44,10 @@ import org.onosproject.routing.RoutingService;
47 import org.onosproject.routing.config.RoutingConfigurationService; 44 import org.onosproject.routing.config.RoutingConfigurationService;
48 import org.slf4j.Logger; 45 import org.slf4j.Logger;
49 46
47 +import java.nio.ByteBuffer;
48 +
49 +import static org.slf4j.LoggerFactory.getLogger;
50 +
50 /** 51 /**
51 * This is reactive routing to handle 3 cases: 52 * This is reactive routing to handle 3 cases:
52 * (1) one host wants to talk to another host, both two hosts are in 53 * (1) one host wants to talk to another host, both two hosts are in
...@@ -113,8 +114,8 @@ public class SdnIpReactiveRouting { ...@@ -113,8 +114,8 @@ public class SdnIpReactiveRouting {
113 } 114 }
114 ConnectPoint srcConnectPoint = pkt.receivedFrom(); 115 ConnectPoint srcConnectPoint = pkt.receivedFrom();
115 116
116 - switch (ethPkt.getEtherType()) { 117 + switch (EthType.EtherType.lookup(ethPkt.getEtherType())) {
117 - case 0x806: 118 + case ARP:
118 ARP arpPacket = (ARP) ethPkt.getPayload(); 119 ARP arpPacket = (ARP) ethPkt.getPayload();
119 Ip4Address targetIpAddress = Ip4Address 120 Ip4Address targetIpAddress = Ip4Address
120 .valueOf(arpPacket.getTargetProtocolAddress()); 121 .valueOf(arpPacket.getTargetProtocolAddress());
...@@ -141,7 +142,7 @@ public class SdnIpReactiveRouting { ...@@ -141,7 +142,7 @@ public class SdnIpReactiveRouting {
141 ByteBuffer.wrap(eth.serialize()))); 142 ByteBuffer.wrap(eth.serialize())));
142 } 143 }
143 break; 144 break;
144 - case 0x800: 145 + case IPV4:
145 // Parse packet 146 // Parse packet
146 IPv4 ipv4Packet = (IPv4) ethPkt.getPayload(); 147 IPv4 ipv4Packet = (IPv4) ethPkt.getPayload();
147 IpAddress dstIp = 148 IpAddress dstIp =
......