#!/usr/bin/env python3
#
#  Copyright (c) 2016, The OpenThread Authors.
#  All rights reserved.
#
#  Redistribution and use in source and binary forms, with or without
#  modification, are permitted provided that the following conditions are met:
#  1. Redistributions of source code must retain the above copyright
#     notice, this list of conditions and the following disclaimer.
#  2. Redistributions in binary form must reproduce the above copyright
#     notice, this list of conditions and the following disclaimer in the
#     documentation and/or other materials provided with the distribution.
#  3. Neither the name of the copyright holder nor the
#     names of its contributors may be used to endorse or promote products
#     derived from this software without specific prior written permission.
#
#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
#  POSSIBILITY OF SUCH DAMAGE.
#

import io
import random
import struct
import unittest

import common
import network_layer


def any_eid():
    return bytearray([random.getrandbits(8) for _ in range(16)])


def any_mac_extended_address():
    return bytearray([random.getrandbits(8) for _ in range(8)])


def any_rloc16():
    return random.getrandbits(16)


def any_ml_eid():
    return bytearray([random.getrandbits(8) for _ in range(8)])


def any_status():
    return random.getrandbits(1)


def any_seconds():
    return random.getrandbits(32)


def any_id_sequence():
    return random.getrandbits(8)


def any_router_id_mask():
    return random.getrandbits(64)


def any_options(count=None):
    count = count if count is not None else random.randint(0, 255)
    return [random.getrandbits(8) for _ in range(count)]


def any_tlv_data(length=None):
    _type = random.getrandbits(8)
    length = length if length is not None else random.getrandbits(8)
    value = bytearray([random.getrandbits(8) for _ in range(length)])

    return bytearray([_type, length]) + value


def any_tlvs_data(count=None):
    count = count if count is not None else random.randint(0, 16)
    data = bytearray()

    for _ in range(count):
        data += any_tlv_data(random.randint(1, 15))

    return data


class TestTargetEid(unittest.TestCase):

    def test_should_return_eid_value_when_eid_property_is_called(self):
        # GIVEN
        eid = any_eid()

        target_eid = network_layer.TargetEid(eid)

        # WHEN
        actual_eid = target_eid.eid

        # THEN
        self.assertEqual(eid, actual_eid)

    def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(self):
        # GIVEN
        eid = any_eid()

        target_eid = network_layer.TargetEid(eid)

        # THEN
        self.assertEqual(target_eid, network_layer.TargetEid(eid))


class TestTargetEidFactory(unittest.TestCase):

    def test_should_create_TargetEid_from_bytearray_when_parse_method_is_called(self):
        # GIVEN
        eid = any_eid()

        factory = network_layer.TargetEidFactory()

        # WHEN
        target_eid = factory.parse(io.BytesIO(eid), common.MessageInfo())

        # THEN
        self.assertTrue(isinstance(target_eid, network_layer.TargetEid))
        self.assertEqual(eid, target_eid.eid)


class TestMacExtendedAddress(unittest.TestCase):

    def test_should_return_mac_address_value_when_mac_address_property_is_called(self):
        # GIVEN
        mac_address = any_mac_extended_address()

        mac_extended_address = network_layer.MacExtendedAddress(mac_address)

        # WHEN
        actual_mac_address = mac_extended_address.mac_address

        # THEN
        self.assertEqual(mac_address, actual_mac_address)

    def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(self):
        # GIVEN
        mac_address = any_mac_extended_address()

        mac_extended_address = network_layer.MacExtendedAddress(mac_address)

        # THEN
        self.assertEqual(mac_extended_address, network_layer.MacExtendedAddress(mac_address))


