Apache Mesos
icmp.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_FILTER_ICMP_HPP__
18 #define __LINUX_ROUTING_FILTER_ICMP_HPP__
19 
20 #include <string>
21 #include <vector>
22 
23 #include <stout/ip.hpp>
24 #include <stout/option.hpp>
25 #include <stout/result.hpp>
26 #include <stout/try.hpp>
27 
28 #include "linux/routing/handle.hpp"
29 
33 
34 namespace routing {
35 namespace filter {
36 namespace icmp {
37 
38 struct Classifier
39 {
40  explicit Classifier(const Option<net::IP>& _destinationIP)
41  : destinationIP(_destinationIP) {}
42 
43  bool operator==(const Classifier& that) const
44  {
45  return destinationIP == that.destinationIP;
46  }
47 
48  // TODO(evelinad): Replace net::IP with net::IP::Network when we will
49  // support classifiers for the entire subnet.
51 };
52 
53 
54 // Returns true if there exists an ICMP packet filter attached to the
55 // given parent on the link which matches the specified classifier.
57  const std::string& link,
58  const Handle& parent,
59  const Classifier& classifier);
60 
61 
62 // Creates an ICMP packet filter attached to the given parent on the
63 // link which will redirect all the ICMP packets that satisfy the
64 // conditions specified by the classifier to the target link. Returns
65 // false if an ICMP packet filter attached to the given parent with
66 // the same classifier already exists. The user can choose to specify
67 // an optional priority for the filter.
69  const std::string& link,
70  const Handle& parent,
71  const Classifier& classifier,
72  const Option<Priority>& priority,
73  const action::Redirect& redirect);
74 
75 
76 // Creates an ICMP packet filter attached to the given parent on the
77 // link which will mirror all the ICMP packets that satisfy the
78 // conditions specified by the classifier to a set of links (specified
79 // in the mirror action). Returns false if an ICMP packet filter
80 // attached to the given parent with the same classifier already
81 // exists. The user can choose to specify an optional priority for the
82 // filter.
84  const std::string& link,
85  const Handle& parent,
86  const Classifier& classifier,
87  const Option<Priority>& priority,
88  const action::Mirror& mirror);
89 
90 
91 // Creates an ICMP packet filter attached to the given parent on the
92 // link which will set the classid for packets that satisfy the
93 // conditions specified by the classifier. Returns false if an ICMP
94 // packet filter attached to the given parent with the same classifier
95 // already exists. The user can choose to specify an optional priority
96 // for the filter.
98  const std::string& link,
99  const Handle& parent,
100  const Classifier& classifier,
101  const Option<Priority>& priority,
102  const Option<Handle>& classid);
103 
104 
105 // Removes the ICMP packet filter attached to the given parent that
106 // matches the specified classifier from the link. Returns false if
107 // such a filter is not found.
108 Try<bool> remove(
109  const std::string& link,
110  const Handle& parent,
111  const Classifier& classifier);
112 
113 
114 // Updates the action of the ICMP packet filter attached to the given
115 // parent that matches the specified classifier on the link. Returns
116 // false if such a filter is not found.
118  const std::string& link,
119  const Handle& parent,
120  const Classifier& classifier,
121  const action::Mirror& mirror);
122 
123 
124 // Returns the classifiers of all the ICMP packet filters attached to
125 // the given parent on the link. Returns None if the link or the
126 // parent is not found.
128  const std::string& link,
129  const Handle& parent);
130 
131 } // namespace icmp {
132 } // namespace filter {
133 } // namespace routing {
134 
135 #endif // __LINUX_ROUTING_FILTER_ICMP_HPP__
Definition: icmp.hpp:38
Definition: check.hpp:33
Definition: handle.hpp:38
Try< bool > update(const std::string &link, const Handle &parent, const Classifier &classifier, const action::Mirror &mirror)
Future< Nothing > redirect(int_fd from, Option< int_fd > to, size_t chunk=4096, const std::vector< lambda::function< void(const std::string &)>> &hooks={})
Redirect output from the &#39;from&#39; file descriptor to the &#39;to&#39; file descriptor (or /dev/null if &#39;to&#39; is ...
Definition: check.hpp:30
Option< net::IP > destinationIP
Definition: icmp.hpp:50
Definition: action.hpp:41
Result< std::vector< Classifier > > classifiers(const std::string &link, const Handle &parent)
Definition: internal.hpp:809
bool operator==(const Classifier &that) const
Definition: icmp.hpp:43
Try< bool > create(const std::string &link, const Handle &parent, const Classifier &classifier, const Option< Priority > &priority, const action::Redirect &redirect)
Definition: diagnosis.hpp:30
Try< uint32_t > classid(const std::string &hierarchy, const std::string &cgroup)
Definition: action.hpp:54
Classifier(const Option< net::IP > &_destinationIP)
Definition: icmp.hpp:40
Try< bool > exists(const std::string &link, const Handle &parent, const Classifier &classifier)
void filter(Filter *filter)