blob: cedae891f6181bd1dfb40e166cc2a05f19ae281d [file] [log] [blame]
samanwita palf28207b2015-09-04 10:41:56 -07001/*
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 */
16package org.onosproject.dhcp.impl;
17
18import org.onosproject.core.ApplicationId;
19import org.onosproject.net.config.Config;
20import org.onosproject.net.config.basics.BasicElementConfig;
21
22/**
23 * DHCP Config class.
24 */
25public 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 ROUTER_ADDRESS = "router";
32 public static final String DOMAIN_SERVER = "domain";
33 public static final String TTL = "ttl";
34 public static final String LEASE_TIME = "lease";
35 public static final String RENEW_TIME = "renew";
36 public static final String REBIND_TIME = "rebind";
37
38 /**
39 * Returns the dhcp server ip.
40 *
41 * @return ip address or null if not set
42 */
43 public String ip() {
44 return get(MY_IP, null);
45 }
46
47 /**
48 * Sets the dhcp server ip.
49 *
50 * @param ip new ip address; null to clear
51 * @return self
52 */
53 public BasicElementConfig ip(String ip) {
54 return (BasicElementConfig) setOrClear(MY_IP, ip);
55 }
56
57 /**
58 * Returns the dhcp server mac.
59 *
60 * @return server mac or null if not set
61 */
62 public String mac() {
63 return get(MY_MAC, null);
64 }
65
66 /**
67 * Sets the dhcp server mac.
68 *
69 * @param mac new mac address; null to clear
70 * @return self
71 */
72 public BasicElementConfig mac(String mac) {
73 return (BasicElementConfig) setOrClear(MY_MAC, mac);
74 }
75
76 /**
77 * Returns the subnet mask.
78 *
79 * @return subnet mask or null if not set
80 */
81 public String subnetMask() {
82 return get(SUBNET_MASK, null);
83 }
84
85 /**
86 * Sets the subnet mask.
87 *
88 * @param subnet new subnet mask; null to clear
89 * @return self
90 */
91 public BasicElementConfig subnetMask(String subnet) {
92 return (BasicElementConfig) setOrClear(SUBNET_MASK, subnet);
93 }
94
95 /**
96 * Returns the broadcast address.
97 *
98 * @return broadcast address or null if not set
99 */
100 public String broadcastAddress() {
101 return get(BROADCAST_ADDRESS, null);
102 }
103
104 /**
105 * Sets the broadcast address.
106 *
107 * @param broadcast new broadcast address; null to clear
108 * @return self
109 */
110 public BasicElementConfig broadcastAddress(String broadcast) {
111 return (BasicElementConfig) setOrClear(BROADCAST_ADDRESS, broadcast);
112 }
113
114 /**
115 * Returns the Time To Live for the reply packets.
116 *
117 * @return ttl or null if not set
118 */
119 public String ttl() {
120 return get(TTL, null);
121 }
122
123 /**
124 * Sets the Time To Live for the reply packets.
125 *
126 * @param ttl new ttl; null to clear
127 * @return self
128 */
129 public BasicElementConfig ttl(String ttl) {
130 return (BasicElementConfig) setOrClear(TTL, ttl);
131 }
132
133 /**
134 * Returns the Lease Time offered by the DHCP Server.
135 *
136 * @return lease time or null if not set
137 */
138 public String leaseTime() {
139 return get(LEASE_TIME, null);
140 }
141
142 /**
143 * Sets the Lease Time offered by the DHCP Server.
144 *
145 * @param lease new lease time; null to clear
146 * @return self
147 */
148 public BasicElementConfig leaseTime(String lease) {
149 return (BasicElementConfig) setOrClear(LEASE_TIME, lease);
150 }
151
152 /**
153 * Returns the Renew Time offered by the DHCP Server.
154 *
155 * @return renew time or null if not set
156 */
157 public String renewTime() {
158 return get(RENEW_TIME, null);
159 }
160
161 /**
162 * Sets the Renew Time offered by the DHCP Server.
163 *
164 * @param renew new renew time; null to clear
165 * @return self
166 */
167 public BasicElementConfig renewTime(String renew) {
168 return (BasicElementConfig) setOrClear(RENEW_TIME, renew);
169 }
170
171 /**
172 * Returns the Rebind Time offered by the DHCP Server.
173 *
174 * @return rebind time or null if not set
175 */
176 public String rebindTime() {
177 return get(REBIND_TIME, null);
178 }
179
180 /**
181 * Sets the Rebind Time offered by the DHCP Server.
182 *
183 * @param rebind new rebind time; null to clear
184 * @return self
185 */
186 public BasicElementConfig rebindTime(String rebind) {
187 return (BasicElementConfig) setOrClear(REBIND_TIME, rebind);
188 }
189
190 /**
191 * Returns the Router Address.
192 *
193 * @return router address or null if not set
194 */
195 public String routerAddress() {
196 return get(ROUTER_ADDRESS, null);
197 }
198
199 /**
200 * Sets the Router Address.
201 *
202 * @param router new router address; null to clear
203 * @return self
204 */
205 public BasicElementConfig routerAddress(String router) {
206 return (BasicElementConfig) setOrClear(ROUTER_ADDRESS, router);
207 }
208
209 /**
210 * Returns the Domain Server Address.
211 *
212 * @return domain server address or null if not set
213 */
214 public String domainServer() {
215 return get(DOMAIN_SERVER, null);
216 }
217
218 /**
219 * Sets the Domain Server Address.
220 *
221 * @param domain new domain server address; null to clear
222 * @return self
223 */
224 public BasicElementConfig domainServer(String domain) {
225 return (BasicElementConfig) setOrClear(DOMAIN_SERVER, domain);
226 }
227}