Adding openflow protocol set support in onos for device

Change-Id: Id796e54b536eda19d511a1978657abd6e149f117
diff --git a/core/api/src/main/java/org/onosproject/net/behaviour/BridgeDescription.java b/core/api/src/main/java/org/onosproject/net/behaviour/BridgeDescription.java
index 945fd5b..a3b02a8 100644
--- a/core/api/src/main/java/org/onosproject/net/behaviour/BridgeDescription.java
+++ b/core/api/src/main/java/org/onosproject/net/behaviour/BridgeDescription.java
@@ -104,6 +104,14 @@
     Optional<Boolean> disableInBand();
 
     /**
+     * Returns list of Control Protocol Versions supported on device.
+     * @return List of Control Protocol Versions enabled on bridge
+     */
+    Optional<List<ControlProtocolVersion>> controlProtocols();
+
+    /**
+
+    /**
      * Builder of bridge description entities.
      */
     interface Builder {
@@ -156,6 +164,13 @@
         Builder datapathType(String datapathType);
 
         /**
+         * Returns bridge description builder with given control protocol versions.
+         * @param controlProtocols List of control protocol
+         * @return bridge description builder
+         */
+        Builder controlProtocols(List<ControlProtocolVersion> controlProtocols);
+
+        /**
          * Returns bridge description builder with in-band control disabled.
          *
          * @return bridge description builder
diff --git a/core/api/src/main/java/org/onosproject/net/behaviour/ControlProtocolVersion.java b/core/api/src/main/java/org/onosproject/net/behaviour/ControlProtocolVersion.java
new file mode 100644
index 0000000..2b5ee7c
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/behaviour/ControlProtocolVersion.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.behaviour;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public enum ControlProtocolVersion {
+    OF_1_0("OpenFlow10"),
+    OF_1_1("OpenFlow11"),
+    OF_1_2("OpenFlow12"),
+    OF_1_3("OpenFlow13"),
+    OF_1_4("OpenFlow14"),
+    OF_1_5("OpenFlow15");
+
+    private final String versionString;
+
+    /**
+     * Creates the enum from a string representing the control protoocol version.
+     *
+     * @param versionString the text representing the control protocol version.
+     */
+    ControlProtocolVersion(final String versionString) {
+        this.versionString = versionString;
+    }
+
+    @Override
+    public String toString() {
+        return versionString;
+    }
+
+    /**
+     * Returns a list of control protocol version string values.
+     *
+     * @return the list of string values corresponding to the enums
+     */
+    public static List<String> toStringList() {
+        return Arrays.stream(values())
+                .map(ControlProtocolVersion::toString)
+                .collect(Collectors.toCollection(ArrayList::new));
+    }
+
+    /**
+     * Alternative method to valueOf. It returns the ControlProtocolVersion type
+     * corresponding to the given string. If the parameter does not match a
+     * constant name, or is null, null is returned.
+     *
+     * @param versionString the string representing the encapsulation type
+     * @return the EncapsulationType constant corresponding to the string given
+     */
+    public static ControlProtocolVersion enumFromString(String versionString) {
+        if (versionString != null && !versionString.isEmpty()) {
+            for (ControlProtocolVersion c : values()) {
+                if (versionString.equalsIgnoreCase(c.toString())) {
+                    return c;
+                }
+            }
+        }
+        return null;
+    }
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/behaviour/DefaultBridgeDescription.java b/core/api/src/main/java/org/onosproject/net/behaviour/DefaultBridgeDescription.java
index 1d5f550..cc0b837 100644
--- a/core/api/src/main/java/org/onosproject/net/behaviour/DefaultBridgeDescription.java
+++ b/core/api/src/main/java/org/onosproject/net/behaviour/DefaultBridgeDescription.java
@@ -39,6 +39,7 @@
     private final Optional<FailMode> failMode;
     private final Optional<String> datapathId;
     private final Optional<String> datapathType;
+    private final Optional<List<ControlProtocolVersion>> controlProtocols;
     private final Optional<Boolean> disableInBand;
 
     /* Adds more configurations */
@@ -49,7 +50,8 @@
                                      Optional<FailMode> failMode,
                                      Optional<String> datapathId,
                                      Optional<String> datapathType,
-                                     Optional<Boolean> disableInBand) {
+                                     Optional<Boolean> disableInBand,
+                                     Optional<List<ControlProtocolVersion>> controlProtocols) {
         this.name = checkNotNull(name);
         this.controllers = controllers;
         this.enableLocalController = enableLocalController;
@@ -57,6 +59,7 @@
         this.datapathId = datapathId;
         this.datapathType = datapathType;
         this.disableInBand = disableInBand;
+        this.controlProtocols = controlProtocols;
     }
 
     @Override
@@ -95,6 +98,11 @@
     }
 
     @Override
+    public Optional<List<ControlProtocolVersion>> controlProtocols() {
+        return controlProtocols;
+    }
+
+    @Override
     public Optional<DeviceId> deviceId() {
         if (datapathId.isPresent()) {
             return Optional.of(DeviceId.deviceId("of:" + datapathId.get()));
@@ -125,6 +133,7 @@
         private Optional<FailMode> failMode = Optional.empty();
         private Optional<String> datapathId = Optional.empty();
         private Optional<String> datapathType = Optional.empty();
+        private Optional<List<ControlProtocolVersion>> controlProtocols = Optional.empty();
         private Optional<Boolean> disableInBand = Optional.empty();
 
         private Builder() {
@@ -137,7 +146,8 @@
                                                 failMode,
                                                 datapathId,
                                                 datapathType,
-                                                disableInBand);
+                                                disableInBand,
+                                                controlProtocols);
         }
 
         @Override
@@ -180,6 +190,12 @@
         }
 
         @Override
+        public Builder controlProtocols(List<ControlProtocolVersion> controlProtocols) {
+            this.controlProtocols = Optional.ofNullable(controlProtocols);
+            return this;
+        }
+
+        @Override
         public Builder disableInBand() {
             this.disableInBand = Optional.of(Boolean.TRUE);
             return this;