blob: 95bad37f75c88e4195ecb4bc47c48d8110c0e075 [file] [log] [blame]
Chip Boling67b674a2019-02-08 11:42:18 -06001#
2# Copyright 2017 the original author or authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
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 pyvoltha.adapters.extensions.omci.omci_defs import OmciUninitializedFieldError, \
27 AttributeAccess, OmciNullPointer, EntityOperations, OmciInvalidTypeError
28from pyvoltha.adapters.extensions.omci.omci_fields import OmciSerialNumberField, OmciTableField
29from pyvoltha.adapters.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),
Matt Jeanneret72fe6ae2019-04-13 20:58:47 -0400259 ECA(ByteField("arc", 0), {AA.R, AA.W},
Chip Boling67b674a2019-02-08 11:42:18 -0600260 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
Matt Jeanneret72fe6ae2019-04-13 20:58:47 -0400297 ECA(IntField("power_sched_override", None), {AA.R, AA.W},
Chip Boling67b674a2019-02-08 11:42:18 -0600298 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
Matt Jeanneret72fe6ae2019-04-13 20:58:47 -0400341 ECA(ByteField("autodetection_config", 0), {AA.R, AA.W},
Chip Boling67b674a2019-02-08 11:42:18 -0600342 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
Matt Jeanneret72fe6ae2019-04-13 20:58:47 -0400345 ECA(ByteField("ethernet_loopback_config", 0), {AA.R, AA.W},
Chip Boling67b674a2019-02-08 11:42:18 -0600346 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),
Matt Jeanneretd55eb152019-10-08 13:59:23 -0400349 ECA(ByteField("operational_state", 1), {AA.R},
Chip Boling67b674a2019-02-08 11:42:18 -0600350 range_check=lambda x: 0 <= x <= 1, optional=True, avc=True),
Matt Jeanneret72fe6ae2019-04-13 20:58:47 -0400351 ECA(ByteField("config_ind", 0), {AA.R},
Chip Boling67b674a2019-02-08 11:42:18 -0600352 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),
Matt Jeanneret72fe6ae2019-04-13 20:58:47 -0400354 ECA(ByteField("dte_dce_ind", 0), {AA.R, AA.W},
Chip Boling67b674a2019-02-08 11:42:18 -0600355 range_check=lambda x: 0 <= x <= 2),
356 ECA(ShortField("pause_time", 0), {AA.R, AA.W}, optional=True),
Matt Jeanneret72fe6ae2019-04-13 20:58:47 -0400357 ECA(ByteField("bridged_ip_ind", 2), {AA.R, AA.W},
Chip Boling67b674a2019-02-08 11:42:18 -0600358 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}),
Matt Jeanneret72fe6ae2019-04-13 20:58:47 -0400514 ECA(StrFixedLenField("time_of_day", None, 14), {AA.R, AA.W})
Chip Boling67b674a2019-02-08 11:42:18 -0600515 ]
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),
Matt Jeanneret72fe6ae2019-04-13 20:58:47 -0400524 ECA(ShortField("restore_power_time_reset_interval", 0),
Chip Boling67b674a2019-02-08 11:42:18 -0600525 {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}),
Matt Jeanneret72fe6ae2019-04-13 20:58:47 -0400687 ECA(ByteField("traffic_management_options", None), {AA.R},
Chip Boling67b674a2019-02-08 11:42:18 -0600688 range_check=lambda x: 0 <= x <= 2),
Matt Jeanneret72fe6ae2019-04-13 20:58:47 -0400689 ECA(ByteField("vp_vc_cross_connection_option", 0), {AA.R},
Chip Boling67b674a2019-02-08 11:42:18 -0600690 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}),
Matt Jeanneret72fe6ae2019-04-13 20:58:47 -0400745 ECA(ByteField("mode", None), {AA.R}, deprecated=True),
Chip Boling67b674a2019-02-08 11:42:18 -0600746 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}),
Matt Jeanneret72fe6ae2019-04-13 20:58:47 -0400765 ECA(ByteField("mode_indicator", 1), {AA.R}, deprecated=True),
Chip Boling67b674a2019-02-08 11:42:18 -0600766 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),
Matt Jeanneret72fe6ae2019-04-13 20:58:47 -0400781 ECA(ByteField("whole_ont_dba_reporting", None), {AA.R},
782 deprecated=True),
Chip Boling67b674a2019-02-08 11:42:18 -0600783 ECA(ByteField("sf_threshold", 5), {AA.R, AA.W}),
784 ECA(ByteField("sd_threshold", 9), {AA.R, AA.W}),
785 ECA(ByteField("arc", 0), {AA.R, AA.W},
786 range_check=lambda x: 0 <= x <= 1, avc=True),
787 ECA(ByteField("arc_interval", 0), {AA.R, AA.W}),
788 ECA(ShortField("optical_signal_level", None), {AA.R}),
789 ECA(ByteField("lower_optical_threshold", 0xFF), {AA.R, AA.W}),
790 ECA(ByteField("upper_optical_threshold", 0xFF), {AA.R, AA.W}),
Matt Jeanneret72fe6ae2019-04-13 20:58:47 -0400791 ECA(ShortField("ont_response_time", None), {AA.R}),
Chip Boling67b674a2019-02-08 11:42:18 -0600792 ECA(ShortField("transmit_optical_level", None), {AA.R}),
793 ECA(ByteField("lower_transmit_power_threshold", 0x81), {AA.R, AA.W}),
794 ECA(ByteField("upper_transmit_power_threshold", 0x81), {AA.R, AA.W}),
795 ]
796 mandatory_operations = {OP.Get, OP.Set, OP.Test}
797 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
798 alarms = {
799 0: 'Low received optical power',
800 1: 'High received optical power',
801 2: 'Signal fail',
802 3: 'Signal degrade',
803 4: 'Low transmit optical power',
804 5: 'High transmit optical power',
805 6: 'Laser bias current',
806 }
807
808
809class UniG(EntityClass):
810 class_id = 264
811 attributes = [
812 ECA(ShortField("managed_entity_id", None), {AA.R}),
Matt Jeanneret72fe6ae2019-04-13 20:58:47 -0400813 ECA(ShortField("configuration_option_status", None), {AA.R, AA.W},
814 deprecated=True),
Chip Boling67b674a2019-02-08 11:42:18 -0600815 ECA(ByteField("administrative_state", None), {AA.R, AA.W}),
816 ECA(ByteField("management_capability", None), {AA.R},
817 range_check=lambda x: 0 <= x <= 2),
818 ECA(ShortField("non_omci_management_identifier", None), {AA.R, AA.W}),
819 ECA(ShortField("relay_agent_options", None), {AA.R, AA.W},
820 optional=True),
821 ]
822 mandatory_operations = {OP.Get, OP.Set}
823
824
825class GemInterworkingTp(EntityClass):
826 class_id = 266
827 attributes = [
828 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
829 ECA(ShortField("gem_port_network_ctp_pointer", None),
830 {AA.R, AA.W, AA.SBC}),
831 ECA(ByteField("interworking_option", None), {AA.R, AA.W, AA.SBC},
832 range_check=lambda x: 0 <= x <= 7),
833 ECA(ShortField("service_profile_pointer", None), {AA.R, AA.W, AA.SBC}),
834 ECA(ShortField("interworking_tp_pointer", None), {AA.R, AA.W, AA.SBC}),
835 ECA(ByteField("pptp_counter", None), {AA.R}, optional=True),
836 ECA(ByteField("operational_state", None), {AA.R}, optional=True,
837 range_check=lambda x: 0 <= x <= 1, avc=True),
838 ECA(ShortField("gal_profile_pointer", None), {AA.R, AA.W, AA.SBC}),
839 ECA(ByteField("gal_loopback_configuration", 0),
840 {AA.R, AA.W}, range_check=lambda x: 0 <= x <= 1),
841 ]
842 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
843 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
844 alarms = {
845 6: 'Operational state change',
846 }
847
848
849class GemPortNetworkCtp(EntityClass):
850 class_id = 268
851 attributes = [
852 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
853 ECA(ShortField("port_id", None), {AA.R, AA.W, AA.SBC}),
854 ECA(ShortField("tcont_pointer", None), {AA.R, AA.W, AA.SBC}),
855 ECA(ByteField("direction", None), {AA.R, AA.W, AA.SBC},
856 range_check=lambda x: 1 <= x <= 3),
857 ECA(ShortField("traffic_management_pointer_upstream", None),
858 {AA.R, AA.W, AA.SBC}),
859 ECA(ShortField("traffic_descriptor_profile_pointer", None),
860 {AA.R, AA.W, AA.SBC}, optional=True),
861 ECA(ByteField("uni_counter", None), {AA.R}, optional=True),
862 ECA(ShortField("priority_queue_pointer_downstream", None),
863 {AA.R, AA.W, AA.SBC}),
864 ECA(ByteField("encryption_state", None), {AA.R}, optional=True),
865 ECA(ShortField("traffic_desc_profile_pointer_downstream", None),
866 {AA.R, AA.W, AA.SBC}, optional=True),
867 ECA(ShortField("encryption_key_ring", None), {AA.R, AA.W, AA.SBC},
868 range_check=lambda x: 0 <= x <= 3)
869 ]
870 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
871 notifications = {OP.AlarmNotification}
872 alarms = {
873 5: 'End-to-end loss of continuity',
874 }
875
876
877class GalEthernetProfile(EntityClass):
878 class_id = 272
879 attributes = [
880 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
881 ECA(ShortField("max_gem_payload_size", None), {AA.R, AA.W, AA.SBC}),
882 ]
883 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
884
885
886class PriorityQueueG(EntityClass):
887 class_id = 277
888 attributes = [
889 ECA(ShortField("managed_entity_id", None), {AA.R}),
890 ECA(ByteField("queue_configuration_option", None), {AA.R},
891 range_check=lambda x: 0 <= x <= 1),
892 ECA(ShortField("maximum_queue_size", None), {AA.R}),
893 ECA(ShortField("allocated_queue_size", None), {AA.R, AA.W}),
894 ECA(ShortField("discard_block_counter_reset_interval", None), {AA.R, AA.W}),
895 ECA(ShortField("threshold_value_for_discarded_blocks", None), {AA.R, AA.W}),
aishwaryarana01e7eb1c72019-07-24 09:52:21 -0500896 ECA(IntField("related_port", None), {AA.R, AA.W}),
Chip Boling67b674a2019-02-08 11:42:18 -0600897 ECA(ShortField("traffic_scheduler_pointer", 0), {AA.R, AA.W}),
898 ECA(ByteField("weight", 1), {AA.R, AA.W}),
899 ECA(ShortField("back_pressure_operation", 0), {AA.R, AA.W},
900 range_check=lambda x: 0 <= x <= 1),
901 ECA(IntField("back_pressure_time", 0), {AA.R, AA.W}),
902 ECA(ShortField("back_pressure_occur_queue_threshold", None), {AA.R, AA.W}),
903 ECA(ShortField("back_pressure_clear_queue_threshold", None), {AA.R, AA.W}),
904 # TODO: Custom field of 4 2-byte values would help below
905 ECA(LongField("packet_drop_queue_thresholds", None), {AA.R, AA.W},
906 optional=True),
907 ECA(ShortField("packet_drop_max_p", 0xFFFF), {AA.R, AA.W}, optional=True),
908 ECA(ByteField("queue_drop_w_q", 9), {AA.R, AA.W}, optional=True),
909 ECA(ByteField("drop_precedence_colour_marking", 0), {AA.R, AA.W},
910 optional=True, range_check=lambda x: 0 <= x <= 7),
911 ]
912 mandatory_operations = {OP.Get, OP.Set}
913 notifications = {OP.AlarmNotification}
914 alarms = {
915 0: 'Block loss',
916 }
917
918
919class TrafficSchedulerG(EntityClass):
920 class_id = 278
921 attributes = [
922 ECA(ShortField("managed_entity_id", None), {AA.R}),
923 ECA(ShortField("tcont_pointer", None), {AA.R}),
924 ECA(ShortField("traffic_scheduler_pointer", None), {AA.R}),
925 ECA(ByteField("policy", None), {AA.R, AA.W},
926 range_check=lambda x: 0 <= x <= 2),
927 ECA(ByteField("priority_weight", 0), {AA.R, AA.W}),
928 ]
929 mandatory_operations = {OP.Get, OP.Set}
930
931
932class MulticastGemInterworkingTp(EntityClass):
933 class_id = 281
934 attributes = [
935 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC},
936 range_check=lambda x: x != OmciNullPointer),
937 ECA(ShortField("gem_port_network_ctp_pointer", None), {AA.R, AA.SBC}),
938 ECA(ByteField("interworking_option", None), {AA.R, AA.W, AA.SBC},
939 range_check=lambda x: x in [0, 1, 3, 5]),
940 ECA(ShortField("service_profile_pointer", None), {AA.R, AA.W, AA.SBC}),
941 ECA(ShortField("interworking_tp_pointer", 0), {AA.R, AA.W, AA.SBC},
942 deprecated=True),
943 ECA(ByteField("pptp_counter", None), {AA.R}),
944 ECA(ByteField("operational_state", None), {AA.R}, avc=True,
945 range_check=lambda x: 0 <= x <= 1),
946 ECA(ShortField("gal_profile_pointer", None), {AA.R, AA.W, AA.SBC}),
947 ECA(ByteField("gal_loopback_configuration", None), {AA.R, AA.W, AA.SBC},
948 deprecated=True),
949 # TODO add multicast_address_table here (page 85 of spec.)
950 # ECA(...("multicast_address_table", None), {AA.R, AA.W})
951 ]
952 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.GetNext, OP.Set}
953 optional_operations = {OP.SetTable}
954 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
955 alarms = {
956 0: 'Deprecated',
957 }
958
959
960class AccessControlRow0(Packet):
961 name = "AccessControlRow0"
962 fields_desc = [
963 BitField("set_ctrl", 0, 2),
964 BitField("row_part_id", 0, 3),
965 BitField("test", 0, 1),
966 BitField("row_key", 0, 10),
967
968 ShortField("gem_port_id", None),
969 ShortField("vlan_id", None),
970 IPField("src_ip", None),
971 IPField("dst_ip_start", None),
972 IPField("dst_ip_end", None),
973 IntField("ipm_group_bw", None),
974 ShortField("reserved0", 0)
975 ]
976
977 def to_json(self):
978 return json.dumps(self.fields, separators=(',', ':'))
979
980
981class AccessControlRow1(Packet):
982 name = "AccessControlRow1"
983 fields_desc = [
984 BitField("set_ctrl", 0, 2),
985 BitField("row_part_id", 0, 3),
986 BitField("test", 0, 1),
987 BitField("row_key", 0, 10),
988
989 StrFixedLenField("ipv6_src_addr_start_bytes", None, 12),
990 ShortField("preview_length", None),
991 ShortField("preview_repeat_time", None),
992 ShortField("preview_repeat_count", None),
993 ShortField("preview_reset_time", None),
994 ShortField("reserved1", 0)
995 ]
996
997 def to_json(self):
998 return json.dumps(self.fields, separators=(',', ':'))
999
1000
1001class AccessControlRow2(Packet):
1002 name = "AccessControlRow2"
1003 fields_desc = [
1004 BitField("set_ctrl", 0, 2),
1005 BitField("row_part_id", 0, 3),
1006 BitField("test", 0, 1),
1007 BitField("row_key", 0, 10),
1008
1009 StrFixedLenField("ipv6_dst_addr_start_bytes", None, 12),
1010 StrFixedLenField("reserved2", None, 10)
1011 ]
1012
1013 def to_json(self):
1014 return json.dumps(self.fields, separators=(',', ':'))
1015
1016
1017class DownstreamIgmpMulticastTci(Packet):
1018 name = "DownstreamIgmpMulticastTci"
1019 fields_desc = [
1020 ByteField("ctrl_type", None),
1021 ShortField("tci", None)
1022 ]
1023
1024 def to_json(self):
1025 return json.dumps(self.fields, separators=(',', ':'))
1026
1027
1028class MulticastOperationsProfile(EntityClass):
1029 class_id = 309
1030 attributes = [
1031 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC},
1032 range_check=lambda x: x != 0 and x != OmciNullPointer),
1033 ECA(ByteField("igmp_version", None), {AA.R, AA.W, AA.SBC},
1034 range_check=lambda x: x in [1, 2, 3, 16, 17]),
1035 ECA(ByteField("igmp_function", None), {AA.R, AA.W, AA.SBC},
1036 range_check=lambda x: 0 <= x <= 2),
1037 ECA(ByteField("immediate_leave", None), {AA.R, AA.W, AA.SBC},
1038 range_check=lambda x: 0 <= x <= 1),
1039 ECA(ShortField("us_igmp_tci", None), {AA.R, AA.W, AA.SBC}, optional=True),
1040 ECA(ByteField("us_igmp_tag_ctrl", None), {AA.R, AA.W, AA.SBC},
1041 range_check=lambda x: 0 <= x <= 3, optional=True),
1042 ECA(IntField("us_igmp_rate", None), {AA.R, AA.W, AA.SBC}, optional=True),
1043 # TODO: need to make table and add column data
1044 ECA(StrFixedLenField(
1045 "dynamic_access_control_list_table", None, 24), {AA.R, AA.W}),
1046 # TODO: need to make table and add column data
1047 ECA(StrFixedLenField(
1048 "static_access_control_list_table", None, 24), {AA.R, AA.W}),
1049 # TODO: need to make table and add column data
1050 ECA(StrFixedLenField("lost_groups_list_table", None, 10), {AA.R}),
1051 ECA(ByteField("robustness", None), {AA.R, AA.W, AA.SBC}),
1052 ECA(IntField("querier_ip", None), {AA.R, AA.W, AA.SBC}),
1053 ECA(IntField("query_interval", None), {AA.R, AA.W, AA.SBC}),
1054 ECA(IntField("querier_max_response_time", None), {AA.R, AA.W, AA.SBC}),
1055 ECA(IntField("last_member_response_time", 10), {AA.R, AA.W}),
1056 ECA(ByteField("unauthorized_join_behaviour", None), {AA.R, AA.W}),
1057 ECA(StrFixedLenField("ds_igmp_mcast_tci", None, 3), {AA.R, AA.W, AA.SBC}, optional=True)
1058 ]
1059 mandatory_operations = {OP.Create, OP.Delete, OP.Set, OP.Get, OP.GetNext}
1060 optional_operations = {OP.SetTable}
1061 notifications = {OP.AlarmNotification}
1062 alarms = {
1063 0: 'Lost multicast group',
1064 }
1065
1066
1067class MulticastServicePackage(Packet):
1068 name = "MulticastServicePackage"
1069 fields_desc = [
1070 BitField("set_ctrl", 0, 2),
1071 BitField("reserved0", 0, 4),
1072 BitField("row_key", 0, 10),
1073
1074 ShortField("vid_uni", None),
1075 ShortField("max_simultaneous_groups", None),
1076 IntField("max_multicast_bw", None),
1077 ShortField("mcast_operations_profile_pointer", None),
1078 StrFixedLenField("reserved1", None, 8)
1079 ]
1080
1081 def to_json(self):
1082 return json.dumps(self.fields, separators=(',', ':'))
1083
1084
1085class AllowedPreviewGroupsRow0(Packet):
1086 name = "AllowedPreviewGroupsRow0"
1087 fields_desc = [
1088 BitField("set_ctrl", 0, 2),
1089 BitField("row_part_id", 0, 3),
1090 BitField("reserved0", 0, 1),
1091 BitField("row_key", 0, 10),
1092
1093 StrFixedLenField("ipv6_pad", 0, 12),
1094 IPField("src_ip", None),
1095 ShortField("vlan_id_ani", None),
1096 ShortField("vlan_id_uni", None)
1097 ]
1098
1099 def to_json(self):
1100 return json.dumps(self.fields, separators=(',', ':'))
1101
1102
1103class AllowedPreviewGroupsRow1(Packet):
1104 name = "AllowedPreviewGroupsRow1"
1105 fields_desc = [
1106 BitField("set_ctrl", 0, 2),
1107 BitField("row_part_id", 0, 3),
1108 BitField("reserved0", 0, 1),
1109 BitField("row_key", 0, 10),
1110
1111 StrFixedLenField("ipv6_pad", 0, 12),
1112 IPField("dst_ip", None),
1113 ShortField("duration", None),
1114 ShortField("time_left", None)
1115 ]
1116
1117 def to_json(self):
1118 return json.dumps(self.fields, separators=(',', ':'))
1119
1120
1121class MulticastSubscriberConfigInfo(EntityClass):
1122 class_id = 310
1123 attributes = [
1124 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
1125 ECA(ByteField("me_type", None), {AA.R, AA.W, AA.SBC},
1126 range_check=lambda x: 0 <= x <= 1),
1127 ECA(ShortField("mcast_operations_profile_pointer", None),
1128 {AA.R, AA.W, AA.SBC}),
1129 ECA(ShortField("max_simultaneous_groups", None), {AA.R, AA.W, AA.SBC}),
1130 ECA(IntField("max_multicast_bandwidth", None), {AA.R, AA.W, AA.SBC}),
1131 ECA(ByteField("bandwidth_enforcement", None), {AA.R, AA.W, AA.SBC},
1132 range_check=lambda x: 0 <= x <= 1),
1133 # TODO: need to make table and add column data
1134 ECA(StrFixedLenField(
1135 "multicast_service_package_table", None, 20), {AA.R, AA.W}),
1136 # TODO: need to make table and add column data
1137 ECA(StrFixedLenField(
1138 "allowed_preview_groups_table", None, 22), {AA.R, AA.W}),
1139 ]
1140 mandatory_operations = {OP.Create, OP.Delete, OP.Set, OP.Get, OP.GetNext,
1141 OP.SetTable}
1142
1143
1144class VirtualEthernetInterfacePt(EntityClass):
1145 class_id = 329
1146 attributes = [
1147 ECA(ShortField("managed_entity_id", None), {AA.R},
1148 range_check=lambda x: x != 0 and x != OmciNullPointer),
1149 ECA(ByteField("administrative_state", None), {AA.R, AA.W},
1150 range_check=lambda x: 0 <= x <= 1),
1151 ECA(ByteField("operational_state", None), {AA.R}, avc=True,
1152 range_check=lambda x: 0 <= x <= 1),
1153 ECA(StrFixedLenField(
1154 "interdomain_name", None, 25), {AA.R, AA.W}, optional=True),
1155 ECA(ShortField("tcp_udp_pointer", None), {AA.R, AA.W}, optional=True),
1156 ECA(ShortField("iana_assigned_port", None), {AA.R}),
1157 ]
1158 mandatory_operations = {OP.Get, OP.Set}
1159 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
1160 alarms = {
1161 0: 'Connecting function fail',
1162 }
1163
1164
Matt Jeanneret72fe6ae2019-04-13 20:58:47 -04001165class OmciMeTypeTable(Packet):
1166 """
1167 OMCI ME Supported Types Table
1168 """
1169 name = "OmciMeTypeTable"
1170 fields_desc = [
1171 ShortField("me_type", None)
1172 ]
1173
1174 def to_json(self):
1175 return json.dumps(self.fields, separators=(',', ':'))
1176
1177 @staticmethod
1178 def json_from_value(value):
1179 data = int(value)
1180 temp = OmciMeTypeTable(me_type=data)
1181 return json.dumps(temp.fields, separators=(',', ':'))
1182
1183 def index(self):
1184 return '{:04}'.format(self.fields.get('me_type', 0))
1185
1186 def is_delete(self):
1187 return self.fields.get('me_type', 0) == 0
1188
1189 def delete(self):
1190 self.fields['me_type'] = 0
1191 return self
1192
1193
1194class OmciMsgTypeTable(Packet):
1195 """
1196 OMCI Supported Message Types Table
1197 """
1198 name = "OmciMsgTypeTable"
1199 fields_desc = [
1200 ByteField("msg_type", None)
1201 ]
1202
1203 def to_json(self):
1204 return json.dumps(self.fields, separators=(',', ':'))
1205
1206 @staticmethod
1207 def json_from_value(value):
1208 data = int(value)
1209 temp = OmciMeTypeTable(me_type=data)
1210 return json.dumps(temp.fields, separators=(',', ':'))
1211
1212 def index(self):
1213 return '{:02}'.format(self.fields.get('msg_type', 0))
1214
1215 def is_delete(self):
1216 return self.fields.get('me_type', 0) == 0
1217
1218 def delete(self):
1219 self.fields['me_type'] = 0
1220 return self
1221
1222
Chip Boling67b674a2019-02-08 11:42:18 -06001223class Omci(EntityClass):
1224 class_id = 287
1225 hidden = True
1226 attributes = [
1227 ECA(ShortField("managed_entity_id", None), {AA.R},
1228 range_check=lambda x: x == 0),
1229
Matt Jeanneret72fe6ae2019-04-13 20:58:47 -04001230 ECA(OmciTableField(
1231 PacketLenField("me_type_table", None,
1232 OmciMeTypeTable, length_from=lambda pkt: 2)),
1233 {AA.R}),
Chip Boling67b674a2019-02-08 11:42:18 -06001234
Matt Jeanneret72fe6ae2019-04-13 20:58:47 -04001235 ECA(OmciTableField(
1236 PacketLenField("message_type_table", None,
1237 OmciMsgTypeTable, length_from=lambda pkt: 1)),
1238 {AA.R}),
Chip Boling67b674a2019-02-08 11:42:18 -06001239 ]
1240 mandatory_operations = {OP.Get, OP.GetNext}
1241
1242
1243class EnhSecurityControl(EntityClass):
1244 class_id = 332
1245 attributes = [
1246 ECA(ShortField("managed_entity_id", None), {AA.R}),
1247 ECA(BitField("olt_crypto_capabilities", None, 16*8), {AA.W}),
1248 # TODO: need to make table and add column data
1249 ECA(StrFixedLenField(
1250 "olt_random_challenge_table", None, 17), {AA.R, AA.W}),
1251 ECA(ByteField("olt_challenge_status", 0), {AA.R, AA.W},
1252 range_check=lambda x: 0 <= x <= 1),
1253 ECA(ByteField("onu_selected_crypto_capabilities", None), {AA.R}),
1254 # TODO: need to make table and add column data
1255 ECA(StrFixedLenField(
1256 "onu_random_challenge_table", None, 16), {AA.R}, avc=True),
1257 # TODO: need to make table and add column data
1258 ECA(StrFixedLenField(
1259 "onu_authentication_result_table", None, 16), {AA.R}, avc=True),
1260 # TODO: need to make table and add column data
1261 ECA(StrFixedLenField(
1262 "olt_authentication_result_table", None, 17), {AA.W}),
1263 ECA(ByteField("olt_result_status", None), {AA.R, AA.W},
1264 range_check=lambda x: 0 <= x <= 1),
1265 ECA(ByteField("onu_authentication_status", None), {AA.R}, avc=True,
1266 range_check=lambda x: 0 <= x <= 5),
1267 ECA(StrFixedLenField(
1268 "master_session_key_name", None, 16), {AA.R}),
1269 ECA(StrFixedLenField(
1270 "broadcast_key_table", None, 18), {AA.R, AA.W}),
1271 ECA(ShortField("effective_key_length", None), {AA.R}),
1272
1273 ]
1274 mandatory_operations = {OP.Set, OP.Get, OP.GetNext}
1275 notifications = {OP.AttributeValueChange}
1276
1277
1278class EthernetPMMonitoringHistoryData(EntityClass):
1279 class_id = 24
1280 hidden = True
1281 attributes = [
1282 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
1283 ECA(ByteField("interval_end_time", None), {AA.R}),
1284 ECA(ShortField("threshold_data_1_2_id", None), {AA.R, AA.W, AA.SBC}),
1285 ECA(IntField("fcs_errors", None), {AA.R}, tca=True, counter=True),
1286 ECA(IntField("excessive_collision_counter", None), {AA.R}, tca=True, counter=True),
1287 ECA(IntField("late_collision_counter", None), {AA.R}, tca=True, counter=True),
1288 ECA(IntField("frames_too_long", None), {AA.R}, tca=True, counter=True),
1289 ECA(IntField("buffer_overflows_on_rx", None), {AA.R}, tca=True, counter=True),
1290 ECA(IntField("buffer_overflows_on_tx", None), {AA.R}, tca=True, counter=True),
1291 ECA(IntField("single_collision_frame_counter", None), {AA.R}, tca=True, counter=True),
1292 ECA(IntField("multiple_collisions_frame_counter", None), {AA.R}, tca=True, counter=True),
1293 ECA(IntField("sqe_counter", None), {AA.R}, tca=True, counter=True),
1294 ECA(IntField("deferred_tx_counter", None), {AA.R}, tca=True, counter=True),
1295 ECA(IntField("internal_mac_tx_error_counter", None), {AA.R}, tca=True, counter=True),
1296 ECA(IntField("carrier_sense_error_counter", None), {AA.R}, tca=True, counter=True),
1297 ECA(IntField("alignment_error_counter", None), {AA.R}, tca=True, counter=True),
1298 ECA(IntField("internal_mac_rx_error_counter", None), {AA.R}, tca=True, counter=True)
1299 ]
1300 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set, OP.GetCurrentData}
1301 notifications = {OP.AlarmNotification}
1302 alarms = {
1303 0: 'FCS errors',
1304 1: 'Excessive collision counter',
1305 2: 'Late collision counter',
1306 3: 'Frames too long',
1307 4: 'Buffer overflows on receive',
1308 5: 'Buffer overflows on transmit',
1309 6: 'Single collision frame counter',
1310 7: 'Multiple collision frame counter',
1311 8: 'SQE counter',
1312 9: 'Deferred transmission counter',
1313 10: 'Internal MAC transmit error counter',
1314 11: 'Carrier sense error counter',
1315 12: 'Alignment error counter',
1316 13: 'Internal MAC receive error counter',
1317 }
1318
1319
1320class FecPerformanceMonitoringHistoryData(EntityClass):
1321 class_id = 312
1322 hidden = True
1323 attributes = [
1324 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
1325 ECA(ByteField("interval_end_time", None), {AA.R}),
1326 ECA(ShortField("threshold_data_1_2_id", None), {AA.R, AA.W, AA.SBC}),
1327 ECA(IntField("corrected_bytes", None), {AA.R}, tca=True, counter=True),
1328 ECA(IntField("corrected_code_words", None), {AA.R}, tca=True, counter=True),
1329 ECA(IntField("uncorrectable_code_words", None), {AA.R}, tca=True, counter=True),
1330 ECA(IntField("total_code_words", None), {AA.R}, counter=True),
1331 ECA(ShortField("fec_seconds", None), {AA.R}, tca=True, counter=True)
1332 ]
1333 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set, OP.GetCurrentData}
1334 notifications = {OP.AlarmNotification}
1335 alarms = {
1336 0: 'Corrected bytes',
1337 1: 'Corrected code words',
1338 2: 'Uncorrectable code words',
1339 4: 'FEC seconds',
1340 }
1341
1342
1343class EthernetFrameDownstreamPerformanceMonitoringHistoryData(EntityClass):
1344 class_id = 321
1345 hidden = True
1346 attributes = [
1347 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
1348 ECA(ByteField("interval_end_time", None), {AA.R}),
1349 ECA(ShortField("threshold_data_1_2_id", None), {AA.R, AA.W, AA.SBC}),
1350 ECA(IntField("drop_events", None), {AA.R}, tca=True, counter=True),
1351 ECA(IntField("octets", None), {AA.R}, counter=True),
1352 ECA(IntField("packets", None), {AA.R}, counter=True),
1353 ECA(IntField("broadcast_packets", None), {AA.R}, counter=True),
1354 ECA(IntField("multicast_packets", None), {AA.R}, counter=True),
1355 ECA(IntField("crc_errored_packets", None), {AA.R}, tca=True, counter=True),
1356 ECA(IntField("undersize_packets", None), {AA.R}, tca=True, counter=True),
1357 ECA(IntField("oversize_packets", None), {AA.R}, tca=True, counter=True),
1358 ECA(IntField("64_octets", None), {AA.R}, counter=True),
1359 ECA(IntField("65_to_127_octets", None), {AA.R}, counter=True),
1360 ECA(IntField("128_to_255_octets", None), {AA.R}, counter=True),
1361 ECA(IntField("256_to_511_octets", None), {AA.R}, counter=True),
1362 ECA(IntField("512_to_1023_octets", None), {AA.R}, counter=True),
1363 ECA(IntField("1024_to_1518_octets", None), {AA.R}, counter=True)
1364 ]
1365 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set, OP.GetCurrentData}
1366 notifications = {OP.AlarmNotification}
1367 alarms = {
1368 0: 'Drop events',
1369 1: 'CRC errored packets',
1370 2: 'Undersize packets',
1371 3: 'Oversize packets',
1372 }
1373
1374
1375class EthernetFrameUpstreamPerformanceMonitoringHistoryData(EntityClass):
1376 class_id = 322
1377 hidden = True
1378 attributes = [
1379 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
1380 ECA(ByteField("interval_end_time", None), {AA.R}),
1381 ECA(ShortField("threshold_data_1_2_id", None), {AA.R, AA.W, AA.SBC}),
1382 ECA(IntField("drop_events", None), {AA.R}, tca=True, counter=True),
1383 ECA(IntField("octets", None), {AA.R}, counter=True),
1384 ECA(IntField("packets", None), {AA.R}, counter=True),
1385 ECA(IntField("broadcast_packets", None), {AA.R}, counter=True),
1386 ECA(IntField("multicast_packets", None), {AA.R}, counter=True),
1387 ECA(IntField("crc_errored_packets", None), {AA.R}, tca=True, counter=True),
1388 ECA(IntField("undersize_packets", None), {AA.R}, tca=True, counter=True),
1389 ECA(IntField("oversize_packets", None), {AA.R}, tca=True, counter=True),
1390 ECA(IntField("64_octets", None), {AA.R}, counter=True),
1391 ECA(IntField("65_to_127_octets", None), {AA.R}, counter=True),
1392 ECA(IntField("128_to_255_octets", None), {AA.R}, counter=True),
1393 ECA(IntField("256_to_511_octets", None), {AA.R}, counter=True),
1394 ECA(IntField("512_to_1023_octets", None), {AA.R}, counter=True),
1395 ECA(IntField("1024_to_1518_octets", None), {AA.R}, counter=True)
1396 ]
1397 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set, OP.GetCurrentData}
1398 notifications = {OP.AlarmNotification}
1399 alarms = {
1400 0: 'Drop events',
1401 1: 'CRC errored packets',
1402 2: 'Undersize packets',
1403 3: 'Oversize packets',
1404 }
1405
1406
1407class VeipUni(EntityClass):
1408 class_id = 329
1409 attributes = [
1410 ECA(ShortField("managed_entity_id", None), {AA.R}),
1411 ECA(ByteField("administrative_state", 1), {AA.R, AA.W},
1412 range_check=lambda x: 0 <= x <= 1),
1413 ECA(ByteField("operational_state", 1), {AA.R, AA.W},
1414 range_check=lambda x: 0 <= x <= 1, optional=True, avc=True),
1415 ECA(StrFixedLenField("interdomain_name", None, 25), {AA.R, AA.W},
1416 optional=True),
1417 ECA(ShortField("tcp_udp_pointer", None), {AA.R, AA.W}, optional=True),
1418 ECA(ShortField("iana_assigned_port", 0xFFFF), {AA.R})
1419 ]
1420 mandatory_operations = {OP.Get, OP.Set}
1421 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
1422 alarms = {
1423 0: 'Connecting function fail'
1424 }
1425
1426
1427class EthernetFrameExtendedPerformanceMonitoring(EntityClass):
1428 class_id = 334
1429 hidden = True
1430 attributes = [
1431 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
1432 ECA(ByteField("interval_end_time", None), {AA.R}),
1433 # 2-octet field -> Threshold data 1/2 ID
1434 # 2-octet field -> Parent ME Class
1435 # 2-octet field -> Parent ME Instance
1436 # 2-octet field -> Accumulation disable
1437 # 2-octet field -> TCA Disable
1438 # 2-octet field -> Control fields bitmap
1439 # 2-octet field -> TCI
1440 # 2-octet field -> Reserved
1441 ECA(FieldListField("control_block", None, ShortField('', 0),
1442 count_from=lambda _: 8), {AA.R, AA.W, AA.SBC}),
1443 ECA(IntField("drop_events", None), {AA.R}, tca=True, counter=True),
1444 ECA(IntField("octets", None), {AA.R}, counter=True),
1445 ECA(IntField("packets", None), {AA.R}, counter=True),
1446 ECA(IntField("broadcast_packets", None), {AA.R}, counter=True),
1447 ECA(IntField("multicast_packets", None), {AA.R}, counter=True),
1448 ECA(IntField("crc_errored_packets", None), {AA.R}, tca=True, counter=True),
1449 ECA(IntField("undersize_packets", None), {AA.R}, tca=True, counter=True),
1450 ECA(IntField("oversize_packets", None), {AA.R}, tca=True, counter=True),
1451 ECA(IntField("64_octets", None), {AA.R}, counter=True),
1452 ECA(IntField("65_to_127_octets", None), {AA.R}, counter=True),
1453 ECA(IntField("128_to_255_octets", None), {AA.R}, counter=True),
1454 ECA(IntField("256_to_511_octets", None), {AA.R}, counter=True),
1455 ECA(IntField("512_to_1023_octets", None), {AA.R}, counter=True),
1456 ECA(IntField("1024_to_1518_octets", None), {AA.R}, counter=True)
1457 ]
1458 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
1459 optional_operations = {OP.GetCurrentData}
1460 notifications = {OP.AlarmNotification}
1461 alarms = {
1462 0: 'Drop events',
1463 1: 'CRC errored packets',
1464 2: 'Undersize packets',
1465 3: 'Oversize packets',
1466 }
1467
1468
1469class EthernetFrameExtendedPerformanceMonitoring64Bit(EntityClass):
1470 class_id = 426
1471 hidden = True
1472 attributes = [
1473 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
1474 ECA(ByteField("interval_end_time", None), {AA.R}),
1475 # 2-octet field -> Threshold data 1/2 ID
1476 # 2-octet field -> Parent ME Class
1477 # 2-octet field -> Parent ME Instance
1478 # 2-octet field -> Accumulation disable
1479 # 2-octet field -> TCA Disable
1480 # 2-octet field -> Control fields bitmap
1481 # 2-octet field -> TCI
1482 # 2-octet field -> Reserved
1483 ECA(FieldListField("control_block", None, ShortField('', 0),
1484 count_from=lambda _: 8), {AA.R, AA.W, AA.SBC}),
1485 ECA(LongField("drop_events", None), {AA.R}, tca=True, counter=True),
1486 ECA(LongField("octets", None), {AA.R}, counter=True),
1487 ECA(LongField("packets", None), {AA.R}, counter=True),
1488 ECA(LongField("broadcast_packets", None), {AA.R}, counter=True),
1489 ECA(LongField("multicast_packets", None), {AA.R}, counter=True),
1490 ECA(LongField("crc_errored_packets", None), {AA.R}, tca=True, counter=True),
1491 ECA(LongField("undersize_packets", None), {AA.R}, tca=True, counter=True),
1492 ECA(LongField("oversize_packets", None), {AA.R}, tca=True, counter=True),
1493 ECA(LongField("64_octets", None), {AA.R}, counter=True),
1494 ECA(LongField("65_to_127_octets", None), {AA.R}, counter=True),
1495 ECA(LongField("128_to_255_octets", None), {AA.R}, counter=True),
1496 ECA(LongField("256_to_511_octets", None), {AA.R}, counter=True),
1497 ECA(LongField("512_to_1023_octets", None), {AA.R}, counter=True),
1498 ECA(LongField("1024_to_1518_octets", None), {AA.R}, counter=True)
1499 ]
1500 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
1501 optional_operations = {OP.GetCurrentData}
1502 notifications = {OP.AlarmNotification}
1503 alarms = {
1504 0: 'Drop events',
1505 1: 'CRC errored packets',
1506 2: 'Undersize packets',
1507 3: 'Oversize packets',
1508 }
1509
1510
1511class GemPortNetworkCtpMonitoringHistoryData(EntityClass):
1512 class_id = 341
1513 hidden = True
1514 attributes = [
1515 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
1516 ECA(ByteField("interval_end_time", None), {AA.R}),
1517 ECA(ShortField("threshold_data_1_2_id", None), {AA.R, AA.W, AA.SBC}),
1518 ECA(IntField("transmitted_gem_frames", None), {AA.R}, counter=True),
1519 ECA(IntField("received_gem_frames", None), {AA.R}, counter=True),
1520 ECA(LongField("received_payload_bytes", None), {AA.R}, counter=True),
1521 ECA(LongField("transmitted_payload_bytes", None), {AA.R}, counter=True),
1522 ECA(IntField("encryption_key_errors", None), {AA.R}, tca=True, counter=True)
1523 ]
1524 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set, OP.GetCurrentData}
1525 notifications = {OP.AlarmNotification}
1526 alarms = {
1527 1: 'Encryption key errors',
1528 }
1529
1530
1531class XgPonTcPerformanceMonitoringHistoryData(EntityClass):
1532 class_id = 344
1533 hidden = True
1534 attributes = [
1535 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
1536 ECA(ByteField("interval_end_time", None), {AA.R}),
1537 ECA(ShortField("threshold_data_1_2_id", None), {AA.R, AA.W, AA.SBC}),
1538 ECA(IntField("psbd_hec_error_count", None), {AA.R}, tca=True, counter=True),
1539 ECA(IntField("xgtc_hec_error_count", None), {AA.R}, tca=True, counter=True),
1540 ECA(IntField("unknown_profile_count", None), {AA.R}, tca=True, counter=True),
1541 ECA(IntField("transmitted_xgem_frames", None), {AA.R}, counter=True),
1542 ECA(IntField("fragment_xgem_frames", None), {AA.R}, counter=True),
1543 ECA(IntField("xgem_hec_lost_words_count", None), {AA.R}, tca=True, counter=True),
1544 ECA(IntField("xgem_key_errors", None), {AA.R}, tca=True, counter=True),
1545 ECA(IntField("xgem_hec_error_count", None), {AA.R}, tca=True, counter=True)
1546 ]
1547 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
1548 optional_operations = {OP.GetCurrentData}
1549 notifications = {OP.AlarmNotification}
1550 alarms = {
1551 1: 'PSBd HEC error count',
1552 2: 'XGTC HEC error count',
1553 3: 'Unknown profile count',
1554 4: 'XGEM HEC loss count',
1555 5: 'XGEM key errors',
1556 6: 'XGEM HEC error count',
1557 }
1558
1559
1560class XgPonDownstreamPerformanceMonitoringHistoryData(EntityClass):
1561 class_id = 345
1562 hidden = True
1563 attributes = [
1564 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
1565 ECA(ByteField("interval_end_time", None), {AA.R},),
1566 ECA(ShortField("threshold_data_1_2_id", None), {AA.R, AA.W, AA.SBC}),
1567 ECA(IntField("ploam_mic_error_count", None), {AA.R}, tca=True, counter=True),
1568 ECA(IntField("downstream_ploam_messages_count", None), {AA.R}, counter=True),
1569 ECA(IntField("profile_messages_received", None), {AA.R}, counter=True),
1570 ECA(IntField("ranging_time_messages_received", None), {AA.R}, counter=True),
1571 ECA(IntField("deactivate_onu_id_messages_received", None), {AA.R}, counter=True),
1572 ECA(IntField("disable_serial_number_messages_received", None), {AA.R}, counter=True),
1573 ECA(IntField("request_registration_messages_received", None), {AA.R}, counter=True),
1574 ECA(IntField("assign_alloc_id_messages_received", None), {AA.R}, counter=True),
1575 ECA(IntField("key_control_messages_received", None), {AA.R}, counter=True),
1576 ECA(IntField("sleep_allow_messages_received", None), {AA.R}, counter=True),
1577 ECA(IntField("baseline_omci_messages_received_count", None), {AA.R}, counter=True),
1578 ECA(IntField("extended_omci_messages_received_count", None), {AA.R}, counter=True),
1579 ECA(IntField("assign_onu_id_messages_received", None), {AA.R}, counter=True),
1580 ECA(IntField("omci_mic_error_count", None), {AA.R}, tca=True, counter=True),
1581 ]
1582 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
1583 optional_operations = {OP.GetCurrentData}
1584 notifications = {OP.AlarmNotification}
1585 alarms = {
1586 1: 'PLOAM MIC error count',
1587 2: 'OMCI MIC error count',
1588 }
1589
1590
1591class XgPonUpstreamPerformanceMonitoringHistoryData(EntityClass):
1592 class_id = 346
1593 hidden = True
1594 attributes = [
1595 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
1596 ECA(ByteField("interval_end_time", None), {AA.R}),
1597 ECA(ShortField("threshold_data_1_2_id", None), {AA.R, AA.W, AA.SBC}),
1598 ECA(IntField("upstream_ploam_message_count", None), {AA.R}, counter=True),
1599 ECA(IntField("serial_number_onu_message_count", None), {AA.R}, counter=True),
1600 ECA(IntField("registration_message_count", None), {AA.R}, counter=True),
1601 ECA(IntField("key_report_message_count", None), {AA.R}, counter=True),
1602 ECA(IntField("acknowledge_message_count", None), {AA.R}, counter=True),
1603 ECA(IntField("sleep_request_message_count", None), {AA.R}, counter=True),
1604 ]
1605 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
1606 optional_operations = {OP.GetCurrentData}
1607
1608
1609# entity class lookup table from entity_class values
1610entity_classes_name_map = dict(
1611 inspect.getmembers(sys.modules[__name__],
1612 lambda o: inspect.isclass(o) and \
1613 issubclass(o, EntityClass) and \
1614 o is not EntityClass)
1615)
1616
1617entity_classes = [c for c in entity_classes_name_map.itervalues()]
1618entity_id_to_class_map = dict((c.class_id, c) for c in entity_classes)