AETHER-233 Move IntProgrammable behavior to core APIs

Before, the behavior interface and other concrete classes used it by
were part of the inbandtelemetry app. To make this behavior available to
third-party apps (such as the fabric-tna pipeconf), we move it to the
core APIs.

In this process, we do some clean-up of the behavior API. For example,
we remove references to network-level semantics (as behaviors should
only abstract device-level ones). That helps in reducing the number of
classes required to maintain in the core.

Change-Id: I3ba24ea93cdfea115cee454d5e921e15ec17eee9
diff --git a/apps/inbandtelemetry/api/src/main/java/org/onosproject/inbandtelemetry/api/IntIntent.java b/apps/inbandtelemetry/api/src/main/java/org/onosproject/inbandtelemetry/api/IntIntent.java
index 37e1e29..6e2e92b 100644
--- a/apps/inbandtelemetry/api/src/main/java/org/onosproject/inbandtelemetry/api/IntIntent.java
+++ b/apps/inbandtelemetry/api/src/main/java/org/onosproject/inbandtelemetry/api/IntIntent.java
@@ -16,6 +16,7 @@
 package org.onosproject.inbandtelemetry.api;
 
 import com.google.common.annotations.Beta;
+import org.onosproject.net.behaviour.inbandtelemetry.IntMetadataType;
 import org.onosproject.net.flow.DefaultTrafficSelector;
 import org.onosproject.net.flow.TrafficSelector;
 
