blob: 09cb41130cb498db204de228d70cf4060bb40160 [file] [log] [blame]
Andreas Wundsamf89f7822013-09-23 14:49:24 -07001 // normalize match fields according to current OpenVSwitch behavior. When prerequisites for a field are not met
2 // e.g., eth_type is not set to 0x800, OVS sets the value of corresponding ignored fields (e.g.,
3 // ip_src, tcp_dst) to 0, and sets the wildcard bit to 1.
4 if(ethType.equals(EthType.IPv4)) {
5 // IP
Andreas Wundsam520c8802013-10-08 22:05:23 -07006 if(ipProto.equals(IpProtocol.TCP) || ipProto.equals(IpProtocol.UDP) || ipProto.equals(IpProtocol.ICMP)) {
Andreas Wundsamf89f7822013-09-23 14:49:24 -07007 // fully speced, wildcards and all values are fine
8 // normalize 32-63 ipv4 src 'mask' to a full bitmask
9 if((wildcards & OFPFW_NW_SRC_ALL) != 0)
10 wildcards |= OFPFW_NW_SRC_MASK;
11
12 // normalize 32-63 ipv4 dst 'mask' to a full bitmask
13 if((wildcards & OFPFW_NW_DST_ALL) != 0)
14 wildcards |= OFPFW_NW_DST_MASK;
15
16 } else {
17 // normalize 32-63 ipv4 src 'mask' to a full bitmask
18 if((wildcards & OFPFW_NW_SRC_ALL) != 0)
19 wildcards |= OFPFW_NW_SRC_MASK;
20
21 // normalize 32-63 ipv4 dst 'mask' to a full bitmask
22 if((wildcards & OFPFW_NW_DST_ALL) != 0)
23 wildcards |= OFPFW_NW_DST_MASK;
24
25 // not TCP/UDP/ICMP -> Clear TP wildcards for the wire
26 wildcards |= (OFPFW_TP_SRC | OFPFW_TP_DST);
27 tcpSrc = TransportPort.NONE;
28 tcpDst = TransportPort.NONE;
29 }
30 } else if (ethType.equals(EthType.ARP)) {
31 // normalize 32-63 ipv4 src 'mask' to a full bitmask
32 if((wildcards & OFPFW_NW_SRC_ALL) != 0)
33 wildcards |= OFPFW_NW_SRC_MASK;
34
35 // normalize 32-63 ipv4 dst 'mask' to a full bitmask
36 if((wildcards & OFPFW_NW_DST_ALL) != 0)
37 wildcards |= OFPFW_NW_DST_MASK;
38
39 // ARP: clear NW_TOS / TP wildcards for the wire
40 wildcards |= ( OFPFW_NW_TOS | OFPFW_TP_SRC | OFPFW_TP_DST);
41 ipDscp = IpDscp.NONE;
42 tcpSrc = TransportPort.NONE;
43 tcpDst = TransportPort.NONE;
44 } else {
45 // not even IP. Clear NW/TP wildcards for the wire
46 wildcards |= ( OFPFW_NW_TOS | OFPFW_NW_PROTO | OFPFW_NW_SRC_MASK | OFPFW_NW_DST_MASK | OFPFW_TP_SRC | OFPFW_TP_DST);
47 ipDscp = IpDscp.NONE;
48 ipProto = IpProtocol.NONE;
49 ipv4Src = IPv4Address.NONE;
50 ipv4Dst = IPv4Address.NONE;
51 tcpSrc = TransportPort.NONE;
52 tcpDst = TransportPort.NONE;
53 }