class TestMacExtendedAddressFactory(unittest.TestCase):

    def test_should_create_MacExtendedAddress_from_bytearray_when_parse_method_is_called(self):
        # GIVEN
        mac_address = any_mac_extended_address()

        factory = network_layer.MacExtendedAddressFactory()

        # WHEN
        mac_extended_address = factory.parse(io.BytesIO(mac_address), common.MessageInfo())

        # THEN
        self.assertTrue(isinstance(mac_extended_address, network_layer.MacExtendedAddress))
        self.assertEqual(mac_address, mac_extended_address.mac_address)


class TestRloc16(unittest.TestCase):

    def test_should_return_rloc16_value_when_rloc16_property_is_called(self):
        # GIVEN
        rloc16 = any_rloc16()

        rloc16_obj = network_layer.Rloc16(rloc16)

        # WHEN
        actual_rloc16 = rloc16_obj.rloc16

        # THEN
        self.assertEqual(rloc16, actual_rloc16)

    def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(self):
        # GIVEN
        rloc16 = any_rloc16()

        rloc16_obj = network_layer.Rloc16(rloc16)

        # THEN
        self.assertEqual(rloc16_obj, network_layer.Rloc16(rloc16))


class TestRloc16Factory(unittest.TestCase):

    def test_should_create_Rloc16_from_bytearray_when_parse_method_is_called(self):
        # GIVEN
        rloc16 = any_rloc16()

        factory = network_layer.Rloc16Factory()

        data = bytearray(struct.pack(">H", rloc16))

        # WHEN
        rloc16_obj = factory.parse(io.BytesIO(data), common.MessageInfo())

        # THEN
        self.assertTrue(isinstance(rloc16_obj, network_layer.Rloc16))
        self.assertEqual(rloc16, rloc16_obj.rloc16)


class TestMlEid(unittest.TestCase):

    def test_should_return_ml_eid_value_when_ml_eid_property_is_called(self):
        # GIVEN
        ml_eid = any_ml_eid()

        ml_eid_obj = network_layer.MlEid(ml_eid)

        # WHEN
        actual_ml_eid = ml_eid_obj.ml_eid

        # THEN
        self.assertEqual(ml_eid, actual_ml_eid)

    def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(self):
        # GIVEN
        ml_eid = any_ml_eid()

        ml_eid_obj = network_layer.MlEid(ml_eid)

        # THEN
        self.assertEqual(ml_eid_obj, network_layer.MlEid(ml_eid))


class TestMlEidFactory(unittest.TestCase):

    def test_should_create_MlEid_from_bytearray_when_parse_method_is_called(self):
        # GIVEN
        ml_eid = any_ml_eid()

        factory = network_layer.MlEidFactory()

        # WHEN
        ml_eid_obj = factory.parse(io.BytesIO(ml_eid), common.MessageInfo())

        # THEN
        self.assertTrue(isinstance(ml_eid_obj, network_layer.MlEid))
        self.assertEqual(ml_eid, ml_eid_obj.ml_eid)


class TestStatus(unittest.TestCase):

    def test_should_return_status_value_when_status_property_is_called(self):
        # GIVEN
        status = any_status()

        status_obj = network_layer.Status(status)

        # WHEN
        actual_status = status_obj.status

        # THEN
        self.assertEqual(status, actual_status)

    def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(self):
        # GIVEN
        status = any_status()

        status_obj = network_layer.Status(status)

        # THEN
        self.assertEqual(status_obj, network_layer.Status(status))


class TestStatusFactory(unittest.TestCase):

    def test_should_create_Status_from_bytearray_when_parse_method_is_called(self):
        # GIVEN
        status = any_status()

        factory = network_layer.StatusFactory()

        data = bytearray([status])

        # WHEN
        status_obj = factory.parse(io.BytesIO(data), common.MessageInfo())

        # THEN
        self.assertTrue(isinstance(status_obj, network_layer.Status))
        self.assertEqual(status, status_obj.status)


