OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_ITERATOR_H__ |
| 6 #define SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_ITERATOR_H__ |
| 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 namespace playground2 { |
| 11 |
| 12 class SyscallIterator { |
| 13 public: |
| 14 // Iterates over the entire system call range from 0..0xFFFFFFFFu. This |
| 15 // iterator is aware of how system calls look like and will skip quickly |
| 16 // over ranges that can't contain system calls. It iterates more slowly |
| 17 // whenever it reaches a range that is potentially problematic. And it |
| 18 // iterates over individual values whenever it is in the normal range for |
| 19 // system calls (typically MIN_SYSCALL..MAX_SYSCALL). |
| 20 // If "invalid_only" is "true", the iterator still iterates from |
| 21 // 0..0xFFFFFFFFu, but it never returns values from the range of valid |
| 22 // system call numbers. This feature can be used when verifying that all |
| 23 // "impossible" system call values are treated the same. |
| 24 explicit SyscallIterator(bool invalid_only) |
| 25 : invalid_only_(invalid_only), |
| 26 done_(false), |
| 27 num_(0) { |
| 28 } |
| 29 |
| 30 bool Done() const { return done_; } |
| 31 uint32_t Next(); |
| 32 static bool IsValid(uint32_t num); |
| 33 |
| 34 private: |
| 35 bool invalid_only_; |
| 36 bool done_; |
| 37 uint32_t num_; |
| 38 }; |
| 39 |
| 40 } // namespace |
| 41 |
| 42 #endif // SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_ITERATOR_H__ |
OLD | NEW |