Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 1 | /* |
Tinoj Joseph | 429b9d9 | 2022-11-16 18:51:05 +0530 | [diff] [blame] | 2 | |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 3 | * Copyright 2022-present Open Networking Foundation |
| 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. |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 15 | */ |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 16 | |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 17 | package onosnbi |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 18 | |
| 19 | import ( |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 20 | "fmt" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 21 | "strconv" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 22 | app "voltha-go-controller/internal/pkg/application" |
Tinoj Joseph | 429b9d9 | 2022-11-16 18:51:05 +0530 | [diff] [blame] | 23 | "voltha-go-controller/internal/pkg/controller" |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 24 | |
| 25 | "voltha-go-controller/internal/pkg/of" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 26 | ) |
| 27 | |
| 28 | const ( |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 29 | /** Switch input port. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 30 | InPort string = "IN_PORT" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 31 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 32 | /** Switch physical input port. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 33 | InPhyPort string = "IN_PHY_PORT" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 34 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 35 | /** Metadata passed between tables. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 36 | MetaData string = "METADATA" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 37 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 38 | /** Ethernet destination address. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 39 | EthDst string = "ETH_DST" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 40 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 41 | /** Ethernet destination address with masking. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 42 | EthDstMasked = "ETH_DST_MASKED" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 43 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 44 | /** Ethernet source address. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 45 | EthSrc string = "ETH_SRC" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 46 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 47 | /** Ethernet source address with masking. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 48 | EthSrcMasked string = "ETH_SRC_MASKED" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 49 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 50 | /** Ethernet frame type. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 51 | EthType string = "ETH_TYPE" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 52 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 53 | /** VLAN id. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 54 | VlanVID string = "VLAN_VID" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 55 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 56 | /** VLAN priority. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 57 | VlanPcp string = "VLAN_PCP" |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 58 | /** |
| 59 | * Inner VLAN id. |
| 60 | * |
| 61 | * Note: Some drivers may not support this. |
| 62 | */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 63 | InnerVlanVID string = "INNER_VLAN_VID" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 64 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 65 | /** |
| 66 | * Inner VLAN pcp. |
| 67 | * |
| 68 | * Note: Some drivers may not support this. |
| 69 | */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 70 | InnerVlanPcp string = "INNER_VLAN_PCP" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 71 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 72 | /** IP DSCP (6 bits in ToS field). */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 73 | IPDscp string = "IP_DSCP" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 74 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 75 | /** IP ECN (2 bits in ToS field). */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 76 | IPEcn string = "IP_ECN" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 77 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 78 | /** IP protocol. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 79 | IPProto string = "IP_PROTO" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 80 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 81 | /** IPv4 source address. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 82 | Ipv4Src string = "IPV4_SRC" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 83 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 84 | /** IPv4 destination address. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 85 | Ipv4Dst string = "IPV4_DST" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 86 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 87 | /** TCP source port. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 88 | TCPSrc string = "TCP_SRC" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 89 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 90 | /** TCP source port with masking. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 91 | TCPSrcMasked string = "TCP_SRC_MASKED" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 92 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 93 | /** TCP destination port. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 94 | TCPDst string = "TCP_DST" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 95 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 96 | /** TCP destination port with masking. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 97 | TCPDstMasked string = "TCP_DST" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 98 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 99 | /** UDP source port. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 100 | UDPSrc string = "UDP_SRC" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 101 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 102 | /** UDP source port with masking. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 103 | UDPSrcMasked string = "UDP_SRC_MASKED" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 104 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 105 | /** UDP destination port. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 106 | UDPDst string = "UDP_DST" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 107 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 108 | /** UDP destination port with masking. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 109 | UDPDstMasked string = "UDP_DST_MASKED" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 110 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 111 | /** SCTP source port. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 112 | SctpSrc string = "SCTP_SRC" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 113 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 114 | /** SCTP source port with masking. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 115 | SctpSrcMasked string = "SCTP_SRC_MASKED" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 116 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 117 | /** SCTP destination port. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 118 | SctpDst string = "SCTP_DST" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 119 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 120 | /** SCTP destination port with masking. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 121 | SctpDstMasked string = "SCTP_DST_MASKED" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 122 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 123 | /** ICMP type. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 124 | Icmpv4Type string = "ICMPV4_TYPE" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 125 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 126 | /** ICMP code. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 127 | Icmpv4Code string = "ICMPV4_CODE" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 128 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 129 | /** ARP opcode. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 130 | ArpOp string = "ARP_OP" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 131 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 132 | /** ARP source IPv4 address. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 133 | ArpSpa string = "ARP_SPA" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 134 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 135 | /** ARP target IPv4 address. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 136 | ArpTpa string = "ARP_TPA" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 137 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 138 | /** ARP source hardware address. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 139 | ArpTha string = "ARP_THA" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 140 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 141 | /** IPv6 source address. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 142 | Ipv6Src string = "IPV6_SRC" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 143 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 144 | /** IPv6 destination address. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 145 | Ipv6Dst string = "IPV6_DST" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 146 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 147 | /** IPv6 Flow Label. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 148 | Ipv6Flabel string = "IPV6_FLABEL" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 149 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 150 | /** ICMPv6 type. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 151 | Icmpv6Type string = "ICMPV6_TYPE" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 152 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 153 | /** ICMPv6 code. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 154 | Icmpv6Code string = "ICMPV6_CODE" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 155 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 156 | /** Target address for ND. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 157 | Ipv6NdTarget string = "IPV6_ND_TARGET" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 158 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 159 | /** Source link-layer for ND. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 160 | Ipv6NdSll string = "IPV6_ND_SLL" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 161 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 162 | /** Target link-layer for ND. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 163 | Ipv6NdTll string = "IPV6_ND_TLL" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 164 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 165 | /** MPLS label. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 166 | MplsLabel string = "MPLS_LABEL" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 167 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 168 | /** MPLS TC. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 169 | MplsTc string = "MPLS_TC" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 170 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 171 | /** MPLS BoS bit. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 172 | MplsBos string = "MPLS_BOS" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 173 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 174 | /** PBB I-SID. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 175 | PbbIsID string = "PBB_ISID" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 176 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 177 | /** Logical Port Metadata. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 178 | TunnelID string = "TUNNEL_ID" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 179 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 180 | /** IPv6 Extension Header pseudo-field. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 181 | Ipv6Exthdr string = "IPV6_EXTHDR" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 182 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 183 | /** Unassigned value: 40. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 184 | Unassigned40 string = "UNASSIGNED_40" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 185 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 186 | /** PBB UCA header field. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 187 | PbbUca string = "PBB_UCA" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 188 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 189 | /** TCP flags. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 190 | TCPFlags string = "TCP_FLAGS" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 191 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 192 | /** Output port from action set metadata. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 193 | ActsetOutput string = "ACTSET_OUTPUT" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 194 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 195 | /** Packet type value. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 196 | PacketType string = "PACKET_TYPE" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 197 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 198 | // |
| 199 | // NOTE: Everything below is defined elsewhere: ONOS-specific, |
| 200 | // extensions, etc. |
| 201 | // |
| 202 | /** Optical channel signal ID (lambda). */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 203 | OchSigID string = "OCH_SIGID" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 204 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 205 | /** Optical channel signal type (fixed or flexible). */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 206 | OchSigType string = "OCH_SIGTYPE" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 207 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 208 | /** ODU (Optical channel Data Unit) signal ID. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 209 | OduSigID string = "ODU_SIGID" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 210 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 211 | /** ODU (Optical channel Data Unit) signal type. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 212 | OduSigType string = "ODU_SIGTYPE" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 213 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 214 | /** Protocol-independent. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 215 | ProtocolIndependent string = "PROTOCOL_INDEPENDENT" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 216 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 217 | /** Extension criterion. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 218 | Extension string = "EXTENSION" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 219 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 220 | /** An empty criterion. */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 221 | Dummy string = "DUMMY" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 222 | |
| 223 | /* OUTPUT instruction */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 224 | Output string = "OUTPUT" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 225 | |
| 226 | /* METER instruction */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 227 | Meter string = "METER" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 228 | |
| 229 | /* L2MODIFICATION instruction type */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 230 | L2Modification string = "L2MODIFICATION" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 231 | |
| 232 | /* VLAN_PUSH operation */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 233 | VlanPush string = "VLAN_PUSH" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 234 | |
| 235 | /* VLAN_ID instruction */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 236 | VlanID string = "VLAN_ID" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 237 | |
| 238 | /* VLAN_POP operation */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 239 | VlanPop string = "VLAN_POP" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 240 | |
| 241 | /* VLAN_SET operation */ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 242 | VlanSet string = "VLAN_SET" |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 243 | |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 244 | All string = "ALL" |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 245 | |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 246 | Added string = "ADDED" |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 247 | |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 248 | Failed string = "FAILED" |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 249 | |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 250 | FailedAdd string = "FAILED_ADD" |
Akash Soni | 1db5e49 | 2023-03-27 14:14:07 +0530 | [diff] [blame] | 251 | |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 252 | PendingAdd string = "PENDING_ADD" |
Akash Soni | 1db5e49 | 2023-03-27 14:14:07 +0530 | [diff] [blame] | 253 | |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 254 | PendingRemove string = "PENDING_REMOVE" |
Akash Soni | 1db5e49 | 2023-03-27 14:14:07 +0530 | [diff] [blame] | 255 | |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 256 | Pending string = "PENDING" |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 257 | ) |
| 258 | |
| 259 | // Selector Critrtion structs |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 260 | type Criterion interface { |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 261 | GetType() string |
| 262 | } |
| 263 | |
| 264 | type PortSelector struct { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 265 | Type string `json:"type"` |
| 266 | Port int `json:"port,omitempty"` |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | func (s PortSelector) GetType() string { |
| 270 | return s.Type |
| 271 | } |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 272 | |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 273 | type EthTypeSelector struct { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 274 | Type string `json:"type"` |
| 275 | EthType string `json:"ethType,omitempty"` |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 276 | } |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 277 | |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 278 | func (s EthTypeSelector) GetType() string { |
| 279 | return s.Type |
| 280 | } |
| 281 | |
| 282 | type ProtocolSelector struct { |
| 283 | Type string `json:"type"` |
| 284 | Protocol int `json:"protocol,omitempty"` |
| 285 | } |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 286 | |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 287 | func (s ProtocolSelector) GetType() string { |
| 288 | return s.Type |
| 289 | } |
| 290 | |
| 291 | type UDPPortSelector struct { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 292 | Type string `json:"type"` |
| 293 | UDPPort int `json:"udpPort,omitempty"` |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 294 | } |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 295 | |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 296 | func (s UDPPortSelector) GetType() string { |
| 297 | return s.Type |
| 298 | } |
| 299 | |
| 300 | type VlanSelector struct { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 301 | Type string `json:"type"` |
| 302 | VlanID int `json:"vlanId,omitempty"` |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 303 | } |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 304 | |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 305 | func (s VlanSelector) GetType() string { |
| 306 | return s.Type |
| 307 | } |
| 308 | |
| 309 | type EthSrcSelector struct { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 310 | Type string `json:"type"` |
| 311 | EthSrc string `json:"ethsrc,omitempty"` |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | func (s EthSrcSelector) GetType() string { |
| 315 | return s.Type |
| 316 | } |
| 317 | |
| 318 | type EthDstSelector struct { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 319 | Type string `json:"type"` |
| 320 | DstSrc string `json:"ethdst,omitempty"` |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 321 | } |
| 322 | |
| 323 | func (s EthDstSelector) GetType() string { |
| 324 | return s.Type |
| 325 | } |
| 326 | |
| 327 | type MetaDataSelector struct { |
| 328 | Type string `json:"type"` |
| 329 | Metadata uint64 `json:"metadata,omitempty"` |
| 330 | } |
| 331 | |
| 332 | func (s MetaDataSelector) GetType() string { |
| 333 | return s.Type |
| 334 | } |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 335 | |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 336 | ///////// END of selector interfaces |
| 337 | |
| 338 | type SelectorInfo struct { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 339 | Criteria []Criterion `json:"criteria"` |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | // Instruction structs are defined here |
| 343 | type Instruction interface { |
| 344 | GetInstructionType() string |
| 345 | } |
| 346 | |
| 347 | type PortInstruction struct { |
| 348 | Type string `json:"type"` |
| 349 | Port string `json:"port"` |
| 350 | } |
| 351 | |
| 352 | func (i PortInstruction) GetInstructionType() string { |
| 353 | return i.Type |
| 354 | } |
| 355 | |
| 356 | type PushVlanInstruction struct { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 357 | Type string `json:"type"` |
| 358 | SubType string `json:"subtype"` |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 359 | EthernetType string `json:"ethernetType"` |
| 360 | } |
| 361 | |
| 362 | func (i PushVlanInstruction) GetInstructionType() string { |
| 363 | return i.Type |
| 364 | } |
| 365 | |
| 366 | type VlanInstruction struct { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 367 | Type string `json:"type"` |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 368 | SubType string `json:"subtype"` |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 369 | VlanID int `json:"vlanId"` |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | func (i VlanInstruction) GetInstructionType() string { |
| 373 | return i.Type |
| 374 | } |
| 375 | |
| 376 | type PopVlanInstruction struct { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 377 | Type string `json:"type"` |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 378 | SubType string `json:"subtype"` |
| 379 | } |
| 380 | |
| 381 | func (i PopVlanInstruction) GetInstructionType() string { |
| 382 | return i.Type |
| 383 | } |
| 384 | |
| 385 | type MeterInstruction struct { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 386 | Type string `json:"type"` |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 387 | MeterID string `json:"meterId"` |
| 388 | } |
| 389 | |
| 390 | func (i MeterInstruction) GetInstructionType() string { |
| 391 | return i.Type |
| 392 | } |
| 393 | |
| 394 | type TreatmentInfo struct { |
| 395 | Instructions []Instruction `json:"instructions"` |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 396 | Deferred []interface{} `json:"deferred"` |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 397 | } |
| 398 | type Flow struct { |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 399 | State string `json:"state"` |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 400 | LiveType string `json:"liveType"` |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 401 | ID string `json:"id"` |
| 402 | AppID string `json:"appId"` |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 403 | DeviceID string `json:"deviceId"` |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 404 | TableName string `json:"tableName"` |
| 405 | Treatment TreatmentInfo `json:"treatment"` |
| 406 | Selector SelectorInfo `json:"selector"` |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 407 | LastSeen int64 `json:"lastSeen"` |
| 408 | TableID int `json:"tableId"` |
| 409 | Priority int `json:"priority"` |
| 410 | Timeout int `json:"timeout"` |
| 411 | GroupID int `json:"groupId"` |
| 412 | Life int `json:"life"` |
| 413 | Packets int `json:"packets"` |
| 414 | Bytes int `json:"bytes"` |
| 415 | IsPermanent bool `json:"isPermanent"` |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | type FlowEntry struct { |
| 419 | Flows []Flow `json:"flows"` |
| 420 | } |
| 421 | |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 422 | // Meter struct |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 423 | type Meters struct { |
| 424 | ID string `json:"id"` |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 425 | Unit string `json:"unit"` |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 426 | DeviceID string `json:"deviceId"` |
| 427 | AppID string `json:"appId"` |
| 428 | State string `json:"state"` |
| 429 | MeterBands []Bands `json:"bands"` |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 430 | Life int `json:"life"` |
| 431 | Packets int `json:"packets"` |
| 432 | Bytes int `json:"bytes"` |
| 433 | ReferenceCount int `json:"referenceCount"` |
| 434 | Burst bool `json:"burst"` |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 435 | } |
| 436 | |
| 437 | type Bands struct { |
| 438 | Type string `json:"type"` |
| 439 | Rate int `json:"rate"` |
| 440 | Packets int `json:"packets"` |
| 441 | Bytes int `json:"bytes"` |
| 442 | BurstSize int `json:"burstSize"` |
| 443 | Prec int `json:"prec,omitempty"` |
| 444 | } |
| 445 | |
| 446 | type GroupsInfo struct { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 447 | Type string `json:"type"` |
| 448 | DeviceID string `json:"deviceId"` |
| 449 | AppID string `json:"appId"` |
| 450 | AppCookie string `json:"appCookie"` |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 451 | State string `json:"state"` |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 452 | Buckets []Bucket `json:"buckets"` |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 453 | ID int `json:"id"` |
| 454 | Life int `json:"life"` |
| 455 | Packets int `json:"packets"` |
| 456 | Bytes int `json:"bytes"` |
| 457 | ReferenceCount int `json:"referenceCount"` |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 458 | } |
| 459 | |
| 460 | type Bucket struct { |
| 461 | Type string `json:"type"` |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 462 | Treatment Treatment `json:"treatment"` |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 463 | Weight int `json:"weight"` |
| 464 | Packets int `json:"packets"` |
| 465 | Bytes int `json:"bytes"` |
| 466 | BucketID int `json:"bucketId"` |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 467 | } |
| 468 | |
| 469 | type Treatment struct { |
| 470 | Instructions []Instructions `json:"instructions"` |
| 471 | Deferred []interface{} `json:"deferred"` |
| 472 | } |
| 473 | |
| 474 | type Instructions struct { |
| 475 | Type string `json:"type"` |
| 476 | Port string `json:"port"` |
| 477 | } |
| 478 | |
| 479 | type MeterList struct { |
| 480 | Meters []Meters `json:"meters"` |
| 481 | } |
| 482 | |
| 483 | type GroupList struct { |
| 484 | Groups []*GroupsInfo `json:"groups"` |
| 485 | } |
| 486 | |
| 487 | type SubscribersList struct { |
| 488 | Subscribers []SubscriberInfo `json:"subscribers"` |
| 489 | } |
| 490 | |
Akash Soni | 87a1907 | 2023-02-28 00:46:59 +0530 | [diff] [blame] | 491 | type OltFlowServiceConfig struct { |
| 492 | OltFlowService app.OltFlowService `json:"oltFlowService"` |
| 493 | } |
| 494 | |
| 495 | type DeviceConfigPayload struct { |
| 496 | DeviceConfig *app.DeviceConfig `json:"deviceConfig"` |
| 497 | } |
| 498 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 499 | func ConvertFlowToFlowEntry(subFlow *of.VoltSubFlow) FlowEntry { |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 500 | var flowEntry FlowEntry |
Tinoj Joseph | 429b9d9 | 2022-11-16 18:51:05 +0530 | [diff] [blame] | 501 | flowEntry.Flows = []Flow{} |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 502 | flow := ConvertVoltSubFlowToOnosFlow(subFlow) |
| 503 | flowEntry.Flows = append(flowEntry.Flows, flow) |
| 504 | return flowEntry |
| 505 | } |
| 506 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 507 | func ConvertFlowsToFlowEntry(subFlows []*of.VoltSubFlow) FlowEntry { |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 508 | var flowEntry FlowEntry |
Tinoj Joseph | 429b9d9 | 2022-11-16 18:51:05 +0530 | [diff] [blame] | 509 | flowEntry.Flows = []Flow{} |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 510 | for _, subFlow := range subFlows { |
| 511 | flow := ConvertVoltSubFlowToOnosFlow(subFlow) |
| 512 | flowEntry.Flows = append(flowEntry.Flows, flow) |
| 513 | } |
| 514 | return flowEntry |
| 515 | } |
| 516 | |
Akash Soni | 1db5e49 | 2023-03-27 14:14:07 +0530 | [diff] [blame] | 517 | func FlowStateMapping(state uint8) string { |
| 518 | var flowState string |
| 519 | if state == of.FlowAddSuccess { |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 520 | flowState = Added |
Akash Soni | 1db5e49 | 2023-03-27 14:14:07 +0530 | [diff] [blame] | 521 | } else if state == of.FlowAddFailure { |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 522 | flowState = FailedAdd |
Akash Soni | 1db5e49 | 2023-03-27 14:14:07 +0530 | [diff] [blame] | 523 | } else if state == of.FlowAddPending { |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 524 | flowState = PendingAdd |
Akash Soni | 1db5e49 | 2023-03-27 14:14:07 +0530 | [diff] [blame] | 525 | } else if state == of.FlowDelPending { |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 526 | flowState = PendingRemove |
Akash Soni | 1db5e49 | 2023-03-27 14:14:07 +0530 | [diff] [blame] | 527 | } |
| 528 | return flowState |
| 529 | } |
| 530 | |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 531 | func ConvertVoltSubFlowToOnosFlow(subFlow *of.VoltSubFlow) Flow { |
| 532 | var flow Flow |
| 533 | flow.ID = strconv.FormatUint(subFlow.Cookie, 10) |
| 534 | flow.TableID = int(subFlow.TableID) |
| 535 | flow.Priority = int(subFlow.Priority) |
Akash Soni | 1db5e49 | 2023-03-27 14:14:07 +0530 | [diff] [blame] | 536 | state := FlowStateMapping(subFlow.State) |
| 537 | flow.State = state |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 538 | // Fill Match criteria |
| 539 | if subFlow.InPort != 0 { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 540 | portSelector := PortSelector{ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 541 | Type: InPort, |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 542 | Port: int(subFlow.InPort), |
| 543 | } |
| 544 | flow.Selector.Criteria = append(flow.Selector.Criteria, Criterion(portSelector)) |
| 545 | } |
| 546 | if subFlow.MatchVlan != of.VlanNone { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 547 | vlanSelector := VlanSelector{ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 548 | Type: VlanVID, |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 549 | VlanID: int(subFlow.MatchVlan), |
| 550 | } |
| 551 | flow.Selector.Criteria = append(flow.Selector.Criteria, Criterion(vlanSelector)) |
| 552 | } |
| 553 | if subFlow.SrcMacMatch { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 554 | ethSrcSelector := EthSrcSelector{ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 555 | Type: EthSrc, |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 556 | EthSrc: subFlow.SrcMacAddr.String(), |
| 557 | } |
| 558 | flow.Selector.Criteria = append(flow.Selector.Criteria, Criterion(ethSrcSelector)) |
| 559 | } |
| 560 | if subFlow.DstMacMatch { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 561 | ethDstSelector := EthDstSelector{ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 562 | Type: EthDst, |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 563 | DstSrc: subFlow.DstMacAddr.String(), |
| 564 | } |
| 565 | flow.Selector.Criteria = append(flow.Selector.Criteria, Criterion(ethDstSelector)) |
| 566 | } |
| 567 | if subFlow.L3Protocol != of.EtherTypeAny { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 568 | ethTypeSelector := EthTypeSelector{ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 569 | Type: EthType, |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 570 | EthType: strconv.FormatUint(uint64(subFlow.L3Protocol), 16), |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 571 | } |
| 572 | flow.Selector.Criteria = append(flow.Selector.Criteria, Criterion(ethTypeSelector)) |
| 573 | } |
| 574 | if subFlow.L4Protocol != of.IPProtocolIgnore { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 575 | protocolSelector := ProtocolSelector{ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 576 | Type: IPProto, |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 577 | Protocol: int(subFlow.L4Protocol), |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 578 | } |
| 579 | flow.Selector.Criteria = append(flow.Selector.Criteria, Criterion(protocolSelector)) |
| 580 | } |
| 581 | if subFlow.SrcPort != 0 { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 582 | udpPortSelector := UDPPortSelector{ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 583 | Type: UDPSrc, |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 584 | UDPPort: int(subFlow.SrcPort), |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 585 | } |
| 586 | flow.Selector.Criteria = append(flow.Selector.Criteria, Criterion(udpPortSelector)) |
| 587 | } |
| 588 | if subFlow.DstPort != 0 { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 589 | udpPortSelector := UDPPortSelector{ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 590 | Type: UDPDst, |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 591 | UDPPort: int(subFlow.DstPort), |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 592 | } |
| 593 | flow.Selector.Criteria = append(flow.Selector.Criteria, Criterion(udpPortSelector)) |
| 594 | } |
| 595 | if subFlow.TableMetadata != 0 { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 596 | metaDataSelector := MetaDataSelector{ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 597 | Type: MetaData, |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 598 | Metadata: subFlow.TableMetadata, |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 599 | } |
| 600 | flow.Selector.Criteria = append(flow.Selector.Criteria, Criterion(metaDataSelector)) |
| 601 | } |
| 602 | |
| 603 | // Fill actions |
| 604 | if subFlow.Output != 0 { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 605 | portInstruction := PortInstruction{ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 606 | Type: Output, |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 607 | } |
| 608 | switch subFlow.Output { |
| 609 | case of.OutputTypeToController: |
| 610 | portInstruction.Port = "CONTROLLER" |
| 611 | case of.OutputTypeToNetwork: |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 612 | portInstruction.Port = strconv.FormatUint(uint64(subFlow.OutPort), 10) |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 613 | case of.OutputTypeGoToTable: |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 614 | portInstruction.Port = strconv.FormatUint(uint64(subFlow.GoToTableID), 10) |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 615 | } |
| 616 | flow.Treatment.Instructions = append(flow.Treatment.Instructions, Instruction(portInstruction)) |
| 617 | } |
| 618 | if len(subFlow.PushVlan) != 0 { |
| 619 | for _, vlan := range subFlow.PushVlan { |
| 620 | if vlan == of.VlanNone { |
| 621 | continue |
| 622 | } |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 623 | pushVlanInstruction := PushVlanInstruction{ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 624 | Type: L2Modification, |
| 625 | SubType: VlanPush, |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 626 | EthernetType: "0x8100", |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 627 | } |
| 628 | flow.Treatment.Instructions = append(flow.Treatment.Instructions, Instruction(pushVlanInstruction)) |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 629 | vlanInstruction := VlanInstruction{ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 630 | Type: L2Modification, |
| 631 | SubType: VlanID, |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 632 | VlanID: int(vlan), |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 633 | } |
| 634 | flow.Treatment.Instructions = append(flow.Treatment.Instructions, Instruction(vlanInstruction)) |
| 635 | } |
| 636 | } |
| 637 | if subFlow.SetVlan != of.VlanNone { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 638 | vlanInstruction := VlanInstruction{ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 639 | Type: L2Modification, |
| 640 | SubType: VlanSet, |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 641 | VlanID: int(subFlow.SetVlan), |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 642 | } |
| 643 | flow.Treatment.Instructions = append(flow.Treatment.Instructions, Instruction(vlanInstruction)) |
| 644 | } |
| 645 | if subFlow.RemoveVlan != 0 { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 646 | popVlanInstruction := PopVlanInstruction{ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 647 | Type: L2Modification, |
| 648 | SubType: VlanPop, |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 649 | } |
| 650 | flow.Treatment.Instructions = append(flow.Treatment.Instructions, Instruction(popVlanInstruction)) |
| 651 | } |
| 652 | if subFlow.MeterID != 0 { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 653 | meterInstruction := MeterInstruction{ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 654 | Type: Meter, |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 655 | MeterID: strconv.FormatUint(uint64(subFlow.MeterID), 10), |
| 656 | } |
| 657 | flow.Treatment.Instructions = append(flow.Treatment.Instructions, Instruction(meterInstruction)) |
| 658 | } |
| 659 | return flow |
| 660 | } |
| 661 | |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 662 | func convertServiceToSubscriberInfo(svcs []*app.VoltService) []SubscriberInfo { |
| 663 | subs := []SubscriberInfo{} |
| 664 | for _, vs := range svcs { |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 665 | pbit := vs.GetServicePbit() |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 666 | sub := SubscriberInfo{ |
| 667 | Location: vs.Device, |
| 668 | TagInfo: UniTagInformation{ |
| 669 | UniTagMatch: int(vs.UniVlan), |
| 670 | PonCTag: int(vs.CVlan), |
| 671 | PonSTag: int(vs.SVlan), |
| 672 | UsPonCTagPriority: pbit, |
| 673 | UsPonSTagPriority: pbit, |
| 674 | DsPonCTagPriority: pbit, |
| 675 | DsPonSTagPriority: pbit, |
| 676 | TechnologyProfileID: int(vs.TechProfileID), |
| 677 | UpstreamBandwidthProfile: vs.UsMeterProfile, |
| 678 | DownstreamBandwidthProfile: vs.DsMeterProfile, |
| 679 | UpstreamOltBandwidthProfile: vs.UsMeterProfile, |
| 680 | DownstreamOltBandwidthProfile: vs.DsMeterProfile, |
Sridhar Ravindra | b8374ae | 2023-04-14 15:49:25 +0530 | [diff] [blame] | 681 | ServiceName: vs.ServiceType, |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 682 | EnableMacLearning: vs.MacLearning == app.Learn, |
| 683 | ConfiguredMacAddress: vs.MacAddr.String(), |
| 684 | IsDhcpRequired: vs.MacLearning == app.Learn, |
| 685 | IsIgmpRequired: vs.IgmpEnabled, |
| 686 | IsPppoeRequired: false, |
| 687 | }, |
| 688 | } |
| 689 | subs = append(subs, sub) |
| 690 | } |
| 691 | return subs |
Tinoj Joseph | ec742f6 | 2022-09-29 19:11:10 +0530 | [diff] [blame] | 692 | } |
| 693 | |
Tinoj Joseph | 429b9d9 | 2022-11-16 18:51:05 +0530 | [diff] [blame] | 694 | type DeviceEntry struct { |
| 695 | Devices []Device `json:"devices"` |
| 696 | } |
| 697 | |
| 698 | type Device struct { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 699 | ID string `json:"id"` |
| 700 | Type string `json:"type"` |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 701 | Role string `json:"role"` |
| 702 | Mfr string `json:"mfr"` |
| 703 | Hw string `json:"hw"` |
| 704 | Sw string `json:"sw"` |
| 705 | Serial string `json:"serial"` |
| 706 | Driver string `json:"driver"` |
| 707 | ChassisID string `json:"chassisId"` |
| 708 | LastUpdate string `json:"lastUpdate"` |
| 709 | HumanReadableLastUpdate string `json:"humanReadableLastUpdate"` |
Tinoj Joseph | 429b9d9 | 2022-11-16 18:51:05 +0530 | [diff] [blame] | 710 | Annotations DeviceAnnotations `json:"annotations"` |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 711 | Available bool `json:"available"` |
Tinoj Joseph | 429b9d9 | 2022-11-16 18:51:05 +0530 | [diff] [blame] | 712 | } |
| 713 | type DeviceAnnotations struct { |
| 714 | ChannelID string `json:"channelId"` |
| 715 | ManagementAddress string `json:"managementAddress"` |
| 716 | Protocol string `json:"protocol"` |
| 717 | } |
| 718 | |
| 719 | func convertVoltDeviceToDevice(voltDevice *app.VoltDevice) Device { |
| 720 | var device Device |
| 721 | |
| 722 | d, err := controller.GetController().GetDevice(voltDevice.Name) |
| 723 | if err != nil { |
| 724 | device.ID = voltDevice.Name |
| 725 | return device |
| 726 | } |
| 727 | device.ID = d.ID |
| 728 | if d.State == controller.DeviceStateUP { |
| 729 | device.Available = true |
| 730 | } else { |
| 731 | device.Available = false |
| 732 | } |
| 733 | device.Serial = d.SerialNum |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 734 | device.Mfr = d.MfrDesc |
| 735 | device.Hw = d.HwDesc |
| 736 | device.Sw = d.SwDesc |
Tinoj Joseph | 429b9d9 | 2022-11-16 18:51:05 +0530 | [diff] [blame] | 737 | device.LastUpdate = d.TimeStamp.String() |
| 738 | device.HumanReadableLastUpdate = d.TimeStamp.String() |
| 739 | return device |
| 740 | } |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 741 | |
Tinoj Joseph | 429b9d9 | 2022-11-16 18:51:05 +0530 | [diff] [blame] | 742 | type PortEntry struct { |
| 743 | Ports []Port `json:"ports"` |
| 744 | } |
| 745 | |
Akash Soni | 1db5e49 | 2023-03-27 14:14:07 +0530 | [diff] [blame] | 746 | type DevicePortEntry struct { |
| 747 | Device Device `json:"device"` |
| 748 | Ports []Port `json:"ports"` |
| 749 | } |
| 750 | |
Tinoj Joseph | 429b9d9 | 2022-11-16 18:51:05 +0530 | [diff] [blame] | 751 | type Port struct { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 752 | Element string `json:"element"` |
| 753 | Port string `json:"port"` |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 754 | Type string `json:"type"` |
Tinoj Joseph | 429b9d9 | 2022-11-16 18:51:05 +0530 | [diff] [blame] | 755 | Annotations PortAnnotations `json:"annotations"` |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 756 | PortSpeed int `json:"portSpeed"` |
| 757 | IsEnabled bool `json:"isEnabled"` |
Tinoj Joseph | 429b9d9 | 2022-11-16 18:51:05 +0530 | [diff] [blame] | 758 | } |
| 759 | type PortAnnotations struct { |
| 760 | AdminState string `json:"adminState"` |
| 761 | PortMac string `json:"portMac"` |
| 762 | PortName string `json:"portName"` |
| 763 | } |
| 764 | |
| 765 | func convertVoltPortToPort(voltPort *app.VoltPort) Port { |
| 766 | var port Port |
| 767 | port.Port = strconv.Itoa(int(voltPort.ID)) |
| 768 | port.Element = voltPort.Device |
| 769 | if voltPort.State == app.PortStateUp { |
| 770 | port.IsEnabled = true |
| 771 | } else { |
| 772 | port.IsEnabled = false |
| 773 | } |
| 774 | if voltPort.Type == app.VoltPortTypeNni { |
| 775 | port.Type = "fiber" |
| 776 | } else { |
| 777 | port.Type = "copper" |
| 778 | } |
| 779 | port.Annotations.AdminState = "enabled" |
| 780 | port.Annotations.PortName = voltPort.Name |
| 781 | |
| 782 | device, err := controller.GetController().GetDevice(voltPort.Device) |
| 783 | if err != nil { |
| 784 | return port |
| 785 | } |
| 786 | |
| 787 | devicePort := device.GetPortByName(voltPort.Name) |
| 788 | if devicePort != nil { |
| 789 | port.PortSpeed = int(devicePort.MaxSpeed) |
| 790 | port.Annotations.PortMac = devicePort.HwAddr |
| 791 | } |
| 792 | return port |
| 793 | } |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 794 | func (gh *GroupsHandle) convertGroupsToOnosGroup(groupsInfo *of.Group) *GroupsInfo { |
Hitesh Chhabra | af80b83 | 2023-07-21 15:27:20 +0530 | [diff] [blame] | 795 | logger.Debug(ctx, "Entering into convertGroupsToOnosGroup") |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 796 | var groups *GroupsInfo |
| 797 | var bucket []Bucket |
| 798 | Instruction := []Instructions{} |
| 799 | if groupsInfo != nil { |
| 800 | for _, buckets := range groupsInfo.Buckets { |
| 801 | inst := Instructions{ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 802 | Type: All, |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 803 | Port: fmt.Sprint(buckets), |
| 804 | } |
| 805 | Instruction = append(Instruction, inst) |
| 806 | trtmt := Treatment{ |
| 807 | Instructions: Instruction, |
| 808 | } |
| 809 | bkt := Bucket{ |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 810 | Type: All, |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 811 | Treatment: trtmt, |
| 812 | } |
| 813 | bucket = append(bucket, bkt) |
| 814 | } |
| 815 | if groupsInfo.State == of.GroupOperSuccess { |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 816 | groups.State = Added |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 817 | } else if groupsInfo.State == of.GroupOperFailure { |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 818 | groups.State = Failed |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 819 | } else if groupsInfo.State == of.GroupOperPending { |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 820 | groups.State = Pending |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 821 | } |
| 822 | groups = &GroupsInfo{ |
| 823 | DeviceID: groupsInfo.Device, |
| 824 | ID: int(groupsInfo.GroupID), |
| 825 | State: groups.State, |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 826 | Type: All, |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 827 | Buckets: bucket, |
| 828 | } |
| 829 | } |
| 830 | return groups |
| 831 | } |
| 832 | |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 833 | func (mh *MetersHandle) MeterObjectMapping(meterInfo *of.Meter, deviceID string) Meters { |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 834 | var meter Meters |
| 835 | var bd []Bands |
| 836 | for _, band := range meterInfo.Bands { |
| 837 | bnd := Bands{ |
| 838 | Type: fmt.Sprint(band.Type), |
| 839 | Rate: int(band.Rate), |
| 840 | BurstSize: int(band.BurstSize), |
| 841 | } |
| 842 | bd = append(bd, bnd) |
| 843 | } |
| 844 | if meterInfo.State == of.MeterOperSuccess { |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 845 | meter.State = Added |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 846 | } else if meterInfo.State == of.MeterOperFailure { |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 847 | meter.State = Failed |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 848 | } else if meterInfo.State == of.MeterOperPending { |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 849 | meter.State = Pending |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 850 | } |
| 851 | meter = Meters{ |
| 852 | ID: fmt.Sprint(meterInfo.ID), |
| 853 | State: meter.State, |
vinokuma | 926cb3e | 2023-03-29 11:41:06 +0530 | [diff] [blame] | 854 | DeviceID: deviceID, |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 855 | MeterBands: bd, |
| 856 | } |
| 857 | return meter |
Akash Soni | b3abf52 | 2022-12-19 13:20:02 +0530 | [diff] [blame] | 858 | } |