Update Match and Action sub-classes for SDN-IP.

- Added ModifyDstMacAction class to modify destination MAC address on the packet
- Added PacketMatchBuilder class to instantiate PacketMatch class
- Updated PacketMatch class to be able to handle IP prefix, src/dst TCP port and ether type
- Added simple unit tests
- This task is a part of ONOS-1879

Change-Id: Ib26f117076dceac3f58b4911fbb936752e719a4a
diff --git a/src/main/java/net/onrc/onos/core/matchaction/match/PacketMatchBuilder.java b/src/main/java/net/onrc/onos/core/matchaction/match/PacketMatchBuilder.java
new file mode 100644
index 0000000..1ddc720
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/matchaction/match/PacketMatchBuilder.java
@@ -0,0 +1,143 @@
+package net.onrc.onos.core.matchaction.match;
+
+import net.floodlightcontroller.util.MACAddress;
+import net.onrc.onos.core.util.IPv4;
+import net.onrc.onos.core.util.IPv4Net;
+
+/**
+ * A builder to instantiate PacketMatch class.
+ */
+public class PacketMatchBuilder {
+    private MACAddress srcMac = null;
+    private MACAddress dstMac = null;
+    private Short etherType = null;
+    private IPv4Net srcIp = null;
+    private IPv4Net dstIp = null;
+    private Byte ipProto = null;
+    private Short srcTcpPort = null;
+    private Short dstTcpPort = null;
+
+    /**
+     * Sets source MAC address.
+     *
+     * @param mac the source MAC address
+     * @return this builder
+     */
+    public PacketMatchBuilder setSrcMac(MACAddress mac) {
+        srcMac = mac;
+        return this;
+    }
+
+    /**
+     * Sets destination MAC address.
+     *
+     * @param mac the destination MAC address
+     * @return this builder
+     */
+    public PacketMatchBuilder setDstMac(MACAddress mac) {
+        dstMac = mac;
+        return this;
+    }
+
+    /**
+     * Sets Ethernet type.
+     *
+     * @param etherTypeNo the Ethernet type
+     * @return this builder
+     */
+    public PacketMatchBuilder setEtherType(short etherTypeNo) {
+        etherType = etherTypeNo;
+        return this;
+    }
+
+    /**
+     * Sets source IP address with prefix length.
+     *
+     * @param ip the source IP address
+     * @param prefixLen the prefix length
+     * @return this builder
+     */
+    public PacketMatchBuilder setSrcIp(IPv4 ip, short prefixLen) {
+        srcIp = new IPv4Net(ip, prefixLen);
+        return this;
+    }
+
+    /**
+     * Sets source IP address.
+     *
+     * @param ip the source IP address
+     * @return this builder
+     */
+    public PacketMatchBuilder setSrcIp(IPv4 ip) {
+        return setSrcIp(ip, (short) 32);
+    }
+
+    /**
+     * Sets destination IP address with prefix length.
+     *
+     * @param ip the destination IP address
+     * @param prefixLen the prefix length
+     * @return this builder
+     */
+    public PacketMatchBuilder setDstIp(IPv4 ip, short prefixLen) {
+        dstIp = new IPv4Net(ip, prefixLen);
+        return this;
+    }
+
+    /**
+     * Sets destination IP address.
+     *
+     * @param ip the destination IP address
+     * @return this builder
+     */
+    public PacketMatchBuilder setDstIp(IPv4 ip) {
+        return setDstIp(ip, (short) 32);
+    }
+
+    /**
+     * Sets IP protocol number.
+     *
+     * @param ipProtoNo the IP protocol
+     * @return this builder
+     */
+    public PacketMatchBuilder setIpProto(byte ipProtoNo) {
+        ipProto = ipProtoNo;
+        return this;
+    }
+
+    /**
+     * Sets source TCP port number.
+     *
+     * @param tcpPort the source TCP port number
+     * @return this builder
+     */
+    public PacketMatchBuilder setSrcTcpPort(short tcpPort) {
+        srcTcpPort = tcpPort;
+        return this;
+    }
+
+    /**
+     * Sets destination TCP port number.
+     *
+     * @param tcpPort the destination TCP port number
+     * @return this builder
+     */
+    public PacketMatchBuilder setDstTcpPort(short tcpPort) {
+        dstTcpPort = tcpPort;
+        return this;
+    }
+
+    /**
+     * Builds the PacketMatch instance.
+     *
+     * @return the PacketMatch instance
+     */
+    public PacketMatch build() {
+        // TODO: check consistency among fields
+
+        return new PacketMatch(srcMac, dstMac,
+                etherType,
+                srcIp, dstIp, ipProto,
+                srcTcpPort, dstTcpPort);
+    }
+}