blob: 65e53590444f08a88ed70839f3488473b7960775 [file] [log] [blame]
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -08001#
Zsolt Haraszti3eb27a52017-01-03 21:56:48 -08002# Copyright 2017 the original author or authors.
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -08003#
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
Nathan Knuthb396f472017-03-28 17:18:51 -070019from binascii import hexlify
Chip Bolingc7d3e2d2018-04-06 10:16:29 -050020import json
Zsolt Haraszti578a46c2016-12-20 16:38:43 -080021from scapy.fields import ByteField, ShortField, MACField, BitField, IPField
Chip Bolinge2e64a02018-02-06 12:58:07 -060022from scapy.fields import IntField, StrFixedLenField, LongField
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -080023from scapy.packet import Packet
24
25from voltha.extensions.omci.omci_defs import OmciUninitializedFieldError, \
Chip Bolinge2e64a02018-02-06 12:58:07 -060026 AttributeAccess, OmciNullPointer, EntityOperations, OmciInvalidTypeError
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -080027from voltha.extensions.omci.omci_defs import bitpos_from_mask
28
29
30class EntityClassAttribute(object):
31
Chip Bolinge2e64a02018-02-06 12:58:07 -060032 def __init__(self, fld, access=set(), optional=False, range_check=None,
33 avc=False, deprecated=False):
34 """
35 Initialize an Attribute for a Managed Entity Class
36
37 :param fld: (Field) Scapy field type
38 :param access: (AttributeAccess) Allowed access
39 :param optional: (boolean) If true, attribute is option, else mandatory
40 :param range_check: (callable) None, Lambda, or Function to validate value
41 :param avc: (boolean) If true, an AVC notification can occur for the attribute
42 :param deprecated: (boolean) If true, this attribute is deprecated and
43 only 'read' operations (if-any) performed.
44 """
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -080045 self._fld = fld
46 self._access = access
47 self._optional = optional
Chip Bolinge2e64a02018-02-06 12:58:07 -060048 self._range_check = range_check
49 self._avc = avc
50 self._deprecated = deprecated
51
52 @property
53 def field(self):
54 return self._fld
55
56 @property
57 def access(self):
58 return self._access
59
60 @property
61 def optional(self):
62 return self._optional
63
64 @property
65 def range_check(self):
66 return self._range_check
67
68 @property
69 def avc_allowed(self):
70 return self._avc
71
72 @property
73 def deprecated(self):
74 return self._deprecated
75
76 _type_checker_map = {
77 'ByteField': lambda val: isinstance(val, (int, long)) and 0 <= val <= 0xFF,
78 'ShortField': lambda val: isinstance(val, (int, long)) and 0 <= val <= 0xFFFF,
79 'IntField': lambda val: isinstance(val, (int, long)) and 0 <= val <= 0xFFFFFFFF,
80 'LongField': lambda val: isinstance(val, (int, long)) and 0 <= val <= 0xFFFFFFFFFFFFFFFF,
81 'StrFixedLenField': lambda val: isinstance(val, basestring),
82 'MACField': lambda val: True, # TODO: Add a constraint for this field type
83 'BitField': lambda val: True, # TODO: Add a constraint for this field type
84 'IPField': lambda val: True, # TODO: Add a constraint for this field type
85
86 # TODO: As additional Scapy field types are used, add constraints
87 }
88
89 def valid(self, value):
90 def _isa_lambda_function(v):
91 import inspect
92 return callable(v) and len(inspect.getargspec(v).args) == 1
93
94 field_type = self.field.__class__.__name__
95 type_check = EntityClassAttribute._type_checker_map.get(field_type,
96 lambda val: True)
97
98 # TODO: Currently StrFixedLenField is used heavily for both bit fields as
99 # and other 'byte/octet' related strings that are NOT textual. Until
100 # all of these are corrected, 'StrFixedLenField' cannot test the type
101 # of the value provided
102
103 if field_type != 'StrFixedLenField' and not type_check(value):
104 return False
105
106 if _isa_lambda_function(self.range_check):
107 return self.range_check(value)
108 return True
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800109
110
111class EntityClassMeta(type):
112 """
113 Metaclass for EntityClass to generate secondary class attributes
114 for class attributes of the derived classes.
115 """
116 def __init__(cls, name, bases, dct):
117 super(EntityClassMeta, cls).__init__(name, bases, dct)
118
119 # initialize attribute_name_to_index_map
120 cls.attribute_name_to_index_map = dict(
121 (a._fld.name, idx) for idx, a in enumerate(cls.attributes))
122
123
124class EntityClass(object):
125
126 class_id = 'to be filled by subclass'
127 attributes = []
Chip Boling106b60a2018-01-21 06:55:40 -0600128 mandatory_operations = set()
129 optional_operations = set()
Chip Bolinge2e64a02018-02-06 12:58:07 -0600130 notifications = set()
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800131
132 # will be map of attr_name -> index in attributes, initialized by metaclass
133 attribute_name_to_index_map = None
134 __metaclass__ = EntityClassMeta
135
136 def __init__(self, **kw):
137 assert(isinstance(kw, dict))
138 for k, v in kw.iteritems():
139 assert(k in self.attribute_name_to_index_map)
140 self._data = kw
141
142 def serialize(self, mask=None, operation=None):
Chip Bolinge2e64a02018-02-06 12:58:07 -0600143 octets = ''
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800144
145 # generate ordered list of attribute indices needed to be processed
146 # if mask is provided, we use that explicitly
147 # if mask is not provided, we determine attributes from the self._data
148 # content also taking into account the type of operation in hand
149 if mask is not None:
150 attribute_indices = EntityClass.attribute_indices_from_mask(mask)
151 else:
152 attribute_indices = self.attribute_indices_from_data()
153
154 # Serialize each indexed field (ignoring entity id)
155 for index in attribute_indices:
Chip Bolinge2e64a02018-02-06 12:58:07 -0600156 eca = self.attributes[index]
157 field = eca.field
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800158 try:
159 value = self._data[field.name]
Chip Bolinge2e64a02018-02-06 12:58:07 -0600160
161 if not eca.valid(value):
162 raise OmciInvalidTypeError(
163 'Value "{}" for Entity field "{}" is not valid'.format(value,
164 field.name))
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800165 except KeyError:
166 raise OmciUninitializedFieldError(
Chip Bolinge2e64a02018-02-06 12:58:07 -0600167 'Entity field "{}" not set'.format(field.name))
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800168
Chip Bolinge2e64a02018-02-06 12:58:07 -0600169 octets = field.addfield(None, octets, value)
170
171 return octets
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800172
173 def attribute_indices_from_data(self):
174 return sorted(
175 self.attribute_name_to_index_map[attr_name]
176 for attr_name in self._data.iterkeys())
177
178 byte1_mask_to_attr_indices = dict(
179 (m, bitpos_from_mask(m, 8, -1)) for m in range(256))
180 byte2_mask_to_attr_indices = dict(
181 (m, bitpos_from_mask(m, 16, -1)) for m in range(256))
Chip Bolinge2e64a02018-02-06 12:58:07 -0600182
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800183 @classmethod
184 def attribute_indices_from_mask(cls, mask):
185 # each bit in the 2-byte field denote an attribute index; we use a
186 # lookup table to make lookup a bit faster
187 return \
188 cls.byte1_mask_to_attr_indices[(mask >> 8) & 0xff] + \
189 cls.byte2_mask_to_attr_indices[(mask & 0xff)]
190
191 @classmethod
192 def mask_for(cls, *attr_names):
193 """
194 Return mask value corresponding to given attributes names
195 :param attr_names: Attribute names
196 :return: integer mask value
197 """
198 mask = 0
199 for attr_name in attr_names:
200 index = cls.attribute_name_to_index_map[attr_name]
201 mask |= (1 << (16 - index))
202 return mask
203
204
205# abbreviations
206ECA = EntityClassAttribute
207AA = AttributeAccess
208OP = EntityOperations
209
210
211class OntData(EntityClass):
212 class_id = 2
213 attributes = [
Chip Bolinge2e64a02018-02-06 12:58:07 -0600214 ECA(ShortField("managed_entity_id", None), {AA.R},
215 range_check=lambda x: x == 0),
Chip Boling9b7a11a2018-04-15 13:33:21 -0500216 # Only 1 octet used if GET/SET operation
217 ECA(ShortField("mib_data_sync", 0), {AA.R, AA.W})
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800218 ]
219 mandatory_operations = {OP.Get, OP.Set,
220 OP.GetAllAlarms, OP.GetAllAlarmsNext,
221 OP.MibReset, OP.MibUpload, OP.MibUploadNext}
Zsolt Harasztie3ece3c2016-12-19 23:32:38 -0800222
223
224class Cardholder(EntityClass):
225 class_id = 5
226 attributes = [
Chip Bolinge2e64a02018-02-06 12:58:07 -0600227 ECA(ShortField("managed_entity_id", None), {AA.R},
228 range_check=lambda x: 0 <= x < 255 or 256 <= x < 511,
229 avc=True),
Zsolt Harasztie3ece3c2016-12-19 23:32:38 -0800230 ECA(ByteField("actual_plugin_unit_type", None), {AA.R}),
231 ECA(ByteField("expected_plugin_unit_type", None), {AA.R, AA.W}),
232 ECA(ByteField("expected_port_count", None), {AA.R, AA.W},
233 optional=True),
234 ECA(StrFixedLenField("expected_equipment_id", None, 20), {AA.R, AA.W},
Chip Bolinge2e64a02018-02-06 12:58:07 -0600235 optional=True, avc=True),
Zsolt Harasztie3ece3c2016-12-19 23:32:38 -0800236 ECA(StrFixedLenField("actual_equipment_id", None, 20), {AA.R},
237 optional=True),
238 ECA(ByteField("protection_profile_pointer", None), {AA.R},
239 optional=True),
240 ECA(ByteField("invoke_protection_switch", None), {AA.R, AA.W},
Chip Bolinge2e64a02018-02-06 12:58:07 -0600241 optional=True, range_check=lambda x: 0 <= x <= 3),
242 ECA(ByteField("arc", 0), {AA.R, AA.W},
243 range_check=lambda x: 0 <= x <= 1, optional=True, avc=True),
244 ECA(ByteField("arc_interval", 0), {AA.R, AA.W}, optional=True),
Zsolt Harasztie3ece3c2016-12-19 23:32:38 -0800245 ]
246 mandatory_operations = {OP.Get, OP.Set}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600247 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800248
249
250class CircuitPack(EntityClass):
251 class_id = 6
252 attributes = [
Chip Bolinge2e64a02018-02-06 12:58:07 -0600253 ECA(StrFixedLenField("managed_entity_id", None, 22), {AA.R, AA.SBC},
254 range_check=lambda x: 0 <= x < 255 or 256 <= x < 511),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800255 ECA(ByteField("type", None), {AA.R, AA.SBC}),
256 ECA(ByteField("number_of_ports", None), {AA.R}, optional=True),
257 ECA(StrFixedLenField("serial_number", None, 8), {AA.R}),
258 ECA(StrFixedLenField("version", None, 14), {AA.R}),
259 ECA(StrFixedLenField("vendor_id", None, 4), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600260 ECA(ByteField("administrative_state", None), {AA.R, AA.W}),
261 ECA(ByteField("operational_state", None), {AA.R}, optional=True, avc=True),
262 ECA(ByteField("bridged_or_ip_ind", None), {AA.R, AA.W}, optional=True,
263 range_check=lambda x: 0 <= x <= 2),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800264 ECA(StrFixedLenField("equipment_id", None, 20), {AA.R}, optional=True),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600265 ECA(ByteField("card_configuration", None), {AA.R, AA.W, AA.SBC},
266 optional=True), # not really mandatory, see spec ITU-T G.988, 9.1.6
267 ECA(ByteField("total_tcont_buffer_number", None), {AA.R},
268 optional=True), # not really mandatory, see spec ITU-T G.988, 9.1.6
269 ECA(ByteField("total_priority_queue_number", None), {AA.R},
270 optional=True), # not really mandatory, see spec ITU-T G.988, 9.1.6
271 ECA(ByteField("total_traffic_scheduler_number", None), {AA.R},
272 optional=True), # not really mandatory, see spec ITU-T G.988, 9.1.6
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800273 ECA(IntField("power_sched_override", None), {AA.R, AA.W},
274 optional=True)
275 ]
276 mandatory_operations = {OP.Get, OP.Set, OP.Reboot}
277 optional_operations = {OP.Create, OP.Delete, OP.Test}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600278 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800279
280
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800281class SoftwareImage(EntityClass):
282 class_id = 7
283 attributes = [
Chip Bolinge2e64a02018-02-06 12:58:07 -0600284 ECA(ShortField("managed_entity_id", None), {AA.R},
285 range_check=lambda x: 0 <= x/256 <= 254 or 0 <= x % 256 <= 1),
286 ECA(StrFixedLenField("version", None, 14), {AA.R}, avc=True),
287 ECA(ByteField("is_committed", None), {AA.R}, avc=True,
288 range_check=lambda x: 0 <= x <= 1),
289 ECA(ByteField("is_active", None), {AA.R}, avc=True,
290 range_check=lambda x: 0 <= x <= 1),
291 ECA(ByteField("is_valid", None), {AA.R}, avc=True,
292 range_check=lambda x: 0 <= x <= 1),
293 ECA(StrFixedLenField("product_code", None, 25), {AA.R}, optional=True, avc=True),
294 ECA(StrFixedLenField("image_hash", None, 16), {AA.R}, optional=True, avc=True),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800295 ]
Chip Bolinge2e64a02018-02-06 12:58:07 -0600296 mandatory_operations = {OP.Get, OP.StartSoftwareDownload, OP.DownloadSection,
297 OP.EndSoftwareDownload, OP.ActivateSoftware,
298 OP.CommitSoftware}
299 notifications = {OP.AttributeValueChange}
300
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800301
Nathan Knuth61a039c2017-03-23 13:50:29 -0700302class PptpEthernetUni(EntityClass):
303 class_id = 11
304 attributes = [
Chip Bolinge2e64a02018-02-06 12:58:07 -0600305 ECA(ShortField("managed_entity_id", None), {AA.R}),
306 ECA(ByteField("expected_type", 0), {AA.R, AA.W},
307 range_check=lambda x: 0 <= x <= 254),
308 ECA(ByteField("sensed_type", 0), {AA.R}, optional=True, avc=True),
309 # TODO: For sensed_type AVC, see not in AT&T OMCI Specification, V3.0, page 123
310 ECA(ByteField("autodetection_config", 0), {AA.R, AA.W},
311 range_check=lambda x: x in [0, 1, 2, 3, 4, 5,
312 0x10, 0x11, 0x12, 0x13, 0x14,
313 0x20, 0x30], optional=True), # See ITU-T G.988
314 ECA(ByteField("ethernet_loopback_config", 0), {AA.R, AA.W},
315 range_check=lambda x: x in [0, 3]),
316 ECA(ByteField("administrative_state", 1), {AA.R, AA.W},
317 range_check=lambda x: 0 <= x <= 1),
318 ECA(ByteField("operational_state", 1), {AA.R, AA.W},
319 range_check=lambda x: 0 <= x <= 1, optional=True, avc=True),
320 ECA(ByteField("config_ind", 0), {AA.R},
321 range_check=lambda x: x in [0, 1, 2, 3, 4, 0x11, 0x12, 0x13]),
322 ECA(ByteField("max_frame_size", 1518), {AA.R, AA.W}, optional=True),
323 ECA(ByteField("dte_dce_ind", 0), {AA.R, AA.W},
324 range_check=lambda x: 0 <= x <= 2),
325 ECA(ShortField("pause_time", 0), {AA.R, AA.W}, optional=True),
Nathan Knuth61a039c2017-03-23 13:50:29 -0700326 ECA(ByteField("bridged_ip_ind", 2), {AA.R, AA.W}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600327 ECA(ByteField("arc", 0), {AA.R, AA.W}, optional=True,
328 range_check=lambda x: 0 <= x <= 1, avc=True),
329 ECA(ByteField("arc_interval", 0), {AA.R, AA.W}, optional=True),
330 ECA(ByteField("pppoe_filter", 0), {AA.R, AA.W}, optional=True),
331 ECA(ByteField("power_control", 0), {AA.R, AA.W}, optional=True),
Nathan Knuth61a039c2017-03-23 13:50:29 -0700332 ]
333 mandatory_operations = {OP.Get, OP.Set}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600334 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
335
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800336
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800337class MacBridgeServiceProfile(EntityClass):
338 class_id = 45
339 attributes = [
340 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600341 ECA(ByteField("spanning_tree_ind", None), {AA.R, AA.W, AA.SBC},
342 range_check=lambda x: 0 <= x <= 1),
343 ECA(ByteField("learning_ind", None), {AA.R, AA.W, AA.SBC},
344 range_check=lambda x: 0 <= x <= 1),
345 ECA(ByteField("port_bridging_ind", None), {AA.R, AA.W, AA.SBC},
346 range_check=lambda x: 0 <= x <= 1),
347 ECA(ShortField("priority", None), {AA.R, AA.W, AA.SBC}),
348 ECA(ShortField("max_age", None), {AA.R, AA.W, AA.SBC},
349 range_check=lambda x: 0x0600 <= x <= 0x2800),
350 ECA(ShortField("hello_time", None), {AA.R, AA.W, AA.SBC},
351 range_check=lambda x: 0x0100 <= x <= 0x0A00),
352 ECA(ShortField("forward_delay", None), {AA.R, AA.W, AA.SBC},
353 range_check=lambda x: 0x0400 <= x <= 0x1E00),
354 ECA(ByteField("unknown_mac_address_discard", None),
355 {AA.R, AA.W, AA.SBC}, range_check=lambda x: 0 <= x <= 1),
356 ECA(ByteField("mac_learning_depth", None),
357 {AA.R, AA.W, AA.SBC}, optional=True),
358 ECA(ByteField("dynamic_filtering_ageing_time", None),
359 {AA.R, AA.W, AA.SBC}, optional=True),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800360 ]
361 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
362
363
364class MacBridgePortConfigurationData(EntityClass):
365 class_id = 47
366 attributes = [
367 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
368 ECA(ShortField("bridge_id_pointer", None), {AA.R, AA.W, AA.SBC}),
369 ECA(ByteField("port_num", None), {AA.R, AA.W, AA.SBC}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600370 ECA(ByteField("tp_type", None), {AA.R, AA.W, AA.SBC},
371 range_check=lambda x: 1 <= x <= 12),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800372 ECA(ShortField("tp_pointer", None), {AA.R, AA.W, AA.SBC}),
373 ECA(ShortField("port_priority", None), {AA.R, AA.W, AA.SBC}),
374 ECA(ShortField("port_path_cost", None), {AA.R, AA.W, AA.SBC}),
375 ECA(ByteField("port_spanning_tree_in", None), {AA.R, AA.W, AA.SBC}),
376 ECA(ByteField("encapsulation_methods", None), {AA.R, AA.W, AA.SBC},
Chip Bolinge2e64a02018-02-06 12:58:07 -0600377 optional=True, deprecated=True),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800378 ECA(ByteField("lan_fcs_ind", None), {AA.R, AA.W, AA.SBC},
Chip Bolinge2e64a02018-02-06 12:58:07 -0600379 optional=True, deprecated=True),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800380 ECA(MACField("port_mac_address", None), {AA.R}, optional=True),
381 ECA(ShortField("outbound_td_pointer", None), {AA.R, AA.W},
382 optional=True),
383 ECA(ShortField("inbound_td_pointer", None), {AA.R, AA.W},
384 optional=True),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600385 # TODO:
386 ECA(ByteField("mac_learning_depth", 0), {AA.R, AA.W, AA.SBC},
387 optional=True),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800388 ]
389 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600390 notifications = {OP.AlarmNotification}
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800391
392
Chip Bolinge6c416f2018-05-01 15:07:51 -0500393class MacBridgePortFilterPreAssignTable(EntityClass):
394 class_id = 79
395 attributes = [
396 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
397 ECA(ShortField("ipv4_multicast", 0), {AA.R, AA.W},
398 range_check=lambda x: 0 <= x <= 1),
399 ECA(ShortField("ipv6_multicast", 0), {AA.R, AA.W},
400 range_check=lambda x: 0 <= x <= 1),
401 ECA(ShortField("ipv4_broadcast", 0), {AA.R, AA.W},
402 range_check=lambda x: 0 <= x <= 1),
403 ECA(ShortField("rarp", 0), {AA.R, AA.W},
404 range_check=lambda x: 0 <= x <= 1),
405 ECA(ShortField("ipx", 0), {AA.R, AA.W},
406 range_check=lambda x: 0 <= x <= 1),
407 ECA(ShortField("netbeui", 0), {AA.R, AA.W},
408 range_check=lambda x: 0 <= x <= 1),
409 ECA(ShortField("appletalk", 0), {AA.R, AA.W},
410 range_check=lambda x: 0 <= x <= 1),
411 ECA(ShortField("bridge_management_information", 0), {AA.R, AA.W},
412 range_check=lambda x: 0 <= x <= 1),
413 ECA(ShortField("arp", 0), {AA.R, AA.W},
414 range_check=lambda x: 0 <= x <= 1),
415 ECA(ShortField("pppoe_broadcast", 0), {AA.R, AA.W},
416 range_check=lambda x: 0 <= x <= 1)
417 ]
418 mandatory_operations = {OP.Get, OP.Set}
419 notifications = {OP.AlarmNotification}
420
421
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800422class VlanTaggingFilterData(EntityClass):
423 class_id = 84
424 attributes = [
425 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
426 ECA(ShortField("vlan_filter_0", None), {AA.R, AA.W, AA.SBC}),
427 ECA(ShortField("vlan_filter_1", None), {AA.R, AA.W, AA.SBC}),
428 ECA(ShortField("vlan_filter_2", None), {AA.R, AA.W, AA.SBC}),
429 ECA(ShortField("vlan_filter_3", None), {AA.R, AA.W, AA.SBC}),
430 ECA(ShortField("vlan_filter_4", None), {AA.R, AA.W, AA.SBC}),
431 ECA(ShortField("vlan_filter_5", None), {AA.R, AA.W, AA.SBC}),
432 ECA(ShortField("vlan_filter_6", None), {AA.R, AA.W, AA.SBC}),
433 ECA(ShortField("vlan_filter_7", None), {AA.R, AA.W, AA.SBC}),
434 ECA(ShortField("vlan_filter_8", None), {AA.R, AA.W, AA.SBC}),
435 ECA(ShortField("vlan_filter_9", None), {AA.R, AA.W, AA.SBC}),
436 ECA(ShortField("vlan_filter_10", None), {AA.R, AA.W, AA.SBC}),
437 ECA(ShortField("vlan_filter_11", None), {AA.R, AA.W, AA.SBC}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600438 ECA(ByteField("forward_operation", None), {AA.R, AA.W, AA.SBC},
439 range_check=lambda x: 0x00 <= x <= 0x21),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800440 ECA(ByteField("number_of_entries", None), {AA.R, AA.W, AA.SBC})
441 ]
442 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
443
444
445class Ieee8021pMapperServiceProfile(EntityClass):
446 class_id = 130
447 attributes = [
448 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600449 ECA(ShortField("tp_pointer", None), {AA.R, AA.W, AA.SBC}),
450 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_0",
451 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
452 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_1",
453 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
454 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_2",
455 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
456 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_3",
457 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
458 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_4",
459 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
460 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_5",
461 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
462 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_6",
463 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
464 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_7",
465 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800466 ECA(ByteField("unmarked_frame_option", None),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600467 {AA.R, AA.W, AA.SBC}, range_check=lambda x: 0 <= x <= 1),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800468 ECA(StrFixedLenField("dscp_to_p_bit_mapping", None, length=24),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600469 {AA.R, AA.W}), # TODO: Would a custom 3-bit group bitfield work better?
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800470 ECA(ByteField("default_p_bit_marking", None),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600471 {AA.R, AA.W, AA.SBC}),
472 ECA(ByteField("tp_type", None), {AA.R, AA.W, AA.SBC},
473 optional=True, range_check=lambda x: 0 <= x <= 8)
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800474 ]
475 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
476
477
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800478class OltG(EntityClass):
479 class_id = 131
480 attributes = [
Chip Bolinge2e64a02018-02-06 12:58:07 -0600481 ECA(ShortField("managed_entity_id", None), {AA.R},
482 range_check=lambda x: x == 0),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800483 ECA(StrFixedLenField("olt_vendor_id", None, 4), {AA.R, AA.W}),
484 ECA(StrFixedLenField("equipment_id", None, 20), {AA.R, AA.W}),
485 ECA(StrFixedLenField("version", None, 14), {AA.R, AA.W}),
486 ECA(StrFixedLenField("time_of_day", None, 14), {AA.R, AA.W})
487 ]
488 mandatory_operations = {OP.Get, OP.Set}
489
490
491class OntPowerShedding(EntityClass):
492 class_id = 133
493 attributes = [
Chip Bolinge2e64a02018-02-06 12:58:07 -0600494 ECA(ShortField("managed_entity_id", None), {AA.R},
495 range_check=lambda x: x == 0),
496 ECA(ShortField("restore_power_time_reset_interval", 0),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800497 {AA.R, AA.W}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600498 ECA(ShortField("data_class_shedding_interval", 0), {AA.R, AA.W}),
499 ECA(ShortField("voice_class_shedding_interval", 0), {AA.R, AA.W}),
500 ECA(ShortField("video_overlay_class_shedding_interval", 0), {AA.R, AA.W}),
501 ECA(ShortField("video_return_class_shedding_interval", 0), {AA.R, AA.W}),
502 ECA(ShortField("dsl_class_shedding_interval", 0), {AA.R, AA.W}),
503 ECA(ShortField("atm_class_shedding_interval", 0), {AA.R, AA.W}),
504 ECA(ShortField("ces_class_shedding_interval", 0), {AA.R, AA.W}),
505 ECA(ShortField("frame_class_shedding_interval", 0), {AA.R, AA.W}),
506 ECA(ShortField("sonet_class_shedding_interval", 0), {AA.R, AA.W}),
507 ECA(ShortField("shedding_status", None), {AA.R, AA.W}, optional=True,
508 avc=True),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800509 ]
510 mandatory_operations = {OP.Get, OP.Set}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600511 notifications = {OP.AttributeValueChange}
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800512
513
514class IpHostConfigData(EntityClass):
515 class_id = 134
516 attributes = [
517 ECA(ShortField("managed_entity_id", None), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600518 ECA(BitField("ip_options", 0, size=8), {AA.R, AA.W}),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800519 ECA(MACField("mac_address", None), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600520 ECA(StrFixedLenField("onu_identifier", None, 25), {AA.R, AA.W}),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800521 ECA(IPField("ip_address", None), {AA.R, AA.W}),
522 ECA(IPField("mask", None), {AA.R, AA.W}),
523 ECA(IPField("gateway", None), {AA.R, AA.W}),
524 ECA(IPField("primary_dns", None), {AA.R, AA.W}),
525 ECA(IPField("secondary_dns", None), {AA.R, AA.W}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600526 ECA(IPField("current_address", None), {AA.R}, avc=True),
527 ECA(IPField("current_mask", None), {AA.R}, avc=True),
528 ECA(IPField("current_gateway", None), {AA.R}, avc=True),
529 ECA(IPField("current_primary_dns", None), {AA.R}, avc=True),
530 ECA(IPField("current_secondary_dns", None), {AA.R}, avc=True),
531 ECA(StrFixedLenField("domain_name", None, 25), {AA.R}, avc=True),
532 ECA(StrFixedLenField("host_name", None, 25), {AA.R}, avc=True),
533 ECA(ShortField("relay_agent_options", None), {AA.R, AA.W},
534 optional=True),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800535 ]
536 mandatory_operations = {OP.Get, OP.Set, OP.Test}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600537 notifications = {OP.AttributeValueChange}
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800538
539
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800540class VlanTaggingOperation(Packet):
541 name = "VlanTaggingOperation"
542 fields_desc = [
543 BitField("filter_outer_priority", 0, 4),
544 BitField("filter_outer_vid", 0, 13),
545 BitField("filter_outer_tpid_de", 0, 3),
546 BitField("pad1", 0, 12),
547
548 BitField("filter_inner_priority", 0, 4),
549 BitField("filter_inner_vid", 0, 13),
550 BitField("filter_inner_tpid_de", 0, 3),
551 BitField("pad2", 0, 8),
552 BitField("filter_ether_type", 0, 4),
553
554 BitField("treatment_tags_to_remove", 0, 2),
555 BitField("pad3", 0, 10),
556 BitField("treatment_outer_priority", 0, 4),
557 BitField("treatment_outer_vid", 0, 13),
558 BitField("treatment_outer_tpid_de", 0, 3),
559
560 BitField("pad4", 0, 12),
561 BitField("treatment_inner_priority", 0, 4),
562 BitField("treatment_inner_vid", 0, 13),
563 BitField("treatment_inner_tpid_de", 0, 3),
564 ]
565
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500566 def to_json(self):
Chip Bolingbed4c6b2018-05-09 08:52:16 -0500567 return json.dumps(self.fields, separators=(',', ':'))
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500568
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800569
570class ExtendedVlanTaggingOperationConfigurationData(EntityClass):
571 class_id = 171
572 attributes = [
Chip Bolinge2e64a02018-02-06 12:58:07 -0600573 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
574 ECA(ByteField("association_type", None), {AA.R, AA.W, AA.SBC},
575 range_check=lambda x: 0 <= x <= 11),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800576 ECA(ShortField("received_vlan_tagging_operation_table_max_size", None),
577 {AA.R}),
578 ECA(ShortField("input_tpid", None), {AA.R, AA.W}),
579 ECA(ShortField("output_tpid", None), {AA.R, AA.W}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600580 ECA(ByteField("downstream_mode", None), {AA.R, AA.W},
581 range_check=lambda x: 0 <= x <= 8),
582 ECA(StrFixedLenField("received_frame_vlan_tagging_operation_table",
583 VlanTaggingOperation, 16), {AA.R, AA.W}),
584 ECA(ShortField("associated_me_pointer", None), {AA.R, AA.W, AA.SBC}),
585 ECA(StrFixedLenField("dscp_to_p_bit_mapping", None, length=24),
586 {AA.R, AA.W}), # TODO: Would a custom 3-bit group bitfield work better?
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800587 ]
588 mandatory_operations = {OP.Create, OP.Delete, OP.Set, OP.Get, OP.GetNext}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600589 optional_operations = {OP.SetTable}
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800590
591
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800592class OntG(EntityClass):
593 class_id = 256
594 attributes = [
Chip Bolinge2e64a02018-02-06 12:58:07 -0600595 ECA(ShortField("managed_entity_id", None), {AA.R},
596 range_check=lambda x: x == 0),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800597 ECA(StrFixedLenField("vendor_id", None, 4), {AA.R}),
598 ECA(StrFixedLenField("version", None, 14), {AA.R}),
599 ECA(StrFixedLenField("serial_number", None, 8), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600600 ECA(ByteField("traffic_management_options", None), {AA.R},
601 range_check=lambda x: 0 <= x <= 2),
602 ECA(ByteField("vp_vc_cross_connection_option", 0), {AA.R},
603 optional=True, deprecated=True),
604 ECA(ByteField("battery_backup", None), {AA.R, AA.W},
605 range_check=lambda x: 0 <= x <= 1),
606 ECA(ByteField("administrative_state", None), {AA.R, AA.W},
607 range_check=lambda x: 0 <= x <= 1),
608 ECA(ByteField("operational_state", None), {AA.R}, optional=True,
609 range_check=lambda x: 0 <= x <= 1, avc=True),
610 ECA(ByteField("ont_survival_time", None), {AA.R}, optional=True),
611 ECA(StrFixedLenField("logical_onu_id", None, 24), {AA.R},
612 optional=True, avc=True),
613 ECA(StrFixedLenField("logical_password", None, 12), {AA.R},
614 optional=True, avc=True),
615 ECA(ByteField("credentials_status", None), {AA.R, AA.W},
616 optional=True, range_check=lambda x: 0 <= x <= 4),
617 ECA(BitField("extended_tc_layer_options", None, size=16), {AA.R},
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800618 optional=True),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800619 ]
620 mandatory_operations = {
621 OP.Get, OP.Set, OP.Reboot, OP.Test, OP.SynchronizeTime}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600622 notifications = {OP.TestResult, OP.AttributeValueChange,
623 OP.AlarmNotification}
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800624
625
626class Ont2G(EntityClass):
627 class_id = 257
628 attributes = [
Chip Bolinge2e64a02018-02-06 12:58:07 -0600629 ECA(ShortField("managed_entity_id", None), {AA.R},
630 range_check=lambda x: x == 0),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800631 ECA(StrFixedLenField("equipment_id", None, 20), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600632 ECA(ByteField("omcc_version", None), {AA.R}, avc=True),
633 ECA(ShortField("vendor_product_code", None), {AA.R}),
634 ECA(ByteField("security_capability", None), {AA.R},
635 range_check=lambda x: 0 <= x <= 1),
636 ECA(ByteField("security_mode", None), {AA.R, AA.W},
637 range_check=lambda x: 0 <= x <= 1),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800638 ECA(ShortField("total_priority_queue_number", None), {AA.R}),
639 ECA(ByteField("total_traffic_scheduler_number", None), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600640 ECA(ByteField("mode", None), {AA.R}, deprecated=True),
641 ECA(ShortField("total_gem_port_id_number", None), {AA.R}),
642 ECA(IntField("sys_uptime", None), {AA.R}),
643 ECA(BitField("connectivity_capability", None, size=16), {AA.R}),
644 ECA(ByteField("current_connectivity_mode", None), {AA.R, AA.W},
645 range_check=lambda x: 0 <= x <= 7),
646 ECA(BitField("qos_configuration_flexibility", None, size=16),
647 {AA.R}, optional=True),
648 ECA(ShortField("priority_queue_scale_factor", None), {AA.R, AA.W},
649 optional=True),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800650 ]
651 mandatory_operations = {OP.Get, OP.Set}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600652 notifications = {OP.AttributeValueChange}
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800653
654
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800655class Tcont(EntityClass):
656 class_id = 262
657 attributes = [
658 ECA(ShortField("managed_entity_id", None), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600659 ECA(ShortField("alloc_id", None), {AA.R, AA.W}),
660 ECA(ByteField("mode_indicator", 1), {AA.R}, deprecated=True),
661 ECA(ByteField("policy", None), {AA.R, AA.W},
662 range_check=lambda x: 0 <= x <= 2),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800663 ]
664 mandatory_operations = {OP.Get, OP.Set}
665
666
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800667class AniG(EntityClass):
668 class_id = 263
669 attributes = [
670 ECA(ShortField("managed_entity_id", None), {AA.R}),
671 ECA(ByteField("sr_indication", None), {AA.R}),
672 ECA(ShortField("total_tcont_number", None), {AA.R}),
673 ECA(ShortField("gem_block_length", None), {AA.R, AA.W}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600674 ECA(ByteField("piggyback_dba_reporting", None), {AA.R},
675 range_check=lambda x: 0 <= x <= 4),
676 ECA(ByteField("whole_ont_dba_reporting", None), {AA.R},
677 deprecated=True),
678 ECA(ByteField("sf_threshold", 5), {AA.R, AA.W}),
679 ECA(ByteField("sd_threshold", 9), {AA.R, AA.W}),
680 ECA(ByteField("arc", 0), {AA.R, AA.W},
681 range_check=lambda x: 0 <= x <= 1, avc=True),
682 ECA(ByteField("arc_interval", 0), {AA.R, AA.W}),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800683 ECA(ShortField("optical_signal_level", None), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600684 ECA(ByteField("lower_optical_threshold", 0xFF), {AA.R, AA.W}),
685 ECA(ByteField("upper_optical_threshold", 0xFF), {AA.R, AA.W}),
686 ECA(ByteField("ont_response_time", None), {AA.R}),
687 ECA(ShortField("transmit_optical_level", None), {AA.R}),
688 ECA(ByteField("lower_transmit_power_threshold", 0x81), {AA.R, AA.W}),
689 ECA(ByteField("upper_transmit_power_threshold", 0x81), {AA.R, AA.W}),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800690 ]
691 mandatory_operations = {OP.Get, OP.Set, OP.Test}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600692 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800693
694
695class UniG(EntityClass):
696 class_id = 264
697 attributes = [
698 ECA(ShortField("managed_entity_id", None), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600699 ECA(ShortField("configuration_option_status", None), {AA.R, AA.W},
700 deprecated=True),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800701 ECA(ByteField("administrative_state", None), {AA.R, AA.W}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600702 ECA(ByteField("management_capability", None), {AA.R},
703 range_check=lambda x: 0 <= x <= 2),
704 ECA(ShortField("non_omci_management_identifier", None), {AA.R, AA.W}),
705 ECA(ShortField("relay_agent_options", None), {AA.R, AA.W},
706 optional=True),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800707 ]
708 mandatory_operations = {OP.Get, OP.Set}
709
710
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800711class GemInterworkingTp(EntityClass):
712 class_id = 266
713 attributes = [
Chip Bolinge2e64a02018-02-06 12:58:07 -0600714 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800715 ECA(ShortField("gem_port_network_ctp_pointer", None),
716 {AA.R, AA.W, AA.SBC}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600717 ECA(ByteField("interworking_option", None), {AA.R, AA.W, AA.SBC},
718 range_check=lambda x: 0 <= x <= 7),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800719 ECA(ShortField("service_profile_pointer", None), {AA.R, AA.W, AA.SBC}),
720 ECA(ShortField("interworking_tp_pointer", None), {AA.R, AA.W, AA.SBC}),
721 ECA(ByteField("pptp_counter", None), {AA.R}, optional=True),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600722 ECA(ByteField("operational_state", None), {AA.R}, optional=True,
723 range_check=lambda x: 0 <= x <= 1, avc=True),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800724 ECA(ShortField("gal_profile_pointer", None), {AA.R, AA.W, AA.SBC}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600725 ECA(ByteField("gal_loopback_configuration", 0),
726 {AA.R, AA.W}, range_check=lambda x: 0 <= x <= 1),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800727 ]
Chip Bolingeada0c92017-12-27 09:45:26 -0600728 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600729 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800730
731
732class GemPortNetworkCtp(EntityClass):
733 class_id = 268
734 attributes = [
735 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
736 ECA(ShortField("port_id", None), {AA.R, AA.W, AA.SBC}),
737 ECA(ShortField("tcont_pointer", None), {AA.R, AA.W, AA.SBC}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600738 ECA(ByteField("direction", None), {AA.R, AA.W, AA.SBC},
739 range_check=lambda x: 1 <= x <= 3),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800740 ECA(ShortField("traffic_management_pointer_upstream", None),
741 {AA.R, AA.W, AA.SBC}),
742 ECA(ShortField("traffic_descriptor_profile_pointer", None),
743 {AA.R, AA.W, AA.SBC}, optional=True),
744 ECA(ByteField("uni_counter", None), {AA.R}, optional=True),
745 ECA(ShortField("priority_queue_pointer_downstream", None),
746 {AA.R, AA.W, AA.SBC}),
Nathan Knuth61a039c2017-03-23 13:50:29 -0700747 ECA(ByteField("encryption_state", None), {AA.R}, optional=True),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600748 ECA(ShortField("traffic_desc_profile_pointer_downstream", None),
749 {AA.R, AA.W, AA.SBC}, optional=True),
750 ECA(ShortField("encryption_key_ring", None), {AA.R, AA.W, AA.SBC},
751 range_check=lambda x: 0 <= x <= 3)
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800752 ]
753 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600754 notifications = {OP.AlarmNotification}
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800755
756
757class GalEthernetProfile(EntityClass):
758 class_id = 272
759 attributes = [
760 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
761 ECA(ShortField("max_gem_payload_size", None), {AA.R, AA.W, AA.SBC}),
762 ]
763 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
764
765
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800766class PriorityQueueG(EntityClass):
767 class_id = 277
768 attributes = [
769 ECA(ShortField("managed_entity_id", None), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600770 ECA(ByteField("queue_configuration_option", None), {AA.R},
771 range_check=lambda x: 0 <= x <= 1),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800772 ECA(ShortField("maximum_queue_size", None), {AA.R}),
773 ECA(ShortField("allocated_queue_size", None), {AA.R, AA.W}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600774 ECA(ShortField("discard_block_counter_reset_interval", None), {AA.R, AA.W}),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800775 ECA(ShortField("threshold_value_for_discarded_blocks", None), {AA.R, AA.W}),
776 ECA(IntField("related_port", None), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600777 ECA(ShortField("traffic_scheduler_pointer", 0), {AA.R, AA.W}),
778 ECA(ByteField("weight", 1), {AA.R, AA.W}),
779 ECA(ShortField("back_pressure_operation", 0), {AA.R, AA.W},
780 range_check=lambda x: 0 <= x <= 1),
781 ECA(IntField("back_pressure_time", 0), {AA.R, AA.W}),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800782 ECA(ShortField("back_pressure_occur_queue_threshold", None), {AA.R, AA.W}),
783 ECA(ShortField("back_pressure_clear_queue_threshold", None), {AA.R, AA.W}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600784 # TODO: Custom field of 4 2-byte values would help below
785 ECA(LongField("packet_drop_queue_thresholds", None), {AA.R, AA.W},
786 optional=True),
787 ECA(ShortField("packet_drop_max_p", 0xFFFF), {AA.R, AA.W}, optional=True),
788 ECA(ByteField("queue_drop_w_q", 9), {AA.R, AA.W}, optional=True),
789 ECA(ByteField("drop_precedence_colour_marking", 0), {AA.R, AA.W},
790 optional=True, range_check=lambda x: 0 <= x <= 7),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800791 ]
792 mandatory_operations = {OP.Get, OP.Set}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600793 notifications = {OP.AlarmNotification}
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800794
795
796class TrafficSchedulerG(EntityClass):
797 class_id = 278
798 attributes = [
799 ECA(ShortField("managed_entity_id", None), {AA.R}),
800 ECA(ShortField("tcont_pointer", None), {AA.R}),
801 ECA(ShortField("traffic_scheduler_pointer", None), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600802 ECA(ByteField("policy", None), {AA.R, AA.W},
803 range_check=lambda x: 0 <= x <= 2),
804 ECA(ByteField("priority_weight", 0), {AA.R, AA.W}),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800805 ]
806 mandatory_operations = {OP.Get, OP.Set}
807
808
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800809class MulticastGemInterworkingTp(EntityClass):
810 class_id = 281
811 attributes = [
Chip Bolinge2e64a02018-02-06 12:58:07 -0600812 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC},
813 range_check=lambda x: x != OmciNullPointer),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800814 ECA(ShortField("gem_port_network_ctp_pointer", None), {AA.R, AA.SBC}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600815 ECA(ByteField("interworking_option", None), {AA.R, AA.W, AA.SBC},
816 range_check=lambda x: x in [0, 1, 3, 5]),
817 ECA(ShortField("service_profile_pointer", None), {AA.R, AA.W, AA.SBC}),
818 ECA(ShortField("interworking_tp_pointer", 0), {AA.R, AA.W, AA.SBC},
819 deprecated=True),
820 ECA(ByteField("pptp_counter", None), {AA.R}),
821 ECA(ByteField("operational_state", None), {AA.R}, avc=True,
822 range_check=lambda x: 0 <= x <= 1),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800823 ECA(ShortField("gal_profile_pointer", None), {AA.R, AA.W, AA.SBC}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600824 ECA(ByteField("gal_loopback_configuration", None), {AA.R, AA.W, AA.SBC},
825 deprecated=True),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800826 # TODO add multicast_address_table here (page 85 of spec.)
827 # ECA(...("multicast_address_table", None), {AA.R, AA.W})
828 ]
829 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.GetNext, OP.Set}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600830 optional_operations = {OP.SetTable}
831 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800832
833
Steve Crooks9e85ce82017-03-20 12:00:53 -0400834class AccessControlRow0(Packet):
835 name = "AccessControlRow0"
836 fields_desc = [
837 BitField("set_ctrl", 0, 2),
838 BitField("row_part_id", 0, 3),
839 BitField("test", 0, 1),
840 BitField("row_key", 0, 10),
841
842 ShortField("gem_port_id", None),
843 ShortField("vlan_id", None),
844 IPField("src_ip", None),
845 IPField("dst_ip_start", None),
846 IPField("dst_ip_end", None),
847 IntField("ipm_group_bw", None),
848 ShortField("reserved0", 0)
849 ]
850
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500851 def to_json(self):
Chip Bolingbed4c6b2018-05-09 08:52:16 -0500852 return json.dumps(self.fields, separators=(',', ':'))
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500853
Chip Bolinge2e64a02018-02-06 12:58:07 -0600854
Steve Crooks9e85ce82017-03-20 12:00:53 -0400855class AccessControlRow1(Packet):
856 name = "AccessControlRow1"
857 fields_desc = [
858 BitField("set_ctrl", 0, 2),
859 BitField("row_part_id", 0, 3),
860 BitField("test", 0, 1),
861 BitField("row_key", 0, 10),
862
863 StrFixedLenField("ipv6_src_addr_start_bytes", None, 12),
864 ShortField("preview_length", None),
865 ShortField("preview_repeat_time", None),
866 ShortField("preview_repeat_count", None),
867 ShortField("preview_reset_time", None),
868 ShortField("reserved1", 0)
869 ]
870
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500871 def to_json(self):
Chip Bolingbed4c6b2018-05-09 08:52:16 -0500872 return json.dumps(self.fields, separators=(',', ':'))
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500873
Chip Bolinge2e64a02018-02-06 12:58:07 -0600874
Steve Crooks9e85ce82017-03-20 12:00:53 -0400875class AccessControlRow2(Packet):
876 name = "AccessControlRow2"
877 fields_desc = [
878 BitField("set_ctrl", 0, 2),
879 BitField("row_part_id", 0, 3),
880 BitField("test", 0, 1),
881 BitField("row_key", 0, 10),
882
883 StrFixedLenField("ipv6_dst_addr_start_bytes", None, 12),
884 StrFixedLenField("reserved2", None, 10)
885 ]
886
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500887 def to_json(self):
Chip Bolingbed4c6b2018-05-09 08:52:16 -0500888 return json.dumps(self.fields, separators=(',', ':'))
Chip Bolinge2e64a02018-02-06 12:58:07 -0600889
Chip Boling9b7a11a2018-04-15 13:33:21 -0500890
Steve Crooks9e85ce82017-03-20 12:00:53 -0400891class DownstreamIgmpMulticastTci(Packet):
892 name = "DownstreamIgmpMulticastTci"
893 fields_desc = [
894 ByteField("ctrl_type", None),
895 ShortField("tci", None)
896 ]
897
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500898 def to_json(self):
Chip Bolingbed4c6b2018-05-09 08:52:16 -0500899 return json.dumps(self.fields, separators=(',', ':'))
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500900
Chip Bolinge2e64a02018-02-06 12:58:07 -0600901
Steve Crooks89b94b72017-02-01 10:06:30 -0500902class MulticastOperationsProfile(EntityClass):
903 class_id = 309
904 attributes = [
Chip Bolinge2e64a02018-02-06 12:58:07 -0600905 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC},
906 range_check=lambda x: x != 0 and x != OmciNullPointer),
907 ECA(ByteField("igmp_version", None), {AA.R, AA.W, AA.SBC},
908 range_check=lambda x: x in [1, 2, 3, 16, 17]),
909 ECA(ByteField("igmp_function", None), {AA.R, AA.W, AA.SBC},
910 range_check=lambda x: 0 <= x <= 2),
911 ECA(ByteField("immediate_leave", None), {AA.R, AA.W, AA.SBC},
912 range_check=lambda x: 0 <= x <= 1),
Steve Crooks89b94b72017-02-01 10:06:30 -0500913 ECA(ShortField("us_igmp_tci", None), {AA.R, AA.W, AA.SBC}, optional=True),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600914 ECA(ByteField("us_igmp_tag_ctrl", None), {AA.R, AA.W, AA.SBC},
915 range_check=lambda x: 0 <= x <= 3, optional=True),
Steve Crooks89b94b72017-02-01 10:06:30 -0500916 ECA(IntField("us_igmp_rate", None), {AA.R, AA.W, AA.SBC}, optional=True),
917 # TODO: need to make table and add column data
918 ECA(StrFixedLenField(
919 "dynamic_access_control_list_table", None, 24), {AA.R, AA.W}),
920 # TODO: need to make table and add column data
921 ECA(StrFixedLenField(
922 "static_access_control_list_table", None, 24), {AA.R, AA.W}),
923 # TODO: need to make table and add column data
Chip Bolinge2e64a02018-02-06 12:58:07 -0600924 ECA(StrFixedLenField("lost_groups_list_table", None, 10), {AA.R}),
925 ECA(ByteField("robustness", None), {AA.R, AA.W, AA.SBC}),
926 ECA(IntField("querier_ip", None), {AA.R, AA.W, AA.SBC}),
927 ECA(IntField("query_interval", None), {AA.R, AA.W, AA.SBC}),
928 ECA(IntField("querier_max_response_time", None), {AA.R, AA.W, AA.SBC}),
929 ECA(IntField("last_member_response_time", 10), {AA.R, AA.W}),
930 ECA(ByteField("unauthorized_join_behaviour", None), {AA.R, AA.W}),
Steve Crooks9e85ce82017-03-20 12:00:53 -0400931 ECA(StrFixedLenField("ds_igmp_mcast_tci", None, 3), {AA.R, AA.W, AA.SBC}, optional=True)
Steve Crooks89b94b72017-02-01 10:06:30 -0500932 ]
933 mandatory_operations = {OP.Create, OP.Delete, OP.Set, OP.Get, OP.GetNext}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600934 optional_operations = {OP.SetTable}
935 notifications = {OP.AlarmNotification}
936
Steve Crooks89b94b72017-02-01 10:06:30 -0500937
Steve Crooks9e85ce82017-03-20 12:00:53 -0400938class MulticastServicePackage(Packet):
939 name = "MulticastServicePackage"
940 fields_desc = [
941 BitField("set_ctrl", 0, 2),
942 BitField("reserved0", 0, 4),
943 BitField("row_key", 0, 10),
944
945 ShortField("vid_uni", None),
946 ShortField("max_simultaneous_groups", None),
947 IntField("max_multicast_bw", None),
948 ShortField("mcast_operations_profile_pointer", None),
949 StrFixedLenField("reserved1", None, 8)
950 ]
951
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500952 def to_json(self):
Chip Bolingbed4c6b2018-05-09 08:52:16 -0500953 return json.dumps(self.fields, separators=(',', ':'))
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500954
Chip Bolinge2e64a02018-02-06 12:58:07 -0600955
Steve Crooks9e85ce82017-03-20 12:00:53 -0400956class AllowedPreviewGroupsRow0(Packet):
957 name = "AllowedPreviewGroupsRow0"
958 fields_desc = [
959 BitField("set_ctrl", 0, 2),
960 BitField("row_part_id", 0, 3),
961 BitField("reserved0", 0, 1),
962 BitField("row_key", 0, 10),
963
964 StrFixedLenField("ipv6_pad", 0, 12),
965 IPField("src_ip", None),
966 ShortField("vlan_id_ani", None),
967 ShortField("vlan_id_uni", None)
968 ]
969
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500970 def to_json(self):
Chip Bolingbed4c6b2018-05-09 08:52:16 -0500971 return json.dumps(self.fields, separators=(',', ':'))
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500972
Chip Bolinge2e64a02018-02-06 12:58:07 -0600973
Steve Crooks9e85ce82017-03-20 12:00:53 -0400974class AllowedPreviewGroupsRow1(Packet):
975 name = "AllowedPreviewGroupsRow1"
976 fields_desc = [
977 BitField("set_ctrl", 0, 2),
978 BitField("row_part_id", 0, 3),
979 BitField("reserved0", 0, 1),
980 BitField("row_key", 0, 10),
981
982 StrFixedLenField("ipv6_pad", 0, 12),
983 IPField("dst_ip", None),
984 ShortField("duration", None),
985 ShortField("time_left", None)
986 ]
Steve Crooks89b94b72017-02-01 10:06:30 -0500987
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500988 def to_json(self):
Chip Bolingbed4c6b2018-05-09 08:52:16 -0500989 return json.dumps(self.fields, separators=(',', ':'))
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500990
Chip Bolinge2e64a02018-02-06 12:58:07 -0600991
Steve Crooks89b94b72017-02-01 10:06:30 -0500992class MulticastSubscriberConfigInfo(EntityClass):
993 class_id = 310
994 attributes = [
995 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600996 ECA(ByteField("me_type", None), {AA.R, AA.W, AA.SBC},
997 range_check=lambda x: 0 <= x <= 1),
998 ECA(ShortField("mcast_operations_profile_pointer", None),
999 {AA.R, AA.W, AA.SBC}),
1000 ECA(ShortField("max_simultaneous_groups", None), {AA.R, AA.W, AA.SBC}),
1001 ECA(IntField("max_multicast_bandwidth", None), {AA.R, AA.W, AA.SBC}),
1002 ECA(ByteField("bandwidth_enforcement", None), {AA.R, AA.W, AA.SBC},
1003 range_check=lambda x: 0 <= x <= 1),
Steve Crooks89b94b72017-02-01 10:06:30 -05001004 # TODO: need to make table and add column data
1005 ECA(StrFixedLenField(
Chip Bolinge2e64a02018-02-06 12:58:07 -06001006 "multicast_service_package_table", None, 20), {AA.R, AA.W}),
Steve Crooks89b94b72017-02-01 10:06:30 -05001007 # TODO: need to make table and add column data
1008 ECA(StrFixedLenField(
Chip Bolinge2e64a02018-02-06 12:58:07 -06001009 "allowed_preview_groups_table", None, 22), {AA.R, AA.W}),
Steve Crooks89b94b72017-02-01 10:06:30 -05001010 ]
Chip Bolinge2e64a02018-02-06 12:58:07 -06001011 mandatory_operations = {OP.Create, OP.Delete, OP.Set, OP.Get, OP.GetNext,
1012 OP.SetTable}
Steve Crooks89b94b72017-02-01 10:06:30 -05001013
1014
1015class VirtualEthernetInterfacePt(EntityClass):
Zsolt Haraszti578a46c2016-12-20 16:38:43 -08001016 class_id = 329
1017 attributes = [
Chip Bolinge2e64a02018-02-06 12:58:07 -06001018 ECA(ShortField("managed_entity_id", None), {AA.R},
1019 range_check=lambda x: x != 0 and x != OmciNullPointer),
1020 ECA(ByteField("administrative_state", None), {AA.R, AA.W},
1021 range_check=lambda x: 0 <= x <= 1),
1022 ECA(ByteField("operational_state", None), {AA.R}, avc=True,
1023 range_check=lambda x: 0 <= x <= 1),
Steve Crooks89b94b72017-02-01 10:06:30 -05001024 ECA(StrFixedLenField(
1025 "interdomain_name", None, 25), {AA.R, AA.W}, optional=True),
1026 ECA(ShortField("tcp_udp_pointer", None), {AA.R, AA.W}, optional=True),
1027 ECA(ShortField("iana_assigned_port", None), {AA.R}),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -08001028 ]
Steve Crooks89b94b72017-02-01 10:06:30 -05001029 mandatory_operations = {OP.Get, OP.Set}
Chip Bolinge2e64a02018-02-06 12:58:07 -06001030 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
Zsolt Haraszti578a46c2016-12-20 16:38:43 -08001031
1032
Chip Bolingf0b3a062018-01-18 13:53:58 -06001033class EnhSecurityControl(EntityClass):
Zsolt Haraszti578a46c2016-12-20 16:38:43 -08001034 class_id = 332
1035 attributes = [
Steve Crooks89b94b72017-02-01 10:06:30 -05001036 ECA(ShortField("managed_entity_id", None), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -06001037 ECA(BitField("olt_crypto_capabilities", None, 16*8), {AA.W}),
Steve Crooks89b94b72017-02-01 10:06:30 -05001038 # TODO: need to make table and add column data
1039 ECA(StrFixedLenField(
1040 "olt_random_challenge_table", None, 17), {AA.R, AA.W}),
Chip Bolinge2e64a02018-02-06 12:58:07 -06001041 ECA(ByteField("olt_challenge_status", 0), {AA.R, AA.W},
1042 range_check=lambda x: 0 <= x <= 1),
Steve Crooks89b94b72017-02-01 10:06:30 -05001043 ECA(ByteField("onu_selected_crypto_capabilities", None), {AA.R}),
1044 # TODO: need to make table and add column data
1045 ECA(StrFixedLenField(
Chip Bolinge2e64a02018-02-06 12:58:07 -06001046 "onu_random_challenge_table", None, 16), {AA.R}, avc=True),
Steve Crooks89b94b72017-02-01 10:06:30 -05001047 # TODO: need to make table and add column data
1048 ECA(StrFixedLenField(
Chip Bolinge2e64a02018-02-06 12:58:07 -06001049 "onu_authentication_result_table", None, 16), {AA.R}, avc=True),
Steve Crooks89b94b72017-02-01 10:06:30 -05001050 # TODO: need to make table and add column data
1051 ECA(StrFixedLenField(
1052 "olt_authentication_result_table", None, 17), {AA.W}),
Chip Bolinge2e64a02018-02-06 12:58:07 -06001053 ECA(ByteField("olt_result_status", None), {AA.R, AA.W},
1054 range_check=lambda x: 0 <= x <= 1),
1055 ECA(ByteField("onu_authentication_status", None), {AA.R}, avc=True,
1056 range_check=lambda x: 0 <= x <= 5),
Steve Crooks89b94b72017-02-01 10:06:30 -05001057 ECA(StrFixedLenField(
1058 "master_session_key_name", None, 16), {AA.R}),
1059 ECA(StrFixedLenField(
Chip Bolinge2e64a02018-02-06 12:58:07 -06001060 "broadcast_key_table", None, 18), {AA.R, AA.W}),
1061 ECA(ShortField("effective_key_length", None), {AA.R}),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -08001062
1063 ]
Steve Crooks89b94b72017-02-01 10:06:30 -05001064 mandatory_operations = {OP.Set, OP.Get, OP.GetNext}
Chip Bolinge2e64a02018-02-06 12:58:07 -06001065 notifications = {OP.AttributeValueChange}
Zsolt Haraszti578a46c2016-12-20 16:38:43 -08001066
1067
1068class Unknown347(EntityClass):
1069 class_id = 347
1070 attributes = [
1071
1072 ]
1073
1074
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -08001075# entity class lookup table from entity_class values
1076entity_classes_name_map = dict(
1077 inspect.getmembers(sys.modules[__name__],
1078 lambda o: inspect.isclass(o) and \
1079 issubclass(o, EntityClass) and \
1080 o is not EntityClass)
1081)
1082
1083entity_classes = [c for c in entity_classes_name_map.itervalues()]
1084entity_id_to_class_map = dict((c.class_id, c) for c in entity_classes)