import inspect
from core.commons import printYellow, printGreen

##
## @brief      Support Enumerator class that defines all the Diameter's AVP Codes
## 
## @author: Ilario Dal Grande <ilario.dalgrande@guest.telecomitalia.it>
##
class DiamAVPCodes():
    
    @staticmethod
    def name2code(name):
        attributes = inspect.getmembers(DiamAVPCodes, lambda a:not(inspect.isroutine(a)))
        for a in attributes :
            if a[0].replace('_', '').upper() == name.replace('-', '').upper():
                return a[1]
       
        return None
    
    @staticmethod
    def code2name(code):
        attributes = inspect.getmembers(DiamAVPCodes, lambda a:not(inspect.isroutine(a)))
        members = [a[0] for a in attributes if not(a[0].startswith('__') and a[0].endswith('__')) and a[0].isupper() and a[1]==code]
        
        if members!=[]:
            return members[0]
        
        return None
    
    USER_NAME                                               = 1
    CLASS                                                   = 25
    SESSION_TIMEOUT                                         = 27
    PROXY_STATE                                             = 33
    ACCOUNTING_SESSION_ID                                   = 44
    ACCT_MULTI_SESSION_ID                                   = 50
    EVENT_TIMESTAMP                                         = 55
    ACCT_INTERIM_INTERVAL                                   = 85
    MIP_HOME_LINK_PREFIX                                    = 125
    HOST_IP_ADDRESS                                         = 257
    AUTH_APPLICATION_ID                                     = 258
    ACCT_APPLICATION_ID                                     = 259
    VENDOR_SPECIFIC_APPLICATION_ID                          = 260
    REDIRECT_HOST_USAGE                                     = 261
    REDIRECT_MAX_CACHE_TIME                                 = 262
    SESSION_ID                                              = 263
    ORIGIN_HOST                                             = 264
    SUPPORTED_VENDOR_ID                                     = 265
    VENDOR_ID                                               = 266
    FIRMWARE_REVISION                                       = 267
    RESULT_CODE                                             = 268
    PRODUCT_NAME                                            = 269
    SESSION_BINDING                                         = 270
    SESSION_SERVER_FAILOVER                                 = 271
    MULTI_ROUND_TIME_OUT                                    = 272
    DISCONNECT_CAUSE                                        = 273
    AUTH_REQUEST_TYPE                                       = 274
    AUTH_GRACE_PERIOD                                       = 276
    AUTH_SESSION_STATE                                      = 277
    ORIGIN_STATE_ID                                         = 278
    FAILED_AVP                                              = 279
    PROXY_HOST                                              = 280
    ERROR_MESSAGE                                           = 281
    ROUTE_RECORD                                            = 282
    DESTINATION_REALM                                       = 283
    PROXY_INFO                                              = 284
    RE_AUTH_REQUEST_TYPE                                    = 285
    ACCOUNTING_SUB_SESSION_ID                               = 287
    AUTHORIZATION_LIFETIME                                  = 291
    REDIRECT_HOST                                           = 292
    DESTINATION_HOST                                        = 293
    ERROR_REPORTING_HOST                                    = 294
    TERMINATION_CAUSE                                       = 295
    ORIGIN_REALM                                            = 296
    EXPERIMENTAL_RESULT                                     = 297
    EXPERIMENTAL_RESULT_CODE                                = 298
    INBAND_SECURITY_ID                                      = 299
    E2E_SEQUENCE                                            = 300
    DRMP                                                    = 301
    AAA_SERVER_NAME_3GPP                                    = 318
    MIP_HOME_AGENT_ADDRESS                                  = 334
    MIP_HOME_AGENT_HOST                                     = 348
    ACCOUNTING_RECORD_TYPE                                  = 480
    ACCOUNTING_REALTIME_REQUIRED                            = 483
    ACCOUNTING_RECORD_NUMBER                                = 485
    MIP6_AGENT_INFO                                         = 486
    SERVICE_SELECTION                                       = 493
    MAX_REQUEST_BANDWIDTH_DL                                = 515
    MAX_REQUEST_BANDWIDTH_UL                                = 516
    VISITED_NETWORK_IDENTIFIER                              = 600
    PUBLIC_IDENTITY                                         = 601
    SERVER_NAME                                             = 602
    SERVER_CAPABILITY                                       = 603
    MANDATORY_CAPABILITY                                    = 604
    OPTIONAL_CAPABILITY                                     = 605
    USER_DATA                                               = 606
    SIP_NUMBER_AUTH_ITEMS                                   = 607
    SIP_AUTHENTICATION_SCHEME                               = 608
    SIP_AUTHENTICATE                                        = 609
    SIP_AUTHORIZATION                                       = 610
    SIP_AUTHENTICATION_CONTEXT                              = 611
    SIP_AUTH_DATA_ITEM                                      = 612
    SIP_ITEM_NUMBER                                         = 613
    SERVER_ASSIGNMENT_TYPE                                  = 614
    OC_SUPPORTED_FEATURES                                   = 621
    OC_FEATURES_VECTOR                                      = 622
    OC_OLR                                                  = 623
    USER_AUTHORIZATION_TYPE                                 = 623
    OC_SEQUENCE_NUMBER                                      = 624
    USER_DATA_ALREADY_AVAILABLE                             = 624
    OC_VALIDITY_DURATION                                    = 625
    OC_REPORT_TYPE                                          = 626
    OC_REDUCTION_PERCENTAGE                                 = 627
    SUPPORTED_FEATURES                                      = 628
    FEATURE_LIST_ID                                         = 629
    FEATURE_LIST                                            = 630
    WILDCARDED_PUBLIC_IDENTITY                              = 634
    UAR_FLAGS                                               = 637
    SCSCF_RESTORATION_INFO                                  = 639
    MSISDN                                                  = 701
    SERVED_PARTY_IP_ADDRESS                                 = 848
    QOS_CLASS_IDENTIFIER                                    = 1028
    RAT                                                     = 1032
    ALLOCATION_RETENTION_PRIORITY                           = 1034
    PRIORITY_LEVEL                                          = 1046
    PRE_EMPTION_CAPABILITY                                  = 1047
    PRE_EMPTION_VULNERABILITY                               = 1048
    LCS_FORMAT_INDICATOR                                    = 1237
    LCS_NAME_STRING                                         = 1238
    LCS_REQUESTOR_ID_STRING                                 = 1240
    LCS_CLIENT_TYPE                                         = 1241
    LOCATION_ESTIMATE                                       = 1242
    SUBSCRIPTION_DATA                                       = 1400
    TERMINAL_INFORMATION                                    = 1401
    IMEI                                                    = 1402
    SOFTWARE_VERSION                                        = 1403
    ULR_FLAGS                                               = 1405
    ULA_FLAGS                                               = 1406
    VISITED_PLMN_ID                                         = 1407
    REQUESTED_EUTRAN_AUTHENTICATION_INFO                    = 1408
    REQUESTED_UTRAN_GERAN_AUTHENTICATION_INFO               = 1409
    NUMBER_OF_REQUESTED_VECTORS                             = 1410
    RE_SYNCRONIZATION_INFO                                  = 1411
    IMMEDIATE_RESPONSE_PREFERRED                            = 1412
    AUTHENTICATION_INFO                                     = 1413
    NETWORK_ACCESS_MODE                                     = 1417
    HPLMN_ODB                                               = 1418
    CANCELLATION_TYPE                                       = 1420
    DSR_FLAGS                                               = 1421
    DSA_FLAGS                                               = 1422
    CONTEXT_IDENTIFIER                                      = 1423
    SUBSCRIBER_STATUS                                       = 1424
    SUBSCRIBER_STATUS                                       = 1424
    OPERATOR_DETERMINED_BARRING                             = 1425
    ACCESS_RESTRICTION_DATA                                 = 1426
    APN_OI_REPLACEMENT                                      = 1427
    ALL_APN_CONFIGURATIONS_INCLUDED_INDICATOR               = 1428
    APN_CONFIGURATION_PROFILE                               = 1429
    APN_CONFIGURATION                                       = 1430
    EPS_SUBSCRIBED_QOS_PROFILE                              = 1431
    VPLMN_DYNAMIC_ADDRESS_ALLOWED                           = 1432
    STN_SR                                                  = 1433
    ALERT_REASON                                            = 1434
    AMBR                                                    = 1435
    CSG_SUBSCRIPTION_DATA                                   = 1436
    PDN_GW_ALLOCATION_TYPE                                  = 1438
    RAT_FREQUENCY_SELECTION_PRIORITY_ID                     = 1440
    IDA_FLAGS                                               = 1441
    PUA_FLAGS                                               = 1442
    NOR_FLAGS                                               = 1443
    USER_ID                                                 = 1444
    EQUIPMENT_STATUS                                        = 1445
    REGIONAL_SUBSCRIPTION_ZONE_CODE                         = 1446
    PDN_TYPE                                                = 1456
    ROAMING_RESTRICTED_DUE_TO_UNSUPPORTED_FEATURE           = 1457
    TRACE_DATA                                              = 1458
    TRACE_REFERENCE                                         = 1459
    GPRS_SUBSCRIPTION_DATA                                  = 1467
    MEID_3GPP2                                              = 1471
    SPECIFIC_APN_INFO                                       = 1472
    LCS_INFO                                                = 1473
    GMLC_NUBER                                              = 1474
    SS_CODE                                                 = 1476
    SS_STATUS                                               = 1477
    TELESERVICE_LIST                                        = 1486
    TS_CODE                                                 = 1487
    CALL_BARRING_INFO                                       = 1488
    SGSN_NUMBER                                             = 1489
    IDR_FLAGS                                               = 1490
    ICS_INDICATOR                                           = 1491
    IMS_VOICE_OVER_PS_SESSION_SUPPORTED                     = 1492
    HOMOGENEOUS_SUPPORT_OF_IMS_VOICE_OVER_PS_SESSIONS       = 1493
    LAST_UE_ACTIVITY_TIME                                   = 1494
    EPS_USER_STATE                                          = 1495
    EPS_LOCATION_INFORMATION                                = 1496
    MME_LOCATION_INFORMATION                                = 1600
    SGSN_LOCATION_INFORMATION                               = 1601
    CELL_GLOBAL_IDENTITY                                    = 1604
    SERVICE_AREA_IDENTITY                                   = 1607
    ACTIVE_APN                                              = 1612
    SIPTO_PERMISSION                                        = 1613
    ERROR_DIAGNOSTIC                                        = 1614
    UE_SRVCC_CAPABILITY                                     = 1615
    MPS_PRIORITY                                            = 1616
    VPLMN_LIPA_ALLOWED                                      = 1617
    LIPA_PERMISSION                                         = 1618
    SUBSCRIBED_PERIODIC_RAU_TAU_TIMER                       = 1619
    RELAY_NODE_INDICATOR                                    = 1633
    MDT_USER_CONSENT                                        = 1634
    PUR_FLAGS                                               = 1635
    SUBSCRIBED_VSRVCC                                       = 1636
    EQUIVALENT_PLMN_LIST                                    = 1637
    CLR_FLAGS                                               = 1638
    TIME_ZONE                                               = 1642
    A_MSISDN                                                = 1643
    MME_NUMBER_FOR_MT_SMS                                   = 1645
    SMS_REGISTER_REQUEST                                    = 1648
    LOCAL_TIME_ZONE                                         = 1649
    DAYLIGHT_SAVING_TIME                                    = 1650
    SUBSCRIPTION_DATA_FLAGS                                 = 1654
    RESTORATION_PRIORITY                                    = 1663
    SGS_MME_IDENTITY                                        = 1664
    SIPTO_LOCAL_NETWORK_PERMISSION                          = 1665
    COUPLED_NODE_DIAMETER_ID                                = 1666
    WLAN_OFFLOADABILITY                                     = 1667
    WLAN_OFFLOADABILITY_EUTRAN                              = 1668
    WLAN_OFFLOADABILITY_UTRAN                               = 1669
    RESET_ID                                                = 1670
    ADJACENT_ACCESS_RESTRICTION_DATA                        = 1673
    DL_BUFFERING_SUGGESTED_PACKET_COUNT                     = 1674
    IMSI_GROUP_ID                                           = 1675
    GROUP_SERVICE_ID                                        = 1676
    GROUP_PLMN_ID                                           = 1677
    LOCAL_GROUP_ID                                          = 1678
    LMSI                                                    = 2400
    SERVING_NODE                                            = 2401
    MME_NAME                                                = 2402
    MSC_NUMBER                                              = 2403
    LCS_CAPANBILITIES_SETS                                  = 2404
    GMLC_ADDRESS                                            = 2405
    ADDITIONAL_SERVING_NODE                                 = 2406
    PPR_ADDRESS                                             = 2407
    MME_REALM                                               = 2408
    SGSN_NAME                                               = 2409
    SGSN_REALM                                              = 2410
    RIA_FLAGS                                               = 2411
    SLG_LOCATION_TYPE                                       = 2500
    LCS_EPS_CLIENT_NAME                                     = 2501
    LCS_REQUESTOR_NAME                                      = 2502
    LCS_PRIORITY                                            = 2503
    LCS_QOS                                                 = 2504
    HORIZONTAL_ACCURACY                                     = 2505
    VERTICAL_ACCURACY                                       = 2506
    VERTICAL_REQUESTED                                      = 2507
    VELOCITY_REQUESTED                                      = 2508
    RESPONSE_TIME                                           = 2509
    SUPPORTED_GAD_SHAPES                                    = 2510
    LCS_CODEWORD                                            = 2511
    LCS_PRIVACY_CHECK                                       = 2512
    ACCURACY_FULFILMENT_INDICATOR                           = 2513
    AGE_OF_LOCATION_ESTIMATE                                = 2514
    VELOCITY_ESTIMATE                                       = 2515
    EUTRAN_POSITIONING_DATA                                 = 2516
    ECGI                                                    = 2517
    LOCATION_EVENT                                          = 2518
    PSEUDONYM_INDICATOR                                     = 2519
    LCS_SERVICE_TYPE_ID                                     = 2520
    LCS_PRIVACY_CHECK_NON_SESSION                           = 2521
    LCS_PRIVACY_CHECK_SESSION                               = 2522
    LCS_QOS_CLASS                                           = 2523
    GERAN_POSITIONING_INFO                                  = 2524
    GERAN_POSITIONING_DATA                                  = 2525
    GERAN_GANSS_POSITIONING_DATA                            = 2526
    UTRAN_POSITIONING_INFO                                  = 2527
    UTRAN_POSITIONING_DATA                                  = 2528
    UTRAN_GANSS_POSITIONING_DATA                            = 2529
    LRR_FLAGS                                               = 2530
    LCS_REFERENCE_NUMBER                                    = 2531
    DEFERRED_LOCATION_TYPE                                  = 2532
    AREA_EVENT_INFO                                         = 2533
    AREA_DEFINITION                                         = 2534
    AREA                                                    = 2535
    AREA_TYPE                                               = 2536
    AREA_IDENTIFICATION                                     = 2537
    OCCURRENCE_INFO                                         = 2538
    INTERVAL_TIME                                           = 2539
    PERIODIC_LDR_INFORMATION                                = 2540
    REPORTING_AMOUNT                                        = 2541
    REPORTING_INTERVAL                                      = 2542
    REPORTING_PLMN_LIST                                     = 2543
    PLMN_ID_LIST                                            = 2544
    PLR_FLAGS                                               = 2545
    PLA_FLAGS                                               = 2546
    DEFERRED_MT_LR_DATA                                     = 2547
    TERMINATION_CAUSE                                       = 2548
    LRA_FLAGS                                               = 2549
    PERIODIC_LOCATION_SUPPORT_INDICATOR                     = 2550
    PRIORITIZED_LIST_INDICATOR                              = 2551
    ESMLC_CELL_INFO                                         = 2552
    CELL_PORTION_ID                                         = 2553
    XRTT_RCID_1                                             = 2554
    CIVIC_ADDRESS                                           = 2556
    BAROMETRIC_PRESSURE                                     = 2557
    UTRAN_ADDITIONAL_POSITIONING_DATA                       = 2558
    AESE_COMMUNICATION_PATTERN                              = 3113
    PROSE_SUBSCRIPTION_DATA                                 = 3701
    PROSE_PERMISSION                                        = 3702
    