• Home
  • Raw
  • Download

Lines Matching refs:ffi

34 local ffi = require('ffi')
44 local BPF = ffi.typeof('struct bpf')
45 local HELPER = ffi.typeof('struct bpf_func_id')
65 [ffi.new] = true,
92 insn = ffi.new('struct bpf_insn[4096]'),
104 local stack_top = (stackslots + 1) * ffi.sizeof('uint64_t')
119 vinfo.spill = (var + 1) * ffi.sizeof('uint64_t') -- Index by (variable number) * (register width)
186 vtype = ffi.typeof(const)
222 elseif vtype and ffi.sizeof(vtype) == 8 then
224 emit(BPF.LD + BPF.DW, reg, 0, 0, ffi.cast('uint32_t', src.const))
225 emit(0, 0, 0, 0, ffi.cast('uint32_t', bit.rshift(bit.rshift(src.const, 16), 16)))
251 local w = ffi.sizeof(vtype)
277 local as_u32 = ffi.new('uint32_t [1]')
278 local sub = blank:sub(sp+1, sp+ffi.sizeof(as_u32))
279 ffi.copy(as_u32, sub, #sub)
281 sp = sp + ffi.sizeof(as_u32)
352 local base, size = V[a].const.__base, math.min(#b, ffi.sizeof(V[a].type))
358 local as_u32 = ffi.new('uint32_t [1]')
359 local sub = b:sub(sp+1, sp+ffi.sizeof(as_u32))
360 ffi.copy(as_u32, sub, #sub)
365 sp = sp + ffi.sizeof(as_u32)
402 local imm = ffi.new('uint32_t[1]')
403 ffi.copy(imm, b, #b)
492 if w > 1 and ffi.abi('le') then -- LD_ABS has htonl() semantics, reverse
499 if ffi.abi('le') then -- LD_ABS has htonl() semantics, reverse
505 if ffi.abi('le') then -- LD_ABS has htonl() semantics, reverse
519 if w > 1 and ffi.abi('le') then -- LD_ABS has htonl() semantics, reverse
533 emit(BPF.LD + const_width[w], dst_reg, src_type, 0, ffi.cast('uint32_t', imm))
535 emit(0, 0, 0, 0, ffi.cast('uint32_t', bit.lshift(bit.lshift(imm, 16), 16)))
558 local w = ffi.sizeof(vtype)
636 vreg(map_var, 1, true, ffi.typeof('uint64_t'))
638 LD_IMM_X(1, BPF.PSEUDO_MAP_FD, map.fd, ffi.sizeof(V[map_var].type))
641 local key_size = ffi.sizeof(map.key_type)
666 …assert(key_size == ffi.sizeof(V[key].type), 'VAR '..key..' type incompatible with BPF map key type…
682 vreg(dst, 0, true, ffi.typeof('uint8_t *'))
700 if V[src].type == ffi.typeof('void') then
710 local val_size = ffi.sizeof(map.val_type)
714 local sp = stack_top + ffi.sizeof(map.key_type) + val_size
746 if val_size ~= ffi.sizeof(V[src].type) then
748 src, V[src].type, map.val_type, val_size, ffi.sizeof(V[src].type))
767 vset(a, nil, c, ffi.typeof('int32_t'))
769 vset(a, nil, c, ffi.typeof('uint64_t'))
773 vset(a, nil, d, ffi.typeof('int16_t'))
777 local ct = ffi.typeof(c)
778 if ffi.istype(ct, ffi.typeof('uint64_t')) or ffi.istype(ct, ffi.typeof('int64_t')) then
789 local vtype = (d < 1) and ffi.typeof('void') or ffi.typeof('uint8_t')
793 vset(a, nil, c, ffi.typeof('const char[?]'))
858 local w = ffi.sizeof(vinfo.__dissector)
895 local w = ffi.sizeof(vinfo.__dissector)
943 local ofs,bpos = ffi.offsetof(base.__dissector, c)
983 local vtype = base.__dissector and base.__dissector or ffi.typeof('uint8_t')
1003 local vtype = base.__dissector and base.__dissector or ffi.typeof('uint8_t')
1017 local ofs,bpos,bsize = ffi.offsetof(base.__dissector, c)
1021 ofs,bpos,bsize = ffi.offsetof(base.__dissector, c)
1069 if ffi.istype(base.__dissector, ffi.typeof('struct sk_buff')) then
1073 V[a].const = {__dissector = ffi.typeof('uint8_t')}
1102 local jmpi = ffi.new('struct bpf_insn', code.insn[code.pc-1])
1290 local off = tonumber(ffi.cast('int16_t', ins.off)) -- Reinterpret as signed
1349 local env = { pkt=proto.pkt, eth=proto.pkt, BPF=BPF, ffi=ffi }
1401 local next_key = ffi.new(ffi.typeof(t.key))
1407 cur_key = ffi.new(ffi.typeof(t.key))
1450 return ffi.new(map.val_type, map.val[0])
1525 ffi.gc(reader, function ()
1540 if not key_ctype then key_ctype = ffi.typeof('uint32_t') end
1541 if not val_ctype then val_ctype = ffi.typeof('uint32_t') end
1545 key_ctype = ffi.typeof('int32_t')
1546 val_ctype = ffi.typeof('struct bpf_stacktrace')
1548 …local fd, err = S.bpf_map_create(S.c.BPF_MAP[type], ffi.sizeof(key_ctype), ffi.sizeof(val_ctype), …
1552 key = ffi.new(ffi.typeof('$ [1]', key_ctype)),
1553 val = ffi.new(ffi.typeof('$ [1]', val_ctype)),
1574 elseif ffi.istype(S.t.fd, sock) then -- luacheck: ignore
1616 tonumber(ffi.cast('uint32_t', sym)))