# Path: pyisis/lib/util.py
# def cast_as (bufptr, ctype):
#     try:
#         return ctype.from_buffer(bufptr)
#     except TypeError:
#         return cast(bufptr, POINTER(ctype)).contents
# 
# def tlvrdb (val):
#     # In python3 byte strings return integers when indexed
#     return val


from ctypes import BigEndianStructure, create_string_buffer
from ctypes import c_uint8, c_uint16, c_uint32, sizeof
from pyisis.lib.util import cast_as, tlvrdb
import pyisis.clns as clns
import sys
    _pack_ = 1
    _fields_ = [ ("ether_dst", c_uint8 * 6),
                 ("ether_src", c_uint8 * 6),
                 ("ether_type", c_uint16), ]

    def __str__ (self):
        return "Ether(dst={},src={},typelen={})".format(clns.iso_decode(self.ether_dst),
                                                        clns.iso_decode(self.ether_src),
                                                        self.ether_type)


class LLCHeader (BigEndianStructure):
    _pack_ = 1
    _fields_ = [ ("llc_dsap", c_uint8),
                 ("llc_ssap", c_uint8),
                 ("llc_control", c_uint8) ]

    def __str__ (self):
        return "LLC(dsap={:#02x},ssap={:#02x},ctrl={:#02x})".format(self.llc_dsap,
                                                                    self.llc_ssap,
                                                                    self.llc_control)


class LLCFrame (BigEndianStructure):
    _pack_ = 1
    _anonymous_ = ("mac_header", "llc_header")
    _fields_ = [ ("mac_header", EtherHeader),
                 ("llc_header", LLCHeader), ]



# Path: pyisis/lib/util.py
# def cast_as (bufptr, ctype):
#     try:
#         return ctype.from_buffer(bufptr)
#     except TypeError:
#         return cast(bufptr, POINTER(ctype)).contents
# 
# def tlvrdb (val):
#     # In python3 byte strings return integers when indexed
#     return val


# Path: pyisis/pdu.py
from ctypes import BigEndianStructure, create_string_buffer
from ctypes import c_uint8, c_uint16, c_uint32, sizeof
from pyisis.lib.util import cast_as, tlvrdb
import pyisis.clns as clns
import sys

    _pack_ = 1
    _fields_ = [ ("ether_dst", c_uint8 * 6),
                 ("ether_src", c_uint8 * 6),
                 ("ether_type", c_uint16), ]

    def __str__ (self):
        return "Ether(dst={},src={},typelen={})".format(clns.iso_decode(self.ether_dst),
                                                        clns.iso_decode(self.ether_src),
                                                        self.ether_type)


class LLCHeader (BigEndianStructure):
    _pack_ = 1
    _fields_ = [ ("llc_dsap", c_uint8),
                 ("llc_ssap", c_uint8),
                 ("llc_control", c_uint8) ]

    def __str__ (self):
        return "LLC(dsap={:#02x},ssap={:#02x},ctrl={:#02x})".format(self.llc_dsap,
                                                                    self.llc_ssap,
                                                                    self.llc_control)


class LLCFrame (BigEndianStructure):
    _pack_ = 1
    _anonymous_ = ("mac_header", "llc_header")
    _fields_ = [ ("mac_header", EtherHeader),
                 ("llc_header", LLCHeader), ]



class CLNSHeader (BigEndianStructure):