blob: 665e21c96f7dd5ef0a861c2c712399c66b3af0e5 [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 Boling4c06db92018-05-24 15:02:26 -050022from scapy.fields import IntField, StrFixedLenField, LongField, FieldListField
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]),
Chip Bolingf60a5322018-05-15 09:03:02 -0500322 ECA(ShortField("max_frame_size", 1518), {AA.R, AA.W}, optional=True),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600323 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),
Chip Bolingf60a5322018-05-15 09:03:02 -0500326 ECA(ByteField("bridged_ip_ind", 2), {AA.R, AA.W},
327 optional=True, range_check=lambda x: 0 <= x <= 2),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600328 ECA(ByteField("arc", 0), {AA.R, AA.W}, optional=True,
329 range_check=lambda x: 0 <= x <= 1, avc=True),
330 ECA(ByteField("arc_interval", 0), {AA.R, AA.W}, optional=True),
331 ECA(ByteField("pppoe_filter", 0), {AA.R, AA.W}, optional=True),
332 ECA(ByteField("power_control", 0), {AA.R, AA.W}, optional=True),
Nathan Knuth61a039c2017-03-23 13:50:29 -0700333 ]
334 mandatory_operations = {OP.Get, OP.Set}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600335 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
336
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800337
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800338class MacBridgeServiceProfile(EntityClass):
339 class_id = 45
340 attributes = [
341 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600342 ECA(ByteField("spanning_tree_ind", None), {AA.R, AA.W, AA.SBC},
343 range_check=lambda x: 0 <= x <= 1),
344 ECA(ByteField("learning_ind", None), {AA.R, AA.W, AA.SBC},
345 range_check=lambda x: 0 <= x <= 1),
346 ECA(ByteField("port_bridging_ind", None), {AA.R, AA.W, AA.SBC},
347 range_check=lambda x: 0 <= x <= 1),
348 ECA(ShortField("priority", None), {AA.R, AA.W, AA.SBC}),
349 ECA(ShortField("max_age", None), {AA.R, AA.W, AA.SBC},
350 range_check=lambda x: 0x0600 <= x <= 0x2800),
351 ECA(ShortField("hello_time", None), {AA.R, AA.W, AA.SBC},
352 range_check=lambda x: 0x0100 <= x <= 0x0A00),
353 ECA(ShortField("forward_delay", None), {AA.R, AA.W, AA.SBC},
354 range_check=lambda x: 0x0400 <= x <= 0x1E00),
355 ECA(ByteField("unknown_mac_address_discard", None),
356 {AA.R, AA.W, AA.SBC}, range_check=lambda x: 0 <= x <= 1),
357 ECA(ByteField("mac_learning_depth", None),
358 {AA.R, AA.W, AA.SBC}, optional=True),
359 ECA(ByteField("dynamic_filtering_ageing_time", None),
360 {AA.R, AA.W, AA.SBC}, optional=True),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800361 ]
362 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
363
364
365class MacBridgePortConfigurationData(EntityClass):
366 class_id = 47
367 attributes = [
368 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
369 ECA(ShortField("bridge_id_pointer", None), {AA.R, AA.W, AA.SBC}),
370 ECA(ByteField("port_num", None), {AA.R, AA.W, AA.SBC}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600371 ECA(ByteField("tp_type", None), {AA.R, AA.W, AA.SBC},
372 range_check=lambda x: 1 <= x <= 12),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800373 ECA(ShortField("tp_pointer", None), {AA.R, AA.W, AA.SBC}),
374 ECA(ShortField("port_priority", None), {AA.R, AA.W, AA.SBC}),
375 ECA(ShortField("port_path_cost", None), {AA.R, AA.W, AA.SBC}),
376 ECA(ByteField("port_spanning_tree_in", None), {AA.R, AA.W, AA.SBC}),
377 ECA(ByteField("encapsulation_methods", None), {AA.R, AA.W, AA.SBC},
Chip Bolinge2e64a02018-02-06 12:58:07 -0600378 optional=True, deprecated=True),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800379 ECA(ByteField("lan_fcs_ind", None), {AA.R, AA.W, AA.SBC},
Chip Bolinge2e64a02018-02-06 12:58:07 -0600380 optional=True, deprecated=True),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800381 ECA(MACField("port_mac_address", None), {AA.R}, optional=True),
382 ECA(ShortField("outbound_td_pointer", None), {AA.R, AA.W},
383 optional=True),
384 ECA(ShortField("inbound_td_pointer", None), {AA.R, AA.W},
385 optional=True),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600386 # TODO:
387 ECA(ByteField("mac_learning_depth", 0), {AA.R, AA.W, AA.SBC},
388 optional=True),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800389 ]
390 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600391 notifications = {OP.AlarmNotification}
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800392
393
Chip Bolinge6c416f2018-05-01 15:07:51 -0500394class MacBridgePortFilterPreAssignTable(EntityClass):
395 class_id = 79
396 attributes = [
397 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
398 ECA(ShortField("ipv4_multicast", 0), {AA.R, AA.W},
399 range_check=lambda x: 0 <= x <= 1),
400 ECA(ShortField("ipv6_multicast", 0), {AA.R, AA.W},
401 range_check=lambda x: 0 <= x <= 1),
402 ECA(ShortField("ipv4_broadcast", 0), {AA.R, AA.W},
403 range_check=lambda x: 0 <= x <= 1),
404 ECA(ShortField("rarp", 0), {AA.R, AA.W},
405 range_check=lambda x: 0 <= x <= 1),
406 ECA(ShortField("ipx", 0), {AA.R, AA.W},
407 range_check=lambda x: 0 <= x <= 1),
408 ECA(ShortField("netbeui", 0), {AA.R, AA.W},
409 range_check=lambda x: 0 <= x <= 1),
410 ECA(ShortField("appletalk", 0), {AA.R, AA.W},
411 range_check=lambda x: 0 <= x <= 1),
412 ECA(ShortField("bridge_management_information", 0), {AA.R, AA.W},
413 range_check=lambda x: 0 <= x <= 1),
414 ECA(ShortField("arp", 0), {AA.R, AA.W},
415 range_check=lambda x: 0 <= x <= 1),
416 ECA(ShortField("pppoe_broadcast", 0), {AA.R, AA.W},
417 range_check=lambda x: 0 <= x <= 1)
418 ]
419 mandatory_operations = {OP.Get, OP.Set}
420 notifications = {OP.AlarmNotification}
421
422
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800423class VlanTaggingFilterData(EntityClass):
424 class_id = 84
425 attributes = [
426 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
Chip Boling4c06db92018-05-24 15:02:26 -0500427 ECA(FieldListField("vlan_filter_list", None,
428 ShortField('', 0), count_from=lambda _: 12),
429 {AA.R, AA.W, AA.SBC}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600430 ECA(ByteField("forward_operation", None), {AA.R, AA.W, AA.SBC},
431 range_check=lambda x: 0x00 <= x <= 0x21),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800432 ECA(ByteField("number_of_entries", None), {AA.R, AA.W, AA.SBC})
433 ]
434 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
435
436
437class Ieee8021pMapperServiceProfile(EntityClass):
438 class_id = 130
439 attributes = [
440 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600441 ECA(ShortField("tp_pointer", None), {AA.R, AA.W, AA.SBC}),
442 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_0",
443 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
444 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_1",
445 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
446 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_2",
447 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
448 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_3",
449 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
450 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_4",
451 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
452 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_5",
453 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
454 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_6",
455 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
456 ECA(ShortField("interwork_tp_pointer_for_p_bit_priority_7",
457 OmciNullPointer), {AA.R, AA.W, AA.SBC}),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800458 ECA(ByteField("unmarked_frame_option", None),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600459 {AA.R, AA.W, AA.SBC}, range_check=lambda x: 0 <= x <= 1),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800460 ECA(StrFixedLenField("dscp_to_p_bit_mapping", None, length=24),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600461 {AA.R, AA.W}), # TODO: Would a custom 3-bit group bitfield work better?
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800462 ECA(ByteField("default_p_bit_marking", None),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600463 {AA.R, AA.W, AA.SBC}),
464 ECA(ByteField("tp_type", None), {AA.R, AA.W, AA.SBC},
465 optional=True, range_check=lambda x: 0 <= x <= 8)
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800466 ]
467 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
468
469
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800470class OltG(EntityClass):
471 class_id = 131
472 attributes = [
Chip Bolinge2e64a02018-02-06 12:58:07 -0600473 ECA(ShortField("managed_entity_id", None), {AA.R},
474 range_check=lambda x: x == 0),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800475 ECA(StrFixedLenField("olt_vendor_id", None, 4), {AA.R, AA.W}),
476 ECA(StrFixedLenField("equipment_id", None, 20), {AA.R, AA.W}),
477 ECA(StrFixedLenField("version", None, 14), {AA.R, AA.W}),
478 ECA(StrFixedLenField("time_of_day", None, 14), {AA.R, AA.W})
479 ]
480 mandatory_operations = {OP.Get, OP.Set}
481
482
483class OntPowerShedding(EntityClass):
484 class_id = 133
485 attributes = [
Chip Bolinge2e64a02018-02-06 12:58:07 -0600486 ECA(ShortField("managed_entity_id", None), {AA.R},
487 range_check=lambda x: x == 0),
488 ECA(ShortField("restore_power_time_reset_interval", 0),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800489 {AA.R, AA.W}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600490 ECA(ShortField("data_class_shedding_interval", 0), {AA.R, AA.W}),
491 ECA(ShortField("voice_class_shedding_interval", 0), {AA.R, AA.W}),
492 ECA(ShortField("video_overlay_class_shedding_interval", 0), {AA.R, AA.W}),
493 ECA(ShortField("video_return_class_shedding_interval", 0), {AA.R, AA.W}),
494 ECA(ShortField("dsl_class_shedding_interval", 0), {AA.R, AA.W}),
495 ECA(ShortField("atm_class_shedding_interval", 0), {AA.R, AA.W}),
496 ECA(ShortField("ces_class_shedding_interval", 0), {AA.R, AA.W}),
497 ECA(ShortField("frame_class_shedding_interval", 0), {AA.R, AA.W}),
498 ECA(ShortField("sonet_class_shedding_interval", 0), {AA.R, AA.W}),
499 ECA(ShortField("shedding_status", None), {AA.R, AA.W}, optional=True,
500 avc=True),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800501 ]
502 mandatory_operations = {OP.Get, OP.Set}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600503 notifications = {OP.AttributeValueChange}
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800504
505
506class IpHostConfigData(EntityClass):
507 class_id = 134
508 attributes = [
509 ECA(ShortField("managed_entity_id", None), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600510 ECA(BitField("ip_options", 0, size=8), {AA.R, AA.W}),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800511 ECA(MACField("mac_address", None), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600512 ECA(StrFixedLenField("onu_identifier", None, 25), {AA.R, AA.W}),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800513 ECA(IPField("ip_address", None), {AA.R, AA.W}),
514 ECA(IPField("mask", None), {AA.R, AA.W}),
515 ECA(IPField("gateway", None), {AA.R, AA.W}),
516 ECA(IPField("primary_dns", None), {AA.R, AA.W}),
517 ECA(IPField("secondary_dns", None), {AA.R, AA.W}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600518 ECA(IPField("current_address", None), {AA.R}, avc=True),
519 ECA(IPField("current_mask", None), {AA.R}, avc=True),
520 ECA(IPField("current_gateway", None), {AA.R}, avc=True),
521 ECA(IPField("current_primary_dns", None), {AA.R}, avc=True),
522 ECA(IPField("current_secondary_dns", None), {AA.R}, avc=True),
523 ECA(StrFixedLenField("domain_name", None, 25), {AA.R}, avc=True),
524 ECA(StrFixedLenField("host_name", None, 25), {AA.R}, avc=True),
525 ECA(ShortField("relay_agent_options", None), {AA.R, AA.W},
526 optional=True),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800527 ]
528 mandatory_operations = {OP.Get, OP.Set, OP.Test}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600529 notifications = {OP.AttributeValueChange}
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800530
531
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800532class VlanTaggingOperation(Packet):
533 name = "VlanTaggingOperation"
534 fields_desc = [
535 BitField("filter_outer_priority", 0, 4),
536 BitField("filter_outer_vid", 0, 13),
537 BitField("filter_outer_tpid_de", 0, 3),
538 BitField("pad1", 0, 12),
539
540 BitField("filter_inner_priority", 0, 4),
541 BitField("filter_inner_vid", 0, 13),
542 BitField("filter_inner_tpid_de", 0, 3),
543 BitField("pad2", 0, 8),
544 BitField("filter_ether_type", 0, 4),
545
546 BitField("treatment_tags_to_remove", 0, 2),
547 BitField("pad3", 0, 10),
548 BitField("treatment_outer_priority", 0, 4),
549 BitField("treatment_outer_vid", 0, 13),
550 BitField("treatment_outer_tpid_de", 0, 3),
551
552 BitField("pad4", 0, 12),
553 BitField("treatment_inner_priority", 0, 4),
554 BitField("treatment_inner_vid", 0, 13),
555 BitField("treatment_inner_tpid_de", 0, 3),
556 ]
557
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500558 def to_json(self):
Chip Bolingbed4c6b2018-05-09 08:52:16 -0500559 return json.dumps(self.fields, separators=(',', ':'))
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500560
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800561
562class ExtendedVlanTaggingOperationConfigurationData(EntityClass):
563 class_id = 171
564 attributes = [
Chip Bolinge2e64a02018-02-06 12:58:07 -0600565 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
566 ECA(ByteField("association_type", None), {AA.R, AA.W, AA.SBC},
567 range_check=lambda x: 0 <= x <= 11),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800568 ECA(ShortField("received_vlan_tagging_operation_table_max_size", None),
569 {AA.R}),
570 ECA(ShortField("input_tpid", None), {AA.R, AA.W}),
571 ECA(ShortField("output_tpid", None), {AA.R, AA.W}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600572 ECA(ByteField("downstream_mode", None), {AA.R, AA.W},
573 range_check=lambda x: 0 <= x <= 8),
574 ECA(StrFixedLenField("received_frame_vlan_tagging_operation_table",
575 VlanTaggingOperation, 16), {AA.R, AA.W}),
576 ECA(ShortField("associated_me_pointer", None), {AA.R, AA.W, AA.SBC}),
Chip Boling4069a512018-06-06 15:51:38 -0500577 ECA(FieldListField("dscp_to_p_bit_mapping", None,
578 BitField('', 0, size=3), count_from=lambda _: 64),
579 {AA.R, AA.W}),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800580 ]
581 mandatory_operations = {OP.Create, OP.Delete, OP.Set, OP.Get, OP.GetNext}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600582 optional_operations = {OP.SetTable}
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800583
584
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800585class OntG(EntityClass):
586 class_id = 256
587 attributes = [
Chip Bolinge2e64a02018-02-06 12:58:07 -0600588 ECA(ShortField("managed_entity_id", None), {AA.R},
589 range_check=lambda x: x == 0),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800590 ECA(StrFixedLenField("vendor_id", None, 4), {AA.R}),
591 ECA(StrFixedLenField("version", None, 14), {AA.R}),
592 ECA(StrFixedLenField("serial_number", None, 8), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600593 ECA(ByteField("traffic_management_options", None), {AA.R},
594 range_check=lambda x: 0 <= x <= 2),
595 ECA(ByteField("vp_vc_cross_connection_option", 0), {AA.R},
596 optional=True, deprecated=True),
597 ECA(ByteField("battery_backup", None), {AA.R, AA.W},
598 range_check=lambda x: 0 <= x <= 1),
599 ECA(ByteField("administrative_state", None), {AA.R, AA.W},
600 range_check=lambda x: 0 <= x <= 1),
601 ECA(ByteField("operational_state", None), {AA.R}, optional=True,
602 range_check=lambda x: 0 <= x <= 1, avc=True),
603 ECA(ByteField("ont_survival_time", None), {AA.R}, optional=True),
604 ECA(StrFixedLenField("logical_onu_id", None, 24), {AA.R},
605 optional=True, avc=True),
606 ECA(StrFixedLenField("logical_password", None, 12), {AA.R},
607 optional=True, avc=True),
608 ECA(ByteField("credentials_status", None), {AA.R, AA.W},
609 optional=True, range_check=lambda x: 0 <= x <= 4),
610 ECA(BitField("extended_tc_layer_options", None, size=16), {AA.R},
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800611 optional=True),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800612 ]
613 mandatory_operations = {
614 OP.Get, OP.Set, OP.Reboot, OP.Test, OP.SynchronizeTime}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600615 notifications = {OP.TestResult, OP.AttributeValueChange,
616 OP.AlarmNotification}
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800617
618
619class Ont2G(EntityClass):
620 class_id = 257
621 attributes = [
Chip Bolinge2e64a02018-02-06 12:58:07 -0600622 ECA(ShortField("managed_entity_id", None), {AA.R},
623 range_check=lambda x: x == 0),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800624 ECA(StrFixedLenField("equipment_id", None, 20), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600625 ECA(ByteField("omcc_version", None), {AA.R}, avc=True),
626 ECA(ShortField("vendor_product_code", None), {AA.R}),
627 ECA(ByteField("security_capability", None), {AA.R},
628 range_check=lambda x: 0 <= x <= 1),
629 ECA(ByteField("security_mode", None), {AA.R, AA.W},
630 range_check=lambda x: 0 <= x <= 1),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800631 ECA(ShortField("total_priority_queue_number", None), {AA.R}),
632 ECA(ByteField("total_traffic_scheduler_number", None), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600633 ECA(ByteField("mode", None), {AA.R}, deprecated=True),
634 ECA(ShortField("total_gem_port_id_number", None), {AA.R}),
635 ECA(IntField("sys_uptime", None), {AA.R}),
636 ECA(BitField("connectivity_capability", None, size=16), {AA.R}),
637 ECA(ByteField("current_connectivity_mode", None), {AA.R, AA.W},
638 range_check=lambda x: 0 <= x <= 7),
639 ECA(BitField("qos_configuration_flexibility", None, size=16),
640 {AA.R}, optional=True),
641 ECA(ShortField("priority_queue_scale_factor", None), {AA.R, AA.W},
642 optional=True),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800643 ]
644 mandatory_operations = {OP.Get, OP.Set}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600645 notifications = {OP.AttributeValueChange}
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800646
647
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800648class Tcont(EntityClass):
649 class_id = 262
650 attributes = [
651 ECA(ShortField("managed_entity_id", None), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600652 ECA(ShortField("alloc_id", None), {AA.R, AA.W}),
653 ECA(ByteField("mode_indicator", 1), {AA.R}, deprecated=True),
654 ECA(ByteField("policy", None), {AA.R, AA.W},
655 range_check=lambda x: 0 <= x <= 2),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800656 ]
657 mandatory_operations = {OP.Get, OP.Set}
658
659
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800660class AniG(EntityClass):
661 class_id = 263
662 attributes = [
663 ECA(ShortField("managed_entity_id", None), {AA.R}),
664 ECA(ByteField("sr_indication", None), {AA.R}),
665 ECA(ShortField("total_tcont_number", None), {AA.R}),
666 ECA(ShortField("gem_block_length", None), {AA.R, AA.W}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600667 ECA(ByteField("piggyback_dba_reporting", None), {AA.R},
668 range_check=lambda x: 0 <= x <= 4),
669 ECA(ByteField("whole_ont_dba_reporting", None), {AA.R},
670 deprecated=True),
671 ECA(ByteField("sf_threshold", 5), {AA.R, AA.W}),
672 ECA(ByteField("sd_threshold", 9), {AA.R, AA.W}),
673 ECA(ByteField("arc", 0), {AA.R, AA.W},
674 range_check=lambda x: 0 <= x <= 1, avc=True),
675 ECA(ByteField("arc_interval", 0), {AA.R, AA.W}),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800676 ECA(ShortField("optical_signal_level", None), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600677 ECA(ByteField("lower_optical_threshold", 0xFF), {AA.R, AA.W}),
678 ECA(ByteField("upper_optical_threshold", 0xFF), {AA.R, AA.W}),
679 ECA(ByteField("ont_response_time", None), {AA.R}),
680 ECA(ShortField("transmit_optical_level", None), {AA.R}),
681 ECA(ByteField("lower_transmit_power_threshold", 0x81), {AA.R, AA.W}),
682 ECA(ByteField("upper_transmit_power_threshold", 0x81), {AA.R, AA.W}),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800683 ]
684 mandatory_operations = {OP.Get, OP.Set, OP.Test}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600685 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800686
687
688class UniG(EntityClass):
689 class_id = 264
690 attributes = [
691 ECA(ShortField("managed_entity_id", None), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600692 ECA(ShortField("configuration_option_status", None), {AA.R, AA.W},
693 deprecated=True),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800694 ECA(ByteField("administrative_state", None), {AA.R, AA.W}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600695 ECA(ByteField("management_capability", None), {AA.R},
696 range_check=lambda x: 0 <= x <= 2),
697 ECA(ShortField("non_omci_management_identifier", None), {AA.R, AA.W}),
698 ECA(ShortField("relay_agent_options", None), {AA.R, AA.W},
699 optional=True),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800700 ]
701 mandatory_operations = {OP.Get, OP.Set}
702
703
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800704class GemInterworkingTp(EntityClass):
705 class_id = 266
706 attributes = [
Chip Bolinge2e64a02018-02-06 12:58:07 -0600707 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800708 ECA(ShortField("gem_port_network_ctp_pointer", None),
709 {AA.R, AA.W, AA.SBC}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600710 ECA(ByteField("interworking_option", None), {AA.R, AA.W, AA.SBC},
711 range_check=lambda x: 0 <= x <= 7),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800712 ECA(ShortField("service_profile_pointer", None), {AA.R, AA.W, AA.SBC}),
713 ECA(ShortField("interworking_tp_pointer", None), {AA.R, AA.W, AA.SBC}),
714 ECA(ByteField("pptp_counter", None), {AA.R}, optional=True),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600715 ECA(ByteField("operational_state", None), {AA.R}, optional=True,
716 range_check=lambda x: 0 <= x <= 1, avc=True),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800717 ECA(ShortField("gal_profile_pointer", None), {AA.R, AA.W, AA.SBC}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600718 ECA(ByteField("gal_loopback_configuration", 0),
719 {AA.R, AA.W}, range_check=lambda x: 0 <= x <= 1),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800720 ]
Chip Bolingeada0c92017-12-27 09:45:26 -0600721 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600722 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800723
724
725class GemPortNetworkCtp(EntityClass):
726 class_id = 268
727 attributes = [
728 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
729 ECA(ShortField("port_id", None), {AA.R, AA.W, AA.SBC}),
730 ECA(ShortField("tcont_pointer", None), {AA.R, AA.W, AA.SBC}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600731 ECA(ByteField("direction", None), {AA.R, AA.W, AA.SBC},
732 range_check=lambda x: 1 <= x <= 3),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800733 ECA(ShortField("traffic_management_pointer_upstream", None),
734 {AA.R, AA.W, AA.SBC}),
735 ECA(ShortField("traffic_descriptor_profile_pointer", None),
736 {AA.R, AA.W, AA.SBC}, optional=True),
737 ECA(ByteField("uni_counter", None), {AA.R}, optional=True),
738 ECA(ShortField("priority_queue_pointer_downstream", None),
739 {AA.R, AA.W, AA.SBC}),
Nathan Knuth61a039c2017-03-23 13:50:29 -0700740 ECA(ByteField("encryption_state", None), {AA.R}, optional=True),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600741 ECA(ShortField("traffic_desc_profile_pointer_downstream", None),
742 {AA.R, AA.W, AA.SBC}, optional=True),
743 ECA(ShortField("encryption_key_ring", None), {AA.R, AA.W, AA.SBC},
744 range_check=lambda x: 0 <= x <= 3)
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800745 ]
746 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600747 notifications = {OP.AlarmNotification}
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800748
749
750class GalEthernetProfile(EntityClass):
751 class_id = 272
752 attributes = [
753 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
754 ECA(ShortField("max_gem_payload_size", None), {AA.R, AA.W, AA.SBC}),
755 ]
756 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set}
757
758
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800759class PriorityQueueG(EntityClass):
760 class_id = 277
761 attributes = [
762 ECA(ShortField("managed_entity_id", None), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600763 ECA(ByteField("queue_configuration_option", None), {AA.R},
764 range_check=lambda x: 0 <= x <= 1),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800765 ECA(ShortField("maximum_queue_size", None), {AA.R}),
766 ECA(ShortField("allocated_queue_size", None), {AA.R, AA.W}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600767 ECA(ShortField("discard_block_counter_reset_interval", None), {AA.R, AA.W}),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800768 ECA(ShortField("threshold_value_for_discarded_blocks", None), {AA.R, AA.W}),
769 ECA(IntField("related_port", None), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600770 ECA(ShortField("traffic_scheduler_pointer", 0), {AA.R, AA.W}),
771 ECA(ByteField("weight", 1), {AA.R, AA.W}),
772 ECA(ShortField("back_pressure_operation", 0), {AA.R, AA.W},
773 range_check=lambda x: 0 <= x <= 1),
774 ECA(IntField("back_pressure_time", 0), {AA.R, AA.W}),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800775 ECA(ShortField("back_pressure_occur_queue_threshold", None), {AA.R, AA.W}),
776 ECA(ShortField("back_pressure_clear_queue_threshold", None), {AA.R, AA.W}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600777 # TODO: Custom field of 4 2-byte values would help below
778 ECA(LongField("packet_drop_queue_thresholds", None), {AA.R, AA.W},
779 optional=True),
780 ECA(ShortField("packet_drop_max_p", 0xFFFF), {AA.R, AA.W}, optional=True),
781 ECA(ByteField("queue_drop_w_q", 9), {AA.R, AA.W}, optional=True),
782 ECA(ByteField("drop_precedence_colour_marking", 0), {AA.R, AA.W},
783 optional=True, range_check=lambda x: 0 <= x <= 7),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800784 ]
785 mandatory_operations = {OP.Get, OP.Set}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600786 notifications = {OP.AlarmNotification}
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800787
788
789class TrafficSchedulerG(EntityClass):
790 class_id = 278
791 attributes = [
792 ECA(ShortField("managed_entity_id", None), {AA.R}),
793 ECA(ShortField("tcont_pointer", None), {AA.R}),
794 ECA(ShortField("traffic_scheduler_pointer", None), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600795 ECA(ByteField("policy", None), {AA.R, AA.W},
796 range_check=lambda x: 0 <= x <= 2),
797 ECA(ByteField("priority_weight", 0), {AA.R, AA.W}),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -0800798 ]
799 mandatory_operations = {OP.Get, OP.Set}
800
801
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800802class MulticastGemInterworkingTp(EntityClass):
803 class_id = 281
804 attributes = [
Chip Bolinge2e64a02018-02-06 12:58:07 -0600805 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC},
806 range_check=lambda x: x != OmciNullPointer),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800807 ECA(ShortField("gem_port_network_ctp_pointer", None), {AA.R, AA.SBC}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600808 ECA(ByteField("interworking_option", None), {AA.R, AA.W, AA.SBC},
809 range_check=lambda x: x in [0, 1, 3, 5]),
810 ECA(ShortField("service_profile_pointer", None), {AA.R, AA.W, AA.SBC}),
811 ECA(ShortField("interworking_tp_pointer", 0), {AA.R, AA.W, AA.SBC},
812 deprecated=True),
813 ECA(ByteField("pptp_counter", None), {AA.R}),
814 ECA(ByteField("operational_state", None), {AA.R}, avc=True,
815 range_check=lambda x: 0 <= x <= 1),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800816 ECA(ShortField("gal_profile_pointer", None), {AA.R, AA.W, AA.SBC}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600817 ECA(ByteField("gal_loopback_configuration", None), {AA.R, AA.W, AA.SBC},
818 deprecated=True),
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800819 # TODO add multicast_address_table here (page 85 of spec.)
820 # ECA(...("multicast_address_table", None), {AA.R, AA.W})
821 ]
822 mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.GetNext, OP.Set}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600823 optional_operations = {OP.SetTable}
824 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -0800825
826
Steve Crooks9e85ce82017-03-20 12:00:53 -0400827class AccessControlRow0(Packet):
828 name = "AccessControlRow0"
829 fields_desc = [
830 BitField("set_ctrl", 0, 2),
831 BitField("row_part_id", 0, 3),
832 BitField("test", 0, 1),
833 BitField("row_key", 0, 10),
834
835 ShortField("gem_port_id", None),
836 ShortField("vlan_id", None),
837 IPField("src_ip", None),
838 IPField("dst_ip_start", None),
839 IPField("dst_ip_end", None),
840 IntField("ipm_group_bw", None),
841 ShortField("reserved0", 0)
842 ]
843
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500844 def to_json(self):
Chip Bolingbed4c6b2018-05-09 08:52:16 -0500845 return json.dumps(self.fields, separators=(',', ':'))
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500846
Chip Bolinge2e64a02018-02-06 12:58:07 -0600847
Steve Crooks9e85ce82017-03-20 12:00:53 -0400848class AccessControlRow1(Packet):
849 name = "AccessControlRow1"
850 fields_desc = [
851 BitField("set_ctrl", 0, 2),
852 BitField("row_part_id", 0, 3),
853 BitField("test", 0, 1),
854 BitField("row_key", 0, 10),
855
856 StrFixedLenField("ipv6_src_addr_start_bytes", None, 12),
857 ShortField("preview_length", None),
858 ShortField("preview_repeat_time", None),
859 ShortField("preview_repeat_count", None),
860 ShortField("preview_reset_time", None),
861 ShortField("reserved1", 0)
862 ]
863
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500864 def to_json(self):
Chip Bolingbed4c6b2018-05-09 08:52:16 -0500865 return json.dumps(self.fields, separators=(',', ':'))
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500866
Chip Bolinge2e64a02018-02-06 12:58:07 -0600867
Steve Crooks9e85ce82017-03-20 12:00:53 -0400868class AccessControlRow2(Packet):
869 name = "AccessControlRow2"
870 fields_desc = [
871 BitField("set_ctrl", 0, 2),
872 BitField("row_part_id", 0, 3),
873 BitField("test", 0, 1),
874 BitField("row_key", 0, 10),
875
876 StrFixedLenField("ipv6_dst_addr_start_bytes", None, 12),
877 StrFixedLenField("reserved2", None, 10)
878 ]
879
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500880 def to_json(self):
Chip Bolingbed4c6b2018-05-09 08:52:16 -0500881 return json.dumps(self.fields, separators=(',', ':'))
Chip Bolinge2e64a02018-02-06 12:58:07 -0600882
Chip Boling9b7a11a2018-04-15 13:33:21 -0500883
Steve Crooks9e85ce82017-03-20 12:00:53 -0400884class DownstreamIgmpMulticastTci(Packet):
885 name = "DownstreamIgmpMulticastTci"
886 fields_desc = [
887 ByteField("ctrl_type", None),
888 ShortField("tci", None)
889 ]
890
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500891 def to_json(self):
Chip Bolingbed4c6b2018-05-09 08:52:16 -0500892 return json.dumps(self.fields, separators=(',', ':'))
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500893
Chip Bolinge2e64a02018-02-06 12:58:07 -0600894
Steve Crooks89b94b72017-02-01 10:06:30 -0500895class MulticastOperationsProfile(EntityClass):
896 class_id = 309
897 attributes = [
Chip Bolinge2e64a02018-02-06 12:58:07 -0600898 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC},
899 range_check=lambda x: x != 0 and x != OmciNullPointer),
900 ECA(ByteField("igmp_version", None), {AA.R, AA.W, AA.SBC},
901 range_check=lambda x: x in [1, 2, 3, 16, 17]),
902 ECA(ByteField("igmp_function", None), {AA.R, AA.W, AA.SBC},
903 range_check=lambda x: 0 <= x <= 2),
904 ECA(ByteField("immediate_leave", None), {AA.R, AA.W, AA.SBC},
905 range_check=lambda x: 0 <= x <= 1),
Steve Crooks89b94b72017-02-01 10:06:30 -0500906 ECA(ShortField("us_igmp_tci", None), {AA.R, AA.W, AA.SBC}, optional=True),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600907 ECA(ByteField("us_igmp_tag_ctrl", None), {AA.R, AA.W, AA.SBC},
908 range_check=lambda x: 0 <= x <= 3, optional=True),
Steve Crooks89b94b72017-02-01 10:06:30 -0500909 ECA(IntField("us_igmp_rate", None), {AA.R, AA.W, AA.SBC}, optional=True),
910 # TODO: need to make table and add column data
911 ECA(StrFixedLenField(
912 "dynamic_access_control_list_table", None, 24), {AA.R, AA.W}),
913 # TODO: need to make table and add column data
914 ECA(StrFixedLenField(
915 "static_access_control_list_table", None, 24), {AA.R, AA.W}),
916 # TODO: need to make table and add column data
Chip Bolinge2e64a02018-02-06 12:58:07 -0600917 ECA(StrFixedLenField("lost_groups_list_table", None, 10), {AA.R}),
918 ECA(ByteField("robustness", None), {AA.R, AA.W, AA.SBC}),
919 ECA(IntField("querier_ip", None), {AA.R, AA.W, AA.SBC}),
920 ECA(IntField("query_interval", None), {AA.R, AA.W, AA.SBC}),
921 ECA(IntField("querier_max_response_time", None), {AA.R, AA.W, AA.SBC}),
922 ECA(IntField("last_member_response_time", 10), {AA.R, AA.W}),
923 ECA(ByteField("unauthorized_join_behaviour", None), {AA.R, AA.W}),
Steve Crooks9e85ce82017-03-20 12:00:53 -0400924 ECA(StrFixedLenField("ds_igmp_mcast_tci", None, 3), {AA.R, AA.W, AA.SBC}, optional=True)
Steve Crooks89b94b72017-02-01 10:06:30 -0500925 ]
926 mandatory_operations = {OP.Create, OP.Delete, OP.Set, OP.Get, OP.GetNext}
Chip Bolinge2e64a02018-02-06 12:58:07 -0600927 optional_operations = {OP.SetTable}
928 notifications = {OP.AlarmNotification}
929
Steve Crooks89b94b72017-02-01 10:06:30 -0500930
Steve Crooks9e85ce82017-03-20 12:00:53 -0400931class MulticastServicePackage(Packet):
932 name = "MulticastServicePackage"
933 fields_desc = [
934 BitField("set_ctrl", 0, 2),
935 BitField("reserved0", 0, 4),
936 BitField("row_key", 0, 10),
937
938 ShortField("vid_uni", None),
939 ShortField("max_simultaneous_groups", None),
940 IntField("max_multicast_bw", None),
941 ShortField("mcast_operations_profile_pointer", None),
942 StrFixedLenField("reserved1", None, 8)
943 ]
944
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500945 def to_json(self):
Chip Bolingbed4c6b2018-05-09 08:52:16 -0500946 return json.dumps(self.fields, separators=(',', ':'))
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500947
Chip Bolinge2e64a02018-02-06 12:58:07 -0600948
Steve Crooks9e85ce82017-03-20 12:00:53 -0400949class AllowedPreviewGroupsRow0(Packet):
950 name = "AllowedPreviewGroupsRow0"
951 fields_desc = [
952 BitField("set_ctrl", 0, 2),
953 BitField("row_part_id", 0, 3),
954 BitField("reserved0", 0, 1),
955 BitField("row_key", 0, 10),
956
957 StrFixedLenField("ipv6_pad", 0, 12),
958 IPField("src_ip", None),
959 ShortField("vlan_id_ani", None),
960 ShortField("vlan_id_uni", None)
961 ]
962
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500963 def to_json(self):
Chip Bolingbed4c6b2018-05-09 08:52:16 -0500964 return json.dumps(self.fields, separators=(',', ':'))
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500965
Chip Bolinge2e64a02018-02-06 12:58:07 -0600966
Steve Crooks9e85ce82017-03-20 12:00:53 -0400967class AllowedPreviewGroupsRow1(Packet):
968 name = "AllowedPreviewGroupsRow1"
969 fields_desc = [
970 BitField("set_ctrl", 0, 2),
971 BitField("row_part_id", 0, 3),
972 BitField("reserved0", 0, 1),
973 BitField("row_key", 0, 10),
974
975 StrFixedLenField("ipv6_pad", 0, 12),
976 IPField("dst_ip", None),
977 ShortField("duration", None),
978 ShortField("time_left", None)
979 ]
Steve Crooks89b94b72017-02-01 10:06:30 -0500980
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500981 def to_json(self):
Chip Bolingbed4c6b2018-05-09 08:52:16 -0500982 return json.dumps(self.fields, separators=(',', ':'))
Chip Bolingc7d3e2d2018-04-06 10:16:29 -0500983
Chip Bolinge2e64a02018-02-06 12:58:07 -0600984
Steve Crooks89b94b72017-02-01 10:06:30 -0500985class MulticastSubscriberConfigInfo(EntityClass):
986 class_id = 310
987 attributes = [
988 ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}),
Chip Bolinge2e64a02018-02-06 12:58:07 -0600989 ECA(ByteField("me_type", None), {AA.R, AA.W, AA.SBC},
990 range_check=lambda x: 0 <= x <= 1),
991 ECA(ShortField("mcast_operations_profile_pointer", None),
992 {AA.R, AA.W, AA.SBC}),
993 ECA(ShortField("max_simultaneous_groups", None), {AA.R, AA.W, AA.SBC}),
994 ECA(IntField("max_multicast_bandwidth", None), {AA.R, AA.W, AA.SBC}),
995 ECA(ByteField("bandwidth_enforcement", None), {AA.R, AA.W, AA.SBC},
996 range_check=lambda x: 0 <= x <= 1),
Steve Crooks89b94b72017-02-01 10:06:30 -0500997 # TODO: need to make table and add column data
998 ECA(StrFixedLenField(
Chip Bolinge2e64a02018-02-06 12:58:07 -0600999 "multicast_service_package_table", None, 20), {AA.R, AA.W}),
Steve Crooks89b94b72017-02-01 10:06:30 -05001000 # TODO: need to make table and add column data
1001 ECA(StrFixedLenField(
Chip Bolinge2e64a02018-02-06 12:58:07 -06001002 "allowed_preview_groups_table", None, 22), {AA.R, AA.W}),
Steve Crooks89b94b72017-02-01 10:06:30 -05001003 ]
Chip Bolinge2e64a02018-02-06 12:58:07 -06001004 mandatory_operations = {OP.Create, OP.Delete, OP.Set, OP.Get, OP.GetNext,
1005 OP.SetTable}
Steve Crooks89b94b72017-02-01 10:06:30 -05001006
1007
1008class VirtualEthernetInterfacePt(EntityClass):
Zsolt Haraszti578a46c2016-12-20 16:38:43 -08001009 class_id = 329
1010 attributes = [
Chip Bolinge2e64a02018-02-06 12:58:07 -06001011 ECA(ShortField("managed_entity_id", None), {AA.R},
1012 range_check=lambda x: x != 0 and x != OmciNullPointer),
1013 ECA(ByteField("administrative_state", None), {AA.R, AA.W},
1014 range_check=lambda x: 0 <= x <= 1),
1015 ECA(ByteField("operational_state", None), {AA.R}, avc=True,
1016 range_check=lambda x: 0 <= x <= 1),
Steve Crooks89b94b72017-02-01 10:06:30 -05001017 ECA(StrFixedLenField(
1018 "interdomain_name", None, 25), {AA.R, AA.W}, optional=True),
1019 ECA(ShortField("tcp_udp_pointer", None), {AA.R, AA.W}, optional=True),
1020 ECA(ShortField("iana_assigned_port", None), {AA.R}),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -08001021 ]
Steve Crooks89b94b72017-02-01 10:06:30 -05001022 mandatory_operations = {OP.Get, OP.Set}
Chip Bolinge2e64a02018-02-06 12:58:07 -06001023 notifications = {OP.AttributeValueChange, OP.AlarmNotification}
Zsolt Haraszti578a46c2016-12-20 16:38:43 -08001024
1025
Chip Boling28155862018-06-07 11:13:39 -05001026class Omci(EntityClass):
1027 class_id = 287
1028 attributes = [
1029 ECA(ShortField("managed_entity_id", None), {AA.R},
1030 range_check=lambda x: x == 0),
1031
1032 # TODO: Can this be expressed better in SCAPY, probably not?
1033 # On the initial, Get request for either the me_type or message_type
1034 # attributes, you will receive a 4 octet value (big endian) that is
1035 # the number of octets to 'get-next' to fully load the desired
1036 # attribute. For a basic OMCI formatted message, that will be 29
1037 # octets per get-request.
1038 #
1039 # For the me_type_table, these are 16-bit values (ME Class IDs)
1040 #
1041 # For the message_type_table, these are 8-bit values (Actions)
1042
1043 ECA(FieldListField("me_type_table", None, ByteField('', 0),
1044 count_from=lambda _: 29), {AA.R}),
1045 ECA(FieldListField("message_type_table", None, ByteField('', 0),
1046 count_from=lambda _: 29), {AA.R}),
1047 ]
1048 mandatory_operations = {OP.Get, OP.GetNext}
1049
1050
Chip Bolingf0b3a062018-01-18 13:53:58 -06001051class EnhSecurityControl(EntityClass):
Zsolt Haraszti578a46c2016-12-20 16:38:43 -08001052 class_id = 332
1053 attributes = [
Steve Crooks89b94b72017-02-01 10:06:30 -05001054 ECA(ShortField("managed_entity_id", None), {AA.R}),
Chip Bolinge2e64a02018-02-06 12:58:07 -06001055 ECA(BitField("olt_crypto_capabilities", None, 16*8), {AA.W}),
Steve Crooks89b94b72017-02-01 10:06:30 -05001056 # TODO: need to make table and add column data
1057 ECA(StrFixedLenField(
1058 "olt_random_challenge_table", None, 17), {AA.R, AA.W}),
Chip Bolinge2e64a02018-02-06 12:58:07 -06001059 ECA(ByteField("olt_challenge_status", 0), {AA.R, AA.W},
1060 range_check=lambda x: 0 <= x <= 1),
Steve Crooks89b94b72017-02-01 10:06:30 -05001061 ECA(ByteField("onu_selected_crypto_capabilities", None), {AA.R}),
1062 # TODO: need to make table and add column data
1063 ECA(StrFixedLenField(
Chip Bolinge2e64a02018-02-06 12:58:07 -06001064 "onu_random_challenge_table", None, 16), {AA.R}, avc=True),
Steve Crooks89b94b72017-02-01 10:06:30 -05001065 # TODO: need to make table and add column data
1066 ECA(StrFixedLenField(
Chip Bolinge2e64a02018-02-06 12:58:07 -06001067 "onu_authentication_result_table", None, 16), {AA.R}, avc=True),
Steve Crooks89b94b72017-02-01 10:06:30 -05001068 # TODO: need to make table and add column data
1069 ECA(StrFixedLenField(
1070 "olt_authentication_result_table", None, 17), {AA.W}),
Chip Bolinge2e64a02018-02-06 12:58:07 -06001071 ECA(ByteField("olt_result_status", None), {AA.R, AA.W},
1072 range_check=lambda x: 0 <= x <= 1),
1073 ECA(ByteField("onu_authentication_status", None), {AA.R}, avc=True,
1074 range_check=lambda x: 0 <= x <= 5),
Steve Crooks89b94b72017-02-01 10:06:30 -05001075 ECA(StrFixedLenField(
1076 "master_session_key_name", None, 16), {AA.R}),
1077 ECA(StrFixedLenField(
Chip Bolinge2e64a02018-02-06 12:58:07 -06001078 "broadcast_key_table", None, 18), {AA.R, AA.W}),
1079 ECA(ShortField("effective_key_length", None), {AA.R}),
Zsolt Haraszti578a46c2016-12-20 16:38:43 -08001080
1081 ]
Steve Crooks89b94b72017-02-01 10:06:30 -05001082 mandatory_operations = {OP.Set, OP.Get, OP.GetNext}
Chip Bolinge2e64a02018-02-06 12:58:07 -06001083 notifications = {OP.AttributeValueChange}
Zsolt Haraszti578a46c2016-12-20 16:38:43 -08001084
Zsolt Harasztie0acd8f2016-12-16 14:53:55 -08001085# entity class lookup table from entity_class values
1086entity_classes_name_map = dict(
1087 inspect.getmembers(sys.modules[__name__],
1088 lambda o: inspect.isclass(o) and \
1089 issubclass(o, EntityClass) and \
1090 o is not EntityClass)
1091)
1092
1093entity_classes = [c for c in entity_classes_name_map.itervalues()]
1094entity_id_to_class_map = dict((c.class_id, c) for c in entity_classes)