samanwita pal | 775f619 | 2015-07-28 10:10:13 -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.impl; |
| 17 | |
| 18 | import org.onosproject.core.ApplicationId; |
| 19 | import org.onosproject.incubator.net.config.Config; |
| 20 | import org.onosproject.incubator.net.config.basics.BasicElementConfig; |
| 21 | |
| 22 | /** |
| 23 | * DHCP Config class. |
| 24 | */ |
| 25 | public class DHCPConfig extends Config<ApplicationId> { |
| 26 | |
| 27 | public static final String MY_IP = "ip"; |
| 28 | public static final String MY_MAC = "mac"; |
| 29 | public static final String SUBNET_MASK = "subnet"; |
| 30 | public static final String BROADCAST_ADDRESS = "broadcast"; |
| 31 | public static final String TTL = "ttl"; |
| 32 | public static final String LEASE_TIME = "lease"; |
| 33 | public static final String RENEW_TIME = "renew"; |
| 34 | public static final String REBIND_TIME = "rebind"; |
| 35 | |
| 36 | /** |
| 37 | * Returns the dhcp server ip. |
| 38 | * |
| 39 | * @return ip address or null if not set |
| 40 | */ |
| 41 | public String ip() { |
| 42 | return get(MY_IP, null); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Sets the dhcp server ip. |
| 47 | * |
| 48 | * @param ip new ip address; null to clear |
| 49 | * @return self |
| 50 | */ |
| 51 | public BasicElementConfig ip(String ip) { |
| 52 | return (BasicElementConfig) setOrClear(MY_IP, ip); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Returns the dhcp server mac. |
| 57 | * |
| 58 | * @return server mac or null if not set |
| 59 | */ |
| 60 | public String mac() { |
| 61 | return get(MY_MAC, null); |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Sets the dhcp server mac. |
| 66 | * |
| 67 | * @param mac new mac address; null to clear |
| 68 | * @return self |
| 69 | */ |
| 70 | public BasicElementConfig mac(String mac) { |
| 71 | return (BasicElementConfig) setOrClear(MY_MAC, mac); |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Returns the subnet mask. |
| 76 | * |
| 77 | * @return subnet mask or null if not set |
| 78 | */ |
| 79 | public String subnetMask() { |
| 80 | return get(SUBNET_MASK, null); |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Sets the subnet mask. |
| 85 | * |
| 86 | * @param subnet new subnet mask; null to clear |
| 87 | * @return self |
| 88 | */ |
| 89 | public BasicElementConfig subnetMask(String subnet) { |
| 90 | return (BasicElementConfig) setOrClear(SUBNET_MASK, subnet); |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Returns the broadcast address. |
| 95 | * |
| 96 | * @return broadcast address or null if not set |
| 97 | */ |
| 98 | public String broadcastAddress() { |
| 99 | return get(BROADCAST_ADDRESS, null); |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Sets the broadcast address. |
| 104 | * |
| 105 | * @param broadcast new broadcast address; null to clear |
| 106 | * @return self |
| 107 | */ |
| 108 | public BasicElementConfig broadcastAddress(String broadcast) { |
| 109 | return (BasicElementConfig) setOrClear(BROADCAST_ADDRESS, broadcast); |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Returns the Time To Live for the reply packets. |
| 114 | * |
| 115 | * @return ttl or null if not set |
| 116 | */ |
| 117 | public String ttl() { |
| 118 | return get(TTL, null); |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Sets the Time To Live for the reply packets. |
| 123 | * |
| 124 | * @param ttl new ttl; null to clear |
| 125 | * @return self |
| 126 | */ |
| 127 | public BasicElementConfig ttl(String ttl) { |
| 128 | return (BasicElementConfig) setOrClear(TTL, ttl); |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * Returns the Lease Time offered by the DHCP Server. |
| 133 | * |
| 134 | * @return lease time or null if not set |
| 135 | */ |
| 136 | public String leaseTime() { |
| 137 | return get(LEASE_TIME, null); |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * Sets the Lease Time offered by the DHCP Server. |
| 142 | * |
| 143 | * @param lease new lease time; null to clear |
| 144 | * @return self |
| 145 | */ |
| 146 | public BasicElementConfig leaseTime(String lease) { |
| 147 | return (BasicElementConfig) setOrClear(LEASE_TIME, lease); |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * Returns the Renew Time offered by the DHCP Server. |
| 152 | * |
| 153 | * @return renew time or null if not set |
| 154 | */ |
| 155 | public String renewTime() { |
| 156 | return get(RENEW_TIME, null); |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Sets the Renew Time offered by the DHCP Server. |
| 161 | * |
| 162 | * @param renew new renew time; null to clear |
| 163 | * @return self |
| 164 | */ |
| 165 | public BasicElementConfig renewTime(String renew) { |
| 166 | return (BasicElementConfig) setOrClear(RENEW_TIME, renew); |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * Returns the Rebind Time offered by the DHCP Server. |
| 171 | * |
| 172 | * @return rebind time or null if not set |
| 173 | */ |
| 174 | public String rebindTime() { |
| 175 | return get(REBIND_TIME, null); |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * Sets the Rebind Time offered by the DHCP Server. |
| 180 | * |
| 181 | * @param rebind new rebind time; null to clear |
| 182 | * @return self |
| 183 | */ |
| 184 | public BasicElementConfig rebindTime(String rebind) { |
| 185 | return (BasicElementConfig) setOrClear(REBIND_TIME, rebind); |
| 186 | } |
| 187 | } |