Home | History | Annotate | Download | only in seccomp-bpf

Lines Matching refs:state

17 struct State {
18 State(const std::vector<struct sock_filter>& p,
28 DISALLOW_IMPLICIT_CONSTRUCTORS(State);
222 void Ld(State* state, const struct sock_filter& insn, const char** err) {
229 memcpy(&state->accumulator,
230 reinterpret_cast<const char*>(&state->data) + insn.k,
236 state->acc_is_valid = true;
240 void Jmp(State* state, const struct sock_filter& insn, const char** err) {
242 if (state->ip + insn.k + 1 >= state->program.size() ||
243 state->ip + insn.k + 1 <= state->ip) {
248 state->ip += insn.k;
250 if (BPF_SRC(insn.code) != BPF_K || !state->acc_is_valid ||
251 state->ip + insn.jt + 1 >= state->program.size() ||
252 state->ip + insn.jf + 1 >= state->program.size()) {
257 if (state->accumulator == insn.k) {
258 state->ip += insn.jt;
260 state->ip += insn.jf;
264 if (state->accumulator > insn.k) {
265 state->ip += insn.jt;
267 state->ip += insn.jf;
271 if (state->accumulator >= insn.k) {
272 state->ip += insn.jt;
274 state->ip += insn.jf;
278 if (state->accumulator & insn.k) {
279 state->ip += insn.jt;
281 state->ip += insn.jf;
290 uint32_t Ret(State*, const struct sock_filter& insn, const char** err) {
298 void Alu(State* state, const struct sock_filter& insn, const char** err) {
300 state->accumulator = -state->accumulator;
309 state->accumulator += insn.k;
312 state->accumulator -= insn.k;
315 state->accumulator *= insn.k;
322 state->accumulator /= insn.k;
329 state->accumulator %= insn.k;
332 state->accumulator |= insn.k;
335 state->accumulator ^= insn.k;
338 state->accumulator &= insn.k;
345 state->accumulator <<= insn.k;
352 state->accumulator >>= insn.k;
406 for (State state(program, data); !*err; ++state.ip) {
407 if (state.ip >= program.size()) {
411 const struct sock_filter& insn = program[state.ip];
414 Ld(&state, insn, err);
417 Jmp(&state, insn, err);
420 uint32_t r = Ret(&state, insn, err);
436 Alu(&state, insn, err);