@@ -40,55 +41,17 @@
  */
 @Beta
 public final class IntIntent {
-    /**
-     * Represents a type of INT metadata.
-     */
-    public enum IntMetadataType {
-        /**
-         * The unique ID of a switch.
-         */
-        SWITCH_ID,
-        /**
-         * The ports on which the INT packet was received and sent out.
-         */
-        L1_PORT_ID,
-        /**
-         * Time taken for the INT packet to be switched within the device.
-         */
-        HOP_LATENCY,
-        /**
-         * The build-up of traffic in the queue that the INT packet observes
-         * in the device while being forwarded.
-         */
-        QUEUE_OCCUPANCY,
-        /**
-         * The device local time when the INT packet was received on the ingress port.
-         */
-        INGRESS_TIMESTAMP,
-        /**
-         * The device local time when the INT packet was processed by the egress port.
-         */
-        EGRESS_TIMESTAMP,
-        /**
-         * The logical ports on which the INT packet was received and sent out.
-         */
-        L2_PORT_ID,
-        /**
-         * Current utilization of the egress port via witch the INT packet was sent out.
-         */
-        EGRESS_TX_UTIL
-    }
 
     /**
      * Represents an INT header type.
      */
     public enum IntHeaderType {
         /**
-         * Intemediate devices must process this type of INT header.
+         * Intermediate devices must process this type of INT header.
          */
         HOP_BY_HOP,
         /**
-         * Intemediate devices must ignore this type of INT header.
+         * Intermediate devices must ignore this type of INT header.
          */
         DESTINATION
     }
@@ -102,7 +65,7 @@
          */
         TRACKED_FLOW,
         /**
-         * Reports for all dropeed packets matching a drop watchlist.
+         * Reports for all dropped packets matching a drop watchlist.
          */
         DROPPED_PACKET,
         /**
diff --git a/apps/inbandtelemetry/api/src/main/java/org/onosproject/inbandtelemetry/api/IntService.java b/apps/inbandtelemetry/api/src/main/java/org/onosproject/inbandtelemetry/api/IntService.java
index 59e65c3..ba236bb 100644
--- a/apps/inbandtelemetry/api/src/main/java/org/onosproject/inbandtelemetry/api/IntService.java
+++ b/apps/inbandtelemetry/api/src/main/java/org/onosproject/inbandtelemetry/api/IntService.java
@@ -16,6 +16,7 @@
 package org.onosproject.inbandtelemetry.api;
 
 import com.google.common.annotations.Beta;
+import org.onosproject.net.behaviour.inbandtelemetry.IntDeviceConfig;
 import org.onosproject.net.DeviceId;
 
 import java.util.Map;
@@ -76,14 +77,14 @@
      *
      * @param cfg configuration to set up
      */
-    void setConfig(IntConfig cfg);
+    void setConfig(IntDeviceConfig cfg);
 
     /**
      * Retrieves the INT configuration.
      *
      * @return configuration
      */
-    IntConfig getConfig();
+    IntDeviceConfig getConfig();
 
     /**
      * Installs an IntIntent to devices.
diff --git a/apps/inbandtelemetry/app/src/main/java/org/onosproject/inbandtelemetry/app/ui/IntAppTableMessageHandler.java b/apps/inbandtelemetry/app/src/main/java/org/onosproject/inbandtelemetry/app/ui/IntAppTableMessageHandler.java
index fafd4b4..a0df5a9 100644
--- a/apps/inbandtelemetry/app/src/main/java/org/onosproject/inbandtelemetry/app/ui/IntAppTableMessageHandler.java
+++ b/apps/inbandtelemetry/app/src/main/java/org/onosproject/inbandtelemetry/app/ui/IntAppTableMessageHandler.java
@@ -19,6 +19,7 @@
 import com.google.common.collect.ImmutableSet;
 import org.onosproject.inbandtelemetry.api.IntIntent;
 import org.onosproject.inbandtelemetry.api.IntIntentId;
+import org.onosproject.net.behaviour.inbandtelemetry.IntMetadataType;
 import org.onosproject.inbandtelemetry.api.IntService;
 import org.onosproject.net.flow.criteria.Criterion;
 import org.onosproject.net.flow.criteria.IPCriterion;
@@ -105,7 +106,7 @@
             TcpPortCriterion tcpDstPort = (TcpPortCriterion) intent.selector().getCriterion(Criterion.Type.TCP_DST);
             UdpPortCriterion udpSrcPort = (UdpPortCriterion) intent.selector().getCriterion(Criterion.Type.UDP_SRC);
             UdpPortCriterion udpDstPort = (UdpPortCriterion) intent.selector().getCriterion(Criterion.Type.UDP_DST);
-            Set<IntIntent.IntMetadataType> metadataTypes = intent.metadataTypes();
+            Set<IntMetadataType> metadataTypes = intent.metadataTypes();
             row.cell(ID, intentId.toString())
                     .cell(SRC_ADDR, ip4Src == null ? "N/A" : ip4Src.ip().toString())
                     .cell(DST_ADDR, ip4Dst == null ? "N/A" : ip4Dst.ip().toString());
@@ -123,7 +124,7 @@
                         .cell(DST_PORT, "N/A");
             }
             String metaStr = "";
-            for (IntIntent.IntMetadataType metadataType : metadataTypes) {
+            for (IntMetadataType metadataType : metadataTypes) {
                 metaStr += metadataType.toString();
                 metaStr += ", ";
             }
diff --git a/apps/inbandtelemetry/app/src/main/java/org/onosproject/inbandtelemetry/app/ui/IntAppUiMessageHandler.java b/apps/inbandtelemetry/app/src/main/java/org/onosproject/inbandtelemetry/app/ui/IntAppUiMessageHandler.java
index 0dc18a4..226c428 100644
--- a/apps/inbandtelemetry/app/src/main/java/org/onosproject/inbandtelemetry/app/ui/IntAppUiMessageHandler.java
+++ b/apps/inbandtelemetry/app/src/main/java/org/onosproject/inbandtelemetry/app/ui/IntAppUiMessageHandler.java
@@ -25,8 +25,9 @@
 import org.onlab.packet.TpPort;
 import org.onosproject.inbandtelemetry.api.IntIntent;
 import org.onosproject.inbandtelemetry.api.IntIntentId;
+import org.onosproject.net.behaviour.inbandtelemetry.IntMetadataType;
 import org.onosproject.inbandtelemetry.api.IntService;
-import org.onosproject.inbandtelemetry.api.IntConfig;
+import org.onosproject.net.behaviour.inbandtelemetry.IntDeviceConfig;
 import org.onosproject.net.flow.DefaultTrafficSelector;
 import org.onosproject.net.flow.TrafficSelector;
 import org.onosproject.ui.RequestHandler;
@@ -67,7 +68,7 @@
             log.info("intConfigAddRequest: {}", payload);
 
             intService = get(IntService.class);
-            IntConfig.Builder builder = IntConfig.builder();
+            IntDeviceConfig.Builder builder = IntDeviceConfig.builder();
 
             if (payload.get("collectorIp") != null) {
                 builder.withCollectorIp(IpAddress.valueOf(payload.get("collectorIp").asText()));
@@ -152,25 +153,25 @@
                     for (final JsonNode json : meta) {
                         switch (json.asText()) {
                             case "SWITCH_ID":
-                                builder.withMetadataType(IntIntent.IntMetadataType.SWITCH_ID);
+                                builder.withMetadataType(IntMetadataType.SWITCH_ID);
                                 break;
                             case "PORT_ID":
-                                builder.withMetadataType(IntIntent.IntMetadataType.L1_PORT_ID);
+                                builder.withMetadataType(IntMetadataType.L1_PORT_ID);
                                 break;
                             case "HOP_LATENCY":
-                                builder.withMetadataType(IntIntent.IntMetadataType.HOP_LATENCY);
+                                builder.withMetadataType(IntMetadataType.HOP_LATENCY);
                                 break;
                             case "QUEUE_OCCUPANCY":
-                                builder.withMetadataType(IntIntent.IntMetadataType.QUEUE_OCCUPANCY);
+                                builder.withMetadataType(IntMetadataType.QUEUE_OCCUPANCY);
                                 break;
                             case "INGRESS_TIMESTAMP":
-                                builder.withMetadataType(IntIntent.IntMetadataType.INGRESS_TIMESTAMP);
+                                builder.withMetadataType(IntMetadataType.INGRESS_TIMESTAMP);
                                 break;
                             case "EGRESS_TIMESTAMP":
-                                builder.withMetadataType(IntIntent.IntMetadataType.EGRESS_TIMESTAMP);
+                                builder.withMetadataType(IntMetadataType.EGRESS_TIMESTAMP);
                                 break;
                             case "EGRESS_TX_UTIL":
-                                builder.withMetadataType(IntIntent.IntMetadataType.EGRESS_TX_UTIL);
+                                builder.withMetadataType(IntMetadataType.EGRESS_TX_UTIL);
                                 break;
                             default:
                                 break;
diff --git a/apps/inbandtelemetry/impl/src/main/java/org/onosproject/inbandtelemetry/impl/SimpleIntManager.java b/apps/inbandtelemetry/impl/src/main/java/org/onosproject/inbandtelemetry/impl/SimpleIntManager.java
index 5481997..906efd8 100644
--- a/apps/inbandtelemetry/impl/src/main/java/org/onosproject/inbandtelemetry/impl/SimpleIntManager.java
+++ b/apps/inbandtelemetry/impl/src/main/java/org/onosproject/inbandtelemetry/impl/SimpleIntManager.java
@@ -21,11 +21,12 @@
 import org.onlab.util.SharedScheduledExecutors;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.CoreService;
-import org.onosproject.inbandtelemetry.api.IntConfig;
+import org.onosproject.net.behaviour.inbandtelemetry.IntMetadataType;
+import org.onosproject.net.behaviour.inbandtelemetry.IntDeviceConfig;
 import org.onosproject.inbandtelemetry.api.IntIntent;
 import org.onosproject.inbandtelemetry.api.IntIntentId;
-import org.onosproject.inbandtelemetry.api.IntObjective;
-import org.onosproject.inbandtelemetry.api.IntProgrammable;
+import org.onosproject.net.behaviour.inbandtelemetry.IntObjective;
+import org.onosproject.net.behaviour.inbandtelemetry.IntProgrammable;
 import org.onosproject.inbandtelemetry.api.IntService;
 import org.onosproject.mastership.MastershipService;
 import org.onosproject.net.ConnectPoint;
@@ -114,7 +115,7 @@
     // Distributed state.
     private ConsistentMap<IntIntentId, IntIntent> intentMap;
     private ConsistentMap<DeviceId, Long> devicesToConfigure;
-    private AtomicValue<IntConfig> intConfig;
+    private AtomicValue<IntDeviceConfig> intConfig;
     private AtomicValue<Boolean> intStarted;
     private AtomicIdGenerator intentIds;
 
@@ -138,11 +139,11 @@
                 .register(IntIntentId.class)
                 .register(IntDeviceRole.class)
                 .register(IntIntent.IntHeaderType.class)
-                .register(IntIntent.IntMetadataType.class)
+                .register(IntMetadataType.class)
                 .register(IntIntent.IntReportType.class)
                 .register(IntIntent.TelemetryMode.class)
-                .register(IntConfig.class)
-                .register(IntConfig.TelemetrySpec.class);
+                .register(IntDeviceConfig.class)
+                .register(IntDeviceConfig.TelemetrySpec.class);
 
         devicesToConfigure = storageService.<DeviceId, Long>consistentMapBuilder()
                 .withSerializer(Serializer.using(serializer.build()))
@@ -168,7 +169,7 @@
                 .asAtomicValue();
         intStarted.addListener(intStartedListener);
 
-        intConfig = storageService.<IntConfig>atomicValueBuilder()
+        intConfig = storageService.<IntDeviceConfig>atomicValueBuilder()
                 .withSerializer(Serializer.using(serializer.build()))
                 .withName("onos-int-config")
                 .withApplicationId(appId)
@@ -241,14 +242,14 @@
     }
 
     @Override
-    public void setConfig(IntConfig cfg) {
+    public void setConfig(IntDeviceConfig cfg) {
         checkNotNull(cfg);
         // Atomic value event will trigger device configure.
         intConfig.set(cfg);
     }
 
     @Override
-    public IntConfig getConfig() {
+    public IntDeviceConfig getConfig() {
         return intConfig.get();
     }
 
@@ -438,10 +439,11 @@
     }
 
     private IntObjective getIntObjective(IntIntent intent) {
+        // FIXME: we are ignore intent.headerType()
+        //  what should we do with it?
         return new IntObjective.Builder()
                 .withSelector(intent.selector())
                 .withMetadataTypes(intent.metadataTypes())
-                .withHeaderType(intent.headerType())
                 .build();
     }
 
@@ -486,9 +488,9 @@
     }
 
     private class InternalIntConfigListener
-            implements AtomicValueEventListener<IntConfig> {
+            implements AtomicValueEventListener<IntDeviceConfig> {
         @Override
-        public void event(AtomicValueEvent<IntConfig> event) {
+        public void event(AtomicValueEvent<IntDeviceConfig> event) {
             triggerAllDeviceConfigure();
         }
     }
diff --git a/apps/inbandtelemetry/api/src/main/java/org/onosproject/inbandtelemetry/api/IntConfig.java b/core/api/src/main/java/org/onosproject/net/behaviour/inbandtelemetry/IntDeviceConfig.java
similarity index 87%
rename from apps/inbandtelemetry/api/src/main/java/org/onosproject/inbandtelemetry/api/IntConfig.java
rename to core/api/src/main/java/org/onosproject/net/behaviour/inbandtelemetry/IntDeviceConfig.java
index c5af580..c77b7bd 100644
--- a/apps/inbandtelemetry/api/src/main/java/org/onosproject/inbandtelemetry/api/IntConfig.java
+++ b/core/api/src/main/java/org/onosproject/net/behaviour/inbandtelemetry/IntDeviceConfig.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.inbandtelemetry.api;
+package org.onosproject.net.behaviour.inbandtelemetry;
 
 import com.google.common.annotations.Beta;
 import org.onlab.packet.IpAddress;
@@ -23,10 +23,10 @@
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
- * Network-level INT configuration.
+ * Device-level configuration of the INT process.
  */
 @Beta
-public final class IntConfig {
+public final class IntDeviceConfig {
     /**
      * Represents a type of telemetry spec to collect in the dataplane.
      */
@@ -55,8 +55,8 @@
     private final TelemetrySpec spec;
     private boolean enabled;
 
-    private IntConfig(IpAddress collectorIp, TpPort collectorPort, MacAddress collectorNextHopMac,
-                      IpAddress sinkIp, MacAddress sinkMac, TelemetrySpec spec, boolean enabled) {
+    private IntDeviceConfig(IpAddress collectorIp, TpPort collectorPort, MacAddress collectorNextHopMac,
+                            IpAddress sinkIp, MacAddress sinkMac, TelemetrySpec spec, boolean enabled) {
         this.collectorIp = collectorIp;
         this.collectorPort = collectorPort;
         this.collectorNextHopMac = collectorNextHopMac;
@@ -172,7 +172,7 @@
          * @param collectorIp IP address of the collector
          * @return an IntConfig builder
          */
-        public IntConfig.Builder withCollectorIp(IpAddress collectorIp) {
+        public IntDeviceConfig.Builder withCollectorIp(IpAddress collectorIp) {
             this.collectorIp = collectorIp;
             return this;
         }
@@ -183,7 +183,7 @@
          * @param collectorPort UDP port number of the collector
          * @return an IntConfig builder
          */
-        public IntConfig.Builder withCollectorPort(TpPort collectorPort) {
+        public IntDeviceConfig.Builder withCollectorPort(TpPort collectorPort) {
             this.collectorPort = collectorPort;
             return this;
         }
@@ -195,7 +195,7 @@
          * @param collectorNextHopMac MAC address of the collector
          * @return an IntConfig builder
          */
-        public IntConfig.Builder withCollectorNextHopMac(MacAddress collectorNextHopMac) {
+        public IntDeviceConfig.Builder withCollectorNextHopMac(MacAddress collectorNextHopMac) {
             this.collectorNextHopMac = collectorNextHopMac;
             return this;
         }
@@ -206,7 +206,7 @@
          * @param sinkIp sink device's IP address
          * @return an IntConfig builder
          */
-        public IntConfig.Builder withSinkIp(IpAddress sinkIp) {
+        public IntDeviceConfig.Builder withSinkIp(IpAddress sinkIp) {
             this.sinkIp = sinkIp;
             return this;
         }
@@ -217,7 +217,7 @@
          * @param sinkMac sink device's MAC address
          * @return an IntConfig builder
          */
-        public IntConfig.Builder withSinkMac(MacAddress sinkMac) {
+        public IntDeviceConfig.Builder withSinkMac(MacAddress sinkMac) {
             this.sinkMac = sinkMac;
             return this;
         }
@@ -228,7 +228,7 @@
          * @param spec telemetry spec
          * @return an IntConfig builder
          */
-        public IntConfig.Builder withTelemetrySpec(TelemetrySpec spec) {
+        public IntDeviceConfig.Builder withTelemetrySpec(TelemetrySpec spec) {
             this.spec = spec;
             return this;
         }
@@ -240,7 +240,7 @@
          * @param enabled the status of INT
          * @return an IntConfig builder
          */
-        public IntConfig.Builder enabled(boolean enabled) {
+        public IntDeviceConfig.Builder enabled(boolean enabled) {
             this.enabled = enabled;
             return this;
         }
@@ -250,13 +250,13 @@
          *
          * @return an IntConfig object
          */
-        public IntConfig build() {
+        public IntDeviceConfig build() {
             checkNotNull(collectorIp, "Collector IP should be specified.");
             checkNotNull(collectorPort, "Collector port number should be specified.");
             checkNotNull(collectorNextHopMac, "Next hop MAC address for report packets should be provided.");
             checkNotNull(sinkIp, "Sink IP address for report packets should be specified.");
             checkNotNull(sinkMac, "Sink MAC address for report packets should be specified.");
-            return new IntConfig(collectorIp, collectorPort, collectorNextHopMac,
+            return new IntDeviceConfig(collectorIp, collectorPort, collectorNextHopMac,
                                  sinkIp, sinkMac, spec, enabled);
         }
     }
diff --git a/core/api/src/main/java/org/onosproject/net/behaviour/inbandtelemetry/IntMetadataType.java b/core/api/src/main/java/org/onosproject/net/behaviour/inbandtelemetry/IntMetadataType.java
new file mode 100644
index 0000000..fec5a17
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/behaviour/inbandtelemetry/IntMetadataType.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2020-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.inbandtelemetry;
+
+/**
+ * Represents a type of INT metadata.
+ */
+public enum IntMetadataType {
+    /**
+     * ID of a switch, unique in the scope of the whole network.
+     */
+    SWITCH_ID,
+    /**
+     * The port on which the INT packet was received and sent out.
+     */
+    L1_PORT_ID,
+    /**
+     * Time taken for the INT packet to be switched within the device.
+     */
+    HOP_LATENCY,
+    /**
+     * The build-up of traffic in the queue that the INT packet observes
+     * in the device while being forwarded.
+     */
+    QUEUE_OCCUPANCY,
+    /**
+     * The device local time when the INT packet was received on the ingress port.
+     */
+    INGRESS_TIMESTAMP,
+    /**
+     * The device local time when the INT packet was processed by the egress port.
+     */
+    EGRESS_TIMESTAMP,
+    /**
+     * The logical ports on which the INT packet was received and sent out.
+     */
+    L2_PORT_ID,
+    /**
+     * Current utilization of the egress port via witch the INT packet was sent out.
+     */
+    EGRESS_TX_UTIL
+}
diff --git a/apps/inbandtelemetry/api/src/main/java/org/onosproject/inbandtelemetry/api/IntObjective.java b/core/api/src/main/java/org/onosproject/net/behaviour/inbandtelemetry/IntObjective.java
similarity index 67%
rename from apps/inbandtelemetry/api/src/main/java/org/onosproject/inbandtelemetry/api/IntObjective.java
rename to core/api/src/main/java/org/onosproject/net/behaviour/inbandtelemetry/IntObjective.java
index da8dc29..b73e9c2 100644
--- a/apps/inbandtelemetry/api/src/main/java/org/onosproject/inbandtelemetry/api/IntObjective.java
+++ b/core/api/src/main/java/org/onosproject/net/behaviour/inbandtelemetry/IntObjective.java
@@ -13,8 +13,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.inbandtelemetry.api;
+package org.onosproject.net.behaviour.inbandtelemetry;
 
+import com.google.common.collect.ImmutableSet;
 import org.onosproject.net.flow.DefaultTrafficSelector;
 import org.onosproject.net.flow.TrafficSelector;
 
@@ -22,10 +23,11 @@
 import java.util.Set;
 
 import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.inbandtelemetry.api.IntIntent.IntMetadataType;
-import static org.onosproject.inbandtelemetry.api.IntIntent.IntHeaderType;
 
+/**
+ * Represents a device-level objective to collect INT metadata for packets
+ * identified by a traffic selector.
+ */
 public final class IntObjective {
 
     private static final int DEFAULT_PRIORITY = 10;
@@ -33,22 +35,17 @@
     // TrafficSelector to describe target flows to monitor
     private final TrafficSelector selector;
     // Set of metadata types to collect
-    private final Set<IntMetadataType> metadataTypes;
-    // Type of header (either hop-by-hop or destination)
-    private final IntHeaderType headerType;
+    private final ImmutableSet<IntMetadataType> metadataTypes;
 
     /**
      * Creates an IntObjective.
      *
      * @param selector      the traffic selector that identifies traffic to enable INT
      * @param metadataTypes a set of metadata types to collect
-     * @param headerType    the type of INT header
      */
-    private IntObjective(TrafficSelector selector, Set<IntMetadataType> metadataTypes,
-                         IntHeaderType headerType) {
+    private IntObjective(TrafficSelector selector, Set<IntMetadataType> metadataTypes) {
         this.selector = selector;
-        this.metadataTypes = metadataTypes;
-        this.headerType = headerType;
+        this.metadataTypes = ImmutableSet.copyOf(metadataTypes);
     }
 
     /**
@@ -70,21 +67,11 @@
     }
 
     /**
-     * Returns a INT header type specified in this objective.
-     *
-     * @return INT header type
-     */
-    public IntHeaderType headerType() {
-        return headerType;
-    }
-
-    /**
      * An IntObjective builder.
      */
     public static final class Builder {
         private TrafficSelector selector = DefaultTrafficSelector.emptySelector();
-        private Set<IntMetadataType> metadataTypes = new HashSet<>();
-        private IntHeaderType headerType = IntHeaderType.HOP_BY_HOP;
+        private final Set<IntMetadataType> metadataTypes = new HashSet<>();
 
         /**
          * Assigns a selector to the IntObjective.
@@ -109,17 +96,6 @@
         }
 
         /**
-         * Assigns a header type to the IntObjective.
-         *
-         * @param headerType a header type
-         * @return an IntObjective builder
-         */
-        public IntObjective.Builder withHeaderType(IntHeaderType headerType) {
-            this.headerType = headerType;
-            return this;
-        }
-
-        /**
          * Builds the IntObjective.
          *
          * @return an IntObjective
@@ -127,9 +103,8 @@
         public IntObjective build() {
             checkArgument(!selector.criteria().isEmpty(), "Empty selector cannot match any flow.");
             checkArgument(!metadataTypes.isEmpty(), "Metadata types cannot be empty");
-            checkNotNull(headerType, "Header type cannot be null.");
 
-            return new IntObjective(selector, metadataTypes, headerType);
+            return new IntObjective(selector, metadataTypes);
         }
     }
 }
diff --git a/apps/inbandtelemetry/api/src/main/java/org/onosproject/inbandtelemetry/api/IntProgrammable.java b/core/api/src/main/java/org/onosproject/net/behaviour/inbandtelemetry/IntProgrammable.java
similarity index 91%
rename from apps/inbandtelemetry/api/src/main/java/org/onosproject/inbandtelemetry/api/IntProgrammable.java
rename to core/api/src/main/java/org/onosproject/net/behaviour/inbandtelemetry/IntProgrammable.java
index 507f870..5560e8c 100644
--- a/apps/inbandtelemetry/api/src/main/java/org/onosproject/inbandtelemetry/api/IntProgrammable.java
+++ b/core/api/src/main/java/org/onosproject/net/behaviour/inbandtelemetry/IntProgrammable.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.inbandtelemetry.api;
+package org.onosproject.net.behaviour.inbandtelemetry;
 
 import com.google.common.annotations.Beta;
 import org.onosproject.net.PortNumber;
@@ -55,7 +55,7 @@
 
     /**
      * Configures the given port as an INT source port. Packets received via
-     * this port can be modified to add the INT header, if a corresponding  INT
+     * this port can be modified to add the INT header, if a corresponding INT
      * objective is matched. Returns true if the operation was successful, false
      * otherwise.
      *
@@ -79,7 +79,7 @@
      * Adds a given IntObjective to the device.
      *
      * @param obj an IntObjective
-     * @return true if the objective is successfully added; false otherwise.
+     * @return true if the objective was successfully added; false otherwise.
      */
     boolean addIntObjective(IntObjective obj);
 
@@ -87,7 +87,7 @@
      * Removes a given IntObjective entry from the device.
      *
      * @param obj an IntObjective
-     * @return true if the objective is successfully removed; false otherwise.
+     * @return true if the objective was successfully removed; false otherwise.
      */
     boolean removeIntObjective(IntObjective obj);
 
@@ -97,7 +97,7 @@
      * @param config a configuration regarding to the collector
      * @return true if the objective is successfully added; false otherwise.
      */
-    boolean setupIntConfig(IntConfig config);
+    boolean setupIntConfig(IntDeviceConfig config);
 
     /**
      * Clean up any INT-related configuration from the device.
diff --git a/core/api/src/main/java/org/onosproject/net/behaviour/inbandtelemetry/package-info.java b/core/api/src/main/java/org/onosproject/net/behaviour/inbandtelemetry/package-info.java
new file mode 100644
index 0000000..fcbdf71
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/behaviour/inbandtelemetry/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2015-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.
+ */
+
+/**
+ * Behaviors abstracting devices supporting in-band network telemetry.
+ */
+package org.onosproject.net.behaviour.inbandtelemetry;
diff --git a/pipelines/basic/BUILD b/pipelines/basic/BUILD
index c5b3136..de5fd3a 100644
--- a/pipelines/basic/BUILD
+++ b/pipelines/basic/BUILD
@@ -2,12 +2,10 @@
     "@minimal_json//jar",
     "//protocols/p4runtime/model:onos-protocols-p4runtime-model",
     "//protocols/p4runtime/api:onos-protocols-p4runtime-api",
-    "//apps/inbandtelemetry/api:onos-apps-inbandtelemetry-api",
 ]
 
 BUNDLES = [
     "//pipelines/basic:onos-pipelines-basic",
-    "//apps/inbandtelemetry/api:onos-apps-inbandtelemetry-api",
 ]
 
 osgi_jar(
diff --git a/pipelines/basic/src/main/java/org/onosproject/pipelines/basic/IntProgrammableImpl.java b/pipelines/basic/src/main/java/org/onosproject/pipelines/basic/IntProgrammableImpl.java
index 9a81e4c..0e8d2cd 100644
--- a/pipelines/basic/src/main/java/org/onosproject/pipelines/basic/IntProgrammableImpl.java
+++ b/pipelines/basic/src/main/java/org/onosproject/pipelines/basic/IntProgrammableImpl.java
@@ -16,15 +16,15 @@
 package org.onosproject.pipelines.basic;
 
 import com.google.common.collect.Sets;
+import org.onosproject.net.behaviour.inbandtelemetry.IntMetadataType;
 import org.osgi.service.component.annotations.Reference;
 import org.osgi.service.component.annotations.ReferenceCardinality;
 import org.onlab.util.ImmutableByteSequence;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.CoreService;
-import org.onosproject.inbandtelemetry.api.IntConfig;
-import org.onosproject.inbandtelemetry.api.IntIntent;
-import org.onosproject.inbandtelemetry.api.IntObjective;
-import org.onosproject.inbandtelemetry.api.IntProgrammable;
+import org.onosproject.net.behaviour.inbandtelemetry.IntDeviceConfig;
+import org.onosproject.net.behaviour.inbandtelemetry.IntObjective;
+import org.onosproject.net.behaviour.inbandtelemetry.IntProgrammable;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.PortNumber;
 import org.onosproject.net.driver.AbstractHandlerBehaviour;
@@ -215,7 +215,7 @@
     }
 
     @Override
-    public boolean setupIntConfig(IntConfig config) {
+    public boolean setupIntConfig(IntDeviceConfig config) {
         return setupIntReportInternal(config);
     }
 
@@ -353,9 +353,9 @@
                 .build();
     }
 
-    private int buildInstructionBitmap(Set<IntIntent.IntMetadataType> metadataTypes) {
+    private int buildInstructionBitmap(Set<IntMetadataType> metadataTypes) {
         int instBitmap = 0;
-        for (IntIntent.IntMetadataType metadataType : metadataTypes) {
+        for (IntMetadataType metadataType : metadataTypes) {
             switch (metadataType) {
                 case SWITCH_ID:
                     instBitmap |= (1 << 15);
@@ -430,7 +430,7 @@
         }
     }
 
-    private boolean setupIntReportInternal(IntConfig cfg) {
+    private boolean setupIntReportInternal(IntDeviceConfig cfg) {
         if (!setupBehaviour()) {
             return false;
         }
@@ -446,7 +446,7 @@
         }
     }
 
-    private FlowRule buildReportEntry(IntConfig cfg) {
+    private FlowRule buildReportEntry(IntDeviceConfig cfg) {
         TrafficSelector selector = DefaultTrafficSelector.builder()
                 .matchPi(PiCriterion.builder().matchExact(
                         IntConstants.HDR_INT_IS_VALID, (byte) 0x01)
diff --git a/pipelines/basic/src/main/java/org/onosproject/pipelines/basic/PipeconfLoader.java b/pipelines/basic/src/main/java/org/onosproject/pipelines/basic/PipeconfLoader.java
index 02dcd29..1ba5957 100644
--- a/pipelines/basic/src/main/java/org/onosproject/pipelines/basic/PipeconfLoader.java
+++ b/pipelines/basic/src/main/java/org/onosproject/pipelines/basic/PipeconfLoader.java
@@ -18,7 +18,7 @@
 
 import com.google.common.collect.ImmutableList;
 import org.onosproject.core.CoreService;
-import org.onosproject.inbandtelemetry.api.IntProgrammable;
+import org.onosproject.net.behaviour.inbandtelemetry.IntProgrammable;
 import org.onosproject.net.behaviour.Pipeliner;
 import org.onosproject.net.device.PortStatisticsDiscovery;
 import org.onosproject.net.pi.model.DefaultPiPipeconf;
diff --git a/pipelines/fabric/BUILD b/pipelines/fabric/BUILD
index 41ecec5..19a74d2 100644
--- a/pipelines/fabric/BUILD
+++ b/pipelines/fabric/BUILD
@@ -1,7 +1,6 @@
 BUNDLES = [
     "//pipelines/fabric/api:onos-pipelines-fabric-api",
     "//pipelines/fabric/impl:onos-pipelines-fabric-impl",
-    "//apps/inbandtelemetry/api:onos-apps-inbandtelemetry-api",
 ]
 
 onos_app(
diff --git a/pipelines/fabric/impl/BUILD b/pipelines/fabric/impl/BUILD
index 3e8824d..e5c214b 100644
--- a/pipelines/fabric/impl/BUILD
+++ b/pipelines/fabric/impl/BUILD
@@ -5,7 +5,6 @@
     "//providers/general/device:onos-providers-general-device",
     "//pipelines/basic:onos-pipelines-basic",
     "//core/store/serializers:onos-core-serializers",
-    "//apps/inbandtelemetry/api:onos-apps-inbandtelemetry-api",
     "//drivers/p4runtime:onos-drivers-p4runtime",
 ]
 
diff --git a/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/FabricPipeconfManager.java b/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/FabricPipeconfManager.java
index f366e99..d8af395 100644
--- a/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/FabricPipeconfManager.java
+++ b/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/FabricPipeconfManager.java
@@ -16,7 +16,7 @@
 
 package org.onosproject.pipelines.fabric.impl;
 
-import org.onosproject.inbandtelemetry.api.IntProgrammable;
+import org.onosproject.net.behaviour.inbandtelemetry.IntProgrammable;
 
 import org.onosproject.net.behaviour.BngProgrammable;
 import org.onosproject.net.behaviour.Pipeliner;
diff --git a/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/behaviour/FabricIntProgrammable.java b/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/behaviour/FabricIntProgrammable.java
index 6edbfd7..7f9e35e 100644
--- a/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/behaviour/FabricIntProgrammable.java
+++ b/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/behaviour/FabricIntProgrammable.java
@@ -18,10 +18,10 @@
 import com.google.common.collect.Sets;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.CoreService;
-import org.onosproject.inbandtelemetry.api.IntConfig;
-import org.onosproject.inbandtelemetry.api.IntIntent;
-import org.onosproject.inbandtelemetry.api.IntObjective;
-import org.onosproject.inbandtelemetry.api.IntProgrammable;
+import org.onosproject.net.behaviour.inbandtelemetry.IntMetadataType;
+import org.onosproject.net.behaviour.inbandtelemetry.IntDeviceConfig;
+import org.onosproject.net.behaviour.inbandtelemetry.IntObjective;
+import org.onosproject.net.behaviour.inbandtelemetry.IntProgrammable;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.PortNumber;
 import org.onosproject.net.config.NetworkConfigService;
@@ -259,7 +259,7 @@
     }
 
     @Override
-    public boolean setupIntConfig(IntConfig config) {
+    public boolean setupIntConfig(IntDeviceConfig config) {
 
         if (!setupBehaviour()) {
             return false;
@@ -368,9 +368,9 @@
                 .build();
     }
 
-    private int buildInstructionBitmap(Set<IntIntent.IntMetadataType> metadataTypes) {
+    private int buildInstructionBitmap(Set<IntMetadataType> metadataTypes) {
         int instBitmap = 0;
-        for (IntIntent.IntMetadataType metadataType : metadataTypes) {
+        for (IntMetadataType metadataType : metadataTypes) {
             switch (metadataType) {
                 case SWITCH_ID:
                     instBitmap |= (1 << 15);
@@ -442,7 +442,7 @@
         }
     }
 
-    private boolean setupIntReportInternal(IntConfig cfg) {
+    private boolean setupIntReportInternal(IntDeviceConfig cfg) {
         // Report not fully supported yet.
         return true;
         // FlowRule reportRule = buildReportEntry(cfg, PKT_INSTANCE_TYPE_INGRESS_CLONE);
@@ -456,7 +456,7 @@
         // }
     }
 
-    private FlowRule buildReportEntry(IntConfig cfg, int type) {
+    private FlowRule buildReportEntry(IntDeviceConfig cfg, int type) {
 
         if (!setupBehaviour()) {
             return null;