Jonghwan Hyun | 722275f | 2018-05-14 15:44:56 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Carmelo Cascone | defc74e | 2020-07-17 15:27:02 -0700 | [diff] [blame] | 16 | package org.onosproject.net.behaviour.inbandtelemetry; |
Jonghwan Hyun | 722275f | 2018-05-14 15:44:56 -0700 | [diff] [blame] | 17 | |
| 18 | import com.google.common.annotations.Beta; |
Carmelo Cascone | fa42158 | 2018-09-13 10:05:57 -0700 | [diff] [blame] | 19 | import org.onosproject.net.PortNumber; |
Jonghwan Hyun | 722275f | 2018-05-14 15:44:56 -0700 | [diff] [blame] | 20 | import org.onosproject.net.driver.HandlerBehaviour; |
| 21 | |
Carmelo Cascone | fa42158 | 2018-09-13 10:05:57 -0700 | [diff] [blame] | 22 | /** |
| 23 | * Abstraction of a device implementing In-band Network Telemetry (INT) |
| 24 | * capabilities. |
| 25 | */ |
Jonghwan Hyun | 722275f | 2018-05-14 15:44:56 -0700 | [diff] [blame] | 26 | @Beta |
| 27 | public interface IntProgrammable extends HandlerBehaviour { |
| 28 | |
| 29 | /** |
Carmelo Cascone | fa42158 | 2018-09-13 10:05:57 -0700 | [diff] [blame] | 30 | * INT functionalities that a device can implement. |
Jonghwan Hyun | 722275f | 2018-05-14 15:44:56 -0700 | [diff] [blame] | 31 | */ |
Carmelo Cascone | fa42158 | 2018-09-13 10:05:57 -0700 | [diff] [blame] | 32 | enum IntFunctionality { |
| 33 | /** |
| 34 | * Source functionality. |
| 35 | */ |
| 36 | SOURCE, |
| 37 | /** |
| 38 | * Sink functionality. |
| 39 | */ |
| 40 | SINK, |
| 41 | /** |
| 42 | * Transit functionality. |
| 43 | */ |
Yi Tseng | 4027cac | 2020-10-13 19:15:12 -0700 | [diff] [blame] | 44 | TRANSIT, |
| 45 | /** |
| 46 | * Postcard functionality. |
| 47 | */ |
| 48 | POSTCARD |
Carmelo Cascone | fa42158 | 2018-09-13 10:05:57 -0700 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Initializes the pipeline, by installing required flow rules not relevant |
| 53 | * to specific watchlist, report and event. Returns true if the operation |
| 54 | * was successful, false otherwise. |
| 55 | * |
| 56 | * @return true if successful, false otherwise |
| 57 | */ |
| 58 | boolean init(); |
| 59 | |
| 60 | /** |
| 61 | * Configures the given port as an INT source port. Packets received via |
Carmelo Cascone | defc74e | 2020-07-17 15:27:02 -0700 | [diff] [blame] | 62 | * this port can be modified to add the INT header, if a corresponding INT |
Carmelo Cascone | fa42158 | 2018-09-13 10:05:57 -0700 | [diff] [blame] | 63 | * objective is matched. Returns true if the operation was successful, false |
| 64 | * otherwise. |
| 65 | * |
| 66 | * @param port port |
| 67 | * @return true if successful, false otherwise |
| 68 | */ |
| 69 | boolean setSourcePort(PortNumber port); |
| 70 | |
| 71 | /** |
| 72 | * Configures the given port as an INT sink port. Packets forwarded via this |
| 73 | * port will be stripped of the INT header and a corresponding INT report |
| 74 | * will be generated. Returns true if the operation was successful, false |
| 75 | * otherwise. |
| 76 | * |
| 77 | * @param port port |
| 78 | * @return true if successful, false otherwise |
| 79 | */ |
| 80 | boolean setSinkPort(PortNumber port); |
Jonghwan Hyun | 722275f | 2018-05-14 15:44:56 -0700 | [diff] [blame] | 81 | |
| 82 | /** |
| 83 | * Adds a given IntObjective to the device. |
| 84 | * |
| 85 | * @param obj an IntObjective |
Carmelo Cascone | defc74e | 2020-07-17 15:27:02 -0700 | [diff] [blame] | 86 | * @return true if the objective was successfully added; false otherwise. |
Jonghwan Hyun | 722275f | 2018-05-14 15:44:56 -0700 | [diff] [blame] | 87 | */ |
Carmelo Cascone | fa42158 | 2018-09-13 10:05:57 -0700 | [diff] [blame] | 88 | boolean addIntObjective(IntObjective obj); |
Jonghwan Hyun | 722275f | 2018-05-14 15:44:56 -0700 | [diff] [blame] | 89 | |
| 90 | /** |
| 91 | * Removes a given IntObjective entry from the device. |
| 92 | * |
| 93 | * @param obj an IntObjective |
Carmelo Cascone | defc74e | 2020-07-17 15:27:02 -0700 | [diff] [blame] | 94 | * @return true if the objective was successfully removed; false otherwise. |
Jonghwan Hyun | 722275f | 2018-05-14 15:44:56 -0700 | [diff] [blame] | 95 | */ |
Carmelo Cascone | fa42158 | 2018-09-13 10:05:57 -0700 | [diff] [blame] | 96 | boolean removeIntObjective(IntObjective obj); |
Jonghwan Hyun | 722275f | 2018-05-14 15:44:56 -0700 | [diff] [blame] | 97 | |
| 98 | /** |
| 99 | * Set up report-related configuration. |
| 100 | * |
| 101 | * @param config a configuration regarding to the collector |
| 102 | * @return true if the objective is successfully added; false otherwise. |
| 103 | */ |
Carmelo Cascone | defc74e | 2020-07-17 15:27:02 -0700 | [diff] [blame] | 104 | boolean setupIntConfig(IntDeviceConfig config); |
Carmelo Cascone | fa42158 | 2018-09-13 10:05:57 -0700 | [diff] [blame] | 105 | |
| 106 | /** |
| 107 | * Clean up any INT-related configuration from the device. |
| 108 | */ |
| 109 | void cleanup(); |
| 110 | |
| 111 | /** |
| 112 | * Returns true if this device supports the given INT functionality. |
| 113 | * |
| 114 | * @param functionality INt functionality |
| 115 | * @return true if functionality is supported, false otherwise |
| 116 | */ |
| 117 | boolean supportsFunctionality(IntFunctionality functionality); |
Jonghwan Hyun | 722275f | 2018-05-14 15:44:56 -0700 | [diff] [blame] | 118 | |
| 119 | //TODO: [ONOS-7616] Design IntEvent and related APIs |
| 120 | } |