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