+ } else {
+ if (type == 0x0800) {
+ etype = EtherIPType.V4;
+ } else if (type == 0x86dd) {
+ etype = EtherIPType.V6;
+ }
+ }
+
+ }
+ }
+
+ if (layer3match != null) {
+ if (layer3match instanceof Ipv4Match) {
+ if (((Ipv4Match) layer3match).getIpv4Source() != null) {
+ if (NetUtils.isIPv4AddressValid(((Ipv4Match) layer3match).getIpv4Source().getValue())) {
+ ipsrctype = EtherIPType.V4;
+ } else {
+ logger.error("IP source address is not valid");
+ return false;
+ }
+
+ } else if (((Ipv4Match) layer3match).getIpv4Destination() != null) {
+ if (NetUtils.isIPv4AddressValid(((Ipv4Match) layer3match).getIpv4Destination().getValue())) {
+ ipdsttype = EtherIPType.V4;
+ } else {
+ logger.error("IP Destination address is not valid");
+ return false;
+ }
+
+ }
+ } else if (layer3match instanceof Ipv6Match) {
+ if (((Ipv6Match) layer3match).getIpv6Source() != null) {
+ if (NetUtils.isIPv6AddressValid(((Ipv6Match) layer3match).getIpv6Source().getValue())) {
+ ipsrctype = EtherIPType.V6;
+ } else {
+ logger.error("IPv6 source address is not valid");
+ return false;
+ }
+
+ } else if (((Ipv6Match) layer3match).getIpv6Destination() != null) {
+ if (NetUtils.isIPv6AddressValid(((Ipv6Match) layer3match).getIpv6Destination().getValue())) {
+ ipdsttype = EtherIPType.V6;
+ } else {
+ logger.error("IPv6 Destination address is not valid");
+ return false;
+ }
+
+ }
+
+ }
+
+ if (etype != EtherIPType.ANY) {
+ if ((ipsrctype != EtherIPType.ANY) && (ipsrctype != etype)) {
+ logger.error("Type mismatch between Ethernet & Src IP");
+ return false;
+ }
+ if ((ipdsttype != EtherIPType.ANY) && (ipdsttype != etype)) {
+ logger.error("Type mismatch between Ethernet & Dst IP");
+ return false;
+ }
+ }
+ if (ipsrctype != ipdsttype) {
+ if (!((ipsrctype == EtherIPType.ANY) || (ipdsttype == EtherIPType.ANY))) {
+ logger.error("IP Src Dest Type mismatch");
+ return false;