Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 1 | # |
Zsolt Haraszti | 3eb27a5 | 2017-01-03 21:56:48 -0800 | [diff] [blame] | 2 | # Copyright 2017 the original author or authors. |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | import inspect |
| 17 | |
| 18 | import sys |
Nathan Knuth | b396f47 | 2017-03-28 17:18:51 -0700 | [diff] [blame] | 19 | from binascii import hexlify |
Chip Boling | c7d3e2d | 2018-04-06 10:16:29 -0500 | [diff] [blame] | 20 | import json |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 21 | from scapy.fields import ByteField, ShortField, MACField, BitField, IPField |
Chip Boling | 4c06db9 | 2018-05-24 15:02:26 -0500 | [diff] [blame] | 22 | from scapy.fields import IntField, StrFixedLenField, LongField, FieldListField |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 23 | from scapy.packet import Packet |
| 24 | |
| 25 | from voltha.extensions.omci.omci_defs import OmciUninitializedFieldError, \ |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 26 | AttributeAccess, OmciNullPointer, EntityOperations, OmciInvalidTypeError |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 27 | from voltha.extensions.omci.omci_defs import bitpos_from_mask |
| 28 | |
| 29 | |
| 30 | class EntityClassAttribute(object): |
| 31 | |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 32 | 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 Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 45 | self._fld = fld |
| 46 | self._access = access |
| 47 | self._optional = optional |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 48 | 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 Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 109 | |
| 110 | |
| 111 | class 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 | |
| 124 | class EntityClass(object): |
| 125 | |
| 126 | class_id = 'to be filled by subclass' |
| 127 | attributes = [] |
Chip Boling | 106b60a | 2018-01-21 06:55:40 -0600 | [diff] [blame] | 128 | mandatory_operations = set() |
| 129 | optional_operations = set() |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 130 | notifications = set() |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 131 | |
| 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 Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 143 | octets = '' |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 144 | |
| 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 Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 156 | eca = self.attributes[index] |
| 157 | field = eca.field |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 158 | try: |
| 159 | value = self._data[field.name] |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 160 | |
| 161 | if not eca.valid(value): |
| 162 | raise OmciInvalidTypeError( |
| 163 | 'Value "{}" for Entity field "{}" is not valid'.format(value, |
| 164 | field.name)) |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 165 | except KeyError: |
| 166 | raise OmciUninitializedFieldError( |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 167 | 'Entity field "{}" not set'.format(field.name)) |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 168 | |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 169 | octets = field.addfield(None, octets, value) |
| 170 | |
| 171 | return octets |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 172 | |
| 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 Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 182 | |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 183 | @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 |
| 206 | ECA = EntityClassAttribute |
| 207 | AA = AttributeAccess |
| 208 | OP = EntityOperations |
| 209 | |
| 210 | |
| 211 | class OntData(EntityClass): |
| 212 | class_id = 2 |
| 213 | attributes = [ |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 214 | ECA(ShortField("managed_entity_id", None), {AA.R}, |
| 215 | range_check=lambda x: x == 0), |
Chip Boling | 9b7a11a | 2018-04-15 13:33:21 -0500 | [diff] [blame] | 216 | # Only 1 octet used if GET/SET operation |
| 217 | ECA(ShortField("mib_data_sync", 0), {AA.R, AA.W}) |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 218 | ] |
| 219 | mandatory_operations = {OP.Get, OP.Set, |
| 220 | OP.GetAllAlarms, OP.GetAllAlarmsNext, |
| 221 | OP.MibReset, OP.MibUpload, OP.MibUploadNext} |
Zsolt Haraszti | e3ece3c | 2016-12-19 23:32:38 -0800 | [diff] [blame] | 222 | |
| 223 | |
| 224 | class Cardholder(EntityClass): |
| 225 | class_id = 5 |
| 226 | attributes = [ |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 227 | ECA(ShortField("managed_entity_id", None), {AA.R}, |
| 228 | range_check=lambda x: 0 <= x < 255 or 256 <= x < 511, |
| 229 | avc=True), |
Zsolt Haraszti | e3ece3c | 2016-12-19 23:32:38 -0800 | [diff] [blame] | 230 | 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 Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 235 | optional=True, avc=True), |
Zsolt Haraszti | e3ece3c | 2016-12-19 23:32:38 -0800 | [diff] [blame] | 236 | 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 Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 241 | 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 Haraszti | e3ece3c | 2016-12-19 23:32:38 -0800 | [diff] [blame] | 245 | ] |
| 246 | mandatory_operations = {OP.Get, OP.Set} |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 247 | notifications = {OP.AttributeValueChange, OP.AlarmNotification} |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 248 | |
| 249 | |
| 250 | class CircuitPack(EntityClass): |
| 251 | class_id = 6 |
| 252 | attributes = [ |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 253 | ECA(StrFixedLenField("managed_entity_id", None, 22), {AA.R, AA.SBC}, |
| 254 | range_check=lambda x: 0 <= x < 255 or 256 <= x < 511), |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 255 | 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 Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 260 | 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 Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 264 | ECA(StrFixedLenField("equipment_id", None, 20), {AA.R}, optional=True), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 265 | 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 Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 273 | 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 Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 278 | notifications = {OP.AttributeValueChange, OP.AlarmNotification} |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 279 | |
| 280 | |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 281 | class SoftwareImage(EntityClass): |
| 282 | class_id = 7 |
| 283 | attributes = [ |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 284 | 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 Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 295 | ] |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 296 | mandatory_operations = {OP.Get, OP.StartSoftwareDownload, OP.DownloadSection, |
| 297 | OP.EndSoftwareDownload, OP.ActivateSoftware, |
| 298 | OP.CommitSoftware} |
| 299 | notifications = {OP.AttributeValueChange} |
| 300 | |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 301 | |
Nathan Knuth | 61a039c | 2017-03-23 13:50:29 -0700 | [diff] [blame] | 302 | class PptpEthernetUni(EntityClass): |
| 303 | class_id = 11 |
| 304 | attributes = [ |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 305 | 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 Boling | f60a532 | 2018-05-15 09:03:02 -0500 | [diff] [blame] | 322 | ECA(ShortField("max_frame_size", 1518), {AA.R, AA.W}, optional=True), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 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), |
Chip Boling | f60a532 | 2018-05-15 09:03:02 -0500 | [diff] [blame] | 326 | ECA(ByteField("bridged_ip_ind", 2), {AA.R, AA.W}, |
| 327 | optional=True, range_check=lambda x: 0 <= x <= 2), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 328 | 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 Knuth | 61a039c | 2017-03-23 13:50:29 -0700 | [diff] [blame] | 333 | ] |
| 334 | mandatory_operations = {OP.Get, OP.Set} |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 335 | notifications = {OP.AttributeValueChange, OP.AlarmNotification} |
| 336 | |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 337 | |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 338 | class MacBridgeServiceProfile(EntityClass): |
| 339 | class_id = 45 |
| 340 | attributes = [ |
| 341 | ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 342 | 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 Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 361 | ] |
| 362 | mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set} |
| 363 | |
| 364 | |
| 365 | class 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 Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 371 | ECA(ByteField("tp_type", None), {AA.R, AA.W, AA.SBC}, |
| 372 | range_check=lambda x: 1 <= x <= 12), |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 373 | 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 Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 378 | optional=True, deprecated=True), |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 379 | ECA(ByteField("lan_fcs_ind", None), {AA.R, AA.W, AA.SBC}, |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 380 | optional=True, deprecated=True), |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 381 | 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 Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 386 | # TODO: |
| 387 | ECA(ByteField("mac_learning_depth", 0), {AA.R, AA.W, AA.SBC}, |
| 388 | optional=True), |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 389 | ] |
| 390 | mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set} |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 391 | notifications = {OP.AlarmNotification} |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 392 | |
| 393 | |
Chip Boling | e6c416f | 2018-05-01 15:07:51 -0500 | [diff] [blame] | 394 | class 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 Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 423 | class VlanTaggingFilterData(EntityClass): |
| 424 | class_id = 84 |
| 425 | attributes = [ |
| 426 | ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}), |
Chip Boling | 4c06db9 | 2018-05-24 15:02:26 -0500 | [diff] [blame] | 427 | ECA(FieldListField("vlan_filter_list", None, |
| 428 | ShortField('', 0), count_from=lambda _: 12), |
| 429 | {AA.R, AA.W, AA.SBC}), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 430 | ECA(ByteField("forward_operation", None), {AA.R, AA.W, AA.SBC}, |
| 431 | range_check=lambda x: 0x00 <= x <= 0x21), |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 432 | 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 | |
| 437 | class Ieee8021pMapperServiceProfile(EntityClass): |
| 438 | class_id = 130 |
| 439 | attributes = [ |
| 440 | ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 441 | 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 Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 458 | ECA(ByteField("unmarked_frame_option", None), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 459 | {AA.R, AA.W, AA.SBC}, range_check=lambda x: 0 <= x <= 1), |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 460 | ECA(StrFixedLenField("dscp_to_p_bit_mapping", None, length=24), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 461 | {AA.R, AA.W}), # TODO: Would a custom 3-bit group bitfield work better? |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 462 | ECA(ByteField("default_p_bit_marking", None), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 463 | {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 Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 466 | ] |
| 467 | mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set} |
| 468 | |
| 469 | |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 470 | class OltG(EntityClass): |
| 471 | class_id = 131 |
| 472 | attributes = [ |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 473 | ECA(ShortField("managed_entity_id", None), {AA.R}, |
| 474 | range_check=lambda x: x == 0), |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 475 | 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 | |
| 483 | class OntPowerShedding(EntityClass): |
| 484 | class_id = 133 |
| 485 | attributes = [ |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 486 | 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 Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 489 | {AA.R, AA.W}), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 490 | 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 Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 501 | ] |
| 502 | mandatory_operations = {OP.Get, OP.Set} |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 503 | notifications = {OP.AttributeValueChange} |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 504 | |
| 505 | |
| 506 | class IpHostConfigData(EntityClass): |
| 507 | class_id = 134 |
| 508 | attributes = [ |
| 509 | ECA(ShortField("managed_entity_id", None), {AA.R}), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 510 | ECA(BitField("ip_options", 0, size=8), {AA.R, AA.W}), |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 511 | ECA(MACField("mac_address", None), {AA.R}), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 512 | ECA(StrFixedLenField("onu_identifier", None, 25), {AA.R, AA.W}), |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 513 | 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 Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 518 | 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 Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 527 | ] |
| 528 | mandatory_operations = {OP.Get, OP.Set, OP.Test} |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 529 | notifications = {OP.AttributeValueChange} |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 530 | |
| 531 | |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 532 | class 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 Boling | c7d3e2d | 2018-04-06 10:16:29 -0500 | [diff] [blame] | 558 | def to_json(self): |
Chip Boling | bed4c6b | 2018-05-09 08:52:16 -0500 | [diff] [blame] | 559 | return json.dumps(self.fields, separators=(',', ':')) |
Chip Boling | c7d3e2d | 2018-04-06 10:16:29 -0500 | [diff] [blame] | 560 | |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 561 | |
| 562 | class ExtendedVlanTaggingOperationConfigurationData(EntityClass): |
| 563 | class_id = 171 |
| 564 | attributes = [ |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 565 | 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 Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 568 | 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 Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 572 | 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 Boling | 4069a51 | 2018-06-06 15:51:38 -0500 | [diff] [blame] | 577 | ECA(FieldListField("dscp_to_p_bit_mapping", None, |
| 578 | BitField('', 0, size=3), count_from=lambda _: 64), |
| 579 | {AA.R, AA.W}), |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 580 | ] |
| 581 | mandatory_operations = {OP.Create, OP.Delete, OP.Set, OP.Get, OP.GetNext} |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 582 | optional_operations = {OP.SetTable} |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 583 | |
| 584 | |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 585 | class OntG(EntityClass): |
| 586 | class_id = 256 |
| 587 | attributes = [ |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 588 | ECA(ShortField("managed_entity_id", None), {AA.R}, |
| 589 | range_check=lambda x: x == 0), |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 590 | 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 Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 593 | 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 Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 611 | optional=True), |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 612 | ] |
| 613 | mandatory_operations = { |
| 614 | OP.Get, OP.Set, OP.Reboot, OP.Test, OP.SynchronizeTime} |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 615 | notifications = {OP.TestResult, OP.AttributeValueChange, |
| 616 | OP.AlarmNotification} |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 617 | |
| 618 | |
| 619 | class Ont2G(EntityClass): |
| 620 | class_id = 257 |
| 621 | attributes = [ |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 622 | ECA(ShortField("managed_entity_id", None), {AA.R}, |
| 623 | range_check=lambda x: x == 0), |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 624 | ECA(StrFixedLenField("equipment_id", None, 20), {AA.R}), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 625 | 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 Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 631 | ECA(ShortField("total_priority_queue_number", None), {AA.R}), |
| 632 | ECA(ByteField("total_traffic_scheduler_number", None), {AA.R}), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 633 | 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 Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 643 | ] |
| 644 | mandatory_operations = {OP.Get, OP.Set} |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 645 | notifications = {OP.AttributeValueChange} |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 646 | |
| 647 | |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 648 | class Tcont(EntityClass): |
| 649 | class_id = 262 |
| 650 | attributes = [ |
| 651 | ECA(ShortField("managed_entity_id", None), {AA.R}), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 652 | 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 Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 656 | ] |
| 657 | mandatory_operations = {OP.Get, OP.Set} |
| 658 | |
| 659 | |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 660 | class 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 Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 667 | 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 Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 676 | ECA(ShortField("optical_signal_level", None), {AA.R}), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 677 | 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 Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 683 | ] |
| 684 | mandatory_operations = {OP.Get, OP.Set, OP.Test} |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 685 | notifications = {OP.AttributeValueChange, OP.AlarmNotification} |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 686 | |
| 687 | |
| 688 | class UniG(EntityClass): |
| 689 | class_id = 264 |
| 690 | attributes = [ |
| 691 | ECA(ShortField("managed_entity_id", None), {AA.R}), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 692 | ECA(ShortField("configuration_option_status", None), {AA.R, AA.W}, |
| 693 | deprecated=True), |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 694 | ECA(ByteField("administrative_state", None), {AA.R, AA.W}), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 695 | 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 Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 700 | ] |
| 701 | mandatory_operations = {OP.Get, OP.Set} |
| 702 | |
| 703 | |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 704 | class GemInterworkingTp(EntityClass): |
| 705 | class_id = 266 |
| 706 | attributes = [ |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 707 | ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}), |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 708 | ECA(ShortField("gem_port_network_ctp_pointer", None), |
| 709 | {AA.R, AA.W, AA.SBC}), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 710 | ECA(ByteField("interworking_option", None), {AA.R, AA.W, AA.SBC}, |
| 711 | range_check=lambda x: 0 <= x <= 7), |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 712 | 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 Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 715 | ECA(ByteField("operational_state", None), {AA.R}, optional=True, |
| 716 | range_check=lambda x: 0 <= x <= 1, avc=True), |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 717 | ECA(ShortField("gal_profile_pointer", None), {AA.R, AA.W, AA.SBC}), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 718 | ECA(ByteField("gal_loopback_configuration", 0), |
| 719 | {AA.R, AA.W}, range_check=lambda x: 0 <= x <= 1), |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 720 | ] |
Chip Boling | eada0c9 | 2017-12-27 09:45:26 -0600 | [diff] [blame] | 721 | mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set} |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 722 | notifications = {OP.AttributeValueChange, OP.AlarmNotification} |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 723 | |
| 724 | |
| 725 | class 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 Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 731 | ECA(ByteField("direction", None), {AA.R, AA.W, AA.SBC}, |
| 732 | range_check=lambda x: 1 <= x <= 3), |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 733 | 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 Knuth | 61a039c | 2017-03-23 13:50:29 -0700 | [diff] [blame] | 740 | ECA(ByteField("encryption_state", None), {AA.R}, optional=True), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 741 | 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 Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 745 | ] |
| 746 | mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set} |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 747 | notifications = {OP.AlarmNotification} |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 748 | |
| 749 | |
| 750 | class 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 Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 759 | class PriorityQueueG(EntityClass): |
| 760 | class_id = 277 |
| 761 | attributes = [ |
| 762 | ECA(ShortField("managed_entity_id", None), {AA.R}), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 763 | ECA(ByteField("queue_configuration_option", None), {AA.R}, |
| 764 | range_check=lambda x: 0 <= x <= 1), |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 765 | ECA(ShortField("maximum_queue_size", None), {AA.R}), |
| 766 | ECA(ShortField("allocated_queue_size", None), {AA.R, AA.W}), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 767 | ECA(ShortField("discard_block_counter_reset_interval", None), {AA.R, AA.W}), |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 768 | ECA(ShortField("threshold_value_for_discarded_blocks", None), {AA.R, AA.W}), |
| 769 | ECA(IntField("related_port", None), {AA.R}), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 770 | 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 Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 775 | 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 Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 777 | # 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 Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 784 | ] |
| 785 | mandatory_operations = {OP.Get, OP.Set} |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 786 | notifications = {OP.AlarmNotification} |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 787 | |
| 788 | |
| 789 | class 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 Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 795 | 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 Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 798 | ] |
| 799 | mandatory_operations = {OP.Get, OP.Set} |
| 800 | |
| 801 | |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 802 | class MulticastGemInterworkingTp(EntityClass): |
| 803 | class_id = 281 |
| 804 | attributes = [ |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 805 | ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}, |
| 806 | range_check=lambda x: x != OmciNullPointer), |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 807 | ECA(ShortField("gem_port_network_ctp_pointer", None), {AA.R, AA.SBC}), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 808 | 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 Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 816 | ECA(ShortField("gal_profile_pointer", None), {AA.R, AA.W, AA.SBC}), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 817 | ECA(ByteField("gal_loopback_configuration", None), {AA.R, AA.W, AA.SBC}, |
| 818 | deprecated=True), |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 819 | # 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 Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 823 | optional_operations = {OP.SetTable} |
| 824 | notifications = {OP.AttributeValueChange, OP.AlarmNotification} |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 825 | |
| 826 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 827 | class 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 Boling | c7d3e2d | 2018-04-06 10:16:29 -0500 | [diff] [blame] | 844 | def to_json(self): |
Chip Boling | bed4c6b | 2018-05-09 08:52:16 -0500 | [diff] [blame] | 845 | return json.dumps(self.fields, separators=(',', ':')) |
Chip Boling | c7d3e2d | 2018-04-06 10:16:29 -0500 | [diff] [blame] | 846 | |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 847 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 848 | class 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 Boling | c7d3e2d | 2018-04-06 10:16:29 -0500 | [diff] [blame] | 864 | def to_json(self): |
Chip Boling | bed4c6b | 2018-05-09 08:52:16 -0500 | [diff] [blame] | 865 | return json.dumps(self.fields, separators=(',', ':')) |
Chip Boling | c7d3e2d | 2018-04-06 10:16:29 -0500 | [diff] [blame] | 866 | |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 867 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 868 | class 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 Boling | c7d3e2d | 2018-04-06 10:16:29 -0500 | [diff] [blame] | 880 | def to_json(self): |
Chip Boling | bed4c6b | 2018-05-09 08:52:16 -0500 | [diff] [blame] | 881 | return json.dumps(self.fields, separators=(',', ':')) |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 882 | |
Chip Boling | 9b7a11a | 2018-04-15 13:33:21 -0500 | [diff] [blame] | 883 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 884 | class DownstreamIgmpMulticastTci(Packet): |
| 885 | name = "DownstreamIgmpMulticastTci" |
| 886 | fields_desc = [ |
| 887 | ByteField("ctrl_type", None), |
| 888 | ShortField("tci", None) |
| 889 | ] |
| 890 | |
Chip Boling | c7d3e2d | 2018-04-06 10:16:29 -0500 | [diff] [blame] | 891 | def to_json(self): |
Chip Boling | bed4c6b | 2018-05-09 08:52:16 -0500 | [diff] [blame] | 892 | return json.dumps(self.fields, separators=(',', ':')) |
Chip Boling | c7d3e2d | 2018-04-06 10:16:29 -0500 | [diff] [blame] | 893 | |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 894 | |
Steve Crooks | 89b94b7 | 2017-02-01 10:06:30 -0500 | [diff] [blame] | 895 | class MulticastOperationsProfile(EntityClass): |
| 896 | class_id = 309 |
| 897 | attributes = [ |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 898 | 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 Crooks | 89b94b7 | 2017-02-01 10:06:30 -0500 | [diff] [blame] | 906 | ECA(ShortField("us_igmp_tci", None), {AA.R, AA.W, AA.SBC}, optional=True), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 907 | ECA(ByteField("us_igmp_tag_ctrl", None), {AA.R, AA.W, AA.SBC}, |
| 908 | range_check=lambda x: 0 <= x <= 3, optional=True), |
Steve Crooks | 89b94b7 | 2017-02-01 10:06:30 -0500 | [diff] [blame] | 909 | 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 Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 917 | 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 Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 924 | ECA(StrFixedLenField("ds_igmp_mcast_tci", None, 3), {AA.R, AA.W, AA.SBC}, optional=True) |
Steve Crooks | 89b94b7 | 2017-02-01 10:06:30 -0500 | [diff] [blame] | 925 | ] |
| 926 | mandatory_operations = {OP.Create, OP.Delete, OP.Set, OP.Get, OP.GetNext} |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 927 | optional_operations = {OP.SetTable} |
| 928 | notifications = {OP.AlarmNotification} |
| 929 | |
Steve Crooks | 89b94b7 | 2017-02-01 10:06:30 -0500 | [diff] [blame] | 930 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 931 | class 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 Boling | c7d3e2d | 2018-04-06 10:16:29 -0500 | [diff] [blame] | 945 | def to_json(self): |
Chip Boling | bed4c6b | 2018-05-09 08:52:16 -0500 | [diff] [blame] | 946 | return json.dumps(self.fields, separators=(',', ':')) |
Chip Boling | c7d3e2d | 2018-04-06 10:16:29 -0500 | [diff] [blame] | 947 | |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 948 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 949 | class 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 Boling | c7d3e2d | 2018-04-06 10:16:29 -0500 | [diff] [blame] | 963 | def to_json(self): |
Chip Boling | bed4c6b | 2018-05-09 08:52:16 -0500 | [diff] [blame] | 964 | return json.dumps(self.fields, separators=(',', ':')) |
Chip Boling | c7d3e2d | 2018-04-06 10:16:29 -0500 | [diff] [blame] | 965 | |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 966 | |
Steve Crooks | 9e85ce8 | 2017-03-20 12:00:53 -0400 | [diff] [blame] | 967 | class 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 Crooks | 89b94b7 | 2017-02-01 10:06:30 -0500 | [diff] [blame] | 980 | |
Chip Boling | c7d3e2d | 2018-04-06 10:16:29 -0500 | [diff] [blame] | 981 | def to_json(self): |
Chip Boling | bed4c6b | 2018-05-09 08:52:16 -0500 | [diff] [blame] | 982 | return json.dumps(self.fields, separators=(',', ':')) |
Chip Boling | c7d3e2d | 2018-04-06 10:16:29 -0500 | [diff] [blame] | 983 | |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 984 | |
Steve Crooks | 89b94b7 | 2017-02-01 10:06:30 -0500 | [diff] [blame] | 985 | class MulticastSubscriberConfigInfo(EntityClass): |
| 986 | class_id = 310 |
| 987 | attributes = [ |
| 988 | ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 989 | 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 Crooks | 89b94b7 | 2017-02-01 10:06:30 -0500 | [diff] [blame] | 997 | # TODO: need to make table and add column data |
| 998 | ECA(StrFixedLenField( |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 999 | "multicast_service_package_table", None, 20), {AA.R, AA.W}), |
Steve Crooks | 89b94b7 | 2017-02-01 10:06:30 -0500 | [diff] [blame] | 1000 | # TODO: need to make table and add column data |
| 1001 | ECA(StrFixedLenField( |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 1002 | "allowed_preview_groups_table", None, 22), {AA.R, AA.W}), |
Steve Crooks | 89b94b7 | 2017-02-01 10:06:30 -0500 | [diff] [blame] | 1003 | ] |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 1004 | mandatory_operations = {OP.Create, OP.Delete, OP.Set, OP.Get, OP.GetNext, |
| 1005 | OP.SetTable} |
Steve Crooks | 89b94b7 | 2017-02-01 10:06:30 -0500 | [diff] [blame] | 1006 | |
| 1007 | |
| 1008 | class VirtualEthernetInterfacePt(EntityClass): |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 1009 | class_id = 329 |
| 1010 | attributes = [ |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 1011 | 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 Crooks | 89b94b7 | 2017-02-01 10:06:30 -0500 | [diff] [blame] | 1017 | 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 Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 1021 | ] |
Steve Crooks | 89b94b7 | 2017-02-01 10:06:30 -0500 | [diff] [blame] | 1022 | mandatory_operations = {OP.Get, OP.Set} |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 1023 | notifications = {OP.AttributeValueChange, OP.AlarmNotification} |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 1024 | |
| 1025 | |
Chip Boling | 2815586 | 2018-06-07 11:13:39 -0500 | [diff] [blame^] | 1026 | class 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 Boling | f0b3a06 | 2018-01-18 13:53:58 -0600 | [diff] [blame] | 1051 | class EnhSecurityControl(EntityClass): |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 1052 | class_id = 332 |
| 1053 | attributes = [ |
Steve Crooks | 89b94b7 | 2017-02-01 10:06:30 -0500 | [diff] [blame] | 1054 | ECA(ShortField("managed_entity_id", None), {AA.R}), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 1055 | ECA(BitField("olt_crypto_capabilities", None, 16*8), {AA.W}), |
Steve Crooks | 89b94b7 | 2017-02-01 10:06:30 -0500 | [diff] [blame] | 1056 | # TODO: need to make table and add column data |
| 1057 | ECA(StrFixedLenField( |
| 1058 | "olt_random_challenge_table", None, 17), {AA.R, AA.W}), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 1059 | ECA(ByteField("olt_challenge_status", 0), {AA.R, AA.W}, |
| 1060 | range_check=lambda x: 0 <= x <= 1), |
Steve Crooks | 89b94b7 | 2017-02-01 10:06:30 -0500 | [diff] [blame] | 1061 | ECA(ByteField("onu_selected_crypto_capabilities", None), {AA.R}), |
| 1062 | # TODO: need to make table and add column data |
| 1063 | ECA(StrFixedLenField( |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 1064 | "onu_random_challenge_table", None, 16), {AA.R}, avc=True), |
Steve Crooks | 89b94b7 | 2017-02-01 10:06:30 -0500 | [diff] [blame] | 1065 | # TODO: need to make table and add column data |
| 1066 | ECA(StrFixedLenField( |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 1067 | "onu_authentication_result_table", None, 16), {AA.R}, avc=True), |
Steve Crooks | 89b94b7 | 2017-02-01 10:06:30 -0500 | [diff] [blame] | 1068 | # TODO: need to make table and add column data |
| 1069 | ECA(StrFixedLenField( |
| 1070 | "olt_authentication_result_table", None, 17), {AA.W}), |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 1071 | 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 Crooks | 89b94b7 | 2017-02-01 10:06:30 -0500 | [diff] [blame] | 1075 | ECA(StrFixedLenField( |
| 1076 | "master_session_key_name", None, 16), {AA.R}), |
| 1077 | ECA(StrFixedLenField( |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 1078 | "broadcast_key_table", None, 18), {AA.R, AA.W}), |
| 1079 | ECA(ShortField("effective_key_length", None), {AA.R}), |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 1080 | |
| 1081 | ] |
Steve Crooks | 89b94b7 | 2017-02-01 10:06:30 -0500 | [diff] [blame] | 1082 | mandatory_operations = {OP.Set, OP.Get, OP.GetNext} |
Chip Boling | e2e64a0 | 2018-02-06 12:58:07 -0600 | [diff] [blame] | 1083 | notifications = {OP.AttributeValueChange} |
Zsolt Haraszti | 578a46c | 2016-12-20 16:38:43 -0800 | [diff] [blame] | 1084 | |
Zsolt Haraszti | e0acd8f | 2016-12-16 14:53:55 -0800 | [diff] [blame] | 1085 | # entity class lookup table from entity_class values |
| 1086 | entity_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 | |
| 1093 | entity_classes = [c for c in entity_classes_name_map.itervalues()] |
| 1094 | entity_id_to_class_map = dict((c.class_id, c) for c in entity_classes) |