# 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 ctypes import create_string_buffer, sizeof
from pyisis.bstr import memspan                             # pylint: disable=E0611
from pyisis.lib.util import bchr, memcpy, buffer3, stringify3, tlvwrb
import errno
import logbook
import pyisis.adjacency as adjacency
import pyisis.lib.bpf as bpf
import pyisis.clns as clns
import pyisis.lib.debug as debug
import pyisis.lsp as lsp
import pyisis.pdu as pdu
import pyisis.lib.rawsock as rawsock
import pyisis.lib.timers as timers
import pyisis.tlv as tlv
import pyisis.lib.util as util
import select
import sys
import threading
import traceback
                import pdb
            return

        #--------------------------------------------
        # Validate Ethernet Payload and Frame Length
        #--------------------------------------------

        # XXX this is for ethernet only adjust when we get p2p
        # Validate ethernet length field
        payload_len = frame.ether_type
        if payload_len < 46:
            logger.warning("Recived short ethernet frame length {}", payload_len)

        if payload_len + 14 > len(pkt):
            logger.warning("Recived ethernet frame with incorrect length: {} > {}",
                           payload_len,
                           len(pkt) - 14)
        if frame.pdu_len + sizeof(pdu.LLCHeader) > payload_len:
            logger.warning("Recived pkt smaller ({}) than pdu_len ({})",
                           payload_len,
                           frame.pdu_len)

        # Strip off any extra left from padded ethernet frame
        payload_len = frame.pdu_len + sizeof(pdu.LLCHeader)

        #-----------------------------------
        # Get CLNS buffer and TLV space ptr
        #-----------------------------------

        clnsoff = sizeof(pdu.LLCHeader)
        payload = buffer3(pkt, sizeof(pdu.EtherHeader))

# 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/link.py
from ctypes import create_string_buffer, sizeof
from pyisis.bstr import memspan                             # pylint: disable=E0611
from pyisis.lib.util import bchr, memcpy, buffer3, stringify3, tlvwrb
import errno
import logbook
import pyisis.adjacency as adjacency
import pyisis.lib.bpf as bpf
import pyisis.clns as clns
import pyisis.lib.debug as debug
import pyisis.lsp as lsp
import pyisis.pdu as pdu
import pyisis.lib.rawsock as rawsock
import pyisis.lib.timers as timers
import pyisis.tlv as tlv
import pyisis.lib.util as util
import select
import sys
import threading
import traceback
                import pdb

            return

        #--------------------------------------------
        # Validate Ethernet Payload and Frame Length
        #--------------------------------------------

        # XXX this is for ethernet only adjust when we get p2p
        # Validate ethernet length field
        payload_len = frame.ether_type
        if payload_len < 46:
            logger.warning("Recived short ethernet frame length {}", payload_len)

        if payload_len + 14 > len(pkt):
            logger.warning("Recived ethernet frame with incorrect length: {} > {}",
                           payload_len,
                           len(pkt) - 14)
        if frame.pdu_len + sizeof(pdu.LLCHeader) > payload_len:
            logger.warning("Recived pkt smaller ({}) than pdu_len ({})",
                           payload_len,
                           frame.pdu_len)

        # Strip off any extra left from padded ethernet frame
        payload_len = frame.pdu_len + sizeof(pdu.LLCHeader)

        #-----------------------------------
        # Get CLNS buffer and TLV space ptr
        #-----------------------------------

        clnsoff = sizeof(pdu.LLCHeader)
        payload = buffer3(pkt, sizeof(pdu.EtherHeader))

        pdubuf = buffer3(payload, clnsoff, payload_len - clnsoff)