Merge "DHCP Handling for TOR VM"
[vpnservice.git] / dhcpservice / dhcpservice-impl / src / main / java / org / opendaylight / vpnservice / dhcpservice / DhcpInfo.java
1 /*
2  * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.vpnservice.dhcpservice;
9
10 import java.util.ArrayList;
11 import java.util.List;
12
13 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnet.attributes.HostRoutes;
15
16 public class DhcpInfo  {
17     private String _clientIp;
18     private String _serverIp;
19     private String _gatewayIp;
20     private String _cidr;
21     private List<String> _dnsServers;
22     private List<HostRoutes> _hostRoutes;
23     
24     public DhcpInfo() {
25         //Empty constructor
26     }
27
28     protected DhcpInfo setClientIp(String clientIp) {
29         _clientIp = clientIp;
30         return this;
31     }
32
33     protected DhcpInfo setCidr(String cidr) {
34         _cidr = cidr;
35         return this;
36     }
37
38     protected DhcpInfo setServerIp(String serverIp) {
39         _serverIp = serverIp;
40         return this;
41     }
42
43     protected DhcpInfo setGatewayIp(String gwIp) {
44         _gatewayIp = gwIp;
45         return this;
46     }
47
48     protected DhcpInfo setHostRoutes(List<HostRoutes> hostRoutes) {
49         _hostRoutes = hostRoutes;
50         return this;
51     }
52
53     protected DhcpInfo setDnsServers(List<String> dnsServers) {
54         _dnsServers = dnsServers;
55         return this;
56     }
57
58     protected DhcpInfo setDnsServersIpAddrs(List<IpAddress> dnsServers) {
59         for (IpAddress ipAddr: dnsServers) {
60             addDnsServer(ipAddr.getIpv4Address().getValue());
61         }
62         return this;
63     }
64
65     protected DhcpInfo addDnsServer(String dnsServerIp) {
66         if(_dnsServers == null) {
67             _dnsServers = new ArrayList<String>();
68         }
69         _dnsServers.add(dnsServerIp);
70         return this;
71     }
72
73
74     protected String getClientIp() {
75         return _clientIp;
76     }
77
78     protected String getCidr() {
79         return _cidr;
80     }
81
82     protected String getServerIp() {
83         return _serverIp ;
84     }
85
86     protected String getGatewayIp() {
87         return _gatewayIp ;
88     }
89
90     protected List<String> getDnsServers() {
91         return _dnsServers;
92     }
93
94     protected List<HostRoutes> getHostRoutes() {
95         return _hostRoutes;
96     }
97
98 }