blob: a8a2d0587350083f6e149cb59a9307983afad4b6 [file] [log] [blame]
Chip Boling32aab302019-01-23 10:50: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#
16"""
17OMCI Managed Entity Frame support
18"""
19from voltha.extensions.omci.omci import *
20from voltha.extensions.omci.me_frame import MEFrame
21
22
23class CardholderFrame(MEFrame):
24 """
25 This managed entity represents fixed equipment slot configuration
26 for the ONU
27 """
28 def __init__(self, single, slot_number, attributes):
29 """
30 :param single:(bool) True if the ONU is a single piece of integrated equipment,
31 False if the ONU contains pluggable equipment modules
32 :param slot_number: (int) slot number (0..254)
33
34 :param attributes: (basestring, list, set, dict) attributes. For gets
35 a string, list, or set can be provided. For create/set
36 operations, a dictionary should be provided, for
37 deletes None may be specified.
38 """
39 # Validate
40 MEFrame.check_type(single, bool)
41 MEFrame.check_type(slot_number, int)
42 if not 0 <= slot_number <= 254:
43 raise ValueError('slot_number should be 0..254')
44
45 entity_id = 256 + slot_number if single else slot_number
46
47 super(CardholderFrame, self).__init__(Cardholder, entity_id,
48 MEFrame._attr_to_data(attributes))
49
50
51class CircuitPackFrame(MEFrame):
52 """
53 This managed entity models a real or virtual circuit pack that is equipped in
54 a real or virtual ONU slot.
55 """
56 def __init__(self, entity_id, attributes):
57 """
58 :param entity_id: (int) This attribute uniquely identifies each instance of
59 this managed entity. Its value is the same as that
60 of the cardholder managed entity containing this
61 circuit pack instance. (0..65535)
62
63 :param attributes: (basestring, list, set, dict) attributes. For gets
64 a string, list, or set can be provided. For create/set
65 operations, a dictionary should be provided, for
66 deletes None may be specified.
67 """
68 super(CircuitPackFrame, self).__init__(CircuitPack, entity_id,
69 MEFrame._attr_to_data(attributes))
70
71
72class ExtendedVlanTaggingOperationConfigurationDataFrame(MEFrame):
73 """
74 This managed entity organizes data associated with VLAN tagging. Regardless
75 of its point of attachment, the specified tagging operations refer to the
76 upstream direction.
77 """
78 def __init__(self, entity_id, attributes):
79 """
80 :param entity_id: (int) This attribute uniquely identifies each instance of
81 this managed entity. Its value is the same as that
82 of the cardholder managed entity containing this
83 circuit pack instance. (0..65535)
84
85 :param attributes: (basestring, list, set, dict) attributes. For gets
86 a string, list, or set can be provided. For create/set
87 operations, a dictionary should be provided, for
88 deletes None may be specified.
89 """
90 super(ExtendedVlanTaggingOperationConfigurationDataFrame,
91 self).__init__(ExtendedVlanTaggingOperationConfigurationData,
92 entity_id,
93 MEFrame._attr_to_data(attributes))
94
95
96class IpHostConfigDataFrame(MEFrame):
97 """
98 The IP host config data configures IPv4 based services offered on the ONU.
99 """
100 def __init__(self, entity_id, attributes):
101 """
102 :param entity_id: (int) This attribute uniquely identifies each instance of
103 this managed entity. (0..65535)
104
105 :param attributes: (basestring, list, set, dict) attributes. For gets
106 a string, list, or set can be provided. For create/set
107 operations, a dictionary should be provided, for
108 deletes None may be specified.
109 """
110 super(IpHostConfigDataFrame, self).__init__(IpHostConfigData,
111 entity_id,
112 MEFrame._attr_to_data(attributes))
113
114
115class GalEthernetProfileFrame(MEFrame):
116 """
117 This managed entity organizes data that describe the GTC adaptation layer
118 processing functions of the ONU for Ethernet services.
119 """
120 def __init__(self, entity_id, max_gem_payload_size=None):
121 """
122 :param entity_id: (int) This attribute uniquely identifies each instance of
123 this managed entity. (0..65535)
124
125 :param max_gem_payload_size: (int) This attribute defines the maximum payload
126 size generated in the associated GEM interworking
127 termination point managed entity. (0..65535
128 """
129 MEFrame.check_type(max_gem_payload_size, (int, type(None)))
130 if max_gem_payload_size is not None and not 0 <= max_gem_payload_size <= 0xFFFF: # TODO: verify min/max
131 raise ValueError('max_gem_payload_size should be 0..0xFFFF')
132
133 data = None if max_gem_payload_size is None else\
134 {
135 'max_gem_payload_size': max_gem_payload_size
136 }
137 super(GalEthernetProfileFrame, self).__init__(GalEthernetProfile,
138 entity_id,
139 data)
140
141
142class GemInterworkingTpFrame(MEFrame):
143 """
144 An instance of this managed entity represents a point in the ONU where the
145 interworking of a bearer service (usually Ethernet) to the GEM layer takes
146 place.
147 """
148 def __init__(self, entity_id,
149 gem_port_network_ctp_pointer=None,
150 interworking_option=None,
151 service_profile_pointer=None,
152 interworking_tp_pointer=None,
153 pptp_counter=None,
154 gal_profile_pointer=None,
155 attributes=None):
156 """
157 :param entity_id: (int) This attribute uniquely identifies each instance of
158 this managed entity. (0..65535)
159
160 :param gem_port_network_ctp_pointer: (int) This attribute points to an instance of
161 the GEM port network CTP. (0..65535)
162
163 :param interworking_option: (int) This attribute identifies the type
164 of non-GEM function that is being interworked.
165 The options are:
166 0 Circuit-emulated TDM
167 1 MAC bridged LAN
168 2 Reserved
169 3 Reserved
170 4 Video return path
171 5 IEEE 802.1p mapper
172 6 Downstream broadcast
173 7 MPLS PW TDM service
174
175 :param service_profile_pointer: (int) This attribute points to an instance of
176 a service profile.
177 CES service profile if interworking option = 0
178 MAC bridge service profile if interworking option = 1
179 Video return path service profile if interworking option = 4
180 IEEE 802.1p mapper service profile if interworking option = 5
181 Null pointer if interworking option = 6
182 CES service profile if interworking option = 7
183
184 :param interworking_tp_pointer: (int) This attribute is used for the circuit
185 emulation service and IEEE 802.1p mapper
186 service without a MAC bridge.
187
188 :param gal_profile_pointer: (int) This attribute points to an instance of
189 a service profile.
190
191 :param attributes: (basestring, list, set, dict) additional ME attributes.
192 not specifically specified as a parameter. For gets
193 a string, list, or set can be provided. For create/set
194 operations, a dictionary should be provided, for
195 deletes None may be specified..
196 """
197 # Validate
198 self.check_type(gem_port_network_ctp_pointer, (int, type(None)))
199 self.check_type(interworking_option, (int, type(None)))
200 self.check_type(service_profile_pointer, (int, type(None)))
201 self.check_type(interworking_tp_pointer,(int, type(None)))
202 self.check_type(pptp_counter,(int, type(None)))
203 self.check_type(gal_profile_pointer, (int, type(None)))
204
205 if gem_port_network_ctp_pointer is not None and not 0 <= gem_port_network_ctp_pointer <= 0xFFFE: # TODO: Verify max
206 raise ValueError('gem_port_network_ctp_pointer should be 0..0xFFFE')
207
208 if interworking_option is not None and not 0 <= interworking_option <= 7:
209 raise ValueError('interworking_option should be 0..7')
210
211 if service_profile_pointer is not None and not 0 <= service_profile_pointer <= 0xFFFE: # TODO: Verify max
212 raise ValueError('service_profile_pointer should be 0..0xFFFE')
213
214 if interworking_tp_pointer is not None and not 0 <= interworking_tp_pointer <= 0xFFFE: # TODO: Verify max
215 raise ValueError('interworking_tp_pointer should be 0..0xFFFE')
216
217 if pptp_counter is not None and not 0 <= pptp_counter <= 255: # TODO: Verify max
218 raise ValueError('pptp_counter should be 0..255')
219
220 if gal_profile_pointer is not None and not 0 <= gal_profile_pointer <= 0xFFFE: # TODO: Verify max
221 raise ValueError('gal_profile_pointer should be 0..0xFFFE')
222
223 data = MEFrame._attr_to_data(attributes)
224
225 if gem_port_network_ctp_pointer is not None or \
226 interworking_option is not None or \
227 service_profile_pointer is not None or \
228 interworking_tp_pointer is not None or \
229 gal_profile_pointer is not None:
230
231 data = data or dict()
232
233 if gem_port_network_ctp_pointer is not None:
234 data['gem_port_network_ctp_pointer'] = gem_port_network_ctp_pointer
235
236 if interworking_option is not None:
237 data['interworking_option'] = interworking_option
238
239 if service_profile_pointer is not None:
240 data['service_profile_pointer'] = service_profile_pointer
241
242 if interworking_tp_pointer is not None:
243 data['interworking_tp_pointer'] = interworking_tp_pointer
244
245 if gal_profile_pointer is not None:
246 data['gal_profile_pointer'] = gal_profile_pointer
247
248 super(GemInterworkingTpFrame, self).__init__(GemInterworkingTp,
249 entity_id,
250 data)
251
252
253class GemPortNetworkCtpFrame(MEFrame):
254 """
255 This managed entity represents the termination of a GEM port on an ONU.
256 """
257 def __init__(self, entity_id, port_id=None, tcont_id=None,
258 direction=None, upstream_tm=None, attributes=None):
259 """
260 :param entity_id: (int) This attribute uniquely identifies each instance of
261 this managed entity. (0..65535)
262
263 :param port_id: (int) This attribute is the port-ID of the GEM port associated
264 with this CTP
265
266 :param tcont_id: (int) This attribute points to a T-CONT instance
267
268 :param direction: (string) Data direction. Valid values are:
269 'upstream' - UNI-to-ANI
270 'downstream' - ANI-to-UNI
271 'bi-directional' - guess :-)
272
273 :param upstream_tm: (int) If the traffic management option attribute in
274 the ONU-G ME is 0 (priority controlled) or 2
275 (priority and rate controlled), this pointer
276 specifies the priority queue ME serving this GEM
277 port network CTP. If the traffic management
278 option attribute is 1 (rate controlled), this
279 attribute redundantly points to the T-CONT serving
280 this GEM port network CTP.
281
282 :param attributes: (basestring, list, set, dict) additional ME attributes.
283 not specifically specified as a parameter. For gets
284 a string, list, or set can be provided. For create/set
285 operations, a dictionary should be provided, for
286 deletes None may be specified.
287 """
288 _directions = {"upstream": 1, "downstream": 2, "bi-directional": 3}
289
290 # Validate
291 self.check_type(port_id, (int, type(None)))
292 self.check_type(tcont_id, (int, type(None)))
293 self.check_type(direction, (basestring, type(None)))
294 self.check_type(upstream_tm, (int, type(None)))
295
296 if port_id is not None and not 0 <= port_id <= 0xFFFE: # TODO: Verify max
297 raise ValueError('port_id should be 0..0xFFFE')
298
299 if tcont_id is not None and not 0 <= tcont_id <= 0xFFFE: # TODO: Verify max
300 raise ValueError('tcont_id should be 0..0xFFFE')
301
302 if direction is not None and str(direction).lower() not in _directions:
303 raise ValueError('direction should one of {}'.format(_directions.keys()))
304
305 if upstream_tm is not None and not 0 <= upstream_tm <= 0xFFFE: # TODO: Verify max
306 raise ValueError('upstream_tm should be 0..0xFFFE')
307
308 data = MEFrame._attr_to_data(attributes)
309
310 if port_id is not None or tcont_id is not None or\
311 direction is not None or upstream_tm is not None:
312
313 data = data or dict()
314
315 if port_id is not None:
316 data['port_id'] = port_id
317 if tcont_id is not None:
318 data['tcont_pointer'] = tcont_id
319 if direction is not None:
320 data['direction'] = _directions[str(direction).lower()]
321 if upstream_tm is not None:
322 data['traffic_management_pointer_upstream'] = upstream_tm
323
324 super(GemPortNetworkCtpFrame, self).__init__(GemPortNetworkCtp,
325 entity_id,
326 data)
327
328
329class Ieee8021pMapperServiceProfileFrame(MEFrame):
330 """
331 This managed entity associates the priorities of IEEE 802.1p [IEEE
332 802.1D] priority tagged frames with specific connections.
333 """
334 def __init__(self, entity_id, tp_pointer=None, interwork_tp_pointers=None):
335 """
336 :param entity_id: (int) This attribute uniquely identifies each instance of
337 this managed entity. (0..65535)
338
339 :param tp_pointer: (int) This attribute points to an instance of the
340 associated termination point. (0..65535)
341
342 :param interwork_tp_pointers: (list) List of 1 to 8 interworking termination
343 point IDs. The first entry is assigned
344 got p-bit priority 0. If less than 8 IDs
345 are provided, the last ID is used for
346 the remaining items.
347 """
348 if tp_pointer is None and interwork_tp_pointers is None:
349 data = dict(
350 tp_pointer=OmciNullPointer,
351 interwork_tp_pointer_for_p_bit_priority_0=OmciNullPointer,
352 interwork_tp_pointer_for_p_bit_priority_1=OmciNullPointer,
353 interwork_tp_pointer_for_p_bit_priority_2=OmciNullPointer,
354 interwork_tp_pointer_for_p_bit_priority_3=OmciNullPointer,
355 interwork_tp_pointer_for_p_bit_priority_4=OmciNullPointer,
356 interwork_tp_pointer_for_p_bit_priority_5=OmciNullPointer,
357 interwork_tp_pointer_for_p_bit_priority_6=OmciNullPointer,
358 interwork_tp_pointer_for_p_bit_priority_7=OmciNullPointer
359 )
360 else:
361 self.check_type(tp_pointer, (list, type(None)))
362 self.check_type(interwork_tp_pointers, (list, type(None)))
363
364 data = dict()
365
366 if tp_pointer is not None:
367 data['tp_pointer'] = tp_pointer
368
369 if interwork_tp_pointers is not None:
370 assert all(isinstance(tp, int) and 0 <= tp <= 0xFFFF
371 for tp in interwork_tp_pointers),\
372 'Interworking TP IDs must be 0..0xFFFF'
373 assert 1 <= len(interwork_tp_pointers) <= 8, \
374 'Invalid number of Interworking TP IDs. Must be 1..8'
375
376 data = dict()
377 for pbit in range(0, len(interwork_tp_pointers)):
378 data['interwork_tp_pointer_for_p_bit_priority_{}'.format(pbit)] = \
379 interwork_tp_pointers[pbit]
380
381 for pbit in range(len(interwork_tp_pointers), 8):
382 data['interwork_tp_pointer_for_p_bit_priority_{}'.format(pbit)] = \
383 interwork_tp_pointers[len(interwork_tp_pointers) - 1]
384
385 super(Ieee8021pMapperServiceProfileFrame, self).__init__(Ieee8021pMapperServiceProfile,
386 entity_id,
387 data)
388
389
390class MacBridgePortConfigurationDataFrame(MEFrame):
391 """
392 This managed entity represents the ONU as equipment.
393 """
394 def __init__(self, entity_id, bridge_id_pointer=None, port_num=None,
395 tp_type=None, tp_pointer=None, attributes=None):
396 """
397 :param entity_id: (int) This attribute uniquely identifies each instance of
398 this managed entity. (0..65535)
399
400 :param bridge_id_pointer: (int) This attribute points to an instance of the
401 MAC bridge service profile. (0..65535)
402
403 :param port_num: (int) This attribute is the bridge port number. (0..255)
404
405 :param tp_type: (int) This attribute identifies the type of termination point
406 associated with this MAC bridge port. Valid values are:
407 1 Physical path termination point Ethernet UNI
408 2 Interworking VCC termination point
409 3 IEEE 802.1p mapper service profile
410 4 IP host config data or IPv6 host config data
411 5 GEM interworking termination point
412 6 Multicast GEM interworking termination point
413 7 Physical path termination point xDSL UNI part 1
414 8 Physical path termination point VDSL UNI
415 9 Ethernet flow termination point
416 10 Reserved
417 11 Virtual Ethernet interface point
418 12 Physical path termination point MoCA UNI
419
420 :param tp_pointer: (int) This attribute points to the termination point
421 associated with this MAC bridge por. (0..65535)
422
423 :param attributes: (basestring, list, set, dict) additional ME attributes.
424 not specifically specified as a parameter. For gets
425 a string, list, or set can be provided. For create/set
426 operations, a dictionary should be provided, for
427 deletes None may be specified.
428 """
429 # Validate
430 self.check_type(bridge_id_pointer, (int, type(None)))
431 self.check_type(port_num, (int, type(None)))
432 self.check_type(tp_type, (int, type(None)))
433 self.check_type(tp_pointer, (int, type(None)))
434
435 if bridge_id_pointer is not None and not 0 <= bridge_id_pointer <= 0xFFFE: # TODO: Verify max
436 raise ValueError('bridge_id_pointer should be 0..0xFFFE')
437
438 if port_num is not None and not 0 <= port_num <= 255:
439 raise ValueError('port_num should be 0..255') # TODO: Verify min,max
440
441 if tp_type is not None and not 1 <= tp_type <= 12:
442 raise ValueError('service_profile_pointer should be 1..12')
443
444 if tp_pointer is not None and not 0 <= tp_pointer <= 0xFFFE: # TODO: Verify max
445 raise ValueError('interworking_tp_pointer should be 0..0xFFFE')
446
447 data = MEFrame._attr_to_data(attributes)
448
449 if bridge_id_pointer is not None or \
450 port_num is not None or \
451 tp_type is not None or \
452 tp_pointer is not None:
453
454 data = data or dict()
455
456 if bridge_id_pointer is not None:
457 data['bridge_id_pointer'] = bridge_id_pointer
458
459 if port_num is not None:
460 data['port_num'] = port_num
461
462 if tp_type is not None:
463 data['tp_type'] = tp_type
464
465 if tp_pointer is not None:
466 data['tp_pointer'] = tp_pointer
467
468 super(MacBridgePortConfigurationDataFrame, self).\
469 __init__(MacBridgePortConfigurationData, entity_id, data)
470
471
472class MacBridgeServiceProfileFrame(MEFrame):
473 """
474 This managed entity models a MAC bridge in its entirety; any number
475 of ports may be associated with the bridge through pointers to the
476 MAC bridge service profile managed entity.
477 """
478 def __init__(self, entity_id, attributes=None):
479 """
480 :param entity_id: (int) This attribute uniquely identifies each instance of
481 this managed entity. (0..65535)
482
483 :param attributes: (basestring, list, set, dict) attributes. For gets
484 a string, list, or set can be provided. For create/set
485 operations, a dictionary should be provided, for
486 deletes None may be specified.
487 """
488 super(MacBridgeServiceProfileFrame, self).__init__(MacBridgeServiceProfile,
489 entity_id,
490 MEFrame._attr_to_data(attributes))
491
492
493class OntGFrame(MEFrame):
494 """
495 This managed entity represents the ONU as equipment.
496 """
497 def __init__(self, attributes=None):
498 """
499 :param attributes: (basestring, list, set, dict) attributes. For gets
500 a string, list, or set can be provided. For create/set
501 operations, a dictionary should be provided, for
502 deletes None may be specified.
503 """
504 super(OntGFrame, self).__init__(OntG, 0,
505 MEFrame._attr_to_data(attributes))
506
507
508class Ont2GFrame(MEFrame):
509 """
510 This managed entity contains additional attributes associated with a PON ONU.
511 """
512 def __init__(self, attributes=None):
513 """
514 :param attributes: (basestring, list, set, dict) attributes. For gets
515 a string, list, or set can be provided. For create/set
516 operations, a dictionary should be provided, for
517 deletes None may be specified.
518 """
519 # Only one managed entity instance (Entity ID=0)
520 super(Ont2GFrame, self).__init__(Ont2G, 0,
521 MEFrame._attr_to_data(attributes))
522
523
524class PptpEthernetUniFrame(MEFrame):
525 """
526 This managed entity represents the point at an Ethernet UNI where the physical path
527 terminates and Ethernet physical level functions are performed.
528 """
529 def __init__(self, entity_id, attributes=None):
530 """
531 :param entity_id: (int) This attribute uniquely identifies each instance of
532 this managed entity. (0..65535)
533
534 :param attributes: (basestring, list, set, dict) attributes. For gets
535 a string, list, or set can be provided. For create/set
536 operations, a dictionary should be provided, for
537 deletes None may be specified.
538 """
539 super(PptpEthernetUniFrame, self).__init__(PptpEthernetUni, entity_id,
540 MEFrame._attr_to_data(attributes))
541
542
543class VeipUniFrame(MEFrame):
544 """
545 This managed entity represents the point a virtual UNI interfaces to a non omci management domain
546 This is typically seen in RG+ONU all-in-one type devices
547 """
548 def __init__(self, entity_id, attributes=None):
549 """
550 :param entity_id: (int) This attribute uniquely identifies each instance of
551 this managed entity. (0..65535)
552
553 :param attributes: (basestring, list, set, dict) attributes. For gets
554 a string, list, or set can be provided. For create/set
555 operations, a dictionary should be provided, for
556 deletes None may be specified.
557 """
558 super(VeipUniFrame, self).__init__(VeipUni, entity_id,
559 MEFrame._attr_to_data(attributes))
560
561
562class SoftwareImageFrame(MEFrame):
563 """
564 This managed entity models an executable software image stored in the ONU.
565 """
566 def __init__(self, entity_id):
567 """
568 :param entity_id: (int) This attribute uniquely identifies each instance of
569 this managed entity. (0..65535)
570 """
571 super(SoftwareImageFrame, self).__init__(SoftwareImage, entity_id, None)
572
573
574class TcontFrame(MEFrame):
575 """
576 An instance of the traffic container managed entity T-CONT represents a
577 logical connection group associated with a G-PON PLOAM layer alloc-ID.
578 """
579 def __init__(self, entity_id, alloc_id=None, policy=None):
580 """
581 :param entity_id: (int) This attribute uniquely identifies each instance of
582 this managed entity. (0..65535)
583
584 :param alloc_id: (int) This attribute links the T-CONT with the alloc-ID
585 assigned by the OLT in the assign_alloc-ID PLOAM
586 message (0..0xFFF) or 0xFFFF to mark as free
587
588 :param policy: (int) This attribute indicates the T-CONT's traffic scheduling
589 policy. Valid values:
590 0 - Null
591 1 - Strict priority
592 2 - WRR - Weighted round robin
593 """
594 # Validate
595 self.check_type(alloc_id, (int, type(None)))
596 self.check_type(policy, (int, type(None)))
597
598 if alloc_id is not None and not (0 <= alloc_id <= 0xFFF or alloc_id == 0xFFFF):
599 raise ValueError('alloc_id should be 0..0xFFF or 0xFFFF to mark it as free')
600
601 if policy is not None and not 0 <= policy <= 2:
602 raise ValueError('policy should be 0..2')
603
604 if alloc_id is None and policy is None:
605 data = None
606 else:
607 data = dict()
608
609 if alloc_id is not None:
610 data['alloc_id'] = alloc_id
611
612 if policy is not None:
613 data['policy'] = policy
614
615 super(TcontFrame, self).__init__(Tcont, entity_id, data)
616
617
618class VlanTaggingFilterDataFrame(MEFrame):
619 """
620 An instance of this managed entity represents a point in the ONU where the
621 interworking of a bearer service (usually Ethernet) to the GEM layer takes
622 place.
623 """
624 def __init__(self, entity_id, vlan_tcis=None, forward_operation=None):
625 """
626 :param entity_id: (int) This attribute uniquely identifies each instance of
627 this managed entity. (0..65535)
628
629 :param vlan_tcis: (list) This attribute is a list of provisioned TCI values
630 for the bridge port. (0..0xFFFF)
631
632 :param forward_operation: (int) What to do. See ITU spec for more information
633
634 """
635 # Validate
636 self.check_type(vlan_tcis, (list, type(None)))
637 self.check_type(forward_operation, (int, type(None)))
638
639 if forward_operation is not None and not 0 <= forward_operation <= 0x21:
640 raise ValueError('forward_operation should be 0..0x21')
641
642 if vlan_tcis is None and forward_operation is None:
643 data = None
644
645 else:
646 data = dict()
647
648 if vlan_tcis is not None:
649 num_tcis = len(vlan_tcis)
650
651 assert 0 <= num_tcis <= 12, 'Number of VLAN TCI values is 0..12'
652 assert all(isinstance(tci, int) and 0 <= tci <= 0xFFFF
653 for tci in vlan_tcis), "VLAN TCI's are 0..0xFFFF"
654
655 if num_tcis > 0:
656 vlan_filter_list = [0] * 12
657 for index in range(0, num_tcis):
658 vlan_filter_list[index] = vlan_tcis[index]
659
660 data['vlan_filter_list'] = vlan_filter_list
661 data['number_of_entries'] = num_tcis
662
663 if forward_operation is not None:
664 assert 0 <= forward_operation <= 0x21, \
665 'forwarding_operation must be 0x00..0x21'
666 data['forward_operation'] = forward_operation
667
668 super(VlanTaggingFilterDataFrame, self).__init__(VlanTaggingFilterData,
669 entity_id,
670 data)
671
672
673class OntDataFrame(MEFrame):
674 """
675 This managed entity models the MIB itself
676 """
677 def __init__(self, mib_data_sync=None, sequence_number=None, ignore_arc=None):
678 """
679 For 'get', 'MIB reset', 'MIB upload', pass no value
680 For 'set' actions, pass mib_data_sync value (0..255)
681 For 'MIB upload next',and 'Get all alarms next' pass sequence_number value (0..65535)
682 For 'Get all alarms", set ignore_arc to True to get all alarms regadrless
683 of ARC status or False to get all alarms not currently
684 under ARC
685
686 :param mib_data_sync: (int) This attribute is used to check the alignment
687 of the MIB of the ONU with the corresponding MIB
688 in the OLT. (0..0xFF)
689 :param sequence_number: (int) This is used for MIB Upload Next (0..0xFFFF)
690 :param ignore_arc: (bool) None for all but 'get_all_alarm' commands
691 """
692 self.check_type(mib_data_sync, (int, type(None)))
693 if mib_data_sync is not None and not 0 <= mib_data_sync <= 0xFF:
694 raise ValueError('mib_data_sync should be 0..0xFF')
695
696 if sequence_number is not None and not 0 <= sequence_number <= 0xFFFF:
697 raise ValueError('sequence_number should be 0..0xFFFF')
698
699 if ignore_arc is not None and not isinstance(ignore_arc, bool):
700 raise TypeError('ignore_arc should be a boolean')
701
702 if mib_data_sync is not None:
703 # Note: Currently the Scapy decode/encode is 16-bits since we need
704 # the data field that large in order to support MIB and Alarm Upload Next
705 # commands. Push our 8-bit MDS value into the upper 8-bits so that
706 # it is encoded properly into the ONT_Data 'set' frame
707 data = {'mib_data_sync': mib_data_sync << 8}
708
709 elif sequence_number is not None:
710 data = {'mib_data_sync': sequence_number}
711
712 elif ignore_arc is not None:
713 data = {'mib_data_sync': 0 if ignore_arc else 1}
714
715 else:
716 data = {'mib_data_sync'} # Make Get's happy
717
718 super(OntDataFrame, self).__init__(OntData, 0, data)
719
720
721class OmciFrame(MEFrame):
722 """
723 This managed entity describes the ONU's general level of support for OMCI managed
724 entities and messages. This ME is not included in a MIB upload.
725 """
726 def __init__(self, me_type_table=None, message_type_table=None):
727 """
728 For 'get' request, set the type of table count you wish by
729 setting either me_me_type_table or message_type_table to
730 a boolean 'True' value
731
732 For 'get-next' requests, set the sequence number for the
733 table you wish to retrieve by setting either me_me_type_table or message_type_table to
734 a integer value.
735 """
736 if not isinstance(me_type_table, (bool, int, type(None))):
737 raise TypeError('Parameters must be a boolean or integer')
738
739 if not isinstance(message_type_table, (bool, int, type(None))):
740 raise TypeError('Parameters must be a boolean or integer')
741
742 if me_type_table is not None:
743 if isinstance(me_type_table, bool):
744 data = {'me_type_table'}
745 else:
746 data = {'me_type_table': me_type_table}
747
748 elif message_type_table is not None:
749 if isinstance('message_type_table', bool):
750 data = {'message_type_table'}
751 else:
752 data = {'message_type_table': message_type_table}
753 else:
754 raise NotImplemented('Unknown request')
755
756 super(OmciFrame, self).__init__(Omci, 0, data)
757
758
759class EthernetPMMonitoringHistoryDataFrame(MEFrame):
760 """
761 This managed entity collects some of the performance monitoring data for a physical
762 Ethernet interface
763 """
764 def __init__(self, entity_id, attributes):
765 """
766 :param entity_id: (int) This attribute uniquely identifies each instance of
767 this managed entity. Through an identical ID, this
768 managed entity is implicitly linked to an instance
769 of the physical path termination point Ethernet UNI
770
771 :param attributes: (basestring, list, set, dict) attributes. For gets
772 a string, list, or set can be provided. For set
773 operations, a dictionary should be provided, for
774 deletes None may be specified.
775 """
776 super(EthernetPMMonitoringHistoryDataFrame, self).__init__(
777 EthernetPMMonitoringHistoryData,
778 entity_id,
779 MEFrame._attr_to_data(attributes))
780
781
782class FecPerformanceMonitoringHistoryDataFrame(MEFrame):
783 """
784 This managed entity collects performance monitoring data associated with PON
785 downstream FEC counters.
786 """
787 def __init__(self, entity_id, attributes):
788 """
789 :param entity_id: (int) This attribute uniquely identifies each instance of
790 this managed entity. Through an identical ID, this
791 managed entity is implicitly linked to an instance of
792 the ANI-G
793
794 :param attributes: (basestring, list, set, dict) attributes. For gets
795 a string, list, or set can be provided. For set
796 operations, a dictionary should be provided, for
797 deletes None may be specified.
798 """
799 super(FecPerformanceMonitoringHistoryDataFrame, self).__init__(
800 FecPerformanceMonitoringHistoryData,
801 entity_id,
802 MEFrame._attr_to_data(attributes))
803
804
805class EthernetFrameDownstreamPerformanceMonitoringHistoryDataFrame(MEFrame):
806 """
807 This managed entity collects performance monitoring data associated with downstream
808 Ethernet frame delivery. It is based on the Etherstats group of [IETF RFC 2819].
809 """
810 def __init__(self, entity_id, attributes):
811 """
812 :param entity_id: (int) This attribute uniquely identifies each instance of
813 this managed entity. Through an identical ID, this
814 managed entity is implicitly linked to an instance of
815 a MAC bridge port configuration data
816
817 :param attributes: (basestring, list, set, dict) attributes. For gets
818 a string, list, or set can be provided. For set
819 operations, a dictionary should be provided, for
820 deletes None may be specified.
821 """
822 super(EthernetFrameDownstreamPerformanceMonitoringHistoryDataFrame, self).__init__(
823 EthernetFrameDownstreamPerformanceMonitoringHistoryData,
824 entity_id,
825 MEFrame._attr_to_data(attributes))
826
827
828class EthernetFrameUpstreamPerformanceMonitoringHistoryDataFrame(MEFrame):
829 """
830 This managed entity collects performance monitoring data associated with upstream
831 Ethernet frame delivery. It is based on the Etherstats group of [IETF RFC 2819].
832 """
833 def __init__(self, entity_id, attributes):
834 """
835 :param entity_id: (int) This attribute uniquely identifies each instance of
836 this managed entity. Through an identical ID, this
837 managed entity is implicitly linked to an instance of
838 a MAC bridge port configuration data
839
840 :param attributes: (basestring, list, set, dict) attributes. For gets
841 a string, list, or set can be provided. For set
842 operations, a dictionary should be provided, for
843 deletes None may be specified.
844 """
845 super(EthernetFrameUpstreamPerformanceMonitoringHistoryDataFrame, self).__init__(
846 EthernetFrameUpstreamPerformanceMonitoringHistoryData,
847 entity_id,
848 MEFrame._attr_to_data(attributes))
849
850
851class GemPortNetworkCtpMonitoringHistoryDataFrame(MEFrame):
852 """
853 This managed entity collects GEM frame performance monitoring data associated
854 with a GEM port network CTP
855 """
856 def __init__(self, entity_id, attributes):
857 """
858 :param entity_id: (int) This attribute uniquely identifies each instance of
859 this managed entity. Through an identical ID, this
860 managed entity is implicitly linked to an instance
861 of the GEM port network CTP.
862
863 :param attributes: (basestring, list, set, dict) attributes. For gets
864 a string, list, or set can be provided. For set
865 operations, a dictionary should be provided, for
866 deletes None may be specified.
867 """
868 super(GemPortNetworkCtpMonitoringHistoryDataFrame, self).__init__(
869 GemPortNetworkCtpMonitoringHistoryData,
870 entity_id,
871 MEFrame._attr_to_data(attributes))
872
873
874class XgPonTcPerformanceMonitoringHistoryDataFrame(MEFrame):
875 """
876 This managed entity collects performance monitoring data associated with
877 the XG-PON transmission convergence layer, as defined in [ITU-T G.987.3]
878 """
879 def __init__(self, entity_id, attributes):
880 """
881 :param entity_id: (int) This attribute uniquely identifies each instance of
882 this managed entity. Through an identical ID, this
883 managed entity is implicitly linked to an instance of
884 the ANI-G.
885
886 :param attributes: (basestring, list, set, dict) attributes. For gets
887 a string, list, or set can be provided. For set
888 operations, a dictionary should be provided, for
889 deletes None may be specified.
890 """
891 super(XgPonTcPerformanceMonitoringHistoryDataFrame, self).__init__(
892 XgPonTcPerformanceMonitoringHistoryData, entity_id,
893 MEFrame._attr_to_data(attributes))
894
895
896class XgPonDownstreamPerformanceMonitoringHistoryDataFrame(MEFrame):
897 """
898 This managed entity collects performance monitoring data associated with
899 the XG-PON ined in [ITU-T G.987.3]
900 """
901 def __init__(self, entity_id, attributes):
902 """
903 :param entity_id: (int) This attribute uniquely identifies each instance of
904 this managed entity. Through an identical ID, this
905 managed entity is implicitly linked to an instance of
906 the ANI-G.
907
908 :param attributes: (basestring, list, set, dict) attributes. For gets
909 a string, list, or set can be provided. For set
910 operations, a dictionary should be provided, for
911 deletes None may be specified.
912 """
913 super(XgPonDownstreamPerformanceMonitoringHistoryDataFrame, self).__init__(
914 XgPonDownstreamPerformanceMonitoringHistoryData,
915 entity_id,
916 MEFrame._attr_to_data(attributes))
917
918
919class XgPonUpstreamPerformanceMonitoringHistoryDataFrame(MEFrame):
920 """
921 This managed entity collects performance monitoring data associated with
922 the XG-PON transmission convergence layer, as defined in [ITU-T G.987.3]
923 """
924 def __init__(self, entity_id, attributes):
925 """
926 :param entity_id: (int) TThis attribute uniquely identifies each instance of
927 this managed entity. Through an identical ID, this
928 managed entity is implicitly linked to an instance of
929 the ANI-G.
930
931 :param attributes: (basestring, list, set, dict) attributes. For gets
932 a string, list, or set can be provided. For set
933 operations, a dictionary should be provided, for
934 deletes None may be specified.
935 """
936 super(XgPonUpstreamPerformanceMonitoringHistoryDataFrame, self).__init__(
937 XgPonUpstreamPerformanceMonitoringHistoryData,
938 entity_id,
939 MEFrame._attr_to_data(attributes))