class TestTimeSinceLastTransaction(unittest.TestCase):

    def test_should_return_seconds_value_when_seconds_property_is_called(self):
        # GIVEN
        seconds = any_seconds()

        time_since_last_transaction = network_layer.TimeSinceLastTransaction(seconds)

        # WHEN
        actual_seconds = time_since_last_transaction.seconds

        # THEN
        self.assertEqual(seconds, actual_seconds)

    def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(self):
        # GIVEN
        seconds = any_seconds()

        time_since_last_transaction = network_layer.TimeSinceLastTransaction(seconds)

        # THEN
        self.assertEqual(
            time_since_last_transaction,
            network_layer.TimeSinceLastTransaction(seconds),
        )


class TestTimeSinceLastTransactionFactory(unittest.TestCase):

    def test_should_create_TimeSinceLastTransaction_from_bytearray_when_parse_method_is_called(self):
        # GIVEN
        seconds = any_seconds()

        factory = network_layer.TimeSinceLastTransactionFactory()

        data = bytearray(struct.pack(">L", seconds))

        # WHEN
        time_since_last_transaction = factory.parse(io.BytesIO(data), common.MessageInfo())

        # THEN
        self.assertTrue(isinstance(
            time_since_last_transaction,
            network_layer.TimeSinceLastTransaction,
        ))
        self.assertEqual(seconds, time_since_last_transaction.seconds)


class TestRouterMask(unittest.TestCase):

    def test_should_return_id_sequence_value_when_id_sequence_property_is_called(self):
        # GIVEN
        id_sequence = any_id_sequence()

        router_mask = network_layer.RouterMask(id_sequence, any_router_id_mask())

        # WHEN
        actual_id_sequence = router_mask.id_sequence

        # THEN
        self.assertEqual(id_sequence, actual_id_sequence)

    def test_should_return_router_id_mask_value_when_router_id_mask_property_is_called(self):
        # GIVEN
        router_id_mask = any_router_id_mask()

        router_mask = network_layer.RouterMask(any_id_sequence(), router_id_mask)

        # WHEN
        actual_router_id_mask = router_mask.router_id_mask

        # THEN
        self.assertEqual(router_id_mask, actual_router_id_mask)

    def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(self):
        # GIVEN
        id_sequence = any_id_sequence()
        router_id_mask = any_router_id_mask()

        router_mask = network_layer.RouterMask(id_sequence, router_id_mask)

        # THEN
        self.assertEqual(router_mask, network_layer.RouterMask(id_sequence, router_id_mask))


class TestRouterMaskFactory(unittest.TestCase):

    def test_should_create_RouterMask_from_bytearray_when_parse_method_is_called(self):
        # GIVEN
        id_sequence = any_id_sequence()
        router_id_mask = any_router_id_mask()

        factory = network_layer.RouterMaskFactory()

        data = bytearray([id_sequence]) + struct.pack(">Q", router_id_mask)

        # WHEN
        router_mask = factory.parse(io.BytesIO(data), common.MessageInfo())

        # THEN
        self.assertTrue(isinstance(router_mask, network_layer.RouterMask))
        self.assertEqual(id_sequence, router_mask.id_sequence)
        self.assertEqual(router_id_mask, router_mask.router_id_mask)


class TestNdOption(unittest.TestCase):

    def test_should_return_options_value_when_options_property_is_called(self):
        # GIVEN
        options = any_options()

        nd_option = network_layer.NdOption(options)

        # WHEN
        actual_options = nd_option.options

        # THEN
        self.assertEqual(options, actual_options)

    def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(self):
        # GIVEN
        options = any_options()

        nd_option = network_layer.NdOption(options)

        # THEN
        self.assertEqual(nd_option, network_layer.NdOption(options))


class TestNdOptionFactory(unittest.TestCase):

    def test_should_create_NdOption_from_bytearray_when_parse_method_is_called(self):
        # GIVEN
        options = any_options()

        factory = network_layer.NdOptionFactory()

        data = bytearray(options)

        # WHEN
        nd_option = factory.parse(io.BytesIO(data), common.MessageInfo())

        # THEN
        self.assertTrue(isinstance(nd_option, network_layer.NdOption))
        self.assertEqual(options, nd_option.options)


