Shad Ansari | 4dade92 | 2017-12-13 19:06:49 +0000 | [diff] [blame^] | 1 | # |
| 2 | # Copyright 2017 the original author or authors. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | import inspect |
| 17 | |
| 18 | import sys |
| 19 | from binascii import hexlify |
| 20 | from scapy.fields import ByteField, ShortField, MACField, BitField, IPField |
| 21 | from scapy.fields import IntField, StrFixedLenField |
| 22 | from scapy.packet import Packet |
| 23 | |
| 24 | from voltha.extensions.omci.omci_defs import OmciUninitializedFieldError, \ |
| 25 | AttributeAccess, OmciNullPointer, EntityOperations |
| 26 | from voltha.extensions.omci.omci_defs import bitpos_from_mask |
| 27 | |
| 28 | |
| 29 | class EntityClassAttribute(object): |
| 30 | |
| 31 | def __init__(self, fld, access=set(), optional=False): |
| 32 | self._fld = fld |
| 33 | self._access = access |
| 34 | self._optional = optional |
| 35 | |
| 36 | |
| 37 | class EntityClassMeta(type): |
| 38 | """ |
| 39 | Metaclass for EntityClass to generate secondary class attributes |
| 40 | for class attributes of the derived classes. |
| 41 | """ |
| 42 | def __init__(cls, name, bases, dct): |
| 43 | super(EntityClassMeta, cls).__init__(name, bases, dct) |
| 44 | |
| 45 | # initialize attribute_name_to_index_map |
| 46 | cls.attribute_name_to_index_map = dict( |
| 47 | (a._fld.name, idx) for idx, a in enumerate(cls.attributes)) |
| 48 | |
| 49 | |
| 50 | class EntityClass(object): |
| 51 | |
| 52 | class_id = 'to be filled by subclass' |
| 53 | attributes = [] |
| 54 | mandatory_operations = {} |
| 55 | optional_operations = {} |
| 56 | |
| 57 | # will be map of attr_name -> index in attributes, initialized by metaclass |
| 58 | attribute_name_to_index_map = None |
| 59 | __metaclass__ = EntityClassMeta |
| 60 | |
| 61 | def __init__(self, **kw): |
| 62 | assert(isinstance(kw, dict)) |
| 63 | for k, v in kw.iteritems(): |
| 64 | assert(k in self.attribute_name_to_index_map) |
| 65 | self._data = kw |
| 66 | |
| 67 | def serialize(self, mask=None, operation=None): |
| 68 | bytes = '' |
| 69 | |
| 70 | # generate ordered list of attribute indices needed to be processed |
| 71 | # if mask is provided, we use that explicitly |
| 72 | # if mask is not provided, we determine attributes from the self._data |
| 73 | # content also taking into account the type of operation in hand |
| 74 | if mask is not None: |
| 75 | attribute_indices = EntityClass.attribute_indices_from_mask(mask) |
| 76 | else: |
| 77 | attribute_indices = self.attribute_indices_from_data() |
| 78 | |
| 79 | # Serialize each indexed field (ignoring entity id) |
| 80 | for index in attribute_indices: |
| 81 | field = self.attributes[index]._fld |
| 82 | try: |
| 83 | value = self._data[field.name] |
| 84 | except KeyError: |
| 85 | raise OmciUninitializedFieldError( |
| 86 | 'Entity field "{}" not set'.format(field.name) ) |
| 87 | bytes = field.addfield(None, bytes, value) |
| 88 | |
| 89 | return bytes |
| 90 | |
| 91 | def attribute_indices_from_data(self): |
| 92 | return sorted( |
| 93 | self.attribute_name_to_index_map[attr_name] |
| 94 | for attr_name in self._data.iterkeys()) |
| 95 | |
| 96 | byte1_mask_to_attr_indices = dict( |
| 97 | (m, bitpos_from_mask(m, 8, -1)) for m in range(256)) |
| 98 | byte2_mask_to_attr_indices = dict( |
| 99 | (m, bitpos_from_mask(m, 16, -1)) for m in range(256)) |
| 100 | @classmethod |
| 101 | def attribute_indices_from_mask(cls, mask): |
| 102 | # each bit in the 2-byte field denote an attribute index; we use a |
| 103 | # lookup table to make lookup a bit faster |
| 104 | return \ |
| 105 | cls.byte1_mask_to_attr_indices[(mask >> 8) & 0xff] + \ |
| 106 | cls.byte2_mask_to_attr_indices[(mask & 0xff)] |
| 107 | |
| 108 | @classmethod |
| 109 | def mask_for(cls, *attr_names): |
| 110 | """ |
| 111 | Return mask value corresponding to given attributes names |
| 112 | :param attr_names: Attribute names |
| 113 | :return: integer mask value |
| 114 | """ |
| 115 | mask = 0 |
| 116 | for attr_name in attr_names: |
| 117 | index = cls.attribute_name_to_index_map[attr_name] |
| 118 | mask |= (1 << (16 - index)) |
| 119 | return mask |
| 120 | |
| 121 | |
| 122 | # abbreviations |
| 123 | ECA = EntityClassAttribute |
| 124 | AA = AttributeAccess |
| 125 | OP = EntityOperations |
| 126 | |
| 127 | |
| 128 | class OntData(EntityClass): |
| 129 | class_id = 2 |
| 130 | attributes = [ |
| 131 | ECA(ShortField("managed_entity_id", None), {AA.R}), |
| 132 | ECA(ByteField("mib_data_sync", 0), {AA.R, AA.W}) |
| 133 | ] |
| 134 | mandatory_operations = {OP.Get, OP.Set, |
| 135 | OP.GetAllAlarms, OP.GetAllAlarmsNext, |
| 136 | OP.MibReset, OP.MibUpload, OP.MibUploadNext} |
| 137 | |
| 138 | |
| 139 | class Cardholder(EntityClass): |
| 140 | class_id = 5 |
| 141 | attributes = [ |
| 142 | ECA(ShortField("managed_entity_id", None), {AA.R}), |
| 143 | ECA(ByteField("actual_plugin_unit_type", None), {AA.R}), |
| 144 | ECA(ByteField("expected_plugin_unit_type", None), {AA.R, AA.W}), |
| 145 | ECA(ByteField("expected_port_count", None), {AA.R, AA.W}, |
| 146 | optional=True), |
| 147 | ECA(StrFixedLenField("expected_equipment_id", None, 20), {AA.R, AA.W}, |
| 148 | optional=True), |
| 149 | ECA(StrFixedLenField("actual_equipment_id", None, 20), {AA.R}, |
| 150 | optional=True), |
| 151 | ECA(ByteField("protection_profile_pointer", None), {AA.R}, |
| 152 | optional=True), |
| 153 | ECA(ByteField("invoke_protection_switch", None), {AA.R, AA.W}, |
| 154 | optional=True), |
| 155 | ECA(ByteField("arc", None), {AA.R, AA.W}), |
| 156 | ECA(ByteField("arc_interval", None), {AA.R, AA.W}), |
| 157 | ] |
| 158 | mandatory_operations = {OP.Get, OP.Set} |
| 159 | |
| 160 | |
| 161 | class CircuitPack(EntityClass): |
| 162 | class_id = 6 |
| 163 | attributes = [ |
| 164 | ECA(StrFixedLenField("managed_entity_id", None, 22), {AA.R, AA.SBC}), |
| 165 | ECA(ByteField("type", None), {AA.R, AA.SBC}), |
| 166 | ECA(ByteField("number_of_ports", None), {AA.R}, optional=True), |
| 167 | ECA(StrFixedLenField("serial_number", None, 8), {AA.R}), |
| 168 | ECA(StrFixedLenField("version", None, 14), {AA.R}), |
| 169 | ECA(StrFixedLenField("vendor_id", None, 4), {AA.R}), |
| 170 | ECA(ByteField("administrative_state", None), {AA.R, AA.W, AA.SBC}), |
| 171 | ECA(ByteField("operational_state", None), {AA.R}, optional=True), |
| 172 | ECA(ByteField("bridged_or_ip_ind", None), {AA.R, AA.W}, optional=True), |
| 173 | ECA(StrFixedLenField("equipment_id", None, 20), {AA.R}, optional=True), |
| 174 | ECA(ByteField("card_configuration", None), {AA.R, AA.W, AA.SBC}), # not really mandatory, see spec |
| 175 | ECA(ByteField("total_tcont_buffer_number", None), {AA.R}), |
| 176 | ECA(ByteField("total_priority_queue_number", None), {AA.R}), |
| 177 | ECA(ByteField("total_traffic_scheduler_number", None), {AA.R}), |
| 178 | ECA(IntField("power_sched_override", None), {AA.R, AA.W}, |
| 179 | optional=True) |
| 180 | ] |
| 181 | mandatory_operations = {OP.Get, OP.Set, OP.Reboot} |
| 182 | optional_operations = {OP.Create, OP.Delete, OP.Test} |
| 183 | |
| 184 | |
| 185 | class SoftwareImage(EntityClass): |
| 186 | class_id = 7 |
| 187 | attributes = [ |
| 188 | ECA(ShortField("managed_entity_id", None), {AA.R}), |
| 189 | ECA(StrFixedLenField("version", None, 14), {AA.R}), |
| 190 | ECA(ByteField("is_committed", None), {AA.R}), |
| 191 | ECA(ByteField("is_active", None), {AA.R}), |
| 192 | ECA(ByteField("is_valid", None), {AA.R}), |
| 193 | ] |
| 194 | mandatory_operations = {OP.Get} |
| 195 | |
| 196 | class PptpEthernetUni(EntityClass): |
| 197 | class_id = 11 |
| 198 | attributes = [ |
| 199 | ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}), |
| 200 | ECA(ByteField("expected_type", 0), {AA.R, AA.W}), |
| 201 | ECA(ByteField("sensed_type", 0), {AA.R}), |
| 202 | ECA(ByteField("autodetection_config", 0), {AA.R}), |
| 203 | ECA(ByteField("ethernet_loopback_config", 0), {AA.R}), |
| 204 | ECA(ByteField("administrative_state", 1), {AA.R, AA.W}), |
| 205 | ECA(ByteField("operational_state", 1), {AA.R, AA.W}), |
| 206 | ECA(ByteField("config_ind", 4), {AA.R}), |
| 207 | ECA(ByteField("max_frame_size", 1518), {AA.R, AA.W}), |
| 208 | ECA(ByteField("dte_dce_ind", 0), {AA.R, AA.W}), |
| 209 | ECA(ShortField("pause_time", 0), {AA.R, AA.W}), |
| 210 | ECA(ByteField("bridged_ip_ind", 2), {AA.R, AA.W}), |
| 211 | ECA(ByteField("arc", 0), {AA.R, AA.W}), |
| 212 | ECA(ByteField("arc_interval", 0), {AA.R, AA.W}), |
| 213 | ECA(ByteField("pppoe_filter", 0), {AA.R, AA.W}), |
| 214 | ECA(ByteField("power_control", 0), {AA.R, AA.W}), |
| 215 | ] |
| 216 | mandatory_operations = {OP.Get, OP.Set} |
| 217 | |
| 218 | class MacBridgeServiceProfile(EntityClass): |
| 219 | class_id = 45 |
| 220 | attributes = [ |
| 221 | ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}), |
| 222 | ECA(ByteField("spanning_tree_ind", False), |
| 223 | {AA.R, AA.W, AA.SetByCreate}), |
| 224 | ECA(ByteField("learning_ind", False), {AA.R, AA.W, AA.SetByCreate}), |
| 225 | ECA(ByteField("port_bridging_ind", False), |
| 226 | {AA.R, AA.W, AA.SetByCreate}), |
| 227 | ECA(ShortField("priority", None), {AA.R, AA.W, AA.SetByCreate}), |
| 228 | ECA(ShortField("max_age", None), {AA.R, AA.W, AA.SetByCreate}), |
| 229 | ECA(ShortField("hello_time", None), {AA.R, AA.W, AA.SetByCreate}), |
| 230 | ECA(ShortField("forward_delay", None), {AA.R, AA.W, AA.SetByCreate}), |
| 231 | ECA(ByteField("unknown_mac_address_discard", False), |
| 232 | {AA.R, AA.W, AA.SetByCreate}), |
| 233 | ECA(ByteField("mac_learning_depth", 0), |
| 234 | {AA.R, AA.W, AA.SetByCreate}, optional=True) |
| 235 | |
| 236 | ] |
| 237 | mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set} |
| 238 | |
| 239 | |
| 240 | class MacBridgePortConfigurationData(EntityClass): |
| 241 | class_id = 47 |
| 242 | attributes = [ |
| 243 | ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}), |
| 244 | ECA(ShortField("bridge_id_pointer", None), {AA.R, AA.W, AA.SBC}), |
| 245 | ECA(ByteField("port_num", None), {AA.R, AA.W, AA.SBC}), |
| 246 | ECA(ByteField("tp_type", None), {AA.R, AA.W, AA.SBC}), |
| 247 | ECA(ShortField("tp_pointer", None), {AA.R, AA.W, AA.SBC}), |
| 248 | ECA(ShortField("port_priority", None), {AA.R, AA.W, AA.SBC}), |
| 249 | ECA(ShortField("port_path_cost", None), {AA.R, AA.W, AA.SBC}), |
| 250 | ECA(ByteField("port_spanning_tree_in", None), {AA.R, AA.W, AA.SBC}), |
| 251 | ECA(ByteField("encapsulation_methods", None), {AA.R, AA.W, AA.SBC}, |
| 252 | optional=True), |
| 253 | ECA(ByteField("lan_fcs_ind", None), {AA.R, AA.W, AA.SBC}, |
| 254 | optional=True), |
| 255 | ECA(MACField("port_mac_address", None), {AA.R}, optional=True), |
| 256 | ECA(ShortField("outbound_td_pointer", None), {AA.R, AA.W}, |
| 257 | optional=True), |
| 258 | ECA(ShortField("inbound_td_pointer", None), {AA.R, AA.W}, |
| 259 | optional=True), |
| 260 | ] |
| 261 | mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set} |
| 262 | |
| 263 | |
| 264 | class VlanTaggingFilterData(EntityClass): |
| 265 | class_id = 84 |
| 266 | attributes = [ |
| 267 | ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}), |
| 268 | ECA(ShortField("vlan_filter_0", None), {AA.R, AA.W, AA.SBC}), |
| 269 | ECA(ShortField("vlan_filter_1", None), {AA.R, AA.W, AA.SBC}), |
| 270 | ECA(ShortField("vlan_filter_2", None), {AA.R, AA.W, AA.SBC}), |
| 271 | ECA(ShortField("vlan_filter_3", None), {AA.R, AA.W, AA.SBC}), |
| 272 | ECA(ShortField("vlan_filter_4", None), {AA.R, AA.W, AA.SBC}), |
| 273 | ECA(ShortField("vlan_filter_5", None), {AA.R, AA.W, AA.SBC}), |
| 274 | ECA(ShortField("vlan_filter_6", None), {AA.R, AA.W, AA.SBC}), |
| 275 | ECA(ShortField("vlan_filter_7", None), {AA.R, AA.W, AA.SBC}), |
| 276 | ECA(ShortField("vlan_filter_8", None), {AA.R, AA.W, AA.SBC}), |
| 277 | ECA(ShortField("vlan_filter_9", None), {AA.R, AA.W, AA.SBC}), |
| 278 | ECA(ShortField("vlan_filter_10", None), {AA.R, AA.W, AA.SBC}), |
| 279 | ECA(ShortField("vlan_filter_11", None), {AA.R, AA.W, AA.SBC}), |
| 280 | ECA(ByteField("forward_operation", None), {AA.R, AA.W, AA.SBC}), |
| 281 | ECA(ByteField("number_of_entries", None), {AA.R, AA.W, AA.SBC}) |
| 282 | ] |
| 283 | mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set} |
| 284 | |
| 285 | |
| 286 | class Ieee8021pMapperServiceProfile(EntityClass): |
| 287 | class_id = 130 |
| 288 | attributes = [ |
| 289 | ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}), |
| 290 | ECA(ShortField("tp_pointer", OmciNullPointer), |
| 291 | {AA.R, AA.W, AA.SetByCreate}), |
| 292 | ECA(ShortField( |
| 293 | "interwork_tp_pointer_for_p_bit_priority_0", OmciNullPointer), |
| 294 | {AA.R, AA.W, AA.SetByCreate}), |
| 295 | ECA(ShortField( |
| 296 | "interwork_tp_pointer_for_p_bit_priority_1", OmciNullPointer), |
| 297 | {AA.R, AA.W, AA.SetByCreate}), |
| 298 | ECA(ShortField( |
| 299 | "interwork_tp_pointer_for_p_bit_priority_2", OmciNullPointer), |
| 300 | {AA.R, AA.W, AA.SetByCreate}), |
| 301 | ECA(ShortField( |
| 302 | "interwork_tp_pointer_for_p_bit_priority_3", OmciNullPointer), |
| 303 | {AA.R, AA.W, AA.SetByCreate}), |
| 304 | ECA(ShortField( |
| 305 | "interwork_tp_pointer_for_p_bit_priority_4", OmciNullPointer), |
| 306 | {AA.R, AA.W, AA.SetByCreate}), |
| 307 | ECA(ShortField( |
| 308 | "interwork_tp_pointer_for_p_bit_priority_5", OmciNullPointer), |
| 309 | {AA.R, AA.W, AA.SetByCreate}), |
| 310 | ECA(ShortField( |
| 311 | "interwork_tp_pointer_for_p_bit_priority_6", OmciNullPointer), |
| 312 | {AA.R, AA.W, AA.SetByCreate}), |
| 313 | ECA(ShortField( |
| 314 | "interwork_tp_pointer_for_p_bit_priority_7", OmciNullPointer), |
| 315 | {AA.R, AA.W, AA.SetByCreate}), |
| 316 | ECA(ByteField("unmarked_frame_option", None), |
| 317 | {AA.R, AA.W, AA.SetByCreate}), |
| 318 | ECA(StrFixedLenField("dscp_to_p_bit_mapping", None, length=24), |
| 319 | {AA.R, AA.W}), |
| 320 | ECA(ByteField("default_p_bit_marking", None), |
| 321 | {AA.R, AA.W, AA.SetByCreate}), |
| 322 | ECA(ByteField("tp_type", None), {AA.R, AA.W, AA.SetByCreate}, |
| 323 | optional=True) |
| 324 | ] |
| 325 | mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set} |
| 326 | |
| 327 | |
| 328 | class OltG(EntityClass): |
| 329 | class_id = 131 |
| 330 | attributes = [ |
| 331 | ECA(ShortField("managed_entity_id", None), {AA.R}), |
| 332 | ECA(StrFixedLenField("olt_vendor_id", None, 4), {AA.R, AA.W}), |
| 333 | ECA(StrFixedLenField("equipment_id", None, 20), {AA.R, AA.W}), |
| 334 | ECA(StrFixedLenField("version", None, 14), {AA.R, AA.W}), |
| 335 | ECA(StrFixedLenField("time_of_day", None, 14), {AA.R, AA.W}) |
| 336 | ] |
| 337 | mandatory_operations = {OP.Get, OP.Set} |
| 338 | |
| 339 | |
| 340 | class OntPowerShedding(EntityClass): |
| 341 | class_id = 133 |
| 342 | attributes = [ |
| 343 | ECA(ShortField("managed_entity_id", None), {AA.R}), |
| 344 | ECA(ShortField("restore_power_time_reset_interval", None), |
| 345 | {AA.R, AA.W}), |
| 346 | ECA(ShortField("data_class_shedding_interval", None), {AA.R, AA.W}), |
| 347 | ECA(ShortField("voice_class_shedding_interval", None), {AA.R, AA.W}), |
| 348 | ECA(ShortField("video_overlay_class_shedding_interval", None), {AA.R, AA.W}), |
| 349 | ECA(ShortField("video_return_class_shedding_interval", None), {AA.R, AA.W}), |
| 350 | ECA(ShortField("dsl_class_shedding_interval", None), {AA.R, AA.W}), |
| 351 | ECA(ShortField("atm_class_shedding_interval", None), {AA.R, AA.W}), |
| 352 | ECA(ShortField("ces_class_shedding_interval", None), {AA.R, AA.W}), |
| 353 | ECA(ShortField("frame_class_shedding_interval", None), {AA.R, AA.W}), |
| 354 | ECA(ShortField("sonet_class_shedding_interval", None), {AA.R, AA.W}), |
| 355 | ECA(ShortField("shedding_status", None), {AA.R, AA.W}), |
| 356 | ] |
| 357 | mandatory_operations = {OP.Get, OP.Set} |
| 358 | |
| 359 | |
| 360 | class IpHostConfigData(EntityClass): |
| 361 | class_id = 134 |
| 362 | attributes = [ |
| 363 | ECA(ShortField("managed_entity_id", None), {AA.R}), |
| 364 | ECA(ByteField("ip_options", None), {AA.R, AA.W}), |
| 365 | ECA(MACField("mac_address", None), {AA.R}), |
| 366 | ECA(StrFixedLenField("ont_identifier", None, 25), {AA.R, AA.W}), |
| 367 | ECA(IPField("ip_address", None), {AA.R, AA.W}), |
| 368 | ECA(IPField("mask", None), {AA.R, AA.W}), |
| 369 | ECA(IPField("gateway", None), {AA.R, AA.W}), |
| 370 | ECA(IPField("primary_dns", None), {AA.R, AA.W}), |
| 371 | ECA(IPField("secondary_dns", None), {AA.R, AA.W}), |
| 372 | ECA(IPField("current_address", None), {AA.R}), |
| 373 | ECA(IPField("current_mask", None), {AA.R}), |
| 374 | ECA(IPField("current_gateway", None), {AA.R}), |
| 375 | ECA(IPField("current_primary_dns", None), {AA.R}), |
| 376 | ECA(IPField("current_secondary_dns", None), {AA.R}), |
| 377 | ECA(StrFixedLenField("domain_name", None, 25), {AA.R}), |
| 378 | ECA(StrFixedLenField("host_name", None, 25), {AA.R}), |
| 379 | |
| 380 | ] |
| 381 | mandatory_operations = {OP.Get, OP.Set, OP.Test} |
| 382 | |
| 383 | |
| 384 | class VlanTaggingOperation(Packet): |
| 385 | name = "VlanTaggingOperation" |
| 386 | fields_desc = [ |
| 387 | BitField("filter_outer_priority", 0, 4), |
| 388 | BitField("filter_outer_vid", 0, 13), |
| 389 | BitField("filter_outer_tpid_de", 0, 3), |
| 390 | BitField("pad1", 0, 12), |
| 391 | |
| 392 | BitField("filter_inner_priority", 0, 4), |
| 393 | BitField("filter_inner_vid", 0, 13), |
| 394 | BitField("filter_inner_tpid_de", 0, 3), |
| 395 | BitField("pad2", 0, 8), |
| 396 | BitField("filter_ether_type", 0, 4), |
| 397 | |
| 398 | BitField("treatment_tags_to_remove", 0, 2), |
| 399 | BitField("pad3", 0, 10), |
| 400 | BitField("treatment_outer_priority", 0, 4), |
| 401 | BitField("treatment_outer_vid", 0, 13), |
| 402 | BitField("treatment_outer_tpid_de", 0, 3), |
| 403 | |
| 404 | BitField("pad4", 0, 12), |
| 405 | BitField("treatment_inner_priority", 0, 4), |
| 406 | BitField("treatment_inner_vid", 0, 13), |
| 407 | BitField("treatment_inner_tpid_de", 0, 3), |
| 408 | ] |
| 409 | |
| 410 | |
| 411 | class ExtendedVlanTaggingOperationConfigurationData(EntityClass): |
| 412 | class_id = 171 |
| 413 | attributes = [ |
| 414 | ECA(ShortField("managed_entity_id", None), {AA.R, AA.SetByCreate}), |
| 415 | ECA(ByteField("association_type", None), {AA.R, AA.W, AA.SetByCreate}), |
| 416 | ECA(ShortField("received_vlan_tagging_operation_table_max_size", None), |
| 417 | {AA.R}), |
| 418 | ECA(ShortField("input_tpid", None), {AA.R, AA.W}), |
| 419 | ECA(ShortField("output_tpid", None), {AA.R, AA.W}), |
| 420 | ECA(ByteField("downstream_mode", None), {AA.R, AA.W}), |
| 421 | ECA(StrFixedLenField("received_frame_vlan_tagging_operation_table", VlanTaggingOperation, 16), {AA.R, AA.W}), |
| 422 | ECA(ShortField("associated_me_pointer", None), {AA.R, AA.W, AA.SBC}) |
| 423 | ] |
| 424 | mandatory_operations = {OP.Create, OP.Delete, OP.Set, OP.Get, OP.GetNext} |
| 425 | |
| 426 | |
| 427 | class OntG(EntityClass): |
| 428 | class_id = 256 |
| 429 | attributes = [ |
| 430 | ECA(ShortField("managed_entity_id", None), {AA.R}), |
| 431 | ECA(StrFixedLenField("vendor_id", None, 4), {AA.R}), |
| 432 | ECA(StrFixedLenField("version", None, 14), {AA.R}), |
| 433 | ECA(StrFixedLenField("serial_number", None, 8), {AA.R}), |
| 434 | ECA(ByteField("traffic_management_options", None), {AA.R}), |
| 435 | ECA(ByteField("vp_vc_cross_connection_option", None), {AA.R}, |
| 436 | optional=True), |
| 437 | ECA(ByteField("administrative_state", None), {AA.R, AA.W}), |
| 438 | ECA(ByteField("operational_state", None), {AA.R}, optional=True), |
| 439 | ECA(ByteField("ont_survival_time", None), {AA.R}) |
| 440 | ] |
| 441 | mandatory_operations = { |
| 442 | OP.Get, OP.Set, OP.Reboot, OP.Test, OP.SynchronizeTime} |
| 443 | |
| 444 | |
| 445 | class Ont2G(EntityClass): |
| 446 | class_id = 257 |
| 447 | attributes = [ |
| 448 | ECA(ShortField("managed_entity_id", None), {AA.R}), |
| 449 | ECA(StrFixedLenField("equipment_id", None, 20), {AA.R}), |
| 450 | ECA(ByteField("omcc_version", None), {AA.R}), |
| 451 | ECA(ShortField("vendor_product_code", None), {AA.R}, optional=True), |
| 452 | ECA(ByteField("security_capability", None), {AA.R}), |
| 453 | ECA(ByteField("security_mode", None), {AA.R, AA.W}), |
| 454 | ECA(ShortField("total_priority_queue_number", None), {AA.R}), |
| 455 | ECA(ByteField("total_traffic_scheduler_number", None), {AA.R}), |
| 456 | ECA(ByteField("mode", None), {AA.R}), |
| 457 | ECA(ShortField("total_gem_port_id_number", None), {AA.R}, optional=True), |
| 458 | ECA(IntField("sys_uptime", None), {AA.R}, optional=True), |
| 459 | ] |
| 460 | mandatory_operations = {OP.Get, OP.Set} |
| 461 | |
| 462 | |
| 463 | class Tcont(EntityClass): |
| 464 | class_id = 262 |
| 465 | attributes = [ |
| 466 | ECA(ShortField("managed_entity_id", None), {AA.R}), |
| 467 | ECA(ShortField("alloc_id", 0x00ff), {AA.R, AA.W}), |
| 468 | ECA(ByteField("mode_indicator", 1), {AA.R}), |
| 469 | ECA(ByteField("policy", None), {AA.R, AA.W}), # addendum makes it R/W |
| 470 | ] |
| 471 | mandatory_operations = {OP.Get, OP.Set} |
| 472 | |
| 473 | |
| 474 | class AniG(EntityClass): |
| 475 | class_id = 263 |
| 476 | attributes = [ |
| 477 | ECA(ShortField("managed_entity_id", None), {AA.R}), |
| 478 | ECA(ByteField("sr_indication", None), {AA.R}), |
| 479 | ECA(ShortField("total_tcont_number", None), {AA.R}), |
| 480 | ECA(ShortField("gem_block_length", None), {AA.R, AA.W}), |
| 481 | ECA(ByteField("piggyback_dba_reporting", None), {AA.R}), |
| 482 | ECA(ByteField("whole_ont_dba_reporting", None), {AA.R}), |
| 483 | ECA(ByteField("sf_threshold", None), {AA.R, AA.W}), |
| 484 | ECA(ByteField("sd_threshold", None), {AA.R, AA.W}), |
| 485 | ECA(ByteField("arc", None), {AA.R, AA.W}), |
| 486 | ECA(ByteField("arc_interval", None), {AA.R, AA.W}), |
| 487 | ECA(ShortField("optical_signal_level", None), {AA.R}), |
| 488 | ECA(ByteField("lower_optical_threshold", None), {AA.R, AA.W}, optional=True), |
| 489 | ECA(ByteField("upper_optical_threshold", None), {AA.R, AA.W}, optional=True), |
| 490 | ECA(ByteField("ont_response_time", None), {AA.R}, optional=True), |
| 491 | ECA(ShortField("transmit_optical_level", None), {AA.R}, optional=True), |
| 492 | ECA(ByteField("lower_transmit_power_threshold", None), {AA.R, AA.W}, |
| 493 | optional=True), |
| 494 | ECA(ByteField("upper_transmit_power_threshold", None), {AA.R, AA.W}, |
| 495 | optional=True), |
| 496 | ] |
| 497 | mandatory_operations = {OP.Get, OP.Set, OP.Test} |
| 498 | |
| 499 | |
| 500 | class UniG(EntityClass): |
| 501 | class_id = 264 |
| 502 | attributes = [ |
| 503 | ECA(ShortField("managed_entity_id", None), {AA.R}), |
| 504 | ECA(ShortField("configuration_option_status", None), {AA.R, AA.W}), |
| 505 | ECA(ByteField("administrative_state", None), {AA.R, AA.W}), |
| 506 | ] |
| 507 | mandatory_operations = {OP.Get, OP.Set} |
| 508 | |
| 509 | |
| 510 | class GemInterworkingTp(EntityClass): |
| 511 | class_id = 266 |
| 512 | attributes = [ |
| 513 | ECA(ShortField("managed_entity_id", None), {AA.R, AA.SetByCreate}), |
| 514 | ECA(ShortField("gem_port_network_ctp_pointer", None), |
| 515 | {AA.R, AA.W, AA.SBC}), |
| 516 | ECA(ByteField("interworking_option", None), {AA.R, AA.W, AA.SBC}), |
| 517 | ECA(ShortField("service_profile_pointer", None), {AA.R, AA.W, AA.SBC}), |
| 518 | ECA(ShortField("interworking_tp_pointer", None), {AA.R, AA.W, AA.SBC}), |
| 519 | ECA(ByteField("pptp_counter", None), {AA.R}, optional=True), |
| 520 | ECA(ByteField("operational_state", None), {AA.R}, optional=True), |
| 521 | ECA(ShortField("gal_profile_pointer", None), {AA.R, AA.W, AA.SBC}), |
| 522 | ECA(ByteField("gal_loopback_configuration", None), |
| 523 | {AA.R, AA.W}), |
| 524 | ] |
| 525 | mandatory_operations = {} # TODO |
| 526 | |
| 527 | |
| 528 | class GemPortNetworkCtp(EntityClass): |
| 529 | class_id = 268 |
| 530 | attributes = [ |
| 531 | ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}), |
| 532 | ECA(ShortField("port_id", None), {AA.R, AA.W, AA.SBC}), |
| 533 | ECA(ShortField("tcont_pointer", None), {AA.R, AA.W, AA.SBC}), |
| 534 | ECA(ByteField("direction", None), {AA.R, AA.W, AA.SBC}), |
| 535 | ECA(ShortField("traffic_management_pointer_upstream", None), |
| 536 | {AA.R, AA.W, AA.SBC}), |
| 537 | ECA(ShortField("traffic_descriptor_profile_pointer", None), |
| 538 | {AA.R, AA.W, AA.SBC}, optional=True), |
| 539 | ECA(ByteField("uni_counter", None), {AA.R}, optional=True), |
| 540 | ECA(ShortField("priority_queue_pointer_downstream", None), |
| 541 | {AA.R, AA.W, AA.SBC}), |
| 542 | ECA(ByteField("encryption_state", None), {AA.R}, optional=True), |
| 543 | ECA(ShortField("traffic_desc_profile_pointer_downstream", None), {AA.R, AA.W, AA.SBC}, optional=True), |
| 544 | ECA(ShortField("encryption_key_ring", None), {AA.R, AA.W, AA.SBC}, optional=True) |
| 545 | ] |
| 546 | mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set} |
| 547 | |
| 548 | |
| 549 | class GalEthernetProfile(EntityClass): |
| 550 | class_id = 272 |
| 551 | attributes = [ |
| 552 | ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}), |
| 553 | ECA(ShortField("max_gem_payload_size", None), {AA.R, AA.W, AA.SBC}), |
| 554 | ] |
| 555 | mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.Set} |
| 556 | |
| 557 | |
| 558 | class PriorityQueueG(EntityClass): |
| 559 | class_id = 277 |
| 560 | attributes = [ |
| 561 | ECA(ShortField("managed_entity_id", None), {AA.R}), |
| 562 | ECA(ByteField("queue_configuration_option", None), {AA.R}), |
| 563 | ECA(ShortField("maximum_queue_size", None), {AA.R}), |
| 564 | ECA(ShortField("allocated_queue_size", None), {AA.R, AA.W}), |
| 565 | ECA(ShortField("discard_block_countter_reset_interval", None), {AA.R, AA.W}), |
| 566 | ECA(ShortField("threshold_value_for_discarded_blocks", None), {AA.R, AA.W}), |
| 567 | ECA(IntField("related_port", None), {AA.R}), |
| 568 | ECA(ShortField("traffic_scheduler_g_pointer", None), {AA.R, AA.W}), |
| 569 | ECA(ByteField("weight", None), {AA.R, AA.W}), |
| 570 | ECA(ShortField("back_pressure_operation", None), {AA.R, AA.W}), |
| 571 | ECA(IntField("back_pressure_time", None), {AA.R, AA.W}), |
| 572 | ECA(ShortField("back_pressure_occur_queue_threshold", None), {AA.R, AA.W}), |
| 573 | ECA(ShortField("back_pressure_clear_queue_threshold", None), {AA.R, AA.W}), |
| 574 | ] |
| 575 | mandatory_operations = {OP.Get, OP.Set} |
| 576 | |
| 577 | |
| 578 | class TrafficSchedulerG(EntityClass): |
| 579 | class_id = 278 |
| 580 | attributes = [ |
| 581 | ECA(ShortField("managed_entity_id", None), {AA.R}), |
| 582 | ECA(ShortField("tcont_pointer", None), {AA.R}), |
| 583 | ECA(ShortField("traffic_scheduler_pointer", None), {AA.R}), |
| 584 | ECA(ByteField("policy", None), {AA.R}), |
| 585 | ECA(ByteField("priority_weight", None), {AA.R}), |
| 586 | ] |
| 587 | mandatory_operations = {OP.Get, OP.Set} |
| 588 | |
| 589 | |
| 590 | class MulticastGemInterworkingTp(EntityClass): |
| 591 | class_id = 281 |
| 592 | attributes = [ |
| 593 | ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}), |
| 594 | ECA(ShortField("gem_port_network_ctp_pointer", None), {AA.R, AA.SBC}), |
| 595 | ECA(ByteField("interworking_option", None), {AA.R, AA.SBC}), |
| 596 | ECA(ShortField("service_profile_pointer", None), {AA.R, AA.SBC}), |
| 597 | ECA(ShortField("interworking_tp_pointer", 0), {AA.R, AA.SBC}), |
| 598 | ECA(ByteField("pptp_counter", None), {AA.R}, optional=True), |
| 599 | ECA(ByteField("operational_state", None), {AA.R}, optional=True), |
| 600 | ECA(ShortField("gal_profile_pointer", None), {AA.R, AA.W, AA.SBC}), |
| 601 | ECA(ByteField("gal_loopback_configuration", None), |
| 602 | {AA.R, AA.W, AA.SBC}), |
| 603 | # TODO add multicast_address_table here (page 85 of spec.) |
| 604 | # ECA(...("multicast_address_table", None), {AA.R, AA.W}) |
| 605 | ] |
| 606 | mandatory_operations = {OP.Create, OP.Delete, OP.Get, OP.GetNext, OP.Set} |
| 607 | |
| 608 | |
| 609 | class AccessControlRow0(Packet): |
| 610 | name = "AccessControlRow0" |
| 611 | fields_desc = [ |
| 612 | BitField("set_ctrl", 0, 2), |
| 613 | BitField("row_part_id", 0, 3), |
| 614 | BitField("test", 0, 1), |
| 615 | BitField("row_key", 0, 10), |
| 616 | |
| 617 | ShortField("gem_port_id", None), |
| 618 | ShortField("vlan_id", None), |
| 619 | IPField("src_ip", None), |
| 620 | IPField("dst_ip_start", None), |
| 621 | IPField("dst_ip_end", None), |
| 622 | IntField("ipm_group_bw", None), |
| 623 | ShortField("reserved0", 0) |
| 624 | ] |
| 625 | |
| 626 | class AccessControlRow1(Packet): |
| 627 | name = "AccessControlRow1" |
| 628 | fields_desc = [ |
| 629 | BitField("set_ctrl", 0, 2), |
| 630 | BitField("row_part_id", 0, 3), |
| 631 | BitField("test", 0, 1), |
| 632 | BitField("row_key", 0, 10), |
| 633 | |
| 634 | StrFixedLenField("ipv6_src_addr_start_bytes", None, 12), |
| 635 | ShortField("preview_length", None), |
| 636 | ShortField("preview_repeat_time", None), |
| 637 | ShortField("preview_repeat_count", None), |
| 638 | ShortField("preview_reset_time", None), |
| 639 | ShortField("reserved1", 0) |
| 640 | ] |
| 641 | |
| 642 | class AccessControlRow2(Packet): |
| 643 | name = "AccessControlRow2" |
| 644 | fields_desc = [ |
| 645 | BitField("set_ctrl", 0, 2), |
| 646 | BitField("row_part_id", 0, 3), |
| 647 | BitField("test", 0, 1), |
| 648 | BitField("row_key", 0, 10), |
| 649 | |
| 650 | StrFixedLenField("ipv6_dst_addr_start_bytes", None, 12), |
| 651 | StrFixedLenField("reserved2", None, 10) |
| 652 | ] |
| 653 | |
| 654 | class DownstreamIgmpMulticastTci(Packet): |
| 655 | name = "DownstreamIgmpMulticastTci" |
| 656 | fields_desc = [ |
| 657 | ByteField("ctrl_type", None), |
| 658 | ShortField("tci", None) |
| 659 | ] |
| 660 | |
| 661 | class MulticastOperationsProfile(EntityClass): |
| 662 | class_id = 309 |
| 663 | attributes = [ |
| 664 | ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}), |
| 665 | ECA(ByteField("igmp_version", None), {AA.R, AA.W, AA.SBC}), |
| 666 | ECA(ByteField("igmp_function", None), {AA.R, AA.W, AA.SBC}), |
| 667 | ECA(ByteField("immediate_leave", None), {AA.R, AA.W, AA.SBC}), |
| 668 | ECA(ShortField("us_igmp_tci", None), {AA.R, AA.W, AA.SBC}, optional=True), |
| 669 | ECA(ByteField("us_igmp_tag_ctrl", None), {AA.R, AA.W, AA.SBC}, optional=True), |
| 670 | ECA(IntField("us_igmp_rate", None), {AA.R, AA.W, AA.SBC}, optional=True), |
| 671 | # TODO: need to make table and add column data |
| 672 | ECA(StrFixedLenField( |
| 673 | "dynamic_access_control_list_table", None, 24), {AA.R, AA.W}), |
| 674 | # TODO: need to make table and add column data |
| 675 | ECA(StrFixedLenField( |
| 676 | "static_access_control_list_table", None, 24), {AA.R, AA.W}), |
| 677 | # TODO: need to make table and add column data |
| 678 | ECA(StrFixedLenField("lost_groups_list_table", None, 10), {AA.R}, optional=True), |
| 679 | ECA(ByteField("robustness", None), {AA.R, AA.W, AA.SBC}, optional=True), |
| 680 | ECA(IntField("querier_ip", None), {AA.R, AA.W, AA.SBC}, optional=True), |
| 681 | ECA(IntField("query_interval", None), {AA.R, AA.W, AA.SBC}, optional=True), |
| 682 | ECA(IntField("querier_max_response_time", None), {AA.R, AA.W, AA.SBC}, optional=True), |
| 683 | ECA(IntField("last_member_response_time", None), {AA.R, AA.W}, optional=True), |
| 684 | ECA(ByteField("unauthorized_join_behaviour", None), {AA.R, AA.W}, optional=True), |
| 685 | ECA(StrFixedLenField("ds_igmp_mcast_tci", None, 3), {AA.R, AA.W, AA.SBC}, optional=True) |
| 686 | ] |
| 687 | mandatory_operations = {OP.Create, OP.Delete, OP.Set, OP.Get, OP.GetNext} |
| 688 | |
| 689 | class MulticastServicePackage(Packet): |
| 690 | name = "MulticastServicePackage" |
| 691 | fields_desc = [ |
| 692 | BitField("set_ctrl", 0, 2), |
| 693 | BitField("reserved0", 0, 4), |
| 694 | BitField("row_key", 0, 10), |
| 695 | |
| 696 | ShortField("vid_uni", None), |
| 697 | ShortField("max_simultaneous_groups", None), |
| 698 | IntField("max_multicast_bw", None), |
| 699 | ShortField("mcast_operations_profile_pointer", None), |
| 700 | StrFixedLenField("reserved1", None, 8) |
| 701 | ] |
| 702 | |
| 703 | class AllowedPreviewGroupsRow0(Packet): |
| 704 | name = "AllowedPreviewGroupsRow0" |
| 705 | fields_desc = [ |
| 706 | BitField("set_ctrl", 0, 2), |
| 707 | BitField("row_part_id", 0, 3), |
| 708 | BitField("reserved0", 0, 1), |
| 709 | BitField("row_key", 0, 10), |
| 710 | |
| 711 | StrFixedLenField("ipv6_pad", 0, 12), |
| 712 | IPField("src_ip", None), |
| 713 | ShortField("vlan_id_ani", None), |
| 714 | ShortField("vlan_id_uni", None) |
| 715 | ] |
| 716 | |
| 717 | class AllowedPreviewGroupsRow1(Packet): |
| 718 | name = "AllowedPreviewGroupsRow1" |
| 719 | fields_desc = [ |
| 720 | BitField("set_ctrl", 0, 2), |
| 721 | BitField("row_part_id", 0, 3), |
| 722 | BitField("reserved0", 0, 1), |
| 723 | BitField("row_key", 0, 10), |
| 724 | |
| 725 | StrFixedLenField("ipv6_pad", 0, 12), |
| 726 | IPField("dst_ip", None), |
| 727 | ShortField("duration", None), |
| 728 | ShortField("time_left", None) |
| 729 | ] |
| 730 | |
| 731 | class MulticastSubscriberConfigInfo(EntityClass): |
| 732 | class_id = 310 |
| 733 | attributes = [ |
| 734 | ECA(ShortField("managed_entity_id", None), {AA.R, AA.SBC}), |
| 735 | ECA(ByteField("me_type", None), {AA.R, AA.W, AA.SBC}), |
| 736 | ECA(ShortField("mcast_operations_profile_pointer", None), {AA.R, AA.W, AA.SBC}), |
| 737 | ECA(ShortField("max_simultaneous_groups", None), {AA.R, AA.W, AA.SBC}, optional=True), |
| 738 | ECA(IntField("max_multicast_bandwidth", None), {AA.R, AA.W, AA.SBC}, optional=True), |
| 739 | ECA(ByteField("bandwidth_enforcement", None), {AA.R, AA.W, AA.SBC}, optional=True), |
| 740 | # TODO: need to make table and add column data |
| 741 | ECA(StrFixedLenField( |
| 742 | "multicast_service_package_table", None, 20), {AA.R, AA.W}, optional=True), |
| 743 | # TODO: need to make table and add column data |
| 744 | ECA(StrFixedLenField( |
| 745 | "allowed_preview_groups_table", None, 22), {AA.R, AA.W}, optional=True), |
| 746 | ] |
| 747 | mandatory_operations = {OP.Create, OP.Delete, OP.Set, OP.Get, OP.GetNext} |
| 748 | |
| 749 | |
| 750 | class VirtualEthernetInterfacePt(EntityClass): |
| 751 | class_id = 329 |
| 752 | attributes = [ |
| 753 | ECA(ShortField("managed_entity_id", None), {AA.R}), |
| 754 | ECA(ByteField("administrative_state", None), {AA.R, AA.W}), |
| 755 | ECA(ByteField("operational_state", None), {AA.R}, optional=True), |
| 756 | ECA(StrFixedLenField( |
| 757 | "interdomain_name", None, 25), {AA.R, AA.W}, optional=True), |
| 758 | ECA(ShortField("tcp_udp_pointer", None), {AA.R, AA.W}, optional=True), |
| 759 | ECA(ShortField("iana_assigned_port", None), {AA.R}), |
| 760 | ] |
| 761 | mandatory_operations = {OP.Get, OP.Set} |
| 762 | |
| 763 | |
| 764 | class EnhSecurityControl: |
| 765 | class_id = 332 |
| 766 | attributes = [ |
| 767 | ECA(ShortField("managed_entity_id", None), {AA.R}), |
| 768 | ECA(StrFixedLenField( |
| 769 | "olt_crypto_capabilities", None, 16), {AA.W}), |
| 770 | # TODO: need to make table and add column data |
| 771 | ECA(StrFixedLenField( |
| 772 | "olt_random_challenge_table", None, 17), {AA.R, AA.W}), |
| 773 | ECA(ByteField("olt_challenge_status", None), {AA.R, AA.W}), |
| 774 | ECA(ByteField("onu_selected_crypto_capabilities", None), {AA.R}), |
| 775 | # TODO: need to make table and add column data |
| 776 | ECA(StrFixedLenField( |
| 777 | "onu_random_challenge_table", None, 16), {AA.R}), |
| 778 | # TODO: need to make table and add column data |
| 779 | ECA(StrFixedLenField( |
| 780 | "onu_authentication_result_table", None, 16), {AA.R}), |
| 781 | # TODO: need to make table and add column data |
| 782 | ECA(StrFixedLenField( |
| 783 | "olt_authentication_result_table", None, 17), {AA.W}), |
| 784 | ECA(ByteField("olt_result_status", None), {AA.R, AA.W}), |
| 785 | ECA(ByteField("onu_authentication_status", None), {AA.R}), |
| 786 | ECA(StrFixedLenField( |
| 787 | "master_session_key_name", None, 16), {AA.R}), |
| 788 | ECA(StrFixedLenField( |
| 789 | "broadcast_key_table", None, 18), {AA.R, AA.W}, optional=True), |
| 790 | ECA(ShortField("effective_key_length", None), {AA.R}, optional=True), |
| 791 | |
| 792 | ] |
| 793 | mandatory_operations = {OP.Set, OP.Get, OP.GetNext} |
| 794 | |
| 795 | |
| 796 | class Unknown347(EntityClass): |
| 797 | class_id = 347 |
| 798 | attributes = [ |
| 799 | |
| 800 | ] |
| 801 | |
| 802 | |
| 803 | # entity class lookup table from entity_class values |
| 804 | entity_classes_name_map = dict( |
| 805 | inspect.getmembers(sys.modules[__name__], |
| 806 | lambda o: inspect.isclass(o) and \ |
| 807 | issubclass(o, EntityClass) and \ |
| 808 | o is not EntityClass) |
| 809 | ) |
| 810 | |
| 811 | entity_classes = [c for c in entity_classes_name_map.itervalues()] |
| 812 | entity_id_to_class_map = dict((c.class_id, c) for c in entity_classes) |