# Path: pyisis/lib/util.py
# def stringify3 (b):
#     if type(b) == memoryview:
#         return b.tobytes()
#     else:
#         return str(buffer(b))                           # pylint: disable=E0602


from pyisis.lib.util import stringify3
import logbook
import threading
import pyisis.clns as clns
import pyisis.lib.timers as timers
import pyisis.tlv as tlv
        # XXX this won't work if too many neighbors
        vlist = []
        with self.rlock:
            for adj in self.adjlist:
                if adj.state == adj.ADJ_STATE_DOWN:
                    continue
                vlist.append(adj.snpa)
        return b"".join(vlist)

    def neighbor_iih_tlv_iter (self):
        with self.rlock:
            for adj in self.adjlist:
                if adj.state != Adjacency.ADJ_STATE_DOWN:
                    yield adj.snpa

    def has_up_adjacency (self, snpa):
        # Need to handle p2p link here.
        with self.rlock:
            return (snpa in self.bysnpa and
                    self.bysnpa[snpa].state == Adjacency.ADJ_STATE_UP)

    def up_iter (self):
        with self:
            for adj in self.adjlist:
                if adj.state == adj.ADJ_STATE_UP:
                    yield adj

    def update_adjacency (self, iih, tlvs):
        with self.rlock:
            snpa = stringify3(iih.ether_src)

# Path: pyisis/lib/util.py
# def stringify3 (b):
#     if type(b) == memoryview:
#         return b.tobytes()
#     else:
#         return str(buffer(b))                           # pylint: disable=E0602


# Path: pyisis/adjacency.py
from pyisis.lib.util import stringify3
import logbook
import threading
import pyisis.clns as clns
import pyisis.lib.timers as timers
import pyisis.tlv as tlv

        # XXX this won't work if too many neighbors
        vlist = []
        with self.rlock:
            for adj in self.adjlist:
                if adj.state == adj.ADJ_STATE_DOWN:
                    continue
                vlist.append(adj.snpa)
        return b"".join(vlist)

    def neighbor_iih_tlv_iter (self):
        with self.rlock:
            for adj in self.adjlist:
                if adj.state != Adjacency.ADJ_STATE_DOWN:
                    yield adj.snpa

    def has_up_adjacency (self, snpa):
        # Need to handle p2p link here.
        with self.rlock:
            return (snpa in self.bysnpa and
                    self.bysnpa[snpa].state == Adjacency.ADJ_STATE_UP)

    def up_iter (self):
        with self:
            for adj in self.adjlist:
                if adj.state == adj.ADJ_STATE_UP:
                    yield adj

    def update_adjacency (self, iih, tlvs):
        with self.rlock:
            snpa = stringify3(iih.ether_src)

            source_id = stringify3(iih.source_id)