OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SANDBOX_LINUX_BPF_DSL_BPF_DSL_H_ | 5 #ifndef SANDBOX_LINUX_BPF_DSL_BPF_DSL_H_ |
6 #define SANDBOX_LINUX_BPF_DSL_BPF_DSL_H_ | 6 #define SANDBOX_LINUX_BPF_DSL_BPF_DSL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
(...skipping 15 matching lines...) Expand all Loading... |
26 // An idiomatic and demonstrative (albeit silly) example of this API | 26 // An idiomatic and demonstrative (albeit silly) example of this API |
27 // would be: | 27 // would be: |
28 // | 28 // |
29 // #include "sandbox/linux/bpf_dsl/bpf_dsl.h" | 29 // #include "sandbox/linux/bpf_dsl/bpf_dsl.h" |
30 // | 30 // |
31 // using namespace sandbox::bpf_dsl; | 31 // using namespace sandbox::bpf_dsl; |
32 // | 32 // |
33 // class SillyPolicy : public Policy { | 33 // class SillyPolicy : public Policy { |
34 // public: | 34 // public: |
35 // SillyPolicy() {} | 35 // SillyPolicy() {} |
36 // virtual ~SillyPolicy() {} | 36 // ~SillyPolicy() override {} |
37 // virtual ResultExpr EvaluateSyscall(int sysno) const override { | 37 // ResultExpr EvaluateSyscall(int sysno) const override { |
38 // if (sysno == __NR_fcntl) { | 38 // if (sysno == __NR_fcntl) { |
39 // Arg<int> fd(0), cmd(1); | 39 // Arg<int> fd(0), cmd(1); |
40 // Arg<unsigned long> flags(2); | 40 // Arg<unsigned long> flags(2); |
41 // const uint64_t kGoodFlags = O_ACCMODE | O_NONBLOCK; | 41 // const uint64_t kGoodFlags = O_ACCMODE | O_NONBLOCK; |
42 // return If(fd == 0 && cmd == F_SETFL && (flags & ~kGoodFlags) == 0, | 42 // return If(fd == 0 && cmd == F_SETFL && (flags & ~kGoodFlags) == 0, |
43 // Allow()) | 43 // Allow()) |
44 // .ElseIf(cmd == F_DUPFD || cmd == F_DUPFD_CLOEXEC, | 44 // .ElseIf(cmd == F_DUPFD || cmd == F_DUPFD_CLOEXEC, |
45 // Error(EMFILE)) | 45 // Error(EMFILE)) |
46 // .Else(Trap(SetFlagHandler, NULL)); | 46 // .Else(Trap(SetFlagHandler, NULL)); |
47 // } else { | 47 // } else { |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 | 308 |
309 template <typename T> | 309 template <typename T> |
310 ResultExpr Caser<T>::Default(ResultExpr result) const { | 310 ResultExpr Caser<T>::Default(ResultExpr result) const { |
311 return elser_.Else(result); | 311 return elser_.Else(result); |
312 } | 312 } |
313 | 313 |
314 } // namespace bpf_dsl | 314 } // namespace bpf_dsl |
315 } // namespace sandbox | 315 } // namespace sandbox |
316 | 316 |
317 #endif // SANDBOX_LINUX_BPF_DSL_BPF_DSL_H_ | 317 #endif // SANDBOX_LINUX_BPF_DSL_BPF_DSL_H_ |
OLD | NEW |