blob: ddc65d0d338d629989790d745a2d0e54101cb7f8 [file] [log] [blame]
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08001package net.floodlightcontroller.util;
2
3import net.floodlightcontroller.util.MACAddress;
4import net.floodlightcontroller.util.IPv4Net;
Pavlin Radoslavovad008e02013-02-21 18:42:42 -08005import net.floodlightcontroller.util.serializers.FlowEntryMatchSerializer;
6
7import org.codehaus.jackson.annotate.JsonProperty;
8import org.codehaus.jackson.map.annotate.JsonSerialize;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08009
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 Radoslavovad008e02013-02-21 18:42:42 -080022@JsonSerialize(using=FlowEntryMatchSerializer.class)
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080023public 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 Radoslavovad008e02013-02-21 18:42:42 -0800102 * The string has the following form:
103 * [srcMac:XXX dstMac:XXX srcIPv4Net:XXX dstIPv4Net:XXX]
104 *
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800105 * @return the matching filter as a string.
106 */
107 @Override
108 public String toString() {
Pavlin Radoslavovad008e02013-02-21 18:42:42 -0800109 String ret = "[srcMac: " + this.srcMac.toString();
110 ret += " dstMac:" + this.dstMac.toString();
111 ret += " srcIPv4Net:" + this.srcIPv4Net.toString();
112 ret += " dstIPv4Net:" + this.dstIPv4Net.toString();
113 ret += "]";
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -0800114 return ret;
115 }
116}