blob: 6c2c9084ad40a18b2a8d110567cdc77d45b0ea8d [file] [log] [blame]
Matteo Scandoloaa2adde2021-09-13 12:45:32 -07001/*
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
Gustavo Silva29fb20e2022-05-26 09:59:54 -030017package org.opencord.olt;
Matteo Scandoloaa2adde2021-09-13 12:45:32 -070018
19import java.util.Objects;
20
21/**
22 * OltPortStatus is used to keep track of the flow status for a subscriber service.
23 */
24public class OltPortStatus {
25 // TODO consider adding a lastUpdated field, it may help with debugging
Gustavo Silva29fb20e2022-05-26 09:59:54 -030026 public OltFlowsStatus defaultEapolStatus;
27 public OltFlowsStatus subscriberEapolStatus;
28 public OltFlowsStatus subscriberFlowsStatus;
Matteo Scandoloaa2adde2021-09-13 12:45:32 -070029 // 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 Silva29fb20e2022-05-26 09:59:54 -030031 public OltFlowsStatus dhcpStatus;
32 public OltFlowsStatus pppoeStatus;
Matteo Scandoloaa2adde2021-09-13 12:45:32 -070033
Gustavo Silva29fb20e2022-05-26 09:59:54 -030034 /**
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 Scandoloaa2adde2021-09-13 12:45:32 -070048 this.defaultEapolStatus = defaultEapolStatus;
Andrea Campanella87241ae2022-03-11 11:20:24 +010049 this.subscriberEapolStatus = subscriberEapolStatus;
Matteo Scandoloaa2adde2021-09-13 12:45:32 -070050 this.subscriberFlowsStatus = subscriberFlowsStatus;
51 this.dhcpStatus = dhcpStatus;
yasin sapli0823c932022-01-26 11:26:09 +000052 this.pppoeStatus = pppoeStatus;
Matteo Scandoloaa2adde2021-09-13 12:45:32 -070053 }
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 Campanella87241ae2022-03-11 11:20:24 +010065 && subscriberEapolStatus == that.subscriberEapolStatus
Matteo Scandoloaa2adde2021-09-13 12:45:32 -070066 && subscriberFlowsStatus == that.subscriberFlowsStatus
67 && dhcpStatus == that.dhcpStatus;
68 }
69
70 @Override
71 public int hashCode() {
Andrea Campanella87241ae2022-03-11 11:20:24 +010072 return Objects.hash(defaultEapolStatus, subscriberEapolStatus,
73 subscriberFlowsStatus, dhcpStatus);
Matteo Scandoloaa2adde2021-09-13 12:45:32 -070074 }
75
76 @Override
77 public String toString() {
78 final StringBuilder sb = new StringBuilder("OltPortStatus{");
79 sb.append("defaultEapolStatus=").append(defaultEapolStatus);
Andrea Campanella87241ae2022-03-11 11:20:24 +010080 sb.append(", subscriberEapolStatus=").append(subscriberEapolStatus);
Matteo Scandoloaa2adde2021-09-13 12:45:32 -070081 sb.append(", subscriberFlowsStatus=").append(subscriberFlowsStatus);
82 sb.append(", dhcpStatus=").append(dhcpStatus);
83 sb.append('}');
84 return sb.toString();
85 }
86}