]> git.proxmox.com Git - ceph.git/blob - ceph/src/seastar/include/seastar/net/dhcp.hh
import 15.2.0 Octopus source
[ceph.git] / ceph / src / seastar / include / seastar / net / 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/core/reactor.hh>
26 #include <seastar/util/std-compat.hh>
27
28 namespace seastar {
29
30 namespace net {
31
32 /*
33 * Simplistic DHCP query class.
34 * Due to the nature of the native stack,
35 * it operates on an "ipv4" object instead of,
36 * for example, an interface.
37 */
38 class dhcp {
39 public:
40 dhcp(ipv4 &);
41 dhcp(dhcp &&);
42 ~dhcp();
43
44 static const steady_clock_type::duration default_timeout;
45
46 struct lease {
47 ipv4_address ip;
48 ipv4_address netmask;
49 ipv4_address broadcast;
50
51 ipv4_address gateway;
52 ipv4_address dhcp_server;
53
54 std::vector<ipv4_address> name_servers;
55
56 std::chrono::seconds lease_time;
57 std::chrono::seconds renew_time;
58 std::chrono::seconds rebind_time;
59
60 uint16_t mtu = 0;
61 };
62
63 typedef future<compat::optional<lease>> result_type;
64
65 /**
66 * Runs a discover/request sequence on the ipv4 "stack".
67 * During this execution the ipv4 will be "hijacked"
68 * more or less (through packet filter), and while not
69 * inoperable, most likely quite less efficient.
70 *
71 * Please note that this does _not_ modify the ipv4 object bound.
72 * It only makes queries and records replys for the related NIC.
73 * It is up to caller to use the returned information as he se fit.
74 */
75 result_type discover(const steady_clock_type::duration & = default_timeout);
76 result_type renew(const lease &, const steady_clock_type::duration & = default_timeout);
77 ip_packet_filter* get_ipv4_filter();
78 private:
79 class impl;
80 std::unique_ptr<impl> _impl;
81 };
82
83 }
84
85 }