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; |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 36 | |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame^] | 37 | /** |
| 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 Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 50 | this.circuitId = circuitId; |
| 51 | this.macAddress = macAddress; |
| 52 | this.ip = ip; |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame^] | 53 | this.allocationTime = Instant.now(); |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 54 | } |
| 55 | |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame^] | 56 | /** |
| 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 Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 79 | public String circuitId() { |
| 80 | return circuitId; |
| 81 | } |
| 82 | |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame^] | 83 | /** |
| 84 | * MAC address of client. |
| 85 | * |
| 86 | * @return mac address |
| 87 | */ |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 88 | public MacAddress macAddress() { |
| 89 | return macAddress; |
| 90 | } |
| 91 | |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame^] | 92 | /** |
| 93 | * IP address of client if it has one. |
| 94 | * |
| 95 | * @return client IP |
| 96 | */ |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 97 | public IpAddress ipAddress() { |
| 98 | return ip; |
| 99 | } |
| 100 | |
Jonathan Hart | c36c955 | 2018-07-31 15:07:53 -0400 | [diff] [blame^] | 101 | /** |
| 102 | * Timestamp when the last DHCP message was seen. |
| 103 | * |
| 104 | * @return time |
| 105 | */ |
| 106 | public Instant allocationTime() { |
Amit Ghosh | a17354e | 2017-08-23 12:56:04 +0100 | [diff] [blame] | 107 | return allocationTime; |
| 108 | } |
| 109 | } |