Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 1 | package net.floodlightcontroller.util; |
| 2 | |
| 3 | import net.floodlightcontroller.util.MACAddress; |
| 4 | import net.floodlightcontroller.util.IPv4Net; |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 5 | |
| 6 | import org.codehaus.jackson.annotate.JsonProperty; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 7 | |
| 8 | /** |
| 9 | * The class representing the Flow Entry Matching filter. |
| 10 | * |
| 11 | * The Flow Entry matching filter that is used to specify |
| 12 | * the network data that would be forwarded on the data path from |
| 13 | * the source to the destination. Examples: MAC address (of the |
| 14 | * sender), IP prefix that includes the destination's IP address, etc. |
| 15 | * |
| 16 | * NOTE: The FlowEntryMatch specification below is incomplete: we need |
| 17 | * more matching fields, we need to indicate which fields need to be |
| 18 | * matched, etc. |
| 19 | */ |
| 20 | public class FlowEntryMatch { |
| 21 | private MACAddress srcMac; // Matching source MAC address |
| 22 | private MACAddress dstMac; // Matching destination MAC address |
| 23 | private IPv4Net srcIPv4Net; // Matching source IPv4 prefix |
| 24 | private IPv4Net dstIPv4Net; // Matching destination IPv4 prefix |
| 25 | |
| 26 | /** |
| 27 | * Default constructor. |
| 28 | */ |
| 29 | public FlowEntryMatch() { |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Get the matching source MAC address. |
| 34 | * |
| 35 | * @return the matching source MAC address. |
| 36 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame^] | 37 | @JsonProperty("srcMac") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 38 | public MACAddress srcMac() { return srcMac; } |
| 39 | |
| 40 | /** |
| 41 | * Set the matching source MAC address. |
| 42 | * |
| 43 | * @param srcMac the matching source MAC address to set. |
| 44 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame^] | 45 | @JsonProperty("srcMac") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 46 | public void setSrcMac(MACAddress srcMac) { |
| 47 | this.srcMac = srcMac; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Get the matching destination MAC address. |
| 52 | * |
| 53 | * @return the matching destination MAC address. |
| 54 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame^] | 55 | @JsonProperty("dstMac") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 56 | public MACAddress dstMac() { return dstMac; } |
| 57 | |
| 58 | /** |
| 59 | * Set the matching destination MAC address. |
| 60 | * |
| 61 | * @param dstMac the matching destination MAC address to set. |
| 62 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame^] | 63 | @JsonProperty("dstMac") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 64 | public void setDstMac(MACAddress dstMac) { |
| 65 | this.dstMac = dstMac; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Get the matching source IPv4 prefix. |
| 70 | * |
| 71 | * @return the matching source IPv4 prefix. |
| 72 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame^] | 73 | @JsonProperty("srcIPv4Net") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 74 | public IPv4Net srcIPv4Net() { return srcIPv4Net; } |
| 75 | |
| 76 | /** |
| 77 | * Set the matching source IPv4 prefix. |
| 78 | * |
| 79 | * @param srcIPv4Net the matching source IPv4 prefix to set. |
| 80 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame^] | 81 | @JsonProperty("srcIPv4Net") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 82 | public void setSrcIPv4Net(IPv4Net srcIPv4Net) { |
| 83 | this.srcIPv4Net = srcIPv4Net; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Get the matching destination IPv4 prefix. |
| 88 | * |
| 89 | * @return the matching destination IPv4 prefix. |
| 90 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame^] | 91 | @JsonProperty("dstIPv4Net") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 92 | public IPv4Net dstIPv4Net() { return dstIPv4Net; } |
| 93 | |
| 94 | /** |
| 95 | * Set the matching destination IPv4 prefix. |
| 96 | * |
| 97 | * @param srcIPv4Net the matching destination IPv4 prefix to set. |
| 98 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame^] | 99 | @JsonProperty("dstIPv4Net") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 100 | public void setDstIPv4Net(IPv4Net dstIPv4Net) { |
| 101 | this.dstIPv4Net = dstIPv4Net; |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Convert the matching filter to a string. |
| 106 | * |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 107 | * The string has the following form: |
Pavlin Radoslavov | a10a9a8 | 2013-02-22 11:47:54 -0800 | [diff] [blame] | 108 | * [srcMac=XXX dstMac=XXX srcIPv4Net=XXX dstIPv4Net=XXX] |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 109 | * |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 110 | * @return the matching filter as a string. |
| 111 | */ |
| 112 | @Override |
| 113 | public String toString() { |
Pavlin Radoslavov | a10a9a8 | 2013-02-22 11:47:54 -0800 | [diff] [blame] | 114 | String ret = "[srcMac=" + this.srcMac.toString(); |
| 115 | ret += " dstMac=" + this.dstMac.toString(); |
| 116 | ret += " srcIPv4Net=" + this.srcIPv4Net.toString(); |
| 117 | ret += " dstIPv4Net=" + this.dstIPv4Net.toString(); |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 118 | ret += "]"; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 119 | return ret; |
| 120 | } |
| 121 | } |