Chip Boling | 67b674a | 2019-02-08 11:42:18 -0600 | [diff] [blame] | 1 | # |
| 2 | # Copyright 2017 the original author or authors. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | from unittest import TestCase, main |
Matt Jeanneret | 702f05f | 2019-09-17 19:47:34 -0400 | [diff] [blame] | 17 | from binascii import unhexlify |
Chip Boling | 67b674a | 2019-02-08 11:42:18 -0600 | [diff] [blame] | 18 | |
| 19 | from pyvoltha.adapters.extensions.omci.omci import * |
| 20 | |
| 21 | |
| 22 | def hexify(buffer): |
| 23 | """Return a hexadecimal string encoding of input buffer""" |
| 24 | return ''.join('%02x' % ord(c) for c in buffer) |
| 25 | |
| 26 | |
| 27 | def chunk(indexable, chunk_size): |
| 28 | for i in range(0, len(indexable), chunk_size): |
| 29 | yield indexable[i:i + chunk_size] |
| 30 | |
| 31 | |
| 32 | def hex2raw(hex_string): |
| 33 | return ''.join(chr(int(byte, 16)) for byte in chunk(hex_string, 2)) |
| 34 | |
| 35 | |
| 36 | class TestOmciFundamentals(TestCase): |
| 37 | |
| 38 | def test_bitpos_from_mask(self): |
| 39 | |
| 40 | f = lambda x: bitpos_from_mask(x) |
| 41 | self.assertEqual(f(0), []) |
| 42 | self.assertEqual(f(1), [0]) |
| 43 | self.assertEqual(f(3), [0, 1]) |
| 44 | self.assertEqual(f(255), [0, 1, 2, 3, 4, 5, 6, 7]) |
| 45 | self.assertEqual(f(0x800), [11]) |
| 46 | self.assertEqual(f(0x811), [0, 4, 11]) |
| 47 | |
| 48 | f = lambda x: bitpos_from_mask(x, 16, -1) |
| 49 | self.assertEqual(f(0), []) |
| 50 | self.assertEqual(f(1), [16]) |
| 51 | self.assertEqual(f(0x800), [5]) |
| 52 | self.assertEqual(f(0x801), [5, 16]) |
| 53 | |
| 54 | |
| 55 | def test_attribute_indeices_from_mask(self): |
| 56 | |
| 57 | f = EntityClass.attribute_indices_from_mask |
| 58 | self.assertEqual(f(0), []) |
| 59 | self.assertEqual(f(0x800), [5]) |
| 60 | self.assertEqual(f(0xf000), [1, 2, 3, 4]) |
| 61 | self.assertEqual(f(0xf804), [1, 2, 3, 4, 5, 14]) |
| 62 | |
| 63 | def test_entity_attribute_serialization(self): |
| 64 | |
| 65 | e = CircuitPack(vendor_id='F') |
| 66 | self.assertEqual(e.serialize(), 'F\x00\x00\x00') |
| 67 | |
| 68 | e = CircuitPack(vendor_id='FOOX') |
| 69 | self.assertEqual(e.serialize(), 'FOOX') |
| 70 | |
| 71 | e = CircuitPack(vendor_id='FOOX', number_of_ports=16) |
| 72 | self.assertEqual(e.serialize(), '\x10FOOX') |
| 73 | |
| 74 | def test_entity_attribute_serialization_mask_based(self): |
| 75 | |
| 76 | e = CircuitPack( |
| 77 | number_of_ports=4, |
| 78 | serial_number='BCMX31323334', # serial number is 4 ascii + 4 hex. 8 octets on the wire |
| 79 | version='a1c12fba91de', |
| 80 | vendor_id='BCM', |
| 81 | total_tcont_buffer_number=128 |
| 82 | ) |
| 83 | |
| 84 | # Full object |
| 85 | self.assertEqual(e.serialize(), |
| 86 | '\x04BCMX1234a1c12fba91de\x00\x00BCM\x00\x80') |
| 87 | |
| 88 | # Explicit mask with valid values |
| 89 | self.assertEqual(e.serialize(0x800), 'BCM\x00') |
| 90 | self.assertEqual(e.serialize(0x6800), '\x04BCMX1234BCM\x00') |
| 91 | |
| 92 | # Referring to an unfilled field is regarded as error |
| 93 | self.assertRaises(OmciUninitializedFieldError, e.serialize, 0xc00) |
| 94 | |
| 95 | def test_omci_mask_value_gen(self): |
| 96 | cls = CircuitPack |
| 97 | self.assertEqual(cls.mask_for('vendor_id'), 0x800) |
| 98 | self.assertEqual( |
| 99 | cls.mask_for('vendor_id', 'bridged_or_ip_ind'), 0x900) |
| 100 | |
| 101 | reference_get_request_hex = ( |
| 102 | '00 00 49 0a' |
| 103 | '00 06 01 01' |
| 104 | '08 00 00 00' |
| 105 | '00 00 00 00' |
| 106 | '00 00 00 00' |
| 107 | '00 00 00 00' |
| 108 | '00 00 00 00' |
| 109 | '00 00 00 00' |
| 110 | '00 00 00 00' |
| 111 | '00 00 00 00' |
| 112 | '00 00 00 28'.replace(' ', '') |
| 113 | ) |
| 114 | reference_get_request_raw = hex2raw(reference_get_request_hex) |
| 115 | |
| 116 | reference_get_response_hex = ( |
| 117 | '00 00 29 0a' |
| 118 | '00 06 01 01' |
| 119 | '00 08 00 50' |
| 120 | '4d 43 53 00' |
| 121 | '00 00 00 00' |
| 122 | '00 00 00 00' |
| 123 | '00 00 00 00' |
| 124 | '00 00 00 00' |
| 125 | '00 00 00 00' |
| 126 | '00 00 00 00' |
| 127 | '00 00 00 28'.replace(' ', '') |
| 128 | ) |
| 129 | reference_get_response_raw = hex2raw(reference_get_response_hex) |
| 130 | |
| 131 | def test_omci_frame_serialization(self): |
| 132 | |
| 133 | frame = OmciFrame( |
| 134 | transaction_id=0, |
| 135 | message_type=OmciGet.message_id, |
| 136 | omci_message=OmciGet( |
| 137 | entity_class=CircuitPack.class_id, |
| 138 | entity_id=0x101, |
| 139 | attributes_mask=CircuitPack.mask_for('vendor_id') |
| 140 | ) |
| 141 | ) |
| 142 | self.assertEqual(hexify(str(frame)), self.reference_get_request_hex) |
| 143 | |
| 144 | def test_omci_frame_deserialization_no_data(self): |
| 145 | frame = OmciFrame(self.reference_get_request_raw) |
| 146 | self.assertEqual(frame.transaction_id, 0) |
| 147 | self.assertEqual(frame.message_type, 0x49) |
| 148 | self.assertEqual(frame.omci, 10) |
| 149 | self.assertEqual(frame.omci_message.entity_class, 0x6) |
| 150 | self.assertEqual(frame.omci_message.entity_id, 0x101) |
| 151 | self.assertEqual(frame.omci_message.attributes_mask, 0x800) |
| 152 | self.assertEqual(frame.omci_trailer, 0x28) |
| 153 | |
| 154 | def test_omci_frame_deserialization_with_data(self): |
| 155 | frame = OmciFrame(self.reference_get_response_raw) |
| 156 | self.assertEqual(frame.transaction_id, 0) |
| 157 | self.assertEqual(frame.message_type, 0x29) |
| 158 | self.assertEqual(frame.omci, 10) |
| 159 | self.assertEqual(frame.omci_message.success_code, 0x0) |
| 160 | self.assertEqual(frame.omci_message.entity_class, 0x6) |
| 161 | self.assertEqual(frame.omci_message.entity_id, 0x101) |
| 162 | self.assertEqual(frame.omci_message.attributes_mask, 0x800) |
| 163 | self.assertEqual(frame.omci_trailer, 0x28) |
| 164 | |
| 165 | def test_entity_attribute_deserialization(self): |
| 166 | pass |
| 167 | |
| 168 | |
| 169 | class TestSelectMessageGeneration(TestCase): |
| 170 | |
| 171 | def assertGeneratedFrameEquals(self, frame, ref): |
| 172 | assert isinstance(frame, Packet) |
| 173 | serialized_hexified_frame = hexify(str(frame)).upper() |
| 174 | ref = ref.upper() |
| 175 | if serialized_hexified_frame != ref: |
| 176 | self.fail('Mismatch:\nReference:\n{}\nGenerated (bad):\n{}'.format( |
| 177 | ref, serialized_hexified_frame |
| 178 | )) |
| 179 | |
| 180 | def test_mib_reset_message_serialization(self): |
| 181 | ref = '00014F0A000200000000000000000000' \ |
| 182 | '00000000000000000000000000000000' \ |
| 183 | '000000000000000000000028' |
| 184 | frame = OmciFrame( |
| 185 | transaction_id=1, |
| 186 | message_type=OmciMibReset.message_id, |
| 187 | omci_message=OmciMibReset( |
| 188 | entity_class=OntData.class_id |
| 189 | ) |
| 190 | ) |
| 191 | self.assertGeneratedFrameEquals(frame, ref) |
| 192 | |
| 193 | def test_create_gal_ethernet_profile(self): |
| 194 | ref = '0002440A011000010030000000000000' \ |
| 195 | '00000000000000000000000000000000' \ |
| 196 | '000000000000000000000028' |
| 197 | frame = OmciFrame( |
| 198 | transaction_id=2, |
| 199 | message_type=OmciCreate.message_id, |
| 200 | omci_message=OmciCreate( |
| 201 | entity_class=GalEthernetProfile.class_id, |
| 202 | entity_id=1, |
| 203 | data=dict( |
| 204 | max_gem_payload_size=48 |
| 205 | ) |
| 206 | ) |
| 207 | ) |
| 208 | self.assertGeneratedFrameEquals(frame, ref) |
| 209 | |
| 210 | def test_set_tcont_1(self): |
| 211 | ref = '0003480A010680008000040000000000' \ |
| 212 | '00000000000000000000000000000000' \ |
| 213 | '000000000000000000000028' |
| 214 | data = dict( |
| 215 | alloc_id=0x400 |
| 216 | ) |
| 217 | frame = OmciFrame( |
| 218 | transaction_id=3, |
| 219 | message_type=OmciSet.message_id, |
| 220 | omci_message=OmciSet( |
| 221 | entity_class=Tcont.class_id, |
| 222 | entity_id=0x8000, |
| 223 | attributes_mask=Tcont.mask_for(*data.keys()), |
| 224 | data=data |
| 225 | ) |
| 226 | ) |
| 227 | self.assertGeneratedFrameEquals(frame, ref) |
| 228 | |
| 229 | def test_set_tcont_2(self): |
| 230 | ref = '0004480A010680018000040100000000' \ |
| 231 | '00000000000000000000000000000000' \ |
| 232 | '000000000000000000000028' |
| 233 | data = dict( |
| 234 | alloc_id=0x401 |
| 235 | ) |
| 236 | frame = OmciFrame( |
| 237 | transaction_id=4, |
| 238 | message_type=OmciSet.message_id, |
| 239 | omci_message=OmciSet( |
| 240 | entity_class=Tcont.class_id, |
| 241 | entity_id=0x8001, |
| 242 | attributes_mask=Tcont.mask_for(*data.keys()), |
| 243 | data=data |
| 244 | ) |
| 245 | ) |
| 246 | self.assertGeneratedFrameEquals(frame, ref) |
| 247 | |
| 248 | def test_create_8021p_mapper_service_profile(self): |
| 249 | ref = '0007440A00828000ffffffffffffffff' \ |
| 250 | 'ffffffffffffffffffff000000000000' \ |
| 251 | '000000000000000000000028' |
| 252 | frame = OmciFrame( |
| 253 | transaction_id=7, |
| 254 | message_type=OmciCreate.message_id, |
| 255 | omci_message=OmciCreate( |
| 256 | entity_class=Ieee8021pMapperServiceProfile.class_id, |
| 257 | entity_id=0x8000, |
| 258 | data=dict( |
| 259 | tp_pointer=OmciNullPointer, |
| 260 | interwork_tp_pointer_for_p_bit_priority_0=OmciNullPointer, |
| 261 | ) |
| 262 | ) |
| 263 | ) |
| 264 | self.assertGeneratedFrameEquals(frame, ref) |
| 265 | |
| 266 | def test_create_mac_bridge_service_profile(self): |
| 267 | ref = '000B440A002D02010001008000140002' \ |
| 268 | '000f0001000000000000000000000000' \ |
| 269 | '000000000000000000000028' |
| 270 | frame = OmciFrame( |
| 271 | transaction_id=11, |
| 272 | message_type=OmciCreate.message_id, |
| 273 | omci_message=OmciCreate( |
| 274 | entity_class=MacBridgeServiceProfile.class_id, |
| 275 | entity_id=0x201, |
| 276 | data=dict( |
| 277 | spanning_tree_ind=False, |
| 278 | learning_ind=True, |
| 279 | priority=0x8000, |
| 280 | max_age=20 * 256, |
| 281 | hello_time=2 * 256, |
| 282 | forward_delay=15 * 256, |
| 283 | unknown_mac_address_discard=True |
| 284 | ) |
| 285 | ) |
| 286 | ) |
| 287 | self.assertGeneratedFrameEquals(frame, ref) |
| 288 | |
| 289 | def test_create_gem_port_network_ctp(self): |
| 290 | ref = '000C440A010C01000400800003010000' \ |
| 291 | '00000000000000000000000000000000' \ |
| 292 | '000000000000000000000028' |
| 293 | frame = OmciFrame( |
| 294 | transaction_id=12, |
| 295 | message_type=OmciCreate.message_id, |
| 296 | omci_message=OmciCreate( |
| 297 | entity_class=GemPortNetworkCtp.class_id, |
| 298 | entity_id=0x100, |
| 299 | data=dict( |
| 300 | port_id=0x400, |
| 301 | tcont_pointer=0x8000, |
| 302 | direction=3, |
| 303 | traffic_management_pointer_upstream=0x100 |
| 304 | ) |
| 305 | ) |
| 306 | ) |
| 307 | self.assertGeneratedFrameEquals(frame, ref) |
| 308 | |
| 309 | def test_multicast_gem_interworking_tp(self): |
| 310 | ref = '0011440A011900060104000001000000' \ |
| 311 | '00000000000000000000000000000000' \ |
| 312 | '000000000000000000000028' |
| 313 | frame = OmciFrame( |
| 314 | transaction_id=17, |
| 315 | message_type=OmciCreate.message_id, |
| 316 | omci_message=OmciCreate( |
| 317 | entity_class=MulticastGemInterworkingTp.class_id, |
| 318 | entity_id=0x6, |
| 319 | data=dict( |
| 320 | gem_port_network_ctp_pointer=0x104, |
| 321 | interworking_option=0, |
| 322 | service_profile_pointer=0x1, |
| 323 | ) |
| 324 | ) |
| 325 | ) |
| 326 | self.assertGeneratedFrameEquals(frame, ref) |
| 327 | |
| 328 | def test_create_gem_inteworking_tp(self): |
| 329 | ref = '0012440A010A80010100058000000000' \ |
| 330 | '01000000000000000000000000000000' \ |
| 331 | '000000000000000000000028' |
| 332 | frame = OmciFrame( |
| 333 | transaction_id=18, |
| 334 | message_type=OmciCreate.message_id, |
| 335 | omci_message=OmciCreate( |
| 336 | entity_class=GemInterworkingTp.class_id, |
| 337 | entity_id=0x8001, |
| 338 | data=dict( |
| 339 | gem_port_network_ctp_pointer=0x100, |
| 340 | interworking_option=5, |
| 341 | service_profile_pointer=0x8000, |
| 342 | interworking_tp_pointer=0x0, |
| 343 | gal_profile_pointer=0x1 |
| 344 | ) |
| 345 | ) |
| 346 | ) |
| 347 | self.assertGeneratedFrameEquals(frame, ref) |
| 348 | |
| 349 | def test_set_8021p_mapper_service_profile(self): |
| 350 | ref = '0016480A008280004000800100000000' \ |
| 351 | '00000000000000000000000000000000' \ |
| 352 | '000000000000000000000028' |
| 353 | data = dict( |
| 354 | interwork_tp_pointer_for_p_bit_priority_0=0x8001 |
| 355 | ) |
| 356 | frame = OmciFrame( |
| 357 | transaction_id=22, |
| 358 | message_type=OmciSet.message_id, |
| 359 | omci_message=OmciSet( |
| 360 | entity_class=Ieee8021pMapperServiceProfile.class_id, |
| 361 | entity_id=0x8000, |
| 362 | attributes_mask=Ieee8021pMapperServiceProfile.mask_for( |
| 363 | *data.keys()), |
| 364 | data=data |
| 365 | ) |
| 366 | ) |
| 367 | self.assertGeneratedFrameEquals(frame, ref) |
| 368 | |
| 369 | def test_create_mac_bridge_port_configuration_data(self): |
| 370 | ref = '001A440A002F21010201020380000000' \ |
| 371 | '00000000000000000000000000000000' \ |
| 372 | '000000000000000000000028' |
| 373 | frame = OmciFrame( |
| 374 | transaction_id=26, |
| 375 | message_type=OmciCreate.message_id, |
| 376 | omci_message=OmciCreate( |
| 377 | entity_class=MacBridgePortConfigurationData.class_id, |
| 378 | entity_id=0x2101, |
| 379 | data=dict( |
| 380 | bridge_id_pointer=0x201, |
| 381 | port_num=2, |
| 382 | tp_type=3, |
| 383 | tp_pointer=0x8000 |
| 384 | ) |
| 385 | ) |
| 386 | ) |
| 387 | self.assertGeneratedFrameEquals(frame, ref) |
| 388 | |
| 389 | def test_create_vlan_tagging_filter_data(self): |
| 390 | ref = '001F440A005421010400000000000000' \ |
| 391 | '00000000000000000000000000000000' \ |
| 392 | '100100000000000000000028' |
| 393 | vlan_filter_list = [0] * 12 |
| 394 | vlan_filter_list[0] = 0x0400 |
| 395 | |
| 396 | frame = OmciFrame( |
| 397 | transaction_id=31, |
| 398 | message_type=OmciCreate.message_id, |
| 399 | omci_message=OmciCreate( |
| 400 | entity_class=VlanTaggingFilterData.class_id, |
| 401 | entity_id=0x2101, |
| 402 | data=dict( |
| 403 | vlan_filter_list=vlan_filter_list, |
| 404 | forward_operation=0x10, |
| 405 | number_of_entries=1 |
| 406 | ) |
| 407 | ) |
| 408 | ) |
| 409 | self.assertGeneratedFrameEquals(frame, ref) |
| 410 | |
| 411 | def test_create_extended_vlan_tagging_operation_configuration_data(self): |
| 412 | ref = '0023440A00AB02020A04010000000000' \ |
| 413 | '00000000000000000000000000000000' \ |
| 414 | '000000000000000000000028' |
| 415 | frame = OmciFrame( |
| 416 | transaction_id=35, |
| 417 | message_type=OmciCreate.message_id, |
| 418 | omci_message=OmciCreate( |
| 419 | entity_class= |
| 420 | ExtendedVlanTaggingOperationConfigurationData.class_id, |
| 421 | entity_id=0x202, |
| 422 | data=dict( |
| 423 | association_type=10, |
| 424 | associated_me_pointer=0x401 |
| 425 | ) |
| 426 | ) |
| 427 | ) |
| 428 | self.assertGeneratedFrameEquals(frame, ref) |
| 429 | |
| 430 | def test_set_extended_vlan_tagging_operation_configuration_data(self): |
| 431 | ref = '0024480A00AB02023800810081000000' \ |
| 432 | '00000000000000000000000000000000' \ |
| 433 | '000000000000000000000028' |
| 434 | data = dict( |
| 435 | input_tpid=0x8100, |
| 436 | output_tpid=0x8100, |
| 437 | downstream_mode=0, # inverse of upstream |
| 438 | ) |
| 439 | frame = OmciFrame( |
| 440 | transaction_id=36, |
| 441 | message_type=OmciSet.message_id, |
| 442 | omci_message=OmciSet( |
| 443 | entity_class=\ |
| 444 | ExtendedVlanTaggingOperationConfigurationData.class_id, |
| 445 | entity_id=0x202, |
| 446 | attributes_mask= \ |
| 447 | ExtendedVlanTaggingOperationConfigurationData.mask_for( |
| 448 | *data.keys()), |
| 449 | data=data |
| 450 | ) |
| 451 | ) |
| 452 | self.assertGeneratedFrameEquals(frame, ref) |
| 453 | |
| 454 | def test_set_extended_vlan_tagging_1(self): |
| 455 | ref = '0025480A00AB02020400f00000008200' \ |
| 456 | '5000402f000000082004000000000000' \ |
| 457 | '000000000000000000000028' |
| 458 | data = dict( |
| 459 | received_frame_vlan_tagging_operation_table=\ |
| 460 | VlanTaggingOperation( |
| 461 | filter_outer_priority=15, |
| 462 | filter_inner_priority=8, |
| 463 | filter_inner_vid=1024, |
| 464 | filter_inner_tpid_de=5, |
| 465 | filter_ether_type=0, |
| 466 | treatment_tags_to_remove=1, |
| 467 | pad3=2, |
| 468 | treatment_outer_priority=15, |
| 469 | treatment_inner_priority=8, |
| 470 | treatment_inner_vid=1024, |
| 471 | treatment_inner_tpid_de=4 |
| 472 | ) |
| 473 | ) |
| 474 | frame = OmciFrame( |
| 475 | transaction_id=37, |
| 476 | message_type=OmciSet.message_id, |
| 477 | omci_message=OmciSet( |
| 478 | entity_class=\ |
| 479 | ExtendedVlanTaggingOperationConfigurationData.class_id, |
| 480 | entity_id=0x202, |
| 481 | attributes_mask= \ |
| 482 | ExtendedVlanTaggingOperationConfigurationData.mask_for( |
| 483 | *data.keys()), |
| 484 | data=data |
| 485 | ) |
| 486 | ) |
| 487 | self.assertGeneratedFrameEquals(frame, ref) |
| 488 | |
| 489 | def test_set_extended_vlan_tagging_2(self): |
| 490 | ref = '0026480A00AB02020400F00000008200' \ |
| 491 | 'd000402f00000008200c000000000000' \ |
| 492 | '000000000000000000000028' |
| 493 | data = dict( |
| 494 | received_frame_vlan_tagging_operation_table= |
| 495 | VlanTaggingOperation( |
| 496 | filter_outer_priority=15, |
| 497 | filter_inner_priority=8, |
| 498 | filter_inner_vid=1025, |
| 499 | filter_inner_tpid_de=5, |
| 500 | filter_ether_type=0, |
| 501 | treatment_tags_to_remove=1, |
| 502 | pad3=2, |
| 503 | treatment_outer_priority=15, |
| 504 | treatment_inner_priority=8, |
| 505 | treatment_inner_vid=1025, |
| 506 | treatment_inner_tpid_de=4 |
| 507 | ) |
| 508 | ) |
| 509 | frame = OmciFrame( |
| 510 | transaction_id=38, |
| 511 | message_type=OmciSet.message_id, |
| 512 | omci_message=OmciSet( |
| 513 | entity_class= |
| 514 | ExtendedVlanTaggingOperationConfigurationData.class_id, |
| 515 | entity_id=0x202, |
| 516 | attributes_mask= |
| 517 | ExtendedVlanTaggingOperationConfigurationData.mask_for( |
| 518 | *data.keys()), |
| 519 | data=data |
| 520 | ) |
| 521 | ) |
| 522 | self.assertGeneratedFrameEquals(frame, ref) |
| 523 | |
| 524 | def test_create_mac_bridge_port_configuration_data2(self): |
| 525 | ref = '0029440A002F02010201010b04010000' \ |
| 526 | '00000000000000000000000000000000' \ |
| 527 | '000000000000000000000028' |
| 528 | frame = OmciFrame( |
| 529 | transaction_id=41, |
| 530 | message_type=OmciCreate.message_id, |
| 531 | omci_message=OmciCreate( |
| 532 | entity_class=MacBridgePortConfigurationData.class_id, |
| 533 | entity_id=0x201, |
| 534 | data=dict( |
| 535 | bridge_id_pointer=0x201, |
| 536 | encapsulation_methods=0, |
| 537 | port_num=1, |
| 538 | port_priority=0, |
| 539 | port_path_cost=0, |
| 540 | port_spanning_tree_in=0, |
| 541 | lan_fcs_ind=0, |
| 542 | tp_type=11, |
| 543 | tp_pointer=0x401, |
| 544 | mac_learning_depth=0 |
| 545 | ) |
| 546 | ) |
| 547 | ) |
| 548 | self.assertGeneratedFrameEquals(frame, ref) |
| 549 | frame2 = OmciFrame(hex2raw(ref)) |
| 550 | self.assertEqual(frame2, frame) |
| 551 | |
| 552 | def test_mib_upload(self): |
| 553 | ref = '00304D0A000200000000000000000000' \ |
| 554 | '00000000000000000000000000000000' \ |
| 555 | '000000000000000000000028' |
| 556 | frame = OmciFrame( |
| 557 | transaction_id=48, |
| 558 | message_type=OmciMibUpload.message_id, |
| 559 | omci_message=OmciMibUpload( |
| 560 | entity_class=OntData.class_id |
| 561 | ) |
| 562 | ) |
| 563 | self.assertGeneratedFrameEquals(frame, ref) |
| 564 | |
| 565 | def test_parse_enh_security_avc(self): |
| 566 | refs = [ |
| 567 | "0000110a014c0000008000202020202020202020202020202020202020202020" |
| 568 | "2020202020202020000000280be43cf4" |
| 569 | ] |
| 570 | for i, data in enumerate(refs): |
| 571 | frame = OmciFrame(hex2raw(data)) |
| 572 | omci = frame.omci_message |
| 573 | # frame.show() |
| 574 | |
| 575 | def test_parse_alarm_message(self): |
| 576 | refs = [ |
| 577 | "0000100a00050101000000000000000000000000000000000000000000000000" |
| 578 | "0000000220000000000000280be43cf4" |
| 579 | ] |
| 580 | for i, data in enumerate(refs): |
| 581 | frame = OmciFrame(hex2raw(data)) |
| 582 | omci = frame.omci_message |
| 583 | # frame.show() |
| 584 | |
| 585 | def test_parse_results(self): |
| 586 | refs = [ |
| 587 | "00001B0a014c0000008000202020202020202020202020202020202020202020" |
| 588 | "2020202020202020000000280be43cf4" |
| 589 | ] |
| 590 | for i, data in enumerate(refs): |
| 591 | frame = OmciFrame(hex2raw(data)) |
| 592 | omci = frame.omci_message |
| 593 | # frame.show() |
| 594 | |
| 595 | def test_parsing_mib_upload_next_responses(self): |
| 596 | refs = [ |
| 597 | "00032e0a00020000000200008000000000000000000000000000000000000000" |
| 598 | "00000000000000000000002828ce00e2", |
| 599 | "00042e0a0002000000050101f0002f2f05202020202020202020202020202020" |
| 600 | "202020202000000000000028d4eb4bdf", |
| 601 | "00052e0a00020000000501010f80202020202020202020202020202020202020" |
| 602 | "2020000000000000000000282dbe4b44", |
| 603 | "00062e0a0002000000050104f000303001202020202020202020202020202020" |
| 604 | "202020202000000000000028ef1b035b", |
| 605 | "00072e0a00020000000501040f80202020202020202020202020202020202020" |
| 606 | "202000000000000000000028fec29135", |
| 607 | "00082e0a0002000000050180f000f8f801202020202020202020202020202020" |
| 608 | "202020202000000000000028fd4e0b07", |
| 609 | "00092e0a00020000000501800f80202020202020202020202020202020202020" |
| 610 | "2020000000000000000000283306b3c0", |
| 611 | "000a2e0a0002000000060101f0002f054252434d123456780000000000000000" |
| 612 | "00000000000c000000000028585c2083", |
| 613 | "000b2e0a00020000000601010f004252434d0000000000000000000000000000" |
| 614 | "0000000000000000000000284f0e82b9", |
| 615 | "000c2e0a000200000006010100f8202020202020202020202020202020202020" |
| 616 | "202000000000000000000028e68bdb63", |
| 617 | "000d2e0a00020000000601010004000000000000000000000000000000000000" |
| 618 | "00000000000000000000002857bc2730", |
| 619 | "000e2e0a0002000000060104f00030014252434d123456780000000000000000" |
| 620 | "00000000000c000000000028afe656f5", |
| 621 | "000f2e0a00020000000601040f004252434d0000000000000000000000000000" |
| 622 | "000000000000000000000028f8f6db74", |
| 623 | "00102e0a000200000006010400f8202020202020202020202020202020202020" |
| 624 | "202000000800000000000028064fc177", |
| 625 | "00112e0a00020000000601040004000000000000000000000000000000000000" |
| 626 | "0000000000000000000000285a5c0841", |
| 627 | "00122e0a0002000000060180f000f8014252434d123456780000000000000000" |
| 628 | "00000000000c0000000000286826eafe", |
| 629 | "00132e0a00020000000601800f004252434d0000000000000000000000000000" |
| 630 | "0000000000000000000000281c4b7033", |
| 631 | "00142e0a000200000006018000f8202020202020202020202020202020202020" |
| 632 | "202000084040000000000028ac144eb3", |
| 633 | "00152e0a00020000000601800004000000000000000000000000000000000000" |
| 634 | "0000000000000000000000280a81a9a7", |
| 635 | "00162e0a0002000000070000f0003530323247574f3236363230303301010100" |
| 636 | "0000000000000000000000287ea42d51", |
| 637 | "00172e0a0002000000070001f0003530323247574f3236363230303300000100" |
| 638 | "000000000000000000000028b17f567f", |
| 639 | "00182e0a0002000000830000c000202020202020202020202020202020202020" |
| 640 | "2020202020200000000000280e7eebaa", |
| 641 | "00192e0a00020000008300002000202020202020202020202020202000000000" |
| 642 | "000000000000000000000028a95c03b3", |
| 643 | "001a2e0a00020000008300001000000000000000000000000000000000000000" |
| 644 | "000000000000000000000028f30515a1", |
| 645 | "001b2e0a0002000000850000ffe0000000000000000000000000000000000000" |
| 646 | "000000000000000000000028764c18de", |
| 647 | "001c2e0a0002000000860001c00000001018aaaa000000000000000000000000" |
| 648 | "000000000000000000000028ea220ce0", |
| 649 | "001d2e0a00020000008600012000000000000000000000000000000000000000" |
| 650 | "000000000000000000000028fbdb571a", |
| 651 | "001e2e0a00020000008600011f80000000000000000000000000000000000000" |
| 652 | "000000000000000000000028c2682282", |
| 653 | "001f2e0a00020000008600010078000000000000000000000000000000000000" |
| 654 | "0000000000000000000000289c4809b1", |
| 655 | "00202e0a00020000008600010004000000000000000000000000000000000000" |
| 656 | "000000000000000000000028d174a7d6", |
| 657 | "00212e0a00020000008600010002000000000000000000000000000000000000" |
| 658 | "0000000000000000000000288f353976", |
| 659 | "00222e0a0002000001000000e0004252434d0000000000000000000000000000" |
| 660 | "4252434d123456780000002803bbceb6", |
| 661 | "00232e0a00020000010000001f80000000000000000000000000000000000000" |
| 662 | "0000000000000000000000281b9674db", |
| 663 | "00242e0a00020000010000000040000000000000000000000000000000000000" |
| 664 | "000000000000000000000028b1050b9b", |
| 665 | "00252e0a00020000010000000038000000000000000000000000000003000000" |
| 666 | "0000000000000000000000288266645e", |
| 667 | "00262e0a0002000001010000f80042564d344b3030425241303931352d303038" |
| 668 | "3300b3000001010000000028837d624f", |
| 669 | "00272e0a000200000101000007f8000000010020027c85630016000030000000" |
| 670 | "00000000000000000000002896c707e1", |
| 671 | "00282e0a0002000001068000e00000ff01010000000000000000000000000000" |
| 672 | "00000000000000000000002811acb324", |
| 673 | "00292e0a0002000001068001e00000ff01010000000000000000000000000000" |
| 674 | "00000000000000000000002823ad6aa9", |
| 675 | "002a2e0a0002000001068002e00000ff01010000000000000000000000000000" |
| 676 | "000000000000000000000028a290efd9", |
| 677 | "002b2e0a0002000001068003e00000ff01010000000000000000000000000000" |
| 678 | "000000000000000000000028af893357", |
| 679 | "002c2e0a0002000001068004e00000ff01010000000000000000000000000000" |
| 680 | "000000000000000000000028901141a3", |
| 681 | "002d2e0a0002000001068005e00000ff01010000000000000000000000000000" |
| 682 | "000000000000000000000028c4398bcc", |
| 683 | "002e2e0a0002000001068006e00000ff01010000000000000000000000000000" |
| 684 | "000000000000000000000028e60acd99", |
| 685 | "002f2e0a0002000001068007e00000ff01010000000000000000000000000000" |
| 686 | "0000000000000000000000284b5faf23", |
| 687 | "00302e0a0002000001078001ffff01000800300000050900000000ffff000000" |
| 688 | "008181000000000000000028bef89455", |
| 689 | "00312e0a0002000001080401f000000000000401000000000000000000000000" |
| 690 | "0000000000000000000000287dc5183d", |
| 691 | "00322e0a0002000001150401fff0000080008000000000040100000000010000" |
| 692 | "000000000000000000000028cc0a46a9", |
| 693 | "00332e0a0002000001150401000f0200020002000200ffff0900000000000000" |
| 694 | "0000000000000000000000288c42acdd", |
| 695 | "00342e0a0002000001150402fff0000080008000000000040100010000010000" |
| 696 | "000000000000000000000028de9f625a", |
| 697 | "00352e0a0002000001150402000f0200020002000200ffff0900000000000000" |
| 698 | "0000000000000000000000280587860b", |
| 699 | "00362e0a0002000001150403fff0000080008000000000040100020000010000" |
| 700 | "000000000000000000000028a49cc820", |
| 701 | "00372e0a0002000001150403000f0200020002000200ffff0900000000000000" |
| 702 | "000000000000000000000028b4e4a2b9", |
| 703 | "00382e0a0002000001150404fff0000080008000000000040100030000010000" |
| 704 | "0000000000000000000000288233147b", |
| 705 | "00392e0a0002000001150404000f0200020002000200ffff0900000000000000" |
| 706 | "00000000000000000000002881b706b0", |
| 707 | "003a2e0a0002000001150405fff0000080008000000000040100040000010000" |
| 708 | "000000000000000000000028be8efc9f", |
| 709 | "003b2e0a0002000001150405000f0200020002000200ffff0900000000000000" |
| 710 | "000000000000000000000028d944804b", |
| 711 | "003c2e0a0002000001150406fff0000080008000000000040100050000010000" |
| 712 | "000000000000000000000028725c3864", |
| 713 | "003d2e0a0002000001150406000f0200020002000200ffff0900000000000000" |
| 714 | "0000000000000000000000284e2d5cd2", |
| 715 | "003e2e0a0002000001150407fff0000080008000000000040100060000010000" |
| 716 | "000000000000000000000028464b03ba", |
| 717 | "003f2e0a0002000001150407000f0200020002000200ffff0900000000000000" |
| 718 | "0000000000000000000000287006cfd0", |
| 719 | "00402e0a0002000001150408fff0000080008000000000040100070000010000" |
| 720 | "000000000000000000000028cd88ebeb", |
| 721 | "00412e0a0002000001150408000f0200020002000200ffff0900000000000000" |
| 722 | "0000000000000000000000285a5905e2", |
| 723 | "00422e0a0002000001158000fff0000100010000000000800000000000010000" |
| 724 | "000000000000000000000028e61b19d1", |
| 725 | "00432e0a0002000001158000000f0200020002000200ffff0900000000000000" |
| 726 | "000000000000000000000028b0cc5937", |
| 727 | "00442e0a0002000001158001fff0000100010000000000800000010000010000" |
| 728 | "0000000000000000000000285386bbf2", |
| 729 | "00452e0a0002000001158001000f0200020002000200ffff0900000000000000" |
| 730 | "000000000000000000000028c06723ab", |
| 731 | "00462e0a0002000001158002fff0000100010000000000800000020000010000" |
| 732 | "000000000000000000000028ab49704a", |
| 733 | "00472e0a0002000001158002000f0200020002000200ffff0900000000000000" |
| 734 | "00000000000000000000002857432f25", |
| 735 | "00482e0a0002000001158003fff0000100010000000000800000030000010000" |
| 736 | "000000000000000000000028b383c057", |
| 737 | "00492e0a0002000001158003000f0200020002000200ffff0900000000000000" |
| 738 | "000000000000000000000028dca40d66", |
| 739 | "004a2e0a0002000001158004fff0000100010000000000800000040000010000" |
| 740 | "0000000000000000000000286b7ba0e2", |
| 741 | "004b2e0a0002000001158004000f0200020002000200ffff0900000000000000" |
| 742 | "000000000000000000000028fd442363", |
| 743 | "004c2e0a0002000001158005fff0000100010000000000800000050000010000" |
| 744 | "0000000000000000000000280ee9a0b8", |
| 745 | "004d2e0a0002000001158005000f0200020002000200ffff0900000000000000" |
| 746 | "000000000000000000000028bc1b9843", |
| 747 | "004e2e0a0002000001158006fff0000100010000000000800000060000010000" |
| 748 | "0000000000000000000000280c535114", |
| 749 | "004f2e0a0002000001158006000f0200020002000200ffff0900000000000000" |
| 750 | "00000000000000000000002887032f2b", |
| 751 | "00502e0a0002000001158007fff0000100010000000000800000070000010000" |
| 752 | "000000000000000000000028a77d7f61", |
| 753 | "00512e0a0002000001158007000f0200020002000200ffff0900000000000000" |
| 754 | "00000000000000000000002835e9f567", |
| 755 | "00522e0a0002000001158008fff0000100010000000000800100000000010000" |
| 756 | "000000000000000000000028ff4ca94b", |
| 757 | "00532e0a0002000001158008000f0200020002000200ffff0900000000000000" |
| 758 | "0000000000000000000000281e2f1e33", |
| 759 | "00542e0a0002000001158009fff0000100010000000000800100010000010000" |
| 760 | "0000000000000000000000283c473db0", |
| 761 | "00552e0a0002000001158009000f0200020002000200ffff0900000000000000" |
| 762 | "00000000000000000000002869f51dda", |
| 763 | "00562e0a000200000115800afff0000100010000000000800100020000010000" |
| 764 | "000000000000000000000028046b8feb", |
| 765 | "00572e0a000200000115800a000f0200020002000200ffff0900000000000000" |
| 766 | "00000000000000000000002868b1495e", |
| 767 | "00582e0a000200000115800bfff0000100010000000000800100030000010000" |
| 768 | "0000000000000000000000282b927566", |
| 769 | "00592e0a000200000115800b000f0200020002000200ffff0900000000000000" |
| 770 | "000000000000000000000028cd43de96", |
| 771 | "005a2e0a000200000115800cfff0000100010000000000800100040000010000" |
| 772 | "000000000000000000000028c49617dd", |
| 773 | "005b2e0a000200000115800c000f0200020002000200ffff0900000000000000" |
| 774 | "000000000000000000000028fbbb972a", |
| 775 | "005c2e0a000200000115800dfff0000100010000000000800100050000010000" |
| 776 | "00000000000000000000002893d4c2b5", |
| 777 | "005d2e0a000200000115800d000f0200020002000200ffff0900000000000000" |
| 778 | "000000000000000000000028dc9d97ca", |
| 779 | "005e2e0a000200000115800efff0000100010000000000800100060000010000" |
| 780 | "0000000000000000000000280e1ec245", |
| 781 | "005f2e0a000200000115800e000f0200020002000200ffff0900000000000000" |
| 782 | "000000000000000000000028be3d56f1", |
| 783 | "00602e0a000200000115800ffff0000100010000000000800100070000010000" |
| 784 | "0000000000000000000000280c046099", |
| 785 | "00612e0a000200000115800f000f0200020002000200ffff0900000000000000" |
| 786 | "000000000000000000000028d770e4ea", |
| 787 | "00622e0a0002000001158010fff0000100010000000000800200000000010000" |
| 788 | "0000000000000000000000281b449092", |
| 789 | "00632e0a0002000001158010000f0200020002000200ffff0900000000000000" |
| 790 | "0000000000000000000000282b7a8604", |
| 791 | "00642e0a0002000001158011fff0000100010000000000800200010000010000" |
| 792 | "000000000000000000000028ad498068", |
| 793 | "00652e0a0002000001158011000f0200020002000200ffff0900000000000000" |
| 794 | "000000000000000000000028a114b304", |
| 795 | "00662e0a0002000001158012fff0000100010000000000800200020000010000" |
| 796 | "000000000000000000000028c091715d", |
| 797 | "00672e0a0002000001158012000f0200020002000200ffff0900000000000000" |
| 798 | "000000000000000000000028d4ab49e7", |
| 799 | "00682e0a0002000001158013fff0000100010000000000800200030000010000" |
| 800 | "000000000000000000000028e39dd5dd", |
| 801 | "00692e0a0002000001158013000f0200020002000200ffff0900000000000000" |
| 802 | "0000000000000000000000288779ebf0", |
| 803 | "006a2e0a0002000001158014fff0000100010000000000800200040000010000" |
| 804 | "000000000000000000000028c47a741f", |
| 805 | "006b2e0a0002000001158014000f0200020002000200ffff0900000000000000" |
| 806 | "000000000000000000000028ce765fcd", |
| 807 | "006c2e0a0002000001158015fff0000100010000000000800200050000010000" |
| 808 | "0000000000000000000000288f732591", |
| 809 | "006d2e0a0002000001158015000f0200020002000200ffff0900000000000000" |
| 810 | "000000000000000000000028920b6f5e", |
| 811 | "006e2e0a0002000001158016fff0000100010000000000800200060000010000" |
| 812 | "000000000000000000000028f072e1c3", |
| 813 | "006f2e0a0002000001158016000f0200020002000200ffff0900000000000000" |
| 814 | "000000000000000000000028b47ea00f", |
| 815 | "00702e0a0002000001158017fff0000100010000000000800200070000010000" |
| 816 | "00000000000000000000002813461627", |
| 817 | "00712e0a0002000001158017000f0200020002000200ffff0900000000000000" |
| 818 | "00000000000000000000002809013378", |
| 819 | "00722e0a0002000001158018fff0000100010000000000800300000000010000" |
| 820 | "0000000000000000000000286168e200", |
| 821 | "00732e0a0002000001158018000f0200020002000200ffff0900000000000000" |
| 822 | "000000000000000000000028eccc81f7", |
| 823 | "00742e0a0002000001158019fff0000100010000000000800300010000010000" |
| 824 | "00000000000000000000002855fe8072", |
| 825 | "00752e0a0002000001158019000f0200020002000200ffff0900000000000000" |
| 826 | "000000000000000000000028c159c496", |
| 827 | "00762e0a000200000115801afff0000100010000000000800300020000010000" |
| 828 | "00000000000000000000002872652aca", |
| 829 | "00772e0a000200000115801a000f0200020002000200ffff0900000000000000" |
| 830 | "0000000000000000000000283ba1c255", |
| 831 | "00782e0a000200000115801bfff0000100010000000000800300030000010000" |
| 832 | "0000000000000000000000286b2ecb95", |
| 833 | "00792e0a000200000115801b000f0200020002000200ffff0900000000000000" |
| 834 | "000000000000000000000028441fbe05", |
| 835 | "007a2e0a000200000115801cfff0000100010000000000800300040000010000" |
| 836 | "000000000000000000000028f07ad5d8", |
| 837 | "007b2e0a000200000115801c000f0200020002000200ffff0900000000000000" |
| 838 | "000000000000000000000028237d6a28", |
| 839 | "007c2e0a000200000115801dfff0000100010000000000800300050000010000" |
| 840 | "000000000000000000000028e47dfdca", |
| 841 | "007d2e0a000200000115801d000f0200020002000200ffff0900000000000000" |
| 842 | "0000000000000000000000280ca941be", |
| 843 | "007e2e0a000200000115801efff0000100010000000000800300060000010000" |
| 844 | "0000000000000000000000283a1ef4d4", |
| 845 | "007f2e0a000200000115801e000f0200020002000200ffff0900000000000000" |
| 846 | "0000000000000000000000289c905cd5", |
| 847 | "00802e0a000200000115801ffff0000100010000000000800300070000010000" |
| 848 | "000000000000000000000028384ae4c6", |
| 849 | "00812e0a000200000115801f000f0200020002000200ffff0900000000000000" |
| 850 | "000000000000000000000028be87eb55", |
| 851 | "00822e0a0002000001158020fff0000100010000000000800400000000010000" |
| 852 | "000000000000000000000028f0412282", |
| 853 | "00832e0a0002000001158020000f0200020002000200ffff0900000000000000" |
| 854 | "000000000000000000000028842ada0c", |
| 855 | "00842e0a0002000001158021fff0000100010000000000800400010000010000" |
| 856 | "000000000000000000000028a6eed1bc", |
| 857 | "00852e0a0002000001158021000f0200020002000200ffff0900000000000000" |
| 858 | "0000000000000000000000280f3dd903", |
| 859 | "00862e0a0002000001158022fff0000100010000000000800400020000010000" |
| 860 | "000000000000000000000028474a0823", |
| 861 | "00872e0a0002000001158022000f0200020002000200ffff0900000000000000" |
| 862 | "000000000000000000000028e00456b3", |
| 863 | "00882e0a0002000001158023fff0000100010000000000800400030000010000" |
| 864 | "00000000000000000000002851cbe1a6", |
| 865 | "00892e0a0002000001158023000f0200020002000200ffff0900000000000000" |
| 866 | "00000000000000000000002869a99563", |
| 867 | "008a2e0a0002000001158024fff0000100010000000000800400040000010000" |
| 868 | "00000000000000000000002867705534", |
| 869 | "008b2e0a0002000001158024000f0200020002000200ffff0900000000000000" |
| 870 | "0000000000000000000000286f9570c0", |
| 871 | "008c2e0a0002000001158025fff0000100010000000000800400050000010000" |
| 872 | "000000000000000000000028450ef70e", |
| 873 | "008d2e0a0002000001158025000f0200020002000200ffff0900000000000000" |
| 874 | "00000000000000000000002847588afa", |
| 875 | "008e2e0a0002000001158026fff0000100010000000000800400060000010000" |
| 876 | "000000000000000000000028c8218600", |
| 877 | "008f2e0a0002000001158026000f0200020002000200ffff0900000000000000" |
| 878 | "000000000000000000000028391a6ba7", |
| 879 | "00902e0a0002000001158027fff0000100010000000000800400070000010000" |
| 880 | "000000000000000000000028afc0878b", |
| 881 | "00912e0a0002000001158027000f0200020002000200ffff0900000000000000" |
| 882 | "00000000000000000000002819130d66", |
| 883 | "00922e0a0002000001158028fff0000100010000000000800500000000010000" |
| 884 | "0000000000000000000000289afa4cf7", |
| 885 | "00932e0a0002000001158028000f0200020002000200ffff0900000000000000" |
| 886 | "00000000000000000000002873a4e20b", |
| 887 | "00942e0a0002000001158029fff0000100010000000000800500010000010000" |
| 888 | "000000000000000000000028633debd9", |
| 889 | "00952e0a0002000001158029000f0200020002000200ffff0900000000000000" |
| 890 | "0000000000000000000000280397eb28", |
| 891 | "00962e0a000200000115802afff0000100010000000000800500020000010000" |
| 892 | "0000000000000000000000280ed5ee7a", |
| 893 | "00972e0a000200000115802a000f0200020002000200ffff0900000000000000" |
| 894 | "000000000000000000000028f886ba59", |
| 895 | "00982e0a000200000115802bfff0000100010000000000800500030000010000" |
| 896 | "00000000000000000000002888ff79b1", |
| 897 | "00992e0a000200000115802b000f0200020002000200ffff0900000000000000" |
| 898 | "00000000000000000000002846baf278", |
| 899 | "009a2e0a000200000115802cfff0000100010000000000800500040000010000" |
| 900 | "0000000000000000000000281fd1e68f", |
| 901 | "009b2e0a000200000115802c000f0200020002000200ffff0900000000000000" |
| 902 | "000000000000000000000028d99760f9", |
| 903 | "009c2e0a000200000115802dfff0000100010000000000800500050000010000" |
| 904 | "000000000000000000000028557aaf84", |
| 905 | "009d2e0a000200000115802d000f0200020002000200ffff0900000000000000" |
| 906 | "000000000000000000000028064210fd", |
| 907 | "009e2e0a000200000115802efff0000100010000000000800500060000010000" |
| 908 | "0000000000000000000000285fd6c061", |
| 909 | "009f2e0a000200000115802e000f0200020002000200ffff0900000000000000" |
| 910 | "000000000000000000000028299efbb5", |
| 911 | "00a02e0a000200000115802ffff0000100010000000000800500070000010000" |
| 912 | "00000000000000000000002834f127c4", |
| 913 | "00a12e0a000200000115802f000f0200020002000200ffff0900000000000000" |
| 914 | "000000000000000000000028edd30591", |
| 915 | "00a22e0a0002000001158030fff0000100010000000000800600000000010000" |
| 916 | "000000000000000000000028183183f2", |
| 917 | "00a32e0a0002000001158030000f0200020002000200ffff0900000000000000" |
| 918 | "000000000000000000000028a27e71f6", |
| 919 | "00a42e0a0002000001158031fff0000100010000000000800600010000010000" |
| 920 | "000000000000000000000028bd64dfc0", |
| 921 | "00a52e0a0002000001158031000f0200020002000200ffff0900000000000000" |
| 922 | "00000000000000000000002839e2f37e", |
| 923 | "00a62e0a0002000001158032fff0000100010000000000800600020000010000" |
| 924 | "0000000000000000000000283e72282e", |
| 925 | "00a72e0a0002000001158032000f0200020002000200ffff0900000000000000" |
| 926 | "000000000000000000000028cef19baa", |
| 927 | "00a82e0a0002000001158033fff0000100010000000000800600030000010000" |
| 928 | "0000000000000000000000281c1caf44", |
| 929 | "00a92e0a0002000001158033000f0200020002000200ffff0900000000000000" |
| 930 | "00000000000000000000002814712e27", |
| 931 | "00aa2e0a0002000001158034fff0000100010000000000800600040000010000" |
| 932 | "000000000000000000000028f02a30a4", |
| 933 | "00ab2e0a0002000001158034000f0200020002000200ffff0900000000000000" |
| 934 | "000000000000000000000028068fcbf5", |
| 935 | "00ac2e0a0002000001158035fff0000100010000000000800600050000010000" |
| 936 | "000000000000000000000028436bd783", |
| 937 | "00ad2e0a0002000001158035000f0200020002000200ffff0900000000000000" |
| 938 | "0000000000000000000000288da3200f", |
| 939 | "00ae2e0a0002000001158036fff0000100010000000000800600060000010000" |
| 940 | "000000000000000000000028c26a02ca", |
| 941 | "00af2e0a0002000001158036000f0200020002000200ffff0900000000000000" |
| 942 | "000000000000000000000028147a41ee", |
| 943 | "00b02e0a0002000001158037fff0000100010000000000800600070000010000" |
| 944 | "0000000000000000000000287c2bbec0", |
| 945 | "00b12e0a0002000001158037000f0200020002000200ffff0900000000000000" |
| 946 | "0000000000000000000000284c86c11f", |
| 947 | "00b22e0a0002000001158038fff0000100010000000000800700000000010000" |
| 948 | "00000000000000000000002895b94e06", |
| 949 | "00b32e0a0002000001158038000f0200020002000200ffff0900000000000000" |
| 950 | "000000000000000000000028a2b34012", |
| 951 | "00b42e0a0002000001158039fff0000100010000000000800700010000010000" |
| 952 | "00000000000000000000002804b205a3", |
| 953 | "00b52e0a0002000001158039000f0200020002000200ffff0900000000000000" |
| 954 | "00000000000000000000002886856d76", |
| 955 | "00b62e0a000200000115803afff0000100010000000000800700020000010000" |
| 956 | "0000000000000000000000282a22752c", |
| 957 | "00b72e0a000200000115803a000f0200020002000200ffff0900000000000000" |
| 958 | "000000000000000000000028488e67db", |
| 959 | "00b82e0a000200000115803bfff0000100010000000000800700030000010000" |
| 960 | "000000000000000000000028a55f79ea", |
| 961 | "00b92e0a000200000115803b000f0200020002000200ffff0900000000000000" |
| 962 | "00000000000000000000002842d77ba7", |
| 963 | "00ba2e0a000200000115803cfff0000100010000000000800700040000010000" |
| 964 | "000000000000000000000028da65268a", |
| 965 | "00bb2e0a000200000115803c000f0200020002000200ffff0900000000000000" |
| 966 | "000000000000000000000028c58443ec", |
| 967 | "00bc2e0a000200000115803dfff0000100010000000000800700050000010000" |
| 968 | "000000000000000000000028997aca59", |
| 969 | "00bd2e0a000200000115803d000f0200020002000200ffff0900000000000000" |
| 970 | "000000000000000000000028a2670b7d", |
| 971 | "00be2e0a000200000115803efff0000100010000000000800700060000010000" |
| 972 | "00000000000000000000002813e904cb", |
| 973 | "00bf2e0a000200000115803e000f0200020002000200ffff0900000000000000" |
| 974 | "000000000000000000000028c387a9e5", |
| 975 | "00c02e0a000200000115803ffff0000100010000000000800700070000010000" |
| 976 | "000000000000000000000028d556a6b2", |
| 977 | "00c12e0a000200000115803f000f0200020002000200ffff0900000000000000" |
| 978 | "00000000000000000000002868d9961a", |
| 979 | "00c22e0a0002000001168000f000800000000200000000000000000000000000" |
| 980 | "000000000000000000000028b69b53c1", |
| 981 | "00c32e0a0002000001168001f000800000000200000000000000000000000000" |
| 982 | "000000000000000000000028537705d4", |
| 983 | "00c42e0a0002000001168002f000800000000200000000000000000000000000" |
| 984 | "000000000000000000000028db171b7b", |
| 985 | "00c52e0a0002000001168003f000800000000200000000000000000000000000" |
| 986 | "000000000000000000000028f9b3fa54", |
| 987 | "00c62e0a0002000001168004f000800000000200000000000000000000000000" |
| 988 | "000000000000000000000028cdacda4e", |
| 989 | "00c72e0a0002000001168005f000800000000200000000000000000000000000" |
| 990 | "00000000000000000000002837133b6e", |
| 991 | "00c82e0a0002000001168006f000800000000200000000000000000000000000" |
| 992 | "000000000000000000000028d6447905", |
| 993 | "00c92e0a0002000001168007f000800000000200000000000000000000000000" |
| 994 | "000000000000000000000028021a3910", |
| 995 | "00ca2e0a0002000001168008f000800100000200000000000000000000000000" |
| 996 | "00000000000000000000002835d3cf43", |
| 997 | "00cb2e0a0002000001168009f000800100000200000000000000000000000000" |
| 998 | "00000000000000000000002887ad76fc", |
| 999 | "00cc2e0a000200000116800af000800100000200000000000000000000000000" |
| 1000 | "00000000000000000000002895e3d838", |
| 1001 | "00cd2e0a000200000116800bf000800100000200000000000000000000000000" |
| 1002 | "000000000000000000000028a07489ac", |
| 1003 | "00ce2e0a000200000116800cf000800100000200000000000000000000000000" |
| 1004 | "0000000000000000000000285d08821d", |
| 1005 | "00cf2e0a000200000116800df000800100000200000000000000000000000000" |
| 1006 | "000000000000000000000028302249a4", |
| 1007 | "00d02e0a000200000116800ef000800100000200000000000000000000000000" |
| 1008 | "0000000000000000000000283966d3bc", |
| 1009 | "00d12e0a000200000116800ff000800100000200000000000000000000000000" |
| 1010 | "0000000000000000000000289519cdb5", |
| 1011 | "00d22e0a0002000001168010f000800200000200000000000000000000000000" |
| 1012 | "0000000000000000000000281bc99b7b", |
| 1013 | "00d32e0a0002000001168011f000800200000200000000000000000000000000" |
| 1014 | "000000000000000000000028e483b1a0", |
| 1015 | "00d42e0a0002000001168012f000800200000200000000000000000000000000" |
| 1016 | "0000000000000000000000286885d8bd", |
| 1017 | "00d52e0a0002000001168013f000800200000200000000000000000000000000" |
| 1018 | "000000000000000000000028cbe7afd8", |
| 1019 | "00d62e0a0002000001168014f000800200000200000000000000000000000000" |
| 1020 | "00000000000000000000002809009846", |
| 1021 | "00d72e0a0002000001168015f000800200000200000000000000000000000000" |
| 1022 | "0000000000000000000000285bee86c4", |
| 1023 | "00d82e0a0002000001168016f000800200000200000000000000000000000000" |
| 1024 | "0000000000000000000000281f25725c", |
| 1025 | "00d92e0a0002000001168017f000800200000200000000000000000000000000" |
| 1026 | "00000000000000000000002872e94fe1", |
| 1027 | "00da2e0a0002000001168018f000800300000200000000000000000000000000" |
| 1028 | "000000000000000000000028e39d572f", |
| 1029 | "00db2e0a0002000001168019f000800300000200000000000000000000000000" |
| 1030 | "0000000000000000000000281c9dcadd", |
| 1031 | "00dc2e0a000200000116801af000800300000200000000000000000000000000" |
| 1032 | "0000000000000000000000287c5b8405", |
| 1033 | "00dd2e0a000200000116801bf000800300000200000000000000000000000000" |
| 1034 | "00000000000000000000002826334420", |
| 1035 | "00de2e0a000200000116801cf000800300000200000000000000000000000000" |
| 1036 | "00000000000000000000002871ee1536", |
| 1037 | "00df2e0a000200000116801df000800300000200000000000000000000000000" |
| 1038 | "0000000000000000000000289dfeeeb9", |
| 1039 | "00e02e0a000200000116801ef000800300000200000000000000000000000000" |
| 1040 | "000000000000000000000028954d55b3", |
| 1041 | "00e12e0a000200000116801ff000800300000200000000000000000000000000" |
| 1042 | "000000000000000000000028930c564e", |
| 1043 | "00e22e0a0002000001168020f000800400000200000000000000000000000000" |
| 1044 | "000000000000000000000028b9cec3bf", |
| 1045 | "00e32e0a0002000001168021f000800400000200000000000000000000000000" |
| 1046 | "0000000000000000000000284263f268", |
| 1047 | "00e42e0a0002000001168022f000800400000200000000000000000000000000" |
| 1048 | "000000000000000000000028913e5219", |
| 1049 | "00e52e0a0002000001168023f000800400000200000000000000000000000000" |
| 1050 | "000000000000000000000028efe86fe1", |
| 1051 | "00e62e0a0002000001168024f000800400000200000000000000000000000000" |
| 1052 | "000000000000000000000028deb045df", |
| 1053 | "00e72e0a0002000001168025f000800400000200000000000000000000000000" |
| 1054 | "000000000000000000000028255bcd32", |
| 1055 | "00e82e0a0002000001168026f000800400000200000000000000000000000000" |
| 1056 | "000000000000000000000028355392ad", |
| 1057 | "00e92e0a0002000001168027f000800400000200000000000000000000000000" |
| 1058 | "000000000000000000000028404a6aca", |
| 1059 | "00ea2e0a0002000001168028f000800500000200000000000000000000000000" |
| 1060 | "0000000000000000000000281de78f94", |
| 1061 | "00eb2e0a0002000001168029f000800500000200000000000000000000000000" |
| 1062 | "000000000000000000000028501a3aae", |
| 1063 | "00ec2e0a000200000116802af000800500000200000000000000000000000000" |
| 1064 | "0000000000000000000000282947d976", |
| 1065 | "00ed2e0a000200000116802bf000800500000200000000000000000000000000" |
| 1066 | "000000000000000000000028095cfe0d", |
| 1067 | "00ee2e0a000200000116802cf000800500000200000000000000000000000000" |
| 1068 | "000000000000000000000028bbcfc27a", |
| 1069 | "00ef2e0a000200000116802df000800500000200000000000000000000000000" |
| 1070 | "000000000000000000000028dbb27396", |
| 1071 | "00f02e0a000200000116802ef000800500000200000000000000000000000000" |
| 1072 | "000000000000000000000028dbe9b225", |
| 1073 | "00f12e0a000200000116802ff000800500000200000000000000000000000000" |
| 1074 | "000000000000000000000028840c0b08", |
| 1075 | "00f22e0a0002000001168030f000800600000200000000000000000000000000" |
| 1076 | "0000000000000000000000287683e4f8", |
| 1077 | "00f32e0a0002000001168031f000800600000200000000000000000000000000" |
| 1078 | "00000000000000000000002844d131d1", |
| 1079 | "00f42e0a0002000001168032f000800600000200000000000000000000000000" |
| 1080 | "0000000000000000000000284d2c2c6d", |
| 1081 | "00f52e0a0002000001168033f000800600000200000000000000000000000000" |
| 1082 | "000000000000000000000028e89a166c", |
| 1083 | "00f62e0a0002000001168034f000800600000200000000000000000000000000" |
| 1084 | "0000000000000000000000280f47db8c", |
| 1085 | "00f72e0a0002000001168035f000800600000200000000000000000000000000" |
| 1086 | "0000000000000000000000283ede8b3e", |
| 1087 | "00f82e0a0002000001168036f000800600000200000000000000000000000000" |
| 1088 | "000000000000000000000028580547db", |
| 1089 | "00f92e0a0002000001168037f000800600000200000000000000000000000000" |
| 1090 | "000000000000000000000028d72a270e", |
| 1091 | "00fa2e0a0002000001168038f000800700000200000000000000000000000000" |
| 1092 | "000000000000000000000028c25ce712", |
| 1093 | "00fb2e0a0002000001168039f000800700000200000000000000000000000000" |
| 1094 | "000000000000000000000028b908637e", |
| 1095 | "00fc2e0a000200000116803af000800700000200000000000000000000000000" |
| 1096 | "0000000000000000000000285b66e6fa", |
| 1097 | "00fd2e0a000200000116803bf000800700000200000000000000000000000000" |
| 1098 | "00000000000000000000002855c10393", |
| 1099 | "00fe2e0a000200000116803cf000800700000200000000000000000000000000" |
| 1100 | "0000000000000000000000283e94c57d", |
| 1101 | "00ff2e0a000200000116803df000800700000200000000000000000000000000" |
| 1102 | "0000000000000000000000284347e7f0", |
| 1103 | "01002e0a000200000116803ef000800700000200000000000000000000000000" |
| 1104 | "000000000000000000000028be66429d", |
| 1105 | "01012e0a000200000116803ff000800700000200000000000000000000000000" |
| 1106 | "0000000000000000000000284f7db145", |
| 1107 | "01022e0a0002000001490401c000000000000000000000000000000000000000" |
| 1108 | "000000000000000000000028470aa043", |
| 1109 | "01032e0a00020000014904012000000000000000000000000000000000000000" |
| 1110 | "000000000000000000000028a6bc6e48", |
| 1111 | "01042e0a00020000014904011800ffffffff0000000000000000000000000000" |
| 1112 | "000000000000000000000028f747c739", |
| 1113 | ] |
| 1114 | mask = "%5s %9s %20s %9s %s" |
| 1115 | print |
| 1116 | print mask % ("seq", "class_id", "class", "instance", "attributes") |
| 1117 | for i, data in enumerate(refs): |
| 1118 | frame = OmciFrame(hex2raw(data)) |
| 1119 | omci = frame.omci_message |
| 1120 | # frame.show() |
| 1121 | print mask % ( |
| 1122 | str(i), |
| 1123 | str(omci.object_entity_class), |
| 1124 | entity_id_to_class_map[omci.object_entity_class].__name__, |
| 1125 | '0x%x' % omci.object_entity_id, |
| 1126 | '\n '.join( |
| 1127 | '%s: %s' % (k, v) for k, v in omci.object_data.items()) |
| 1128 | ) |
| 1129 | |
| 1130 | def test_onu_reboot(self): |
| 1131 | ref = '0016590a01000000000000000000000000000'\ |
| 1132 | '0000000000000000000000000000000000000'\ |
| 1133 | '00000000000028' |
| 1134 | |
| 1135 | frame = OmciFrame( |
| 1136 | transaction_id=22, |
| 1137 | message_type=OmciReboot.message_id, |
| 1138 | omci_message=OmciReboot( |
| 1139 | entity_class=OntG.class_id, |
Matt Jeanneret | 702f05f | 2019-09-17 19:47:34 -0400 | [diff] [blame] | 1140 | entity_id=0 |
Chip Boling | 67b674a | 2019-02-08 11:42:18 -0600 | [diff] [blame] | 1141 | ) |
| 1142 | ) |
| 1143 | self.assertGeneratedFrameEquals(frame, ref) |
| 1144 | |
| 1145 | def test_omci_entity_ids(self): |
| 1146 | from pyvoltha.adapters.extensions.omci.omci_entities import entity_classes |
| 1147 | |
| 1148 | # For Entity Classes that have a Managed Entity ID with Set-By-Create |
| 1149 | # access, verify that the attribute name matches 'managed_entity_id' |
| 1150 | # |
| 1151 | # This is critical for the MIB Synchronizer state machine as it needs |
| 1152 | # to backfill Set-By-Create attributes when it sees a Create response |
| 1153 | # but it needs to ignore the 'managed_entity_id' attribute (by name). |
| 1154 | |
| 1155 | for entity in entity_classes: |
| 1156 | mei_attr = entity.attributes[0] |
| 1157 | self.assertIsNotNone(mei_attr) |
| 1158 | self.assertTrue(AA.SBC not in mei_attr.access or |
| 1159 | mei_attr.field.name == 'managed_entity_id') |
| 1160 | |
Matt Jeanneret | 702f05f | 2019-09-17 19:47:34 -0400 | [diff] [blame] | 1161 | def test_get_response_without_error_but_too_big(self): |
| 1162 | # This test is related to a bug that I believe is in the BroadCom |
| 1163 | # ONU stack software, or at least it was seen on both an Alpha and |
| 1164 | # an T&W BCM-based onu. The IEEE 802.1p Mapper Service Profile ME |
| 1165 | # (#130) sent by the ONUs have a payload of 27 octets based on the |
| 1166 | # Attribute Mask in the encoding. However, get-response baseline |
| 1167 | # messages have the last 4 octets reserved for failed/errored attribute |
| 1168 | # masks so only 25 octets should be allowed. Of course the 4 octets |
| 1169 | # are only valid if the status code == 9, but they still should |
| 1170 | # be reserved. |
| 1171 | # |
| 1172 | # This test verifies that we can still parse the 27 octet payload |
| 1173 | # since the first rule of interoperability is to be lenient with |
| 1174 | # what you receive and strict with what you transmit. |
| 1175 | # |
| 1176 | ref = '017d290a008280020000780000000000000000000000' +\ |
| 1177 | '0000000000000000000000000000' +\ |
| 1178 | '01' +\ |
| 1179 | '02' +\ |
| 1180 | '0000' +\ |
| 1181 | '00000028' |
| 1182 | zeros_24 = '000000000000000000000000000000000000000000000000' |
| 1183 | bytes_24 = unhexlify(zeros_24) |
| 1184 | attributes = { |
| 1185 | "unmarked_frame_option": 0, # 1 octet |
| 1186 | "dscp_to_p_bit_mapping": bytes_24, # 24 octets |
| 1187 | "default_p_bit_marking": 1, # 1 octet - This is too much |
| 1188 | "tp_type": 2, # 1 octet |
| 1189 | } |
| 1190 | frame = OmciFrame( |
| 1191 | transaction_id=0x017d, |
| 1192 | message_type=OmciGetResponse.message_id, |
| 1193 | omci_message=OmciGetResponse( |
| 1194 | entity_class=Ieee8021pMapperServiceProfile.class_id, |
| 1195 | success_code=0, |
| 1196 | entity_id=0x8002, |
| 1197 | attributes_mask=Ieee8021pMapperServiceProfile.mask_for(*attributes.keys()), |
| 1198 | data=attributes |
| 1199 | ) |
| 1200 | ) |
| 1201 | self.assertGeneratedFrameEquals(frame, ref) |
| 1202 | |
| 1203 | def test_get_response_with_errors_max_data(self): |
| 1204 | # First a frame with maximum data used up. This aligns the fields up perfectly |
| 1205 | # with the simplest definition of a Get Response |
| 1206 | ref = '017d290a008280020900600000000000000000000000' +\ |
| 1207 | '0000000000000000000000000000' +\ |
| 1208 | '0010' +\ |
| 1209 | '0008' +\ |
| 1210 | '00000028' |
| 1211 | zeros_24 = '000000000000000000000000000000000000000000000000' |
| 1212 | bytes_24 = unhexlify(zeros_24) |
| 1213 | good_attributes = { |
| 1214 | "unmarked_frame_option": 0, # 1 octet |
| 1215 | "dscp_to_p_bit_mapping": bytes_24, # 24 octets |
| 1216 | } |
| 1217 | unsupported_attributes = ["default_p_bit_marking"] |
| 1218 | failed_attributes_mask = ["tp_type"] |
| 1219 | |
| 1220 | the_class = Ieee8021pMapperServiceProfile |
| 1221 | frame = OmciFrame( |
| 1222 | transaction_id=0x017d, |
| 1223 | message_type=OmciGetResponse.message_id, |
| 1224 | omci_message=OmciGetResponse( |
| 1225 | entity_class=the_class.class_id, |
| 1226 | success_code=9, |
| 1227 | entity_id=0x8002, |
| 1228 | attributes_mask=the_class.mask_for(*good_attributes.keys()), |
| 1229 | unsupported_attributes_mask=the_class.mask_for(*unsupported_attributes), |
| 1230 | failed_attributes_mask=the_class.mask_for(*failed_attributes_mask), |
| 1231 | data=good_attributes |
| 1232 | ) |
| 1233 | ) |
| 1234 | self.assertGeneratedFrameEquals(frame, ref) |
| 1235 | |
| 1236 | def test_get_response_with_errors_min_data(self): |
| 1237 | # Next a frame with only a little data used up. This aligns will require |
| 1238 | # the encoder and decoder to skip to the last 8 octets of the data field |
| 1239 | # and encode the failed masks there |
| 1240 | ref = '017d290a00828002090040' +\ |
| 1241 | '01' + '00000000000000000000' +\ |
| 1242 | '0000000000000000000000000000' +\ |
| 1243 | '0010' +\ |
| 1244 | '0028' +\ |
| 1245 | '00000028' |
| 1246 | |
| 1247 | good_attributes = { |
| 1248 | "unmarked_frame_option": 1, # 1 octet |
| 1249 | } |
| 1250 | unsupported_attributes = ["default_p_bit_marking"] |
| 1251 | failed_attributes_mask = ["dscp_to_p_bit_mapping", "tp_type"] |
| 1252 | |
| 1253 | the_class = Ieee8021pMapperServiceProfile |
| 1254 | frame = OmciFrame( |
| 1255 | transaction_id=0x017d, |
| 1256 | message_type=OmciGetResponse.message_id, |
| 1257 | omci_message=OmciGetResponse( |
| 1258 | entity_class=the_class.class_id, |
| 1259 | success_code=9, |
| 1260 | entity_id=0x8002, |
| 1261 | attributes_mask=the_class.mask_for(*good_attributes.keys()), |
| 1262 | unsupported_attributes_mask=the_class.mask_for(*unsupported_attributes), |
| 1263 | failed_attributes_mask=the_class.mask_for(*failed_attributes_mask), |
| 1264 | data=good_attributes |
| 1265 | ) |
| 1266 | ) |
| 1267 | self.assertGeneratedFrameEquals(frame, ref) |
| 1268 | |
| 1269 | # Now test decode of the packet |
| 1270 | decoded = OmciFrame(unhexlify(ref)) |
| 1271 | |
| 1272 | orig_fields = frame.fields['omci_message'].fields |
| 1273 | omci_fields = decoded.fields['omci_message'].fields |
| 1274 | |
| 1275 | for field in ['entity_class', 'entity_id', 'attributes_mask', |
| 1276 | 'success_code', 'unsupported_attributes_mask', |
| 1277 | 'failed_attributes_mask']: |
| 1278 | self.assertEqual(omci_fields[field], orig_fields[field]) |
| 1279 | |
| 1280 | self.assertEqual(omci_fields['data']['unmarked_frame_option'], |
| 1281 | orig_fields['data']['unmarked_frame_option']) |
| 1282 | |
Chip Boling | 67b674a | 2019-02-08 11:42:18 -0600 | [diff] [blame] | 1283 | |
| 1284 | if __name__ == '__main__': |
| 1285 | main() |