Major refactoring of the BMv2 protocol module

- Created 3 separate sub-modules: API (doesn't depend on
    Thrift), CTL (depends on Thrift), THRIFT-API (to generate Thrift
    sources)
- Implemented 2 new services (for device configuration swapping and
    table entry management) needed to distribute BMv2-specific state
    among ONOS instances.
- Implemented a BMv2 controller (previously other modules where
    using separately a Thrift client and a server)
- Added a default BMv2 JSON configuration (default.json) and interpreter
    to be used for devices that connect for the first time to ONOS.
    This allows for basic services to work (i.e. LLDP link discovery,
    ARP proxy. etc.).
- Changed behavior of the flow rule translator and extension selector,
    now it allows extension to specify only some of the match parameters
    (before extension selectors were expected to describe the whole
    match key, i.e. all fields)
- Various renaming to better represent the API
- Various java doc fixes / improvements

Change-Id: Ida4b5e546b0def97c3552a6c05f7bce76fd32c28
diff --git a/utils/misc/src/main/java/org/onlab/util/ImmutableByteSequence.java b/utils/misc/src/main/java/org/onlab/util/ImmutableByteSequence.java
index 57171de..f5f9a59 100644
--- a/utils/misc/src/main/java/org/onlab/util/ImmutableByteSequence.java
+++ b/utils/misc/src/main/java/org/onlab/util/ImmutableByteSequence.java
@@ -73,6 +73,24 @@
     }
 
     /**
+     * Creates a new immutable byte sequence with the same content and order of
+     * the passed byte array, from/to the given indexes (inclusive).
+     *
+     * @param original a byte array value
+     * @return a new immutable byte sequence
+     */
+    public static ImmutableByteSequence copyFrom(byte[] original, int fromIdx, int toIdx) {
+        checkArgument(original != null && original.length > 0,
+                      "Cannot copy from an empty or null array");
+        checkArgument(toIdx >= fromIdx && toIdx < original.length, "invalid indexes");
+        ByteBuffer buffer = ByteBuffer.allocate((toIdx - fromIdx) + 1);
+        for (int i = fromIdx; i <= toIdx; i++) {
+            buffer.put(original[i]);
+        }
+        return new ImmutableByteSequence(buffer);
+    }
+
+    /**
      * Creates a new immutable byte sequence copying bytes from the given
      * ByteBuffer {@link ByteBuffer}. If the byte buffer order is not big-endian
      * bytes will be copied in reverse order.