karthik1977 | bc5ea1e | 2023-01-02 19:25:14 +0530 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2023-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 | */ |
| 16 | package org.onosproject.netflow.impl; |
| 17 | |
| 18 | import java.util.List; |
| 19 | |
| 20 | import org.onlab.packet.Deserializer; |
| 21 | |
| 22 | |
| 23 | /** |
| 24 | * The Options Template Record (and its corresponding Options Data |
| 25 | * Record) is used to supply information about the NetFlow process |
| 26 | * configuration or NetFlow process specific data, rather than supplying |
| 27 | * information about IP Flows. |
| 28 | * Ref: https://www.ietf.org/rfc/rfc3954.txt |
| 29 | */ |
| 30 | public class OptionalTemplateFlowSet extends FlowSet { |
| 31 | |
| 32 | /* |
| 33 | 0 1 2 3 |
| 34 | 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
| 35 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 36 | | FlowSet ID = 1 | Length | |
| 37 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 38 | | Template ID | Option Scope Length | |
| 39 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 40 | | Option Length | Scope 1 Field Type | |
| 41 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 42 | | Scope 1 Field Length | ... | |
| 43 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 44 | | Scope N Field Length | Option 1 Field Type | |
| 45 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 46 | | Option 1 Field Length | ... | |
| 47 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 48 | | Option M Field Length | Padding | |
| 49 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 50 | */ |
| 51 | |
| 52 | private int flowSetId; |
| 53 | |
| 54 | private int length; |
| 55 | |
| 56 | private List<DataTemplateRecord> records; |
| 57 | |
| 58 | /** |
| 59 | * Returns flowset type. |
| 60 | * |
| 61 | * @return flowset type |
| 62 | */ |
| 63 | @Override |
| 64 | public Type getType() { |
| 65 | return Type.OPTIONAL_TEMPLATE_FLOWSET; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Returns flowset id. |
| 70 | * FlowSet ID value of 1 is reserved for the Options Template. |
| 71 | * |
| 72 | * @return flow set ID |
| 73 | */ |
| 74 | public int getFlowSetId() { |
| 75 | return flowSetId; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Returns total length of this FlowSet. |
| 80 | * Each Options Template FlowSet |
| 81 | * MAY contain multiple Options Template Records. Thus, the |
| 82 | * Length value MUST be used to determine the position of the next |
| 83 | * FlowSet record, which could be either a Template FlowSet or |
| 84 | * Data FlowSet. |
| 85 | * |
| 86 | * @return flow set ID |
| 87 | */ |
| 88 | public int getLength() { |
| 89 | return length; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * Returns list of optional data template records. |
| 94 | * |
| 95 | * @return list of optional data template records |
| 96 | */ |
| 97 | public List<DataTemplateRecord> getRecords() { |
| 98 | return records; |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Deserializer function for data option template flowset. |
| 103 | * |
| 104 | * @return data deserializer function |
| 105 | */ |
| 106 | public static Deserializer<OptionalTemplateFlowSet> deserializer() { |
| 107 | return (data, offset, length) -> { |
| 108 | //TODO parse optional template |
| 109 | return new OptionalTemplateFlowSet(); |
| 110 | }; |
| 111 | } |
| 112 | |
| 113 | } |