Home | History | Annotate | Download | only in contrib
      1 #! /usr/bin/env python
      2 
      3 # This file is part of Scapy
      4 # Scapy is free software: you can redistribute it and/or modify
      5 # it under the terms of the GNU General Public License as published by
      6 # the Free Software Foundation, either version 2 of the License, or
      7 # any later version.
      8 #
      9 # Scapy is distributed in the hope that it will be useful,
     10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     12 # GNU General Public License for more details.
     13 #
     14 # You should have received a copy of the GNU General Public License
     15 # along with Scapy. If not, see <http://www.gnu.org/licenses/>.
     16 
     17 # scapy.contrib.description = HomePlugAV Layer
     18 # scapy.contrib.status = loads
     19 
     20 from __future__ import absolute_import
     21 from scapy.packet import *
     22 from scapy.fields import *
     23 from scapy.layers.l2 import Ether
     24 from scapy.modules.six.moves import range
     25 
     26 """
     27     Copyright (C) HomePlugAV Layer for Scapy by FlUxIuS (Sebastien Dudek)
     28 """
     29 
     30 """
     31     HomePlugAV Management Message Type
     32     Key (type value) : Description
     33 """
     34 HPAVTypeList = { 0xA000 : "'Get Device/sw version Request'",
     35                 0xA001 : "'Get Device/sw version Confirmation'",
     36                 0xA008 : "'Read MAC Memory Request'",
     37                 0xA009 : "'Read MAC Memory Confirmation'",
     38                 0xA00C : "'Start MAC Request'",
     39                 0xA00D : "'Start MAC Confirmation'",
     40                 0xA010 : "'Get NVM Parameters Request'",
     41                 0xA011 : "'Get NVM Parameters Confirmation'",
     42                 0xA01C : "'Reset Device Request'",
     43                 0xA01D : "'Reset Device Confirmation'",
     44                 0xA020 : "'Write Module Data Request'",
     45                 0xA024 : "'Read Module Data Request'",
     46                 0xA025 : "'Read Module Data Confirmation'",
     47                 0xA028 : "'Write Module Data to NVM Request'",
     48                 0xA028 : "'Write Module Data to NVM Confirmation'",
     49                 0xA034 : "'Sniffer Request'",
     50                 0xA035 : "'Sniffer Confirmation'",
     51                 0xA036 : "'Sniffer Indicates'",
     52                 0xA038 : "'Network Information Request'",
     53                 0xA039 : "'Network Information Confirmation'",
     54                 0xA048 : "'Loopback Request'",
     55                 0xA049 : "'Loopback Request Confirmation'",
     56                 0xA050 : "'Set Encryption Key Request'",
     57                 0xA051 : "'Set Encryption Key Request Confirmation'",
     58                 0xA058 : "'Read Configuration Block Request'",
     59                 0xA058 : "'Read Configuration Block Confirmation'",
     60                 0xA062 : "'Embedded Host Action Required Indication'" }
     61 
     62 HPAVversionList = { 0x00 : "1.0",
     63                     0x01 : "1.1" }
     64 
     65 HPAVDeviceIDList = {    0x00 : "Unknown",
     66                         0x01 : "'INT6000'",
     67                         0x02 : "'INT6300'",
     68                         0x03 : "'INT6400'",
     69                         0x04 : "'AR7400'",
     70                         0x05 : "'AR6405'",
     71                         0x20 : "'QCA7450/QCA7420'",
     72                         0x21 : "'QCA6410/QCA6411'",
     73                         0x22 : "'QCA7000'" }
     74 
     75 StationRole = { 0x00 : "'Station'",
     76                 0x01 : "'Proxy coordinator'",
     77                 0x02 : "'Central coordinator'" }
     78 
     79 StatusCodes = { 0x00 : "'Success'",
     80                 0x10 : "'Invalid Address'",
     81                 0x14 : "'Invalid Length'" }
     82 
     83 DefaultVendor = "Qualcomm"
     84 
     85 #########################################################################
     86 # Qualcomm Vendor Specific Management Message Types;                    #
     87 # from https://github.com/qca/open-plc-utils/blob/master/mme/qualcomm.h #
     88 #########################################################################
     89 # Commented commands are already in HPAVTypeList, the other have to be implemted 
     90 QualcommTypeList = {  #0xA000 : "VS_SW_VER",
     91                     0xA004 : "VS_WR_MEM",
     92                     #0xA008 : "VS_RD_MEM",
     93                     #0xA00C : "VS_ST_MAC",
     94                     #0xA010 : "VS_GET_NVM",
     95                     0xA014 : "VS_RSVD_1",
     96                     0xA018 : "VS_RSVD_2",
     97                     #0xA01C : "VS_RS_DEV",
     98                     #0xA020 : "VS_WR_MOD",
     99                     #0xA024 : "VS_RD_MOD",
    100                     #0xA028 : "VS_MOD_NVM",
    101                     0xA02C : "VS_WD_RPT",
    102                     0xA030 : "VS_LNK_STATS",
    103                     #0xA034 : "VS_SNIFFER",
    104                     #0xA038 : "VS_NW_INFO",
    105                     0xA03C : "VS_RSVD_3",
    106                     0xA040 : "VS_CP_RPT",
    107                     0xA044 : "VS_ARPC",
    108                     #0xA050 : "VS_SET_KEY",
    109                     0xA054 : "VS_MFG_STRING",
    110                     #0xA058 : "VS_RD_CBLOCK",
    111                     0xA05C : "VS_SET_SDRAM",
    112                     0xA060 : "VS_HOST_ACTION",
    113                     0xA068 : "VS_OP_ATTRIBUTES",
    114                     0xA06C : "VS_ENET_SETTINGS",
    115                     0xA070 : "VS_TONE_MAP_CHAR",
    116                     0xA074 : "VS_NW_INFO_STATS",
    117                     0xA078 : "VS_SLAVE_MEM",
    118                     0xA07C : "VS_FAC_DEFAULTS",
    119                     0xA07D : "VS_FAC_DEFAULTS_CONFIRM",
    120                     0xA084 : "VS_MULTICAST_INFO",
    121                     0xA088 : "VS_CLASSIFICATION",
    122                     0xA090 : "VS_RX_TONE_MAP_CHAR",
    123                     0xA094 : "VS_SET_LED_BEHAVIOR",
    124                     0xA098 : "VS_WRITE_AND_EXECUTE_APPLET",
    125                     0xA09C : "VS_MDIO_COMMAND",
    126                     0xA0A0 : "VS_SLAVE_REG",
    127                     0xA0A4 : "VS_BANDWIDTH_LIMITING",
    128                     0xA0A8 : "VS_SNID_OPERATION",
    129                     0xA0AC : "VS_NN_MITIGATE",
    130                     0xA0B0 : "VS_MODULE_OPERATION",
    131                     0xA0B4 : "VS_DIAG_NETWORK_PROBE",
    132                     0xA0B8 : "VS_PL_LINK_STATUS",
    133                     0xA0BC : "VS_GPIO_STATE_CHANGE",
    134                     0xA0C0 : "VS_CONN_ADD",
    135                     0xA0C4 : "VS_CONN_MOD",
    136                     0xA0C8 : "VS_CONN_REL",
    137                     0xA0CC : "VS_CONN_INFO",
    138                     0xA0D0 : "VS_MULTIPORT_LNK_STA",
    139                     0xA0DC : "VS_EM_ID_TABLE",
    140                     0xA0E0 : "VS_STANDBY",
    141                     0xA0E4 : "VS_SLEEPSCHEDULE",
    142                     0xA0E8 : "VS_SLEEPSCHEDULE_NOTIFICATION",
    143                     0xA0F0 : "VS_MICROCONTROLLER_DIAG",
    144                     0xA0F8 : "VS_GET_PROPERTY",
    145                     0xA100 : "VS_SET_PROPERTY",
    146                     0xA104 : "VS_PHYSWITCH_MDIO",
    147                     0xA10C : "VS_SELFTEST_ONETIME_CONFIG",
    148                     0xA110 : "VS_SELFTEST_RESULTS",
    149                     0xA114 : "VS_MDU_TRAFFIC_STATS",
    150                     0xA118 : "VS_FORWARD_CONFIG",
    151                     0xA200 : "VS_HYBRID_INFO"}
    152 ########## END OF Qualcomm commands ##########################
    153 
    154 EofPadList = [ 0xA000, 0xA038 ] # TODO: The complete list of Padding can help to improve the condition in VendorMME Class
    155 
    156 def FragmentCond(pkt):
    157     """
    158         A fragementation field condition
    159         TODO: To complete
    160     """
    161     fragTypeTable = [ 0xA038, 0xA039 ]
    162     return ((pkt.version == 0x01 )  and ( pkt.HPtype in fragTypeTable ))
    163 
    164 class MACManagementHeader(Packet):
    165     name = "MACManagementHeader "
    166     if DefaultVendor == "Qualcomm":
    167         HPAVTypeList.update(QualcommTypeList) 
    168     fields_desc=[ ByteEnumField("version",0, HPAVversionList),
    169                 EnumField("HPtype" , 0xA000, HPAVTypeList, "<H") ]
    170 
    171 class VendorMME(Packet):
    172     name = "VendorMME "
    173     fields_desc=[ X3BytesField("OUI", 0x00b052) ]
    174 
    175 class GetDeviceVersion(Packet):
    176     name = "GetDeviceVersion"
    177     fields_desc=[ ByteEnumField("Status", 0x0, StatusCodes),
    178                 ByteEnumField("DeviceID",0x20, HPAVDeviceIDList),
    179                 FieldLenField("VersionLen", None, count_of="DeviceVersion", fmt="B"),
    180                 StrLenField("DeviceVersion", b"NoVersion\x00", length_from = lambda pkt: pkt.VersionLen),
    181                 StrLenField("DeviceVersion_pad", b"\xcc\xcc\xcc\xcc\xcc"+b"\x00"*59, length_from = lambda pkt: 64-pkt.VersionLen), 
    182                 ByteEnumField("Upgradable", 0, {0:"False",1:"True"}) ]
    183 
    184 class NetworkInformationRequest(Packet):
    185     name = "NetworkInformationRequest"
    186     fields_desc=[ ]
    187 
    188 #""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    189 #   Networks & Stations informations for MAC Management V1.0
    190 #""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    191 class NetworkInfoV10(Packet):
    192     """
    193         Network Information Element
    194     """
    195     name = "NetworkInfo"
    196     fields_desc = [ StrFixedLenField("NetworkID", b"\x00\x00\x00\x00\x00\x00\x00", 7),
    197                     XByteField("ShortNetworkID", 0x00),
    198                     XByteField("TerminalEID", 0x01),
    199                     ByteEnumField("StationRole", 0x00, StationRole),
    200                     MACField("CCoMACAdress", "00:00:00:00:00:00"),
    201                     XByteField("CCoTerminalEID", 0x01) ]
    202 
    203     def extract_padding(self, p):
    204         return b"", p
    205 
    206 class StationInfoV10(Packet):
    207     """
    208         Station Information Element
    209     """
    210     name = "StationInfo"
    211     fields_desc=[ MACField("StationMAC", "00:00:00:00:00:00"),
    212                 XByteField("StationTerminalEID", 0x01), 
    213                 MACField("firstnodeMAC", "ff:ff:ff:ff:ff:ff"),
    214                 XByteField("TXaverage", 0x00),
    215                 XByteField("RXaverage", 0x00) ]
    216 
    217     def extract_padding(self, p):
    218         return b"", p
    219 
    220 #""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    221 #   Networks & Stations informations for MAC Management V1.1 
    222 #""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    223 class NetworkInfoV11(Packet):
    224     """
    225         Network Information Element
    226     """
    227     name = "NetworkInfo"
    228     fields_desc = [ StrFixedLenField("NetworkID", b"\x00\x00\x00\x00\x00\x00\x00", 7),
    229                     ShortField("reserved_1", 0x0000),
    230                     XByteField("ShortNetworkID", 0x00),
    231                     XByteField("TerminalEID", 0x01),
    232                     IntField("reserved_2", 0x00000000),
    233                     ByteEnumField("StationRole", 0x00, StationRole),
    234                     MACField("CCoMACAdress", "00:00:00:00:00:00"),
    235                     XByteField("CCoTerminalEID", 0x01),
    236                     X3BytesField("reserved_3", 0x000000) ]
    237     
    238     def extract_padding(self, p):
    239         return b"", p
    240 
    241 
    242 class StationInfoV11(Packet):
    243     """
    244         Station Information Element
    245     """
    246     name = "StationInfo"
    247     fields_desc=[ MACField("StationMAC", "00:00:00:00:00:00"),
    248                 XByteField("StationTerminalEID", 0x01),
    249                 X3BytesField("reserved_s2", 0x000000),
    250                 MACField("firstnodeMAC", "ff:ff:ff:ff:ff:ff"),
    251                 LEShortField("TXaverage", 0x0000),
    252                 BitField("RxCoupling", 0, 4),
    253                 BitField("TxCoupling", 0, 4),
    254                 XByteField("reserved_s3", 0x00),
    255                 LEShortField("RXaverage", 0x0000),
    256                 XByteField("reserved_s4", 0x00) ]
    257     
    258     def extract_padding(self, p):
    259         return b"", p
    260 
    261 #""""""""""""""""""""""""" END """"""""""""""""""""""""""""""""""""""""""""""""""""""""""
    262 
    263 class NetworkInfoConfirmationV10(Packet):
    264     """
    265         Network Information Confirmation following the MAC Management version 1.0
    266     """
    267     name = "NetworkInfoConfirmation"
    268     fields_desc=[ XByteField("LogicalNetworksNumber", 0x01),
    269                 PacketListField("NetworksInfos", "", NetworkInfoV10, length_from=lambda pkt: pkt.LogicalNetworksNumber * 17),
    270                 XByteField("StationsNumber", 0x01),
    271                 PacketListField("StationsInfos", "", StationInfoV10, length_from=lambda pkt: pkt.StationsNumber * 21) ]
    272 
    273 class NetworkInfoConfirmationV11(Packet):
    274     """
    275         Network Information Confirmation following the MAC Management version 1.1
    276         This introduce few 'crazy' reserved bytes -> have fun!
    277     """
    278     name = "NetworkInfoConfirmation"
    279     fields_desc= [ StrFixedLenField("reserved_n1", b"\x00\x00\x3a\x00\x00", 5),
    280                 XByteField("LogicalNetworksNumber", 0x01),
    281                 PacketListField("NetworksInfos", "", NetworkInfoV11, length_from=lambda pkt: pkt.LogicalNetworksNumber * 26),
    282                 XByteField("StationsNumber", 0x01),
    283                 StrFixedLenField("reserverd_s1", b"\x00\x00\x00\x00\x00", 5),
    284                 PacketListField("StationsInfos", "", StationInfoV11, length_from=lambda pkt: pkt.StationsNumber * 23) ]
    285 
    286 
    287 # Description of Embedded Host Action Required Indice
    288 ActionsList = { 0x02 : "'PIB Update Ready'",
    289                 0x04 : "'Loader (Bootloader)'" }
    290 
    291 class HostActionRequired(Packet):
    292     """
    293         Embedded Host Action Required Indice
    294     """
    295     name = "HostActionRequired"
    296     fields_desc=[ ByteEnumField("ActionRequired", 0x02, ActionsList) ]
    297 
    298 class LoopbackRequest(Packet):
    299     name = "LoopbackRequest"
    300     fields_desc=[ ByteField("Duration", 0x01),
    301                 ByteField("reserved_l1", 0x01),
    302                 ShortField("LRlength", 0x0000) ]
    303                 # TODO: Test all possibles data to complete it
    304 
    305 class LoopbackConfirmation(Packet):
    306     name = "LoopbackConfirmation"
    307     fields_desc=[ ByteEnumField("Status", 0x0, StatusCodes), 
    308                 ByteField("Duration", 0x01),
    309                 ShortField("LRlength", 0x0000) ]
    310 
    311 ################################################################
    312 # Encryption Key Packets
    313 ################################################################
    314 
    315 class SetEncryptionKeyRequest(Packet):
    316     name = "SetEncryptionKeyRequest"
    317     fields_desc=[ XByteField("EKS", 0x00),
    318                 StrFixedLenField("NMK", 
    319                                 b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
    320                                 16),
    321                 XByteField("PayloadEncKeySelect", 0x00),
    322                 MACField("DestinationMAC", "ff:ff:ff:ff:ff:ff"),
    323                 StrFixedLenField("DAK", 
    324                                 b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 
    325                                 16) ]
    326 
    327 SetEncKey_Status = {    0x00 : "Success",
    328                         0x10 : "Invalid EKS",
    329                         0x11 : "Invalid PKS" }
    330 
    331 class SetEncryptionKeyConfirmation(Packet):
    332     name = "SetEncryptionKeyConfirmation"
    333     fields_desc=[ ByteEnumField("Status", 0x0, SetEncKey_Status) ]
    334 
    335 ################################################################
    336 # Default config Packet
    337 ################################################################
    338 
    339 class QUAResetFactoryConfirm(Packet):
    340     name = "QUAResetFactoryConfirm"
    341     fields_desc=[ ByteEnumField("Status", 0x0, StatusCodes) ] #TODO : Probably a Status bytefield?
    342 
    343 ######################################################################
    344 # NVM Parameters Packets
    345 ######################################################################
    346 
    347 class GetNVMParametersRequest(Packet):
    348     name = "Get NVM Parameters Request"
    349     fields_desc=[ ]
    350 
    351 class GetNVMParametersConfirmation(Packet):
    352     name = "Get NVM Parameters Confirmation"
    353     fields_desc=[ ByteEnumField("Status", 0x0, StatusCodes),
    354                 LEIntField("NVMType", 0x00000013),
    355                 LEIntField("NVMPageSize", 0x00000100),
    356                 LEIntField("NVMBlockSize", 0x00010000),
    357                 LEIntField("NVMMemorySize", 0x00100000) ]
    358 
    359 ######################################################################
    360 # Sniffer Packets
    361 ######################################################################
    362 
    363 SnifferControlList = { 0x0 : "'Disabled'",
    364                        0x1 : "'Enabled'" }
    365 
    366 SnifferTypeCodes = { 0x00 : "'Regular'" }
    367 
    368 class SnifferRequest(Packet):
    369     name = "SnifferRequest"
    370     fields_desc=[ ByteEnumField("SnifferControl", 0x0, SnifferControlList) ]
    371 
    372 SnifferCodes = { 0x00 : "'Success'",
    373                  0x10 : "'Invalid Control'" }
    374 
    375 class SnifferConfirmation(Packet):
    376     name = "SnifferConfirmation"
    377     fields_desc=[ ByteEnumField("Status", 0x0, StatusCodes) ]
    378 
    379 DirectionCodes = { 0x00 : "'Tx'",
    380                    0x01 : "'Rx'" }
    381 
    382 ANCodes = { 0x00 : "'In-home'",
    383             0x01 : "'Access'" }
    384 
    385 class SnifferIndicate(Packet):
    386     # TODO: Some bitfield have been regrouped for the moment => need more work on it
    387     name = "SnifferIndicate"
    388     fields_desc=[ ByteEnumField("SnifferType", 0x0, SnifferTypeCodes), 
    389                   ByteEnumField("Direction", 0x0, DirectionCodes),
    390                   LELongField("SystemTime", 0x0),
    391                   LEIntField("BeaconTime", 0x0), 
    392                   XByteField("ShortNetworkID", 0x0),
    393                   ByteField("SourceTermEqID", 0),
    394                   ByteField("DestTermEqID", 0),
    395                   ByteField("LinkID", 0),
    396                   XByteField("PayloadEncrKeySelect", 0x0f),
    397                   ByteField("PendingPHYblock", 0),
    398                   ByteField("BitLoadingEstim", 0), 
    399                   BitField("ToneMapIndex", 0, size=5),
    400                   BitField("NumberofSymbols", 0, size=2),
    401                   BitField("PHYblockSize", 0, size=1),
    402                   XShortField("FrameLength", 0x0000),
    403                   XByteField("ReversegrandLength", 0x0),
    404                   BitField("RequestSACKtrans", 0, size=1),
    405                   BitField("DataMACstreamCMD", 0, size=3),
    406                   BitField("ManNACFrameStreamCMD", 0, size=3),
    407                   BitField("reserved_1", 0, size=6),
    408                   BitField("MultinetBroadcast", 0, size=1),
    409                   BitField("DifferentCPPHYclock", 0, size=1),
    410                   BitField("Multicast", 0, size=1),
    411                   X3BytesField("FrameControlCheckSeq", 0x000000),
    412                   XByteField("ShortNetworkID_", 0x0),
    413                   IntField("BeaconTimestamp", 0),
    414                   XShortField("BeaconTransOffset_0", 0x0000),
    415                   XShortField("BeaconTransOffset_1", 0x0000),
    416                   XShortField("BeaconTransOffset_2", 0x0000),
    417                   XShortField("BeaconTransOffset_3", 0x0000),
    418                   X3BytesField("FrameContrchkSeq", 0x000000) ]
    419 
    420 ######################################################################
    421 # Read MAC Memory
    422 #####################################################################
    423 
    424 class ReadMACMemoryRequest(Packet):
    425     name = "ReadMACMemoryRequest"
    426     fields_desc=[ LEIntField("Address" , 0x00000000),
    427                   LEIntField("Length", 0x00000400), 
    428                 ]
    429 
    430 ReadMACStatus = { 0x00 : "Success",
    431                   0x10 : "Invalid Address",
    432                   0x14 : "Invalid Length" }
    433 
    434 class ReadMACMemoryConfirmation(Packet):
    435     name = "ReadMACMemoryConfirmation"
    436 
    437     fields_desc=[ ByteEnumField("Status", 0x00 , ReadMACStatus),
    438                   LEIntField("Address" , 0),
    439                   FieldLenField("MACLen", None, length_of="MACData", fmt="<H"),
    440                   StrLenField("MACData", b"\x00", length_from = lambda pkt: pkt.MACLen),
    441                 ]
    442 
    443 ######################################################################
    444 # Read Module Datas
    445 ######################################################################
    446 
    447 ModuleIDList = {    0x00 : "MAC Soft-Loader Image",
    448                     0x01 : "MAC Software Image",
    449                     0x02 : "PIB",
    450                     0x10 : "Write Alternate Flash Location" }
    451 
    452 def chksum32(data):
    453     cksum = 0
    454     for i in range(0, len(data), 4):
    455         cksum = (cksum ^ struct.unpack('<I', data[i:i+4])[0]) & 0xffffffff   
    456     return (~cksum) & 0xffffffff
    457 
    458 class ReadModuleDataRequest(Packet):
    459     name = "ReadModuleDataRequest"
    460     fields_desc=[ ByteEnumField("ModuleID", 0x02, ModuleIDList),
    461                   XByteField("reserved", 0x00),
    462                   LEShortField("Length" , 0x0400),
    463                   LEIntField("Offset", 0x00000000) ]
    464 
    465 class ReadModuleDataConfirmation(Packet):
    466     name = "ReadModuleDataConfirmation"
    467     fields_desc=[ ByteEnumField("Status", 0x0, StatusCodes),
    468                   X3BytesField("reserved_1", 0x000000),
    469                   ByteEnumField("ModuleID", 0x02, ModuleIDList),
    470                   XByteField("reserved_2", 0x00),
    471                   FieldLenField("DataLen", None, count_of="ModuleData", fmt="<H"),
    472                   LEIntField("Offset", 0x00000000),
    473                   LEIntField("checksum", None), 
    474                   StrLenField("ModuleData", b"\x00", length_from = lambda pkt: pkt.DataLen),
    475                 ]
    476 
    477     def post_build(self, p, pay):
    478         if self.DataLen is None:
    479             _len = len(self.ModuleData)
    480             p = p[:6] + struct.pack('h', _len) + p[8:]
    481         if self.checksum is None and p:
    482             ck = chksum32(self.ModuleData)
    483             p = p[:12] + struct.pack('I', ck) + p[16:]
    484         return p+pay
    485 
    486 ######################################################################
    487 # Write Module Datas
    488 ######################################################################
    489 
    490 class WriteModuleDataRequest(Packet):
    491     name = "WriteModuleDataRequest"
    492     fields_desc=[ ByteEnumField("ModuleID", 0x02, ModuleIDList),
    493                   XByteField("reserved_1", 0x00),
    494                   FieldLenField("DataLen", None, count_of="ModuleData", fmt="<H"),
    495                   LEIntField("Offset", 0x00000000),
    496                   LEIntField("checksum", None),
    497                   StrLenField("ModuleData", b"\x00", length_from = lambda pkt: pkt.DataLen),
    498                 ]
    499 
    500     def post_build(self, p, pay):
    501         if self.DataLen is None:
    502             _len = len(self.ModuleData)
    503             p = p[:2] + struct.pack('h', _len) + p[4:]
    504         if self.checksum is None and p:
    505             ck = chksum32(self.ModuleData)
    506             p = p[:8] + struct.pack('I', ck) + p[12:]
    507         return p+pay
    508 
    509 ######################################
    510 # Parse PIB                          #
    511 ######################################
    512 
    513 class ClassifierPriorityMap(Packet):
    514     name = "ClassifierPriorityMap"
    515     fields_desc=[ LEIntField("Priority" , 0),
    516                   LEIntField("PID" , 0),
    517                   LEIntField("IndividualOperand" , 0),
    518                   StrFixedLenField("ClassifierValue",
    519                                 b"\x00"*16,
    520                                 16),
    521                 ]
    522  
    523     def extract_padding(self, p):
    524         return b"", p
    525 
    526 class ClassifierObj(Packet):
    527     name = "ClassifierObj"
    528     
    529     fields_desc=[ LEIntField("ClassifierPID", 0),
    530                   LEIntField("IndividualOperand", 0),
    531                   StrFixedLenField("ClassifierValue",
    532                                 b"\x00"*16,
    533                                 16), 
    534                 ]
    535 
    536     def extract_padding(self, p):
    537         return b"", p
    538 
    539 class AutoConnection(Packet):
    540     name = "AutoConnection"
    541 
    542     fields_desc=[ XByteField("Action", 0x00), 
    543                   XByteField("ClassificationOperand", 0x00),
    544                   XShortField("NumClassifiers", 0x0000),
    545                   PacketListField("ClassifierObjs", "", ClassifierObj, length_from=lambda x: 24),
    546                   XShortField("CSPECversion", 0x0000),
    547                   XByteField("ConnCAP", 0x00),
    548                   XByteField("ConnCoQoSPrio", 0x00),
    549                   ShortField("ConnRate", 0),
    550                   LEIntField("ConnTTL", 0),
    551                   ShortField("CSPECversion", 0),
    552                   StrFixedLenField("VlanTag",
    553                                 b"\x00"*4,
    554                                 4),
    555                   XIntField("reserved_1", 0),
    556                   StrFixedLenField("reserved_2",
    557                                 b"\x00"*14,
    558                                 14),
    559                 ]
    560 
    561     def extract_padding(self, p):
    562         return b"", p
    563 
    564 class PeerNode(Packet):
    565     name = "PeerNodes"
    566     fields_desc=[ XByteField("PeerTEI", 0x0),
    567                   MACField("PIBMACAddr", "00:00:00:00:00:00"),
    568                 ]
    569 
    570     def extract_padding(self, p):
    571         return b"", p
    572 
    573 class AggregateConfigEntrie(Packet):
    574     name = "AggregateConfigEntrie"
    575     fields_desc=[ XByteField("TrafficTypeID", 0x0),
    576                   XByteField("AggregationConfigID", 0x0),
    577                 ]
    578 
    579     def extract_padding(self, p):
    580         return b"", p
    581 
    582 class RSVD_CustomAggregationParameter(Packet):
    583     name = "RSVD_CustomAggregationParameter"
    584     fields_desc=[ XIntField("CustomAggregationParameter", 0),
    585                 ]
    586 
    587     def extract_padding(self, p):
    588         return b"", p
    589 
    590 class PrescalerValue(Packet):
    591     name = "PrescalerValue"
    592     fields_desc=[ XIntField("prescaler", 0),
    593                 ]
    594 
    595     def extract_padding(self, p):
    596         return b"", p
    597 
    598 class GPIOMap(Packet):
    599     name = "GPIOMap"
    600     fields_desc=[ XByteField("GPIOvalue", 0),
    601                 ]
    602 
    603     def extract_padding(self, p):
    604         return b"", p
    605 
    606 class ReservedPercentageForCap(Packet):
    607     name = "ReservedPercentageForCap"
    608     fields_desc=[ XByteField("CAPpercent", 0),
    609                 ]
    610 
    611     def extract_padding(self, p):
    612         return b"", p
    613 
    614 class ConfigBit(Packet):
    615     name = "ConfigBit"
    616     fields_desc=[ BitField("OverrideSoundCap", 0, 1),
    617                   BitField("OverrideFailHoldDefaults", 0, 1),
    618                   BitField("OverrideResourceDefaults", 0, 1),
    619                   BitField("OverrideContentionWindowDefaults", 0, 1),
    620                   BitField("OverrideUnplugDetectionDefaults", 0, 1),
    621                   BitField("OverrideResoundDefaults", 0, 1),
    622                   BitField("OverrideExpiryDefaults", 0, 1),
    623                   BitField("DisableWorseChannelTrigger", 0, 1),
    624                   BitField("DisableBetterChannelTrigger", 0, 1),
    625                   BitField("DisableNetworkEventTrigger", 0, 1),
    626                   BitField("rsv1", 0, 6),
    627                 ]
    628                 
    629 class ContentionWindowTable(Packet):
    630     name = "ContentionWindowTable"
    631     fields_desc=[ XShortField("element", 0), 
    632                 ]
    633 
    634     def extract_padding(self, p):
    635         return b"", p
    636 
    637 class BackoffDeferalCountTable(Packet):
    638     name = "BackoffDeferalCountTable"
    639     fields_desc=[ XByteField("element", 0),
    640                 ]
    641 
    642     def extract_padding(self, p):
    643         return b"", p
    644 
    645 class BehaviorBlockArray(Packet):
    646     name = "BehaviorBlockArray"
    647     fields_desc=[ XByteField("BehId", 0),
    648                   XByteField("NoOfSteps", 0),
    649                   XByteField("DurationInMs", 0),
    650                   XShortField("GPIOMaskBits_1", 0),
    651                   XShortField("GPIOMaskBits_2", 0),
    652                   XShortField("GPIOMaskBits_3", 0),
    653                   XShortField("GPIOMaskBits_4", 0),
    654                   XShortField("GPIOMaskBits_5", 0),
    655                   XShortField("GPIOMaskBits_6", 0),
    656                   XIntField("reserved_beh", 0),
    657                 ]
    658 
    659     def extract_padding(self, p):
    660         return b"", p
    661 
    662 class EventBlockArray(Packet):
    663     name = "EventBlockArray"
    664     fields_desc=[ XByteField("EventPriorityID", 0),
    665                   XByteField("EventID", 0),
    666                   XByteField("BehID_1", 0),
    667                   XByteField("BehID_2", 0),
    668                   XByteField("BehID_3", 0),
    669                   XShortField("ParticipatingGPIOs", 0),
    670                   XByteField("EventAttributes", 0),
    671                   XShortField("reserved_evb", 0),
    672                 ]
    673 
    674     def extract_padding(self, p):
    675         return b"", p
    676 
    677 class ModulePIB(Packet):
    678     """
    679         Simple Module PIB Decoder.
    680             /!\ A wrong slice would produce 'bad' results
    681     """
    682     name = "ModulePIB"
    683     __slots__ = ["_ModulePIB__offset", "_ModulePIB__length"]
    684     fields_desc=[
    685         ConditionalField(XByteField("FirmwareMajorVersion", 0x00),
    686                          lambda pkt:(0x0 == pkt.__offset and 0x1 <= pkt.__offset+pkt.__length)), # The following conditional fiels just check if the current field fits in the data range
    687         ConditionalField(XByteField("PIBMinorVersion", 0x00),
    688                          lambda pkt:(0x1 >= pkt.__offset and 0x2 <= pkt.__offset+pkt.__length)),
    689         ConditionalField(XShortField("reserved_1" , 0x0000),
    690                          lambda pkt:(0x2 >= pkt.__offset and 0x4 <= pkt.__offset+pkt.__length)),
    691         ConditionalField(XShortField("PIBLength" , 0x0000),
    692                          lambda pkt:(0x4 >= pkt.__offset and 0x6 <= pkt.__offset+pkt.__length)),
    693         ConditionalField(XShortField("reserved_2" , 0x0000),
    694                          lambda pkt:(0x6 >= pkt.__offset and 0x8 <= pkt.__offset+pkt.__length)),
    695         ConditionalField(LEIntField("checksumPIB", None),
    696                          lambda pkt:(0x8 >= pkt.__offset and 0xC <= pkt.__offset+pkt.__length)),
    697         ConditionalField(MACField("PIBMACAddr", "00:00:00:00:00:00"),
    698                          lambda pkt:(0xC >= pkt.__offset and 0x12 <= pkt.__offset+pkt.__length)),
    699         ConditionalField(StrFixedLenField("DAK",
    700                                           b"\x00"*16,
    701                                           16),
    702                          lambda pkt:(0x12 >= pkt.__offset and 0x22 <= pkt.__offset+pkt.__length)),
    703         ConditionalField(XShortField("reserved_3" , 0x0000),
    704                          lambda pkt:(0x22 >= pkt.__offset and 0x24 <= pkt.__offset+pkt.__length)),
    705         ConditionalField(StrFixedLenField("ManufactorID",
    706                                           b"\x00"*64,
    707                                           64),
    708                          lambda pkt:(0x24 >= pkt.__offset and 0x64 <= pkt.__offset+pkt.__length)),
    709         ConditionalField(StrFixedLenField("NMK",
    710                                           b"\x00"*16,
    711                                           16),
    712                          lambda pkt:(0x64 >= pkt.__offset and 0x74 <= pkt.__offset+pkt.__length)),
    713         ConditionalField(StrFixedLenField("UserID",
    714                                           b"\x00"*64,
    715                                           64),
    716                          lambda pkt:(0x74 >= pkt.__offset and 0xB4 <= pkt.__offset+pkt.__length)),
    717         ConditionalField(StrFixedLenField("AVLN_ID",
    718                                           b"\x00"*64,
    719                                           64),
    720                          lambda pkt:(0xB4 >= pkt.__offset and 0xF4 <= pkt.__offset+pkt.__length)),
    721         ConditionalField(XByteField("CCoSelection", 0x00),
    722                          lambda pkt:(0xF4 >= pkt.__offset and 0xF5 <= pkt.__offset+pkt.__length)),
    723         ConditionalField(XByteField("CoExistSelection", 0x00),
    724                          lambda pkt:(0xF5 >= pkt.__offset and 0xF6 <= pkt.__offset+pkt.__length)),
    725         ConditionalField(XByteField("PLFreqSelection", 0x00),
    726                          lambda pkt:(0xF6 >= pkt.__offset and 0xF7 <= pkt.__offset+pkt.__length)),
    727         ConditionalField(XByteField("H3CDowngradeShld", 0x00),
    728                          lambda pkt:(0xF7 >= pkt.__offset and 0xF8 <= pkt.__offset+pkt.__length)),
    729         ConditionalField(StrFixedLenField("PreferredNID",
    730                                           b"\x00"*7,
    731                                           7),
    732                          lambda pkt:(0xF8 >= pkt.__offset and 0xFF <= pkt.__offset+pkt.__length)),
    733         ConditionalField(XByteField("AutoFWUpgradeable", 0x00),
    734                          lambda pkt:(0xFF >= pkt.__offset and 0x100 <= pkt.__offset+pkt.__length)),
    735         ConditionalField(XByteField("MDUConfiguration", 0x00),
    736                          lambda pkt:(0x100 >= pkt.__offset and 0x101 <= pkt.__offset+pkt.__length)),
    737         ConditionalField(XByteField("MDURole", 0x00),
    738                          lambda pkt:(0x101 >= pkt.__offset and 0x102 <= pkt.__offset+pkt.__length)),
    739         ConditionalField(XByteField("SnifferEnabled", 0x00),
    740                          lambda pkt:(0x102 >= pkt.__offset and 0x103 <= pkt.__offset+pkt.__length)),
    741         ConditionalField(MACField("SnifferMACAddrRetrn", "00:00:00:00:00:00"),
    742                          lambda pkt:(0x103 >= pkt.__offset and 0x109 <= pkt.__offset+pkt.__length)),
    743         ConditionalField(XByteField("WireTapEnable", 0x00),
    744                          lambda pkt:(0x109 >= pkt.__offset and 0x10A <= pkt.__offset+pkt.__length)),
    745         ConditionalField(XShortField("reserved_4" , 0x0000),
    746                          lambda pkt:(0x10A >= pkt.__offset and 0x10C <= pkt.__offset+pkt.__length)),
    747         ConditionalField(XByteField("StaticNetworkEnabled" , 0x00),
    748                          lambda pkt:(0x10C >= pkt.__offset and 0x10D <= pkt.__offset+pkt.__length)),
    749         ConditionalField(XByteField("LD_TEI" , 0x00),
    750                          lambda pkt:(0x10D >= pkt.__offset and 0x10E <= pkt.__offset+pkt.__length)),
    751         ConditionalField(MACField("CCo_MACAdd", "00:00:00:00:00:00"),
    752                          lambda pkt:(0x10E >= pkt.__offset and 0x114 <= pkt.__offset+pkt.__length)),
    753         ConditionalField(XByteField("SNID", 0x00),
    754                          lambda pkt:(0x114 >= pkt.__offset and 0x115 <= pkt.__offset+pkt.__length)),
    755         ConditionalField(XByteField("NumOfPeerNodes", 0x00),
    756                          lambda pkt:(0x115 >= pkt.__offset and 0x116 <= pkt.__offset+pkt.__length)),
    757         ConditionalField(PacketListField("PeerNodes", "", PeerNode, length_from=lambda x: 56),
    758                          lambda pkt:(0x116 >= pkt.__offset and 0x11C <= pkt.__offset+pkt.__length)), 
    759         ConditionalField(StrFixedLenField("reserved_5",
    760                                           b"\x00"*62,
    761                                           62),
    762                          lambda pkt:(0x146 >= pkt.__offset and 0x14e <= pkt.__offset+pkt.__length)),
    763         ConditionalField(XByteField("OverideModeDefaults" , 0x00),
    764                          lambda pkt:(0x18C >= pkt.__offset and 0x18D <= pkt.__offset+pkt.__length)),
    765         ConditionalField(XByteField("DisableFlowControl" , 0x00),
    766                          lambda pkt:(0x18D >= pkt.__offset and 0x18E <= pkt.__offset+pkt.__length)),
    767         ConditionalField(XByteField("AdvertisementCapabilities" , 0x00),
    768                          lambda pkt:(0x18E >= pkt.__offset and 0x18F <= pkt.__offset+pkt.__length)),
    769         ConditionalField(XByteField("OverrideMeteringDefaults" , 0x00),
    770                          lambda pkt:(0x18F >= pkt.__offset and 0x190 <= pkt.__offset+pkt.__length)),
    771         ConditionalField(LEIntField("MaxFramesPerSec" , 0),
    772                          lambda pkt:(0x190 >= pkt.__offset and 0x194 <= pkt.__offset+pkt.__length)),
    773         ConditionalField(XByteField("DisableAutoNegotiation" , 0x00),
    774                          lambda pkt:(0x194 >= pkt.__offset and 0x195 <= pkt.__offset+pkt.__length)),
    775         ConditionalField(XByteField("EnetSpeedSetting" , 0x00),
    776                          lambda pkt:(0x195 >= pkt.__offset and 0x196 <= pkt.__offset+pkt.__length)),
    777         ConditionalField(XByteField("EnetDuplexSetting" , 0x00),
    778                          lambda pkt:(0x196 >= pkt.__offset and 0x197 <= pkt.__offset+pkt.__length)),
    779         ConditionalField(XByteField("DisableTxFlowControl" , 0x00),
    780                          lambda pkt:(0x197 >= pkt.__offset and 0x198 <= pkt.__offset+pkt.__length)),
    781         ConditionalField(XByteField("DisableRxFlowControl" , 0x00),
    782                          lambda pkt:(0x198 >= pkt.__offset and 0x199 <= pkt.__offset+pkt.__length)),
    783         ConditionalField(XByteField("PhyAddressSelection" , 0x00),
    784                          lambda pkt:(0x199 >= pkt.__offset and 0x19A <= pkt.__offset+pkt.__length)),
    785         ConditionalField(XByteField("PhyAddressSelection_Data" , 0x00),
    786                          lambda pkt:(0x19A >= pkt.__offset and 0x19B <= pkt.__offset+pkt.__length)),
    787         ConditionalField(XByteField("reserved_6" , 0x00),
    788                          lambda pkt:(0x19B >= pkt.__offset and 0x19C <= pkt.__offset+pkt.__length)),
    789         ConditionalField(XByteField("Force33MHz" , 0x00),
    790                          lambda pkt:(0x19C >= pkt.__offset and 0x19D <= pkt.__offset+pkt.__length)),
    791         ConditionalField(XByteField("LinkStatusOnPowerline" , 0x00),
    792                          lambda pkt:(0x19D >= pkt.__offset and 0x19E <= pkt.__offset+pkt.__length)),
    793         ConditionalField(XByteField("OverrideIdDefaults" , 0x00),
    794                          lambda pkt:(0x19E >= pkt.__offset and 0x19F <= pkt.__offset+pkt.__length)),
    795         ConditionalField(XByteField("OverrideSubIdDefaults" , 0x00),
    796                          lambda pkt:(0x19F >= pkt.__offset and 0x1A0 <= pkt.__offset+pkt.__length)),
    797         ConditionalField(XShortField("PCIDeviceID" , 0x0000),
    798                          lambda pkt:(0x1A0 >= pkt.__offset and 0x1A2 <= pkt.__offset+pkt.__length)),
    799         ConditionalField(XShortField("PCIVendorID" , 0x0000),
    800                          lambda pkt:(0x1A2 >= pkt.__offset and 0x1A4 <= pkt.__offset+pkt.__length)),
    801         ConditionalField(XByteField("reserved_7" , 0x00),
    802                          lambda pkt:(0x1A4 >= pkt.__offset and 0x1A5 <= pkt.__offset+pkt.__length)),
    803         ConditionalField(XByteField("PCIClassCode" , 0x00),
    804                          lambda pkt:(0x1A5 >= pkt.__offset and 0x1A6 <= pkt.__offset+pkt.__length)),
    805         ConditionalField(XByteField("PCIClassCodeSubClass" , 0x00),
    806                          lambda pkt:(0x1A6 >= pkt.__offset and 0x1A7 <= pkt.__offset+pkt.__length)),
    807         ConditionalField(XByteField("PCIRevisionID" , 0x00),
    808                          lambda pkt:(0x1A7 >= pkt.__offset and 0x1A8 <= pkt.__offset+pkt.__length)),
    809         ConditionalField(XShortField("PCISubsystemID" , 0x0000),
    810                          lambda pkt:(0x1A8 >= pkt.__offset and 0x1AA <= pkt.__offset+pkt.__length)),
    811         ConditionalField(XShortField("PCISybsystemVendorID" , 0x0000),
    812                          lambda pkt:(0x1AA >= pkt.__offset and 0x1AC <= pkt.__offset+pkt.__length)),
    813         ConditionalField(StrFixedLenField("reserved_8",
    814                                           b"\x00"*64,
    815                                           64),
    816                          lambda pkt:(0x1AC >= pkt.__offset and 0x1EC <= pkt.__offset+pkt.__length)),
    817         ConditionalField(XByteField("OverrideIGMPDefaults" , 0x00),
    818                          lambda pkt:(0x1EC >= pkt.__offset and 0x1ED <= pkt.__offset+pkt.__length)),
    819         ConditionalField(XByteField("ConfigFlags" , 0x00),
    820                          lambda pkt:(0x1ED >= pkt.__offset and 0x1EE <= pkt.__offset+pkt.__length)),
    821         ConditionalField(XByteField("NumCpToSend_PLFrames" , 0x00),
    822                          lambda pkt:(0x1EE >= pkt.__offset and 0x1EF <= pkt.__offset+pkt.__length)),
    823         ConditionalField(StrFixedLenField("reserved_9",
    824                                           b"\x00"*29,
    825                                           29),
    826                          lambda pkt:(0x1EF >= pkt.__offset and 0x20C <= pkt.__offset+pkt.__length)),
    827         ConditionalField(XByteField("UniCastPriority" , 0x00),
    828                          lambda pkt:(0x20C >= pkt.__offset and 0x20D <= pkt.__offset+pkt.__length)),
    829         ConditionalField(XByteField("McastPriority" , 0x00),
    830                          lambda pkt:(0x20D >= pkt.__offset and 0x20E <= pkt.__offset+pkt.__length)),
    831         ConditionalField(XByteField("IGMPPriority" , 0x00),
    832                          lambda pkt:(0x20E >= pkt.__offset and 0x20F <= pkt.__offset+pkt.__length)),
    833         ConditionalField(XByteField("AVStreamPriority" , 0x00),
    834                          lambda pkt:(0x20F >= pkt.__offset and 0x210 <= pkt.__offset+pkt.__length)),
    835         ConditionalField(LEIntField("PriorityTTL_0" , 0),
    836                          lambda pkt:(0x210 >= pkt.__offset and 0x214 <= pkt.__offset+pkt.__length)),
    837         ConditionalField(LEIntField("PriorityTTL_1" , 0),
    838                          lambda pkt:(0x214 >= pkt.__offset and 0x218 <= pkt.__offset+pkt.__length)),
    839         ConditionalField(LEIntField("PriorityTTL_2" , 0),
    840                          lambda pkt:(0x218 >= pkt.__offset and 0x21C <= pkt.__offset+pkt.__length)),
    841         ConditionalField(LEIntField("PriorityTTL_3" , 0),
    842                          lambda pkt:(0x21C >= pkt.__offset and 0x220 <= pkt.__offset+pkt.__length)),
    843         ConditionalField(XByteField("EnableVLANOver" , 0x00),
    844                          lambda pkt:(0x220 >= pkt.__offset and 0x221 <= pkt.__offset+pkt.__length)),
    845         ConditionalField(XByteField("EnableTOSOver" , 0x00),
    846                          lambda pkt:(0x221 >= pkt.__offset and 0x222 <= pkt.__offset+pkt.__length)),
    847         ConditionalField(XShortField("reserved_10" , 0x0000),
    848                          lambda pkt:(0x222 >= pkt.__offset and 0x224 <= pkt.__offset+pkt.__length)),
    849         ConditionalField(LEIntField("VLANPrioTOSPrecMatrix" , 0),
    850                          lambda pkt:(0x224 >= pkt.__offset and 0x228 <= pkt.__offset+pkt.__length)),
    851         ConditionalField(LEIntField("NumClassifierPriorityMaps" , 0),
    852                          lambda pkt:(0x228 >= pkt.__offset and 0x22C <= pkt.__offset+pkt.__length)),
    853         ConditionalField(LEIntField("NumAutoConnections" , 0),
    854                          lambda pkt:(0x22C >= pkt.__offset and 0x230 <= pkt.__offset+pkt.__length)), 
    855         ConditionalField(PacketListField("ClassifierPriorityMaps", "", ClassifierPriorityMap, length_from=lambda x: 224),
    856                          lambda pkt:(0x230 >= pkt.__offset and 0x244 <= pkt.__offset+pkt.__length)),
    857         ConditionalField(PacketListField("AutoConnections", "", AutoConnection, length_from=lambda x: 1600),
    858                          lambda pkt:(0x310 >= pkt.__offset and 0x36e <= pkt.__offset+pkt.__length)),
    859         ConditionalField(XByteField("NumberOfConfigEntries" , 0x00),
    860                          lambda pkt:(0x950 >= pkt.__offset and 0x951 <= pkt.__offset+pkt.__length)),
    861         ConditionalField(PacketListField("AggregateConfigEntries", "", AggregateConfigEntrie, length_from=lambda x: 16),
    862                          lambda pkt:(0x951 >= pkt.__offset and 0x961 <= pkt.__offset+pkt.__length)),
    863         ConditionalField(PacketListField("RSVD_CustomAggregationParameters", "", RSVD_CustomAggregationParameter, length_from=lambda x: 48),
    864                          lambda pkt:(0x961 >= pkt.__offset and 0x991 <= pkt.__offset+pkt.__length)),
    865         ConditionalField(StrFixedLenField("reserved_11",
    866                                           b"\x00"*123,
    867                                           123),
    868                          lambda pkt:(0x991 >= pkt.__offset and 0xA0C <= pkt.__offset+pkt.__length)),
    869         ConditionalField(XIntField("ToneMaskType" , 0),
    870                          lambda pkt:(0xA0C >= pkt.__offset and 0xA10 <= pkt.__offset+pkt.__length)),
    871         ConditionalField(XIntField("ToneMaskEnabled" , 0),
    872                          lambda pkt:(0xA10 >= pkt.__offset and 0xA14 <= pkt.__offset+pkt.__length)),
    873         ConditionalField(XIntField("StartTone" , 0),
    874                          lambda pkt:(0xA14 >= pkt.__offset and 0xA18 <= pkt.__offset+pkt.__length)),
    875         ConditionalField(XIntField("EndTone" , 0),
    876                          lambda pkt:(0xA18 >= pkt.__offset and 0xA1C <= pkt.__offset+pkt.__length)),
    877         ConditionalField(StrFixedLenField("reserved_12",
    878                                           b"\x00"*12,
    879                                           12),
    880                          lambda pkt:(0xA1C >= pkt.__offset and 0xA28 <= pkt.__offset+pkt.__length)),
    881         ConditionalField(XIntField("PsdIndex" , 0),
    882                          lambda pkt:(0xA28 >= pkt.__offset and 0xA2C <= pkt.__offset+pkt.__length)),
    883         ConditionalField(XIntField("TxPrescalerType" , 0),
    884                          lambda pkt:(0xA2C >= pkt.__offset and 0xA30 <= pkt.__offset+pkt.__length)),
    885         ConditionalField(PacketListField("PrescalerValues", "", PrescalerValue, length_from=lambda x: 3600),
    886                          lambda pkt:(0xA30 >= pkt.__offset and 0xA34 <= pkt.__offset+pkt.__length)),
    887         ConditionalField(StrFixedLenField("reserved_13",
    888                                           b"\x00"*1484,
    889                                           1484),
    890                          lambda pkt:(0x1840 >= pkt.__offset and 0x1E0C <= pkt.__offset+pkt.__length)),
    891         ConditionalField(XIntField("AllowNEKRotation" , 0),
    892                          lambda pkt:(0x1E0C >= pkt.__offset and 0x1E10 <= pkt.__offset+pkt.__length)),
    893         ConditionalField(XIntField("OverrideLocalNEK" , 0),
    894                          lambda pkt:(0x1E10 >= pkt.__offset and 0x1E14 <= pkt.__offset+pkt.__length)),
    895         ConditionalField(StrFixedLenField("LocalNEKToUse",
    896                                           b"\x00"*16,
    897                                           16),
    898                          lambda pkt:(0x1E14 >= pkt.__offset and 0x1E24 <= pkt.__offset+pkt.__length)),
    899         ConditionalField(XIntField("OverrideNEKRotationTimer" , 0),
    900                          lambda pkt:(0x1E24 >= pkt.__offset and 0x1E28 <= pkt.__offset+pkt.__length)),
    901         ConditionalField(XIntField("NEKRotationTime_Min" , 0),
    902                          lambda pkt:(0x1E28 >= pkt.__offset and 0x1E2C <= pkt.__offset+pkt.__length)),
    903         ConditionalField(StrFixedLenField("reserved_14",
    904                                           b"\x00"*96,
    905                                           96),
    906                          lambda pkt:(0x1E2C >= pkt.__offset and 0x1E8C <= pkt.__offset+pkt.__length)),
    907         ConditionalField(XIntField("AVLNMembership" , 0),
    908                          lambda pkt:(0x1E8C >= pkt.__offset and 0x1E90 <= pkt.__offset+pkt.__length)),
    909         ConditionalField(XIntField("SimpleConnectTimeout" , 0),
    910                          lambda pkt:(0x1E90 >= pkt.__offset and 0x1E94 <= pkt.__offset+pkt.__length)),
    911         ConditionalField(XByteField("EnableLEDThroughputIndicate" , 0),
    912                          lambda pkt:(0x1E94 >= pkt.__offset and 0x1E95 <= pkt.__offset+pkt.__length)),
    913         ConditionalField(XByteField("MidLEDThroughputThreshold_Mbps" , 0),
    914                          lambda pkt:(0x1E95 >= pkt.__offset and 0x1E96 <= pkt.__offset+pkt.__length)),
    915         ConditionalField(XByteField("HighLEDThroughputThreshold_Mbps" , 0),
    916                          lambda pkt:(0x1E96 >= pkt.__offset and 0x1E97 <= pkt.__offset+pkt.__length)),
    917         ConditionalField(XByteField("reserved_15" , 0),
    918                          lambda pkt:(0x1E97 >= pkt.__offset and 0x1E98 <= pkt.__offset+pkt.__length)),
    919         ConditionalField(XByteField("EnableUnicastQuieriesToMember" , 0),
    920                          lambda pkt:(0x1E98 >= pkt.__offset and 0x1E99 <= pkt.__offset+pkt.__length)),
    921         ConditionalField(XByteField("DisableMLDGroupIDCheckInMAC" , 0),
    922                          lambda pkt:(0x1E99 >= pkt.__offset and 0x1E9A <= pkt.__offset+pkt.__length)),
    923         ConditionalField(XShortField("EnableReportsToNonQuerierHosts" , 0),
    924                          lambda pkt:(0x1E9A >= pkt.__offset and 0x1E9C <= pkt.__offset+pkt.__length)),
    925         ConditionalField(XIntField("DisableExpireGroupMembershipInterval" , 0),
    926                          lambda pkt:(0x1E9C >= pkt.__offset and 0x1EA0 <= pkt.__offset+pkt.__length)),
    927         ConditionalField(XIntField("DisableLEDTestLights" , 0),
    928                          lambda pkt:(0x1EA0 >= pkt.__offset and 0x1EA4 <= pkt.__offset+pkt.__length)),
    929         ConditionalField(PacketListField("GPIOMaps", "", GPIOMap, length_from=lambda x: 12),
    930                          lambda pkt:(0x1EA4 >= pkt.__offset and 0x1EB0 <= pkt.__offset+pkt.__length)),
    931         ConditionalField(XLongField("reserved_16" , 0),
    932                          lambda pkt:(0x1EB0 >= pkt.__offset and 0x1EB8 <= pkt.__offset+pkt.__length)),
    933         ConditionalField(XByteField("EnableTrafficClass_DSCPOver" , 0),
    934                          lambda pkt:(0x1EB8 >= pkt.__offset and 0x1EB9 <= pkt.__offset+pkt.__length)),
    935         ConditionalField(StrFixedLenField("TrafficClass_DSCPMatrices",
    936                                           b"\x00"*64,
    937                                           64),
    938                          lambda pkt:(0x1EB9 >= pkt.__offset and 0x1EF9 <= pkt.__offset+pkt.__length)),
    939         ConditionalField(XByteField("GPIOControl" , 0),
    940                          lambda pkt:(0x1EF9 >= pkt.__offset and 0x1EFA <= pkt.__offset+pkt.__length)),
    941         ConditionalField(StrFixedLenField("LEDControl",
    942                                           b"\x00"*32,
    943                                           32),
    944                          lambda pkt:(0x1EFA >= pkt.__offset and 0x1F1A <= pkt.__offset+pkt.__length)),
    945         ConditionalField(XIntField("OverrideMinButtonPressHoldTime" , 0),
    946                          lambda pkt:(0x1F1A >= pkt.__offset and 0x1F1E <= pkt.__offset+pkt.__length)),
    947         ConditionalField(LEIntField("MinButtonPressHoldTime" , 0),
    948                          lambda pkt:(0x1F1E >= pkt.__offset and 0x1F22 <= pkt.__offset+pkt.__length)),
    949         ConditionalField(StrFixedLenField("reserved_17",
    950                                           b"\x00"*22,
    951                                           22),
    952                          lambda pkt:(0x1F22 >= pkt.__offset and 0x1F38 <= pkt.__offset+pkt.__length)),
    953         ConditionalField(XIntField("MemoryProfile" , 0),
    954                          lambda pkt:(0x1F38 >= pkt.__offset and 0x1F3C <= pkt.__offset+pkt.__length)),
    955         ConditionalField(XIntField("DisableAllLEDFlashOnWarmReboot" , 0),
    956                          lambda pkt:(0x1F3C >= pkt.__offset and 0x1F40 <= pkt.__offset+pkt.__length)),
    957         ConditionalField(LEIntField("UplinkLimit_bps" , 0),
    958                          lambda pkt:(0x1F40 >= pkt.__offset and 0x1F44 <= pkt.__offset+pkt.__length)),
    959         ConditionalField(LEIntField("DownlinkLimit_bps" , 0),
    960                          lambda pkt:(0x1F44 >= pkt.__offset and 0x1F48 <= pkt.__offset+pkt.__length)),
    961         ConditionalField(XIntField("MDUStaticSNID" , 0),
    962                          lambda pkt:(0x1F48 >= pkt.__offset and 0x1F4C <= pkt.__offset+pkt.__length)),
    963         ConditionalField(XByteField("MitigateEnabled" , 0),
    964                          lambda pkt:(0x1F4C >= pkt.__offset and 0x1F4D <= pkt.__offset+pkt.__length)),
    965         ConditionalField(XIntField("CorrelThreshold" , 0),
    966                          lambda pkt:(0x1F4D >= pkt.__offset and 0x1F51 <= pkt.__offset+pkt.__length)),
    967         ConditionalField(LEIntField("ScaledTxGain" , 0),
    968                          lambda pkt:(0x1F51 >= pkt.__offset and 0x1F55 <= pkt.__offset+pkt.__length)),
    969         ConditionalField(XByteField("ResourceThresholdEnabled" , 0),
    970                          lambda pkt:(0x1F55 >= pkt.__offset and 0x1F56 <= pkt.__offset+pkt.__length)),
    971         ConditionalField(PacketListField("ReservedPercentageForCaps", "", ReservedPercentageForCap, length_from=lambda x: 4),
    972                          lambda pkt:(0x1F56 >= pkt.__offset and 0x1F5A <= pkt.__offset+pkt.__length)),
    973         ConditionalField(XByteField("PowerSavingMode" , 0),
    974                          lambda pkt:(0x1F5A >= pkt.__offset and 0x1F5B <= pkt.__offset+pkt.__length)),
    975         ConditionalField(XByteField("PowerLEDDutyCycle" , 0),
    976                          lambda pkt:(0x1F5B >= pkt.__offset and 0x1F5C <= pkt.__offset+pkt.__length)),
    977         ConditionalField(XShortField("reserved_18" , 0),
    978                          lambda pkt:(0x1F5C >= pkt.__offset and 0x1F5E <= pkt.__offset+pkt.__length)),
    979         ConditionalField(LEIntField("LinkUpDurationBeforeReset_ms" , 0),
    980                          lambda pkt:(0x1F5E >= pkt.__offset and 0x1F62 <= pkt.__offset+pkt.__length)),
    981         ConditionalField(LEIntField("PowerLEDPeriod_ms" , 0),
    982                          lambda pkt:(0x1F62 >= pkt.__offset and 0x1F66 <= pkt.__offset+pkt.__length)),
    983         ConditionalField(LEIntField("LinkDownDurationBeforeLowPowerMode_ms" , 0),
    984                          lambda pkt:(0x1F66 >= pkt.__offset and 0x1F6A <= pkt.__offset+pkt.__length)),
    985         ConditionalField(XIntField("reserved_19" , 0),
    986                          lambda pkt:(0x1F6A >= pkt.__offset and 0x1F6E <= pkt.__offset+pkt.__length)),
    987         ConditionalField(XByteField("AfeGainBusMode" , 0),
    988                          lambda pkt:(0x1F6E >= pkt.__offset and 0x1F6F <= pkt.__offset+pkt.__length)),
    989         ConditionalField(XByteField("EnableDynamicPsd" , 0),
    990                          lambda pkt:(0x1F6F >= pkt.__offset and 0x1F70 <= pkt.__offset+pkt.__length)),
    991         ConditionalField(XByteField("ReservedPercentageForTxStreams" , 0),
    992                          lambda pkt:(0x1F70 >= pkt.__offset and 0x1F71 <= pkt.__offset+pkt.__length)),
    993         ConditionalField(XByteField("ReservedPercentageForRxStreams" , 0),
    994                          lambda pkt:(0x1F71 >= pkt.__offset and 0x1F72 <= pkt.__offset+pkt.__length)),
    995         ConditionalField(StrFixedLenField("reserved_20",
    996                                           b"\x00"*22,
    997                                           22),
    998                          lambda pkt:(0x1F72 >= pkt.__offset and 0x1F88 <= pkt.__offset+pkt.__length)),
    999         ConditionalField(XIntField("LegacyNetworkUpgradeEnable" , 0),
   1000                          lambda pkt:(0x1F88 >= pkt.__offset and 0x1F8C <= pkt.__offset+pkt.__length)),
   1001         ConditionalField(XIntField("unknown" , 0),
   1002                          lambda pkt:(0x1F8C >= pkt.__offset and 0x1F90 <= pkt.__offset+pkt.__length)),
   1003         ConditionalField(LEIntField("MMETTL_us" , 0),
   1004                          lambda pkt:(0x1F90 >= pkt.__offset and 0x1F94 <= pkt.__offset+pkt.__length)),
   1005         ConditionalField(PacketListField("ConfigBits", "", ConfigBit, length_from=lambda x: 2),
   1006                          lambda pkt:(0x1F94 >= pkt.__offset and 0x1F96 <= pkt.__offset+pkt.__length)),
   1007         ConditionalField(LEIntField("TxToneMapExpiry_ms" , 0),
   1008                          lambda pkt:(0x1F96 >= pkt.__offset and 0x1F9A <= pkt.__offset+pkt.__length)),
   1009         ConditionalField(LEIntField("RxToneMapExpiry_ms" , 0),
   1010                          lambda pkt:(0x1F9A >= pkt.__offset and 0x1F9E <= pkt.__offset+pkt.__length)),
   1011         ConditionalField(LEIntField("TimeoutToResound_ms" , 0),
   1012                          lambda pkt:(0x1F9E >= pkt.__offset and 0x1FA2 <= pkt.__offset+pkt.__length)),
   1013         ConditionalField(XIntField("MissingSackThresholdForUnplugDetection" , 0),
   1014                          lambda pkt:(0x1FA2 >= pkt.__offset and 0x1FA6 <= pkt.__offset+pkt.__length)),
   1015         ConditionalField(LEIntField("UnplugTimeout_ms" , 0),
   1016                          lambda pkt:(0x1FA6 >= pkt.__offset and 0x1FAA <= pkt.__offset+pkt.__length)),
   1017         ConditionalField(PacketListField("ContentionWindowTableES", "", ContentionWindowTable, length_from=lambda x: 8),
   1018                          lambda pkt:(0x1FAA >= pkt.__offset and 0x1FB2 <= pkt.__offset+pkt.__length)),
   1019         ConditionalField(PacketListField("BackoffDeferalCountTableES", "", BackoffDeferalCountTable, length_from=lambda x: 4),
   1020                          lambda pkt:(0x1FB2 >= pkt.__offset and 0x1FB6 <= pkt.__offset+pkt.__length)),
   1021         ConditionalField(XByteField("GoodSoundCountThreshold" , 0),
   1022                          lambda pkt:(0x1FB6 >= pkt.__offset and 0x1FB7 <= pkt.__offset+pkt.__length)),
   1023         ConditionalField(XByteField("SoundCountThreshold_GoodSoundCountPass" , 0),
   1024                          lambda pkt:(0x1FB7 >= pkt.__offset and 0x1FB8 <= pkt.__offset+pkt.__length)),
   1025         ConditionalField(XByteField("SoundCountThreshold_GoodSoundCountFail" , 0),
   1026                          lambda pkt:(0x1FB8 >= pkt.__offset and 0x1FB9 <= pkt.__offset+pkt.__length)),
   1027         ConditionalField(XShortField("reserved_21" , 0),
   1028                          lambda pkt:(0x1FB9 >= pkt.__offset and 0x1FBB <= pkt.__offset+pkt.__length)),
   1029         ConditionalField(XByteField("ExclusiveTxPbs_percentage" , 0),
   1030                          lambda pkt:(0x1FBB >= pkt.__offset and 0x1FBC <= pkt.__offset+pkt.__length)),
   1031         ConditionalField(XByteField("ExclusiveRxPbs_percentage" , 0),
   1032                          lambda pkt:(0x1FBC >= pkt.__offset and 0x1FBD <= pkt.__offset+pkt.__length)),
   1033         ConditionalField(XByteField("OptimizationBackwardCompatible" , 0),
   1034                          lambda pkt:(0x1FBD >= pkt.__offset and 0x1FBE <= pkt.__offset+pkt.__length)),
   1035         ConditionalField(XByteField("reserved_21" , 0),
   1036                          lambda pkt:(0x1FBE >= pkt.__offset and 0x1FBF <= pkt.__offset+pkt.__length)),
   1037         ConditionalField(XByteField("MaxPbsPerSymbol" , 0),
   1038                          lambda pkt:(0x1FBF >= pkt.__offset and 0x1FC0 <= pkt.__offset+pkt.__length)),
   1039         ConditionalField(XByteField("MaxModulation" , 0),
   1040                          lambda pkt:(0x1FC0 >= pkt.__offset and 0x1FC1 <= pkt.__offset+pkt.__length)),
   1041         ConditionalField(XByteField("ContinuousRx" , 0),
   1042                          lambda pkt:(0x1FC1 >= pkt.__offset and 0x1FC2 <= pkt.__offset+pkt.__length)),
   1043         ConditionalField(StrFixedLenField("reserved_22",
   1044                                           b"\x00"*6,
   1045                                           6),
   1046                          lambda pkt:(0x1FC2 >= pkt.__offset and 0x1FC8 <= pkt.__offset+pkt.__length)),
   1047         ConditionalField(XByteField("PBControlStatus" , 0),
   1048                          lambda pkt:(0x1FC8 >= pkt.__offset and 0x1FC9 <= pkt.__offset+pkt.__length)),
   1049         ConditionalField(XByteField("STAMembershipMaskEnabled" , 0),
   1050                          lambda pkt:(0x1FC9 >= pkt.__offset and 0x1FCA <= pkt.__offset+pkt.__length)),
   1051         ConditionalField(XByteField("ExitDefaultEnabled" , 0),
   1052                          lambda pkt:(0x1FCA >= pkt.__offset and 0x1FCB <= pkt.__offset+pkt.__length)),
   1053         ConditionalField(XByteField("RejectDefaultEnabled" , 0),
   1054                          lambda pkt:(0x1FCB >= pkt.__offset and 0x1FCC <= pkt.__offset+pkt.__length)),
   1055         ConditionalField(XByteField("ChainingEnabled" , 0),
   1056                          lambda pkt:(0x1FCC >= pkt.__offset and 0x1FCD <= pkt.__offset+pkt.__length)),
   1057         ConditionalField(StrFixedLenField("VendorSpecificNMK",
   1058                                           b"\x00"*16,
   1059                                           16),
   1060                          lambda pkt:(0x1FCD >= pkt.__offset and 0x1FDD <= pkt.__offset+pkt.__length)),
   1061         ConditionalField(XByteField("LocalMACAddressLimit" , 0),
   1062                          lambda pkt:(0x1FDD >= pkt.__offset and 0x1FDE <= pkt.__offset+pkt.__length)),
   1063         ConditionalField(XByteField("OverrideBridgeTableAgingTime" , 0),
   1064                          lambda pkt:(0x1FDE >= pkt.__offset and 0x1FDF <= pkt.__offset+pkt.__length)),
   1065         ConditionalField(XShortField("LocalBridgeTableAgingTime_min" , 0),
   1066                          lambda pkt:(0x1FDF >= pkt.__offset and 0x1FE1 <= pkt.__offset+pkt.__length)),
   1067         ConditionalField(XShortField("RemoteBridgeTableAgingTime_min" , 0),
   1068                          lambda pkt:(0x1FE1 >= pkt.__offset and 0x1FE3 <= pkt.__offset+pkt.__length)),
   1069         ConditionalField(XIntField("PhySyncReference" , 0),
   1070                          lambda pkt:(0x1FE3 >= pkt.__offset and 0x1FE7 <= pkt.__offset+pkt.__length)),
   1071         ConditionalField(XByteField("reserved_23" , 0),
   1072                          lambda pkt:(0x1FE7 >= pkt.__offset and 0x1FE8 <= pkt.__offset+pkt.__length)),
   1073         ConditionalField(XIntField("reserved_24" , 0),
   1074                          lambda pkt:(0x1FE8 >= pkt.__offset and 0x1FEC <= pkt.__offset+pkt.__length)),
   1075         ConditionalField(XIntField("reserved_25" , 0),
   1076                          lambda pkt:(0x1FEC >= pkt.__offset and 0x1FF0 <= pkt.__offset+pkt.__length)),
   1077         ConditionalField(StrFixedLenField("reserved_26",
   1078                                           b"\x00"*24,
   1079                                           24),
   1080                          lambda pkt:(0x1FF0 >= pkt.__offset and 0x2008 <= pkt.__offset+pkt.__length)),
   1081         ConditionalField(XByteField("OverrideDefaultLedEventBehavior" , 0x80),
   1082                          lambda pkt:(0x2008 >= pkt.__offset and 0x2009 <= pkt.__offset+pkt.__length)),
   1083         ConditionalField(XByteField("ReportToHostInfo" , 0),
   1084                          lambda pkt:(0x2009 >= pkt.__offset and 0x200A <= pkt.__offset+pkt.__length)),
   1085         ConditionalField(X3BytesField("reserved_27" , 0),
   1086                          lambda pkt:(0x200A >= pkt.__offset and 0x200D <= pkt.__offset+pkt.__length)),
   1087         ConditionalField(XByteField("NumBehaviors" , 0),
   1088                          lambda pkt:(0x200D >= pkt.__offset and 0x200E <= pkt.__offset+pkt.__length)),
   1089         ConditionalField(PacketListField("BehaviorBlockArrayES", "", BehaviorBlockArray, length_from=lambda x: 1200),
   1090                          lambda pkt:(0x200E >= pkt.__offset and 0x24BE <= pkt.__offset+pkt.__length)),
   1091         ConditionalField(XByteField("NumEvents" , 0),
   1092                          lambda pkt:(0x24BE >= pkt.__offset and 0x24BF <= pkt.__offset+pkt.__length)),
   1093         ConditionalField(PacketListField("EventBlockArrayES", "", EventBlockArray, length_from=lambda x: 550),
   1094                          lambda pkt:(0x24BF >= pkt.__offset and 0x26E5 <= pkt.__offset+pkt.__length)),
   1095     ]
   1096     def __init__(self, packet="", offset = 0x0, length = 0x400):
   1097         self.__offset = offset
   1098         self.__length = length
   1099         return super(ModulePIB,self).__init__(packet)
   1100 
   1101 
   1102 ######################################################################
   1103 # Read MAC Memory
   1104 #####################################################################
   1105 
   1106 StartMACCodes = { 0x00 : "Success" } 
   1107 
   1108 class StartMACRequest(Packet):
   1109     name = "StartMACRequest"
   1110     fields_desc=[ ByteEnumField("ModuleID", 0x00, StartMACCodes),
   1111                   X3BytesField("reserver_1", 0x000000),
   1112                   LEIntField("ImgLoadStartAddr" , 0x00000000),
   1113                   LEIntField("ImgLength", 0x00000000),
   1114                   LEIntField("ImgCheckSum", 0x00000000),
   1115                   LEIntField("ImgStartAddr", 0x00000000),
   1116                 ]
   1117 
   1118 class StartMACConfirmation(Packet):
   1119     name = "StartMACConfirmation"
   1120     fields_desc=[ ByteEnumField("Status", 0x00, StartMACCodes),
   1121                   XByteField("ModuleID", 0x00),
   1122                 ]
   1123 
   1124 ######################################################################
   1125 # Reset Device
   1126 ######################################################################
   1127 
   1128 ResetDeviceCodes = { 0x00 : "Success" }
   1129 
   1130 class ResetDeviceRequest(Packet):
   1131     name = "ResetDeviceRequest"
   1132     fields_desc=[ ]
   1133 
   1134 class ResetDeviceConfirmation(Packet):
   1135     name = "ResetDeviceConfirmation"
   1136     fields_desc=[ ByteEnumField("Status", 0x00, ResetDeviceCodes) ]
   1137 
   1138 ######################################################################
   1139 # Read Configuration Block
   1140 ######################################################################
   1141 
   1142 ReadConfBlockCodes = { 0x00 : "Success" }
   1143 
   1144 class ReadConfBlockRequest(Packet):
   1145     name = "ReadConfBlockRequest"
   1146     fields_desc=[ ]
   1147 
   1148 CBImgTCodes = { 0x00 : "Generic Image",
   1149                 0x01 : "Synopsis configuration",
   1150                 0x02 : "Denali configuration",
   1151                 0x03 : "Denali applet",
   1152                 0x04 : "Runtime firmware",
   1153                 0x05 : "OAS client",
   1154                 0x06 : "Custom image",
   1155                 0x07 : "Memory control applet",
   1156                 0x08 : "Power management applet",
   1157                 0x09 : "OAS client IP stack",
   1158                 0x0A : "OAS client TR069",
   1159                 0x0B : "SoftLoader",
   1160                 0x0C : "Flash layout",
   1161                 0x0D : "Unknown",
   1162                 0x0E : "Chain manifest",
   1163                 0x0F : "Runtime parameters",
   1164                 0x10 : "Custom module in scratch",
   1165                 0x11 : "Custom module update applet" }
   1166 
   1167 class ConfBlock(Packet):
   1168     name = "ConfBlock"
   1169     fields_desc=[ LEIntField("HeaderVersionNum", 0),
   1170                   LEIntField("ImgAddrNVM", 0), 
   1171                   LEIntField("ImgAddrSDRAM", 0),
   1172                   LEIntField("ImgLength", 0),
   1173                   LEIntField("ImgCheckSum", 0),
   1174                   LEIntField("EntryPoint", 0),
   1175                   XByteField("HeaderMinVersion", 0x00),
   1176                   ByteEnumField("HeaderImgType", 0x00, CBImgTCodes), 
   1177                   XShortField("HeaderIgnoreMask", 0x0000), 
   1178                   LEIntField("HeaderModuleID", 0), 
   1179                   LEIntField("HeaderModuleSubID", 0),
   1180                   LEIntField("AddrNextHeaderNVM", 0),
   1181                   LEIntField("HeaderChecksum", 0),
   1182                   LEIntField("SDRAMsize", 0),
   1183                   LEIntField("SDRAMConfRegister", 0),
   1184                   LEIntField("SDRAMTimingRegister_0", 0),
   1185                   LEIntField("SDRAMTimingRegister_1", 0),
   1186                   LEIntField("SDRAMControlRegister", 0),
   1187                   LEIntField("SDRAMRefreshRegister", 0),
   1188                   LEIntField("MACClockRegister", 0),
   1189                   LEIntField("reserved_1", 0), ]
   1190 
   1191 class ReadConfBlockConfirmation(Packet):
   1192     name = "ReadConfBlockConfirmation"
   1193     fields_desc=[ ByteEnumField("Status", 0x00, ReadConfBlockCodes),
   1194                   FieldLenField("BlockLen", None, count_of="ConfigurationBlock", fmt="B"),
   1195                   PacketListField("ConfigurationBlock", None, ConfBlock, length_from=lambda pkt:pkt.BlockLen) ]
   1196 
   1197 
   1198 ######################################################################
   1199 # Write Module Data to NVM
   1200 ######################################################################
   1201 
   1202 class WriteModuleData2NVMRequest(Packet):
   1203     name = "WriteModuleData2NVMRequest"
   1204     fields_desc=[ ByteEnumField("ModuleID", 0x02, ModuleIDList) ]
   1205 
   1206 class WriteModuleData2NVMConfirmation(Packet):
   1207     name = "WriteModuleData2NVMConfirmation"
   1208     fields_desc=[ ByteEnumField("Status", 0x0, StatusCodes),
   1209                   ByteEnumField("ModuleID", 0x02, ModuleIDList) ]
   1210 
   1211 ############################ END ######################################
   1212 
   1213 class HomePlugAV(Packet):
   1214     """
   1215         HomePlugAV Packet - by default => gets devices informations
   1216     """
   1217     name = "HomePlugAV "
   1218     fields_desc=[ MACManagementHeader,
   1219                 ConditionalField(XShortField("FragmentInfo", 0x0), FragmentCond), # Fragmentation Field
   1220                 VendorMME ]
   1221 
   1222     def answers(self, other):
   1223         return ( isinstance(self, HomePlugAV ) )
   1224 
   1225 bind_layers( Ether, HomePlugAV, { "type":0x88e1 } )
   1226 
   1227 #   +----------+------------+--------------------+
   1228 #   | Ethernet | HomePlugAV | Elements + Payload |
   1229 #   +----------+------------+--------------------+
   1230 bind_layers( HomePlugAV, GetDeviceVersion, { "HPtype" : 0xA001 } )
   1231 bind_layers( HomePlugAV, StartMACRequest, { "HPtype" : 0xA00C } )
   1232 bind_layers( HomePlugAV, StartMACConfirmation, { "HPtype" : 0xA00D } )
   1233 bind_layers( HomePlugAV, ResetDeviceRequest, { "HPtype" : 0xA01C } )
   1234 bind_layers( HomePlugAV, ResetDeviceConfirmation, { "HPtype" : 0xA01D } )
   1235 bind_layers( HomePlugAV, NetworkInformationRequest, { "HPtype" : 0xA038 } )
   1236 bind_layers( HomePlugAV, ReadMACMemoryRequest, { "HPtype" : 0xA008 } )
   1237 bind_layers( HomePlugAV, ReadMACMemoryConfirmation, { "HPtype" : 0xA009 } )
   1238 bind_layers( HomePlugAV, ReadModuleDataRequest, { "HPtype" : 0xA024 } )
   1239 bind_layers( HomePlugAV, ReadModuleDataConfirmation, { "HPtype" : 0xA025 } )
   1240 bind_layers( HomePlugAV, WriteModuleDataRequest, { "HPtype" : 0xA020 } ) 
   1241 bind_layers( HomePlugAV, WriteModuleData2NVMRequest, { "HPtype" : 0xA028 } ) 
   1242 bind_layers( HomePlugAV, WriteModuleData2NVMConfirmation, { "HPtype" : 0xA029 } )
   1243 bind_layers( HomePlugAV, NetworkInfoConfirmationV10, { "HPtype" : 0xA039, "version" : 0x00 } )
   1244 bind_layers( HomePlugAV, NetworkInfoConfirmationV11, { "HPtype" : 0xA039, "version" : 0x01 } )
   1245 bind_layers( NetworkInfoConfirmationV10, NetworkInfoV10, { "HPtype" : 0xA039, "version" : 0x00 } )
   1246 bind_layers( NetworkInfoConfirmationV11, NetworkInfoV11, { "HPtype" : 0xA039, "version" : 0x01 } )
   1247 bind_layers( HomePlugAV, HostActionRequired, { "HPtype" : 0xA062 } )
   1248 bind_layers( HomePlugAV, LoopbackRequest, { "HPtype" : 0xA048 } )
   1249 bind_layers( HomePlugAV, LoopbackConfirmation, { "HPtype" : 0xA049 } )
   1250 bind_layers( HomePlugAV, SetEncryptionKeyRequest, { "HPtype" : 0xA050 } )
   1251 bind_layers( HomePlugAV, SetEncryptionKeyConfirmation, { "HPtype" : 0xA051 } )
   1252 bind_layers( HomePlugAV, ReadConfBlockRequest, { "HPtype" : 0xA058 } )
   1253 bind_layers( HomePlugAV, ReadConfBlockConfirmation, { "HPtype" : 0xA059 } ) 
   1254 bind_layers( HomePlugAV, QUAResetFactoryConfirm, { "HPtype" : 0xA07D } )
   1255 bind_layers( HomePlugAV, GetNVMParametersRequest, { "HPtype" : 0xA010 } )
   1256 bind_layers( HomePlugAV, GetNVMParametersConfirmation, { "HPtype" : 0xA011 } )
   1257 bind_layers( HomePlugAV, SnifferRequest,  { "HPtype" : 0xA034 } )
   1258 bind_layers( HomePlugAV, SnifferConfirmation,  { "HPtype" : 0xA035 } )
   1259 bind_layers( HomePlugAV, SnifferIndicate,  { "HPtype" : 0xA036 } )
   1260 
   1261 """
   1262     Credit song : "Western Spaguetti - We are terrorists"
   1263 """ 
   1264