Matteo Scandolo | aa2adde | 2021-09-13 12:45:32 -0700 | [diff] [blame] | 1 | /* |
Joey Armstrong | 7f6d6d2 | 2023-01-09 17:09:50 -0500 | [diff] [blame] | 2 | * Copyright 2021-2023 Open Networking Foundation (ONF) and the ONF Contributors |
Matteo Scandolo | aa2adde | 2021-09-13 12:45:32 -0700 | [diff] [blame] | 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 | |
Gustavo Silva | 29fb20e | 2022-05-26 09:59:54 -0300 | [diff] [blame] | 17 | package org.opencord.olt; |
Matteo Scandolo | aa2adde | 2021-09-13 12:45:32 -0700 | [diff] [blame] | 18 | |
| 19 | import java.util.Objects; |
| 20 | |
| 21 | /** |
| 22 | * OltPortStatus is used to keep track of the flow status for a subscriber service. |
| 23 | */ |
| 24 | public class OltPortStatus { |
| 25 | // TODO consider adding a lastUpdated field, it may help with debugging |
Gustavo Silva | 29fb20e | 2022-05-26 09:59:54 -0300 | [diff] [blame] | 26 | public OltFlowsStatus defaultEapolStatus; |
| 27 | public OltFlowsStatus subscriberEapolStatus; |
| 28 | public OltFlowsStatus subscriberFlowsStatus; |
Matteo Scandolo | aa2adde | 2021-09-13 12:45:32 -0700 | [diff] [blame] | 29 | // NOTE we need to keep track of the DHCP status as that is installed before the other flows |
| 30 | // if macLearning is enabled (DHCP is needed to learn the MacAddress from the host) |
Gustavo Silva | 29fb20e | 2022-05-26 09:59:54 -0300 | [diff] [blame] | 31 | public OltFlowsStatus dhcpStatus; |
| 32 | public OltFlowsStatus pppoeStatus; |
Matteo Scandolo | aa2adde | 2021-09-13 12:45:32 -0700 | [diff] [blame] | 33 | |
Gustavo Silva | 29fb20e | 2022-05-26 09:59:54 -0300 | [diff] [blame] | 34 | /** |
| 35 | * Creates a OltPortStatus from a group of OltFlowsStatus. |
| 36 | * |
| 37 | * @param defaultEapolStatus the default |
| 38 | * @param subscriberEapolStatus the status |
| 39 | * @param subscriberFlowsStatus the bandwidth profile |
| 40 | * @param dhcpStatus the bandwidth profile |
| 41 | * @param pppoeStatus the bandwidth profile |
| 42 | */ |
| 43 | public OltPortStatus(OltFlowsStatus defaultEapolStatus, |
| 44 | OltFlowsStatus subscriberEapolStatus, |
| 45 | OltFlowsStatus subscriberFlowsStatus, |
| 46 | OltFlowsStatus dhcpStatus, |
| 47 | OltFlowsStatus pppoeStatus) { |
Matteo Scandolo | aa2adde | 2021-09-13 12:45:32 -0700 | [diff] [blame] | 48 | this.defaultEapolStatus = defaultEapolStatus; |
Andrea Campanella | 87241ae | 2022-03-11 11:20:24 +0100 | [diff] [blame] | 49 | this.subscriberEapolStatus = subscriberEapolStatus; |
Matteo Scandolo | aa2adde | 2021-09-13 12:45:32 -0700 | [diff] [blame] | 50 | this.subscriberFlowsStatus = subscriberFlowsStatus; |
| 51 | this.dhcpStatus = dhcpStatus; |
yasin sapli | 0823c93 | 2022-01-26 11:26:09 +0000 | [diff] [blame] | 52 | this.pppoeStatus = pppoeStatus; |
Matteo Scandolo | aa2adde | 2021-09-13 12:45:32 -0700 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | @Override |
| 56 | public boolean equals(Object o) { |
| 57 | if (this == o) { |
| 58 | return true; |
| 59 | } |
| 60 | if (o == null || getClass() != o.getClass()) { |
| 61 | return false; |
| 62 | } |
| 63 | OltPortStatus that = (OltPortStatus) o; |
| 64 | return defaultEapolStatus == that.defaultEapolStatus |
Andrea Campanella | 87241ae | 2022-03-11 11:20:24 +0100 | [diff] [blame] | 65 | && subscriberEapolStatus == that.subscriberEapolStatus |
Matteo Scandolo | aa2adde | 2021-09-13 12:45:32 -0700 | [diff] [blame] | 66 | && subscriberFlowsStatus == that.subscriberFlowsStatus |
| 67 | && dhcpStatus == that.dhcpStatus; |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public int hashCode() { |
Andrea Campanella | 87241ae | 2022-03-11 11:20:24 +0100 | [diff] [blame] | 72 | return Objects.hash(defaultEapolStatus, subscriberEapolStatus, |
| 73 | subscriberFlowsStatus, dhcpStatus); |
Matteo Scandolo | aa2adde | 2021-09-13 12:45:32 -0700 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | @Override |
| 77 | public String toString() { |
| 78 | final StringBuilder sb = new StringBuilder("OltPortStatus{"); |
| 79 | sb.append("defaultEapolStatus=").append(defaultEapolStatus); |
Andrea Campanella | 87241ae | 2022-03-11 11:20:24 +0100 | [diff] [blame] | 80 | sb.append(", subscriberEapolStatus=").append(subscriberEapolStatus); |
Matteo Scandolo | aa2adde | 2021-09-13 12:45:32 -0700 | [diff] [blame] | 81 | sb.append(", subscriberFlowsStatus=").append(subscriberFlowsStatus); |
| 82 | sb.append(", dhcpStatus=").append(dhcpStatus); |
| 83 | sb.append('}'); |
| 84 | return sb.toString(); |
| 85 | } |
| 86 | } |