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