blob: 770b2f030dce1c67d882660b15ae228b52b08c2c [file] [log] [blame]
Amit Ghosha17354e2017-08-23 12:56:04 +01001/*
2 * Copyright 2017-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 */
16package org.opencord.dhcpl2relay;
17
Jonathan Hartc36c9552018-07-31 15:07:53 -040018import org.onlab.packet.DHCP;
Amit Ghosha17354e2017-08-23 12:56:04 +010019import org.onlab.packet.IpAddress;
20import org.onlab.packet.MacAddress;
Jonathan Hartc36c9552018-07-31 15:07:53 -040021import org.onosproject.net.ConnectPoint;
Amit Ghosha17354e2017-08-23 12:56:04 +010022
Jonathan Hartc36c9552018-07-31 15:07:53 -040023import java.time.Instant;
Amit Ghosha17354e2017-08-23 12:56:04 +010024
25/**
Jonathan Hartc36c9552018-07-31 15:07:53 -040026 * Information about DHCP Allocations.
Amit Ghosha17354e2017-08-23 12:56:04 +010027 */
28public class DhcpAllocationInfo {
29
Jonathan Hartc36c9552018-07-31 15:07:53 -040030 private ConnectPoint location;
Amit Ghosha17354e2017-08-23 12:56:04 +010031 private String circuitId;
32 private MacAddress macAddress;
33 private IpAddress ip;
Jonathan Hartc36c9552018-07-31 15:07:53 -040034 private Instant allocationTime;
35 private DHCP.MsgType type;
Matteo Scandolo64bba8c2020-08-19 11:50:33 -070036 private String subscriberId;
Amit Ghosha17354e2017-08-23 12:56:04 +010037
Jonathan Hartc36c9552018-07-31 15:07:53 -040038 /**
39 * Creates a new DHCP allocation info record.
40 *
41 * @param location connect point the requestor was seen on
42 * @param type last known message type
43 * @param circuitId option 82 information
44 * @param macAddress MAC address of client
45 * @param ip IP of client if allocated
Matteo Scandolo64bba8c2020-08-19 11:50:33 -070046 * @param subscriberId Sadis ID of a subscriber
Jonathan Hartc36c9552018-07-31 15:07:53 -040047 */
48 public DhcpAllocationInfo(ConnectPoint location, DHCP.MsgType type,
Matteo Scandolo64bba8c2020-08-19 11:50:33 -070049 String circuitId, MacAddress macAddress, IpAddress ip, String subscriberId) {
Jonathan Hartc36c9552018-07-31 15:07:53 -040050 this.location = location;
51 this.type = type;
Amit Ghosha17354e2017-08-23 12:56:04 +010052 this.circuitId = circuitId;
53 this.macAddress = macAddress;
54 this.ip = ip;
Jonathan Hartc36c9552018-07-31 15:07:53 -040055 this.allocationTime = Instant.now();
Matteo Scandolo64bba8c2020-08-19 11:50:33 -070056 this.subscriberId = subscriberId;
Amit Ghosha17354e2017-08-23 12:56:04 +010057 }
58
Jonathan Hartc36c9552018-07-31 15:07:53 -040059 /**
60 * Location the requestor was seen on.
61 *
62 * @return connect point
63 */
64 public ConnectPoint location() {
65 return location;
66 }
67
68 /**
69 * Last seen message type of the DHCP exchange.
70 *
71 * @return DHCP message type
72 */
73 public DHCP.MsgType type() {
74 return type;
75 }
76
77 /**
78 * Option 82 information.
79 *
80 * @return circuit ID
81 */
Amit Ghosha17354e2017-08-23 12:56:04 +010082 public String circuitId() {
83 return circuitId;
84 }
85
Jonathan Hartc36c9552018-07-31 15:07:53 -040086 /**
87 * MAC address of client.
88 *
89 * @return mac address
90 */
Amit Ghosha17354e2017-08-23 12:56:04 +010091 public MacAddress macAddress() {
92 return macAddress;
93 }
94
Jonathan Hartc36c9552018-07-31 15:07:53 -040095 /**
96 * IP address of client if it has one.
97 *
98 * @return client IP
99 */
Amit Ghosha17354e2017-08-23 12:56:04 +0100100 public IpAddress ipAddress() {
101 return ip;
102 }
103
Jonathan Hartc36c9552018-07-31 15:07:53 -0400104 /**
Matteo Scandolo64bba8c2020-08-19 11:50:33 -0700105 * SubscriberId of client if it has one.
106 *
107 * @return SubscriberId
108 */
109 public String subscriberId() {
110 return subscriberId;
111 }
112
113 /**
Jonathan Hartc36c9552018-07-31 15:07:53 -0400114 * Timestamp when the last DHCP message was seen.
115 *
116 * @return time
117 */
118 public Instant allocationTime() {
Amit Ghosha17354e2017-08-23 12:56:04 +0100119 return allocationTime;
120 }
121}