samanwita pal | 18696f6 | 2015-07-17 13:15:43 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Open Networking Laboratory |
| 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.onosproject.dhcpserver; |
| 17 | |
| 18 | import org.onlab.packet.Ip4Address; |
| 19 | import org.onlab.packet.MacAddress; |
| 20 | |
samanwita pal | f66ed8a | 2015-07-21 15:45:33 -0700 | [diff] [blame] | 21 | import java.util.Map; |
| 22 | |
samanwita pal | 18696f6 | 2015-07-17 13:15:43 -0700 | [diff] [blame] | 23 | /** |
| 24 | * DHCPStore Interface. |
| 25 | */ |
| 26 | public interface DHCPStore { |
| 27 | |
| 28 | /** |
| 29 | * Returns an IP Address for a Mac ID, in response to a DHCP DISCOVER message. |
| 30 | * |
| 31 | * @param macID Mac ID of the client requesting an IP |
| 32 | * @return IP address assigned to the Mac ID |
| 33 | */ |
samanwita pal | f09c09e | 2015-07-22 16:06:42 -0700 | [diff] [blame^] | 34 | Ip4Address suggestIP(MacAddress macID, Ip4Address requestedIP); |
samanwita pal | 18696f6 | 2015-07-17 13:15:43 -0700 | [diff] [blame] | 35 | |
| 36 | /** |
| 37 | * Assigns the requested IP to the Mac ID, in response to a DHCP REQUEST message. |
| 38 | * |
| 39 | * @param macID Mac Id of the client requesting an IP |
| 40 | * @param ipAddr IP Address being requested |
| 41 | * @param leaseTime Lease time offered by the server for this mapping |
| 42 | * @return returns true if the assignment was successful, false otherwise |
| 43 | */ |
samanwita pal | f66ed8a | 2015-07-21 15:45:33 -0700 | [diff] [blame] | 44 | boolean assignIP(MacAddress macID, Ip4Address ipAddr, int leaseTime); |
samanwita pal | 18696f6 | 2015-07-17 13:15:43 -0700 | [diff] [blame] | 45 | |
| 46 | /** |
| 47 | * Sets the default time for which suggested IP mappings are valid. |
| 48 | * |
| 49 | * @param timeInSeconds default time for IP mappings to be valid |
| 50 | */ |
samanwita pal | f66ed8a | 2015-07-21 15:45:33 -0700 | [diff] [blame] | 51 | void setDefaultTimeoutForPurge(int timeInSeconds); |
samanwita pal | 18696f6 | 2015-07-17 13:15:43 -0700 | [diff] [blame] | 52 | |
| 53 | /** |
| 54 | * Releases the IP assigned to a Mac ID into the free pool. |
| 55 | * |
| 56 | * @param macID the macID for which the mapping needs to be changed |
| 57 | */ |
| 58 | void releaseIP(MacAddress macID); |
| 59 | |
samanwita pal | f66ed8a | 2015-07-21 15:45:33 -0700 | [diff] [blame] | 60 | /** |
| 61 | * Returns a collection of all the MacAddress to IPAddress mapping. |
| 62 | * |
| 63 | * @return the collection of the mappings |
| 64 | */ |
| 65 | Map<MacAddress, Ip4Address> listMapping(); |
| 66 | |
| 67 | /** |
| 68 | * Assigns the requested IP to the MAC ID (if available) for an indefinite period of time. |
| 69 | * |
| 70 | * @param macID macID of the client |
| 71 | * @param ipAddr IP Address requested for the client |
| 72 | * @return true if the mapping was successfully registered, false otherwise |
| 73 | */ |
| 74 | boolean assignStaticIP(MacAddress macID, Ip4Address ipAddr); |
| 75 | |
| 76 | /** |
| 77 | * Removes a static IP mapping associated with the given MAC ID from the DHCP Server. |
| 78 | * |
| 79 | * @param macID macID of the client |
| 80 | * @return true if the mapping was successfully registered, false otherwise |
| 81 | */ |
| 82 | boolean removeStaticIP(MacAddress macID); |
| 83 | |
| 84 | /** |
| 85 | * Returns the list of all the available IPs with the server. |
| 86 | * |
| 87 | * @return list of available IPs |
| 88 | */ |
| 89 | Iterable<Ip4Address> getAvailableIPs(); |
| 90 | |
samanwita pal | 18696f6 | 2015-07-17 13:15:43 -0700 | [diff] [blame] | 91 | } |