Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.opencord.dhcpl2relay; |
| 17 | |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 18 | import org.onlab.packet.DHCP; |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 19 | import org.onlab.packet.IpAddress; |
| 20 | import org.onlab.packet.MacAddress; |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 21 | import org.onosproject.net.ConnectPoint; |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 22 | |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 23 | import java.time.Instant; |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 24 | |
| 25 | /** |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 26 | * Information about DHCP Allocations. |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 27 | */ |
| 28 | public class DhcpAllocationInfo { |
| 29 | |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 30 | private ConnectPoint location; |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 31 | private String circuitId; |
| 32 | private MacAddress macAddress; |
| 33 | private IpAddress ip; |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 34 | private Instant allocationTime; |
| 35 | private DHCP.MsgType type; |
Matteo Scandolo | 64bba8c | 2020-08-19 11:50:33 -0700 | [diff] [blame] | 36 | private String subscriberId; |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 37 | |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 38 | /** |
| 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 Scandolo | 64bba8c | 2020-08-19 11:50:33 -0700 | [diff] [blame] | 46 | * @param subscriberId Sadis ID of a subscriber |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 47 | */ |
| 48 | public DhcpAllocationInfo(ConnectPoint location, DHCP.MsgType type, |
Matteo Scandolo | 64bba8c | 2020-08-19 11:50:33 -0700 | [diff] [blame] | 49 | String circuitId, MacAddress macAddress, IpAddress ip, String subscriberId) { |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 50 | this.location = location; |
| 51 | this.type = type; |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 52 | this.circuitId = circuitId; |
| 53 | this.macAddress = macAddress; |
| 54 | this.ip = ip; |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 55 | this.allocationTime = Instant.now(); |
Matteo Scandolo | 64bba8c | 2020-08-19 11:50:33 -0700 | [diff] [blame] | 56 | this.subscriberId = subscriberId; |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 57 | } |
| 58 | |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 59 | /** |
| 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 Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 82 | public String circuitId() { |
| 83 | return circuitId; |
| 84 | } |
| 85 | |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 86 | /** |
| 87 | * MAC address of client. |
| 88 | * |
| 89 | * @return mac address |
| 90 | */ |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 91 | public MacAddress macAddress() { |
| 92 | return macAddress; |
| 93 | } |
| 94 | |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 95 | /** |
| 96 | * IP address of client if it has one. |
| 97 | * |
| 98 | * @return client IP |
| 99 | */ |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 100 | public IpAddress ipAddress() { |
| 101 | return ip; |
| 102 | } |
| 103 | |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 104 | /** |
Matteo Scandolo | 64bba8c | 2020-08-19 11:50:33 -0700 | [diff] [blame] | 105 | * SubscriberId of client if it has one. |
| 106 | * |
| 107 | * @return SubscriberId |
| 108 | */ |
| 109 | public String subscriberId() { |
| 110 | return subscriberId; |
| 111 | } |
| 112 | |
| 113 | /** |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame] | 114 | * Timestamp when the last DHCP message was seen. |
| 115 | * |
| 116 | * @return time |
| 117 | */ |
| 118 | public Instant allocationTime() { |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 119 | return allocationTime; |
| 120 | } |
| 121 | } |