samanwita pal | f28207b | 2015-09-04 10:41:56 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 54dc352 | 2015-09-09 00:11:45 -0700 | [diff] [blame] | 2 | * Copyright 2015 Open Networking Laboratory |
samanwita pal | f28207b | 2015-09-04 10:41:56 -0700 | [diff] [blame] | 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.dhcp; |
| 17 | |
| 18 | import org.onlab.packet.Ip4Address; |
| 19 | import org.onlab.packet.MacAddress; |
| 20 | |
| 21 | import java.util.Map; |
| 22 | |
| 23 | /** |
| 24 | * DHCPStore Interface. |
| 25 | */ |
Thomas Vachuska | a1da42e | 2015-09-09 00:45:22 -0700 | [diff] [blame] | 26 | public interface DhcpStore { |
samanwita pal | f28207b | 2015-09-04 10:41:56 -0700 | [diff] [blame] | 27 | |
| 28 | /** |
| 29 | * Appends all the IPs in a given range to the free pool of IPs. |
| 30 | * |
| 31 | * @param startIP Start IP for the range |
| 32 | * @param endIP End IP for the range |
| 33 | */ |
| 34 | void populateIPPoolfromRange(Ip4Address startIP, Ip4Address endIP); |
| 35 | |
| 36 | /** |
| 37 | * Returns an IP Address for a Mac ID, in response to a DHCP DISCOVER message. |
| 38 | * |
| 39 | * @param macID Mac ID of the client requesting an IP |
Ray Milkey | 9b36d81 | 2015-09-09 15:24:54 -0700 | [diff] [blame^] | 40 | * @param requestedIP requested IP address |
samanwita pal | f28207b | 2015-09-04 10:41:56 -0700 | [diff] [blame] | 41 | * @return IP address assigned to the Mac ID |
| 42 | */ |
| 43 | Ip4Address suggestIP(MacAddress macID, Ip4Address requestedIP); |
| 44 | |
| 45 | /** |
| 46 | * Assigns the requested IP to the Mac ID, in response to a DHCP REQUEST message. |
| 47 | * |
| 48 | * @param macID Mac Id of the client requesting an IP |
| 49 | * @param ipAddr IP Address being requested |
| 50 | * @param leaseTime Lease time offered by the server for this mapping |
| 51 | * @return returns true if the assignment was successful, false otherwise |
| 52 | */ |
| 53 | boolean assignIP(MacAddress macID, Ip4Address ipAddr, int leaseTime); |
| 54 | |
| 55 | /** |
| 56 | * Sets the default time for which suggested IP mappings are valid. |
| 57 | * |
| 58 | * @param timeInSeconds default time for IP mappings to be valid |
| 59 | */ |
| 60 | void setDefaultTimeoutForPurge(int timeInSeconds); |
| 61 | |
| 62 | /** |
| 63 | * Sets the delay after which the dhcp server will purge expired entries. |
| 64 | * |
| 65 | * @param timeInSeconds default time |
| 66 | */ |
| 67 | void setTimerDelay(int timeInSeconds); |
| 68 | |
| 69 | /** |
| 70 | * Releases the IP assigned to a Mac ID into the free pool. |
| 71 | * |
| 72 | * @param macID the macID for which the mapping needs to be changed |
| 73 | */ |
| 74 | void releaseIP(MacAddress macID); |
| 75 | |
| 76 | /** |
| 77 | * Returns a collection of all the MacAddress to IPAddress mapping. |
| 78 | * |
| 79 | * @return the collection of the mappings |
| 80 | */ |
Thomas Vachuska | a1da42e | 2015-09-09 00:45:22 -0700 | [diff] [blame] | 81 | Map<MacAddress, IpAssignment> listMapping(); |
samanwita pal | f28207b | 2015-09-04 10:41:56 -0700 | [diff] [blame] | 82 | |
| 83 | /** |
| 84 | * Assigns the requested IP to the MAC ID (if available) for an indefinite period of time. |
| 85 | * |
| 86 | * @param macID macID of the client |
| 87 | * @param ipAddr IP Address requested for the client |
| 88 | * @return true if the mapping was successfully registered, false otherwise |
| 89 | */ |
| 90 | boolean assignStaticIP(MacAddress macID, Ip4Address ipAddr); |
| 91 | |
| 92 | /** |
| 93 | * Removes a static IP mapping associated with the given MAC ID from the DHCP Server. |
| 94 | * |
| 95 | * @param macID macID of the client |
| 96 | * @return true if the mapping was successfully registered, false otherwise |
| 97 | */ |
| 98 | boolean removeStaticIP(MacAddress macID); |
| 99 | |
| 100 | /** |
| 101 | * Returns the list of all the available IPs with the server. |
| 102 | * |
| 103 | * @return list of available IPs |
| 104 | */ |
| 105 | Iterable<Ip4Address> getAvailableIPs(); |
| 106 | |
| 107 | } |