# Path: pyisis/lib/util.py
# def as_string (cobj):
# def cast_as (bufptr, ctype):
# def copy_as (s, ctype):
# def copy_cobj (s, ctype):
# def memcpy (dst, src):
#     def _chr3 (val):
#     def buffer3 (val, off=None, sz=None):
#     def tlvrdb (val):
#     def buffer3 (val, off=None, l=None):
#     def stringify3 (b):
# def debug_exception ():
#     def __init__ (self):
#     def elapsed (self):
#     def __str__ (self):
#     def __init__ (self, lifetime):
#     def reset (self, lifetime):
#     def expire_at (self):
#     def timeleft (self):
#     def __init__ (self):
#     def __enter__ (self):
#     def __exit__ (self, *args):
#     def held (self):
#     def acquire (self, blocking=True):
#     def release (self):
# def debug_after (count=1):
#     def __enter__ (self):
#     def __exit__ (self, *args):
# class CPUTimer (object):
# class Lifetime (object):
# class QueryLock (object):
# class NoLock (object):


from pyisis.lib.util import xrange3
from fcntl import ioctl
from ctypes import cast, sizeof, POINTER
from ctypes import Structure
from ctypes import c_uint8, c_uint16, c_uint32, c_uint, c_void_p
from pyisis.bstr import writev                              # pylint: disable=E0611
import errno
import ipaddress
import os
import re
import struct
import subprocess
import logbook
import pyisis.clns as clns
BPF_LEN = 0x80
BPF_MSH = 0xa0


# alu/jmp fields
def bpf_op(code):
    return ((code) & 0xf0)
BPF_ADD = 0x00
BPF_SUB = 0x10
BPF_MUL = 0x20
BPF_DIV = 0x30
BPF_OR = 0x40
BPF_AND = 0x50
BPF_LSH = 0x60
BPF_RSH = 0x70
BPF_NEG = 0x80
BPF_JA = 0x00
BPF_JEQ = 0x10
BPF_JGT = 0x20
BPF_JGE = 0x30
BPF_JSET = 0x40


def bpf_src(code):
    return ((code) & 0x08)
BPF_K = 0x00
BPF_X = 0x08


# ret - BPF_K and BPF_X also apply

# Path: pyisis/lib/util.py
# def as_string (cobj):
# def cast_as (bufptr, ctype):
# def copy_as (s, ctype):
# def copy_cobj (s, ctype):
# def memcpy (dst, src):
#     def _chr3 (val):
#     def buffer3 (val, off=None, sz=None):
#     def tlvrdb (val):
#     def buffer3 (val, off=None, l=None):
#     def stringify3 (b):
# def debug_exception ():
#     def __init__ (self):
#     def elapsed (self):
#     def __str__ (self):
#     def __init__ (self, lifetime):
#     def reset (self, lifetime):
#     def expire_at (self):
#     def timeleft (self):
#     def __init__ (self):
#     def __enter__ (self):
#     def __exit__ (self, *args):
#     def held (self):
#     def acquire (self, blocking=True):
#     def release (self):
# def debug_after (count=1):
#     def __enter__ (self):
#     def __exit__ (self, *args):
# class CPUTimer (object):
# class Lifetime (object):
# class QueryLock (object):
# class NoLock (object):


# Path: pyisis/lib/bpf.py
from pyisis.lib.util import xrange3
from fcntl import ioctl
from ctypes import cast, sizeof, POINTER
from ctypes import Structure
from ctypes import c_uint8, c_uint16, c_uint32, c_uint, c_void_p
from pyisis.bstr import writev                              # pylint: disable=E0611
import errno
import ipaddress
import os
import re
import struct
import subprocess
import logbook
import pyisis.clns as clns

BPF_LEN = 0x80
BPF_MSH = 0xa0


# alu/jmp fields
def bpf_op(code):
    return ((code) & 0xf0)
BPF_ADD = 0x00
BPF_SUB = 0x10
BPF_MUL = 0x20
BPF_DIV = 0x30
BPF_OR = 0x40
BPF_AND = 0x50
BPF_LSH = 0x60
BPF_RSH = 0x70
BPF_NEG = 0x80
BPF_JA = 0x00
BPF_JEQ = 0x10
BPF_JGT = 0x20
BPF_JGE = 0x30
BPF_JSET = 0x40


def bpf_src(code):
    return ((code) & 0x08)
BPF_K = 0x00
BPF_X = 0x08


# ret - BPF_K and BPF_X also apply

def bpf_rval(code):