blob: 78ace7081624aff20b9b60a69617c17f23fcbac7 [file] [log] [blame]
Darin Petkove02b3ca2011-05-31 16:00:44 -07001// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef SHILL_IPCONFIG_
6#define SHILL_IPCONFIG_
7
8#include <string>
Darin Petkove7cb7f82011-06-03 13:21:51 -07009#include <vector>
Darin Petkove02b3ca2011-05-31 16:00:44 -070010
11#include <base/memory/ref_counted.h>
12
Chris Masonec1e50412011-06-07 13:04:53 -070013#include "shill/device.h"
Darin Petkove02b3ca2011-05-31 16:00:44 -070014
Chris Masonec1e50412011-06-07 13:04:53 -070015namespace shill {
Darin Petkove02b3ca2011-05-31 16:00:44 -070016
17// IPConfig superclass. Individual IP configuration types will inherit from this
18// class.
19class IPConfig : public base::RefCounted<IPConfig> {
20 public:
Darin Petkove7cb7f82011-06-03 13:21:51 -070021 struct Properties {
22 Properties() : subnet_cidr(0), mtu(0) {}
23
24 std::string address;
25 int subnet_cidr;
26 std::string broadcast_address;
27 std::string gateway;
28 std::vector<std::string> dns_servers;
29 std::string domain_name;
30 std::vector<std::string> domain_search;
31 int mtu;
32 };
33
Chris Masonec1e50412011-06-07 13:04:53 -070034 explicit IPConfig(DeviceConstRefPtr device);
Darin Petkove02b3ca2011-05-31 16:00:44 -070035 virtual ~IPConfig();
36
Chris Masonec1e50412011-06-07 13:04:53 -070037 DeviceConstRefPtr device() const { return device_; }
Darin Petkove02b3ca2011-05-31 16:00:44 -070038 const std::string &GetDeviceName() const;
39
Darin Petkove7cb7f82011-06-03 13:21:51 -070040 // Updates the IP configuration properties and notifies registered listeners
41 // about the event.
42 void UpdateProperties(const Properties &properties);
43
44 const Properties &properties() const { return properties_; }
45
46 // Request or renew IP configuration. Return true on success, false
47 // otherwise. The default implementation always returns false indicating a
48 // failure.
49 virtual bool Request();
50 virtual bool Renew();
Darin Petkovd1b715b2011-06-02 21:21:22 -070051
Darin Petkove02b3ca2011-05-31 16:00:44 -070052 private:
Chris Masonec1e50412011-06-07 13:04:53 -070053 DeviceConstRefPtr device_;
Darin Petkove7cb7f82011-06-03 13:21:51 -070054 Properties properties_;
Darin Petkove02b3ca2011-05-31 16:00:44 -070055
56 DISALLOW_COPY_AND_ASSIGN(IPConfig);
57};
58
59} // namespace shill
60
61#endif // SHILL_IPCONFIG_