Darin Petkov | e02b3ca | 2011-05-31 16:00:44 -0700 | [diff] [blame] | 1 | // 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 Petkov | e7cb7f8 | 2011-06-03 13:21:51 -0700 | [diff] [blame] | 9 | #include <vector> |
Darin Petkov | e02b3ca | 2011-05-31 16:00:44 -0700 | [diff] [blame] | 10 | |
| 11 | #include <base/memory/ref_counted.h> |
| 12 | |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame^] | 13 | #include "shill/device.h" |
Darin Petkov | e02b3ca | 2011-05-31 16:00:44 -0700 | [diff] [blame] | 14 | |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame^] | 15 | namespace shill { |
Darin Petkov | e02b3ca | 2011-05-31 16:00:44 -0700 | [diff] [blame] | 16 | |
| 17 | // IPConfig superclass. Individual IP configuration types will inherit from this |
| 18 | // class. |
| 19 | class IPConfig : public base::RefCounted<IPConfig> { |
| 20 | public: |
Darin Petkov | e7cb7f8 | 2011-06-03 13:21:51 -0700 | [diff] [blame] | 21 | 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 Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame^] | 34 | explicit IPConfig(DeviceConstRefPtr device); |
Darin Petkov | e02b3ca | 2011-05-31 16:00:44 -0700 | [diff] [blame] | 35 | virtual ~IPConfig(); |
| 36 | |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame^] | 37 | DeviceConstRefPtr device() const { return device_; } |
Darin Petkov | e02b3ca | 2011-05-31 16:00:44 -0700 | [diff] [blame] | 38 | const std::string &GetDeviceName() const; |
| 39 | |
Darin Petkov | e7cb7f8 | 2011-06-03 13:21:51 -0700 | [diff] [blame] | 40 | // 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 Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 51 | |
Darin Petkov | e02b3ca | 2011-05-31 16:00:44 -0700 | [diff] [blame] | 52 | private: |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame^] | 53 | DeviceConstRefPtr device_; |
Darin Petkov | e7cb7f8 | 2011-06-03 13:21:51 -0700 | [diff] [blame] | 54 | Properties properties_; |
Darin Petkov | e02b3ca | 2011-05-31 16:00:44 -0700 | [diff] [blame] | 55 | |
| 56 | DISALLOW_COPY_AND_ASSIGN(IPConfig); |
| 57 | }; |
| 58 | |
| 59 | } // namespace shill |
| 60 | |
| 61 | #endif // SHILL_IPCONFIG_ |