Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Side by Side Diff: sandbox/linux/bpf_dsl/dump_bpf.cc

Issue 1053603002: Introduce linux_filter.h and replace #include <linux/filter.h> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sandbox/linux/bpf_dsl/codegen_unittest.cc ('k') | sandbox/linux/bpf_dsl/policy_compiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "sandbox/linux/bpf_dsl/dump_bpf.h" 5 #include "sandbox/linux/bpf_dsl/dump_bpf.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "sandbox/linux/bpf_dsl/codegen.h" 9 #include "sandbox/linux/bpf_dsl/codegen.h"
10 #include "sandbox/linux/bpf_dsl/trap_registry.h" 10 #include "sandbox/linux/bpf_dsl/trap_registry.h"
11 #include "sandbox/linux/system_headers/linux_filter.h"
11 #include "sandbox/linux/system_headers/linux_seccomp.h" 12 #include "sandbox/linux/system_headers/linux_seccomp.h"
12 13
13 namespace sandbox { 14 namespace sandbox {
14 namespace bpf_dsl { 15 namespace bpf_dsl {
15 16
16 void DumpBPF::PrintProgram(const CodeGen::Program& program) { 17 void DumpBPF::PrintProgram(const CodeGen::Program& program) {
17 for (CodeGen::Program::const_iterator iter = program.begin(); 18 for (CodeGen::Program::const_iterator iter = program.begin();
18 iter != program.end(); 19 iter != program.end();
19 ++iter) { 20 ++iter) {
20 int ip = (int)(iter - program.begin()); 21 int ip = (int)(iter - program.begin());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 fprintf(stderr, "errno = %d\n", iter->k & SECCOMP_RET_DATA); 73 fprintf(stderr, "errno = %d\n", iter->k & SECCOMP_RET_DATA);
73 } else if ((iter->k & SECCOMP_RET_ACTION) == SECCOMP_RET_TRACE) { 74 } else if ((iter->k & SECCOMP_RET_ACTION) == SECCOMP_RET_TRACE) {
74 fprintf(stderr, "Trace #%d\n", iter->k & SECCOMP_RET_DATA); 75 fprintf(stderr, "Trace #%d\n", iter->k & SECCOMP_RET_DATA);
75 } else if (iter->k == SECCOMP_RET_ALLOW) { 76 } else if (iter->k == SECCOMP_RET_ALLOW) {
76 fprintf(stderr, "Allowed\n"); 77 fprintf(stderr, "Allowed\n");
77 } else { 78 } else {
78 fprintf(stderr, "???\n"); 79 fprintf(stderr, "???\n");
79 } 80 }
80 break; 81 break;
81 case BPF_ALU: 82 case BPF_ALU:
82 fprintf(stderr, BPF_OP(iter->code) == BPF_NEG 83 if (BPF_OP(iter->code) == BPF_NEG) {
83 ? "A := -A\n" : "A := A %s 0x%x\n", 84 fprintf(stderr, "A := -A\n");
84 BPF_OP(iter->code) == BPF_ADD ? "+" : 85 } else {
85 BPF_OP(iter->code) == BPF_SUB ? "-" : 86 fprintf(stderr, "A := A %s 0x%x\n",
86 BPF_OP(iter->code) == BPF_MUL ? "*" : 87 BPF_OP(iter->code) == BPF_ADD ? "+" :
87 BPF_OP(iter->code) == BPF_DIV ? "/" : 88 BPF_OP(iter->code) == BPF_SUB ? "-" :
88 BPF_OP(iter->code) == BPF_MOD ? "%" : 89 BPF_OP(iter->code) == BPF_MUL ? "*" :
89 BPF_OP(iter->code) == BPF_OR ? "|" : 90 BPF_OP(iter->code) == BPF_DIV ? "/" :
90 BPF_OP(iter->code) == BPF_XOR ? "^" : 91 BPF_OP(iter->code) == BPF_MOD ? "%" :
91 BPF_OP(iter->code) == BPF_AND ? "&" : 92 BPF_OP(iter->code) == BPF_OR ? "|" :
92 BPF_OP(iter->code) == BPF_LSH ? "<<" : 93 BPF_OP(iter->code) == BPF_XOR ? "^" :
93 BPF_OP(iter->code) == BPF_RSH ? ">>" : "???", 94 BPF_OP(iter->code) == BPF_AND ? "&" :
94 (int)iter->k); 95 BPF_OP(iter->code) == BPF_LSH ? "<<" :
96 BPF_OP(iter->code) == BPF_RSH ? ">>" : "???",
97 (int)iter->k);
98 }
95 break; 99 break;
96 default: 100 default:
97 fprintf(stderr, "???\n"); 101 fprintf(stderr, "???\n");
98 break; 102 break;
99 } 103 }
100 } 104 }
101 return; 105 return;
102 } 106 }
103 107
104 } // namespace bpf_dsl 108 } // namespace bpf_dsl
105 } // namespace sandbox 109 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/linux/bpf_dsl/codegen_unittest.cc ('k') | sandbox/linux/bpf_dsl/policy_compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698