blob: a1436818e077547ce9e453152adf1a95325ad224 [file] [log] [blame]
Jonathan Hartc36c9552018-07-31 15:07:53 -04001/*
2 * Copyright 2018-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
17package org.opencord.dhcpl2relay;
18
19import org.onosproject.event.AbstractEvent;
20import org.onosproject.net.ConnectPoint;
21
Marcos Aurelio Carreroeaf02b82019-11-25 13:34:25 -030022import java.util.Map;
23import java.util.concurrent.atomic.AtomicLong;
24
Jonathan Hartc36c9552018-07-31 15:07:53 -040025/**
26 * Dhcp L2 relay event.
27 */
28public class DhcpL2RelayEvent extends AbstractEvent<DhcpL2RelayEvent.Type, DhcpAllocationInfo> {
29
Marcos Aurelio Carreroeaf02b82019-11-25 13:34:25 -030030 public static final String GLOBAL_COUNTER = "global";
31
Jonathan Hartc36c9552018-07-31 15:07:53 -040032 private final ConnectPoint connectPoint;
33
Marcos Aurelio Carreroeaf02b82019-11-25 13:34:25 -030034 private final Map.Entry<String, AtomicLong> countersEntry;
35
Marcos Aurelio Carreroeaf02b82019-11-25 13:34:25 -030036 private final String subscriberId;
37
Jonathan Hartc36c9552018-07-31 15:07:53 -040038 /**
39 * Type of the event.
40 */
41 public enum Type {
42 /**
43 * DHCP lease was updated.
44 */
45 UPDATED,
46
47 /**
48 * DHCP lease was removed.
49 */
Marcos Aurelio Carreroeaf02b82019-11-25 13:34:25 -030050 REMOVED,
51
52 /**
53 * DHCP stats update.
54 */
55 STATS_UPDATE
56 }
57
58 /**
59 * Creates a new event used for STATS.
60 *
61 * @param type type of the event
62 * @param allocationInfo DHCP allocation info
63 * @param connectPoint connect point the client is on
64 * @param countersEntry an entry that represents the counters (used for STATS events)
Marcos Aurelio Carreroeaf02b82019-11-25 13:34:25 -030065 * @param subscriberId the subscriber identifier information
66 */
67 public DhcpL2RelayEvent(Type type, DhcpAllocationInfo allocationInfo, ConnectPoint connectPoint,
Jonathan Hart77ca3152020-02-21 14:31:21 -080068 Map.Entry<String, AtomicLong> countersEntry, String subscriberId) {
Marcos Aurelio Carreroeaf02b82019-11-25 13:34:25 -030069 super(type, allocationInfo);
70 this.connectPoint = connectPoint;
71 this.countersEntry = countersEntry;
Marcos Aurelio Carreroeaf02b82019-11-25 13:34:25 -030072 this.subscriberId = subscriberId;
Jonathan Hartc36c9552018-07-31 15:07:53 -040073 }
74
75 /**
76 * Creates a new event.
77 *
78 * @param type type of the event
79 * @param allocationInfo DHCP allocation info
80 * @param connectPoint connect point the client is on
81 */
82 public DhcpL2RelayEvent(Type type, DhcpAllocationInfo allocationInfo, ConnectPoint connectPoint) {
83 super(type, allocationInfo);
84 this.connectPoint = connectPoint;
Marcos Aurelio Carreroeaf02b82019-11-25 13:34:25 -030085 this.countersEntry = null;
Marcos Aurelio Carreroeaf02b82019-11-25 13:34:25 -030086 this.subscriberId = null;
Jonathan Hartc36c9552018-07-31 15:07:53 -040087 }
88
89 /**
90 * Gets the DHCP client connect point.
91 *
92 * @return connect point
93 */
94 public ConnectPoint connectPoint() {
95 return connectPoint;
96 }
Marcos Aurelio Carreroeaf02b82019-11-25 13:34:25 -030097
98 /**
99 * Gets the counters map entry.
100 *
101 * @return counters map entry
102 */
103 public Map.Entry<String, AtomicLong> getCountersEntry() {
104 return countersEntry;
105 }
106
107 /**
Marcos Aurelio Carreroeaf02b82019-11-25 13:34:25 -0300108 * Gets the subscriber identifier information.
109 *
110 * @return the Id from subscriber
111 */
112 public String getSubscriberId() {
113 return subscriberId;
114 }
Jonathan Hartc36c9552018-07-31 15:07:53 -0400115}