# 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 sizeof
from pyisis.bstr import bchr, memspan                       # pylint: disable=E0611
from pyisis.lib.util import stringify3, tlvrdb, xrange3
import logbook
import pyisis.clns as clns
import pyisis.lib.debug as debug
import pyisis.pdu as pdu
import pyisis.lib.timers as timers
import pyisis.tlv as tlv
import pyisis.lib.util as util
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import absolute_import, division, nested_scopes, print_function, unicode_literals


logger = logbook.Logger(__name__)

ZERO_MAX_AGE = 60
MAX_AGE = 1200


def get_lsp_number (lsphdr):
    return int(lsphdr.lspid[clns.CLNS_LSP_SEGMENT_OFF])


def lsp_id_str (lsp):
    return clns.iso_decode(lsp.lspid)


class LSPSegment (object):
    def __init__ (self, inst, lindex, pdubuf, tlvs):
        self.inst = inst
        self.uproc = inst.update[lindex]
        self.lindex = lindex
        self.pdubuf = bytearray(pdubuf)

# 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/lsp.py
from ctypes import sizeof
from pyisis.bstr import bchr, memspan                       # pylint: disable=E0611
from pyisis.lib.util import stringify3, tlvrdb, xrange3
import logbook
import pyisis.clns as clns
import pyisis.lib.debug as debug
import pyisis.pdu as pdu
import pyisis.lib.timers as timers
import pyisis.tlv as tlv
import pyisis.lib.util as util

#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import absolute_import, division, nested_scopes, print_function, unicode_literals


logger = logbook.Logger(__name__)

ZERO_MAX_AGE = 60
MAX_AGE = 1200


def get_lsp_number (lsphdr):
    return int(lsphdr.lspid[clns.CLNS_LSP_SEGMENT_OFF])


def lsp_id_str (lsp):
    return clns.iso_decode(lsp.lspid)


class LSPSegment (object):
    def __init__ (self, inst, lindex, pdubuf, tlvs):
        self.inst = inst
        self.uproc = inst.update[lindex]
        self.lindex = lindex
        self.pdubuf = bytearray(pdubuf)

        self.lsphdr = util.cast_as(self.pdubuf, pdu.LSPPDU)