blob: 95e6581c6e2f87b27c7a57d51ad33591c9ce59de [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#
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
31
32class EntityClassAttribute(object):
33
34 def __init__(self, fld, access=set(), optional=False, range_check=None,
35 avc=False, tca=False, counter=False, deprecated=False):
36 """
37 Initialize an Attribute for a Managed Entity Class
38
39 :param fld: (Field) Scapy field type
40 :param access: (AttributeAccess) Allowed access
41 :param optional: (boolean) If true, attribute is option, else mandatory
42 :param range_check: (callable) None, Lambda, or Function to validate value
43 :param avc: (boolean) If true, an AVC notification can occur for the attribute
44 :param tca: (boolean) If true, a threshold crossing alert alarm notification can occur
45 for the attribute
46 :param counter: (boolean) If true, this attribute is a PM counter
47 :param deprecated: (boolean) If true, this attribute is deprecated and
48 only 'read' operations (if-any) performed.
49 """
50 self._fld = fld
51 self._access = access
52 self._optional = optional
53 self._range_check = range_check
54 self._avc = avc
55 self._tca = tca
56 self._counter = counter
57 self._deprecated = deprecated
58
59 @property
60 def field(self):
61 return self._fld
62
63 @property
64 def access(self):
65 return self._access
66
67 @property
68 def optional(self):
69 return self._optional
70
71 @property
72 def is_counter(self):
73 return self._counter
74
75 @property
76 def range_check(self):
77 return self._range_check
78
79 @property
80 def avc_allowed(self):
81 return self._avc
82
83 @property
84 def deprecated(self):
85 return self._deprecated
86
87 _type_checker_map = {
88 'ByteField': lambda val: isinstance(val, (int, long)) and 0 <= val <= 0xFF,
89 'ShortField': lambda val: isinstance(val, (int, long)) and 0 <= val <= 0xFFFF,
90 'IntField': lambda val: isinstance(val, (int, long)) and 0 <= val <= 0xFFFFFFFF,
91 'LongField': lambda val: isinstance(val, (int, long)) and 0 <= val <= 0xFFFFFFFFFFFFFFFF,
92 'StrFixedLenField': lambda val: isinstance(val, basestring),
93 'MACField': lambda val: True, # TODO: Add a constraint for this field type
94 'BitField': lambda val: True, # TODO: Add a constraint for this field type
95 'IPField': lambda val: True, # TODO: Add a constraint for this field type
96 'OmciTableField': lambda val: True,
97
98 # TODO: As additional Scapy field types are used, add constraints
99 }
100
101 def valid(self, value):
102 def _isa_lambda_function(v):
103 import inspect
104 return callable(v) and len(inspect.getargspec(v).args) == 1
105
106 field_type = self.field.__class__.__name__
107 type_check = EntityClassAttribute._type_checker_map.get(field_type,
108 lambda val: True)
109
110 # TODO: Currently StrFixedLenField is used heavily for both bit fields as
111 # and other 'byte/octet' related strings that are NOT textual. Until
112 # all of these are corrected, 'StrFixedLenField' cannot test the type
113 # of the value provided
114
115 if field_type != 'StrFixedLenField' and not type_check(value):
116 return False
117
118 if _isa_lambda_function(self.range_check):
119 return self.range_check(value)
120 return True
121
122
123class EntityClassMeta(type):
124 """
125 Metaclass for EntityClass to generate secondary class attributes
126 for class attributes of the derived classes.
127 """
128 def __init__(cls, name, bases, dct):
129 super(EntityClassMeta, cls).__init__(name, bases, dct)
130
131 # initialize attribute_name_to_index_map
132 cls.attribute_name_to_index_map = dict(
133 (a._fld.name, idx) for idx, a in enumerate(cls.attributes))
134
135
136class EntityClass(object):
137
138 class_id = 'to be filled by subclass'
139 attributes = []
140 mandatory_operations = set()
141 optional_operations = set()
142 notifications = set()
143 alarms = dict() # Alarm Number -> Alarm Name
144 hidden = False # If true, this attribute is not reported by a MIB upload.
145 # This attribute is needed to be able to properly perform
146 # MIB Audits.
147
148 # will be map of attr_name -> index in attributes, initialized by metaclass
149 attribute_name_to_index_map = None
150 __metaclass__ = EntityClassMeta
151
152 def __init__(self, **kw):
153 assert(isinstance(kw, dict))
154 for k, v in kw.iteritems():
155 assert(k in self.attribute_name_to_index_map)
156 self._data = kw
157
158 def serialize(self, mask=None, operation=None):
159 octets = ''
160
161 # generate ordered list of attribute indices needed to be processed
162 # if mask is provided, we use that explicitly
163 # if mask is not provided, we determine attributes from the self._data
164 # content also taking into account the type of operation in hand
165 if mask is not None:
166 attribute_indices = EntityClass.attribute_indices_from_mask(mask)
167 else:
168 attribute_indices = self.attribute_indices_from_data()
169
170 # Serialize each indexed field (ignoring entity id)
171 for index in attribute_indices:
172 eca = self.attributes[index]
173 field = eca.field
174 try:
175 value = self._data[field.name]
176
177 if not eca.valid(value):
178 raise OmciInvalidTypeError(
179 'Value "{}" for Entity field "{}" is not valid'.format(value,
180 field.name))
181 except KeyError:
182 raise OmciUninitializedFieldError(
183 'Entity field "{}" not set'.format(field.name))
184
185 octets = field.addfield(None, octets, value)
186
187 return octets
188
189 def attribute_indices_from_data(self):
190 return sorted(
191 self.attribute_name_to_index_map[attr_name]
192 for attr_name in self._data.iterkeys())
193
194 byte1_mask_to_attr_indices = dict(
195 (m, bitpos_from_mask(m, 8, -1)) for m in range(256))
196 byte2_mask_to_attr_indices = dict(
197 (m, bitpos_from_mask(m, 16, -1)) for m in range(256))
198
199 @classmethod
200 def attribute_indices_from_mask(cls, mask):
201 # each bit in the 2-byte field denote an attribute index; we use a
202 # lookup table to make lookup a bit faster
203 return \
204 cls.byte1_mask_to_attr_indices[(mask >> 8) & 0xff] + \
205 cls.byte2_mask_to_attr_indices[(mask & 0xff)]
206
207 @classmethod
208 def mask_for(cls, *attr_names):
209 """
210 Return mask value corresponding to given attributes names
211 :param attr_names: Attribute names
212 :return: integer mask value
213 """
214 mask = 0
215 for attr_name in attr_names:
216 index = cls.attribute_name_to_index_map[attr_name]
217 mask |= (1 << (16 - index))
218 return mask
219
220
221# abbreviations
222ECA = EntityClassAttribute
223AA = AttributeAccess
224OP = EntityOperations
225
226
227class OntData(EntityClass):
228 class_id = 2
229 hidden = True
230 attributes = [
231 ECA(ShortField("managed_entity_id", None), {AA.R},
232 range_check=lambda x: x == 0),
233 # Only 1 octet used if GET/SET operation
234 ECA(ShortField("mib_data_sync", 0), {AA.R, AA.W})
235 ]
236 mandatory_operations = {OP.Get, OP.Set,
237 OP.GetAllAlarms, OP.GetAllAlarmsNext,
238 OP.MibReset, OP.MibUpload, OP.MibUploadNext}
239
240
241class Cardholder(EntityClass):
242 class_id = 5
243 attributes = [
244 ECA(ShortField("managed_entity_id", None), {AA.R},
245 range_check=lambda x: 0 <= x < 255 or 256 <= x < 511,
246 avc=True),
247 ECA(ByteField("actual_plugin_unit_type", None), {AA.R}),
248 ECA(ByteField("expected_plugin_unit_type", None), {AA.R, AA.W}),
249 ECA(ByteField("expected_port_count", None), {AA.R, AA.W},
250 optional=True),
251 ECA(StrFixedLenField("expected_equipment_id", None, 20), {AA.R, AA.W},
252 optional=True, avc=True),
253 ECA(StrFixedLenField("actual_equipment_id", None, 20), {AA.R},
254 optional=True),
255 ECA(ByteField("protection_profile_pointer", None), {AA.R},
256 optional=True),
257 ECA(ByteField("invoke_protection_switch", None), {AA.R, AA.W},
258 optional=True, range_check=lambda x: 0 <= x <= 3),
259 ECA(ByteField("alarm_reporting_control", 0), {AA.R, AA.W},
260 range_check=lambda x: 0 <= x <= 1, optional=True, avc=True),
261 ECA(ByteField("arc_interval", 0), {AA.R, AA.W}, optional=True),
262 ]
263 mandatory_operations = {OP.Get, OP.Set}
264 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
265 alarms = {
266 0: 'Plug-in circuit pack missing',
267 1: 'Plug-in type mismatch alarm',
268 2: 'Improper card removal',
269 3: 'Plug-in equipment ID mismatch alarm',
270 4: 'Protection switch',
271 }
272
273
274class CircuitPack(EntityClass):
275 class_id = 6
276 attributes = [
277 ECA(StrFixedLenField("managed_entity_id", None, 22), {AA.R, AA.SBC},
278 range_check=lambda x: 0 <= x < 255 or 256 <= x < 511),
279 ECA(ByteField("type", None), {AA.R, AA.SBC}),
280 ECA(ByteField("number_of_ports", None), {AA.R}, optional=True),
281 ECA(OmciSerialNumberField("serial_number"), {AA.R}),
282 ECA(StrFixedLenField("version", None, 14), {AA.R}),
283 ECA(StrFixedLenField("vendor_id", None, 4), {AA.R}),
284 ECA(ByteField("administrative_state", None), {AA.R, AA.W}),
285 ECA(ByteField("operational_state", None), {AA.R}, optional=True, avc=True),
286 ECA(ByteField("bridged_or_ip_ind", None), {AA.R, AA.W}, optional=True,
287 range_check=lambda x: 0 <= x <= 2),
288 ECA(StrFixedLenField("equipment_id", None, 20), {AA.R}, optional=True),
289 ECA(ByteField("card_configuration", None), {AA.R, AA.W, AA.SBC},
290 optional=True), # not really mandatory, see spec ITU-T G.988, 9.1.6
291 ECA(ByteField("total_tcont_buffer_number", None), {AA.R},
292 optional=True), # not really mandatory, see spec ITU-T G.988, 9.1.6
293 ECA(ByteField("total_priority_queue_number", None), {AA.R},
294 optional=True), # not really mandatory, see spec ITU-T G.988, 9.1.6
295 ECA(ByteField("total_traffic_scheduler_number", None), {AA.R},
296 optional=True), # not really mandatory, see spec ITU-T G.988, 9.1.6
297 ECA(IntField("power_shed_override", None), {AA.R, AA.W},
298 optional=True)
299 ]
300 mandatory_operations = {OP.Get, OP.Set, OP.Reboot}
301 optional_operations = {OP.Create, OP.Delete, OP.Test}
302 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
303 alarms = {
304 0: 'Equipment alarm',
305 1: 'Powering alarm',
306 2: 'Self-test failure',
307 3: 'Laser end of life',
308 4: 'Temperature yellow',
309 5: 'Temperature red',
310 }
311
312class SoftwareImage(EntityClass):
313 class_id = 7
314 attributes = [
315 ECA(ShortField("managed_entity_id", None), {AA.R},
316 range_check=lambda x: 0 <= x/256 <= 254 or 0 <= x % 256 <= 1),
317 ECA(StrFixedLenField("version", None, 14), {AA.R}, avc=True),
318 ECA(ByteField("is_committed", None), {AA.R}, avc=True,
319 range_check=lambda x: 0 <= x <= 1),
320 ECA(ByteField("is_active", None), {AA.R}, avc=True,
321 range_check=lambda x: 0 <= x <= 1),
322 ECA(ByteField("is_valid", None), {AA.R}, avc=True,
323 range_check=lambda x: 0 <= x <= 1),
324 ECA(StrFixedLenField("product_code", None, 25), {AA.R}, optional=True, avc=True),
325 ECA(StrFixedLenField("image_hash", None, 16), {AA.R}, optional=True, avc=True),
326 ]
327 mandatory_operations = {OP.Get, OP.StartSoftwareDownload, OP.DownloadSection,
328 OP.EndSoftwareDownload, OP.ActivateSoftware,
329 OP.CommitSoftware}
330 notifications = {OP.AttributeValueChange}
331
332
333class PptpEthernetUni(EntityClass):
334 class_id = 11
335 attributes = [
336 ECA(ShortField("managed_entity_id", None), {AA.R}),
337 ECA(ByteField("expected_type", 0), {AA.R, AA.W},
338 range_check=lambda x: 0 <= x <= 254),
339 ECA(ByteField("sensed_type", 0), {AA.R}, optional=True, avc=True),
340 # TODO: For sensed_type AVC, see note in AT&T OMCI Specification, V3.0, page 123
341 ECA(ByteField("auto_detection_configuration", 0), {AA.R, AA.W},
342 range_check=lambda x: x in [0, 1, 2, 3, 4, 5,
343 0x10, 0x11, 0x12, 0x13, 0x14,
344 0x20, 0x30], optional=True), # See ITU-T G.988
345 ECA(ByteField("ethernet_loopback_configuration", 0), {AA.R, AA.W},
346 range_check=lambda x: x in [0, 3]),
347 ECA(ByteField("administrative_state", 1), {AA.R, AA.W},
348 range_check=lambda x: 0 <= x <= 1),
349 ECA(ByteField("operational_state", 1), {AA.R, AA.W},
350 range_check=lambda x: 0 <= x <= 1, optional=True, avc=True),
351 ECA(ByteField("configuration_ind", 0), {AA.R},
352 range_check=lambda x: x in [0, 1, 2, 3, 4, 0x11, 0x12, 0x13]),
353 ECA(ShortField("max_frame_size", 1518), {AA.R, AA.W}, optional=True),
354 ECA(ByteField("dte_or_dce_ind", 0), {AA.R, AA.W},
355 range_check=lambda x: 0 <= x <= 2),
356 ECA(ShortField("pause_time", 0), {AA.R, AA.W}, optional=True),
357 ECA(ByteField("bridged_or_ip_ind", 2), {AA.R, AA.W},
358 optional=True, range_check=lambda x: 0 <= x <= 2),
359 ECA(ByteField("arc", 0), {AA.R, AA.W}, optional=True,
360 range_check=lambda x: 0 <= x <= 1, avc=True),
361 ECA(ByteField("arc_interval", 0), {AA.R, AA.W}, optional=True),
362 ECA(ByteField("pppoe_filter", 0), {AA.R, AA.W}, optional=True),
363 ECA(ByteField("power_control", 0), {AA.R, AA.W}, optional=True),
364 ]
365 mandatory_operations = {OP.Get, OP.Set}
366 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
367 alarms = {
368 0: 'LAN Loss Of Signal',
369 }
370
371
372class MacBridgeServiceProfile(EntityClass):
373 class_id = 45
374 attributes = [
375 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
376 ECA(ByteField("spanning_tree_ind", None), {AA.R, AA.W, AA.SBC},
377 range_check=lambda x: 0 <= x <= 1),
378 ECA(ByteField("learning_ind", None), {AA.R, AA.W, AA.SBC},
379 range_check=lambda x: 0 <= x <= 1),
380 ECA(ByteField("port_bridging_ind", None), {AA.R, AA.W, AA.SBC},
381 range_check=lambda x: 0 <= x <= 1),
382 ECA(ShortField("priority", None), {AA.R, AA.W, AA.SBC}),
383 ECA(ShortField("max_age", None), {AA.R, AA.W, AA.SBC},
384 range_check=lambda x: 0x0600 <= x <= 0x2800),
385 ECA(ShortField("hello_time", None), {AA.R, AA.W, AA.SBC},
386 range_check=lambda x: 0x0100 <= x <= 0x0A00),
387 ECA(ShortField("forward_delay", None), {AA.R, AA.W, AA.SBC},
388 range_check=lambda x: 0x0400 <= x <= 0x1E00),
389 ECA(ByteField("unknown_mac_address_discard", None),
390 {AA.R, AA.W, AA.SBC}, range_check=lambda x: 0 <= x <= 1),
391 ECA(ByteField("mac_learning_depth", None),
392 {AA.R, AA.W, AA.SBC}, optional=True),
393 ECA(ByteField("dynamic_filtering_ageing_time", None),
394 {AA.R, AA.W, AA.SBC}, optional=True),
395 ]
396 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
397
398
399class MacBridgePortConfigurationData(EntityClass):
400 class_id = 47
401 attributes = [
402 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
403 ECA(ShortField("bridge_id_pointer", None), {AA.R, AA.W, AA.SBC}),
404 ECA(ByteField("port_num", None), {AA.R, AA.W, AA.SBC}),
405 ECA(ByteField("tp_type", None), {AA.R, AA.W, AA.SBC},
406 range_check=lambda x: 1 <= x <= 12),
407 ECA(ShortField("tp_pointer", None), {AA.R, AA.W, AA.SBC}),
408 ECA(ShortField("port_priority", None), {AA.R, AA.W, AA.SBC}),
409 ECA(ShortField("port_path_cost", None), {AA.R, AA.W, AA.SBC}),
410 ECA(ByteField("port_spanning_tree_in", None), {AA.R, AA.W, AA.SBC}),
411 ECA(ByteField("encapsulation_methods", None), {AA.R, AA.W, AA.SBC},
412 optional=True, deprecated=True),
413 ECA(ByteField("lan_fcs_ind", None), {AA.R, AA.W, AA.SBC},
414 optional=True, deprecated=True),
415 ECA(MACField("port_mac_address", None), {AA.R}, optional=True),
416 ECA(ShortField("outbound_td_pointer", None), {AA.R, AA.W},
417 optional=True),
418 ECA(ShortField("inbound_td_pointer", None), {AA.R, AA.W},
419 optional=True),
420 # TODO:
421 ECA(ByteField("mac_learning_depth", 0), {AA.R, AA.W, AA.SBC},
422 optional=True),
423 ]
424 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
425 notifications = {OP.AlarmNotification}
426 alarms = {
427 0: 'Port blocking',
428 }
429
430
431class MacBridgePortFilterPreAssignTable(EntityClass):
432 class_id = 79
433 attributes = [
434 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
435 ECA(ShortField("ipv4_multicast", 0), {AA.R, AA.W},
436 range_check=lambda x: 0 <= x <= 1),
437 ECA(ShortField("ipv6_multicast", 0), {AA.R, AA.W},
438 range_check=lambda x: 0 <= x <= 1),
439 ECA(ShortField("ipv4_broadcast", 0), {AA.R, AA.W},
440 range_check=lambda x: 0 <= x <= 1),
441 ECA(ShortField("rarp", 0), {AA.R, AA.W},
442 range_check=lambda x: 0 <= x <= 1),
443 ECA(ShortField("ipx", 0), {AA.R, AA.W},
444 range_check=lambda x: 0 <= x <= 1),
445 ECA(ShortField("netbeui", 0), {AA.R, AA.W},
446 range_check=lambda x: 0 <= x <= 1),
447 ECA(ShortField("appletalk", 0), {AA.R, AA.W},
448 range_check=lambda x: 0 <= x <= 1),
449 ECA(ShortField("bridge_management_information", 0), {AA.R, AA.W},
450 range_check=lambda x: 0 <= x <= 1),
451 ECA(ShortField("arp", 0), {AA.R, AA.W},
452 range_check=lambda x: 0 <= x <= 1),
453 ECA(ShortField("pppoe_broadcast", 0), {AA.R, AA.W},
454 range_check=lambda x: 0 <= x <= 1)
455 ]
456 mandatory_operations = {OP.Get, OP.Set}
457
458
459class VlanTaggingFilterData(EntityClass):
460 class_id = 84
461 attributes = [
462 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
463 ECA(FieldListField("vlan_filter_list", None,
464 ShortField('', 0), count_from=lambda _: 12),
465 {AA.R, AA.W, AA.SBC}),
466 ECA(ByteField("forward_operation", None), {AA.R, AA.W, AA.SBC},
467 range_check=lambda x: 0x00 <= x <= 0x21),
468 ECA(ByteField("number_of_entries", None), {AA.R, AA.W, AA.SBC})
469 ]
470 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
471
472
473class Ieee8021pMapperServiceProfile(EntityClass):
474 class_id = 130
475 attributes = [
476 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
477 ECA(ShortField("tp_pointer", None), {AA.R, AA.W, AA.SBC}),
478 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_0",
479 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
480 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_1",
481 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
482 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_2",
483 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
484 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_3",
485 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
486 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_4",
487 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
488 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_5",
489 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
490 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_6",
491 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
492 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_7",
493 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
494 ECA(ByteField("unmarked_frame_option", None),
495 {AA.R, AA.W, AA.SBC}, range_check=lambda x: 0 <= x <= 1),
496 ECA(StrFixedLenField("dscp_to_p_bit_mapping", None, length=24),
497 {AA.R, AA.W}), # TODO: Would a custom 3-bit group bitfield work better?
498 ECA(ByteField("default_p_bit_marking", None),
499 {AA.R, AA.W, AA.SBC}),
500 ECA(ByteField("tp_type", None), {AA.R, AA.W, AA.SBC},
501 optional=True, range_check=lambda x: 0 <= x <= 8)
502 ]
503 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
504
505
506class OltG(EntityClass):
507 class_id = 131
508 attributes = [
509 ECA(ShortField("managed_entity_id", None), {AA.R},
510 range_check=lambda x: x == 0),
511 ECA(StrFixedLenField("olt_vendor_id", None, 4), {AA.R, AA.W}),
512 ECA(StrFixedLenField("equipment_id", None, 20), {AA.R, AA.W}),
513 ECA(StrFixedLenField("version", None, 14), {AA.R, AA.W}),
514 ECA(StrFixedLenField("time_of_day_information", None, 14), {AA.R, AA.W})
515 ]
516 mandatory_operations = {OP.Get, OP.Set}
517
518
519class OntPowerShedding(EntityClass):
520 class_id = 133
521 attributes = [
522 ECA(ShortField("managed_entity_id", None), {AA.R},
523 range_check=lambda x: x == 0),
524 ECA(ShortField("restore_power_timer_reset_interval", 0),
525 {AA.R, AA.W}),
526 ECA(ShortField("data_class_shedding_interval", 0), {AA.R, AA.W}),
527 ECA(ShortField("voice_class_shedding_interval", 0), {AA.R, AA.W}),
528 ECA(ShortField("video_overlay_class_shedding_interval", 0), {AA.R, AA.W}),
529 ECA(ShortField("video_return_class_shedding_interval", 0), {AA.R, AA.W}),
530 ECA(ShortField("dsl_class_shedding_interval", 0), {AA.R, AA.W}),
531 ECA(ShortField("atm_class_shedding_interval", 0), {AA.R, AA.W}),
532 ECA(ShortField("ces_class_shedding_interval", 0), {AA.R, AA.W}),
533 ECA(ShortField("frame_class_shedding_interval", 0), {AA.R, AA.W}),
534 ECA(ShortField("sonet_class_shedding_interval", 0), {AA.R, AA.W}),
535 ECA(ShortField("shedding_status", None), {AA.R, AA.W}, optional=True,
536 avc=True),
537 ]
538 mandatory_operations = {OP.Get, OP.Set}
539 notifications = {OP.AttributeValueChange}
540
541
542class IpHostConfigData(EntityClass):
543 class_id = 134
544 attributes = [
545 ECA(ShortField("managed_entity_id", None), {AA.R}),
546 ECA(BitField("ip_options", 0, size=8), {AA.R, AA.W}),
547 ECA(MACField("mac_address", None), {AA.R}),
548 ECA(StrFixedLenField("onu_identifier", None, 25), {AA.R, AA.W}),
549 ECA(IPField("ip_address", None), {AA.R, AA.W}),
550 ECA(IPField("mask", None), {AA.R, AA.W}),
551 ECA(IPField("gateway", None), {AA.R, AA.W}),
552 ECA(IPField("primary_dns", None), {AA.R, AA.W}),
553 ECA(IPField("secondary_dns", None), {AA.R, AA.W}),
554 ECA(IPField("current_address", None), {AA.R}, avc=True),
555 ECA(IPField("current_mask", None), {AA.R}, avc=True),
556 ECA(IPField("current_gateway", None), {AA.R}, avc=True),
557 ECA(IPField("current_primary_dns", None), {AA.R}, avc=True),
558 ECA(IPField("current_secondary_dns", None), {AA.R}, avc=True),
559 ECA(StrFixedLenField("domain_name", None, 25), {AA.R}, avc=True),
560 ECA(StrFixedLenField("host_name", None, 25), {AA.R}, avc=True),
561 ECA(ShortField("relay_agent_options", None), {AA.R, AA.W},
562 optional=True),
563 ]
564 mandatory_operations = {OP.Get, OP.Set, OP.Test}
565 notifications = {OP.AttributeValueChange}
566
567
568class VlanTaggingOperation(Packet):
569 name = "VlanTaggingOperation"
570 fields_desc = [
571 BitField("filter_outer_priority", 0, 4),
572 BitField("filter_outer_vid", 0, 13),
573 BitField("filter_outer_tpid_de", 0, 3),
574 BitField("pad1", 0, 12),
575
576 BitField("filter_inner_priority", 0, 4),
577 BitField("filter_inner_vid", 0, 13),
578 BitField("filter_inner_tpid_de", 0, 3),
579 BitField("pad2", 0, 8),
580 BitField("filter_ether_type", 0, 4),
581
582 BitField("treatment_tags_to_remove", 0, 2),
583 BitField("pad3", 0, 10),
584 BitField("treatment_outer_priority", 0, 4),
585 BitField("treatment_outer_vid", 0, 13),
586 BitField("treatment_outer_tpid_de", 0, 3),
587
588 BitField("pad4", 0, 12),
589 BitField("treatment_inner_priority", 0, 4),
590 BitField("treatment_inner_vid", 0, 13),
591 BitField("treatment_inner_tpid_de", 0, 3),
592 ]
593
594 def to_json(self):
595 return json.dumps(self.fields, separators=(',', ':'))
596
597 @staticmethod
598 def json_from_value(value):
599 bits = BitArray(hex=hexlify(value))
600 temp = VlanTaggingOperation(
601 filter_outer_priority=bits[0:4].uint, # 4 <-size
602 filter_outer_vid=bits[4:17].uint, # 13
603 filter_outer_tpid_de=bits[17:20].uint, # 3
604 # pad 12
605 filter_inner_priority=bits[32:36].uint, # 4
606 filter_inner_vid=bits[36:49].uint, # 13
607 filter_inner_tpid_de=bits[49:52].uint, # 3
608 # pad 8
609 filter_ether_type=bits[60:64].uint, # 4
610 treatment_tags_to_remove=bits[64:66].uint, # 2
611 # pad 10
612 treatment_outer_priority=bits[76:80].uint, # 4
613 treatment_outer_vid=bits[80:93].uint, # 13
614 treatment_outer_tpid_de=bits[93:96].uint, # 3
615 # pad 12
616 treatment_inner_priority=bits[108:112].uint, # 4
617 treatment_inner_vid=bits[112:125].uint, # 13
618 treatment_inner_tpid_de=bits[125:128].uint, # 3
619 )
620 return json.dumps(temp.fields, separators=(',', ':'))
621
622 def index(self):
623 return '{:02}'.format(self.fields.get('filter_outer_priority',0)) + \
624 '{:03}'.format(self.fields.get('filter_outer_vid',0)) + \
625 '{:01}'.format(self.fields.get('filter_outer_tpid_de',0)) + \
626 '{:03}'.format(self.fields.get('filter_inner_priority',0)) + \
627 '{:04}'.format(self.fields.get('filter_inner_vid',0)) + \
628 '{:01}'.format(self.fields.get('filter_inner_tpid_de',0)) + \
629 '{:02}'.format(self.fields.get('filter_ether_type',0))
630
631 def is_delete(self):
632 return self.fields.get('treatment_tags_to_remove',0) == 0x3 and \
633 self.fields.get('pad3',0) == 0x3ff and \
634 self.fields.get('treatment_outer_priority',0) == 0xf and \
635 self.fields.get('treatment_outer_vid',0) == 0x1fff and \
636 self.fields.get('treatment_outer_tpid_de',0) == 0x7 and \
637 self.fields.get('pad4',0) == 0xfff and \
638 self.fields.get('treatment_inner_priority',0) == 0xf and \
639 self.fields.get('treatment_inner_vid',0) == 0x1fff and \
640 self.fields.get('treatment_inner_tpid_de',0) == 0x7
641
642 def delete(self):
643 self.fields['treatment_tags_to_remove'] = 0x3
644 self.fields['pad3'] = 0x3ff
645 self.fields['treatment_outer_priority'] = 0xf
646 self.fields['treatment_outer_vid'] = 0x1fff
647 self.fields['treatment_outer_tpid_de'] = 0x7
648 self.fields['pad4'] = 0xfff
649 self.fields['treatment_inner_priority'] = 0xf
650 self.fields['treatment_inner_vid'] = 0x1fff
651 self.fields['treatment_inner_tpid_de'] = 0x7
652 return self
653
654
655class ExtendedVlanTaggingOperationConfigurationData(EntityClass):
656 class_id = 171
657 attributes = [
658 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
659 ECA(ByteField("association_type", None), {AA.R, AA.W, AA.SBC},
660 range_check=lambda x: 0 <= x <= 11),
661 ECA(ShortField("received_vlan_tagging_operation_table_max_size", None),
662 {AA.R}),
663 ECA(ShortField("input_tpid", None), {AA.R, AA.W}),
664 ECA(ShortField("output_tpid", None), {AA.R, AA.W}),
665 ECA(ByteField("downstream_mode", None), {AA.R, AA.W},
666 range_check=lambda x: 0 <= x <= 8),
667 ECA(OmciTableField(
668 PacketLenField("received_frame_vlan_tagging_operation_table", None,
669 VlanTaggingOperation, length_from=lambda pkt: 16)), {AA.R, AA.W}),
670 ECA(ShortField("associated_me_pointer", None), {AA.R, AA.W, AA.SBC}),
671 ECA(FieldListField("dscp_to_p_bit_mapping", None,
672 BitField('', 0, size=3), count_from=lambda _: 64),
673 {AA.R, AA.W}),
674 ]
675 mandatory_operations = {OP.Create, OP.Delete, OP.Set, OP.Get, OP.GetNext}
676 optional_operations = {OP.SetTable}
677
678
679class OntG(EntityClass):
680 class_id = 256
681 attributes = [
682 ECA(ShortField("managed_entity_id", None), {AA.R},
683 range_check=lambda x: x == 0),
684 ECA(StrFixedLenField("vendor_id", None, 4), {AA.R}),
685 ECA(StrFixedLenField("version", None, 14), {AA.R}),
686 ECA(OmciSerialNumberField("serial_number"), {AA.R}),
687 ECA(ByteField("traffic_management_option", None), {AA.R},
688 range_check=lambda x: 0 <= x <= 2),
689 ECA(ByteField("deprecated", 0), {AA.R},
690 optional=True, deprecated=True),
691 ECA(ByteField("battery_backup", None), {AA.R, AA.W},
692 range_check=lambda x: 0 <= x <= 1),
693 ECA(ByteField("administrative_state", None), {AA.R, AA.W},
694 range_check=lambda x: 0 <= x <= 1),
695 ECA(ByteField("operational_state", None), {AA.R}, optional=True,
696 range_check=lambda x: 0 <= x <= 1, avc=True),
697 ECA(ByteField("ont_survival_time", None), {AA.R}, optional=True),
698 ECA(StrFixedLenField("logical_onu_id", None, 24), {AA.R},
699 optional=True, avc=True),
700 ECA(StrFixedLenField("logical_password", None, 12), {AA.R},
701 optional=True, avc=True),
702 ECA(ByteField("credentials_status", None), {AA.R, AA.W},
703 optional=True, range_check=lambda x: 0 <= x <= 4),
704 ECA(BitField("extended_tc_layer_options", None, size=16), {AA.R},
705 optional=True),
706 ]
707 mandatory_operations = {
708 OP.Get, OP.Set, OP.Reboot, OP.Test, OP.SynchronizeTime}
709 notifications = {OP.TestResult, OP.AttributeValueChange,
710 OP.AlarmNotification}
711 alarms = {
712 0: 'Equipment alarm',
713 1: 'Powering alarm',
714 2: 'Battery missing',
715 3: 'Battery failure',
716 4: 'Battery low',
717 5: 'Physical intrusion',
718 6: 'Self-test failure',
719 7: 'Dying gasp',
720 8: 'Temperature yellow',
721 9: 'Temperature red',
722 10: 'Voltage yellow',
723 11: 'Voltage red',
724 12: 'ONU manual power off',
725 13: 'Invalid image',
726 14: 'PSE overload yellow',
727 15: 'PSE overload red',
728 }
729
730
731class Ont2G(EntityClass):
732 class_id = 257
733 attributes = [
734 ECA(ShortField("managed_entity_id", None), {AA.R},
735 range_check=lambda x: x == 0),
736 ECA(StrFixedLenField("equipment_id", None, 20), {AA.R}),
737 ECA(ByteField("omcc_version", None), {AA.R}, avc=True),
738 ECA(ShortField("vendor_product_code", None), {AA.R}),
739 ECA(ByteField("security_capability", None), {AA.R},
740 range_check=lambda x: 0 <= x <= 1),
741 ECA(ByteField("security_mode", None), {AA.R, AA.W},
742 range_check=lambda x: 0 <= x <= 1),
743 ECA(ShortField("total_priority_queue_number", None), {AA.R}),
744 ECA(ByteField("total_traffic_scheduler_number", None), {AA.R}),
745 ECA(ByteField("deprecated", None), {AA.R}, deprecated=True),
746 ECA(ShortField("total_gem_port_id_number", None), {AA.R}),
747 ECA(IntField("sys_uptime", None), {AA.R}),
748 ECA(BitField("connectivity_capability", None, size=16), {AA.R}),
749 ECA(ByteField("current_connectivity_mode", None), {AA.R, AA.W},
750 range_check=lambda x: 0 <= x <= 7),
751 ECA(BitField("qos_configuration_flexibility", None, size=16),
752 {AA.R}, optional=True),
753 ECA(ShortField("priority_queue_scale_factor", None), {AA.R, AA.W},
754 optional=True),
755 ]
756 mandatory_operations = {OP.Get, OP.Set}
757 notifications = {OP.AttributeValueChange}
758
759
760class Tcont(EntityClass):
761 class_id = 262
762 attributes = [
763 ECA(ShortField("managed_entity_id", None), {AA.R}),
764 ECA(ShortField("alloc_id", None), {AA.R, AA.W}),
765 ECA(ByteField("deprecated", 1), {AA.R}, deprecated=True),
766 ECA(ByteField("policy", None), {AA.R, AA.W},
767 range_check=lambda x: 0 <= x <= 2),
768 ]
769 mandatory_operations = {OP.Get, OP.Set}
770
771
772class AniG(EntityClass):
773 class_id = 263
774 attributes = [
775 ECA(ShortField("managed_entity_id", None), {AA.R}),
776 ECA(ByteField("sr_indication", None), {AA.R}),
777 ECA(ShortField("total_tcont_number", None), {AA.R}),
778 ECA(ShortField("gem_block_length", None), {AA.R, AA.W}),
779 ECA(ByteField("piggyback_dba_reporting", None), {AA.R},
780 range_check=lambda x: 0 <= x <= 4),
781 ECA(ByteField("deprecated", None), {AA.R}, deprecated=True),
782 ECA(ByteField("sf_threshold", 5), {AA.R, AA.W}),
783 ECA(ByteField("sd_threshold", 9), {AA.R, AA.W}),
784 ECA(ByteField("arc", 0), {AA.R, AA.W},
785 range_check=lambda x: 0 <= x <= 1, avc=True),
786 ECA(ByteField("arc_interval", 0), {AA.R, AA.W}),
787 ECA(ShortField("optical_signal_level", None), {AA.R}),
788 ECA(ByteField("lower_optical_threshold", 0xFF), {AA.R, AA.W}),
789 ECA(ByteField("upper_optical_threshold", 0xFF), {AA.R, AA.W}),
790 ECA(ShortField("onu_response_time", None), {AA.R}),
791 ECA(ShortField("transmit_optical_level", None), {AA.R}),
792 ECA(ByteField("lower_transmit_power_threshold", 0x81), {AA.R, AA.W}),
793 ECA(ByteField("upper_transmit_power_threshold", 0x81), {AA.R, AA.W}),
794 ]
795 mandatory_operations = {OP.Get, OP.Set, OP.Test}
796 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
797 alarms = {
798 0: 'Low received optical power',
799 1: 'High received optical power',
800 2: 'Signal fail',
801 3: 'Signal degrade',
802 4: 'Low transmit optical power',
803 5: 'High transmit optical power',
804 6: 'Laser bias current',
805 }
806
807
808class UniG(EntityClass):
809 class_id = 264
810 attributes = [
811 ECA(ShortField("managed_entity_id", None), {AA.R}),
812 ECA(ShortField("deprecated", None), {AA.R, AA.W}, 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)