Seastar
High performance C++ framework for concurrent servers
dhcp.hh
1 /*
2  * This file is open source software, licensed to you under the terms
3  * of the Apache License, Version 2.0 (the "License"). See the NOTICE file
4  * distributed with this work for additional information regarding copyright
5  * ownership. You may not use this file except in compliance with the License.
6  *
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14  * KIND, either express or implied. See the License for the
15  * specific language governing permissions and limitations
16  * under the License.
17  */
18 /*
19  * Copyright 2014 Cloudius Systems
20  */
21 
22 #pragma once
23 
24 #include <seastar/net/ip.hh>
25 #include <seastar/util/std-compat.hh>
26 
27 namespace seastar {
28 
29 namespace net {
30 
31 /*
32  * Simplistic DHCP query class.
33  * Due to the nature of the native stack,
34  * it operates on an "ipv4" object instead of,
35  * for example, an interface.
36  */
37 class dhcp {
38 public:
39  dhcp(ipv4 &);
40  dhcp(dhcp &&) noexcept;
41  ~dhcp();
42 
43  static const steady_clock_type::duration default_timeout;
44 
45  struct lease {
46  ipv4_address ip;
47  ipv4_address netmask;
48  ipv4_address broadcast;
49 
50  ipv4_address gateway;
51  ipv4_address dhcp_server;
52 
53  std::vector<ipv4_address> name_servers;
54 
55  std::chrono::seconds lease_time;
56  std::chrono::seconds renew_time;
57  std::chrono::seconds rebind_time;
58 
59  uint16_t mtu = 0;
60  };
61 
63 
74  result_type discover(const steady_clock_type::duration & = default_timeout);
75  result_type renew(const lease &, const steady_clock_type::duration & = default_timeout);
76  ip_packet_filter* get_ipv4_filter();
77 private:
78  class impl;
79  std::unique_ptr<impl> _impl;
80 };
81 
82 }
83 
84 }
A representation of a possibly not-yet-computed value.
Definition: future.hh:1238
Definition: dhcp.hh:37
result_type discover(const steady_clock_type::duration &=default_timeout)
Definition: dhcp.hh:45
Definition: ip.hh:276
holds the implementation parts of the metrics layer, do not use directly.
Seastar API namespace.
Definition: abort_on_ebadf.hh:26
Definition: ip.hh:241
Definition: ipv4_address.hh:35