class TestThreadNetworkData(unittest.TestCase):

    def test_should_return_options_value_when_options_property_is_called(self):
        # GIVEN
        tlvs = any_tlvs_data()

        thread_network_data = network_layer.ThreadNetworkData(tlvs)

        # WHEN
        actual_tlvs = thread_network_data.tlvs

        # THEN
        self.assertEqual(tlvs, actual_tlvs)

    def test_should_return_True_when_try_to_equal_two_the_same_type_objects_with_the_same_values(self):
        # GIVEN
        tlvs = any_tlvs_data()

        thread_network_data = network_layer.ThreadNetworkData(tlvs)

        # THEN
        self.assertEqual(thread_network_data, network_layer.ThreadNetworkData(tlvs))


class TestThreadNetworkDataFactory(unittest.TestCase):

    def test_should_create_ThreadNetworkData_from_bytearray_when_parse_method_is_called(self):
        # GIVEN
        tlvs = any_tlvs_data()

        class DummyNetworkDataTlvsFactory:

            def parse(self, data, message_info):
                return bytearray(data.read())

        factory = network_layer.ThreadNetworkDataFactory(DummyNetworkDataTlvsFactory())

        # WHEN
        thread_network_data = factory.parse(io.BytesIO(tlvs), common.MessageInfo())

        # THEN
        self.assertTrue(isinstance(thread_network_data, network_layer.ThreadNetworkData))
        self.assertEqual(tlvs, thread_network_data.tlvs)


if __name__ == "__main__":
    unittest.main()

