Matteo Scandolo | aa2adde | 2021-09-13 12:45:32 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2021-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 | |
| 17 | package org.opencord.olt.impl; |
| 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 |
| 26 | public OltFlowService.OltFlowsStatus defaultEapolStatus; |
| 27 | public OltFlowService.OltFlowsStatus subscriberFlowsStatus; |
| 28 | // NOTE we need to keep track of the DHCP status as that is installed before the other flows |
| 29 | // if macLearning is enabled (DHCP is needed to learn the MacAddress from the host) |
| 30 | public OltFlowService.OltFlowsStatus dhcpStatus; |
| 31 | |
| 32 | public OltPortStatus(OltFlowService.OltFlowsStatus defaultEapolStatus, |
| 33 | OltFlowService.OltFlowsStatus subscriberFlowsStatus, |
| 34 | OltFlowService.OltFlowsStatus dhcpStatus) { |
| 35 | this.defaultEapolStatus = defaultEapolStatus; |
| 36 | this.subscriberFlowsStatus = subscriberFlowsStatus; |
| 37 | this.dhcpStatus = dhcpStatus; |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public boolean equals(Object o) { |
| 42 | if (this == o) { |
| 43 | return true; |
| 44 | } |
| 45 | if (o == null || getClass() != o.getClass()) { |
| 46 | return false; |
| 47 | } |
| 48 | OltPortStatus that = (OltPortStatus) o; |
| 49 | return defaultEapolStatus == that.defaultEapolStatus |
| 50 | && subscriberFlowsStatus == that.subscriberFlowsStatus |
| 51 | && dhcpStatus == that.dhcpStatus; |
| 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public int hashCode() { |
| 56 | return Objects.hash(defaultEapolStatus, subscriberFlowsStatus, dhcpStatus); |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public String toString() { |
| 61 | final StringBuilder sb = new StringBuilder("OltPortStatus{"); |
| 62 | sb.append("defaultEapolStatus=").append(defaultEapolStatus); |
| 63 | sb.append(", subscriberFlowsStatus=").append(subscriberFlowsStatus); |
| 64 | sb.append(", dhcpStatus=").append(dhcpStatus); |
| 65 | sb.append('}'); |
| 66 | return sb.toString(); |
| 67 | } |
| 68 | } |