blob: f87c5b013eec082ba08874c0f1bf53233690d933 [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;
Amit Ghosha17354e2017-08-23 12:56:04 +010036
Jonathan Hartc36c9552018-07-31 15:07:53 -040037 /**
38 * Creates a new DHCP allocation info record.
39 *
40 * @param location connect point the requestor was seen on
41 * @param type last known message type
42 * @param circuitId option 82 information
43 * @param macAddress MAC address of client
44 * @param ip IP of client if allocated
45 */
46 public DhcpAllocationInfo(ConnectPoint location, DHCP.MsgType type,
47 String circuitId, MacAddress macAddress, IpAddress ip) {
48 this.location = location;
49 this.type = type;
Amit Ghosha17354e2017-08-23 12:56:04 +010050 this.circuitId = circuitId;
51 this.macAddress = macAddress;
52 this.ip = ip;
Jonathan Hartc36c9552018-07-31 15:07:53 -040053 this.allocationTime = Instant.now();
Amit Ghosha17354e2017-08-23 12:56:04 +010054 }
55
Jonathan Hartc36c9552018-07-31 15:07:53 -040056 /**
57 * Location the requestor was seen on.
58 *
59 * @return connect point
60 */
61 public ConnectPoint location() {
62 return location;
63 }
64
65 /**
66 * Last seen message type of the DHCP exchange.
67 *
68 * @return DHCP message type
69 */
70 public DHCP.MsgType type() {
71 return type;
72 }
73
74 /**
75 * Option 82 information.
76 *
77 * @return circuit ID
78 */
Amit Ghosha17354e2017-08-23 12:56:04 +010079 public String circuitId() {
80 return circuitId;
81 }
82
Jonathan Hartc36c9552018-07-31 15:07:53 -040083 /**
84 * MAC address of client.
85 *
86 * @return mac address
87 */
Amit Ghosha17354e2017-08-23 12:56:04 +010088 public MacAddress macAddress() {
89 return macAddress;
90 }
91
Jonathan Hartc36c9552018-07-31 15:07:53 -040092 /**
93 * IP address of client if it has one.
94 *
95 * @return client IP
96 */
Amit Ghosha17354e2017-08-23 12:56:04 +010097 public IpAddress ipAddress() {
98 return ip;
99 }
100
Jonathan Hartc36c9552018-07-31 15:07:53 -0400101 /**
102 * Timestamp when the last DHCP message was seen.
103 *
104 * @return time
105 */
106 public Instant allocationTime() {
Amit Ghosha17354e2017-08-23 12:56:04 +0100107 return allocationTime;
108 }
109}