[((48, 11, 48, 33), 'random.getrandbits', 'random.getrandbits', ({(48, 30, 48, 32): '(16)'}, {}), '(16)', False, 'import random\n'), ((56, 11, 56, 32), 'random.getrandbits', 'random.getrandbits', ({(56, 30, 56, 31): '(1)'}, {}), '(1)', False, 'import random\n'), ((60, 11, 60, 33), 'random.getrandbits', 'random.getrandbits', ({(60, 30, 60, 32): '(32)'}, {}), '(32)', False, 'import random\n'), ((64, 11, 64, 32), 'random.getrandbits', 'random.getrandbits', ({(64, 30, 64, 31): '(8)'}, {}), '(8)', False, 'import random\n'), ((68, 11, 68, 33), 'random.getrandbits', 'random.getrandbits', ({(68, 30, 68, 32): '(64)'}, {}), '(64)', False, 'import random\n'), ((77, 12, 77, 33), 'random.getrandbits', 'random.getrandbits', ({(77, 31, 77, 32): '8'}, {}), '(8)', False, 'import random\n'), ((491, 4, 491, 19), 'unittest.main', 'unittest.main', ({}, {}), '()', False, 'import unittest\n'), ((72, 44, 72, 66), 'random.randint', 'random.randint', ({(72, 59, 72, 60): '(0)', (72, 62, 72, 65): '(255)'}, {}), '(0, 255)', False, 'import random\n'), ((73, 12, 73, 33), 'random.getrandbits', 'random.getrandbits', ({(73, 31, 73, 32): '(8)'}, {}), '(8)', False, 'import random\n'), ((78, 47, 78, 68), 'random.getrandbits', 'random.getrandbits', ({(78, 66, 78, 67): '(8)'}, {}), '(8)', False, 'import random\n'), ((85, 44, 85, 65), 'random.randint', 'random.randint', ({(85, 59, 85, 60): '(0)', (85, 62, 85, 64): '(16)'}, {}), '(0, 16)', False, 'import random\n'), ((100, 21, 100, 49), 'network_layer.TargetEid', 'network_layer.TargetEid', ({(100, 45, 100, 48): 'eid'}, {}), '(eid)', False, 'import network_layer\n'), ((112, 21, 112, 49), 'network_layer.TargetEid', 'network_layer.TargetEid', ({(112, 45, 112, 48): 'eid'}, {}), '(eid)', False, 'import network_layer\n'), ((124, 18, 124, 50), 'network_layer.TargetEidFactory', 'network_layer.TargetEidFactory', ({}, {}), '()', False, 'import network_layer\n'), ((140, 31, 140, 76), 'network_layer.MacExtendedAddress', 'network_layer.MacExtendedAddress', ({(140, 64, 140, 75): 'mac_address'}, {}), '(mac_address)', False, 'import network_layer\n'), ((152, 31, 152, 76), 'network_layer.MacExtendedAddress', 'network_layer.MacExtendedAddress', ({(152, 64, 152, 75): 'mac_address'}, {}), '(mac_address)', False, 'import network_layer\n'), ((164, 18, 164, 59), 'network_layer.MacExtendedAddressFactory', 'network_layer.MacExtendedAddressFactory', ({}, {}), '()', False, 'import network_layer\n'), ((180, 21, 180, 49), 'network_layer.Rloc16', 'network_layer.Rloc16', ({(180, 42, 180, 48): 'rloc16'}, {}), '(rloc16)', False, 'import network_layer\n'), ((192, 21, 192, 49), 'network_layer.Rloc16', 'network_layer.Rloc16', ({(192, 42, 192, 48): 'rloc16'}, {}), '(rloc16)', False, 'import network_layer\n'), ((204, 18, 204, 47), 'network_layer.Rloc16Factory', 'network_layer.Rloc16Factory', ({}, {}), '()', False, 'import network_layer\n'), ((222, 21, 222, 48), 'network_layer.MlEid', 'network_layer.MlEid', ({(222, 41, 222, 47): 'ml_eid'}, {}), '(ml_eid)', False, 'import network_layer\n'), ((234, 21, 234, 48), 'network_layer.MlEid', 'network_layer.MlEid', ({(234, 41, 234, 47): 'ml_eid'}, {}), '(ml_eid)', False, 'import network_layer\n'), ((246, 18, 246, 46), 'network_layer.MlEidFactory', 'network_layer.MlEidFactory', ({}, {}), '()', False, 'import network_layer\n'), ((262, 21, 262, 49), 'network_layer.Status', 'network_layer.Status', ({(262, 42, 262, 48): 'status'}, {}), '(status)', False, 'import network_layer\n'), ((274, 21, 274, 49), 'network_layer.Status', 'network_layer.Status', ({(274, 42, 274, 48): 'status'}, {}), '(status)', False, 'import network_layer\n'), ((286, 18, 286, 47), 'network_layer.StatusFactory', 'network_layer.StatusFactory', ({}, {}), '()', False, 'import network_layer\n'), ((304, 38, 304, 85), 'network_layer.TimeSinceLastTransaction', 'network_layer.TimeSinceLastTransaction', ({(304, 77, 304, 84): 'seconds'}, {}), '(seconds)', False, 'import network_layer\n'), ((316, 38, 316, 85), 'network_layer.TimeSinceLastTransaction', 'network_layer.TimeSinceLastTransaction', ({(316, 77, 316, 84): 'seconds'}, {}), '(seconds)', False, 'import network_layer\n'), ((331, 18, 331, 65), 'network_layer.TimeSinceLastTransactionFactory', 'network_layer.TimeSinceLastTransactionFactory', ({}, {}), '()', False, 'import network_layer\n'), ((377, 22, 377, 75), 'network_layer.RouterMask', 'network_layer.RouterMask', ({(377, 47, 377, 58): 'id_sequence', (377, 60, 377, 74): 'router_id_mask'}, {}), '(id_sequence, router_id_mask)', False, 'import network_layer\n'), ((390, 18, 390, 51), 'network_layer.RouterMaskFactory', 'network_layer.RouterMaskFactory', ({}, {}), '()', False, 'import network_layer\n'), ((409, 20, 409, 51), 'network_layer.NdOption', 'network_layer.NdOption', ({(409, 43, 409, 50): 'options'}, {}), '(options)', False, 'import network_layer\n'), ((421, 20, 421, 51), 'network_layer.NdOption', 'network_layer.NdOption', ({(421, 43, 421, 50): 'options'}, {}), '(options)', False, 'import network_layer\n'), ((433, 18, 433, 49), 'network_layer.NdOptionFactory', 'network_layer.NdOptionFactory', ({}, {}), '()', False, 'import network_layer\n'), ((451, 30, 451, 67), 'network_layer.ThreadNetworkData', 'network_layer.ThreadNetworkData', ({(451, 62, 451, 66): 'tlvs'}, {}), '(tlvs)', False, 'import network_layer\n'), ((463, 30, 463, 67), 'network_layer.ThreadNetworkData', 'network_layer.ThreadNetworkData', ({(463, 62, 463, 66): 'tlvs'}, {}), '(tlvs)', False, 'import network_layer\n'), ((40, 22, 40, 43), 'random.getrandbits', 'random.getrandbits', ({(40, 41, 40, 42): '(8)'}, {}), '(8)', False, 'import random\n'), ((44, 22, 44, 43), 'random.getrandbits', 'random.getrandbits', ({(44, 41, 44, 42): '(8)'}, {}), '(8)', False, 'import random\n'), ((52, 22, 52, 43), 'random.getrandbits', 'random.getrandbits', ({(52, 41, 52, 42): '(8)'}, {}), '(8)', False, 'import random\n'), ((79, 23, 79, 44), 'random.getrandbits', 'random.getrandbits', ({(79, 42, 79, 43): '8'}, {}), '(8)', False, 'import random\n'), ((89, 29, 89, 50), 'random.randint', 'random.randint', ({(89, 44, 89, 45): '(1)', (89, 47, 89, 49): '(15)'}, {}), '(1, 15)', False, 'import random\n'), ((115, 37, 115, 65), 'network_layer.TargetEid', 'network_layer.TargetEid', ({(115, 61, 115, 64): 'eid'}, {}), '(eid)', False, 'import network_layer\n'), ((127, 35, 127, 50), 'io.BytesIO', 'io.BytesIO', ({(127, 46, 127, 49): 'eid'}, {}), '(eid)', False, 'import io\n'), ((127, 52, 127, 72), 'common.MessageInfo', 'common.MessageInfo', ({}, {}), '()', False, 'import common\n'), ((155, 47, 155, 92), 'network_layer.MacExtendedAddress', 'network_layer.MacExtendedAddress', ({(155, 80, 155, 91): 'mac_address'}, {}), '(mac_address)', False, 'import network_layer\n'), ((167, 45, 167, 68), 'io.BytesIO', 'io.BytesIO', ({(167, 56, 167, 67): 'mac_address'}, {}), '(mac_address)', False, 'import io\n'), ((167, 70, 167, 90), 'common.MessageInfo', 'common.MessageInfo', ({}, {}), '()', False, 'import common\n'), ((195, 37, 195, 65), 'network_layer.Rloc16', 'network_layer.Rloc16', ({(195, 58, 195, 64): 'rloc16'}, {}), '(rloc16)', False, 'import network_layer\n'), ((206, 25, 206, 50), 'struct.pack', 'struct.pack', ({(206, 37, 206, 41): '""">H"""', (206, 43, 206, 49): 'rloc16'}, {}), "('>H', rloc16)", False, 'import struct\n'), ((209, 35, 209, 51), 'io.BytesIO', 'io.BytesIO', ({(209, 46, 209, 50): 'data'}, {}), '(data)', False, 'import io\n'), ((209, 53, 209, 73), 'common.MessageInfo', 'common.MessageInfo', ({}, {}), '()', False, 'import common\n'), ((237, 37, 237, 64), 'network_layer.MlEid', 'network_layer.MlEid', ({(237, 57, 237, 63): 'ml_eid'}, {}), '(ml_eid)', False, 'import network_layer\n'), ((249, 35, 249, 53), 'io.BytesIO', 'io.BytesIO', ({(249, 46, 249, 52): 'ml_eid'}, {}), '(ml_eid)', False, 'import io\n'), ((249, 55, 249, 75), 'common.MessageInfo', 'common.MessageInfo', ({}, {}), '()', False, 'import common\n'), ((277, 37, 277, 65), 'network_layer.Status', 'network_layer.Status', ({(277, 58, 277, 64): 'status'}, {}), '(status)', False, 'import network_layer\n'), ((291, 35, 291, 51), 'io.BytesIO', 'io.BytesIO', ({(291, 46, 291, 50): 'data'}, {}), '(data)', False, 'import io\n'), ((291, 53, 291, 73), 'common.MessageInfo', 'common.MessageInfo', ({}, {}), '()', False, 'import common\n'), ((321, 12, 321, 59), 'network_layer.TimeSinceLastTransaction', 'network_layer.TimeSinceLastTransaction', ({(321, 51, 321, 58): 'seconds'}, {}), '(seconds)', False, 'import network_layer\n'), ((333, 25, 333, 51), 'struct.pack', 'struct.pack', ({(333, 37, 333, 41): '""">L"""', (333, 43, 333, 50): 'seconds'}, {}), "('>L', seconds)", False, 'import struct\n'), ((336, 52, 336, 68), 'io.BytesIO', 'io.BytesIO', ({(336, 63, 336, 67): 'data'}, {}), '(data)', False, 'import io\n'), ((336, 70, 336, 90), 'common.MessageInfo', 'common.MessageInfo', ({}, {}), '()', False, 'import common\n'), ((380, 38, 380, 91), 'network_layer.RouterMask', 'network_layer.RouterMask', ({(380, 63, 380, 74): 'id_sequence', (380, 76, 380, 90): 'router_id_mask'}, {}), '(id_sequence, router_id_mask)', False, 'import network_layer\n'), ((392, 42, 392, 75), 'struct.pack', 'struct.pack', ({(392, 54, 392, 58): '""">Q"""', (392, 60, 392, 74): 'router_id_mask'}, {}), "('>Q', router_id_mask)", False, 'import struct\n'), ((395, 36, 395, 52), 'io.BytesIO', 'io.BytesIO', ({(395, 47, 395, 51): 'data'}, {}), '(data)', False, 'import io\n'), ((395, 54, 395, 74), 'common.MessageInfo', 'common.MessageInfo', ({}, {}), '()', False, 'import common\n'), ((424, 36, 424, 67), 'network_layer.NdOption', 'network_layer.NdOption', ({(424, 59, 424, 66): 'options'}, {}), '(options)', False, 'import network_layer\n'), ((438, 34, 438, 50), 'io.BytesIO', 'io.BytesIO', ({(438, 45, 438, 49): 'data'}, {}), '(data)', False, 'import io\n'), ((438, 52, 438, 72), 'common.MessageInfo', 'common.MessageInfo', ({}, {}), '()', False, 'import common\n'), ((466, 46, 466, 83), 'network_layer.ThreadNetworkData', 'network_layer.ThreadNetworkData', ({(466, 78, 466, 82): 'tlvs'}, {}), '(tlvs)', False, 'import network_layer\n'), ((483, 44, 483, 60), 'io.BytesIO', 'io.BytesIO', ({(483, 55, 483, 59): 'tlvs'}, {}), '(tlvs)', False, 'import io\n'), ((483, 62, 483, 82), 'common.MessageInfo', 'common.MessageInfo', ({}, {}), '()', False, 'import common\n')]