blob: 396822460c22c9841ccfb2c0f8a5205bbf3f3b3e [file] [log] [blame]
Matt Jeanneretf1e9c5d2019-02-08 07:41:29 -05001#
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#
16import inspect
17
18import sys
19from binascii import hexlify
20from bitstring import BitArray
21import json
22from scapy.fields import ByteField, ShortField, MACField, BitField, IPField
23from scapy.fields import IntField, StrFixedLenField, LongField, FieldListField, PacketLenField
24from scapy.packet import Packet
25
26from voltha.extensions.omci.omci_defs import OmciUninitializedFieldError, \
27 AttributeAccess, OmciNullPointer, EntityOperations, OmciInvalidTypeError
28from voltha.extensions.omci.omci_fields import OmciSerialNumberField, OmciTableField
29from voltha.extensions.omci.omci_defs import bitpos_from_mask
30
31class EntityClassAttribute(object):
32
33 def __init__(self, fld, access=set(), optional=False, range_check=None,
34 avc=False, tca=False, counter=False, deprecated=False):
35 """
36 Initialize an Attribute for a Managed Entity Class
37
38 :param fld: (Field) Scapy field type
39 :param access: (AttributeAccess) Allowed access
40 :param optional: (boolean) If true, attribute is option, else mandatory
41 :param range_check: (callable) None, Lambda, or Function to validate value
42 :param avc: (boolean) If true, an AVC notification can occur for the attribute
43 :param tca: (boolean) If true, a threshold crossing alert alarm notification can occur
44 for the attribute
45 :param counter: (boolean) If true, this attribute is a PM counter
46 :param deprecated: (boolean) If true, this attribute is deprecated and
47 only 'read' operations (if-any) performed.
48 """
49 self._fld = fld
50 self._access = access
51 self._optional = optional
52 self._range_check = range_check
53 self._avc = avc
54 self._tca = tca
55 self._counter = counter
56 self._deprecated = deprecated
57
58 @property
59 def field(self):
60 return self._fld
61
62 @property
63 def access(self):
64 return self._access
65
66 @property
67 def optional(self):
68 return self._optional
69
70 @property
71 def is_counter(self):
72 return self._counter
73
74 @property
75 def range_check(self):
76 return self._range_check
77
78 @property
79 def avc_allowed(self):
80 return self._avc
81
82 @property
83 def deprecated(self):
84 return self._deprecated
85
86 _type_checker_map = {
87 'ByteField': lambda val: isinstance(val, (int, long)) and 0 <= val <= 0xFF,
88 'ShortField': lambda val: isinstance(val, (int, long)) and 0 <= val <= 0xFFFF,
89 'IntField': lambda val: isinstance(val, (int, long)) and 0 <= val <= 0xFFFFFFFF,
90 'LongField': lambda val: isinstance(val, (int, long)) and 0 <= val <= 0xFFFFFFFFFFFFFFFF,
91 'StrFixedLenField': lambda val: isinstance(val, basestring),
92 'MACField': lambda val: True, # TODO: Add a constraint for this field type
93 'BitField': lambda val: True, # TODO: Add a constraint for this field type
94 'IPField': lambda val: True, # TODO: Add a constraint for this field type
95 'OmciTableField': lambda val: True,
96
97 # TODO: As additional Scapy field types are used, add constraints
98 }
99
100 def valid(self, value):
101 def _isa_lambda_function(v):
102 import inspect
103 return callable(v) and len(inspect.getargspec(v).args) == 1
104
105 field_type = self.field.__class__.__name__
106 type_check = EntityClassAttribute._type_checker_map.get(field_type,
107 lambda val: True)
108
109 # TODO: Currently StrFixedLenField is used heavily for both bit fields as
110 # and other 'byte/octet' related strings that are NOT textual. Until
111 # all of these are corrected, 'StrFixedLenField' cannot test the type
112 # of the value provided
113
114 if field_type != 'StrFixedLenField' and not type_check(value):
115 return False
116
117 if _isa_lambda_function(self.range_check):
118 return self.range_check(value)
119 return True
120
121
122class EntityClassMeta(type):
123 """
124 Metaclass for EntityClass to generate secondary class attributes
125 for class attributes of the derived classes.
126 """
127 def __init__(cls, name, bases, dct):
128 super(EntityClassMeta, cls).__init__(name, bases, dct)
129
130 # initialize attribute_name_to_index_map
131 cls.attribute_name_to_index_map = dict(
132 (a._fld.name, idx) for idx, a in enumerate(cls.attributes))
133
134
135class EntityClass(object):
136
137 class_id = 'to be filled by subclass'
138 attributes = []
139 mandatory_operations = set()
140 optional_operations = set()
141 notifications = set()
142 alarms = dict() # Alarm Number -> Alarm Name
143 hidden = False # If true, this attribute is not reported by a MIB upload.
144 # This attribute is needed to be able to properly perform
145 # MIB Audits.
146
147 # will be map of attr_name -> index in attributes, initialized by metaclass
148 attribute_name_to_index_map = None
149 __metaclass__ = EntityClassMeta
150
151 def __init__(self, **kw):
152 assert(isinstance(kw, dict))
153 for k, v in kw.iteritems():
154 assert(k in self.attribute_name_to_index_map)
155 self._data = kw
156
157 def serialize(self, mask=None, operation=None):
158 octets = ''
159
160 # generate ordered list of attribute indices needed to be processed
161 # if mask is provided, we use that explicitly
162 # if mask is not provided, we determine attributes from the self._data
163 # content also taking into account the type of operation in hand
164 if mask is not None:
165 attribute_indices = EntityClass.attribute_indices_from_mask(mask)
166 else:
167 attribute_indices = self.attribute_indices_from_data()
168
169 # Serialize each indexed field (ignoring entity id)
170 for index in attribute_indices:
171 eca = self.attributes[index]
172 field = eca.field
173 try:
174 value = self._data[field.name]
175
176 if not eca.valid(value):
177 raise OmciInvalidTypeError(
178 'Value "{}" for Entity field "{}" is not valid'.format(value,
179 field.name))
180 except KeyError:
181 raise OmciUninitializedFieldError(
182 'Entity field "{}" not set'.format(field.name))
183
184 octets = field.addfield(None, octets, value)
185
186 return octets
187
188 def attribute_indices_from_data(self):
189 return sorted(
190 self.attribute_name_to_index_map[attr_name]
191 for attr_name in self._data.iterkeys())
192
193 byte1_mask_to_attr_indices = dict(
194 (m, bitpos_from_mask(m, 8, -1)) for m in range(256))
195 byte2_mask_to_attr_indices = dict(
196 (m, bitpos_from_mask(m, 16, -1)) for m in range(256))
197
198 @classmethod
199 def attribute_indices_from_mask(cls, mask):
200 # each bit in the 2-byte field denote an attribute index; we use a
201 # lookup table to make lookup a bit faster
202 return \
203 cls.byte1_mask_to_attr_indices[(mask >> 8) & 0xff] + \
204 cls.byte2_mask_to_attr_indices[(mask & 0xff)]
205
206 @classmethod
207 def mask_for(cls, *attr_names):
208 """
209 Return mask value corresponding to given attributes names
210 :param attr_names: Attribute names
211 :return: integer mask value
212 """
213 mask = 0
214 for attr_name in attr_names:
215 index = cls.attribute_name_to_index_map[attr_name]
216 mask |= (1 << (16 - index))
217 return mask
218
219
220# abbreviations
221ECA = EntityClassAttribute
222AA = AttributeAccess
223OP = EntityOperations
224
225
226class OntData(EntityClass):
227 class_id = 2
228 hidden = True
229 attributes = [
230 ECA(ShortField("managed_entity_id", None), {AA.R},
231 range_check=lambda x: x == 0),
232 # Only 1 octet used if GET/SET operation
233 ECA(ShortField("mib_data_sync", 0), {AA.R, AA.W})
234 ]
235 mandatory_operations = {OP.Get, OP.Set,
236 OP.GetAllAlarms, OP.GetAllAlarmsNext,
237 OP.MibReset, OP.MibUpload, OP.MibUploadNext}
238
239
240class Cardholder(EntityClass):
241 class_id = 5
242 attributes = [
243 ECA(ShortField("managed_entity_id", None), {AA.R},
244 range_check=lambda x: 0 <= x < 255 or 256 <= x < 511,
245 avc=True),
246 ECA(ByteField("actual_plugin_unit_type", None), {AA.R}),
247 ECA(ByteField("expected_plugin_unit_type", None), {AA.R, AA.W}),
248 ECA(ByteField("expected_port_count", None), {AA.R, AA.W},
249 optional=True),
250 ECA(StrFixedLenField("expected_equipment_id", None, 20), {AA.R, AA.W},
251 optional=True, avc=True),
252 ECA(StrFixedLenField("actual_equipment_id", None, 20), {AA.R},
253 optional=True),
254 ECA(ByteField("protection_profile_pointer", None), {AA.R},
255 optional=True),
256 ECA(ByteField("invoke_protection_switch", None), {AA.R, AA.W},
257 optional=True, range_check=lambda x: 0 <= x <= 3),
258 ECA(ByteField("arc", 0), {AA.R, AA.W},
259 range_check=lambda x: 0 <= x <= 1, optional=True, avc=True),
260 ECA(ByteField("arc_interval", 0), {AA.R, AA.W}, optional=True),
261 ]
262 mandatory_operations = {OP.Get, OP.Set}
263 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
264 alarms = {
265 0: 'Plug-in circuit pack missing',
266 1: 'Plug-in type mismatch alarm',
267 2: 'Improper card removal',
268 3: 'Plug-in equipment ID mismatch alarm',
269 4: 'Protection switch',
270 }
271
272
273class CircuitPack(EntityClass):
274 class_id = 6
275 attributes = [
276 ECA(StrFixedLenField("managed_entity_id", None, 22), {AA.R, AA.SBC},
277 range_check=lambda x: 0 <= x < 255 or 256 <= x < 511),
278 ECA(ByteField("type", None), {AA.R, AA.SBC}),
279 ECA(ByteField("number_of_ports", None), {AA.R}, optional=True),
280 ECA(OmciSerialNumberField("serial_number"), {AA.R}),
281 ECA(StrFixedLenField("version", None, 14), {AA.R}),
282 ECA(StrFixedLenField("vendor_id", None, 4), {AA.R}),
283 ECA(ByteField("administrative_state", None), {AA.R, AA.W}),
284 ECA(ByteField("operational_state", None), {AA.R}, optional=True, avc=True),
285 ECA(ByteField("bridged_or_ip_ind", None), {AA.R, AA.W}, optional=True,
286 range_check=lambda x: 0 <= x <= 2),
287 ECA(StrFixedLenField("equipment_id", None, 20), {AA.R}, optional=True),
288 ECA(ByteField("card_configuration", None), {AA.R, AA.W, AA.SBC},
289 optional=True), # not really mandatory, see spec ITU-T G.988, 9.1.6
290 ECA(ByteField("total_tcont_buffer_number", None), {AA.R},
291 optional=True), # not really mandatory, see spec ITU-T G.988, 9.1.6
292 ECA(ByteField("total_priority_queue_number", None), {AA.R},
293 optional=True), # not really mandatory, see spec ITU-T G.988, 9.1.6
294 ECA(ByteField("total_traffic_scheduler_number", None), {AA.R},
295 optional=True), # not really mandatory, see spec ITU-T G.988, 9.1.6
296 ECA(IntField("power_sched_override", None), {AA.R, AA.W},
297 optional=True)
298 ]
299 mandatory_operations = {OP.Get, OP.Set, OP.Reboot}
300 optional_operations = {OP.Create, OP.Delete, OP.Test}
301 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
302 alarms = {
303 0: 'Equipment alarm',
304 1: 'Powering alarm',
305 2: 'Self-test failure',
306 3: 'Laser end of life',
307 4: 'Temperature yellow',
308 5: 'Temperature red',
309 }
310
311class SoftwareImage(EntityClass):
312 class_id = 7
313 attributes = [
314 ECA(ShortField("managed_entity_id", None), {AA.R},
315 range_check=lambda x: 0 <= x/256 <= 254 or 0 <= x % 256 <= 1),
316 ECA(StrFixedLenField("version", None, 14), {AA.R}, avc=True),
317 ECA(ByteField("is_committed", None), {AA.R}, avc=True,
318 range_check=lambda x: 0 <= x <= 1),
319 ECA(ByteField("is_active", None), {AA.R}, avc=True,
320 range_check=lambda x: 0 <= x <= 1),
321 ECA(ByteField("is_valid", None), {AA.R}, avc=True,
322 range_check=lambda x: 0 <= x <= 1),
323 ECA(StrFixedLenField("product_code", None, 25), {AA.R}, optional=True, avc=True),
324 ECA(StrFixedLenField("image_hash", None, 16), {AA.R}, optional=True, avc=True),
325 ]
326 mandatory_operations = {OP.Get, OP.StartSoftwareDownload, OP.DownloadSection,
327 OP.EndSoftwareDownload, OP.ActivateSoftware,
328 OP.CommitSoftware}
329 notifications = {OP.AttributeValueChange}
330
331
332class PptpEthernetUni(EntityClass):
333 class_id = 11
334 attributes = [
335 ECA(ShortField("managed_entity_id", None), {AA.R}),
336 ECA(ByteField("expected_type", 0), {AA.R, AA.W},
337 range_check=lambda x: 0 <= x <= 254),
338 ECA(ByteField("sensed_type", 0), {AA.R}, optional=True, avc=True),
339 # TODO: For sensed_type AVC, see note in AT&T OMCI Specification, V3.0, page 123
340 ECA(ByteField("autodetection_config", 0), {AA.R, AA.W},
341 range_check=lambda x: x in [0, 1, 2, 3, 4, 5,
342 0x10, 0x11, 0x12, 0x13, 0x14,
343 0x20, 0x30], optional=True), # See ITU-T G.988
344 ECA(ByteField("ethernet_loopback_config", 0), {AA.R, AA.W},
345 range_check=lambda x: x in [0, 3]),
346 ECA(ByteField("administrative_state", 1), {AA.R, AA.W},
347 range_check=lambda x: 0 <= x <= 1),
348 ECA(ByteField("operational_state", 1), {AA.R, AA.W},
349 range_check=lambda x: 0 <= x <= 1, optional=True, avc=True),
350 ECA(ByteField("config_ind", 0), {AA.R},
351 range_check=lambda x: x in [0, 1, 2, 3, 4, 0x11, 0x12, 0x13]),
352 ECA(ShortField("max_frame_size", 1518), {AA.R, AA.W}, optional=True),
353 ECA(ByteField("dte_dce_ind", 0), {AA.R, AA.W},
354 range_check=lambda x: 0 <= x <= 2),
355 ECA(ShortField("pause_time", 0), {AA.R, AA.W}, optional=True),
356 ECA(ByteField("bridged_ip_ind", 2), {AA.R, AA.W},
357 optional=True, range_check=lambda x: 0 <= x <= 2),
358 ECA(ByteField("arc", 0), {AA.R, AA.W}, optional=True,
359 range_check=lambda x: 0 <= x <= 1, avc=True),
360 ECA(ByteField("arc_interval", 0), {AA.R, AA.W}, optional=True),
361 ECA(ByteField("pppoe_filter", 0), {AA.R, AA.W}, optional=True),
362 ECA(ByteField("power_control", 0), {AA.R, AA.W}, optional=True),
363 ]
364 mandatory_operations = {OP.Get, OP.Set}
365 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
366 alarms = {
367 0: 'LAN Loss Of Signal',
368 }
369
370
371class MacBridgeServiceProfile(EntityClass):
372 class_id = 45
373 attributes = [
374 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
375 ECA(ByteField("spanning_tree_ind", None), {AA.R, AA.W, AA.SBC},
376 range_check=lambda x: 0 <= x <= 1),
377 ECA(ByteField("learning_ind", None), {AA.R, AA.W, AA.SBC},
378 range_check=lambda x: 0 <= x <= 1),
379 ECA(ByteField("port_bridging_ind", None), {AA.R, AA.W, AA.SBC},
380 range_check=lambda x: 0 <= x <= 1),
381 ECA(ShortField("priority", None), {AA.R, AA.W, AA.SBC}),
382 ECA(ShortField("max_age", None), {AA.R, AA.W, AA.SBC},
383 range_check=lambda x: 0x0600 <= x <= 0x2800),
384 ECA(ShortField("hello_time", None), {AA.R, AA.W, AA.SBC},
385 range_check=lambda x: 0x0100 <= x <= 0x0A00),
386 ECA(ShortField("forward_delay", None), {AA.R, AA.W, AA.SBC},
387 range_check=lambda x: 0x0400 <= x <= 0x1E00),
388 ECA(ByteField("unknown_mac_address_discard", None),
389 {AA.R, AA.W, AA.SBC}, range_check=lambda x: 0 <= x <= 1),
390 ECA(ByteField("mac_learning_depth", None),
391 {AA.R, AA.W, AA.SBC}, optional=True),
392 ECA(ByteField("dynamic_filtering_ageing_time", None),
393 {AA.R, AA.W, AA.SBC}, optional=True),
394 ]
395 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
396
397
398class MacBridgePortConfigurationData(EntityClass):
399 class_id = 47
400 attributes = [
401 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
402 ECA(ShortField("bridge_id_pointer", None), {AA.R, AA.W, AA.SBC}),
403 ECA(ByteField("port_num", None), {AA.R, AA.W, AA.SBC}),
404 ECA(ByteField("tp_type", None), {AA.R, AA.W, AA.SBC},
405 range_check=lambda x: 1 <= x <= 12),
406 ECA(ShortField("tp_pointer", None), {AA.R, AA.W, AA.SBC}),
407 ECA(ShortField("port_priority", None), {AA.R, AA.W, AA.SBC}),
408 ECA(ShortField("port_path_cost", None), {AA.R, AA.W, AA.SBC}),
409 ECA(ByteField("port_spanning_tree_in", None), {AA.R, AA.W, AA.SBC}),
410 ECA(ByteField("encapsulation_methods", None), {AA.R, AA.W, AA.SBC},
411 optional=True, deprecated=True),
412 ECA(ByteField("lan_fcs_ind", None), {AA.R, AA.W, AA.SBC},
413 optional=True, deprecated=True),
414 ECA(MACField("port_mac_address", None), {AA.R}, optional=True),
415 ECA(ShortField("outbound_td_pointer", None), {AA.R, AA.W},
416 optional=True),
417 ECA(ShortField("inbound_td_pointer", None), {AA.R, AA.W},
418 optional=True),
419 # TODO:
420 ECA(ByteField("mac_learning_depth", 0), {AA.R, AA.W, AA.SBC},
421 optional=True),
422 ]
423 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
424 notifications = {OP.AlarmNotification}
425 alarms = {
426 0: 'Port blocking',
427 }
428
429
430class MacBridgePortFilterPreAssignTable(EntityClass):
431 class_id = 79
432 attributes = [
433 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
434 ECA(ShortField("ipv4_multicast", 0), {AA.R, AA.W},
435 range_check=lambda x: 0 <= x <= 1),
436 ECA(ShortField("ipv6_multicast", 0), {AA.R, AA.W},
437 range_check=lambda x: 0 <= x <= 1),
438 ECA(ShortField("ipv4_broadcast", 0), {AA.R, AA.W},
439 range_check=lambda x: 0 <= x <= 1),
440 ECA(ShortField("rarp", 0), {AA.R, AA.W},
441 range_check=lambda x: 0 <= x <= 1),
442 ECA(ShortField("ipx", 0), {AA.R, AA.W},
443 range_check=lambda x: 0 <= x <= 1),
444 ECA(ShortField("netbeui", 0), {AA.R, AA.W},
445 range_check=lambda x: 0 <= x <= 1),
446 ECA(ShortField("appletalk", 0), {AA.R, AA.W},
447 range_check=lambda x: 0 <= x <= 1),
448 ECA(ShortField("bridge_management_information", 0), {AA.R, AA.W},
449 range_check=lambda x: 0 <= x <= 1),
450 ECA(ShortField("arp", 0), {AA.R, AA.W},
451 range_check=lambda x: 0 <= x <= 1),
452 ECA(ShortField("pppoe_broadcast", 0), {AA.R, AA.W},
453 range_check=lambda x: 0 <= x <= 1)
454 ]
455 mandatory_operations = {OP.Get, OP.Set}
456
457
458class VlanTaggingFilterData(EntityClass):
459 class_id = 84
460 attributes = [
461 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
462 ECA(FieldListField("vlan_filter_list", None,
463 ShortField('', 0), count_from=lambda _: 12),
464 {AA.R, AA.W, AA.SBC}),
465 ECA(ByteField("forward_operation", None), {AA.R, AA.W, AA.SBC},
466 range_check=lambda x: 0x00 <= x <= 0x21),
467 ECA(ByteField("number_of_entries", None), {AA.R, AA.W, AA.SBC})
468 ]
469 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
470
471
472class Ieee8021pMapperServiceProfile(EntityClass):
473 class_id = 130
474 attributes = [
475 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
476 ECA(ShortField("tp_pointer", None), {AA.R, AA.W, AA.SBC}),
477 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_0",
478 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
479 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_1",
480 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
481 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_2",
482 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
483 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_3",
484 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
485 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_4",
486 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
487 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_5",
488 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
489 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_6",
490 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
491 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_7",
492 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
493 ECA(ByteField("unmarked_frame_option", None),
494 {AA.R, AA.W, AA.SBC}, range_check=lambda x: 0 <= x <= 1),
495 ECA(StrFixedLenField("dscp_to_p_bit_mapping", None, length=24),
496 {AA.R, AA.W}), # TODO: Would a custom 3-bit group bitfield work better?
497 ECA(ByteField("default_p_bit_marking", None),
498 {AA.R, AA.W, AA.SBC}),
499 ECA(ByteField("tp_type", None), {AA.R, AA.W, AA.SBC},
500 optional=True, range_check=lambda x: 0 <= x <= 8)
501 ]
502 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
503
504
505class OltG(EntityClass):
506 class_id = 131
507 attributes = [
508 ECA(ShortField("managed_entity_id", None), {AA.R},
509 range_check=lambda x: x == 0),
510 ECA(StrFixedLenField("olt_vendor_id", None, 4), {AA.R, AA.W}),
511 ECA(StrFixedLenField("equipment_id", None, 20), {AA.R, AA.W}),
512 ECA(StrFixedLenField("version", None, 14), {AA.R, AA.W}),
513 ECA(StrFixedLenField("time_of_day", None, 14), {AA.R, AA.W})
514 ]
515 mandatory_operations = {OP.Get, OP.Set}
516
517
518class OntPowerShedding(EntityClass):
519 class_id = 133
520 attributes = [
521 ECA(ShortField("managed_entity_id", None), {AA.R},
522 range_check=lambda x: x == 0),
523 ECA(ShortField("restore_power_time_reset_interval", 0),
524 {AA.R, AA.W}),
525 ECA(ShortField("data_class_shedding_interval", 0), {AA.R, AA.W}),
526 ECA(ShortField("voice_class_shedding_interval", 0), {AA.R, AA.W}),
527 ECA(ShortField("video_overlay_class_shedding_interval", 0), {AA.R, AA.W}),
528 ECA(ShortField("video_return_class_shedding_interval", 0), {AA.R, AA.W}),
529 ECA(ShortField("dsl_class_shedding_interval", 0), {AA.R, AA.W}),
530 ECA(ShortField("atm_class_shedding_interval", 0), {AA.R, AA.W}),
531 ECA(ShortField("ces_class_shedding_interval", 0), {AA.R, AA.W}),
532 ECA(ShortField("frame_class_shedding_interval", 0), {AA.R, AA.W}),
533 ECA(ShortField("sonet_class_shedding_interval", 0), {AA.R, AA.W}),
534 ECA(ShortField("shedding_status", None), {AA.R, AA.W}, optional=True,
535 avc=True),
536 ]
537 mandatory_operations = {OP.Get, OP.Set}
538 notifications = {OP.AttributeValueChange}
539
540
541class IpHostConfigData(EntityClass):
542 class_id = 134
543 attributes = [
544 ECA(ShortField("managed_entity_id", None), {AA.R}),
545 ECA(BitField("ip_options", 0, size=8), {AA.R, AA.W}),
546 ECA(MACField("mac_address", None), {AA.R}),
547 ECA(StrFixedLenField("onu_identifier", None, 25), {AA.R, AA.W}),
548 ECA(IPField("ip_address", None), {AA.R, AA.W}),
549 ECA(IPField("mask", None), {AA.R, AA.W}),
550 ECA(IPField("gateway", None), {AA.R, AA.W}),
551 ECA(IPField("primary_dns", None), {AA.R, AA.W}),
552 ECA(IPField("secondary_dns", None), {AA.R, AA.W}),
553 ECA(IPField("current_address", None), {AA.R}, avc=True),
554 ECA(IPField("current_mask", None), {AA.R}, avc=True),
555 ECA(IPField("current_gateway", None), {AA.R}, avc=True),
556 ECA(IPField("current_primary_dns", None), {AA.R}, avc=True),
557 ECA(IPField("current_secondary_dns", None), {AA.R}, avc=True),
558 ECA(StrFixedLenField("domain_name", None, 25), {AA.R}, avc=True),
559 ECA(StrFixedLenField("host_name", None, 25), {AA.R}, avc=True),
560 ECA(ShortField("relay_agent_options", None), {AA.R, AA.W},
561 optional=True),
562 ]
563 mandatory_operations = {OP.Get, OP.Set, OP.Test}
564 notifications = {OP.AttributeValueChange}
565
566
567class VlanTaggingOperation(Packet):
568 name = "VlanTaggingOperation"
569 fields_desc = [
570 BitField("filter_outer_priority", 0, 4),
571 BitField("filter_outer_vid", 0, 13),
572 BitField("filter_outer_tpid_de", 0, 3),
573 BitField("pad1", 0, 12),
574
575 BitField("filter_inner_priority", 0, 4),
576 BitField("filter_inner_vid", 0, 13),
577 BitField("filter_inner_tpid_de", 0, 3),
578 BitField("pad2", 0, 8),
579 BitField("filter_ether_type", 0, 4),
580
581 BitField("treatment_tags_to_remove", 0, 2),
582 BitField("pad3", 0, 10),
583 BitField("treatment_outer_priority", 0, 4),
584 BitField("treatment_outer_vid", 0, 13),
585 BitField("treatment_outer_tpid_de", 0, 3),
586
587 BitField("pad4", 0, 12),
588 BitField("treatment_inner_priority", 0, 4),
589 BitField("treatment_inner_vid", 0, 13),
590 BitField("treatment_inner_tpid_de", 0, 3),
591 ]
592
593 def to_json(self):
594 return json.dumps(self.fields, separators=(',', ':'))
595
596 @staticmethod
597 def json_from_value(value):
598 bits = BitArray(hex=hexlify(value))
599 temp = VlanTaggingOperation(
600 filter_outer_priority=bits[0:4].uint, # 4 <-size
601 filter_outer_vid=bits[4:17].uint, # 13
602 filter_outer_tpid_de=bits[17:20].uint, # 3
603 # pad 12
604 filter_inner_priority=bits[32:36].uint, # 4
605 filter_inner_vid=bits[36:49].uint, # 13
606 filter_inner_tpid_de=bits[49:52].uint, # 3
607 # pad 8
608 filter_ether_type=bits[60:64].uint, # 4
609 treatment_tags_to_remove=bits[64:66].uint, # 2
610 # pad 10
611 treatment_outer_priority=bits[76:80].uint, # 4
612 treatment_outer_vid=bits[80:93].uint, # 13
613 treatment_outer_tpid_de=bits[93:96].uint, # 3
614 # pad 12
615 treatment_inner_priority=bits[108:112].uint, # 4
616 treatment_inner_vid=bits[112:125].uint, # 13
617 treatment_inner_tpid_de=bits[125:128].uint, # 3
618 )
619 return json.dumps(temp.fields, separators=(',', ':'))
620
621 def index(self):
622 return '{:02}'.format(self.fields.get('filter_outer_priority',0)) + \
623 '{:03}'.format(self.fields.get('filter_outer_vid',0)) + \
624 '{:01}'.format(self.fields.get('filter_outer_tpid_de',0)) + \
625 '{:03}'.format(self.fields.get('filter_inner_priority',0)) + \
626 '{:04}'.format(self.fields.get('filter_inner_vid',0)) + \
627 '{:01}'.format(self.fields.get('filter_inner_tpid_de',0)) + \
628 '{:02}'.format(self.fields.get('filter_ether_type',0))
629
630 def is_delete(self):
631 return self.fields.get('treatment_tags_to_remove',0) == 0x3 and \
632 self.fields.get('pad3',0) == 0x3ff and \
633 self.fields.get('treatment_outer_priority',0) == 0xf and \
634 self.fields.get('treatment_outer_vid',0) == 0x1fff and \
635 self.fields.get('treatment_outer_tpid_de',0) == 0x7 and \
636 self.fields.get('pad4',0) == 0xfff and \
637 self.fields.get('treatment_inner_priority',0) == 0xf and \
638 self.fields.get('treatment_inner_vid',0) == 0x1fff and \
639 self.fields.get('treatment_inner_tpid_de',0) == 0x7
640
641 def delete(self):
642 self.fields['treatment_tags_to_remove'] = 0x3
643 self.fields['pad3'] = 0x3ff
644 self.fields['treatment_outer_priority'] = 0xf
645 self.fields['treatment_outer_vid'] = 0x1fff
646 self.fields['treatment_outer_tpid_de'] = 0x7
647 self.fields['pad4'] = 0xfff
648 self.fields['treatment_inner_priority'] = 0xf
649 self.fields['treatment_inner_vid'] = 0x1fff
650 self.fields['treatment_inner_tpid_de'] = 0x7
651 return self
652
653class ExtendedVlanTaggingOperationConfigurationData(EntityClass):
654 class_id = 171
655 attributes = [
656 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
657 ECA(ByteField("association_type", None), {AA.R, AA.W, AA.SBC},
658 range_check=lambda x: 0 <= x <= 11),
659 ECA(ShortField("received_vlan_tagging_operation_table_max_size", None),
660 {AA.R}),
661 ECA(ShortField("input_tpid", None), {AA.R, AA.W}),
662 ECA(ShortField("output_tpid", None), {AA.R, AA.W}),
663 ECA(ByteField("downstream_mode", None), {AA.R, AA.W},
664 range_check=lambda x: 0 <= x <= 8),
665 ECA(OmciTableField(
666 PacketLenField("received_frame_vlan_tagging_operation_table", None,
667 VlanTaggingOperation, length_from=lambda pkt: 16)), {AA.R, AA.W}),
668 ECA(ShortField("associated_me_pointer", None), {AA.R, AA.W, AA.SBC}),
669 ECA(FieldListField("dscp_to_p_bit_mapping", None,
670 BitField('', 0, size=3), count_from=lambda _: 64),
671 {AA.R, AA.W}),
672 ]
673 mandatory_operations = {OP.Create, OP.Delete, OP.Set, OP.Get, OP.GetNext}
674 optional_operations = {OP.SetTable}
675
676
677class OntG(EntityClass):
678 class_id = 256
679 attributes = [
680 ECA(ShortField("managed_entity_id", None), {AA.R},
681 range_check=lambda x: x == 0),
682 ECA(StrFixedLenField("vendor_id", None, 4), {AA.R}),
683 ECA(StrFixedLenField("version", None, 14), {AA.R}),
684 ECA(OmciSerialNumberField("serial_number"), {AA.R}),
685 ECA(ByteField("traffic_management_options", None), {AA.R},
686 range_check=lambda x: 0 <= x <= 2),
687 ECA(ByteField("vp_vc_cross_connection_option", 0), {AA.R},
688 optional=True, deprecated=True),
689 ECA(ByteField("battery_backup", None), {AA.R, AA.W},
690 range_check=lambda x: 0 <= x <= 1),
691 ECA(ByteField("administrative_state", None), {AA.R, AA.W},
692 range_check=lambda x: 0 <= x <= 1),
693 ECA(ByteField("operational_state", None), {AA.R}, optional=True,
694 range_check=lambda x: 0 <= x <= 1, avc=True),
695 ECA(ByteField("ont_survival_time", None), {AA.R}, optional=True),
696 ECA(StrFixedLenField("logical_onu_id", None, 24), {AA.R},
697 optional=True, avc=True),
698 ECA(StrFixedLenField("logical_password", None, 12), {AA.R},
699 optional=True, avc=True),
700 ECA(ByteField("credentials_status", None), {AA.R, AA.W},
701 optional=True, range_check=lambda x: 0 <= x <= 4),
702 ECA(BitField("extended_tc_layer_options", None, size=16), {AA.R},
703 optional=True),
704 ]
705 mandatory_operations = {
706 OP.Get, OP.Set, OP.Reboot, OP.Test, OP.SynchronizeTime}
707 notifications = {OP.TestResult, OP.AttributeValueChange,
708 OP.AlarmNotification}
709 alarms = {
710 0: 'Equipment alarm',
711 1: 'Powering alarm',
712 2: 'Battery missing',
713 3: 'Battery failure',
714 4: 'Battery low',
715 5: 'Physical intrusion',
716 6: 'Self-test failure',
717 7: 'Dying gasp',
718 8: 'Temperature yellow',
719 9: 'Temperature red',
720 10: 'Voltage yellow',
721 11: 'Voltage red',
722 12: 'ONU manual power off',
723 13: 'Invalid image',
724 14: 'PSE overload yellow',
725 15: 'PSE overload red',
726 }
727
728
729class Ont2G(EntityClass):
730 class_id = 257
731 attributes = [
732 ECA(ShortField("managed_entity_id", None), {AA.R},
733 range_check=lambda x: x == 0),
734 ECA(StrFixedLenField("equipment_id", None, 20), {AA.R}),
735 ECA(ByteField("omcc_version", None), {AA.R}, avc=True),
736 ECA(ShortField("vendor_product_code", None), {AA.R}),
737 ECA(ByteField("security_capability", None), {AA.R},
738 range_check=lambda x: 0 <= x <= 1),
739 ECA(ByteField("security_mode", None), {AA.R, AA.W},
740 range_check=lambda x: 0 <= x <= 1),
741 ECA(ShortField("total_priority_queue_number", None), {AA.R}),
742 ECA(ByteField("total_traffic_scheduler_number", None), {AA.R}),
743 ECA(ByteField("mode", None), {AA.R}, deprecated=True),
744 ECA(ShortField("total_gem_port_id_number", None), {AA.R}),
745 ECA(IntField("sys_uptime", None), {AA.R}),
746 ECA(BitField("connectivity_capability", None, size=16), {AA.R}),
747 ECA(ByteField("current_connectivity_mode", None), {AA.R, AA.W},
748 range_check=lambda x: 0 <= x <= 7),
749 ECA(BitField("qos_configuration_flexibility", None, size=16),
750 {AA.R}, optional=True),
751 ECA(ShortField("priority_queue_scale_factor", None), {AA.R, AA.W},
752 optional=True),
753 ]
754 mandatory_operations = {OP.Get, OP.Set}
755 notifications = {OP.AttributeValueChange}
756
757
758class Tcont(EntityClass):
759 class_id = 262
760 attributes = [
761 ECA(ShortField("managed_entity_id", None), {AA.R}),
762 ECA(ShortField("alloc_id", None), {AA.R, AA.W}),
763 ECA(ByteField("mode_indicator", 1), {AA.R}, deprecated=True),
764 ECA(ByteField("policy", None), {AA.R, AA.W},
765 range_check=lambda x: 0 <= x <= 2),
766 ]
767 mandatory_operations = {OP.Get, OP.Set}
768
769
770class AniG(EntityClass):
771 class_id = 263
772 attributes = [
773 ECA(ShortField("managed_entity_id", None), {AA.R}),
774 ECA(ByteField("sr_indication", None), {AA.R}),
775 ECA(ShortField("total_tcont_number", None), {AA.R}),
776 ECA(ShortField("gem_block_length", None), {AA.R, AA.W}),
777 ECA(ByteField("piggyback_dba_reporting", None), {AA.R},
778 range_check=lambda x: 0 <= x <= 4),
779 ECA(ByteField("whole_ont_dba_reporting", None), {AA.R},
780 deprecated=True),
781 ECA(ByteField("sf_threshold", 5), {AA.R, AA.W}),
782 ECA(ByteField("sd_threshold", 9), {AA.R, AA.W}),
783 ECA(ByteField("arc", 0), {AA.R, AA.W},
784 range_check=lambda x: 0 <= x <= 1, avc=True),
785 ECA(ByteField("arc_interval", 0), {AA.R, AA.W}),
786 ECA(ShortField("optical_signal_level", None), {AA.R}),
787 ECA(ByteField("lower_optical_threshold", 0xFF), {AA.R, AA.W}),
788 ECA(ByteField("upper_optical_threshold", 0xFF), {AA.R, AA.W}),
789 ECA(ShortField("ont_response_time", None), {AA.R}),
790 ECA(ShortField("transmit_optical_level", None), {AA.R}),
791 ECA(ByteField("lower_transmit_power_threshold", 0x81), {AA.R, AA.W}),
792 ECA(ByteField("upper_transmit_power_threshold", 0x81), {AA.R, AA.W}),
793 ]
794 mandatory_operations = {OP.Get, OP.Set, OP.Test}
795 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
796 alarms = {
797 0: 'Low received optical power',
798 1: 'High received optical power',
799 2: 'Signal fail',
800 3: 'Signal degrade',
801 4: 'Low transmit optical power',
802 5: 'High transmit optical power',
803 6: 'Laser bias current',
804 }
805
806
807class UniG(EntityClass):
808 class_id = 264
809 attributes = [
810 ECA(ShortField("managed_entity_id", None), {AA.R}),
811 ECA(ShortField("configuration_option_status", None), {AA.R, AA.W},
812 deprecated=True),
813 ECA(ByteField("administrative_state", None), {AA.R, AA.W}),
814 ECA(ByteField("management_capability", None), {AA.R},
815 range_check=lambda x: 0 <= x <= 2),
816 ECA(ShortField("non_omci_management_identifier", None), {AA.R, AA.W}),
817 ECA(ShortField("relay_agent_options", None), {AA.R, AA.W},
818 optional=True),
819 ]
820 mandatory_operations = {OP.Get, OP.Set}
821
822
823class GemInterworkingTp(EntityClass):
824 class_id = 266
825 attributes = [
826 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
827 ECA(ShortField("gem_port_network_ctp_pointer", None),
828 {AA.R, AA.W, AA.SBC}),
829 ECA(ByteField("interworking_option", None), {AA.R, AA.W, AA.SBC},
830 range_check=lambda x: 0 <= x <= 7),
831 ECA(ShortField("service_profile_pointer", None), {AA.R, AA.W, AA.SBC}),
832 ECA(ShortField("interworking_tp_pointer", None), {AA.R, AA.W, AA.SBC}),
833 ECA(ByteField("pptp_counter", None), {AA.R}, optional=True),
834 ECA(ByteField("operational_state", None), {AA.R}, optional=True,
835 range_check=lambda x: 0 <= x <= 1, avc=True),
836 ECA(ShortField("gal_profile_pointer", None), {AA.R, AA.W, AA.SBC}),
837 ECA(ByteField("gal_loopback_configuration", 0),
838 {AA.R, AA.W}, range_check=lambda x: 0 <= x <= 1),
839 ]
840 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
841 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
842 alarms = {
843 6: 'Operational state change',
844 }
845
846
847class GemPortNetworkCtp(EntityClass):
848 class_id = 268
849 attributes = [
850 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
851 ECA(ShortField("port_id", None), {AA.R, AA.W, AA.SBC}),
852 ECA(ShortField("tcont_pointer", None), {AA.R, AA.W, AA.SBC}),
853 ECA(ByteField("direction", None), {AA.R, AA.W, AA.SBC},
854 range_check=lambda x: 1 <= x <= 3),
855 ECA(ShortField("traffic_management_pointer_upstream", None),
856 {AA.R, AA.W, AA.SBC}),
857 ECA(ShortField("traffic_descriptor_profile_pointer", None),
858 {AA.R, AA.W, AA.SBC}, optional=True),
859 ECA(ByteField("uni_counter", None), {AA.R}, optional=True),
860 ECA(ShortField("priority_queue_pointer_downstream", None),
861 {AA.R, AA.W, AA.SBC}),
862 ECA(ByteField("encryption_state", None), {AA.R}, optional=True),
863 ECA(ShortField("traffic_desc_profile_pointer_downstream", None),
864 {AA.R, AA.W, AA.SBC}, optional=True),
865 ECA(ShortField("encryption_key_ring", None), {AA.R, AA.W, AA.SBC},
866 range_check=lambda x: 0 <= x <= 3)
867 ]
868 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
869 notifications = {OP.AlarmNotification}
870 alarms = {
871 5: 'End-to-end loss of continuity',
872 }
873
874
875class GalEthernetProfile(EntityClass):
876 class_id = 272
877 attributes = [
878 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
879 ECA(ShortField("max_gem_payload_size", None), {AA.R, AA.W, AA.SBC}),
880 ]
881 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
882
883
884class PriorityQueueG(EntityClass):
885 class_id = 277
886 attributes = [
887 ECA(ShortField("managed_entity_id", None), {AA.R}),
888 ECA(ByteField("queue_configuration_option", None), {AA.R},
889 range_check=lambda x: 0 <= x <= 1),
890 ECA(ShortField("maximum_queue_size", None), {AA.R}),
891 ECA(ShortField("allocated_queue_size", None), {AA.R, AA.W}),
892 ECA(ShortField("discard_block_counter_reset_interval", None), {AA.R, AA.W}),
893 ECA(ShortField("threshold_value_for_discarded_blocks", None), {AA.R, AA.W}),
894 ECA(IntField("related_port", None), {AA.R}),
895 ECA(ShortField("traffic_scheduler_pointer", 0), {AA.R, AA.W}),
896 ECA(ByteField("weight", 1), {AA.R, AA.W}),
897 ECA(ShortField("back_pressure_operation", 0), {AA.R, AA.W},
898 range_check=lambda x: 0 <= x <= 1),
899 ECA(IntField("back_pressure_time", 0), {AA.R, AA.W}),
900 ECA(ShortField("back_pressure_occur_queue_threshold", None), {AA.R, AA.W}),
901 ECA(ShortField("back_pressure_clear_queue_threshold", None), {AA.R, AA.W}),
902 # TODO: Custom field of 4 2-byte values would help below
903 ECA(LongField("packet_drop_queue_thresholds", None), {AA.R, AA.W},
904 optional=True),
905 ECA(ShortField("packet_drop_max_p", 0xFFFF), {AA.R, AA.W}, optional=True),
906 ECA(ByteField("queue_drop_w_q", 9), {AA.R, AA.W}, optional=True),
907 ECA(ByteField("drop_precedence_colour_marking", 0), {AA.R, AA.W},
908 optional=True, range_check=lambda x: 0 <= x <= 7),
909 ]
910 mandatory_operations = {OP.Get, OP.Set}
911 notifications = {OP.AlarmNotification}
912 alarms = {
913 0: 'Block loss',
914 }
915
916
917class TrafficSchedulerG(EntityClass):
918 class_id = 278
919 attributes = [
920 ECA(ShortField("managed_entity_id", None), {AA.R}),
921 ECA(ShortField("tcont_pointer", None), {AA.R}),
922 ECA(ShortField("traffic_scheduler_pointer", None), {AA.R}),
923 ECA(ByteField("policy", None), {AA.R, AA.W},
924 range_check=lambda x: 0 <= x <= 2),
925 ECA(ByteField("priority_weight", 0), {AA.R, AA.W}),
926 ]
927 mandatory_operations = {OP.Get, OP.Set}
928
929
930class MulticastGemInterworkingTp(EntityClass):
931 class_id = 281
932 attributes = [
933 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC},
934 range_check=lambda x: x != OmciNullPointer),
935 ECA(ShortField("gem_port_network_ctp_pointer", None), {AA.R, AA.SBC}),
936 ECA(ByteField("interworking_option", None), {AA.R, AA.W, AA.SBC},
937 range_check=lambda x: x in [0, 1, 3, 5]),
938 ECA(ShortField("service_profile_pointer", None), {AA.R, AA.W, AA.SBC}),
939 ECA(ShortField("interworking_tp_pointer", 0), {AA.R, AA.W, AA.SBC},
940 deprecated=True),
941 ECA(ByteField("pptp_counter", None), {AA.R}),
942 ECA(ByteField("operational_state", None), {AA.R}, avc=True,
943 range_check=lambda x: 0 <= x <= 1),
944 ECA(ShortField("gal_profile_pointer", None), {AA.R, AA.W, AA.SBC}),
945 ECA(ByteField("gal_loopback_configuration", None), {AA.R, AA.W, AA.SBC},
946 deprecated=True),
947 # TODO add multicast_address_table here (page 85 of spec.)
948 # ECA(...("multicast_address_table", None), {AA.R, AA.W})
949 ]
950 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.GetNext, OP.Set}
951 optional_operations = {OP.SetTable}
952 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
953 alarms = {
954 0: 'Deprecated',
955 }
956
957
958class AccessControlRow0(Packet):
959 name = "AccessControlRow0"
960 fields_desc = [
961 BitField("set_ctrl", 0, 2),
962 BitField("row_part_id", 0, 3),
963 BitField("test", 0, 1),
964 BitField("row_key", 0, 10),
965
966 ShortField("gem_port_id", None),
967 ShortField("vlan_id", None),
968 IPField("src_ip", None),
969 IPField("dst_ip_start", None),
970 IPField("dst_ip_end", None),
971 IntField("ipm_group_bw", None),
972 ShortField("reserved0", 0)
973 ]
974
975 def to_json(self):
976 return json.dumps(self.fields, separators=(',', ':'))
977
978
979class AccessControlRow1(Packet):
980 name = "AccessControlRow1"
981 fields_desc = [
982 BitField("set_ctrl", 0, 2),
983 BitField("row_part_id", 0, 3),
984 BitField("test", 0, 1),
985 BitField("row_key", 0, 10),
986
987 StrFixedLenField("ipv6_src_addr_start_bytes", None, 12),
988 ShortField("preview_length", None),
989 ShortField("preview_repeat_time", None),
990 ShortField("preview_repeat_count", None),
991 ShortField("preview_reset_time", None),
992 ShortField("reserved1", 0)
993 ]
994
995 def to_json(self):
996 return json.dumps(self.fields, separators=(',', ':'))
997
998
999class AccessControlRow2(Packet):
1000 name = "AccessControlRow2"
1001 fields_desc = [
1002 BitField("set_ctrl", 0, 2),
1003 BitField("row_part_id", 0, 3),
1004 BitField("test", 0, 1),
1005 BitField("row_key", 0, 10),
1006
1007 StrFixedLenField("ipv6_dst_addr_start_bytes", None, 12),
1008 StrFixedLenField("reserved2", None, 10)
1009 ]
1010
1011 def to_json(self):
1012 return json.dumps(self.fields, separators=(',', ':'))
1013
1014
1015class DownstreamIgmpMulticastTci(Packet):
1016 name = "DownstreamIgmpMulticastTci"
1017 fields_desc = [
1018 ByteField("ctrl_type", None),
1019 ShortField("tci", None)
1020 ]
1021
1022 def to_json(self):
1023 return json.dumps(self.fields, separators=(',', ':'))
1024
1025
1026class MulticastOperationsProfile(EntityClass):
1027 class_id = 309
1028 attributes = [
1029 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC},
1030 range_check=lambda x: x != 0 and x != OmciNullPointer),
1031 ECA(ByteField("igmp_version", None), {AA.R, AA.W, AA.SBC},
1032 range_check=lambda x: x in [1, 2, 3, 16, 17]),
1033 ECA(ByteField("igmp_function", None), {AA.R, AA.W, AA.SBC},
1034 range_check=lambda x: 0 <= x <= 2),
1035 ECA(ByteField("immediate_leave", None), {AA.R, AA.W, AA.SBC},
1036 range_check=lambda x: 0 <= x <= 1),
1037 ECA(ShortField("us_igmp_tci", None), {AA.R, AA.W, AA.SBC}, optional=True),
1038 ECA(ByteField("us_igmp_tag_ctrl", None), {AA.R, AA.W, AA.SBC},
1039 range_check=lambda x: 0 <= x <= 3, optional=True),
1040 ECA(IntField("us_igmp_rate", None), {AA.R, AA.W, AA.SBC}, optional=True),
1041 # TODO: need to make table and add column data
1042 ECA(StrFixedLenField(
1043 "dynamic_access_control_list_table", None, 24), {AA.R, AA.W}),
1044 # TODO: need to make table and add column data
1045 ECA(StrFixedLenField(
1046 "static_access_control_list_table", None, 24), {AA.R, AA.W}),
1047 # TODO: need to make table and add column data
1048 ECA(StrFixedLenField("lost_groups_list_table", None, 10), {AA.R}),
1049 ECA(ByteField("robustness", None), {AA.R, AA.W, AA.SBC}),
1050 ECA(IntField("querier_ip", None), {AA.R, AA.W, AA.SBC}),
1051 ECA(IntField("query_interval", None), {AA.R, AA.W, AA.SBC}),
1052 ECA(IntField("querier_max_response_time", None), {AA.R, AA.W, AA.SBC}),
1053 ECA(IntField("last_member_response_time", 10), {AA.R, AA.W}),
1054 ECA(ByteField("unauthorized_join_behaviour", None), {AA.R, AA.W}),
1055 ECA(StrFixedLenField("ds_igmp_mcast_tci", None, 3), {AA.R, AA.W, AA.SBC}, optional=True)
1056 ]
1057 mandatory_operations = {OP.Create, OP.Delete, OP.Set, OP.Get, OP.GetNext}
1058 optional_operations = {OP.SetTable}
1059 notifications = {OP.AlarmNotification}
1060 alarms = {
1061 0: 'Lost multicast group',
1062 }
1063
1064
1065class MulticastServicePackage(Packet):
1066 name = "MulticastServicePackage"
1067 fields_desc = [
1068 BitField("set_ctrl", 0, 2),
1069 BitField("reserved0", 0, 4),
1070 BitField("row_key", 0, 10),
1071
1072 ShortField("vid_uni", None),
1073 ShortField("max_simultaneous_groups", None),
1074 IntField("max_multicast_bw", None),
1075 ShortField("mcast_operations_profile_pointer", None),
1076 StrFixedLenField("reserved1", None, 8)
1077 ]
1078
1079 def to_json(self):
1080 return json.dumps(self.fields, separators=(',', ':'))
1081
1082
1083class AllowedPreviewGroupsRow0(Packet):
1084 name = "AllowedPreviewGroupsRow0"
1085 fields_desc = [
1086 BitField("set_ctrl", 0, 2),
1087 BitField("row_part_id", 0, 3),
1088 BitField("reserved0", 0, 1),
1089 BitField("row_key", 0, 10),
1090
1091 StrFixedLenField("ipv6_pad", 0, 12),
1092 IPField("src_ip", None),
1093 ShortField("vlan_id_ani", None),
1094 ShortField("vlan_id_uni", None)
1095 ]
1096
1097 def to_json(self):
1098 return json.dumps(self.fields, separators=(',', ':'))
1099
1100
1101class AllowedPreviewGroupsRow1(Packet):
1102 name = "AllowedPreviewGroupsRow1"
1103 fields_desc = [
1104 BitField("set_ctrl", 0, 2),
1105 BitField("row_part_id", 0, 3),
1106 BitField("reserved0", 0, 1),
1107 BitField("row_key", 0, 10),
1108
1109 StrFixedLenField("ipv6_pad", 0, 12),
1110 IPField("dst_ip", None),
1111 ShortField("duration", None),
1112 ShortField("time_left", None)
1113 ]
1114
1115 def to_json(self):
1116 return json.dumps(self.fields, separators=(',', ':'))
1117
1118
1119class MulticastSubscriberConfigInfo(EntityClass):
1120 class_id = 310
1121 attributes = [
1122 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
1123 ECA(ByteField("me_type", None), {AA.R, AA.W, AA.SBC},
1124 range_check=lambda x: 0 <= x <= 1),
1125 ECA(ShortField("mcast_operations_profile_pointer", None),
1126 {AA.R, AA.W, AA.SBC}),
1127 ECA(ShortField("max_simultaneous_groups", None), {AA.R, AA.W, AA.SBC}),
1128 ECA(IntField("max_multicast_bandwidth", None), {AA.R, AA.W, AA.SBC}),
1129 ECA(ByteField("bandwidth_enforcement", None), {AA.R, AA.W, AA.SBC},
1130 range_check=lambda x: 0 <= x <= 1),
1131 # TODO: need to make table and add column data
1132 ECA(StrFixedLenField(
1133 "multicast_service_package_table", None, 20), {AA.R, AA.W}),
1134 # TODO: need to make table and add column data
1135 ECA(StrFixedLenField(
1136 "allowed_preview_groups_table", None, 22), {AA.R, AA.W}),
1137 ]
1138 mandatory_operations = {OP.Create, OP.Delete, OP.Set, OP.Get, OP.GetNext,
1139 OP.SetTable}
1140
1141
1142class VirtualEthernetInterfacePt(EntityClass):
1143 class_id = 329
1144 attributes = [
1145 ECA(ShortField("managed_entity_id", None), {AA.R},
1146 range_check=lambda x: x != 0 and x != OmciNullPointer),
1147 ECA(ByteField("administrative_state", None), {AA.R, AA.W},
1148 range_check=lambda x: 0 <= x <= 1),
1149 ECA(ByteField("operational_state", None), {AA.R}, avc=True,
1150 range_check=lambda x: 0 <= x <= 1),
1151 ECA(StrFixedLenField(
1152 "interdomain_name", None, 25), {AA.R, AA.W}, optional=True),
1153 ECA(ShortField("tcp_udp_pointer", None), {AA.R, AA.W}, optional=True),
1154 ECA(ShortField("iana_assigned_port", None), {AA.R}),
1155 ]
1156 mandatory_operations = {OP.Get, OP.Set}
1157 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
1158 alarms = {
1159 0: 'Connecting function fail',
1160 }
1161
1162
1163class Omci(EntityClass):
1164 class_id = 287
1165 hidden = True
1166 attributes = [
1167 ECA(ShortField("managed_entity_id", None), {AA.R},
1168 range_check=lambda x: x == 0),
1169
1170 # TODO: Can this be expressed better in SCAPY, probably not?
1171 # On the initial, Get request for either the me_type or message_type
1172 # attributes, you will receive a 4 octet value (big endian) that is
1173 # the number of octets to 'get-next' to fully load the desired
1174 # attribute. For a basic OMCI formatted message, that will be 29
1175 # octets per get-request.
1176 #
1177 # For the me_type_table, these are 16-bit values (ME Class IDs)
1178 #
1179 # For the message_type_table, these are 8-bit values (Actions)
1180
1181 ECA(FieldListField("me_type_table", None, ByteField('', 0),
1182 count_from=lambda _: 29), {AA.R}),
1183 ECA(FieldListField("message_type_table", None, ByteField('', 0),
1184 count_from=lambda _: 29), {AA.R}),
1185 ]
1186 mandatory_operations = {OP.Get, OP.GetNext}
1187
1188
1189class EnhSecurityControl(EntityClass):
1190 class_id = 332
1191 attributes = [
1192 ECA(ShortField("managed_entity_id", None), {AA.R}),
1193 ECA(BitField("olt_crypto_capabilities", None, 16*8), {AA.W}),
1194 # TODO: need to make table and add column data
1195 ECA(StrFixedLenField(
1196 "olt_random_challenge_table", None, 17), {AA.R, AA.W}),
1197 ECA(ByteField("olt_challenge_status", 0), {AA.R, AA.W},
1198 range_check=lambda x: 0 <= x <= 1),
1199 ECA(ByteField("onu_selected_crypto_capabilities", None), {AA.R}),
1200 # TODO: need to make table and add column data
1201 ECA(StrFixedLenField(
1202 "onu_random_challenge_table", None, 16), {AA.R}, avc=True),
1203 # TODO: need to make table and add column data
1204 ECA(StrFixedLenField(
1205 "onu_authentication_result_table", None, 16), {AA.R}, avc=True),
1206 # TODO: need to make table and add column data
1207 ECA(StrFixedLenField(
1208 "olt_authentication_result_table", None, 17), {AA.W}),
1209 ECA(ByteField("olt_result_status", None), {AA.R, AA.W},
1210 range_check=lambda x: 0 <= x <= 1),
1211 ECA(ByteField("onu_authentication_status", None), {AA.R}, avc=True,
1212 range_check=lambda x: 0 <= x <= 5),
1213 ECA(StrFixedLenField(
1214 "master_session_key_name", None, 16), {AA.R}),
1215 ECA(StrFixedLenField(
1216 "broadcast_key_table", None, 18), {AA.R, AA.W}),
1217 ECA(ShortField("effective_key_length", None), {AA.R}),
1218
1219 ]
1220 mandatory_operations = {OP.Set, OP.Get, OP.GetNext}
1221 notifications = {OP.AttributeValueChange}
1222
1223
1224class EthernetPMMonitoringHistoryData(EntityClass):
1225 class_id = 24
1226 hidden = True
1227 attributes = [
1228 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
1229 ECA(ByteField("interval_end_time", None), {AA.R}),
1230 ECA(ShortField("threshold_data_1_2_id", None), {AA.R, AA.W, AA.SBC}),
1231 ECA(IntField("fcs_errors", None), {AA.R}, tca=True, counter=True),
1232 ECA(IntField("excessive_collision_counter", None), {AA.R}, tca=True, counter=True),
1233 ECA(IntField("late_collision_counter", None), {AA.R}, tca=True, counter=True),
1234 ECA(IntField("frames_too_long", None), {AA.R}, tca=True, counter=True),
1235 ECA(IntField("buffer_overflows_on_rx", None), {AA.R}, tca=True, counter=True),
1236 ECA(IntField("buffer_overflows_on_tx", None), {AA.R}, tca=True, counter=True),
1237 ECA(IntField("single_collision_frame_counter", None), {AA.R}, tca=True, counter=True),
1238 ECA(IntField("multiple_collisions_frame_counter", None), {AA.R}, tca=True, counter=True),
1239 ECA(IntField("sqe_counter", None), {AA.R}, tca=True, counter=True),
1240 ECA(IntField("deferred_tx_counter", None), {AA.R}, tca=True, counter=True),
1241 ECA(IntField("internal_mac_tx_error_counter", None), {AA.R}, tca=True, counter=True),
1242 ECA(IntField("carrier_sense_error_counter", None), {AA.R}, tca=True, counter=True),
1243 ECA(IntField("alignment_error_counter", None), {AA.R}, tca=True, counter=True),
1244 ECA(IntField("internal_mac_rx_error_counter", None), {AA.R}, tca=True, counter=True)
1245 ]
1246 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set, OP.GetCurrentData}
1247 notifications = {OP.AlarmNotification}
1248 alarms = {
1249 0: 'FCS errors',
1250 1: 'Excessive collision counter',
1251 2: 'Late collision counter',
1252 3: 'Frames too long',
1253 4: 'Buffer overflows on receive',
1254 5: 'Buffer overflows on transmit',
1255 6: 'Single collision frame counter',
1256 7: 'Multiple collision frame counter',
1257 8: 'SQE counter',
1258 9: 'Deferred transmission counter',
1259 10: 'Internal MAC transmit error counter',
1260 11: 'Carrier sense error counter',
1261 12: 'Alignment error counter',
1262 13: 'Internal MAC receive error counter',
1263 }
1264
1265
1266class FecPerformanceMonitoringHistoryData(EntityClass):
1267 class_id = 312
1268 hidden = True
1269 attributes = [
1270 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
1271 ECA(ByteField("interval_end_time", None), {AA.R}),
1272 ECA(ShortField("threshold_data_1_2_id", None), {AA.R, AA.W, AA.SBC}),
1273 ECA(IntField("corrected_bytes", None), {AA.R}, tca=True, counter=True),
1274 ECA(IntField("corrected_code_words", None), {AA.R}, tca=True, counter=True),
1275 ECA(IntField("uncorrectable_code_words", None), {AA.R}, tca=True, counter=True),
1276 ECA(IntField("total_code_words", None), {AA.R}, counter=True),
1277 ECA(ShortField("fec_seconds", None), {AA.R}, tca=True, counter=True)
1278 ]
1279 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set, OP.GetCurrentData}
1280 notifications = {OP.AlarmNotification}
1281 alarms = {
1282 0: 'Corrected bytes',
1283 1: 'Corrected code words',
1284 2: 'Uncorrectable code words',
1285 4: 'FEC seconds',
1286 }
1287
1288
1289class EthernetFrameDownstreamPerformanceMonitoringHistoryData(EntityClass):
1290 class_id = 321
1291 hidden = True
1292 attributes = [
1293 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
1294 ECA(ByteField("interval_end_time", None), {AA.R}),
1295 ECA(ShortField("threshold_data_1_2_id", None), {AA.R, AA.W, AA.SBC}),
1296 ECA(IntField("drop_events", None), {AA.R}, tca=True, counter=True),
1297 ECA(IntField("octets", None), {AA.R}, counter=True),
1298 ECA(IntField("packets", None), {AA.R}, counter=True),
1299 ECA(IntField("broadcast_packets", None), {AA.R}, counter=True),
1300 ECA(IntField("multicast_packets", None), {AA.R}, counter=True),
1301 ECA(IntField("crc_errored_packets", None), {AA.R}, tca=True, counter=True),
1302 ECA(IntField("undersize_packets", None), {AA.R}, tca=True, counter=True),
1303 ECA(IntField("oversize_packets", None), {AA.R}, tca=True, counter=True),
1304 ECA(IntField("64_octets", None), {AA.R}, counter=True),
1305 ECA(IntField("65_to_127_octets", None), {AA.R}, counter=True),
1306 ECA(IntField("128_to_255_octets", None), {AA.R}, counter=True),
1307 ECA(IntField("256_to_511_octets", None), {AA.R}, counter=True),
1308 ECA(IntField("512_to_1023_octets", None), {AA.R}, counter=True),
1309 ECA(IntField("1024_to_1518_octets", None), {AA.R}, counter=True)
1310 ]
1311 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set, OP.GetCurrentData}
1312 notifications = {OP.AlarmNotification}
1313 alarms = {
1314 0: 'Drop events',
1315 1: 'CRC errored packets',
1316 2: 'Undersize packets',
1317 3: 'Oversize packets',
1318 }
1319
1320
1321class EthernetFrameUpstreamPerformanceMonitoringHistoryData(EntityClass):
1322 class_id = 322
1323 hidden = True
1324 attributes = [
1325 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
1326 ECA(ByteField("interval_end_time", None), {AA.R}),
1327 ECA(ShortField("threshold_data_1_2_id", None), {AA.R, AA.W, AA.SBC}),
1328 ECA(IntField("drop_events", None), {AA.R}, tca=True, counter=True),
1329 ECA(IntField("octets", None), {AA.R}, counter=True),
1330 ECA(IntField("packets", None), {AA.R}, counter=True),
1331 ECA(IntField("broadcast_packets", None), {AA.R}, counter=True),
1332 ECA(IntField("multicast_packets", None), {AA.R}, counter=True),
1333 ECA(IntField("crc_errored_packets", None), {AA.R}, tca=True, counter=True),
1334 ECA(IntField("undersize_packets", None), {AA.R}, tca=True, counter=True),
1335 ECA(IntField("oversize_packets", None), {AA.R}, tca=True, counter=True),
1336 ECA(IntField("64_octets", None), {AA.R}, counter=True),
1337 ECA(IntField("65_to_127_octets", None), {AA.R}, counter=True),
1338 ECA(IntField("128_to_255_octets", None), {AA.R}, counter=True),
1339 ECA(IntField("256_to_511_octets", None), {AA.R}, counter=True),
1340 ECA(IntField("512_to_1023_octets", None), {AA.R}, counter=True),
1341 ECA(IntField("1024_to_1518_octets", None), {AA.R}, counter=True)
1342 ]
1343 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set, OP.GetCurrentData}
1344 notifications = {OP.AlarmNotification}
1345 alarms = {
1346 0: 'Drop events',
1347 1: 'CRC errored packets',
1348 2: 'Undersize packets',
1349 3: 'Oversize packets',
1350 }
1351
1352
1353class VeipUni(EntityClass):
1354 class_id = 329
1355 attributes = [
1356 ECA(ShortField("managed_entity_id", None), {AA.R}),
1357 ECA(ByteField("administrative_state", 1), {AA.R, AA.W},
1358 range_check=lambda x: 0 <= x <= 1),
1359 ECA(ByteField("operational_state", 1), {AA.R, AA.W},
1360 range_check=lambda x: 0 <= x <= 1, optional=True, avc=True),
1361 ECA(StrFixedLenField("interdomain_name", None, 25), {AA.R, AA.W},
1362 optional=True),
1363 ECA(ShortField("tcp_udp_pointer", None), {AA.R, AA.W}, optional=True),
1364 ECA(ShortField("iana_assigned_port", 0xFFFF), {AA.R})
1365 ]
1366 mandatory_operations = {OP.Get, OP.Set}
1367 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
1368 alarms = {
1369 0: 'Connecting function fail'
1370 }
1371
1372
1373class EthernetFrameExtendedPerformanceMonitoring(EntityClass):
1374 class_id = 334
1375 hidden = True
1376 attributes = [
1377 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
1378 ECA(ByteField("interval_end_time", None), {AA.R}),
1379 # 2-octet field -> Threshold data 1/2 ID
1380 # 2-octet field -> Parent ME Class
1381 # 2-octet field -> Parent ME Instance
1382 # 2-octet field -> Accumulation disable
1383 # 2-octet field -> TCA Disable
1384 # 2-octet field -> Control fields bitmap
1385 # 2-octet field -> TCI
1386 # 2-octet field -> Reserved
1387 ECA(FieldListField("control_block", None, ShortField('', 0),
1388 count_from=lambda _: 8), {AA.R, AA.W, AA.SBC}),
1389 ECA(IntField("drop_events", None), {AA.R}, tca=True, counter=True),
1390 ECA(IntField("octets", None), {AA.R}, counter=True),
1391 ECA(IntField("packets", None), {AA.R}, counter=True),
1392 ECA(IntField("broadcast_packets", None), {AA.R}, counter=True),
1393 ECA(IntField("multicast_packets", None), {AA.R}, counter=True),
1394 ECA(IntField("crc_errored_packets", None), {AA.R}, tca=True, counter=True),
1395 ECA(IntField("undersize_packets", None), {AA.R}, tca=True, counter=True),
1396 ECA(IntField("oversize_packets", None), {AA.R}, tca=True, counter=True),
1397 ECA(IntField("64_octets", None), {AA.R}, counter=True),
1398 ECA(IntField("65_to_127_octets", None), {AA.R}, counter=True),
1399 ECA(IntField("128_to_255_octets", None), {AA.R}, counter=True),
1400 ECA(IntField("256_to_511_octets", None), {AA.R}, counter=True),
1401 ECA(IntField("512_to_1023_octets", None), {AA.R}, counter=True),
1402 ECA(IntField("1024_to_1518_octets", None), {AA.R}, counter=True)
1403 ]
1404 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
1405 optional_operations = {OP.GetCurrentData}
1406 notifications = {OP.AlarmNotification}
1407 alarms = {
1408 0: 'Drop events',
1409 1: 'CRC errored packets',
1410 2: 'Undersize packets',
1411 3: 'Oversize packets',
1412 }
1413
1414
1415class EthernetFrameExtendedPerformanceMonitoring64Bit(EntityClass):
1416 class_id = 426
1417 hidden = True
1418 attributes = [
1419 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
1420 ECA(ByteField("interval_end_time", None), {AA.R}),
1421 # 2-octet field -> Threshold data 1/2 ID
1422 # 2-octet field -> Parent ME Class
1423 # 2-octet field -> Parent ME Instance
1424 # 2-octet field -> Accumulation disable
1425 # 2-octet field -> TCA Disable
1426 # 2-octet field -> Control fields bitmap
1427 # 2-octet field -> TCI
1428 # 2-octet field -> Reserved
1429 ECA(FieldListField("control_block", None, ShortField('', 0),
1430 count_from=lambda _: 8), {AA.R, AA.W, AA.SBC}),
1431 ECA(LongField("drop_events", None), {AA.R}, tca=True, counter=True),
1432 ECA(LongField("octets", None), {AA.R}, counter=True),
1433 ECA(LongField("packets", None), {AA.R}, counter=True),
1434 ECA(LongField("broadcast_packets", None), {AA.R}, counter=True),
1435 ECA(LongField("multicast_packets", None), {AA.R}, counter=True),
1436 ECA(LongField("crc_errored_packets", None), {AA.R}, tca=True, counter=True),
1437 ECA(LongField("undersize_packets", None), {AA.R}, tca=True, counter=True),
1438 ECA(LongField("oversize_packets", None), {AA.R}, tca=True, counter=True),
1439 ECA(LongField("64_octets", None), {AA.R}, counter=True),
1440 ECA(LongField("65_to_127_octets", None), {AA.R}, counter=True),
1441 ECA(LongField("128_to_255_octets", None), {AA.R}, counter=True),
1442 ECA(LongField("256_to_511_octets", None), {AA.R}, counter=True),
1443 ECA(LongField("512_to_1023_octets", None), {AA.R}, counter=True),
1444 ECA(LongField("1024_to_1518_octets", None), {AA.R}, counter=True)
1445 ]
1446 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
1447 optional_operations = {OP.GetCurrentData}
1448 notifications = {OP.AlarmNotification}
1449 alarms = {
1450 0: 'Drop events',
1451 1: 'CRC errored packets',
1452 2: 'Undersize packets',
1453 3: 'Oversize packets',
1454 }
1455
1456
1457class GemPortNetworkCtpMonitoringHistoryData(EntityClass):
1458 class_id = 341
1459 hidden = True
1460 attributes = [
1461 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
1462 ECA(ByteField("interval_end_time", None), {AA.R}),
1463 ECA(ShortField("threshold_data_1_2_id", None), {AA.R, AA.W, AA.SBC}),
1464 ECA(IntField("transmitted_gem_frames", None), {AA.R}, counter=True),
1465 ECA(IntField("received_gem_frames", None), {AA.R}, counter=True),
1466 ECA(LongField("received_payload_bytes", None), {AA.R}, counter=True),
1467 ECA(LongField("transmitted_payload_bytes", None), {AA.R}, counter=True),
1468 ECA(IntField("encryption_key_errors", None), {AA.R}, tca=True, counter=True)
1469 ]
1470 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set, OP.GetCurrentData}
1471 notifications = {OP.AlarmNotification}
1472 alarms = {
1473 1: 'Encryption key errors',
1474 }
1475
1476
1477class XgPonTcPerformanceMonitoringHistoryData(EntityClass):
1478 class_id = 344
1479 hidden = True
1480 attributes = [
1481 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
1482 ECA(ByteField("interval_end_time", None), {AA.R}),
1483 ECA(ShortField("threshold_data_1_2_id", None), {AA.R, AA.W, AA.SBC}),
1484 ECA(IntField("psbd_hec_error_count", None), {AA.R}, tca=True, counter=True),
1485 ECA(IntField("xgtc_hec_error_count", None), {AA.R}, tca=True, counter=True),
1486 ECA(IntField("unknown_profile_count", None), {AA.R}, tca=True, counter=True),
1487 ECA(IntField("transmitted_xgem_frames", None), {AA.R}, counter=True),
1488 ECA(IntField("fragment_xgem_frames", None), {AA.R}, counter=True),
1489 ECA(IntField("xgem_hec_lost_words_count", None), {AA.R}, tca=True, counter=True),
1490 ECA(IntField("xgem_key_errors", None), {AA.R}, tca=True, counter=True),
1491 ECA(IntField("xgem_hec_error_count", None), {AA.R}, tca=True, counter=True)
1492 ]
1493 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
1494 optional_operations = {OP.GetCurrentData}
1495 notifications = {OP.AlarmNotification}
1496 alarms = {
1497 1: 'PSBd HEC error count',
1498 2: 'XGTC HEC error count',
1499 3: 'Unknown profile count',
1500 4: 'XGEM HEC loss count',
1501 5: 'XGEM key errors',
1502 6: 'XGEM HEC error count',
1503 }
1504
1505
1506class XgPonDownstreamPerformanceMonitoringHistoryData(EntityClass):
1507 class_id = 345
1508 hidden = True
1509 attributes = [
1510 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
1511 ECA(ByteField("interval_end_time", None), {AA.R},),
1512 ECA(ShortField("threshold_data_1_2_id", None), {AA.R, AA.W, AA.SBC}),
1513 ECA(IntField("ploam_mic_error_count", None), {AA.R}, tca=True, counter=True),
1514 ECA(IntField("downstream_ploam_messages_count", None), {AA.R}, counter=True),
1515 ECA(IntField("profile_messages_received", None), {AA.R}, counter=True),
1516 ECA(IntField("ranging_time_messages_received", None), {AA.R}, counter=True),
1517 ECA(IntField("deactivate_onu_id_messages_received", None), {AA.R}, counter=True),
1518 ECA(IntField("disable_serial_number_messages_received", None), {AA.R}, counter=True),
1519 ECA(IntField("request_registration_messages_received", None), {AA.R}, counter=True),
1520 ECA(IntField("assign_alloc_id_messages_received", None), {AA.R}, counter=True),
1521 ECA(IntField("key_control_messages_received", None), {AA.R}, counter=True),
1522 ECA(IntField("sleep_allow_messages_received", None), {AA.R}, counter=True),
1523 ECA(IntField("baseline_omci_messages_received_count", None), {AA.R}, counter=True),
1524 ECA(IntField("extended_omci_messages_received_count", None), {AA.R}, counter=True),
1525 ECA(IntField("assign_onu_id_messages_received", None), {AA.R}, counter=True),
1526 ECA(IntField("omci_mic_error_count", None), {AA.R}, tca=True, counter=True),
1527 ]
1528 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
1529 optional_operations = {OP.GetCurrentData}
1530 notifications = {OP.AlarmNotification}
1531 alarms = {
1532 1: 'PLOAM MIC error count',
1533 2: 'OMCI MIC error count',
1534 }
1535
1536
1537class XgPonUpstreamPerformanceMonitoringHistoryData(EntityClass):
1538 class_id = 346
1539 hidden = True
1540 attributes = [
1541 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
1542 ECA(ByteField("interval_end_time", None), {AA.R}),
1543 ECA(ShortField("threshold_data_1_2_id", None), {AA.R, AA.W, AA.SBC}),
1544 ECA(IntField("upstream_ploam_message_count", None), {AA.R}, counter=True),
1545 ECA(IntField("serial_number_onu_message_count", None), {AA.R}, counter=True),
1546 ECA(IntField("registration_message_count", None), {AA.R}, counter=True),
1547 ECA(IntField("key_report_message_count", None), {AA.R}, counter=True),
1548 ECA(IntField("acknowledge_message_count", None), {AA.R}, counter=True),
1549 ECA(IntField("sleep_request_message_count", None), {AA.R}, counter=True),
1550 ]
1551 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
1552 optional_operations = {OP.GetCurrentData}
1553
1554
1555# entity class lookup table from entity_class values
1556entity_classes_name_map = dict(
1557 inspect.getmembers(sys.modules[__name__],
1558 lambda o: inspect.isclass(o) and \
1559 issubclass(o, EntityClass) and \
1560 o is not EntityClass)
1561)
1562
1563entity_classes = [c for c in entity_classes_name_map.itervalues()]
1564entity_id_to_class_map = dict((c.class_id, c) for c in entity_classes)