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