Apache Mesos
link.hpp
Go to the documentation of this file.
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. 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, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef __LINUX_ROUTING_LINK_LINK_HPP__
18 #define __LINUX_ROUTING_LINK_LINK_HPP__
19 
20 #include <stdint.h>
21 
22 #include <string>
23 
24 #include <process/future.hpp>
25 
26 #include <stout/hashmap.hpp>
27 #include <stout/mac.hpp>
28 #include <stout/nothing.hpp>
29 #include <stout/option.hpp>
30 #include <stout/result.hpp>
31 #include <stout/try.hpp>
32 
33 namespace routing {
34 namespace link {
35 
36 // Returns the name of the public facing interface of the host (
37 // 'eth0' on most machines). The interface returned is the first
38 // interface in the routing table that has an empty 'destination'.
39 // Returns None if such an interface cannot be found.
41 
42 
43 // Returns the name of the loopback interface of the host (the 'lo'
44 // device on most machines). The interface returned has flag
45 // IFF_LOOPBACK set on it. Returns None if no loopback interface can
46 // be found on the host.
48 
49 
50 // Returns true if the link exists.
51 Try<bool> exists(const std::string& link);
52 
53 
54 // Removes a link. Returns false if the link is not found.
55 Try<bool> remove(const std::string& link);
56 
57 
58 // Waits for the link to be removed. The returned future will be set
59 // once the link has been removed. The user can discard the returned
60 // future to cancel the operation.
61 process::Future<Nothing> removed(const std::string& link);
62 
63 
64 // Returns the interface index of the link. Returns None if the link
65 // is not found.
66 Result<int> index(const std::string& link);
67 
68 
69 // Returns the name of the link from its interface index. Returns None
70 // if the link with the given interface index is not found.
72 
73 
74 // Returns true if the link is up. Returns None if the link is not
75 // found.
76 Result<bool> isUp(const std::string& link);
77 
78 
79 // Sets the link up (IFF_UP). Returns false if the link is not found.
80 Try<bool> setUp(const std::string& link);
81 
82 
83 // Sets the MAC address of the link. Returns false if the link is not
84 // found.
85 Try<bool> setMAC(const std::string& link, const net::MAC& mac);
86 
87 
88 // Returns the Maximum Transmission Unit (MTU) of the link. Returns
89 // None if the link is not found.
90 Result<unsigned int> mtu(const std::string& link);
91 
92 
93 // Sets the Maximum Transmission Unit (MTU) of the link. Returns false
94 // if the link is not found.
95 Try<bool> setMTU(const std::string& link, unsigned int mtu);
96 
97 
98 // Returns the statistics of the link.
99 Result<hashmap<std::string, uint64_t>> statistics(const std::string& link);
100 
101 } // namespace link {
102 } // namespace routing {
103 
104 #endif // __LINUX_ROUTING_LINK_LINK_HPP__
Definition: try.hpp:34
Definition: result.hpp:40
Definition: mac.hpp:74
Result< MAC > mac(const std::string &name)
Definition: mac.hpp:33