#include "diameter_codets.h"
#include "common_sip_msrp.h"

//#include "t3devlib/t3devlib.h"

#include <iostream>
#include <fstream>

namespace t3devlib { 


#define DIAMETER_ONLY 1
#ifdef DIAMETER_ONLY

  void PAInit()
  {
  }
  
  void SAInit()
  {
  }
  
  void CDInit()
  {
  }
  
  void PAReset()
  {
  }
  
  void SAReset()
  {
  }

#endif
	
	namespace gen {

#define AVP_CODE_NOT_IN_USE 0 //used for replacing items in collections
//vendor ID for 3GPP (10415).

//AVP codes from RFC 3588
#define AVP_CODE_Accounting_Realtime_Required 483
#define AVP_CODE_Acct_Multi_Session_Id 50
#define AVP_CODE_Accounting_Record_Number 485
#define AVP_CODE_Accounting_Record_Type 480
#define AVP_CODE_Accounting_Session_Id 44
#define AVP_CODE_Accounting_Sub_Session_Id 287
#define AVP_CODE_Acct_Application_Id 259
#define AVP_CODE_Auth_Application_Id 258
#define AVP_CODE_Auth_Request_Type 274
#define AVP_CODE_Authorization_Lifetime 291
#define AVP_CODE_Auth_Grace_Period 276
#define AVP_CODE_Auth_Session_State 277
#define AVP_CODE_Re_Auth_Request_Type 285
#define AVP_CODE_Class 25
#define AVP_CODE_Destination_Host 293
#define AVP_CODE_Destination_Realm 283
#define AVP_CODE_Disconnect_Cause 273
#define AVP_CODE_E2E_Sequence AVP 300
#define AVP_CODE_Error_Message 281
#define AVP_CODE_Error_Reporting_Host 294
#define AVP_CODE_Event_Timestamp 55
#define AVP_CODE_Experimental_Result 297
#define AVP_CODE_Experimental_Result_Code 298
#define AVP_CODE_Failed_AVP 279
#define AVP_CODE_Firmware_Revision 267
#define AVP_CODE_Host_IP_Address 257
#define AVP_CODE_Inband_Security_Id 299
#define AVP_CODE_Multi_Round_Time_Out 272
#define AVP_CODE_Origin_Host 264
#define AVP_CODE_Origin_Realm 296
#define AVP_CODE_Origin_State_Id 278
#define AVP_CODE_Product_Name 269
#define AVP_CODE_Proxy_Host 280
#define AVP_CODE_Proxy_Info 284
#define AVP_CODE_Proxy_State 33
#define AVP_CODE_Redirect_Host 292
#define AVP_CODE_Redirect_Host_Usage 261
#define AVP_CODE_Redirect_Max_Cache_Time 262
#define AVP_CODE_Result_Code 268
#define AVP_CODE_Route_Record 282
#define AVP_CODE_Session_Id 263
#define AVP_CODE_Session_Timeout 27
#define AVP_CODE_Session_Binding 270
#define AVP_CODE_Session_Server_Failover 271
#define AVP_CODE_Supported_Vendor_Id 265
#define AVP_CODE_Termination_Cause 295
#define AVP_CODE_User_Name 1
#define AVP_CODE_Vendor_Id 266
#define AVP_CODE_Vendor_Specific_Application_Id 260

//AVP codes from RFC 4740
#define AVP_CODE_SIP_Accounting_Information 368
#define AVP_CODE_SIP_Accounting_Server_URI 369
#define AVP_CODE_SIP_Credit_Control_Server_URI 370
#define AVP_CODE_SIP_Server_URI 371
#define AVP_CODE_SIP_Server_Capabilities 372
#define AVP_CODE_SIP_Mandatory_Capability 373
#define AVP_CODE_SIP_Optional_Capability 374
#define AVP_CODE_SIP_Server_Assignment_Type 375
#define AVP_CODE_SIP_Auth_Data_Item 376
#define AVP_CODE_SIP_Authentication_Scheme 377
#define AVP_CODE_SIP_Item_Number 378
#define AVP_CODE_SIP_Authenticate 379
#define AVP_CODE_SIP_Authorization 380
#define AVP_CODE_SIP_Authentication_Info 381
#define AVP_CODE_SIP_Number_Auth_Items 382
#define AVP_CODE_SIP_Deregistration_Reason 383
#define AVP_CODE_SIP_Reason_Code 384
#define AVP_CODE_SIP_Reason_Info 385
#define AVP_CODE_SIP_Visited_Network_Id 386
#define AVP_CODE_SIP_User_Authorization_Type 387
#define AVP_CODE_SIP_Supported_User_Data_Type 388
#define AVP_CODE_SIP_User_Data 389
#define AVP_CODE_SIP_User_Data_Type 390
#define AVP_CODE_SIP_User_Data_Contents 391
#define AVP_CODE_SIP_User_Data_Already_Available 392
#define AVP_CODE_SIP_Method 393//TODO: this is redefined in another standard with a different ID

//AVP codes from 129.214
#define AVP_CODE_Abort_Cause 500
#define AVP_CODE_Access_Network_Charging_Address 501
#define AVP_CODE_Access_Network_Charging_Identifier 502
#define AVP_CODE_Access_Network_Charging_Identifier_Value 503
#define AVP_CODE_Acceptable_Service_Info 526
#define AVP_CODE_AF_Application_Identifier 504
#define AVP_CODE_AF_Charging_Identifier 505
#define AVP_CODE_Application_Service_Provider_Identity 532
#define AVP_CODE_Codec_Data 524
#define AVP_CODE_Flow_Description 507
#define AVP_CODE_Flow_Number 509
#define AVP_CODE_Flows 510
#define AVP_CODE_Flow_Status 511
#define AVP_CODE_Flow_Usage 512
#define AVP_CODE_Service_URN 525
#define AVP_CODE_Specific_Action 513
#define AVP_CODE_Max_Requested_Bandwidth_DL 515
#define AVP_CODE_Max_Requested_Bandwidth_UL 516
#define AVP_CODE_Media_Component_Description 517
#define AVP_CODE_Media_Component_Number 518
#define AVP_CODE_Media_Sub_Component 519
#define AVP_CODE_Media_Type 520
#define AVP_CODE_MPS_Identifier 528
#define AVP_CODE_Min_Requested_Bandwidth_DL 534
#define AVP_CODE_Min_Requested_Bandwidth_UL 535
#define AVP_CODE_RR_Bandwidth 521
#define AVP_CODE_RS_Bandwidth 522
#define AVP_CODE_Service_Info_Status 527
#define AVP_CODE_SIP_Forking_Indication 523
#define AVP_CODE_Sponsor_Identity 531
#define AVP_CODE_Sponsored_Connectivity_Data 530
#define AVP_CODE_AF_Signalling_Protocol 529
#define AVP_CODE_Required_Access_Info 536
#define AVP_CODE_Rx_Request_Type 533


//AVP codes RFC 4006
#define AVP_CODE_CC_Correlation_Id 411
#define AVP_CODE_CC_Input_Octets 412
#define AVP_CODE_CC_Money 413
#define AVP_CODE_CC_Output_Octets 414
#define AVP_CODE_CC_Request_Number 415
#define AVP_CODE_CC_Request_Type 416
#define AVP_CODE_CC_Service_Specific_Units 417
#define AVP_CODE_CC_Session_Failover 418
#define AVP_CODE_CC_Sub_Session_Id 419
#define AVP_CODE_CC_Time 420
#define AVP_CODE_CC_Total_Octets 421
#define AVP_CODE_CC_Unit_Type 454
#define AVP_CODE_Check_Balance_Result 422
#define AVP_CODE_Cost_Information 423
#define AVP_CODE_Cost_Unit 424
#define AVP_CODE_Credit_Control 426
#define AVP_CODE_Credit_Control_Failure_Handling 427
#define AVP_CODE_Currency_Code 425
#define AVP_CODE_Direct_Debiting_Failure_Handling 428
#define AVP_CODE_Exponent 429
#define AVP_CODE_Final_Unit_Action 449
#define AVP_CODE_Final_Unit_Indication 430
#define AVP_CODE_Granted_Service_Unit 431
#define AVP_CODE_G_S_U_Pool_Identifier  453
#define AVP_CODE_G_S_U_Pool_Reference 457
#define AVP_CODE_Multiple_Services_Credit_Control 456
#define AVP_CODE_Multiple_Services_Indicator 455
#define AVP_CODE_Rating_Group 432
#define AVP_CODE_Redirect_Address_Type 433
#define AVP_CODE_Redirect_Server 434
#define AVP_CODE_Redirect_Server_Address 435
#define AVP_CODE_Requested_Action 436
#define AVP_CODE_Requested_Service_Unit 437
#define AVP_CODE_Restriction_Filter_Rule 438
#define AVP_CODE_Service_Context_Id 461
#define AVP_CODE_Service_Identifier 439
#define AVP_CODE_Service_Parameter_Info  440
#define AVP_CODE_Service_Parameter_Type 441
#define AVP_CODE_Service_Parameter_Value 442
#define AVP_CODE_Subscription_Id 443
#define AVP_CODE_Subscription_Id_Data 444
#define AVP_CODE_Subscription_Id_Type 450
#define AVP_CODE_Tariff_Change_Usage 452
#define AVP_CODE_Tariff_Time_Change 451
#define AVP_CODE_Unit_Value 445
#define AVP_CODE_Used_Service_Unit 446
#define AVP_CODE_User_Equipment_Info 458
#define AVP_CODE_User_Equipment_Info_Type 459
#define AVP_CODE_User_Equipment_Info_Value 460
#define AVP_CODE_Value_Digits 447
#define AVP_CODE_Validity_Time 448

//AVP codes from 129.212
#define AVP_CODE_Access_Network_Charging_Identifier_Gx 1022
#define AVP_CODE_Allocation_Retention_Priority 1034
#define AVP_CODE_AN_GW_Address 1050
#define AVP_CODE_APN_Aggregate_Max_Bitrate_DL 1040
#define AVP_CODE_APN_Aggregate_Max_Bitrate_UL 1041
#define AVP_CODE_Bearer_Control_Mode 1023
#define AVP_CODE_Bearer_Identifier 1020
#define AVP_CODE_Bearer_Operation 1021
#define AVP_CODE_Bearer_Usage 1000
#define AVP_CODE_Charging_Rule_Install 1001
#define AVP_CODE_Charging_Rule_Remove 1002
#define AVP_CODE_Charging_Rule_Definition 1003
#define AVP_CODE_Charging_Rule_Base_Name 1004
#define AVP_CODE_Charging_Rule_Name 1005
#define AVP_CODE_Charging_Rule_Report 1018
#define AVP_CODE_Charging_Correlation_Indicator 1073
#define AVP_CODE_CoA_IP_Address 1035
#define AVP_CODE_CoA_Information 1039
#define AVP_CODE_CSG_Information_Reporting 1071
#define AVP_CODE_Default_EPS_Bearer_QoS 1049
#define AVP_CODE_Event_Report_Indication 1033
#define AVP_CODE_Event_Trigger 1006
#define AVP_CODE_Flow_Direction 1072
#define AVP_CODE_Flow_Information 1058
#define AVP_CODE_Flow_Label 1057
#define AVP_CODE_IP_CAN_Type 1027
#define AVP_CODE_Guaranteed_Bitrate_DL 1025
#define AVP_CODE_Guaranteed_Bitrate_UL 1026
#define AVP_CODE_Metering_Method 1007
#define AVP_CODE_Monitoring_Key 1066
#define AVP_CODE_Network_Request_Support 1024
#define AVP_CODE_Offline 1008
#define AVP_CODE_Online 1009
#define AVP_CODE_Packet_Filter_Content 1059
#define AVP_CODE_Packet_Filter_Identifier 1060
#define AVP_CODE_Packet_Filter_Information 1061
#define AVP_CODE_Packet_Filter_Operation 1062
#define AVP_CODE_Packet_Filter_Usage 1072
#define AVP_CODE_PDN_Connection_ID 1065
#define AVP_CODE_Precedence 1010
#define AVP_CODE_Pre_emption_Capability 1047
#define AVP_CODE_Pre_emption_Vulnerability 1048
#define AVP_CODE_Priority_Level 1046
#define AVP_CODE_Reporting_Level 1011
#define AVP_CODE_PCC_Rule_Status 1019
#define AVP_CODE_Session_Release_Cause 1045
#define AVP_CODE_QoS_Class_Identifier 1028
#define AVP_CODE_QoS_Information 1016
#define AVP_CODE_QoS_Negotiation 1029
#define AVP_CODE_QoS_Upgrade 1030
#define AVP_CODE_Resource_Allocation_Notification 1063
#define AVP_CODE_Rule_Failure_Code 1031
#define AVP_CODE_Security_Parameter_Index 1056
#define AVP_CODE_TFT_Filter 1012
#define AVP_CODE_TFT_Packet_Filter_Information 1013
#define AVP_CODE_ToS_Traffic_Class 1014
#define AVP_CODE_Tunnel_Header_Filter 1036
#define AVP_CODE_Tunnel_Header_Length 1037
#define AVP_CODE_Tunnel_Information 1038
#define AVP_CODE_RAT_Type 1032
#define AVP_CODE_Revalidation_Time 1042
#define AVP_CODE_Rule_Activation_Time 1043
#define AVP_CODE_Usage_Monitoring_Information 1067
#define AVP_CODE_Rule_DeActivation_Time 1044
#define AVP_CODE_Usage_Monitoring_Level 1068
#define AVP_CODE_Usage_Monitoring_Report 1069
#define AVP_CODE_Usage_Monitoring_Support 1070

//AVP codes from 132.299
#define AVP_CODE_Accounting_Input_Octets 363
#define AVP_CODE_Accounting_Input_Packets 365
#define AVP_CODE_Accounting_Output_Octets 364
#define AVP_CODE_Accounting_Output_Packets 366
#define AVP_CODE_Accounting_Realtime_Required 483
#define AVP_CODE_Accounting_Record_Number 485
#define AVP_CODE_Accounting_Record_Type 480
#define AVP_CODE_Accounting_Sub_Session_Id 287
#define AVP_CODE_Acct_Application_Id 259
#define AVP_CODE_Acct_Interim_Interval 85
#define AVP_CODE_Acct_Multi_Session_Id 50
#define AVP_CODE_Acct_Session_Id 44
#define AVP_CODE_Auth_Application_Id 258
#define AVP_CODE_Called_Station_Id 30
#define AVP_CODE_CC_Correlation_Id 411
#define AVP_CODE_CC_Input_Octets 412
#define AVP_CODE_CC_Money 413
#define AVP_CODE_CC_Output_Octets 414
#define AVP_CODE_CC_Request_Number 415
#define AVP_CODE_CC_Request_Type 416
#define AVP_CODE_CC_Service_Specific_Units 417
#define AVP_CODE_CC_Session_Failover 418
#define AVP_CODE_CC_Sub_Session_Id 419
#define AVP_CODE_CC_Time 420
#define AVP_CODE_CC_Total_Octets 421
#define AVP_CODE_CC_Unit_Type 454
#define AVP_CODE_Check_Balance_Result 422
#define AVP_CODE_Cost_Information 423
#define AVP_CODE_Cost_Unit 424
#define AVP_CODE_Credit_Control 426
#define AVP_CODE_Credit_Control_Failure_Handling 427
#define AVP_CODE_Currency_Code 425
#define AVP_CODE_Destination_Host 293
#define AVP_CODE_Destination_Realm 283
#define AVP_CODE_Direct_Debiting_Failure_Handling 428
#define AVP_CODE_Error_Message 281
#define AVP_CODE_Error_Reporting_Host 294
#define AVP_CODE_Event_Timestamp 55
#define AVP_CODE_Exponent 429
#define AVP_CODE_Failed_AVP 279
#define AVP_CODE_Filter_Id 11
#define AVP_CODE_Final_Unit_Action 449
#define AVP_CODE_Final_Unit_Indication 430
#define AVP_CODE_Granted_Service_Unit 431
#define AVP_CODE_G_S_U_Pool_Identifier 453
#define AVP_CODE_G_S_U_Pool_Reference 457
#define AVP_CODE_Multiple_Services_Credit_Control 456
#define AVP_CODE_Multiple_Services_Indicator 455
#define AVP_CODE_Origin_Host 264
#define AVP_CODE_Origin_Realm 296
#define AVP_CODE_Origin_State_Id 278
#define AVP_CODE_Proxy_Info 284
#define AVP_CODE_Proxy_Host 280
#define AVP_CODE_Proxy_State 33
#define AVP_CODE_Rating_Group 432
#define AVP_CODE_Redirect_Address_Type 433
#define AVP_CODE_Redirect_Host 292
#define AVP_CODE_Redirect_Host_Usage 261
#define AVP_CODE_Redirect_Max_Cache_Time 262
#define AVP_CODE_Redirect_Server 434
#define AVP_CODE_Redirect_Server_Address 435
#define AVP_CODE_Requested_Action 436
#define AVP_CODE_Requested_Service_Unit 437
#define AVP_CODE_Restriction_Filter_Rule 438
#define AVP_CODE_Result_Code 268
#define AVP_CODE_Route_Record 282
#define AVP_CODE_Service_Context_Id 461
#define AVP_CODE_Service_Identifier 439
#define AVP_CODE_Service_Parameter_Info 440
#define AVP_CODE_Service_Parameter_Type 441
#define AVP_CODE_Service_Parameter_Value 442
#define AVP_CODE_Session_Id 263
#define AVP_CODE_Subscription_Id 443
#define AVP_CODE_Subscription_Id_Data 444
#define AVP_CODE_Subscription_Id_Type 450
#define AVP_CODE_Tariff_Change_Usage 452
#define AVP_CODE_Tariff_Time_Change 451
#define AVP_CODE_Termination_Cause 295
#define AVP_CODE_Unit_Value 445
#define AVP_CODE_Used_Service_Unit 446
#define AVP_CODE_User_Equipment_Info 458
#define AVP_CODE_User_Equipment_Info_Type 459
#define AVP_CODE_User_Equipment_Info_Value 460
#define AVP_CODE_User_Name 1
#define AVP_CODE_Value_Digits 447
#define AVP_CODE_Validity_Time 448
#define AVP_CODE_Vendor_Id 266
#define AVP_CODE_Vendor_Specific_Application_Id 260

//do not quite remember where this is from
#define AVP_CODE_Access_Network_Information 1263
#define AVP_CODE_Account_Expiration 2309
#define AVP_CODE_Accumulated_Cost 2052
#define AVP_CODE_Adaptations 1217
#define AVP_CODE_Additional_Content_Information 1207
#define AVP_CODE_Additional_Type_Information 1205
#define AVP_CODE_Address_Data 897
#define AVP_CODE_Address_Domain 898
#define AVP_CODE_Addressee_Type 1208
#define AVP_CODE_Address_Type 899
#define AVP_CODE_AF_Charging_Identifier 505
#define AVP_CODE_AF_Correlation_Information 1276
#define AVP_CODE_Allocation_Retention_Priority 1034
#define AVP_CODE_Alternate_Charged_Party_Address 1280
#define AVP_CODE_AoC_Cost_Information 2053
#define AVP_CODE_AoC_Format 2310
#define AVP_CODE_AoC_Information 2054
#define AVP_CODE_AoC_Request_Type 2055
#define AVP_CODE_AoC_Service 2311
#define AVP_CODE_AoC_Service_Obligatory_Type 2312
#define AVP_CODE_AoC_Service_Type 2313
#define AVP_CODE_AoC_Subscription_Information 2314
#define AVP_CODE_Application_provided_calledparty_address 837
#define AVP_CODE_Application_Server 836
#define AVP_CODE_Application_Server_ID 2101
#define AVP_CODE_Application_Service_Provider_Identity 532
#define AVP_CODE_Application_Server_Information 850
#define AVP_CODE_Application_Service_Type 2102
#define AVP_CODE_Application_Session_ID 2103
#define AVP_CODE_Applic_ID 1218
#define AVP_CODE_Associated_Party_Address 2035
#define AVP_CODE_Associated_URI 856
#define AVP_CODE_Authorised_QoS 849
#define AVP_CODE_Aux_Applic_Info 1219
#define AVP_CODE_Base_Time_Interval 1265
#define AVP_CODE_Bearer_Service 854
#define AVP_CODE_Called_Asserted_Identity 1250
#define AVP_CODE_Called_Party_Address 832
#define AVP_CODE_Calling_Party_Address 831
#define AVP_CODE_Carrier_Select_Routing_Information 2023
#define AVP_CODE_Cause_Code 861
#define AVP_CODE_CG_Address 846
#define AVP_CODE_Change_Condition 2037
#define AVP_CODE_Change_Time 2038
#define AVP_CODE_Charged_Party 857
#define AVP_CODE_Charging_Characteristics_Selection_Mode 2066
#define AVP_CODE_Class_Identifier 1214
#define AVP_CODE_Client_Address 2018
#define AVP_CODE_CN_IP_Multicast_Distribution 921
#define AVP_CODE_Content_Class 1220
#define AVP_CODE_Content_Disposition 828
#define AVP_CODE_Content_ID 2116
#define AVP_CODE_Content_Provider_ID 2117
#define AVP_CODE_Content_Length 827
#define AVP_CODE_Content_Size 1206
#define AVP_CODE_CSG_Access_Mode 2317
#define AVP_CODE_CSG_Id 1437
#define AVP_CODE_CSG_Membership_Indication 2318
#define AVP_CODE_Content_Type 826
#define AVP_CODE_Current_Tariff 2056
#define AVP_CODE_CUG_Information 2304
#define AVP_CODE_Data_Coding_Scheme 2001
#define AVP_CODE_DCD_Information 2115
#define AVP_CODE_Deferred_Location_Event_Type 1230
#define AVP_CODE_Delivery_Report_Requested 1216
#define AVP_CODE_Delivery_Status 2104
#define AVP_CODE_Destination_Interface 2002
#define AVP_CODE_Diagnostics 2039
#define AVP_CODE_Domain_Name 1200
#define AVP_CODE_DRM_Content 1221
#define AVP_CODE_Dynamic_Address_Flag 2051
#define AVP_CODE_Dynamic_Address_Flag_Extension 2068
#define AVP_CODE_Early_Media_Description 1272
#define AVP_CODE_Envelope 1266
#define AVP_CODE_Envelope_End_Time 1267
#define AVP_CODE_Envelope_Reporting 1268
#define AVP_CODE_Envelope_Start_Time 1269
#define AVP_CODE_Event 825
#define AVP_CODE_Event_Charging_TimeStamp 1258
#define AVP_CODE_Event_Type 823
#define AVP_CODE_Expires 888
#define AVP_CODE_File_Repair_Supported 1224
#define AVP_CODE_Flows 510
#define AVP_CODE_GGSN_Address 847
#define AVP_CODE_Guaranteed_Bitrate_UL 1026
#define AVP_CODE_IM_Information 2110
#define AVP_CODE_IMS_Application_Reference_Identifier 2601
#define AVP_CODE_IMS_Charging_Identifier 841
#define AVP_CODE_IMS_Communication_Service_Identifier 1281
#define AVP_CODE_IMS_Information 876
#define AVP_CODE_IMSI_Unauthenticated_Flag 2308
#define AVP_CODE_Incoming_Trunk_Group_Id 852
#define AVP_CODE_Incremental_Cost 2062
#define AVP_CODE_Initial_IMS_Charging_Identifier 2321
#define AVP_CODE_Interface_Id 2003
#define AVP_CODE_Interface_Port 2004
#define AVP_CODE_Interface_Text 2005
#define AVP_CODE_Interface_Type 2006
#define AVP_CODE_Inter_Operator_Identifier 838
#define AVP_CODE_IP_Realm_Default_Indication 2603
#define AVP_CODE_LCS_APN 1231
#define AVP_CODE_LCS_Client_Dialed_By_MS 1233
#define AVP_CODE_LCS_Client_External_ID 1234
#define AVP_CODE_LCS_Client_Id 1232
#define AVP_CODE_LCS_Client_Name 1235
#define AVP_CODE_LCS_Client_Type 1241
#define AVP_CODE_LCS_Data_Coding_Scheme 1236
#define AVP_CODE_LCS_Format_Indicator 1237
#define AVP_CODE_LCS_Information 878
#define AVP_CODE_LCS_Name_String 1238
#define AVP_CODE_LCS_Requestor_Id 1239
#define AVP_CODE_LCS_Requestor_Id_String 1240
#define AVP_CODE_Local_GW_Inserted_Indication 2604
#define AVP_CODE_Local_Sequence_Number 2063
#define AVP_CODE_Location_Estimate 1242
#define AVP_CODE_Location_Estimate_Type 1243
#define AVP_CODE_Location_Type 1244
#define AVP_CODE_Low_Balance_Indication 2020
#define AVP_CODE_Low_Priority_Indicator 2602
#define AVP_CODE_Mandatory_Capability 604
#define AVP_CODE_Max_Requested_Bandwidth_DL 515
#define AVP_CODE_Max_Requested_Bandwidth_UL 516
#define AVP_CODE_MBMS_2G_3G_Indicator 907
#define AVP_CODE_MBMS GW_Address 2307
#define AVP_CODE_MBMS_Information 880
#define AVP_CODE_MBMS_Service_Area 903
#define AVP_CODE_MBMS_Service_Type 906
#define AVP_CODE_MBMS_Session_Identity 908
#define AVP_CODE_MBMS_User_Service_Type 1225
#define AVP_CODE_Media_Initiator_Flag 882
#define AVP_CODE_Media_Initiator_Party 1288
#define AVP_CODE_Message_Body 889
#define AVP_CODE_Message_Class 1213
#define AVP_CODE_Message_ID 1210
#define AVP_CODE_Message_Size 1212
#define AVP_CODE_Message_Type 1211
#define AVP_CODE_MMBox_Storage_Requested 1248
#define AVP_CODE_MM_Content_Type 1203
#define AVP_CODE_MMS_Information 877
#define AVP_CODE_MMTel_Information 2030
#define AVP_CODE_MSISDN 701
#define AVP_CODE_Neighbour_Node_Address 2705
#define AVP_CODE_Next_Tariff 2057
#define AVP_CODE_NNI_Information 2703
#define AVP_CODE_NNI_Type 2704
#define AVP_CODE_Node_Functionality 862
#define AVP_CODE_Node_Id 2064
#define AVP_CODE_Number_Of_Diversions 2034
#define AVP_CODE_Number_Of_Messages_Sent 2019
#define AVP_CODE_Number_Of_Messages_Successfully_Exploded 2111
#define AVP_CODE_Number_Of_Messages_Successfully_Sent 2112
#define AVP_CODE_Number_Of_Participants 885
#define AVP_CODE_Number_Of_Received_Talk_Bursts 1282
#define AVP_CODE_Number_Of_Talk_Bursts 1283
#define AVP_CODE_Number_Portability_Routing_Information 2024
#define AVP_CODE_Offline_Charging 1278
#define AVP_CODE_Online_Charging_Flag 2303
#define AVP_CODE_Optional_Capability 605
#define AVP_CODE_Originating_IOI 839
#define AVP_CODE_Originator_SCCP_Address 2008
#define AVP_CODE_Originator 864
#define AVP_CODE_Originator_Address 886
#define AVP_CODE_Originator_Received_Address 2027
#define AVP_CODE_Originator_Interface 2009
#define AVP_CODE_Outgoing_Session_Id 2320
#define AVP_CODE_Outgoing_Trunk_Group_Id 853
#define AVP_CODE_Participant_Access_Priority 1259
#define AVP_CODE_Participant_Action_Type 2049
#define AVP_CODE_Participant_Group 1260
#define AVP_CODE_Participants_Involved 887
#define AVP_CODE_PDG_Address 895
#define AVP_CODE_PDG_Charging_Id 896
#define AVP_CODE_PDN_Connection_Charging_ID 2050
#define AVP_CODE_PDP_Address 1227
#define AVP_CODE_PDP_Context_Type 1247
#define AVP_CODE_PDP_Address_Prefix_Length 2606
#define AVP_CODE_PoC_Change_Condition 1261
#define AVP_CODE_PoC_Change_Time 1262
#define AVP_CODE_PoC_Controlling_Address 858
#define AVP_CODE_PoC_Event_Type 2025
#define AVP_CODE_PoC_Group_Name 859
#define AVP_CODE_PoC_Information 879
#define AVP_CODE_PoC_Server_Role 883
#define AVP_CODE_PoC_Session_Id 1229
#define AVP_CODE_PoC_Session_Initiation_type 1277
#define AVP_CODE_PoC_Session_Type 884
#define AVP_CODE_PoC_User_Role 1252
#define AVP_CODE_PoC_User_Role_IDs 1253
#define AVP_CODE_PoC_User_Role_info_Units 1254
#define AVP_CODE_Positioning_Data 1245
#define AVP_CODE_Preferred_AoC_Currency 2315
#define AVP_CODE_Priority 1209
#define AVP_CODE_Priority_Level 1046
#define AVP_CODE_PS_Append_Free_Format_Data 867
#define AVP_CODE_PS_Free_Format_Data 866
#define AVP_CODE_PS_Furnish_Charging_Information 865
#define AVP_CODE_PS_Information 874
#define AVP_CODE_QoS_Information 1016
#define AVP_CODE_QoS_Class_Identifier 1028
#define AVP_CODE_Quota_Consumption_Time 881
#define AVP_CODE_Quota_Holding_Time 871
#define AVP_CODE_RAI 909
#define AVP_CODE_Rate_Element 2058
#define AVP_CODE_RAT_Type 1032
#define AVP_CODE_Read_Reply_Report_Requested 1222
#define AVP_CODE_Reason_Code 2316
#define AVP_CODE_Real_Time_Tariff_Information 2305
#define AVP_CODE_Received_Talk_Burst_Time 1284
#define AVP_CODE_Received_Talk_Burst_Volume 1285
#define AVP_CODE_Recipient_Address 1201
#define AVP_CODE_Recipient_Info 2026
#define AVP_CODE_Recipient_Received_Address 2028
#define AVP_CODE_Recipient_SCCP_Address 2010
#define AVP_CODE_Refund_Information 2022
#define AVP_CODE_Relationship_Mode 2706
#define AVP_CODE_Remaining_Balance 2021
#define AVP_CODE_Reply_Applic_ID 1223
#define AVP_CODE_Reply_Path_Requested 2011
#define AVP_CODE_Reporting_Reason 872
#define AVP_CODE_Requested_Party_Address 1251
#define AVP_CODE_Required_MBMS_Bearer_Capabilities 901
#define AVP_CODE_Role_Of_Node 829
#define AVP_CODE_Scale_Factor 2059
#define AVP_CODE_SDP_Answer_Timestamp 1275
#define AVP_CODE_SDP_Media_Component 843
#define AVP_CODE_SDP_Media_Description 845
#define AVP_CODE_SDP_Media_Name 844
#define AVP_CODE_SDP_Offer_Timestamp 1274
#define AVP_CODE_SDP_Session_Description 842
#define AVP_CODE_SDP_TimeStamps 1273
#define AVP_CODE_SDP_Type 2036
#define AVP_CODE_Session_Direction 2707
#define AVP_CODE_Served_Party_IP_Address 848
#define AVP_CODE_Server_Capabilities 603
#define AVP_CODE_Server_Name 602
#define AVP_CODE_Service_Data_Container 2040
#define AVP_CODE_Service_Generic_Information 1256
#define AVP_CODE_Service_Id 855
#define AVP_CODE_Service_Information 873
#define AVP_CODE_Service_Mode 2032
#define AVP_CODE_Service_Specific_Data 863
#define AVP_CODE_Service_Specific_Info 1249
#define AVP_CODE_Service_Specific_Type 1257
#define AVP_CODE_Serving_Node_Type 2047
#define AVP_CODE_Service_Type 2031
#define AVP_CODE_Session_Priority 650
#define AVP_CODE_SGSN_Address 1228
#define AVP_CODE_SGW_Address 2067
#define AVP_CODE_SGW_Change 2065
//#define AVP_CODE_SIP_Method 824 //TODO: this is redefined in another standard with a different ID
#define AVP_CODE_SIP_Request_Timestamp_Fraction 2301
#define AVP_CODE_SIP_Request_Timestamp 834
#define AVP_CODE_SIP_Response_Timestamp_Fraction 2302
#define AVP_CODE_SIP_Response_Timestamp 835
#define AVP_CODE_SM_Discharge_Time 2012
#define AVP_CODE_SM_Message_Type 2007
#define AVP_CODE_SM_Protocol_ID 2013
#define AVP_CODE_SMSC_Address 2017
#define AVP_CODE_SMS_Information 2000
#define AVP_CODE_SMS_Node 2016
#define AVP_CODE_SM_Service_Type 2029
#define AVP_CODE_SM_Status 2014
#define AVP_CODE_SM_User_Data_Header 2015
#define AVP_CODE_Sponsor_Identify 531
#define AVP_CODE_Start_Time 2041
#define AVP_CODE_Status 2702
#define AVP_CODE_Stop_Time 2042
#define AVP_CODE_Submission_Time 1202
#define AVP_CODE_Subscriber_Role 2033
#define AVP_CODE_Supplementary_Service 2048
#define AVP_CODE_Talk_Burst_Exchange 1255
#define AVP_CODE_Talk_Burst_Time 1286
#define AVP_CODE_Talk_Burst_Volume 1287
#define AVP_CODE_Tariff_Information 2060
#define AVP_CODE_Tariff_XML 2306
#define AVP_CODE_Terminal_Information 1401
#define AVP_CODE_Terminating_IOI 840
#define AVP_CODE_Time_First_Usage 2043
#define AVP_CODE_Time_Last_Usage 2044
#define AVP_CODE_Time_Quota_Mechanism 1270
#define AVP_CODE_Time_Quota_Threshold 868
#define AVP_CODE_Time_Quota_Type 1271
#define AVP_CODE_Time_Stamps 833
#define AVP_CODE_Time_Usage 2045
#define AVP_CODE_TMGI 900
#define AVP_CODE_Token_Text 1215
#define AVP_CODE_Total_Number_Of_Messages_Exploded 2113
#define AVP_CODE_Total_Number_Of_Messages_Sent 2114
#define AVP_CODE_Traffic_Data_Volumes 2046
#define AVP_CODE_Transcoder_Inserted_Indication 2605
#define AVP_CODE_Transit_IOI_List 2701
#define AVP_CODE_Trigger 1264
#define AVP_CODE_Trigger_Type 870
#define AVP_CODE_Trunk_Group_Id 851
#define AVP_CODE_Type_Number 1204
#define AVP_CODE_Unit_Cost 2061
#define AVP_CODE_Unit_Quota_Threshold 1226
#define AVP_CODE_User_CSG_Information 2319
//#define AVP_CODE_User_Data 606//TODO: this is redefined in another standard
#define AVP_CODE_User_Participating_Type 1279
#define AVP_CODE_User_Session_Id 830
#define AVP_CODE_VAS_Id 1102
#define AVP_CODE_VASP_Id 1101
#define AVP_CODE_Volume_Quota_Threshold 869
#define AVP_CODE_WAG_Address 890
#define AVP_CODE_WAG_PLMN_Id 891
#define AVP_CODE_WLAN_Information 875
#define AVP_CODE_WLAN_Radio_Container 892
#define AVP_CODE_WLAN_Session_Id 1246
#define AVP_CODE_WLAN_Technology 893
#define AVP_CODE_WLAN_UE_Local_IPAddress 894

//My definitions
#define AVP_CODE_E_UTRAN_Cell_Global_Identity 1602
#define AVP_CODE_Tracking_Area_Identity 1603
#define AVP_CODE_Cell_Global_Identity 1604
#define AVP_CODE_Routing_Area_Identity 1605
#define AVP_CODE_Location_Area_Identity 1606
#define AVP_CODE_Area_Scope 1624
#define AVP_CODE_List_Of_Measurements 1625
#define AVP_CODE_Reporting_Trigger 1626
#define AVP_CODE_Report_Interval 1627
#define AVP_CODE_Report_Amount 1628
#define AVP_CODE_Event_Treshold_RSRP 1629
#define AVP_CODE_Event_Treshold_RSRQ 1630
#define AVP_CODE_Logging_Interval 1631
#define AVP_CODE_Logging_Duration 1632


#define AVP_CODE_Trace_Interface_List 1464 
#define AVP_CODE_OMC_Id 1466
#define AVP_CODE_MDT_Configuration 1622

#define AVP_CODE_ThreeGPP2_BSID 5535//defined as 5535/9010 in x.S0057-A

#define AVP_CODE_ThreeGPP_SGSN_Address 6
#define AVP_CODE_ThreeGPP_SGSN_IPv6_Address 15
#define AVP_CODE_ThreeGPP_SGSN_MCC_MNC 18
#define AVP_CODE_ThreeGPP_User_Location_Info  22
#define AVP_CODE_ThreeGPP_MS_TimeZone 23

#define AVP_CODE_SIP_AOR 122 //based on Page 20 in RFC4740

#define AVP_CODE_Routing_IP_Address 1079
#define AVP_CODE_Trace_Data 1458
#define AVP_CODE_Trace_Reference 1459

//based on 29.329

#define AVP_CODE_User_Identity 700
#define AVP_CODE_MSISDN 701
#define AVP_CODE_User_Data 702
#define AVP_CODE_Data_Reference 703
#define AVP_CODE_Service_Indication 704
#define AVP_CODE_Subs_Req_Type 705
#define AVP_CODE_Requested_Domain 706
#define AVP_CODE_Current_Location 707
#define AVP_CODE_Identity_Set 708
#define AVP_CODE_Expiry_Time 709
#define AVP_CODE_Send_Data_Indication 710
#define AVP_CODE_Server_Name 602
#define AVP_CODE_Supported_Features 628
#define AVP_CODE_Feature_List_ID 629
#define AVP_CODE_Feature_List 630
#define AVP_CODE_Supported_Applications 631
#define AVP_CODE_Public_Identity 601
#define AVP_CODE_DSAI_Tag 711
#define AVP_CODE_Wildcarded_Public_Identity 634
#define AVP_CODE_Wildcarded_IMPU 636
#define AVP_CODE_Session_Priority 650
#define AVP_CODE_One_Time_Notification 712
#define AVP_CODE_Requested_Nodes 713
#define AVP_CODE_Serving_Node_Indication 714
#define AVP_CODE_Repository_Data_ID 715
#define AVP_CODE_Sequence_Number 716


#define AVP_CODE_Framed_IP_Address 8
#define AVP_CODE_Framed_IPv6_Prefix 97
#define AVP_CODE_ThreeGPP_SGSN_Address 6
#define AVP_CODE_ThreeGPP_SGSN_IPv6_Address 15
#define AVP_CODE_ThreeGPP_User_Location_Info 22
#define AVP_CODE_ThreeGPP_MS_TimeZone 23
#define AVP_CODE_ThreeGPP_RAT_Type 21

#define AVP_CODE_Routing_Rule_Remove 1075
#define AVP_CODE_Routing_Rule_Install 1081
#define AVP_CODE_Maximum_Bandwidth 1082

#define AVP_CODE_Logical_Access_ID 302
#define AVP_CODE_Physical_Access_ID 313
#define AVP_CODE_Charging_Information 618

#define AVP_CODE_Reservation_Priority 458

#define AVP_CODE_Routing_Rule_Definition 1076
#define AVP_CODE_Routing_Rule_Identifier 1077
#define AVP_CODE_Routing_Filter 1078
#define AVP_CODE_G_S_U_Pool_Reference 457

#define AVP_CODE_SIP_MandatoryCapability 373
#define AVP_CODE_SIP_OptionalCapability 374

#define AVP_CODE_Reservation_Priority 458


#define AVP_CODE_Trace_Collection_Entity 1452
#define AVP_CODE_Trace_Depth 1462
#define AVP_CODE_Trace_NE_Type_List 1463
#define AVP_CODE_Trace_Event_List 1465
#define AVP_CODE_Job_Type 1623


#define AVP_CODE_Max_Supported_Bandwidth_DL 1083
#define AVP_CODE_Max_Supported_Bandwidth_UL 1084

#define AVP_CODE_Primary_Event_Charging_Function_Name 619
#define AVP_CODE_Secondary_Event_Charging_Function_Name 620
#define AVP_CODE_Primary_Charging_Collection_Function_Name 621
#define AVP_CODE_Secondary_Charging_Collection_Function_Name 622

#define AVP_CODE_Digest_Realm 104
#define AVP_CODE_Digest_Nonce 105
#define AVP_CODE_Digest_Domain 119
#define AVP_CODE_Digest_Opaque 116
#define AVP_CODE_Digest_Stale 120
#define AVP_CODE_Digest_Algorithm 111
#define AVP_CODE_Digest_QoP 110
#define AVP_CODE_Digest_HA1 121
#define AVP_CODE_Digest_Auth_Param 117
#define AVP_CODE_Digest_Username 115
#define AVP_CODE_Digest_URI 109
#define AVP_CODE_Digest_Response 103
#define AVP_CODE_Digest_CNonce 113
#define AVP_CODE_Digest_Nonce_Count 114
#define AVP_CODE_Digest_Method 108
#define AVP_CODE_Digest_Entity_Body_Hash 112
#define AVP_CODE_Digest_Nextnonce 107
#define AVP_CODE_Digest_Response_Auth 106
//#define AVP_CODE_

//////
unsigned int getAVPDataLength(AVP_Header &header)
{
	unsigned int nCode = header.Get_aVP_Code().GetValue();
	unsigned char buff = header.Get_aVP_flags().Get_v_bit().GetValue().at(0); 
	int nV_flag =  (buff >> 7);
	unsigned int nDataLength = header.Get_aVP_len().GetValue();
	nDataLength -= 8;
	if(nV_flag)
		nDataLength -= 4;
	return nDataLength;
}
unsigned int getBytesRemaining_AVP(Buffer &buffer, AVP_Header &header, unsigned int nStartingPosition)
{
	unsigned int nTotalBytes = header.Get_aVP_len().GetValue();
	unsigned int nCurrent = buffer.GetPosition();
	return nTotalBytes - ((nCurrent - nStartingPosition)/8);
}

unsigned int getBytesRemaining_D(Buffer & buffer, DiameterHeader& header, unsigned int nStartingPosition)
{
	unsigned int nDataBytes = header.Get_msglen().GetValue();
	unsigned int nCurrent = buffer.GetPosition();
	return nDataBytes - ((nCurrent - nStartingPosition)/8);
}

unsigned int getAVPCode(Buffer & buffer) throw (DecodeError)
{
	int nStartingPos = buffer.GetPosition();
	Unsigned code(32);
	code.Decode(buffer);
	unsigned int nCode = code.GetValue();
	buffer.SetPosition(nStartingPos);
	return nCode;
}

bool isNextAVP(Buffer & buffer, unsigned int nCode) throw (DecodeError)
{
	return nCode == getAVPCode(buffer);
}

//#define DEBUG_LOG 1

void debug_log(const char * value)
{
	#ifdef DEBUG_LOG
		std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
		logfile << value << std::endl;
		logfile.close();
	#endif
}

void debug_log_PreDecode(const char * type)
{
	#ifdef DEBUG_LOG
		std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
		logfile << type << "::PreDecode: " << std::endl;
		logfile.close();
	#endif
}

void debug_log_PreDecodeField(const char * type, int id)
{
	#ifdef DEBUG_LOG
		std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
		logfile << type << "::PreDecodeField: " << id << std::endl;
		logfile.close();
	#endif
}

void debug_log_PostDecodeField(const char * type, int id)
{
	#ifdef DEBUG_LOG
		std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
		logfile << type << "::PostDecodeField: " << id << std::endl;
		logfile.close();
	#endif
}

FLOAT32::FLOAT32 ()
	:PrimitiveType()
{
}
FLOAT32::~FLOAT32()
{
}

int FLOAT32::GetLength() const
{
	return 32;
}

::t3devlib::Variable::BaseType FLOAT32::GetBaseType() const
{
	return ::t3devlib::Variable::btFloat;
}

float FLOAT32::GetValue() const
{
	return mValue;
}

void FLOAT32::SetValue(float v)
{
	mValue = v;
}

void FLOAT32::SetValue(const FLOAT32& v)
{
	mValue = v.mValue;
}

const unsigned char* FLOAT32::GetValueBin() const
{
	int bytes = 4;
	msBinBuff.clear();
	msBinBuff.reserve (4);	      
	
	int offset = 24;
	for (int i=3 ; i ; i--) {
		msBinBuff += static_cast <unsigned char> (((unsigned int)mValue) >> offset);
		offset -= 8;
	}
	msBinBuff += static_cast <unsigned char> (((unsigned int)mValue) << -offset);
	return reinterpret_cast<const unsigned char*> (msBinBuff.data());
}

void FLOAT32::Decode (Buffer& buffer) throw (DecodeError)
{
	PrimitiveType::Decode (buffer);
}
void FLOAT32::Encode (Buffer& buffer) throw (EncodeError)
{
	PrimitiveType::Encode (buffer);
}

void FLOAT32::Dump (std::ostream& out, int indent) const
{
	for (int i=indent ; i ; i--) {
		out << ' ';
	}
	out << mValue << " - 0x" << std::hex << mValue << std::dec
	    << " (float) "
	    << std::endl;
}

void FLOAT32::DumpInline (std::ostream& out) const
{
	out << mValue;
}

void FLOAT32::SetValueBinNoOffset (const unsigned char* buff, int bit_length)
{
	assert (buff != NULL);
	assert (bit_length >= -1);
	assert (bit_length <= 32);
		
	if (bit_length == -1) {
		bit_length = 32;
	}

	mValue = 0.0f;
	const unsigned char* p = buff;
		
	// full bytes
	unsigned long nTmp;
	for (int my_offset = bit_length-8 ; my_offset >= 0 ; my_offset -= 8) {
		nTmp |= static_cast <unsigned long> (*p) << my_offset;
		p++;
	}
	mValue = (float)nTmp;
}

FLOAT64::FLOAT64 ()
	:PrimitiveType()
{
}
FLOAT64::~FLOAT64()
{
}

int FLOAT64::GetLength() const
{
	return 64;
}

::t3devlib::Variable::BaseType FLOAT64::GetBaseType() const
{
	return ::t3devlib::Variable::btFloat;
}

double FLOAT64::GetValue() const
{
	return mValue;
}

void FLOAT64::SetValue(double v)
{
	mValue = v;
}

void FLOAT64::SetValue(const FLOAT64& v)
{
	mValue = v.mValue;
}

const unsigned char* FLOAT64::GetValueBin() const
{
	int bytes = 8;
	msBinBuff.clear();
	msBinBuff.reserve (bytes);	      
	
	int offset = 56;
	for (int i=7 ; i ; i--) {
		msBinBuff += static_cast <unsigned char> (((unsigned int)mValue) >> offset);
		offset -= 8;
	}
	msBinBuff += static_cast <unsigned char> (((unsigned int)mValue) << -offset);
	return reinterpret_cast<const unsigned char*> (msBinBuff.data());
}

void FLOAT64::Decode (Buffer& buffer) throw (DecodeError)
{
	PrimitiveType::Decode (buffer);
}
void FLOAT64::Encode (Buffer& buffer) throw (EncodeError)
{
	PrimitiveType::Encode (buffer);
}

void FLOAT64::Dump (std::ostream& out, int indent) const
{
	for (int i=indent ; i ; i--) {
		out << ' ';
	}
	out << mValue << " - 0x" << std::hex << mValue << std::dec
	    << " (double) "
	    << std::endl;
}

void FLOAT64::DumpInline (std::ostream& out) const
{
	out << mValue;
}

void FLOAT64::SetValueBinNoOffset (const unsigned char* buff, int bit_length)
{
	assert (buff != NULL);
	assert (bit_length >= -1);
	assert (bit_length <= 64);
		
	if (bit_length == -1) {
		bit_length = 64;
	}

	mValue = 0.0;
	const unsigned char* p = buff;
		
	// full bytes
	unsigned long long nTmp;
	for (int my_offset = bit_length-8 ; my_offset >= 0 ; my_offset -= 8) {
		nTmp |= static_cast <unsigned long long> (*p) << my_offset;
		p++;
	}
	mValue = (double)nTmp;
}


/*
CER_E, // Capabilities-Exchange-Request 	CER  (257)
CEA_E, // Capabilities-Exchange-Answer 	CEA  (257)
RAR_E,  // Re-Auth-Request 				RAR  (258)
RAA_E,  // Re-Auth-Answer 					RAA  (258)

//
ACR_E, // Accounting-Request				ACR(271)
ACA_E, // Accounting-Answer				ACA (271)

//                  
ASR_E, // Abort-Session-Request			ASR (274)
ASA_E, // Abort-Sesion-Answer				ASA (274)
STR_E, // Session-Termination-Request		STR (275)
STA_E, // Session-Termination-Answer		STA (275)  		    

//
DWR_E, // Device-Watchdog-Request			DWR (280)
DWA_E, // Device-Watchdog-Answer			DWA (280) 
DPR_E, // Disconnect-Peer-Requst			DPR (282)
DPA_E, // Disconnect-Peer-Answer			DPA (282) 

// Codes on Cx
UAR_E,  	// User-Authorization-Request	UAR	300
UAA_E,  	// User-Authorization-Answer	UAA	300
SAR_E,  	// Server-Assignment-Request	SAR	301
SAA_E,  	// Server-Assignment-Answer		SAA	301
LIR_E,  	// Location-Info-Request		LIR	302
LIA_E,  	// Location-Info-Answer			LIA	302
MAR_E,  	// Multimedia-Auth-Request		MAR	303
MAA_E,  	// Multimedia-Auth-Answer		MAA	303
RTR_E, // Registration-Termination-Request	RTR	304
RTA_E, // Registration-Termination-Answer	RTA	304
PPR_E, // Push-Profile-Request			PPR	305
PPA_E, // Push-Profile-Answer			PPA	305	
        			
// Codes on Sh/Dh interface 
UDR_E,	//	UDR User-Data-Request AS->HSS 	306
UDA_E,	//	UDA User-Data-Answer HSS->AS	306		
PUR_E, //	PUR Profile-Update-Request AS->HSS	307
PUA_E,	//	PUA Profile-Update-Answer HSS->AS	307
SNR_E,	//	SNR Subscribe-Notifications-Request AS->HSS	308
SNA_E,	//	SNA Subscribe-Notifications-Answer HSS->AS	308
PNR_E,	//	PNR Profile-Notification-Request HSS->AS	309
PNA_E,		//	PNA Profile-Notification-Answer AS->HSS		309

// Codes on Rx interface
AAR_E,	//	AAR Auth-Accounting-Request  	265
AAA_E,	//	AAA Auth-Accounting-Answer	 	265

// Codes on Gx interface - RFC4006 and TS 129 212
CCR_E,	//	CCR Credit-Control-Request  	272
CCA_E	//	CCA Credit-Control-Answer 		272
*/

const char* Command_Code::msKeywordEnumsAll[] = { 
		"CER_E", // Capabilities-Exchange-Request 	CER  (257)
		"CEA_E", // Capabilities-Exchange-Answer 	CEA  (257)
		"RAR_E",  // Re-Auth-Request 				RAR  (258)
		"RAA_E",  // Re-Auth-Answer 					RAA  (258)

		//
		"ACR_E", // Accounting-Request				ACR(271)
		"ACA_E", // Accounting-Answer				ACA (271)

		//                  
		"ASR_E", // Abort-Session-Request			ASR (274)
		"ASA_E", // Abort-Sesion-Answer				ASA (274)
		"STR_E", // Session-Termination-Request		STR (275)
		"STA_E", // Session-Termination-Answer		STA (275)  		    

		//
		"DWR_E", // Device-Watchdog-Request			DWR (280)
		"DWA_E", // Device-Watchdog-Answer			DWA (280) 
		"DPR_E", // Disconnect-Peer-Requst			DPR (282)
		"DPA_E", // Disconnect-Peer-Answer			DPA (282) 

		// Codes on Cx
		"UAR_E",  	// User-Authorization-Request	UAR	300
		"UAA_E",  	// User-Authorization-Answer	UAA	300
		"SAR_E",  	// Server-Assignment-Request	SAR	301
		"SAA_E",  	// Server-Assignment-Answer		SAA	301
		"LIR_E",  	// Location-Info-Request		LIR	302
		"LIA_E",  	// Location-Info-Answer			LIA	302
		"MAR_E",  	// Multimedia-Auth-Request		MAR	303
		"MAA_E",  	// Multimedia-Auth-Answer		MAA	303
		"RTR_E", // Registration-Termination-Request	RTR	304
		"RTA_E", // Registration-Termination-Answer	RTA	304
		"PPR_E", // Push-Profile-Request			PPR	305
		"PPA_E", // Push-Profile-Answer			PPA	305	
							
		// Codes on Sh/Dh interface 
		"UDR_E",	//	UDR User-Data-Request AS->HSS 	306
		"UDA_E",	//	UDA User-Data-Answer HSS->AS	306		
		"PUR_E", //	PUR Profile-Update-Request AS->HSS	307
		"PUA_E",	//	PUA Profile-Update-Answer HSS->AS	307
		"SNR_E",	//	SNR Subscribe-Notifications-Request AS->HSS	308
		"SNA_E",	//	SNA Subscribe-Notifications-Answer HSS->AS	308
		"PNR_E",	//	PNR Profile-Notification-Request HSS->AS	309
		"PNA_E",		//	PNA Profile-Notification-Answer AS->HSS		309

		// Codes on Rx interface
		"AAR_E",	//	AAR Auth-Accounting-Request  	265
		"AAA_E",	//	AAA Auth-Accounting-Answer	 	265

		// Codes on Gx interface - RFC4006 and TS 129 212
		"CCR_E",	//	CCR Credit-Control-Request  	272
		"CCA_E"	//	CCA Credit-Control-Answer 		272
		"" };

const char* Command_Code::msKeywordEnumsRequest[] = { 
		"CER_E", // Capabilities-Exchange-Request 	CER  (257)
		"RAR_E",  // Re-Auth-Request 				RAR  (258)

		//
		"ACR_E", // Accounting-Request				ACR(271)

		//                  
		"ASR_E", // Abort-Session-Request			ASR (274)
		"STR_E", // Session-Termination-Request		STR (275)

		//
		"DWR_E", // Device-Watchdog-Request			DWR (280)
		"DPR_E", // Disconnect-Peer-Requst			DPR (282)

		// Codes on Cx
		"UAR_E",  	// User-Authorization-Request	UAR	300
		"SAR_E",  	// Server-Assignment-Request	SAR	301
		"LIR_E",  	// Location-Info-Request		LIR	302
		"MAR_E",  	// Multimedia-Auth-Request		MAR	303
		"RTR_E", // Registration-Termination-Request	RTR	304
		"PPR_E", // Push-Profile-Request			PPR	305
        			
		// Codes on Sh/Dh interface 
		"UDR_E",	//	UDR User-Data-Request AS->HSS 	306
		"PUR_E", //	PUR Profile-Update-Request AS->HSS	307
		"SNR_E",	//	SNR Subscribe-Notifications-Request AS->HSS	308
		"PNR_E",	//	PNR Profile-Notification-Request HSS->AS	309

		// Codes on Rx interface
		"AAR_E",	//	AAR Auth-Accounting-Request  	265
		// Codes on Gx interface - RFC4006 and TS 129 212
		"CCR_E",	//	CCR Credit-Control-Request  	272
		"" };
		
const char* Command_Code::msKeywordEnumsAnswer[] = { 
		"CEA_E", // Capabilities-Exchange-Answer 	CEA  (257)
		"RAA_E",  // Re-Auth-Answer 					RAA  (258)

		//
		"ACA_E", // Accounting-Answer				ACA (271)

		//                  
		"ASA_E", // Abort-Sesion-Answer				ASA (274)
		"STA_E", // Session-Termination-Answer		STA (275)  		    

		//
		"DWA_E", // Device-Watchdog-Answer			DWA (280) 
		"DPA_E", // Disconnect-Peer-Answer			DPA (282) 

		// Codes on Cx
		"UAA_E",  	// User-Authorization-Answer	UAA	300
		"SAA_E",  	// Server-Assignment-Answer		SAA	301
		"LIA_E",  	// Location-Info-Answer			LIA	302
		"MAA_E",  	// Multimedia-Auth-Answer		MAA	303
		"RTA_E", // Registration-Termination-Answer	RTA	304
		"PPA_E", // Push-Profile-Answer			PPA	305	
        			
		// Codes on Sh/Dh interface 
		"UDA_E",	//	UDA User-Data-Answer HSS->AS	306		
		"PUA_E",	//	PUA Profile-Update-Answer HSS->AS	307
		"SNA_E",	//	SNA Subscribe-Notifications-Answer HSS->AS	308
		"PNA_E",		//	PNA Profile-Notification-Answer AS->HSS		309

		// Codes on Rx interface
		"AAA_E",	//	AAA Auth-Accounting-Answer	 	265

		// Codes on Gx interface - RFC4006 and TS 129 212
		"CCA_E"	//	CCA Credit-Control-Answer 		272
		"" };

const int Command_Code::msCommandCodeValues[] = { 
		257,//CER_E, CEA_E
		258,//RAR_E, RAA_E

		//
		271,//ACR_E, ACA_E

		//                  
		274,//ASR_E, ASA_E
		275,//STR_E, STA_E

		//
		280,//DWR_E, DWA_E 
		282,//DPR_E, DPA_E

		// Codes on Cx
		300,//UAR_E, UAA_E
		301,//SAR_E, SAA_E
		302,//LIR_E, LIA_E 
		303,//MAR_E, MAA_E
		304,//RTR_E, RTA_E
		305,//PPR_E, PPA_E
							
		// Codes on Sh/Dh interface 
		306,//UDR_E, UDA_E
		307,//PUR_E, PUA_E
		308,//SNR_E, SNA_E
		309,//PNR_E, PNA_E

		// Codes on Rx interface
		265,//AAR_E, AAA_E

		// Codes on Gx interface - RFC4006 and TS 129 212
		272,//CCR_E, CCA_E
		0 };

void Command_Code::Encode (Buffer& buffer) throw (EncodeError)
{
	Unsigned code(24);

	const char * pStr = GetValueString();
	for(int i=0; strlen(msKeywordEnumsRequest[i]); i++)
	{//there is equal count of Request and Answer codes
		if(!strcmp(msKeywordEnumsRequest[i], pStr))
		{
			code.SetValue (msCommandCodeValues[i]);
			code.Encode(buffer);
			break;
		}
		else if(!strcmp(msKeywordEnumsAnswer[i], pStr))
		{
			code.SetValue (msCommandCodeValues[i]);
			code.Encode(buffer);
			break;
		}
	}
}

void Command_Code::Decode (Buffer& buffer) throw (DecodeError)
{
	Unsigned code(24);
	code.Decode(buffer);
	int nCode = code.GetValue();

#ifdef DEBUG_LOG
	std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
	logfile << "Command_Code::Decode::code == \"" << nCode << '"';
	logfile.close();
#endif

	for(int i=0; msCommandCodeValues[i]; i++)
	{
		if(msCommandCodeValues[i] == nCode)
		{
			SetValueString (m_bIsRequest ? msKeywordEnumsRequest[i] : msKeywordEnumsAnswer[i]);
			break;
		}
	}
}
 
/*
type union DIAMETER_MSG {
    CER_MSG	cER_MSG,
    CEA_MSG	cEA_MSG,
    RAR_MSG	rAR_MSG,
    RAA_MSG rAA_MSG,
    ACR_MSG	aCR_MSG,
    ACA_MSG	aCA_MSG,
    ASR_MSG	aSR_MSG,
    ASA_MSG	aSA_MSG,
    STR_MSG sTR_MSG,
    STA_MSG	sTA_MSG,
    DWR_MSG	dWR_MSG,
    DWA_MSG	dWA_MSG,
    DPR_MSG	dPR_MSG,
    DPA_MSG	dPA_MSG,
    //RFC4740
    UAR_MSG	uAR_MSG,
    UAA_MSG	uAA_MSG,
    SAR_MSG	sAR_MSG,
    SAA_MSG	sAA_MSG,
    LIR_MSG	lIR_MSG,
    LIA_MSG	lIA_MSG,
    MAR_MSG	mAR_MSG,
    MAA_MSG	mAA_MSG,
    RTR_MSG	rTR_MSG,
    RTA_MSG	rTA_MSG,
    PPR_MSG	pPR_MSG,
    PPA_MSG	pPA_MSG,
    //Sh interface
    UDR_MSG	uDR_MSG,
    UDA_MSG	uDA_MSG,
    PUR_MSG	pUR_MSG,
    PUA_MSG	pUA_MSG,
    SNR_MSG	sNR_MSG,
    SNA_MSG	sNA_MSG,
    PNR_MSG	pNR_MSG,
    PNA_MSG	pNA_MSG,
    //RFC4006 and TS 129 212
    CCR_MSG	cCR_MSG,
    CCA_MSG	cCA_MSG,
    //Rx interface
    AAR_MSG	aAR_MSG,
    AAA_MSG	aAA_MSG,
    UNKNOWN_MSG	uNKNOWN_MSG  
}*/
void DIAMETER_MSG::PreDecode (Buffer& buffer) throw (DecodeError)
{
	debug_log_PreDecode("DIAMETER_MSG");

	Unsigned version(8);
	Unsigned length(24);
	Unsigned flags(8);
	Unsigned code(24);
	

	//store buffer position
	int nPos = buffer.GetPosition();

	//predecode header
	version.Decode(buffer);
	length.Decode(buffer);
	flags.Decode(buffer);
	code.Decode(buffer);
	
	//rewind buffer position
	buffer.SetPosition(nPos);

	//set the decoded union field
	int nSelectedFieldId = -1;
	int nCode = code.GetValue();
	int nRequest = flags.GetValue() & 0x80;

	#ifdef DEBUG_LOG
		std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
		logfile << "Version: " << version.GetValue() << std::endl;
		logfile << "Length: " << length.GetValue() << std::endl;
		logfile << "Flags: " << flags.GetValue() << std::endl;
		logfile << "Code: " << code.GetValue() << std::endl;
		logfile.close();
	#endif

	if(nCode == 257)
		/*"CER_E", // Capabilities-Exchange-Request 	CER  (257)
		"CEA_E", // Capabilities-Exchange-Answer 	CEA  (257)
			CER_MSG	cER_MSG,
			CEA_MSG	cEA_MSG,*/
		nSelectedFieldId = nRequest ? id_cER_MSG : id_cEA_MSG;
	else if(nCode == 258)
		/*"RAR_E",  // Re-Auth-Request 				RAR  (258)
		"RAA_E",  // Re-Auth-Answer 					RAA  (258)
			RAR_MSG	rAR_MSG,
			RAA_MSG rAA_MSG*/
		nSelectedFieldId = nRequest ? id_rAR_MSG : id_rAA_MSG;
	else if(nCode == 271)
		/*"ACR_E", // Accounting-Request				ACR(271)
		"ACA_E", // Accounting-Answer				ACA (271)
			ACR_MSG	aCR_MSG,
			ACA_MSG	aCA_MSG*/
		nSelectedFieldId = nRequest ? id_aCR_MSG : id_aCA_MSG;
	else if(nCode == 274)
		/*"ASR_E", // Abort-Session-Request			ASR (274)
		"ASA_E", // Abort-Sesion-Answer				ASA (274)
			ASR_MSG	aSR_MSG,
			ASA_MSG	aSA_MSG*/
		nSelectedFieldId = nRequest ? id_aSR_MSG : id_aSA_MSG;
	else if(nCode == 275)
		/*"STR_E", // Session-Termination-Request		STR (275)
		"STA_E", // Session-Termination-Answer		STA (275)
			STR_MSG sTR_MSG,
			STA_MSG	sTA_MSG*/
		nSelectedFieldId = nRequest ? id_sTR_MSG : id_sTA_MSG;
	else if(nCode == 280)
		/*"DWR_E", // Device-Watchdog-Request			DWR (280)
		"DWA_E", // Device-Watchdog-Answer			DWA (280)
			DWR_MSG	dWR_MSG,
		    DWA_MSG	dWA_MSG,*/
		nSelectedFieldId = nRequest ? id_dWR_MSG : id_dWA_MSG;
	else if(nCode == 282)
		/*"DPR_E", // Disconnect-Peer-Requst			DPR (282)
		"DPA_E", // Disconnect-Peer-Answer			DPA (282) 
			DPR_MSG	dPR_MSG,
			DPA_MSG	dPA_MSG,*/
		nSelectedFieldId = nRequest ? id_dPR_MSG : id_dPA_MSG;
	else if(nCode == 300)
		/*"UAR_E",  	// User-Authorization-Request	UAR	300
		"UAA_E",  	// User-Authorization-Answer	UAA	300
			UAR_MSG	uAR_MSG,
			UAA_MSG	uAA_MSG,*/
		nSelectedFieldId = nRequest ? id_uAR_MSG : id_uAA_MSG;
	else if(nCode == 301)
		/*"SAR_E",  	// Server-Assignment-Request	SAR	301
		"SAA_E",  	// Server-Assignment-Answer		SAA	301
			SAR_MSG	sAR_MSG,
			SAA_MSG	sAA_MSG,*/
		nSelectedFieldId = nRequest ? id_sAR_MSG : id_sAA_MSG;
	else if(nCode == 302)
		/*"LIR_E",  	// Location-Info-Request		LIR	302
		"LIA_E",  	// Location-Info-Answer			LIA	302
			LIR_MSG	lIR_MSG,
			LIA_MSG	lIA_MSG,*/
		nSelectedFieldId = nRequest ? id_lIR_MSG : id_lIA_MSG;
	else if(nCode == 303)
		/*"MAR_E",  	// Multimedia-Auth-Request		MAR	303
		"MAA_E",  	// Multimedia-Auth-Answer		MAA	303
			MAR_MSG	mAR_MSG,
			MAA_MSG	mAA_MSG,*/
		nSelectedFieldId = nRequest ? id_mAR_MSG : id_mAA_MSG;
	else if(nCode == 304)
		/*"RTR_E", // Registration-Termination-Request	RTR	304
		"RTA_E", // Registration-Termination-Answer	RTA	304
			RTR_MSG	rTR_MSG,
			RTA_MSG	rTA_MSG,*/
		nSelectedFieldId = nRequest ? id_rTR_MSG : id_rTA_MSG;
	else if(nCode == 305)
		/*"PPR_E", // Push-Profile-Request			PPR	305
		"PPA_E", // Push-Profile-Answer			PPA	305	
			PPR_MSG	pPR_MSG,
			PPA_MSG	pPA_MSG,*/
		nSelectedFieldId = nRequest ? id_pPR_MSG : id_pPA_MSG;
	else if(nCode == 306)
		/*"UDR_E",	//	UDR User-Data-Request AS->HSS 	306
		"UDA_E",	//	UDA User-Data-Answer HSS->AS	306	
			UDR_MSG	uDR_MSG,
			UDA_MSG	uDA_MSG,*/
		nSelectedFieldId = nRequest ? id_uDR_MSG : id_uDA_MSG;
	else if(nCode == 307)
		/*"PUR_E", //	PUR Profile-Update-Request AS->HSS	307
		"PUA_E",	//	PUA Profile-Update-Answer HSS->AS	307
			PUR_MSG	pUR_MSG,
		    PUA_MSG	pUA_MSG,*/
		nSelectedFieldId = nRequest ? id_pUR_MSG : id_pUA_MSG;
	else if(nCode == 308)
		/*"SNR_E",	//	SNR Subscribe-Notifications-Request AS->HSS	308
		"SNA_E",	//	SNA Subscribe-Notifications-Answer HSS->AS	308
			SNR_MSG	sNR_MSG,
			SNA_MSG	sNA_MSG,*/
		nSelectedFieldId = nRequest ? id_sNR_MSG : id_sNA_MSG;
	else if(nCode == 309)
		/*"PNR_E",	//	PNR Profile-Notification-Request HSS->AS	309
		"PNA_E",		//	PNA Profile-Notification-Answer AS->HSS		309
			PNR_MSG	pNR_MSG,
			PNA_MSG	pNA_MSG,*/
		nSelectedFieldId = nRequest ? id_pNR_MSG : id_pNA_MSG;
	else if(nCode == 265)
		/*"AAR_E",	//	AAR Auth-Accounting-Request  	265
		"AAA_E",	//	AAA Auth-Accounting-Answer	 	265
			AAR_MSG	aAR_MSG,
			AAA_MSG	aAA_MSG,*/
		nSelectedFieldId = nRequest ? id_aAR_MSG : id_aAA_MSG;
	else if(nCode == 272)
		/*"CCR_E",	//	CCR Credit-Control-Request  	272
		"CCA_E"	//	CCA Credit-Control-Answer 		272
			CCR_MSG	cCR_MSG,
			CCA_MSG	cCA_MSG,*/
		nSelectedFieldId = nRequest ? id_cCR_MSG : id_cCA_MSG;

	if(nSelectedFieldId == -1)
		/*UNKNOWN_MSG	uNKNOWN_MSG*/
		nSelectedFieldId = id_uNKNOWN_MSG;

	SetHypChosenId(nSelectedFieldId);
}
//exception handling
void DIAMETER_MSG::PostEncode (Buffer& buffer, EncodeError& ex) throw (EncodeError)
{
	std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
	logfile << "DIAMETER_MSG:PostEncode:Exception: " << std::endl;
	logfile << ex << std::endl;
	logfile.close();
}

void DIAMETER_MSG::PostDecode (Buffer& buffer, DecodeError& ex) throw (DecodeError)
{
	std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
	logfile << "DIAMETER_MSG:PostDecode:Exception: " << std::endl;
	logfile << ex << std::endl;
	logfile.close();
}
//////////////////////////////////////////////////////////
///////////////  DIAMETER MESSAGES  //////////////////////
//////////////////////////////////////////////////////////
//hopefully multiple instances of AVPs come directly in sequence
static int get_AVP_offset(std::vector<unsigned int> &lAVPCodes, std::vector<unsigned int> & lOffsets, unsigned int nAVP_Code)
{
	for(int i = 0; i < lAVPCodes.size(); i++)
	{
		if(lAVPCodes.at(i) == nAVP_Code)
			return i;
	}
	return -1;
}

static int get_Remaining_AVP_offset(std::vector<unsigned int> &lAVPCodes)
{
	for(int i = 0; i < lAVPCodes.size(); i++)
	{
		if(lAVPCodes.at(i) != AVP_CODE_NOT_IN_USE)
			return i;
	}
	return -1;
}

static unsigned int skip_AVP(Buffer& buffer) throw (DecodeError)
{
	Unsigned nCode(32);
	Unsigned nFlags(8);
	Unsigned nLen(24);

	unsigned int nAVP_Code;
	unsigned int nByteLen;
	unsigned int nStartPos = buffer.GetPosition();

	nCode.Decode(buffer);
	nFlags.Decode(buffer);
	nLen.Decode(buffer);

	nAVP_Code = nCode.GetValue();
	nByteLen = nLen.GetValue();
	
	while(nByteLen%4)//32bit boundary(if padding is present)
		nByteLen++;
	unsigned int nBitsToSkip = nByteLen * 8;//(AVPlength - (code, flag and len)(2 bytes)) fields

	buffer.SetPosition(nStartPos + nBitsToSkip);
	
	return nAVP_Code;
}

#define DIAMETER_MSG_PreDecode(type)	\
	void type::PreDecode(Buffer& buffer) throw (DecodeError)	\
	{	\
		m_nStartingPosition = buffer.GetPosition();	\
	}

#define DIAMETER_MSG_PostDecodeField(type)	\
	void type::PostDecodeField(int field_id, Buffer& buffer) throw (DecodeError)	\
	{	\
	debug_log_PostDecodeField(#type, field_id);	\
		if(field_id == id_header)	\
		{	\
			unsigned int nFirstAVP_Offset = buffer.GetPosition();	\
			unsigned int nMsgLen = Get_header().Get_msglen().GetValue();	\
			while(nMsgLen%4)	\
				nMsgLen++;	\
			unsigned int nEndOffset = m_nStartingPosition + (nMsgLen * 8);	\
			unsigned int nCurrentOffset = buffer.GetPosition();	\
			while(nCurrentOffset < nEndOffset)	\
			{	\
				unsigned int nAVP_Code = skip_AVP(buffer);	\
				m_lAVP_Codes.push_back(nAVP_Code);	\
				m_lAVP_Offsets.push_back(nCurrentOffset);	\
				nCurrentOffset = buffer.GetPosition();	\
			}	\
			buffer.SetPosition(nFirstAVP_Offset);	\
		}	\
	}
#define DIAMETER_MSG_PostDecode(type)	\
	void type::PostDecode(Buffer& buffer) throw (DecodeError)	\
	{	\
		unsigned int nMsgLen = Get_header().Get_msglen().GetValue();	\
		while(nMsgLen%4)	\
			nMsgLen++;	\
		unsigned int nEndOffset = m_nStartingPosition + (nMsgLen * 8);	\
		buffer.SetPosition(nEndOffset);	\
	}


#define DIAMETER_MSG_PreDecodeField_START(type) \
	void type::PreDecodeField(int field_id, Buffer& buffer) throw (DecodeError)	\
	{	\
		debug_log_PreDecodeField(#type, field_id);	\
		if(false) {}

#define DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(fid, avpcode) \
	else if(field_id == id_##fid)	\
	{	\
		int nOffset = get_AVP_offset(m_lAVP_Codes, m_lAVP_Offsets, avpcode);	\
		if(nOffset == -1)	\
		{	\
			DecodeError ex (this);	\
			ex.Msg() << "Mandatory AVP not present: "	\
					<< #avpcode << endl;	\
			throw ex;	\
		}	\
		m_lAVP_Codes[nOffset] = AVP_CODE_NOT_IN_USE;	\
		buffer.SetPosition(m_lAVP_Offsets.at(nOffset));	\
	}
#define DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(avpcode, fid) DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(fid, avpcode)

#define DIAMETER_MSG_PreDecodeField_SET_OF_MANDATORY(fid, avpcode) \
	else if(field_id == id_##fid)	\
	{	\
		int nOffset = get_AVP_offset(m_lAVP_Codes, m_lAVP_Offsets, avpcode);	\
		if(nOffset == -1)	\
		{	\
			DecodeError ex (this);	\
			ex.Msg() << "Mandatory AVP not present: "	\
					<< #avpcode << endl;	\
			throw ex;	\
		}	\
		Get_##fid().SetOffsets(m_lAVP_Codes, m_lAVP_Offsets);	\
	}
#define DIAMETER_MSG_PreDecodeField_SET_OF_MANDATORY_R(avpcode, fid) DIAMETER_MSG_PreDecodeField_SET_OF_MANDATORY(fid, avpcode)

#define DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(fid, avpcode) \
	else if(field_id == id_##fid)	\
	{	\
		int nOffset = get_AVP_offset(m_lAVP_Codes, m_lAVP_Offsets, avpcode);	\
		if(nOffset != -1)	\
		{	\
			SetHypFieldIsPresent(field_id, 1);	\
			buffer.SetPosition(m_lAVP_Offsets.at(nOffset));	\
			m_lAVP_Codes[nOffset] = AVP_CODE_NOT_IN_USE;	\
		}	\
		else SetHypFieldIsPresent(field_id, 0);	\
	}
#define DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(avpcode, fid) DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(fid, avpcode)

#define DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(fieldName, avpcode) \
	else if(field_id == id_##fieldName)	\
	{	\
		int nOffset = get_AVP_offset(m_lAVP_Codes, m_lAVP_Offsets, avpcode);	\
		if(nOffset != -1)	\
		{	\
			SetHypFieldIsPresent(field_id, 1);	\
			Get_##fieldName().SetOffsets(m_lAVP_Codes, m_lAVP_Offsets);	\
		}	\
		else SetHypFieldIsPresent(field_id, 0);	\
	}
#define DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_(fieldName, getter, avpcode) \
	else if(field_id == fieldName)	\
	{	\
		int nOffset = get_AVP_offset(m_lAVP_Codes, m_lAVP_Offsets, avpcode);	\
		if(nOffset != -1)	\
		{	\
			SetHypFieldIsPresent(field_id, 1);	\
			getter().SetOffsets(m_lAVP_Codes, m_lAVP_Offsets);	\
		}	\
		else SetHypFieldIsPresent(field_id, 0);	\
	}

#define DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(avpcode, fieldName) DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(fieldName, avpcode)

#define DIAMETER_MSG_PreDecodeField_END(type) \
	}

#define DIAMETER_MSG_PreDecodeField_REMAINING \
	else if(field_id == id_aVP_Type)	\
	{	\
		int nOffset = get_Remaining_AVP_offset(m_lAVP_Codes);	\
		if(nOffset != -1)	\
		{	\
			SetHypFieldIsPresent(field_id, 1);	\
			std::vector<unsigned int> lIgnored;	\
			Get_aVP_Type().SetRemaining(m_lAVP_Codes, m_lAVP_Offsets, lIgnored);	\
		}	\
		else SetHypFieldIsPresent(field_id, 0);	\
	}

/*type record UNKNOWN_MSG {
    DiameterHeader 		header,
    set_of_AVP_Type			aVP_Type optional
}*/
DIAMETER_MSG_PreDecode(UNKNOWN_MSG)
DIAMETER_MSG_PreDecodeField_START(UNKNOWN_MSG)
DIAMETER_MSG_PreDecodeField_REMAINING
DIAMETER_MSG_PreDecodeField_END(UNKNOWN_MSG)

//DIAMETER_MSG_PostDecodeField(UNKNOWN_MSG)
void UNKNOWN_MSG::PostDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
	debug_log_PostDecodeField("UNKNOWN_MSG", field_id);
	if(field_id == id_header)
	{
		unsigned int nFirstAVP_Offset = buffer.GetPosition();
		unsigned int nMsgLen = Get_header().Get_msglen().GetValue();
		while(nMsgLen%4)
			nMsgLen++;
		unsigned int nEndOffset = m_nStartingPosition + (nMsgLen * 8);
		unsigned int nCurrentOffset = buffer.GetPosition();
#ifdef DEBUG_LOG
		std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
		logfile << "nFirstAVP_Offset: " << nFirstAVP_Offset << std::endl;
		logfile << "nMsgLen: " << nMsgLen << std::endl;
		logfile << "nEndOffset: " << nEndOffset << std::endl;
		logfile.close();
#endif
		while(nCurrentOffset < nEndOffset)
		{
#ifdef DEBUG_LOG
			std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
			logfile << "nCurrentOffset: " << nCurrentOffset << std::endl;
			logfile.close();
#endif
			unsigned int nAVP_Code = skip_AVP(buffer);
			m_lAVP_Codes.push_back(nAVP_Code);
			m_lAVP_Offsets.push_back(nCurrentOffset);
			nCurrentOffset = buffer.GetPosition();
		}
		buffer.SetPosition(nFirstAVP_Offset);
	}
}
DIAMETER_MSG_PostDecode(UNKNOWN_MSG)
/*
type record  CER_MSG{
	//Ref: RFC3588 5.3.1.  Capabilities-Exchange-Request
	DiameterHeader 						header,//<CER> ::= < Diameter Header: 257, REQ >     		
	Origin_Host_AVP 					origin_Host,//required
	Origin_Realm_AVP 					origin_Realm,
	set_of_Host_IP_Address_AVP 			host_IP_Address,
	Vendor_Id_AVP 						vendor_Id,
	Product_Name_AVP 					product_Name,//required
	set_of_Origin_State_Id_AVP			origin_State_Id optional,
	set_of_Supported_Vendor_Id_AVP		supported_Vendor_Id optional,
	set_of_Auth_Application_Id_AVP		auth_Application_Id optional,
	set_of_Inband_Security_Id_AVP		inband_Security_Id optional,
	set_of_Acct_Application_Id_AVP		acct_Application_Id optional,
	set_of_Vendor_Specific_Appl_Id_AVP	vendor_Specific_Application_Id optional,
	Firmware_Revision_AVP				firmware_Revision optional,
	set_of_AVP_Type 					aVP_Type optional		
}*/
DIAMETER_MSG_PreDecode(CER_MSG)
DIAMETER_MSG_PreDecodeField_START(CER_MSG)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(origin_Host, AVP_CODE_Origin_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(origin_Realm, AVP_CODE_Origin_Realm)
DIAMETER_MSG_PreDecodeField_SET_OF_MANDATORY(host_IP_Address, AVP_CODE_Host_IP_Address)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(vendor_Id, AVP_CODE_Vendor_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(product_Name, AVP_CODE_Product_Name)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(origin_State_Id, AVP_CODE_Origin_State_Id)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(supported_Vendor_Id, AVP_CODE_Supported_Vendor_Id)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(auth_Application_Id, AVP_CODE_Auth_Application_Id)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(inband_Security_Id, AVP_CODE_Inband_Security_Id)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(acct_Application_Id, AVP_CODE_Acct_Application_Id)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(vendor_Specific_Application_Id, AVP_CODE_Vendor_Specific_Application_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(firmware_Revision, AVP_CODE_Firmware_Revision)
DIAMETER_MSG_PreDecodeField_REMAINING
DIAMETER_MSG_PreDecodeField_END(CER_MSG)

DIAMETER_MSG_PostDecodeField(CER_MSG)
DIAMETER_MSG_PostDecode(CER_MSG)

/*type record  CEA_MSG{
	//Ref: RFC3588 5.3.2.  Capabilities-Exchange-Answer       			
	DiameterHeader 						header,//<CEA> ::= < Diameter Header: 257 >
	Result_Code_AVP						result_Code,//required
	Origin_Host_AVP 					origin_Host,
	Origin_Realm_AVP 					origin_Realm,
	set_of_Host_IP_Address_AVP 			host_IP_Address,
	Vendor_Id_AVP 						vendor_Id,
	Product_Name_AVP 					product_Name,//required

	Origin_State_Id_AVP					origin_State_Id optional,
	Error_Message_AVP					error_Message optional,
	set_of_Failed_AVP					failed optional,
	set_of_Supported_Vendor_Id_AVP		supported_Vendor_Id optional,
	set_of_Auth_Application_Id_AVP		auth_Application_Id optional,
	set_of_Inband_Security_Id_AVP		inband_Security_Id optional,
	set_of_Acct_Application_Id_AVP		acct_Application_Id optional,
	set_of_Vendor_Specific_Appl_Id_AVP 	vendor_Specific_Application_Id optional,
	Firmware_Revision_AVP				firmware_Revision optional,
	set_of_AVP_Type 					aVP_Type optional		
}*/
DIAMETER_MSG_PreDecode(CEA_MSG)
DIAMETER_MSG_PreDecodeField_START(CEA_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(result_Code, AVP_CODE_Result_Code)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(origin_Host, AVP_CODE_Origin_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(origin_Realm, AVP_CODE_Origin_Realm )
DIAMETER_MSG_PreDecodeField_SET_OF_MANDATORY(host_IP_Address, AVP_CODE_Host_IP_Address )
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(vendor_Id, AVP_CODE_Vendor_Id )
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(product_Name, AVP_CODE_Product_Name )

DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(origin_State_Id, AVP_CODE_Origin_State_Id )
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(error_Message, AVP_CODE_Error_Message )
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(failed, AVP_CODE_Failed_AVP )
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(supported_Vendor_Id, AVP_CODE_Supported_Vendor_Id )
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(auth_Application_Id, AVP_CODE_Auth_Application_Id )
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(inband_Security_Id, AVP_CODE_Inband_Security_Id )
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(acct_Application_Id, AVP_CODE_Acct_Application_Id )
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(vendor_Specific_Application_Id, AVP_CODE_Vendor_Specific_Application_Id )
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(firmware_Revision, AVP_CODE_Firmware_Revision )
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(CEA_MSG)

DIAMETER_MSG_PostDecodeField(CEA_MSG)
DIAMETER_MSG_PostDecode(CEA_MSG)

/*type record RAR_MSG{
	//Ref: RFC3588 8.3.1.  Re-Auth-Request
	DiameterHeader 						header,//<RAR>  ::= < Diameter Header: 258, REQ, PXY >
	Session_Id_AVP 						session_Id,//fixed pos.				//RFC3588 & TS 129 214 & TS 129 212
	Origin_Host_AVP 					origin_Host,//required				//RFC3588 & TS 129 214 & TS 129 212
	Origin_Realm_AVP 					origin_Realm,						//RFC3588 & TS 129 214 & TS 129 212
	Destination_Realm_AVP				destination_Realm,					//RFC3588 & TS 129 214 & TS 129 212
	Destination_Host_AVP				destination_Host,					//RFC3588 & TS 129 214 & TS 129 212
	Auth_Application_Id_AVP				auth_Application_Id,				//RFC3588 & TS 129 214 & TS 129 212
	Specific_Action_AVP					specific_action optional,			// TS 129 214 required
	Re_Auth_Request_Type_AVP 			re_Auth_Request_Type optional,		//RFC3588req & TS 129 214NOT present & TS 129 212req
	User_Name_AVP 						user_Name optional,					//RFC3588
	set_of_Access_Network_Charging_Identifier_AVP acc_nc_ident optional, // TS 129 214
	Access_Network_Charging_Address_AVP     acc_nc_addr optional, 	// TS 129 214
	set_of_Flows_AVP					flows optional,						// TS 129 214
	set_of_Subscription_Id_AVP			subscription_Id optional,			// TS 129 214
	Abort_Cause_AVP						abort_Cause optional,				// TS 129 214
	IP_CAN_Type_AVP						ip_Can optional,					// TS 129 214
	RAT_Type_AVP						rat_Type optional,					// TS 129 214
	Sponsored_Connectivity_Data_AVP		sponsored_Conectivity_Data optional,// TS 129 214
	Origin_State_Id_AVP					origin_State_Id optional,			//RFC3588 & TS 129 214 & TS 129 212
    set_of_Class_AVP 					class optional,						// TS 129 214
    Session_Release_Cause_AVP			session_Release_Cause optional,		// TS 129 212
    set_of_Event_Trigger_AVP			event_Trigger optional,				// TS 129 212
    Event_Report_Indication_AVP			event_Report_Indication optional,	// TS 129 212
    set_of_Charging_Rule_Remove_AVP		charging_Rule_Remove optional,		// TS 129 212
    set_of_Charging_Rule_Install_AVP	charging_Rule_Install optional,		// TS 129 212
    Default_EPS_Bearer_QoS_AVP			default_EPS_Bearer_QoS optional,	// TS 129 212
    set_of_QoS_Information_AVP			qoS_Information optional,			// TS 129 212
    Revalidation_Time_AVP				revalidation_Time optional,			// TS 129 212
    set_of_Usage_Monitoring_Information_AVP	usage_Monitoring_Information optional,	// TS 129 212
	set_of_Proxy_Info_AVP 				proxy_Info optional,				//RFC3588 & TS 129 214 & TS 129 212
	set_of_Route_Record_AVP 			route_Record optional,				//RFC3588 & TS 129 214 & TS 129 212
	set_of_AVP_Type						aVP_Type optional						//RFC3588 & TS 129 214 & TS 129 212	
}*/
DIAMETER_MSG_PreDecode(RAR_MSG)
DIAMETER_MSG_PreDecodeField_START(RAR_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(session_Id, AVP_CODE_Session_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(origin_Host, AVP_CODE_Origin_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(origin_Realm, AVP_CODE_Origin_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(destination_Realm, AVP_CODE_Destination_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(destination_Host, AVP_CODE_Destination_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(auth_Application_Id, AVP_CODE_Auth_Application_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(specific_action, AVP_CODE_Specific_Action)			// TS 129 214 required
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(re_Auth_Request_Type, AVP_CODE_Re_Auth_Request_Type)		//RFC3588req & TS 129 214NOT present & TS 129 212req
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(user_Name, AVP_CODE_User_Name)				//RFC3588
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(acc_nc_ident, AVP_CODE_Access_Network_Charging_Identifier)	// TS 129 214
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(acc_nc_addr, AVP_CODE_Access_Network_Charging_Address)			// TS 129 214
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(flows, AVP_CODE_Flows)					// TS 129 214
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(subscription_Id, AVP_CODE_Subscription_Id)			// TS 129 214
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(abort_Cause, AVP_CODE_Abort_Cause)				// TS 129 214
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(ip_Can, AVP_CODE_IP_CAN_Type)					// TS 129 214
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(rat_Type, AVP_CODE_RAT_Type)					// TS 129 214
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(sponsored_Conectivity_Data, AVP_CODE_Sponsored_Connectivity_Data)// TS 129 214
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(origin_State_Id, AVP_CODE_Origin_State_Id)			//RFC3588 & TS 129 214 & TS 129 212
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_(id_class, Get_class, AVP_CODE_Class)					// TS 129 214
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(session_Release_Cause, AVP_CODE_Session_Release_Cause)		// TS 129 212
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(event_Trigger, AVP_CODE_Event_Trigger)				// TS 129 212
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(event_Report_Indication, AVP_CODE_Event_Report_Indication)	// TS 129 212
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(charging_Rule_Remove, AVP_CODE_Charging_Rule_Remove)		// TS 129 212
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(charging_Rule_Install, 	AVP_CODE_Charging_Rule_Install)	// TS 129 212
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(default_EPS_Bearer_QoS, AVP_CODE_Default_EPS_Bearer_QoS)	// TS 129 212
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(qoS_Information, AVP_CODE_QoS_Information)			// TS 129 212
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(revalidation_Time, 	AVP_CODE_Revalidation_Time)		// TS 129 212
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(usage_Monitoring_Information, AVP_CODE_Usage_Monitoring_Information)	// TS 129 212
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(proxy_Info, AVP_CODE_Proxy_Info )				//RFC3588 & TS 129 214 & TS 129 212
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(route_Record, AVP_CODE_Route_Record)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(RAR_MSG)

DIAMETER_MSG_PostDecodeField(RAR_MSG)
DIAMETER_MSG_PostDecode(RAR_MSG)

/*type record RAA_MSG{
	//Ref: RFC3588 8.3.2.  Re-Auth-Answer
	DiameterHeader 						header,//<RAA>  ::= < Diameter Header: 258, PXY >
	Session_Id_AVP 						session_Id,//fixed pos.				//RFC3588 & TS 129 214 & TS 129 212
	Result_Code_AVP						result_Code optional,				//RFC3588req & TS 129 214opt & TS 129 212opt
	Origin_Host_AVP 					origin_Host,						//RFC3588 & TS 129 214 & TS 129 212
	Origin_Realm_AVP 					origin_Realm,//required				//RFC3588 & TS 129 214 & TS 129 212
	Experimental_Result_AVP             experimental_result optional, //TS 129 214 & TS 129 212
	User_Name_AVP 						user_Name optional,					//RFC3588 
	set_of_Media_Component_Description_AVP media_Component_Description optional,//TS 129 214
    Service_URN_AVP						service_URN optional,				//TS 129 214
	Origin_State_Id_AVP					origin_State_Id optional,			//RFC3588 & TS 129 214 & TS 129 212
    set_of_Class_AVP 					class optional,						//TS 129 214
    IP_CAN_Type_AVP						iP_CAN_Type optional,				//TS 129 212
    RAT_Type_AVP						rAT_Type optional,					//TS 129 212
    record_of_AN_GW_Address_AVP	aN_GW_Address optional,		//TS 129 212
    ThreeGPP_SGSN_MCC_MNC_AVP			threeGPP_SGSN_MCC_MNC optional,		//TS 129 212
    ThreeGPP_SGSN_Address_AVP			threeGPP_SGSN_Address optional,		//TS 129 212
    ThreeGPP_SGSN_IPv6_Address_AVP		threeGPP_SGSN_IPv6_Address optional,//TS 129 212
    RAI_AVP								rAI optional,						//TS 129 212
    ThreeGPP_User_Location_Info_AVP		threeGPP_User_Location_Info optional,//TS 129 212
    ThreeGPP_MS_TimeZone_AVP			threeGPP_MS_TimeZone optional,		//TS 129 212
    set_of_Charging_Rule_Report_AVP		charging_Rule_Report optional,		//TS 129 212
	Error_Message_AVP					error_Message optional,				//RFC3588 & TS 129 214 & TS 129 212
	Error_Reporting_Host_AVP			error_Reporting_Host optional,		//RFC3588 & TS 129 214 & TS 129 212
	set_of_Failed_AVP					failed optional,				//RFC3588 & TS 129 214 & TS 129 212
	set_of_Redirect_Host_AVP			redirect_Host optional,				//RFC3588 & TS 129 214
    Redirect_Host_Usage_AVP				redirect_Host_Usage optional,		//RFC3588 & TS 129 214
    Redirect_Max_Cache_Time_AVP			redirect_Max_Cache_Time optional,	//RFC3588 & TS 129 214
	set_of_Proxy_Info_AVP				proxy_Info optional,				//RFC3588 & TS 129 214 & TS 129 212
	set_of_AVP_Type						aVP_Type optional        				//RFC3588 & TS 129 214 & TS 129 212
}*/
DIAMETER_MSG_PreDecode(RAA_MSG)
DIAMETER_MSG_PreDecodeField_START(RAA_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(session_Id, AVP_CODE_Session_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(result_Code, AVP_CODE_Result_Code)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(origin_Host, AVP_CODE_Origin_Host)					//RFC3588 & TS 129 214 & TS 129 212
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(origin_Realm, AVP_CODE_Origin_Realm)//required				//RFC3588 & TS 129 214 & TS 129 212
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(experimental_result, AVP_CODE_Experimental_Result) 		//TS 129 214 & TS 129 212
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(user_Name, AVP_CODE_User_Name)					//RFC3588 
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(media_Component_Description, AVP_CODE_Media_Component_Description)//TS 129 214
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(service_URN, AVP_CODE_Service_URN)			//TS 129 214
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(origin_State_Id, AVP_CODE_Origin_State_Id)		//RFC3588 & TS 129 214 & TS 129 212
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_(id_class, Get_class, AVP_CODE_Class)						//TS 129 214
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(iP_CAN_Type, AVP_CODE_IP_CAN_Type)				//TS 129 212
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(rAT_Type, AVP_CODE_RAT_Type)					//TS 129 212
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(aN_GW_Address, AVP_CODE_AN_GW_Address )		//TS 129 212
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(threeGPP_SGSN_MCC_MNC, AVP_CODE_ThreeGPP_SGSN_MCC_MNC )		//TS 129 212
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(threeGPP_SGSN_Address, AVP_CODE_ThreeGPP_SGSN_Address)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(threeGPP_SGSN_IPv6_Address, AVP_CODE_ThreeGPP_SGSN_IPv6_Address)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(rAI, AVP_CODE_RAI)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(threeGPP_User_Location_Info, AVP_CODE_ThreeGPP_User_Location_Info)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(threeGPP_MS_TimeZone, AVP_CODE_ThreeGPP_MS_TimeZone)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(charging_Rule_Report, AVP_CODE_Charging_Rule_Report)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(error_Message, AVP_CODE_Error_Message)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(error_Reporting_Host, AVP_CODE_Error_Reporting_Host)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(failed, AVP_CODE_Failed_AVP)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(redirect_Host, AVP_CODE_Redirect_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(redirect_Host_Usage, AVP_CODE_Redirect_Host_Usage)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(redirect_Max_Cache_Time, AVP_CODE_Redirect_Max_Cache_Time)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(proxy_Info, AVP_CODE_Proxy_Info)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(RAA_MSG)

DIAMETER_MSG_PostDecodeField(RAA_MSG)
DIAMETER_MSG_PostDecode(RAA_MSG)


/*type record ACR_MSG{
	//Ref: RFC3588 9.7.1.  Accounting-Request
	DiameterHeader 						header,//<ACR> ::= < Diameter Header: 271, REQ, PXY >
	Session_Id_AVP 						session_Id,//fixed pos.
	Origin_Host_AVP 					origin_Host,//required
	Origin_Realm_AVP 					origin_Realm,
	Destination_Realm_AVP				destination_Realm,
	Accounting_Record_Type_AVP 			accounting_Record_Type,
	Accounting_Record_Number_AVP		accounting_Record_Number,//required
	Acct_Application_Id_AVP				acct_Application_Id optional,//optional
	Vendor_Specific_Appl_Id_AVP 		vendor_Specific_Application_Id optional,
	User_Name_AVP 						user_Name optional,
    set_of_Supported_Features_AVP 		supported_Features optional,	//specified in RFC4006
	Accounting_Sub_Session_Id_AVP 		accounting_Sub_Session_Id optional,
	Acct_Session_Id_AVP 				acct_Session_Id optional,
	Acct_Multi_Session_Id_AVP 			acct_Multi_Session_Id optional,
	Acct_Interim_Interval_AVP 			acct_Interim_Interval optional,
	Accounting_Realtime_Required_AVP 	accounting_Realtime_Required optional,
	Origin_State_Id_AVP 				origin_State_Id optional,
	Event_Timestamp_AVP 				event_Timestamp optional,
	set_of_Proxy_Info_AVP 				proxy_Info optional,
	set_of_Route_Record_AVP  			route_Record optional,
	set_of_AVP_Type						aVP_Type optional					
}*/
DIAMETER_MSG_PreDecode(ACR_MSG)
DIAMETER_MSG_PreDecodeField_START(ACR_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(session_Id, AVP_CODE_Session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(origin_Host, AVP_CODE_Origin_Host)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(origin_Realm, AVP_CODE_Origin_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(destination_Realm, AVP_CODE_Destination_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(accounting_Record_Type, AVP_CODE_Accounting_Record_Type)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY(accounting_Record_Number, AVP_CODE_Accounting_Record_Number)//required
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(acct_Application_Id, AVP_CODE_Acct_Application_Id)//optional
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(vendor_Specific_Application_Id, AVP_CODE_Vendor_Specific_Application_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(user_Name, AVP_CODE_User_Name)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(supported_Features, AVP_CODE_Supported_Features)	//specified in RFC4006
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(accounting_Sub_Session_Id, AVP_CODE_Accounting_Sub_Session_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(acct_Session_Id, AVP_CODE_Acct_Session_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(acct_Multi_Session_Id, AVP_CODE_Acct_Multi_Session_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(acct_Interim_Interval, AVP_CODE_Acct_Interim_Interval)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(accounting_Realtime_Required, AVP_CODE_Accounting_Realtime_Required)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(origin_State_Id, AVP_CODE_Origin_State_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL(event_Timestamp, AVP_CODE_Event_Timestamp)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(proxy_Info, AVP_CODE_Proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL(route_Record, AVP_CODE_Route_Record)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(ACR_MSG)

DIAMETER_MSG_PostDecodeField(ACR_MSG)
DIAMETER_MSG_PostDecode(ACR_MSG)

/*type record ACA_MSG{
	//Ref: RFC3588	9.7.2.  Accounting-Answer
	DiameterHeader 						header ,//<ACA> ::= < Diameter Header: 271, PXY >
	Session_Id_AVP 						session_Id,//fixed pos.
	Result_Code_AVP						result_Code,//required
	Origin_Host_AVP 					origin_Host,
	Origin_Realm_AVP 					origin_Realm,
	Accounting_Record_Type_AVP 			accounting_Record_Type,
	Accounting_Record_Number_AVP		accounting_Record_Number,//required
	Acct_Application_Id_AVP				acct_Application_Id optional,//optional
	Vendor_Specific_Appl_Id_AVP 		vendor_Specific_Application_Id optional,
	User_Name_AVP 						user_Name optional,
	Accounting_Sub_Session_Id_AVP 		accounting_Sub_Session_Id optional,
	Acct_Session_Id_AVP 				acct_Session_Id optional,
	Acct_Multi_Session_Id_AVP 			acct_Multi_Session_Id optional,
	Error_Reporting_Host_AVP			error_Reporting_Host optional,
	Acct_Interim_Interval_AVP 			acct_Interim_Interval optional,
    Accounting_Realtime_Required_AVP 	accounting_Realtime_Required optional,
	Origin_State_Id_AVP 				origin_State_Id optional,
	Event_Timestamp_AVP 				event_Timestamp optional,
	set_of_Proxy_Info_AVP 				proxy_Info optional,
	set_of_AVP_Type						aVP_Type optional						
}*/
DIAMETER_MSG_PreDecode(ACA_MSG)
DIAMETER_MSG_PreDecodeField_START(ACA_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Result_Code, result_Code)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Accounting_Record_Type, accounting_Record_Type)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Accounting_Record_Number, accounting_Record_Number)//required
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Acct_Application_Id, acct_Application_Id)//optional
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Vendor_Specific_Application_Id, vendor_Specific_Application_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_User_Name, user_Name)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Accounting_Sub_Session_Id, accounting_Sub_Session_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Acct_Session_Id, acct_Session_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Acct_Multi_Session_Id, acct_Multi_Session_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Error_Reporting_Host, error_Reporting_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Acct_Interim_Interval, acct_Interim_Interval)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Accounting_Realtime_Required, accounting_Realtime_Required)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Origin_State_Id, origin_State_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Event_Timestamp, event_Timestamp)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(ACA_MSG)

DIAMETER_MSG_PostDecodeField(ACA_MSG)
DIAMETER_MSG_PostDecode(ACA_MSG)


/*type record ASR_MSG{
	//Ref: RFC3588 8.5.1.  Abort-Session-Request		
	DiameterHeader 						header ,//<ASR>  ::= < Diameter Header: 274, REQ, PXY >
	Session_Id_AVP 						session_Id,//fixed pos.
	Origin_Host_AVP 					origin_Host,//required
	Origin_Realm_AVP 					origin_Realm,
	Destination_Realm_AVP				destination_Realm,
    Destination_Host_AVP				destination_Host,
	Auth_Application_Id_AVP				auth_Application_Id,
	Abort_Cause_AVP						abort_cause optional,//present in ETSI TS 129 214 p.5.6.7
	User_Name_AVP 						user_Name optional,
	Origin_State_Id_AVP 				origin_State_Id optional,
	set_of_Proxy_Info_AVP 				proxy_Info optional,
	set_of_Route_Record_AVP  			route_Record optional,
	set_of_AVP_Type						aVP_Type optional		
}*/
DIAMETER_MSG_PreDecode(ASR_MSG)
DIAMETER_MSG_PreDecodeField_START(ASR_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Destination_Realm, destination_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Destination_Host, destination_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Application_Id, auth_Application_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Abort_Cause, abort_cause)//present in ETSI TS 129 214 p.5.6.7
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_User_Name, user_Name)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Origin_State_Id, origin_State_Id)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(ASR_MSG)

DIAMETER_MSG_PostDecodeField(ASR_MSG)
DIAMETER_MSG_PostDecode(ASR_MSG)

/*type record  ASA_MSG{
	//Ref: RFC3588 8.5.2.  Abort-Session-Answer
	DiameterHeader 						header,//<ASA>  ::= < Diameter Header: 274, PXY >
	Session_Id_AVP 						session_Id,//fixed pos.
	Result_Code_AVP						result_Code,//required
	Origin_Host_AVP 					origin_Host,//required
	Origin_Realm_AVP 					origin_Realm,
	User_Name_AVP 						user_Name optional,
	Origin_State_Id_AVP 				origin_State_Id optional,
	Error_Message_AVP					error_Message optional,
	Error_Reporting_Host_AVP			error_Reporting_Host optional,
	set_of_Failed_AVP					failed optional,
	set_of_Redirect_Host_AVP			redirect_Host optional,
	Redirect_Host_Usage_AVP				redirect_Host_Usage optional,
	Redirect_Max_Cache_Time_AVP		redirect_Max_Cache_Time optional,
	set_of_Proxy_Info_AVP 				proxy_Info optional,
	set_of_AVP_Type						aVP_Type optional		
}*/
DIAMETER_MSG_PreDecode(ASA_MSG)
DIAMETER_MSG_PreDecodeField_START(ASA_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Result_Code, result_Code)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_User_Name, user_Name)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Origin_State_Id, origin_State_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Error_Message, error_Message)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Error_Reporting_Host, error_Reporting_Host)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Failed_AVP, failed)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Redirect_Host, redirect_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Host_Usage, redirect_Host_Usage)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Max_Cache_Time, redirect_Max_Cache_Time)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(ASA_MSG)

DIAMETER_MSG_PostDecodeField(ASA_MSG)
DIAMETER_MSG_PostDecode(ASA_MSG)

/*type record  STR_MSG{
	//Ref: RFC3588 8.4.1.  Session-Termination-Request	
	DiameterHeader 						header,//<STR> ::= < Diameter Header: 275, REQ, PXY >
	Session_Id_AVP 						session_Id,//fixed pos.
	Origin_Host_AVP 					origin_Host,//required
	Origin_Realm_AVP 					origin_Realm,
	Destination_Realm_AVP				destination_Realm,
	Auth_Application_Id_AVP				auth_Application_Id,
    Termination_Cause_AVP 				termination_Cause,//requ.
	User_Name_AVP 						user_Name optional,
	Destination_Host_AVP				destination_Host optional,
	set_of_Class_AVP 					class optional,
	Origin_State_Id_AVP 				origin_State_Id optional,
	set_of_Proxy_Info_AVP 				proxy_Info optional,
	set_of_Route_Record_AVP  			route_Record optional,
	set_of_AVP_Type						aVP_Type optional	
}*/
DIAMETER_MSG_PreDecode(STR_MSG)
DIAMETER_MSG_PreDecodeField_START(STR_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Destination_Realm, destination_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Application_Id, auth_Application_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Termination_Cause, termination_Cause)//requ.
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_User_Name, user_Name)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Destination_Host, destination_Host)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_(id_class, Get_class, AVP_CODE_Class)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Origin_State_Id, origin_State_Id)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(STR_MSG)

DIAMETER_MSG_PostDecodeField(STR_MSG)
DIAMETER_MSG_PostDecode(STR_MSG)

/*type record  STA_MSG{
	//Ref: RFC3588 8.4.2.  Session-Termination-Answer		
	DiameterHeader 						header,//<STA>  ::= < Diameter Header: 275, PXY >
	Session_Id_AVP 						session_Id,//fixed pos.
	Result_Code_AVP						result_Code,//required
	Origin_Host_AVP 					origin_Host,//required
	Origin_Realm_AVP 					origin_Realm,
	User_Name_AVP 						user_Name optional,
	set_of_Class_AVP 					class optional,
	Error_Message_AVP					error_Message optional,
	Error_Reporting_Host_AVP			error_Reporting_Host optional,
	set_of_Failed_AVP					failed optional,
	Sponsored_Connectivity_Data_AVP     sponsored_Connectivity_Data optional,//present in ETSI TS 129 214 p.5.6.6
	Origin_State_Id_AVP 				origin_State_Id optional,
	set_of_Redirect_Host_AVP			redirect_Host optional,
	Redirect_Host_Usage_AVP				redirect_Host_Usage optional,
	Redirect_Max_Cache_Time_AVP			redirect_Max_Cache_Time optional,
	set_of_Proxy_Info_AVP 				proxy_Info optional,
	set_of_AVP_Type						aVP_Type optional		
}*/
DIAMETER_MSG_PreDecode(STA_MSG)
DIAMETER_MSG_PreDecodeField_START(STA_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Result_Code, result_Code)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_User_Name, user_Name)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_(id_class, Get_class, AVP_CODE_Class)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Error_Message, error_Message)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Error_Reporting_Host, error_Reporting_Host)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Failed_AVP, failed)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Sponsored_Connectivity_Data, sponsored_Connectivity_Data)//present in ETSI TS 129 214 p.5.6.6
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Origin_State_Id, origin_State_Id)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Redirect_Host, redirect_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Host_Usage, redirect_Host_Usage)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Max_Cache_Time, redirect_Max_Cache_Time)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(STA_MSG)

DIAMETER_MSG_PostDecodeField(STA_MSG)
DIAMETER_MSG_PostDecode(STA_MSG)

/*type record  DWR_MSG{
	//Ref: RFC3588 5.5.1.  Device-Watchdog-Request
	DiameterHeader 						header,//<DWR>  ::= < Diameter Header: 280, REQ >
	Origin_Host_AVP 					origin_Host,//required
	Origin_Realm_AVP 					origin_Realm,
	Origin_State_Id_AVP 				origin_State_Id optional,
	set_of_AVP_Type 					aVP_Type optional //to await or send some unexpected AVPs
}*/
DIAMETER_MSG_PreDecode(DWR_MSG)
DIAMETER_MSG_PreDecodeField_START(DWR_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Origin_State_Id, origin_State_Id)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(DWR_MSG)

DIAMETER_MSG_PostDecodeField(DWR_MSG)
DIAMETER_MSG_PostDecode(DWR_MSG)

/*type record  DWA_MSG{
	//Ref: RFC3588 5.5.2.  Device-Watchdog-Answer
	DiameterHeader 						header,//<DWA>  ::= < Diameter Header: 280 >
	Result_Code_AVP						result_Code,//required
	Origin_Host_AVP 					origin_Host,
	Origin_Realm_AVP 					origin_Realm,//required
	Error_Message_AVP					error_Message optional,
	set_of_Failed_AVP					failed optional,
	Origin_State_Id_AVP 				origin_State_Id optional,
	set_of_AVP_Type 					aVP_Type optional //to await or send some unexpected AVPs
}*/
DIAMETER_MSG_PreDecode(DWA_MSG)
DIAMETER_MSG_PreDecodeField_START(DWA_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Result_Code, result_Code)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)//required
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Error_Message, error_Message)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Failed_AVP, failed)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Origin_State_Id, origin_State_Id)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(DWA_MSG)

DIAMETER_MSG_PostDecodeField(DWA_MSG)
DIAMETER_MSG_PostDecode(DWA_MSG)

/*type record  DPR_MSG{
	//	Ref: RFC3588 5.4.1.  Disconnect-Peer-Request	
	DiameterHeader 						header,//<DPR>  ::= < Diameter Header: 282, REQ >        		
	Origin_Host_AVP 					origin_Host,//required
	Origin_Realm_AVP 					origin_Realm,
    Disconnect_Cause_AVP				disconnect_Cause,//requ.
	set_of_AVP_Type 					aVP_Type optional //to await or send some unexpected AVPs		
}*/
DIAMETER_MSG_PreDecode(DPR_MSG)
DIAMETER_MSG_PreDecodeField_START(DPR_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Disconnect_Cause, disconnect_Cause)//requ.
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(DPR_MSG)

DIAMETER_MSG_PostDecodeField(DPR_MSG)
DIAMETER_MSG_PostDecode(DPR_MSG)

/*type record DPA_MSG{
	//Ref: RFC3588 5.4.2.  Disconnect-Peer-Answer
	DiameterHeader 						header,//<DPA>  ::= < Diameter Header: 282 >
	Result_Code_AVP						result_Code,//required
	Origin_Host_AVP 					origin_Host,
	Origin_Realm_AVP 					origin_Realm,//required
	Error_Message_AVP					error_Message optional,
	set_of_Failed_AVP			 		failed optional,
	set_of_AVP_Type 					aVP_Type optional //to await or send some unexpected AVPs			
}*/
DIAMETER_MSG_PreDecode(DPA_MSG)
DIAMETER_MSG_PreDecodeField_START(DPA_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Result_Code, result_Code)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)//required
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Error_Message, error_Message)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Failed_AVP, failed)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(DPA_MSG)

DIAMETER_MSG_PostDecodeField(DPA_MSG)
DIAMETER_MSG_PostDecode(DPA_MSG)

/*type record	UAR_MSG{
	//Ref: RFC4740 8.1.  User-Authorization-Request Command
	DiameterHeader 						header,//<UAR> ::= < Diameter Header: 283, PXY >        		        		
	Session_Id_AVP 						session_Id,//fixed pos.
	Auth_Application_Id_AVP 			auth_Application_Id,
	Auth_Session_State_AVP 				auth_Session_State,
	Origin_Host_AVP 					origin_Host,//required
	Origin_Realm_AVP 					origin_Realm,
	Destination_Realm_AVP				destination_Realm,
	SIP_AOR_AVP							sIP_AOR,
	Destination_Host_AVP				destination_Host optional,
	User_Name_AVP 						user_Name optional,
	SIP_Visited_Network_Id_AVP			sIP_Visited_Network_Id,
 	SIP_User_Authorization_Type_AVP		sIP_User_Authorization_Type,
	set_of_Proxy_Info_AVP 				proxy_Info optional,
	set_of_Route_Record_AVP  			route_Record optional,
	set_of_AVP_Type						aVP_Type optional				
}*/
DIAMETER_MSG_PreDecode(UAR_MSG)
DIAMETER_MSG_PreDecodeField_START(UAR_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Application_Id, auth_Application_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Session_State, auth_Session_State)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Destination_Realm, destination_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_SIP_AOR, sIP_AOR)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Destination_Host, destination_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_User_Name, user_Name)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_SIP_Visited_Network_Id, sIP_Visited_Network_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_SIP_User_Authorization_Type, sIP_User_Authorization_Type)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(UAR_MSG)

DIAMETER_MSG_PostDecodeField(UAR_MSG)
DIAMETER_MSG_PostDecode(UAR_MSG)

/*type record UAA_MSG{
	//Ref: RFC4740 8.2.  User-Authorization-Answer Command
	DiameterHeader 					header,//<UAA> ::= < Diameter Header: 283, PXY >	
	Session_Id_AVP 					session_Id,//fixed pos.
	Auth_Application_Id_AVP 		auth_Application_Id,//required
	Auth_Session_State_AVP 			auth_Session_State,
	Result_Code_AVP					result_Code,
	Origin_Host_AVP 				origin_Host,
	Origin_Realm_AVP 				origin_Realm,//required
 	SIP_Server_URI_AVP 				sIP_Server_URI optional, 
 	SIP_Server_Capabilities_AVP		sIP_Server_Capabilities optional,
 	Authorization_Lifetime_AVP		authorization_Lifetime optional,
	Auth_Grace_Period_AVP			auth_Grace_Period optional,
	Redirect_Host_AVP				redirect_Host optional,
	Redirect_Host_Usage_AVP			redirect_Host_Usage optional,
 	Redirect_Max_Cache_Time_AVP		redirect_Max_Cache_Time optional,
	set_of_Proxy_Info_AVP 			proxy_Info optional,
	set_of_Route_Record_AVP  		route_Record optional,
	set_of_AVP_Type					aVP_Type optional				
}*/
DIAMETER_MSG_PreDecode(UAA_MSG)
DIAMETER_MSG_PreDecodeField_START(UAA_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Application_Id, auth_Application_Id)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Session_State, auth_Session_State)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Result_Code, result_Code)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)//required
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_SIP_Server_URI, sIP_Server_URI)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_SIP_Server_Capabilities, sIP_Server_Capabilities)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Authorization_Lifetime, authorization_Lifetime)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Auth_Grace_Period, auth_Grace_Period)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Host, redirect_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Host_Usage, redirect_Host_Usage)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Max_Cache_Time, redirect_Max_Cache_Time)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(UAA_MSG)

DIAMETER_MSG_PostDecodeField(UAA_MSG)
DIAMETER_MSG_PostDecode(UAA_MSG)

/*type record SAR_MSG{
	//Ref: RFC4740 8.3.  Server-Assignment-Request (SAR) Command
	DiameterHeader 					header,//<SAR> ::= < Diameter Header: 284, PXY >
	Session_Id, session_Id,//fixed pos.
	Auth_Application_Id_AVP 		auth_Application_Id,//required
	Auth_Session_State_AVP 			auth_Session_State,
	Origin_Host_AVP 				origin_Host,
	Origin_Realm_AVP 				origin_Realm,
	Destination_Realm_AVP			destination_Realm,
 	SIP_Server_Assignment_Type_AVP 	sIP_Server_Assignment_Type,
 	SIP_User_Data_Already_Available_AVP sIP_User_Data_Already_Available,//required
	Destination_Host_AVP			destination_Host optional,
	User_Name_AVP 					user_Name optional,
	SIP_Server_URI_AVP 				sIP_Server_URI optional, 
	set_of_SIP_Supported_User_Data_Type_AVP sIP_Supported_User_Data_Type optional, 
	set_of_SIP_AOR_AVP				sIP_AOR optional,
	set_of_Proxy_Info_AVP 			proxy_Info optional,
	set_of_Route_Record_AVP  		route_Record optional,
	set_of_AVP_Type					aVP_Type optional				
}*/
DIAMETER_MSG_PreDecode(SAR_MSG)
DIAMETER_MSG_PreDecodeField_START(SAR_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Application_Id, auth_Application_Id)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Session_State, auth_Session_State)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Destination_Realm, destination_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_SIP_Server_Assignment_Type, sIP_Server_Assignment_Type)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_SIP_User_Data_Already_Available, sIP_User_Data_Already_Available)//required
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Destination_Host, destination_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_User_Name, user_Name)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_SIP_Server_URI, sIP_Server_URI)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_SIP_Supported_User_Data_Type, sIP_Supported_User_Data_Type)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_SIP_AOR, sIP_AOR)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(SAR_MSG)

DIAMETER_MSG_PostDecodeField(SAR_MSG)
DIAMETER_MSG_PostDecode(SAR_MSG)

/*type record SAA_MSG{
	// Ref: RFC4740 8.4.  Server-Assignment-Answer (SAA) Command       			
	DiameterHeader 					header ,//<SAA> ::= < Diameter Header: 284, PXY >
	Session_Id_AVP 					session_Id,//fixed pos.
	Auth_Application_Id_AVP 		auth_Application_Id,//required
	Result_Code_AVP					result_Code,
 	Auth_Session_State_AVP 			auth_Session_State,
	Origin_Host_AVP 				origin_Host,
	Origin_Realm_AVP 				origin_Realm,
	set_of_SIP_User_Data_AVP		sIP_User_Data,
 	SIP_Accounting_Information_AVP	sIP_Accounting_Information,
	set_of_SIP_Supported_User_Data_Type_AVP sIP_Supported_User_Data_Type optional,
 	User_Name_AVP					user_Name optional,
 	Auth_Grace_Period_AVP 			auth_Grace_Period optional,
 	Authorization_Lifetime_AVP 		authorization_Lifetime optional,
 	Redirect_Host_AVP 				redirect_Host optional,
 	Redirect_Host_Usage_AVP			redirect_Host_Usage optional,
	Redirect_Max_Cache_Time_AVP		redirect_Max_Cache_Time optional,
	set_of_Proxy_Info_AVP			proxy_Info optional,
	set_of_Route_Record_AVP  		route_Record optional,
	set_of_AVP_Type					aVP_Type optional				
}*/
DIAMETER_MSG_PreDecode(SAA_MSG)
DIAMETER_MSG_PreDecodeField_START(SAA_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Application_Id, auth_Application_Id)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Result_Code, result_Code)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Session_State, auth_Session_State)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_SIP_User_Data, sIP_User_Data)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_SIP_Accounting_Information, sIP_Accounting_Information)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_SIP_Supported_User_Data_Type, sIP_Supported_User_Data_Type)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_User_Name, user_Name)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Auth_Grace_Period, auth_Grace_Period)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Authorization_Lifetime, authorization_Lifetime)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Host, redirect_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Host_Usage, redirect_Host_Usage)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Max_Cache_Time, redirect_Max_Cache_Time)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(SAA_MSG)

DIAMETER_MSG_PostDecodeField(SAA_MSG)
DIAMETER_MSG_PostDecode(SAA_MSG)

/*type record LIR_MSG{
	//Ref: RFC4740 8.5.  Location-Info-Request (LIR) Command
	DiameterHeader 					header ,//<LIA> ::= < Diameter Header: 285, PXY >
	Session_Id_AVP 					session_Id,//fixed pos.
	Auth_Application_Id_AVP 		auth_Application_Id,//required
	Auth_Session_State_AVP 			auth_Session_State,
	Origin_Host_AVP 				origin_Host,
	Origin_Realm_AVP 				origin_Realm,
	Destination_Realm_AVP			destination_Realm,
	SIP_AOR_AVP						sIP_AOR, //requ.
	Destination_Host_AVP			destination_Host optional,
	set_of_Proxy_Info_AVP			proxy_Info optional,
	set_of_Route_Record_AVP  		route_Record optional,
	set_of_AVP_Type					aVP_Type optional					
}*/
DIAMETER_MSG_PreDecode(LIR_MSG)
DIAMETER_MSG_PreDecodeField_START(LIR_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Application_Id, auth_Application_Id)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Session_State, auth_Session_State)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Destination_Realm, destination_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_SIP_AOR, sIP_AOR) //requ.
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Destination_Host, destination_Host)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(LIR_MSG)

DIAMETER_MSG_PostDecodeField(LIR_MSG)
DIAMETER_MSG_PostDecode(LIR_MSG)

/*type record LIA_MSG{
	//Ref: RFC4740 8.6.  Location-Info-Answer (LIA) Command
	DiameterHeader 					header ,//<LIA> ::= < Diameter Header: 285, PXY >      
	Session_Id_AVP 					session_Id,//fixed pos.
	Auth_Application_Id_AVP 		auth_Application_Id,//required
	Result_Code_AVP					result_Code,
	Auth_Session_State_AVP 			auth_Session_State,
	Origin_Host_AVP 				origin_Host,
	Origin_Realm_AVP 				origin_Realm,//required
	SIP_Server_URI_AVP 				sIP_Server_URI optional,
	SIP_Server_Capabilities_AVP		sIP_Server_Capabilities optional,
	Auth_Grace_Period_AVP 			auth_Grace_Period optional,
	Authorization_Lifetime_AVP 		authorization_Lifetime optional,
	Redirect_Host_AVP 				redirect_Host optional,
	Redirect_Host_Usage_AVP			redirect_Host_Usage optional,
	Redirect_Max_Cache_Time_AVP		redirect_Max_Cache_Time optional,
	set_of_Proxy_Info_AVP			proxy_Info optional,
	set_of_Route_Record_AVP  		route_Record optional,
	set_of_AVP_Type					aVP_Type optional				
}*/
DIAMETER_MSG_PreDecode(LIA_MSG)
DIAMETER_MSG_PreDecodeField_START(LIA_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Application_Id, auth_Application_Id)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Result_Code, result_Code)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Session_State, auth_Session_State)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)//required
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_SIP_Server_URI, sIP_Server_URI)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_SIP_Server_Capabilities, sIP_Server_Capabilities)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Auth_Grace_Period, auth_Grace_Period)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Authorization_Lifetime, authorization_Lifetime)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Host, redirect_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Host_Usage, redirect_Host_Usage)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Max_Cache_Time, redirect_Max_Cache_Time)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(LIA_MSG)

DIAMETER_MSG_PostDecodeField(LIA_MSG)
DIAMETER_MSG_PostDecode(LIA_MSG)

/*type record MAR_MSG{
	//Ref: RFC4740 8.7.  Multimedia-Auth-Request (MAR) Command
	DiameterHeader 					header ,//<MAR> ::= < Diameter Header: 286, REQ, PXY >
	Session_Id_AVP 					session_Id,//fixed pos.
	Auth_Application_Id_AVP 		auth_Application_Id,//required
	Auth_Session_State_AVP 			auth_Session_State,
	Origin_Host_AVP 				origin_Host,
	Origin_Realm_AVP 				origin_Realm,
	Destination_Realm_AVP			destination_Realm,
	SIP_AOR_AVP						sIP_AOR, 
 	SIP_Method_AVP 					sIP_Method,//requ.
	Destination_Host_AVP			destination_Host optional,
 	User_Name_AVP					user_Name optional,
	SIP_Server_URI_AVP 				sIP_Server_URI optional,
	SIP_Number_Auth_Items_AVP		sIP_Number_Auth_Items optional,
 	SIP_Auth_Data_Item_AVP			sIP_Auth_Data_Item optional,
	set_of_Proxy_Info_AVP			proxy_Info optional,
	set_of_Route_Record_AVP  		route_Record optional,
	set_of_AVP_Type					aVP_Type optional				
}*/
DIAMETER_MSG_PreDecode(MAR_MSG)
DIAMETER_MSG_PreDecodeField_START(MAR_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Application_Id, auth_Application_Id)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Session_State, auth_Session_State)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Destination_Realm, destination_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_SIP_AOR, sIP_AOR)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_SIP_Method, sIP_Method)//requ.
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Destination_Host, destination_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_User_Name, user_Name)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_SIP_Server_URI, sIP_Server_URI)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_SIP_Number_Auth_Items, sIP_Number_Auth_Items)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_SIP_Auth_Data_Item, sIP_Auth_Data_Item)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(MAR_MSG)

DIAMETER_MSG_PostDecodeField(MAR_MSG)
DIAMETER_MSG_PostDecode(MAR_MSG)

/*type record MAA_MSG{
	//Ref: RFC4740 8.8.  Multimedia-Auth-Answer (MAA) Command
	DiameterHeader 					header ,//<MAA> ::= < Diameter Header: 286, PXY >       
	Session_Id_AVP 					session_Id,//fixed pos.
	Auth_Application_Id_AVP 		auth_Application_Id,//required
	Result_Code_AVP					result_Code,
	Auth_Session_State_AVP 			auth_Session_State,
	Origin_Host_AVP 				origin_Host,
	Origin_Realm_AVP 				origin_Realm,//requi.
	User_Name_AVP					user_Name optional,
	SIP_AOR_AVP						sIP_AOR optional, 
	SIP_Number_Auth_Items_AVP		sIP_Number_Auth_Items optional,
	set_of_SIP_Auth_Data_Item_AVP	sIP_Auth_Data_Item optional,
	Auth_Grace_Period_AVP 			auth_Grace_Period optional,
	Authorization_Lifetime_AVP 		authorization_Lifetime optional,
	Redirect_Host_AVP 				redirect_Host optional,
	Redirect_Host_Usage_AVP			redirect_Host_Usage optional,
	Redirect_Max_Cache_Time_AVP		redirect_Max_Cache_Time optional,
	set_of_Proxy_Info_AVP			proxy_Info optional,
	set_of_Route_Record_AVP  		route_Record optional,
	set_of_AVP_Type					aVP_Type optional				
}*/
DIAMETER_MSG_PreDecode(MAA_MSG)
DIAMETER_MSG_PreDecodeField_START(MAA_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Application_Id, auth_Application_Id)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Result_Code, result_Code)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Session_State, auth_Session_State)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_User_Name, user_Name)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_SIP_AOR, sIP_AOR) 
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_SIP_Number_Auth_Items, sIP_Number_Auth_Items)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_SIP_Auth_Data_Item, sIP_Auth_Data_Item)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Auth_Grace_Period, auth_Grace_Period)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Authorization_Lifetime, authorization_Lifetime)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Host, redirect_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Host_Usage, redirect_Host_Usage)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Max_Cache_Time, redirect_Max_Cache_Time)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(MAA_MSG)

DIAMETER_MSG_PostDecodeField(MAA_MSG)
DIAMETER_MSG_PostDecode(MAA_MSG)

/*type record RTR_MSG{
	//Ref: RFC4740 8.9.  Registration-Termination-Request (RTR) Command
	DiameterHeader 					header ,//<RTR> ::= < Diameter Header: 287, REQ, PXY >   
	Session_Id_AVP 					session_Id,//fixed pos.
	Auth_Application_Id_AVP 		auth_Application_Id,//required
	Auth_Session_State_AVP 			auth_Session_State,
	Origin_Host_AVP 				origin_Host,
	Origin_Realm_AVP 				origin_Realm,
	Destination_Host_AVP			destination_Host,
	SIP_Deregistration_Reason_AVP 	sIP_Deregistration_Reason,//requi.
	Destination_Realm_AVP			destination_Realm,
	User_Name_AVP					user_Name optional,
	set_of_SIP_AOR_AVP				sIP_AOR optional,
	set_of_Proxy_Info_AVP			proxy_Info optional,
	set_of_Route_Record_AVP  		route_Record optional,
	set_of_AVP_Type					aVP_Type optional				
}*/
DIAMETER_MSG_PreDecode(RTR_MSG)
DIAMETER_MSG_PreDecodeField_START(RTR_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Application_Id, auth_Application_Id)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Session_State, auth_Session_State)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Destination_Host, destination_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_SIP_Deregistration_Reason, sIP_Deregistration_Reason)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Destination_Realm, destination_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_User_Name, user_Name)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_SIP_AOR, sIP_AOR)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(RTR_MSG)

DIAMETER_MSG_PostDecodeField(RTR_MSG)
DIAMETER_MSG_PostDecode(RTR_MSG)

/*type record RTA_MSG{
	//Ref: RFC4740 8.10.  Registration-Termination-Answer (RTA) Command
	DiameterHeader 					header ,//<RTA> ::= < Diameter Header: 287, PXY >
	Session_Id_AVP 					session_Id,//fixed pos.
	Auth_Application_Id_AVP 		auth_Application_Id,//required
	Result_Code_AVP					result_Code,
	Auth_Session_State_AVP 			auth_Session_State,
	Origin_Host_AVP 				origin_Host,
	Origin_Realm_AVP 				origin_Realm,//requi.
	Authorization_Lifetime_AVP 		authorization_Lifetime optional,
	Auth_Grace_Period_AVP 			auth_Grace_Period optional,
	Redirect_Host_AVP 				redirect_Host optional,
	Redirect_Host_Usage_AVP			redirect_Host_Usage optional,
	Redirect_Max_Cache_Time_AVP		redirect_Max_Cache_Time optional,
	set_of_Proxy_Info_AVP			proxy_Info optional,
	set_of_Route_Record_AVP  		route_Record optional,
	set_of_AVP_Type					aVP_Type optional					
}*/
DIAMETER_MSG_PreDecode(RTA_MSG)
DIAMETER_MSG_PreDecodeField_START(RTA_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Application_Id, auth_Application_Id)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Result_Code, result_Code)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Session_State, auth_Session_State)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Authorization_Lifetime, authorization_Lifetime)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Auth_Grace_Period, auth_Grace_Period)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Host, redirect_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Host_Usage, redirect_Host_Usage)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Max_Cache_Time, redirect_Max_Cache_Time)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(RTA_MSG)

DIAMETER_MSG_PostDecodeField(RTA_MSG)
DIAMETER_MSG_PostDecode(RTA_MSG)

/*type record PPR_MSG{
	//Ref: RFC4740 8.11.  Push-Profile-Request (PPR) Command
	DiameterHeader 					header ,//<PPR> ::= < Diameter Header: 288, REQ, PXY >
	Session_Id_AVP 					session_Id,//fixed pos.
	Auth_Application_Id_AVP 		auth_Application_Id,//required
	Auth_Session_State_AVP 			auth_Session_State,
	Origin_Host_AVP 				origin_Host,
	Origin_Realm_AVP 				origin_Realm,
	Destination_Realm_AVP			destination_Realm,
	User_Name_AVP					user_Name ,//required
	set_of_SIP_User_Data_AVP		sIP_User_Data optional,
	SIP_Accounting_Information_AVP	sIP_Accounting_Information,//TODO: this is optional in spec
	Destination_Host_AVP			destination_Host optional,
	Authorization_Lifetime_AVP 		authorization_Lifetime optional,
	Auth_Grace_Period_AVP 			auth_Grace_Period optional,
	set_of_Proxy_Info_AVP			proxy_Info optional,
	set_of_Route_Record_AVP  		route_Record optional,
	set_of_AVP_Type					aVP_Type optional				
}*/
DIAMETER_MSG_PreDecode(PPR_MSG)
DIAMETER_MSG_PreDecodeField_START(PPR_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Application_Id, auth_Application_Id)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Session_State, auth_Session_State)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Destination_Realm, destination_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_User_Name, user_Name)//required
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_SIP_User_Data, sIP_User_Data)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_SIP_Accounting_Information, sIP_Accounting_Information)//TODO: this is optional in spec
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Destination_Host, destination_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Authorization_Lifetime, authorization_Lifetime)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Auth_Grace_Period, auth_Grace_Period)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(PPR_MSG)

DIAMETER_MSG_PostDecodeField(PPR_MSG)
DIAMETER_MSG_PostDecode(PPR_MSG)

/*type record PPA_MSG{
	//Ref: RFC4740 8.12.  Push-Profile-Answer (PPA) Command
	DiameterHeader 					header ,//<PPA> ::= < Diameter Header: 288, PXY >
	Session_Id, session_Id,//fixed pos.
	Auth_Application_Id_AVP 		auth_Application_Id,//required
	Result_Code_AVP					result_Code,
	Auth_Session_State_AVP 			auth_Session_State,
	Origin_Host_AVP 				origin_Host,
	Origin_Realm_AVP 				origin_Realm,//requi.      
	Redirect_Host_AVP 				redirect_Host optional,
	Redirect_Host_Usage_AVP			redirect_Host_Usage optional,
	Redirect_Max_Cache_Time_AVP		redirect_Max_Cache_Time optional,
	set_of_Proxy_Info_AVP			proxy_Info optional,
	set_of_Route_Record_AVP  		route_Record optional,
	set_of_AVP_Type					aVP_Type optional				
}*/
DIAMETER_MSG_PreDecode(PPA_MSG)
DIAMETER_MSG_PreDecodeField_START(PPA_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Application_Id, auth_Application_Id)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Result_Code, result_Code)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Session_State, auth_Session_State)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)//requi.      
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Host, redirect_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Host_Usage, redirect_Host_Usage)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Max_Cache_Time, redirect_Max_Cache_Time)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(PPA_MSG)

DIAMETER_MSG_PostDecodeField(PPA_MSG)
DIAMETER_MSG_PostDecode(PPA_MSG)

/*type record UDR_MSG{
	//	Ref: 3GPP TS 29.329	6.1.1 User-Data-Request (UDR) Command  
	DiameterHeader 					header ,//< User-Data-Request> ::= < Diameter Header: 306, REQ, PXY, 16777217 >				
	Session_Id_AVP 					session_Id,//fixed pos.
	Vendor_Specific_Appl_Id_AVP 	vendor_Specific_Application_Id optional,
	Auth_Session_State_AVP 			auth_Session_State,//requi.
	Origin_Host_AVP 				origin_Host,//requi.
	Origin_Realm_AVP 				origin_Realm,//requi.
	Destination_Host_AVP			destination_Host optional,
	Destination_Realm_AVP			destination_Realm,//requi.
	set_of_Supported_Features_AVP 	supported_Features optional,
	User_Identity_AVP 				user_Identity,//requi.
	Wildcarded_PSI_AVP 				wildcarded_PSI optional,
	Wildcarded_IMPU_AVP 			wildcarded_IMPU optional,
	Server_Name_AVP 				server_Name optional,
	set_of_Service_Indication_AVP 	service_Indication optional,
	set_of_Data_Reference_AVP 		data_Reference,//requi.
	set_of_Identity_Set_AVP 		identity_Set optional,
	Requested_Domain_AVP 			requested_Domain optional,
	Current_Location_AVP 			current_Location optional,
	set_of_DSAI_Tag_AVP				dSAI_Tag optional,	
	set_of_Proxy_Info_AVP			proxy_Info optional,
	set_of_Route_Record_AVP  		route_Record optional,
	set_of_AVP_Type					aVP_Type optional					
}*/
DIAMETER_MSG_PreDecode(UDR_MSG)
DIAMETER_MSG_PreDecodeField_START(UDR_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Vendor_Specific_Application_Id, vendor_Specific_Application_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Session_State, auth_Session_State)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Destination_Host, destination_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Destination_Realm, destination_Realm)//requi.
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Supported_Features, supported_Features)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_User_Identity, user_Identity)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Wildcarded_Public_Identity, wildcarded_PSI)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Wildcarded_IMPU, wildcarded_IMPU)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Server_Name, server_Name)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Service_Indication, service_Indication)
DIAMETER_MSG_PreDecodeField_SET_OF_MANDATORY_R(AVP_CODE_Data_Reference, data_Reference)//requi.
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Identity_Set, identity_Set)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Requested_Domain, requested_Domain)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Current_Location, current_Location)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_DSAI_Tag, dSAI_Tag)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(UDR_MSG)

DIAMETER_MSG_PostDecodeField(UDR_MSG)
DIAMETER_MSG_PostDecode(UDR_MSG)

/*type record UDA_MSG{
	//	Ref: 3GPP TS 29.329	6.1.2 User-Data-Answer (UDA) Command	
	DiameterHeader 					header ,//< Diameter Header: 306, PXY, 16777217 >
	Session_Id_AVP 					session_Id,//fixed pos.
	Vendor_Specific_Appl_Id_AVP 	vendor_Specific_Application_Id,
	Result_Code_AVP					result_Code,
	Experimental_Result_AVP			experimental_Result optional,
	Auth_Session_State_AVP 			auth_Session_State,//requi.
	Origin_Host_AVP 				origin_Host,//requi.
	Origin_Realm_AVP 				origin_Realm,//requi.
	set_of_Supported_Features_AVP 	supported_Features optional,
	Wildcarded_PSI_AVP 				wildcarded_PSI optional,
	Wildcarded_IMPU_AVP 			wildcarded_IMPU optional,
	User_Data_AVP 					user_Data optional,
	set_of_AVP_Type					aVP_Type optional,
	set_of_Failed_AVP				failed optional,	
	set_of_Proxy_Info_AVP			proxy_Info optional,
	set_of_Route_Record_AVP  		route_Record optional		 
}*/
DIAMETER_MSG_PreDecode(UDA_MSG)
DIAMETER_MSG_PreDecodeField_START(UDA_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Vendor_Specific_Application_Id, vendor_Specific_Application_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Result_Code, result_Code)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Experimental_Result, experimental_Result)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Session_State, auth_Session_State)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)//requi.
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Supported_Features, supported_Features)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Wildcarded_Public_Identity, wildcarded_PSI)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Wildcarded_IMPU, wildcarded_IMPU)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_User_Data, user_Data)

//TODO:NOT the last field!!!
//set_of_AVP_Type 					aVP_Type optional

DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Failed_AVP, failed)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)

DIAMETER_MSG_PreDecodeField_END(UDA_MSG)

DIAMETER_MSG_PostDecodeField(UDA_MSG)
DIAMETER_MSG_PostDecode(UDA_MSG)

/*type record	PUR_MSG{
	//	Ref: 3GPP TS 29.329	6.1.3 Profile-Update-Request (PUR) Command	
	DiameterHeader 					header ,//< Diameter Header: 307, REQ, PXY, 16777217 >
	Session_Id_AVP 					session_Id,//fixed pos.
	Vendor_Specific_Appl_Id_AVP 	vendor_Specific_Application_Id,
	Auth_Session_State_AVP 			auth_Session_State,//requi.				
	Origin_Host_AVP 				origin_Host,//requi.
	Origin_Realm_AVP 				origin_Realm,//requi.
	Destination_Host_AVP			destination_Host optional,
	Destination_Realm_AVP			destination_Realm,//requi.
	set_of_Supported_Features_AVP 	supported_Features optional,
	User_Identity_AVP 				user_Identity,//requi.
	Wildcarded_PSI_AVP 				wildcarded_PSI optional,
	Wildcarded_IMPU_AVP 			wildcarded_IMPU optional,
	Data_Reference_AVP 				data_Reference,//requi.
	User_Data_AVP 					user_Data,//Requi.
	set_of_Proxy_Info_AVP			proxy_Info optional,
	set_of_Route_Record_AVP  		route_Record optional,
	set_of_AVP_Type					aVP_Type optional				
}*/
DIAMETER_MSG_PreDecode(PUR_MSG)
DIAMETER_MSG_PreDecodeField_START(PUR_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Vendor_Specific_Application_Id, vendor_Specific_Application_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Session_State, auth_Session_State)//requi.				
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Destination_Host, destination_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Destination_Realm, destination_Realm)//requi.
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Supported_Features, supported_Features)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_User_Identity, user_Identity)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Wildcarded_Public_Identity, wildcarded_PSI)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Wildcarded_IMPU, wildcarded_IMPU)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Data_Reference, data_Reference)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_User_Data, user_Data)//Requi.
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(PUR_MSG)

DIAMETER_MSG_PostDecodeField(PUR_MSG)
DIAMETER_MSG_PostDecode(PUR_MSG)

/*type record PUA_MSG{	
	//	Ref: 3GPP TS 29.329	6.1.4 Profile-Update-Answer (PUA) Command
	DiameterHeader 					header ,//< Diameter Header: 307, PXY, 16777217 >
	Session_Id_AVP 					session_Id,//fixed pos.
	Vendor_Specific_Appl_Id_AVP 	vendor_Specific_Application_Id,
	Result_Code_AVP					result_Code optional,
	Experimental_Result_AVP			experimental_Result optional,
	Auth_Session_State_AVP 			auth_Session_State,//requi.	
	Origin_Host_AVP 				origin_Host,//requi.
	Origin_Realm_AVP 				origin_Realm,//requi.
	Wildcarded_PSI_AVP 				wildcarded_PSI optional,
	Wildcarded_IMPU_AVP 			wildcarded_IMPU optional,
	set_of_Supported_Features_AVP 	supported_Features optional,
	set_of_AVP_Type					aVP_Type optional,
	set_of_Failed_AVP				failed optional,	
	set_of_Proxy_Info_AVP			proxy_Info optional,
	set_of_Route_Record_AVP  		route_Record optional			
}*/
DIAMETER_MSG_PreDecode(PUA_MSG)
DIAMETER_MSG_PreDecodeField_START(PUA_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Vendor_Specific_Application_Id, vendor_Specific_Application_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Result_Code, result_Code)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Experimental_Result, experimental_Result)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Session_State, auth_Session_State)//requi.	
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Wildcarded_Public_Identity, wildcarded_PSI)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Wildcarded_IMPU, wildcarded_IMPU)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Supported_Features, supported_Features)
//TODO: field not present
//set_of_AVP_Type 					aVP_Type optional
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Failed_AVP, failed)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)



DIAMETER_MSG_PreDecodeField_END(PUA_MSG)

DIAMETER_MSG_PostDecodeField(PUA_MSG)
DIAMETER_MSG_PostDecode(PUA_MSG)

/*type record SNR_MSG{
	//	Ref: 3GPP TS 29.329	6.1.5 Subscribe-Notifications-Request (SNR) Command	
	DiameterHeader 					header ,//< Diameter Header: 308, REQ, PXY, 16777217 >
	Session_Id_AVP 					session_Id,//fixed pos.
	Vendor_Specific_Appl_Id_AVP 	vendor_Specific_Application_Id,
	Auth_Session_State_AVP 			auth_Session_State,//requi.	
	Origin_Host_AVP 				origin_Host,//requi.
	Origin_Realm_AVP 				origin_Realm,//requi.
	Destination_Host_AVP			destination_Host optional,
	Destination_Realm_AVP			destination_Realm,//requi.
	set_of_Supported_Features_AVP 	supported_Features optional,
	User_Identity_AVP 				user_Identity,//requi.
	Wildcarded_PSI_AVP 				wildcarded_PSI optional,
	Wildcarded_IMPU_AVP 			wildcarded_IMPU optional,
	set_of_Service_Indication_AVP 	service_Indication optional,
	Send_Data_Indication_AVP 		send_Data_Indication  optional,
	Server_Name_AVP 				server_Name optional,
	Subs_Req_Type_AVP 				subs_Req_Type,
	set_of_Data_Reference_AVP 		data_Reference,
	set_of_Identity_Set_AVP 		identity_Set optional,
	Expiry_Time_AVP 				expiry_Time optional,
	set_of_DSAI_Tag_AVP				dSAI_Tag optional,	
	set_of_Proxy_Info_AVP			proxy_Info optional,
	set_of_Route_Record_AVP  		route_Record optional,
	set_of_AVP_Type					aVP_Type optional					
}*/
DIAMETER_MSG_PreDecode(SNR_MSG)
DIAMETER_MSG_PreDecodeField_START(SNR_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Vendor_Specific_Application_Id, vendor_Specific_Application_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Session_State, auth_Session_State)//requi.	
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Destination_Host, destination_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Destination_Realm, destination_Realm)//requi.
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Supported_Features, supported_Features)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_User_Identity, user_Identity)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Wildcarded_Public_Identity, wildcarded_PSI)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Wildcarded_IMPU, wildcarded_IMPU)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Service_Indication, service_Indication)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Send_Data_Indication, send_Data_Indication )
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Server_Name, server_Name)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Subs_Req_Type, subs_Req_Type)
DIAMETER_MSG_PreDecodeField_SET_OF_MANDATORY_R(AVP_CODE_Data_Reference, data_Reference)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Identity_Set, identity_Set)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Expiry_Time, expiry_Time)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_DSAI_Tag, dSAI_Tag)	
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(SNR_MSG)

DIAMETER_MSG_PostDecodeField(SNR_MSG)
DIAMETER_MSG_PostDecode(SNR_MSG)

/*type record SNA_MSG{	
	//	Ref: 3GPP TS 29.329	6.1.6 Subscribe-Notifications-Answer (SNA) Command
	DiameterHeader 					header ,//< Diameter Header: 308, PXY, 16777217 >
	Session_Id_AVP 					session_Id,//fixed pos.
	Vendor_Specific_Appl_Id_AVP 	vendor_Specific_Application_Id,
	Auth_Session_State_AVP 			auth_Session_State,//requi.	
	Result_Code_AVP					result_Code optional,
	Experimental_Result_AVP			experimental_Result optional,
	Origin_Host_AVP 				origin_Host,//requi.
	Origin_Realm_AVP 				origin_Realm,//requi.
	Wildcarded_PSI_AVP 				wildcarded_PSI optional,
	Wildcarded_IMPU_AVP 			wildcarded_IMPU optional,
	set_of_Supported_Features_AVP 	supported_Features optional,
	User_Data_AVP 					user_Data optional,
	Expiry_Time_AVP 				expiry_Time optional,
	set_of_Failed_AVP				failed optional,	
	set_of_Proxy_Info_AVP			proxy_Info optional,
	set_of_Route_Record_AVP  		route_Record optional,
	set_of_AVP_Type					aVP_Type optional										
}*/
DIAMETER_MSG_PreDecode(SNA_MSG)
DIAMETER_MSG_PreDecodeField_START(SNA_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Vendor_Specific_Application_Id, vendor_Specific_Application_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Session_State, auth_Session_State)//requi.	
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Result_Code, result_Code)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Experimental_Result, experimental_Result)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Wildcarded_Public_Identity, wildcarded_PSI)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Wildcarded_IMPU, wildcarded_IMPU)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Supported_Features, supported_Features)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_User_Data, user_Data)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Expiry_Time, expiry_Time)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Failed_AVP, failed)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(SNA_MSG)

DIAMETER_MSG_PostDecodeField(SNA_MSG)
DIAMETER_MSG_PostDecode(SNA_MSG)

/*type record PNR_MSG{	
	//	Ref: 3GPP TS 29.329	6.1.7 Push-Notification-Request (PNR) Command
	DiameterHeader 					header ,//< Diameter Header: 309, REQ, PXY, 16777217 >
	Session_Id_AVP 					session_Id,//fixed pos.
	Vendor_Specific_Appl_Id_AVP 	vendor_Specific_Application_Id,
	Auth_Session_State_AVP 			auth_Session_State,//requi.	
	Origin_Host_AVP 				origin_Host,//requi.
	Origin_Realm_AVP 				origin_Realm,//requi.
	Destination_Host_AVP			destination_Host optional,
	Destination_Realm_AVP			destination_Realm,//requi.
	set_of_Supported_Features_AVP 	supported_Features optional,
	User_Identity_AVP 				user_Identity,//requi.
	Wildcarded_PSI_AVP 				wildcarded_PSI optional,
	Wildcarded_IMPU_AVP 			wildcarded_IMPU optional,
	User_Data_AVP 					user_Data,//Requi.
	set_of_Proxy_Info_AVP			proxy_Info optional,
	set_of_Route_Record_AVP  		route_Record optional,
	set_of_AVP_Type					aVP_Type optional			
}*/
DIAMETER_MSG_PreDecode(PNR_MSG)
DIAMETER_MSG_PreDecodeField_START(PNR_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Vendor_Specific_Application_Id, vendor_Specific_Application_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Session_State, auth_Session_State)//requi.	
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Destination_Host, destination_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Destination_Realm, destination_Realm)//requi.
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Supported_Features, supported_Features)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_User_Identity, user_Identity)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Wildcarded_Public_Identity, wildcarded_PSI)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Wildcarded_IMPU, wildcarded_IMPU)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_User_Data, user_Data)//Requi.
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(PNR_MSG)

DIAMETER_MSG_PostDecodeField(PNR_MSG)
DIAMETER_MSG_PostDecode(PNR_MSG)

/*type record PNA_MSG{	
	//	Ref: 3GPP TS 29.329	6.1.8 Push-Notifications-Answer (PNA) Command
	DiameterHeader	 				header ,//< Diameter Header: 309, PXY, 16777217 >
	Session_Id_AVP 					session_Id,//fixed pos.
	Vendor_Specific_Appl_Id_AVP 	vendor_Specific_Application_Id,
	Result_Code_AVP					result_Code optional,
	Experimental_Result_AVP			experimental_Result optional,
	Auth_Session_State_AVP 			auth_Session_State,//requi.	
	Origin_Host_AVP 				origin_Host,//requi.
	Origin_Realm_AVP 				origin_Realm,//requi.
	set_of_Supported_Features_AVP 	supported_Features optional,
	set_of_AVP_Type					aVP_Type optional,
	set_of_Failed_AVP				failed optional,	
	set_of_Proxy_Info_AVP			proxy_Info optional,
	set_of_Route_Record_AVP  		route_Record optional				
}*/
DIAMETER_MSG_PreDecode(PNA_MSG)
DIAMETER_MSG_PreDecodeField_START(PNA_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Vendor_Specific_Application_Id, vendor_Specific_Application_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Result_Code, result_Code)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Experimental_Result, experimental_Result)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Session_State, auth_Session_State)//requi.	
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)//requi.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)//requi.
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Supported_Features, supported_Features)
//TODO: field not present at all!!!
//set_of_AVP_Type 					aVP_Type optional
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Failed_AVP, failed)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)



DIAMETER_MSG_PreDecodeField_END(PNA_MSG)

DIAMETER_MSG_PostDecodeField(PNA_MSG)
DIAMETER_MSG_PostDecode(PNA_MSG)

/*type record	CCR_MSG{
	//	Ref:  RFC4006   3.1.  Credit-Control-Request (CCR) Command																		
	DiameterHeader 					header ,//< Diameter Header: 272, REQ, PXY>
	Session_Id_AVP 					session_Id,//fixed pos. 			//RFC4006 & TS129 212
	Origin_Host_AVP 				origin_Host,//requi.				//RFC4006 & TS129 212
	Origin_Realm_AVP 				origin_Realm,//requi.				//RFC4006 & TS129 212
	Destination_Realm_AVP			destination_Realm,//requi.			//RFC4006 & TS129 212
	Auth_Application_Id_AVP 		auth_Application_Id,				//RFC4006 & TS129 212
	Service_Context_Id_AVP 			service_Context_Id optional,		//RFC4006
	CC_Request_Type_AVP 			cC_Request_Type,					//RFC4006 & TS129 212
	CC_Request_Number_AVP 			cC_Request_Number,					//RFC4006 & TS129 212
	Destination_Host_AVP 			destination_Host optional,			//RFC4006 & TS129 212
	User_Name_AVP 					user_Name optional,					//RFC4006
	CC_Sub_Session_Id_AVP 			cC_Sub_Session_Id optional,			//RFC4006
	Acct_Multi_Session_Id_AVP 		acct_Multi_Session_Id optional,		//RFC4006
	Origin_State_Id_AVP 			origin_State_Id optional,			//RFC4006 & TS129 212
	Event_Timestamp_AVP 			event_Timestamp optional,			//RFC4006
	set_of_Subscription_Id_AVP 		subscription_Id optional,			//RFC4006 & TS129 212
	Service_Identifier_AVP 			service_Identifier optional,		//RFC4006
	Termination_Cause_AVP 			termination_Cause optional,			//RFC4006 & TS129 212
	Requested_Service_Unit_AVP 		requested_Service_Unit optional,	//RFC4006
	Requested_Action_AVP 			requested_Action optional,			//RFC4006
	set_of_Used_Service_Unit_AVP 	used_Service_Unit optional,			//RFC4006
	Multiple_Services_Indicator_AVP multiple_Services_Indicator optional,					//RFC4006
	set_of_Multiple_Services_Credit_Control_AVP multiple_Services_Credit_Control optional,	//RFC4006
	set_of_Service_Parameter_Info_AVP service_Parameter_Info optional,	//RFC4006
	CC_Correlation_Id_AVP 			cC_Correlation_Id optional,			//RFC4006	
	set_of_Supported_Features_AVP	supported_Features optional,				//TS129 212 only
    Network_Request_Support_AVP		network_Request_Support optional,			//TS129 212 only
    set_of_Packet_Filter_Information_AVP	packet_Filter_Information optional,	//TS129 212 only
    Packet_Filter_Operation_AVP		packet_Filter_Operation optional,			//TS129 212 only
    Bearer_Identifier_AVP			bearer_Identifier optional,					//TS129 212 only
    Bearer_Operation_AVP			bearer_Operation optional,					//TS129 212 only
    Framed_IP_Address_AVP			framed_IP_Address optional,					//TS129 212 only
    Framed_IPv6_Prefix_AVP			framed_IPv6_Prefix optional,				//TS129 212 only
    IP_CAN_Type_AVP					iP_CAN_Type optional,						//TS129 212 only
    ThreeGPP_RAT_Type_AVP			threeGPP_RAT_Type optional,					//TS129 212 only
    RAT_Type_AVP					rAT_Type optional,							//TS129 212 only
    QoS_Information_AVP				qoS_Information optional,					//TS129 212 only
    QoS_Negotiation_AVP				qoS_Negotiation optional,					//TS129 212 only
    QoS_Upgrade_AVP					qoS_Upgrade optional,						//TS129 212 only
    Default_EPS_Bearer_QoS_AVP		default_EPS_Bearer_QoS optional,			//TS129 212 only
    record_of_AN_GW_Address_AVP	aN_GW_Address optional,			//TS129 212 only
    ThreeGPP_SGSN_MCC_MNC_AVP		threeGPP_SGSN_MCC_MNC optional,				//TS129 212 only
    ThreeGPP_SGSN_Address_AVP		threeGPP_SGSN_Address optional,				//TS129 212 only
    ThreeGPP_SGSN_IPv6_Address_AVP	threeGPP_SGSN_IPv6_Address optional,		//TS129 212 only
    RAI_AVP							rAI optional,								//TS129 212 only
    ThreeGPP_User_Location_Info_AVP	threeGPP_User_Location_Info optional,		//TS129 212 only
    ThreeGPP_MS_TimeZone_AVP		threeGPP_MS_TimeZone optional,				//TS129 212 only
    Called_Station_Id_AVP			called_Station_Id optional,					//TS129 212 only
    PDN_Connection_ID_AVP			pDN_Connection_ID optional,					//TS129 212 only
    Bearer_Usage_AVP				bearer_Usage optional,						//TS129 212 only
    Online_AVP						online optional,							//TS129 212 only
    Offline_AVP						offline optional,							//TS129 212 only
    set_of_TFT_Packet_Filter_Information_AVP	tFT_Packet_Filter_Information optional,		//TS129 212 only
    set_of_Charging_Rule_Report_AVP	charging_Rule_Report optional,				//TS129 212 only
    set_of_Event_Trigger_AVP		event_Trigger optional,						//TS129 212 only
    Event_Report_Indication_AVP		event_Report_Indication optional,			//TS129 212 only
    Access_Network_Charging_Address_AVP	access_Network_Charging_Address optional,//TS129 212 only
    set_of_Access_Network_Charging_Identifier_Gx_AVP	access_Network_Charging_Identifier_Gx optional,		//TS129 212 only
    set_of_CoA_Information_AVP		coA_Information optional,					//TS129 212 only
    set_of_Usage_Monitoring_Information_AVP	usage_Monitoring_Information optional,//TS129 212 only
    Routing_Rule_Install_AVP		routing_Rule_Install optional,				//TS129 212 only
    Routing_Rule_Remove_AVP			routing_Rule_Remove optional,				//TS129 212 only
    Maximum_Bandwidth_AVP			maximum_Bandwidth optional,					//TS129 212 only
    Logical_Access_ID_AVP			logical_Access_ID optional,					//TS129 212 only
    Physical_Access_ID_AVP			physical_Access_ID optional,				//TS129 212 only
	User_Equipment_Info_AVP 		user_Equipment_Info optional,				//RFC4006 & TS129 212
	set_of_Proxy_Info_AVP			proxy_Info optional,						//RFC4006 & TS129 212
	set_of_Route_Record_AVP  		route_Record optional,						//RFC4006 & TS129 212
	set_of_AVP_Type					aVP_Type optional							//RFC4006 & TS129 212
}*/
DIAMETER_MSG_PreDecode(CCR_MSG)
DIAMETER_MSG_PreDecodeField_START(CCR_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos. 			//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)//requi.				//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)//requi.				//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Destination_Realm, destination_Realm)//requi.			//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Application_Id, auth_Application_Id)				//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Service_Context_Id, service_Context_Id)		//RFC4006
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_CC_Request_Type, cC_Request_Type)					//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_CC_Request_Number, cC_Request_Number)					//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Destination_Host, destination_Host)			//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_User_Name, user_Name)					//RFC4006
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_CC_Sub_Session_Id, cC_Sub_Session_Id)			//RFC4006
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Acct_Multi_Session_Id, acct_Multi_Session_Id)		//RFC4006
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Origin_State_Id, origin_State_Id)			//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Event_Timestamp, event_Timestamp)			//RFC4006
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Subscription_Id, subscription_Id)			//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Service_Identifier, service_Identifier)		//RFC4006
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Termination_Cause, termination_Cause)			//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Requested_Service_Unit, requested_Service_Unit)	//RFC4006
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Requested_Action, requested_Action)			//RFC4006
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Used_Service_Unit, used_Service_Unit)			//RFC4006
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Multiple_Services_Indicator, multiple_Services_Indicator)					//RFC4006
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Multiple_Services_Credit_Control, multiple_Services_Credit_Control)	//RFC4006
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Service_Parameter_Info, service_Parameter_Info)	//RFC4006
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_CC_Correlation_Id, cC_Correlation_Id)			//RFC4006	
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Supported_Features, supported_Features)				//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Network_Request_Support, network_Request_Support)			//TS129 212 only
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Packet_Filter_Information, packet_Filter_Information)	//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Packet_Filter_Operation, packet_Filter_Operation)			//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Bearer_Identifier, bearer_Identifier)					//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Bearer_Operation, bearer_Operation)					//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Framed_IP_Address, framed_IP_Address)					//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Framed_IPv6_Prefix, framed_IPv6_Prefix)				//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_IP_CAN_Type, iP_CAN_Type)						//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_ThreeGPP_RAT_Type, threeGPP_RAT_Type)					//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_RAT_Type, rAT_Type)							//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_QoS_Information, qoS_Information)					//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_QoS_Negotiation, qoS_Negotiation)					//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_QoS_Upgrade, qoS_Upgrade)						//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Default_EPS_Bearer_QoS, default_EPS_Bearer_QoS)			//TS129 212 only
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_AN_GW_Address, aN_GW_Address)			//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_ThreeGPP_SGSN_MCC_MNC, threeGPP_SGSN_MCC_MNC)				//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_ThreeGPP_SGSN_Address, threeGPP_SGSN_Address)				//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_ThreeGPP_SGSN_IPv6_Address, threeGPP_SGSN_IPv6_Address)		//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_RAI, rAI)								//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_ThreeGPP_User_Location_Info, threeGPP_User_Location_Info)		//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_ThreeGPP_MS_TimeZone, threeGPP_MS_TimeZone)				//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Called_Station_Id, called_Station_Id)					//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_PDN_Connection_ID, pDN_Connection_ID)					//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Bearer_Usage, bearer_Usage)						//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Online, online)							//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Offline, offline)							//TS129 212 only
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_TFT_Packet_Filter_Information, tFT_Packet_Filter_Information)		//TS129 212 only
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Charging_Rule_Report, charging_Rule_Report)				//TS129 212 only
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Event_Trigger, event_Trigger)						//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Event_Report_Indication, event_Report_Indication)			//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Access_Network_Charging_Address, access_Network_Charging_Address)//TS129 212 only
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Access_Network_Charging_Identifier_Gx, access_Network_Charging_Identifier_Gx)		//TS129 212 only
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_CoA_Information, coA_Information)					//TS129 212 only
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Usage_Monitoring_Information, usage_Monitoring_Information)//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Routing_Rule_Install, routing_Rule_Install)				//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Routing_Rule_Remove, routing_Rule_Remove)				//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Maximum_Bandwidth, maximum_Bandwidth)					//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Logical_Access_ID, logical_Access_ID)					//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Physical_Access_ID, physical_Access_ID)				//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_User_Equipment_Info, user_Equipment_Info)				//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)						//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(CCR_MSG)

DIAMETER_MSG_PostDecodeField(CCR_MSG)
DIAMETER_MSG_PostDecode(CCR_MSG)

/*type record CCA_MSG{
	//	Ref: RFC4006 3.2.  Credit-Control-Answer (CCA) Command
	DiameterHeader 					header ,//< Diameter Header: 272, PXY>
	Session_Id_AVP 					session_Id,//fixed pos.			//RFC4006 & TS129 212		
	Result_Code, result_Code optional,			//RFC4006 & TS129 212-optional 
	Origin_Host_AVP 				origin_Host,//requi.			//RFC4006 & TS129 212
	Origin_Realm_AVP 				origin_Realm,//requi.			//RFC4006 & TS129 212
	Auth_Application_Id_AVP 		auth_Application_Id,			//RFC4006 & TS129 212
	CC_Request_Type_AVP 			cC_Request_Type,				//RFC4006 & TS129 212
	CC_Request_Number_AVP 			cC_Request_Number,				//RFC4006 & TS129 212
	User_Name_AVP 					user_Name optional,				//RFC4006
	CC_Session_Failover_AVP  		cC_Session_Failover optional,	//RFC4006
	CC_Sub_Session_Id_AVP 			cC_Sub_Session_Id optional,		//RFC4006
	Acct_Multi_Session_Id_AVP 		acct_Multi_Session_Id optional,	//RFC4006
	Origin_State_Id_AVP 			origin_State optional,			//RFC4006 & TS129 212
	Event_Timestamp_AVP 			event_Timestamp optional,		//RFC4006
	Granted_Service_Unit_AVP 		granted_Service_Unit optional, //RFC4006     				
	set_of_Multiple_Services_Credit_Control_AVP  multiple_Services_Credit_Control optional,	//RFC4006
	Cost_Information_AVP  			cost_Information optional,		//RFC4006
 	Final_Unit_Indication_AVP 		final_Unit_Indication optional,	//RFC4006
	Check_Balance_Result_AVP 		check_Balance_Result optional, //RFC4006      				
	Credit_Control_Failure_Handling_AVP  credit_Control_Failure_Handling optional,		//RFC4006
	Direct_Debiting_Failure_Handling_AVP  direct_Debiting_Failure_Handling optional,	//RFC4006
 	Validity_Time_AVP 				validity_Time optional,			//RFC4006	
	set_of_Redirect_Host_AVP  		redirect_Host optional,			//RFC4006 & TS129 212
	Redirect_Host_Usage_AVP  		redirect_Host_Usage optional,	//RFC4006 & TS129 212
	Redirect_Max_Cache_Time_AVP  	redirect_Max_Cache_Time optional,//RFC4006 & TS129 212
	Experimental_Result_AVP			experimental_Result optional,	//TS129 212 only
	set_of_Supported_Features_AVP	supported_Features optional,	//TS129 212 only
    Bearer_Control_Mode_AVP			bearer_Control_Mode optional,	//TS129 212 only
    set_of_Event_Trigger_AVP		event_Trigger optional,			//TS129 212 only
    set_of_Charging_Rule_Remove_AVP	charging_Rule_Remove optional,	//TS129 212 only
    set_of_Charging_Rule_Install_AVP	charging_Rule_Install optional,	//TS129 212 only
    Charging_Information_AVP		charging_Information optional,	//TS129 212 only
    Online_AVP						online optional,				//TS129 212 only
    Offline_AVP						offline optional,				//TS129 212 only
    set_of_QoS_Information_AVP		qoS_Information optional,		//TS129 212 only
    Revalidation_Time_AVP			revalidation_Time optional,		//TS129 212 only
    Default_EPS_Bearer_QoS_AVP		default_EPS_Bearer_QoS optional,//TS129 212 only
    Bearer_Usage_AVP				bearer_Usage optional,			//TS129 212 only
    ThreeGPP_User_Location_Info_AVP	threeGPP_User_Location_Info optional,			//TS129 212 only
    set_of_Usage_Monitoring_Information_AVP	usage_Monitoring_Information optional,	//TS129 212 only
    set_of_CSG_Information_Reporting_AVP	cSG_Information_Reporting optional,		//TS129 212 only
    User_CSG_Information_AVP		user_CSG_Information optional,	//TS129 212 only
    Error_Message_AVP				error_Message optional,			//TS129 212 only
    Error_Reporting_Host_AVP		error_Reporting_Host optional,	//TS129 212 only
	set_of_Proxy_Info_AVP			proxy_Info optional,			//RFC4006 & TS129 212
	set_of_Route_Record_AVP  		route_Record optional,			//RFC4006 & TS129 212
	set_of_Failed_AVP 				failed optional,			//RFC4006 & TS129 212
	set_of_AVP_Type					aVP_Type optional				//RFC4006 & TS129 212
}*/
DIAMETER_MSG_PreDecode(CCA_MSG)
DIAMETER_MSG_PreDecodeField_START(CCA_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.			//RFC4006 & TS129 212		
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Result_Code, result_Code)			//RFC4006 & TS129 212-optional 
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)//requi.			//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)//requi.			//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Application_Id, auth_Application_Id)			//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_CC_Request_Type, cC_Request_Type)				//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_CC_Request_Number, cC_Request_Number)				//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_User_Name, user_Name)				//RFC4006
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_CC_Session_Failover, cC_Session_Failover)	//RFC4006
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_CC_Sub_Session_Id, cC_Sub_Session_Id)		//RFC4006
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Acct_Multi_Session_Id, acct_Multi_Session_Id)	//RFC4006
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Origin_State_Id, origin_State)			//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Event_Timestamp, event_Timestamp)		//RFC4006
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Granted_Service_Unit, granted_Service_Unit)  //RFC4006     				
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Multiple_Services_Credit_Control, multiple_Services_Credit_Control)	//RFC4006
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Cost_Information, cost_Information)		//RFC4006
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Final_Unit_Indication, final_Unit_Indication)	//RFC4006
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Check_Balance_Result, check_Balance_Result)  //RFC4006      				
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Credit_Control_Failure_Handling, credit_Control_Failure_Handling)		//RFC4006
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Direct_Debiting_Failure_Handling, direct_Debiting_Failure_Handling)	//RFC4006
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Validity_Time, validity_Time)			//RFC4006	
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Redirect_Host, redirect_Host)			//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Host_Usage, redirect_Host_Usage)	//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Max_Cache_Time, redirect_Max_Cache_Time)//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Experimental_Result, experimental_Result)	//TS129 212 only
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Supported_Features, supported_Features)	//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Bearer_Control_Mode, bearer_Control_Mode)	//TS129 212 only
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Event_Trigger, event_Trigger)			//TS129 212 only
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Charging_Rule_Remove, charging_Rule_Remove)	//TS129 212 only
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Charging_Rule_Install, charging_Rule_Install)	//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Charging_Information, charging_Information)	//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Online, online)				//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Offline, offline)				//TS129 212 only
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_QoS_Information, qoS_Information)		//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Revalidation_Time, revalidation_Time)		//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Default_EPS_Bearer_QoS, default_EPS_Bearer_QoS)//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Bearer_Usage, bearer_Usage)			//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_ThreeGPP_User_Location_Info, threeGPP_User_Location_Info)			//TS129 212 only
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Usage_Monitoring_Information, usage_Monitoring_Information)	//TS129 212 only
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_CSG_Information_Reporting, cSG_Information_Reporting)		//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_User_CSG_Information, user_CSG_Information)	//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Error_Message, error_Message)			//TS129 212 only
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Error_Reporting_Host, error_Reporting_Host)	//TS129 212 only
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)			//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)			//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Failed_AVP, failed)			//RFC4006 & TS129 212
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(CCA_MSG)

DIAMETER_MSG_PostDecodeField(CCA_MSG)
DIAMETER_MSG_PostDecode(CCA_MSG)

/*type record AAR_MSG{
    //Ref: ETSI TS 129 214 5.6.1  -Request		
    DiameterHeader 						header ,//<ASR>  ::= < Diameter Header: 274, REQ, PXY >
    Session_Id_AVP 						session_Id,//fixed pos.
    Origin_Host_AVP 					origin_Host,//required
    Origin_Realm_AVP 					origin_Realm,
    Destination_Realm_AVP				destination_Realm,
    Destination_Host_AVP				destination_Host optional,
    Auth_Application_Id_AVP				auth_Application_Id,
    AF_Application_Identifier_AVP       af_Application_Id optional,//present in ETSI TS 129 214 p.5.6.7
    set_of_Media_Component_Description_AVP media_Component_Description optional,
    Service_Info_Status_AVP				service_Info_Status optional,
    AF_Charging_Identifier_AVP			af_Charging_Identifier optional,
    SIP_Forking_Indication_AVP			sip_Forking_Indication optional,
    set_of_Specific_Action_AVP			specific_Action optional,
    set_of_Subscription_Id_AVP			subscription_Id optional,
    set_of_Supported_Features_AVP		supported_Features optional,
    Reservation_Priority_AVP			reservation_Priority optional,
    Framed_IP_Address_AVP				framed_IP_Address optional,
    Framed_IPv6_Prefix_AVP				framed_IPv6_Address optional,
    Called_Station_Id_AVP				called_Station_Id optional,
    Service_URN_AVP						service_URN optional,	
    Sponsored_Connectivity_Data_AVP		sponsored_Connectivity_Data optional,
    MPS_Identifier_AVP					mps_Identifier optional,		
    User_Name_AVP 						user_Name optional,
    Origin_State_Id_AVP 				origin_State_Id optional,
    set_of_Proxy_Info_AVP 				proxy_Info optional,
    set_of_Route_Record_AVP  			route_Record optional,
    set_of_AVP_Type						aVP_Type optional		
}*/
DIAMETER_MSG_PreDecode(AAR_MSG)
DIAMETER_MSG_PreDecodeField_START(AAR_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Destination_Realm, destination_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Destination_Host, destination_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Application_Id, auth_Application_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_AF_Application_Identifier, af_Application_Id)//present in ETSI TS 129 214 p.5.6.7
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Media_Component_Description, media_Component_Description)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Service_Info_Status, service_Info_Status)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_AF_Charging_Identifier, af_Charging_Identifier)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_SIP_Forking_Indication, sip_Forking_Indication)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Specific_Action, specific_Action)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Subscription_Id, subscription_Id)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Supported_Features, supported_Features)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Reservation_Priority, reservation_Priority)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Framed_IP_Address, framed_IP_Address)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Framed_IPv6_Prefix, framed_IPv6_Address)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Called_Station_Id, called_Station_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Service_URN, service_URN)	
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Sponsored_Connectivity_Data, sponsored_Connectivity_Data)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_MPS_Identifier, mps_Identifier)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_User_Name, user_Name)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Origin_State_Id, origin_State_Id)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Route_Record, route_Record)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(AAR_MSG)

DIAMETER_MSG_PostDecodeField(AAR_MSG)
DIAMETER_MSG_PostDecode(AAR_MSG)

/*type record  AAA_MSG{
    //Ref: ETSI TS 129 214 5.6.2  -Request
    DiameterHeader 						header,//<ASA>  ::= < Diameter Header: 274, PXY >
    Session_Id_AVP 						session_Id,//fixed pos.
    Result_Code_AVP						result_Code optional,//required
    Origin_Host_AVP 					origin_Host,//required
    Origin_Realm_AVP 					origin_Realm,
    Auth_Application_Id_AVP 			auth_Application_Id,
    Experimental_Result_AVP				experimental_result optional,
    set_of_Access_Network_Charging_Identifier_AVP access_network_charging_Identifier optional,
    Access_Network_Charging_Address_AVP access_network_chrging_address optional,
    Acceptable_Service_Info_AVP			acceptable_service_info optional,
    IP_CAN_Type_AVP						ip_Can_Type optional,
    RAT_Type_AVP						rat_Type optional,
    set_of_Supported_Features_AVP		supported_Features optional,
    set_of_Class_AVP					class optional,
    User_Name_AVP 						user_Name optional,
    Origin_State_Id_AVP 				origin_State_Id optional,
    Error_Message_AVP					error_Message optional,
    Error_Reporting_Host_AVP			error_Reporting_Host optional,
    set_of_Failed_AVP					failed optional,
    set_of_Redirect_Host_AVP			redirect_Host optional,
    Redirect_Host_Usage_AVP				redirect_Host_Usage optional,
    Redirect_Max_Cache_Time_AVP		    redirect_Max_Cache_Time optional,
    set_of_Proxy_Info_AVP 				proxy_Info optional,
    set_of_AVP_Type						aVP_Type optional		
}*/
DIAMETER_MSG_PreDecode(AAA_MSG)
DIAMETER_MSG_PreDecodeField_START(AAA_MSG)

DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Session_Id, session_Id)//fixed pos.
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Result_Code, result_Code)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Host, origin_Host)//required
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Origin_Realm, origin_Realm)
DIAMETER_MSG_PreDecodeField_SINGLE_MANDATORY_R(AVP_CODE_Auth_Application_Id, auth_Application_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Experimental_Result, experimental_result)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Access_Network_Charging_Identifier, access_network_charging_Identifier)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Access_Network_Charging_Address, access_network_chrging_address)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Acceptable_Service_Info, acceptable_service_info)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_IP_CAN_Type, ip_Can_Type)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_RAT_Type, rat_Type)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Supported_Features, supported_Features)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_(id_class, Get_class, AVP_CODE_Class)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_User_Name, user_Name)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Origin_State_Id, origin_State_Id)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Error_Message, error_Message)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Error_Reporting_Host, error_Reporting_Host)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Failed_AVP, failed)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Redirect_Host, redirect_Host)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Host_Usage, redirect_Host_Usage)
DIAMETER_MSG_PreDecodeField_SINGLE_OPTIONAL_R(AVP_CODE_Redirect_Max_Cache_Time, redirect_Max_Cache_Time)
DIAMETER_MSG_PreDecodeField_SET_OF_OPTIONAL_R(AVP_CODE_Proxy_Info, proxy_Info)
DIAMETER_MSG_PreDecodeField_REMAINING

DIAMETER_MSG_PreDecodeField_END(AAA_MSG)

DIAMETER_MSG_PostDecodeField(AAA_MSG)
DIAMETER_MSG_PostDecode(AAA_MSG)

/*
type record DiameterHeader {
	UInt8 			    version,
	UInt24              msglen,  //message length
	Command_Flags  		cmdflags, //command flags
	Command_Code 		cmdcode, //command code
    UInt32  			applid,  //application id
    UInt32	        	hopid optional, //hop_by_hop_id
    UInt32   	        endid optional  //end_to_end_id
}*/
void DiameterHeader::PreDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
	debug_log_PreDecodeField("DiameterHeader", field_id);
	switch (field_id)
	{
		case id_cmdcode:
			Get_cmdcode().SetRequest();
			break;
		break;
		case id_hopid://mandatory in the standard
		case id_endid://mandatory in the standard
			SetHypFieldIsPresent(field_id, 1);
			break;
		default:
			break;
	}
}

/*
type record Command_Flags{
    Bit1 r_bit,  //Request
    Bit1 p_bit,  //Proxiable
    Bit1 e_bit,  //Error
    Bit1 t_bit,  //Potentialy re-transmited message
    Bit4 reserved_bits
};*/
void Command_Flags::PreDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
#ifdef DEBUG_LOG
	std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
	logfile << "Command_Flags::PreDecodeField: " << field_id << std::endl;
	logfile.close();
#endif
}

/*type record AVP_Type {
	AVP_Header         aVP_Header,
	AVP_Data           aVP_Data    optional            
};*/
void AVP_Type::PostDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
#ifdef DEBUG_LOG
	std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
	logfile << "AVP_Type::PostDecodeField: " << field_id << std::endl;
	logfile.close();
#endif
	if(field_id == id_aVP_Header)
	{
		unsigned int nCode = Get_aVP_Header().Get_aVP_Code().GetValue();
		//TODO: what is the string value???
		unsigned char buff = Get_aVP_Header().Get_aVP_flags().Get_v_bit().GetValue().at(0); 
		int nV_flag =  (buff >> 7);
		unsigned int nDataLength = Get_aVP_Header().Get_aVP_len().GetValue();

		nDataLength -= 8;
		if(nV_flag)
			nDataLength -= 4;

		if(nDataLength == 0)
			SetHypFieldIsPresent(id_aVP_Data, 0);
		else
		{
			SetHypFieldIsPresent(id_aVP_Data, 1);
			Get_aVP_Data().m_nDataLength = nDataLength;
			Get_aVP_Data().m_nExpectedData = 0;//TODO:	for now all data is considered as octetstring....

			/*in case i might know the contents based on the code and V-ID
			int nSelectedFieldId = 0;//id_oCTETSTRING;
			if(nCode == ?)
				nSelectedFieldId = 1;//id_cHARSTRING;
			else if(nCode == ?)
				nSelectedFieldId = 2;//id_iNTEGER32;
			else if(nCode == ?)
				nSelectedFieldId = 3;//id_iNTEGER64;
			else if(nCode == ?)
				nSelectedFieldId = 4;//id_iNTEGER32;
			else if(nCode == ?)
				nSelectedFieldId = 5;//id_uNSIGNED32;
			else if(nCode == ?)
				nSelectedFieldId = 6;//id_uNSIGNED64;
			else if(nCode == ?)
				nSelectedFieldId = 7;//id_fLOAT32;
			else if(nCode == ?)
				nSelectedFieldId = 8;//id_fLOAT64;
			else if(nCode == ?)
				nSelectedFieldId = 9;//id_gROUPED;
			Get_aVP_Data().m_nExpectedData = nSelectedFieldId;
			*/
		}
	}
}

void AVP_Type::PostDecode(Buffer& buffer) throw (DecodeError)
{
	unsigned int nCode = Get_aVP_Header().Get_aVP_Code().GetValue();
	unsigned char buff = Get_aVP_Header().Get_aVP_flags().Get_v_bit().GetValue().at(0); 
	int nV_flag =  (buff >> 7);
	unsigned int nDataLength = Get_aVP_Header().Get_aVP_len().GetValue();

	nDataLength -= 8;
	if(nV_flag)
		nDataLength -= 4;

	int nPadding = 0;
	while(nDataLength%4)
	{
		nDataLength++;
		nPadding++;
	}
	
	//skip padding bytes
	buffer.SetPosition(buffer.GetPosition() + nPadding * 8);
}

/*type record AVP_Header{
	AVP_Code           aVP_Code,
	AVP_Flags          aVP_flags,
	AVP_Length         aVP_len,
	AVP_Vendor_ID      aVP_vid     optional
};*/
void AVP_Header::PreDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
#ifdef DEBUG_LOG
	std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
	logfile << "AVP_Header::PreDecodeField: " << field_id << std::endl;
	logfile.close();
#endif
	if(field_id == id_aVP_vid)
	{
		unsigned char buff = Get_aVP_flags().Get_v_bit().GetValue().at(0); 
		int nV_flag =  (buff >> 7);
#ifdef DEBUG_LOG
		std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
		logfile << "AVP_Header::PreDecodeField::v_bit:: " << Get_aVP_flags().Get_v_bit().GetValue() << std::endl;
		logfile << "AVP_Header::PreDecodeField::nV_flag:: " << nV_flag << std::endl;
		logfile.close();
#endif
		SetHypFieldIsPresent(id_aVP_vid, nV_flag);
	}
}

/*type record AVP_Flags{
    Bit1    v_bit,
    Bit1    m_bit,
    Bit1    p_bit,
    Bit5    reserved_bits
}*/
void AVP_Flags::PreDecode(Buffer& buffer) throw (DecodeError)
{
#ifdef DEBUG_LOG
	Unsigned byte(8);
	byte.Decode(buffer);
	buffer.SetPosition(buffer.GetPosition() - 8);

	std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
	logfile << "AVP_Flags::PreDecode: " << std::endl;
	logfile << "AVP_Flags::Flags: " << byte.GetValue() << std::endl;
	logfile.close();
#endif
}

void AVP_Flags::PostDecode(Buffer& buffer) throw (DecodeError)
{
#ifdef DEBUG_LOG
	std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
	logfile << "AVP_Flags::PostDecode: " << std::endl;
	logfile << "AVP_Flags::v_bit: " << Get_v_bit().GetValue() << std::endl;
	logfile << "AVP_Flags::m_bit: " << Get_m_bit().GetValue() << std::endl;
	logfile << "AVP_Flags::p_bit: " << Get_p_bit().GetValue() << std::endl;
	logfile << "AVP_Flags::reserved_bits: " << Get_reserved_bits().GetValue() << std::endl;
	logfile.close();
#endif
}

/*type union AVP_Data {
	// Ref: FRC3588 p.4.1 Basic Avp Data Formats
	octetstring oCTETSTRING,
	charstring 	cHARSTRING, 
	Int32       iNTEGER32,
	Int64       iNTEGER64,
	UInt32      uNSIGNED32,
	UInt64      uNSIGNED64,
	FLOAT32     fLOAT32,
	FLOAT64     fLOAT64,
	GROUPED     gROUPED
};*/
void AVP_Data::PostEncode(Buffer& buffer) throw (EncodeError)
{
	Unsigned padding(8);
	padding.SetValue(0);

	int nSelectedFieldId = GetHypChosenId();//id_oCTETSTRING;
	int nLen = 0;
	if(nSelectedFieldId == 0)
		nLen = Get_oCTETSTRING().GetLength() / 8;
	else if(nSelectedFieldId == 1)
		nLen = Get_cHARSTRING().GetLength() / 8;
	else//no padding required
		return;
	while(nLen % 4)
	{
		nLen++;
		padding.Encode(buffer);
	}
}
void AVP_Data::PreDecode (Buffer& buffer) throw (DecodeError)
{
	debug_log_PreDecode("AVP_Data");

	int nSelectedFieldId = id_oCTETSTRING;//unknown data	
	if(m_nExpectedData == 1)//if, by any chance I might know what the data contains... then
	{
		nSelectedFieldId = id_cHARSTRING;
		SetHypFieldLength(nSelectedFieldId, m_nDataLength * 8);
	}
	else if(m_nExpectedData == 2)
		nSelectedFieldId = id_iNTEGER32;
	else if(m_nExpectedData == 3)
		nSelectedFieldId = id_iNTEGER64;
	else if(m_nExpectedData == 4)
		nSelectedFieldId = id_iNTEGER32;
	else if(m_nExpectedData == 5)
		nSelectedFieldId = id_uNSIGNED32;
	else if(m_nExpectedData == 6)
		nSelectedFieldId = id_uNSIGNED64;
	else if(m_nExpectedData == 7)
		nSelectedFieldId = id_fLOAT32;
	else if(m_nExpectedData == 8)
		nSelectedFieldId = id_fLOAT64;
	else if(m_nExpectedData == 9)
		nSelectedFieldId = id_gROUPED;
	else
		SetHypFieldLength(nSelectedFieldId, m_nDataLength * 8);

	SetHypChosenId(nSelectedFieldId);
}

/*type record GROUPED{
	AVP_Header  	aVP_Header,
	set_of_AVP_Type aVP_Type
};*/
void GROUPED::PreDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
	debug_log_PostDecodeField("GROUPED", field_id);

	if(field_id == id_aVP_Type)
	{//TODO: optimize
		unsigned int nCode = Get_aVP_Header().Get_aVP_Code().GetValue();
		unsigned char buff = Get_aVP_Header().Get_aVP_flags().Get_v_bit().GetValue().at(0); 
		int nV_flag =  (buff >> 7);
		unsigned int nDataLength = Get_aVP_Header().Get_aVP_len().GetValue();

		nDataLength -= 8;
		if(nV_flag)
			nDataLength -= 4;
			
		Get_aVP_Type().m_nRemainingDataLength = nDataLength;
	}
}

//NB!: EVERYONE WHO IS USING THIS, HAS TO SPECIFY rEMAINING AVPs, OTHERWISE THIS WILL FAIL!!!!!
//type set of AVP_Type set_of_AVP_Type;
void set_of_AVP_Type::SetRemaining(std::vector<unsigned int> lAVP_Codes, std::vector<unsigned int>  lAVP_Offsets, std::vector<unsigned int>  lIgnored)
{
#ifdef DEBUG_LOG
	std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
	logfile << "set_of_AVP_Type::SetRemaining item count in: " << lAVP_Codes.size() << std::endl;
	//logfile.close();
#endif

	bool bIgnore = false;
	for(int i=0;i < lAVP_Codes.size();i++)
	{
		bIgnore = false;
		if(lAVP_Codes.at(i) != AVP_CODE_NOT_IN_USE)
		{
			//very inefficient
			for(int y=0;y < lIgnored.size();y++)
			{
				if(lIgnored.at(y) == lAVP_Codes.at(i))
				{
					bIgnore = true;
					break;
				}
			}
			if(bIgnore)
				continue;
			m_lAVP_Codes.push_back(lAVP_Codes.at(i));
			m_lAVP_Offsets.push_back(lAVP_Offsets.at(i));
		}
	}
#ifdef DEBUG_LOG
	//std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
	logfile << "set_of_AVP_Type::SetRemaining item count out: " << m_lAVP_Codes.size() << std::endl;
	logfile.close();
#endif
}

void set_of_AVP_Type::PreDecode(Buffer& buffer) throw (DecodeError)
{
	debug_log_PreDecode("set_of_AVP_Type");

	m_nStartingPosition = buffer.GetPosition();//TODO: for set of undecoded items, this might not work...
	SetHypSize(m_lAVP_Codes.size());
	if(m_lAVP_Codes.size() > 0)
	{
#ifdef DEBUG_LOG
		std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
		logfile << "set_of_AVP_Type::PreDecode::Size: " << m_lAVP_Codes.size() << std::endl;
		logfile << "set_of_AVP_Type::PreDecode::Offset: " << m_lAVP_Offsets.at(0) << std::endl;
		logfile.close();
#endif
		buffer.SetPosition(m_lAVP_Offsets.at(0));
	}
}
void set_of_AVP_Type::PreDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
	debug_log_PreDecodeField("set_of_AVP_Type", buffer.GetPosition());
}

void set_of_AVP_Type::PostDecodeField(int id, Buffer& buffer) throw (DecodeError)
{
	debug_log_PostDecodeField("set_of_AVP_Type", id);

	if(m_lAVP_Offsets.size() > (id + 1))
	{
#ifdef DEBUG_LOG
		std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
		logfile << "set_of_AVP_Type::PostDecodeField::Offset: " << m_lAVP_Offsets.at(id+1) << std::endl;
		logfile.close();
#endif
		buffer.SetPosition(m_lAVP_Offsets.at(id+1));
	}
}

//http://www.iana.org/assignments/address-family-numbers
//0	Reserved	
//1	IP (IP version 4)	
//2	IP6 (IP version 6)
//...

/*type union Address{
	IPv4Addr ipv4,
	IPv6Addr ipv6
};*/
void Address::PreEncode(Buffer& buffer) throw (EncodeError)
{
	Unsigned family(16);
	if(GetHypChosenId() == id_ipv4)
		family.SetValue(1);
	else
		family.SetValue(2);
	family.Encode(buffer);
}
void Address::PostEncode(Buffer& buffer) throw (EncodeError)
{
	Unsigned padding(8);
	padding.SetValue(0);
	
	padding.Encode(buffer);
	padding.Encode(buffer);
}

void Address::PreDecode (Buffer& buffer) throw (DecodeError)
{
	debug_log_PreDecode("Address");

	Unsigned family(16);
	family.Decode(buffer);
	unsigned int nFamily = family.GetValue();

	if(nFamily == 1)
		SetHypChosenId(id_ipv4);
	else if(nFamily == 2)
		SetHypChosenId(id_ipv6);
	else
	{
		DecodeError ex (this); 
		ex.Msg() << "Unknown address family for deciding Address variant: " 
			   << nFamily
			   << " (valid values are: 1 and 2)" << endl; 
		throw ex;
	}
}

//type record length (4) of UInt8  IPv4Addr;
void IPv4Addr::PreDecode(Buffer& buffer) throw (DecodeError)
{
	debug_log_PreDecode("IPv4Addr");
	SetHypSize(4);
}

//type record length (8) of UInt16 IPv6Addr;
void IPv6Addr::PreDecode(Buffer& buffer) throw (DecodeError)
{
	debug_log_PreDecode("IPv6Addr");
	SetHypSize(8);
}

//////////////////////////////////////////////////////////
//////////////////  Address AVPs  ////////////////////////
//////////////////////////////////////////////////////////
#define ADDRESS_AVP_COMMON_PreDecodeField(type) \
	void type::PreDecodeField(int field_id, Buffer& buffer) throw (DecodeError)	\
	{	\
		debug_log_PreDecodeField(#type, field_id);	\
		if(field_id == id_aVP_Data)	\
		{	\
			unsigned int nDataLength = getAVPDataLength(Get_aVP_Header()); \
			SetHypFieldLength(id_aVP_Data, nDataLength * 8);	\
		}	\
	}
#define ADDRESS_AVP_COMMON_PostDecode(type) \
	void type::PostDecode(Buffer& buffer) throw (DecodeError)	\
	{	\
			unsigned int nDataLength = getAVPDataLength(Get_aVP_Header()); \
			int nPadding = 0; \
			while(nDataLength%4){	\
				nPadding++;	\
				nDataLength++;	\
			}	\
			buffer.SetPosition(buffer.GetPosition() + nPadding * 8);	\
	}

/*type record Host_IP_Address_AVP{
//Ref: RFC3588 5.3.5.  Host-IP-Address AVP
	AVP_Header			aVP_Header,//<AVP header: 257 ....>
	Address				aVP_Data
};*/
ADDRESS_AVP_COMMON_PreDecodeField(Host_IP_Address_AVP)
ADDRESS_AVP_COMMON_PostDecode(Host_IP_Address_AVP)

/*type record Access_Network_Charging_Address_AVP{
//Ref: ETSI TS 129 214 Access_Network_Charging_Address AVP
    AVP_Header			aVP_Header,//<AVP header: 501 ....>
    Address         	aVP_Data
};*/
ADDRESS_AVP_COMMON_PreDecodeField(Access_Network_Charging_Address_AVP)
ADDRESS_AVP_COMMON_PostDecode(Access_Network_Charging_Address_AVP)

/*type record Trace_Collection_Entity_AVP{
//Ref: ETSI TS129 272 Trace_Collection_Entity_AVP
    AVP_Header			aVP_Header, //<AVP header: 1452 ....>
	Address				aVP_Data
};*/
ADDRESS_AVP_COMMON_PreDecodeField(Trace_Collection_Entity_AVP)
ADDRESS_AVP_COMMON_PostDecode(Trace_Collection_Entity_AVP)

/*type record Routing_IP_Address_AVP{
//Ref: ETSI TS 129 212 Routing_IP_Address_AVP
    AVP_Header			aVP_Header,//<AVP header: 1079 ....>
    Address         	aVP_Data
};*/
ADDRESS_AVP_COMMON_PreDecodeField(Routing_IP_Address_AVP)
ADDRESS_AVP_COMMON_PostDecode(Routing_IP_Address_AVP)

/*type record AN_GW_Address_AVP{
//Ref: ETSI TS 129 212 AN_GW_Address_AVP
    AVP_Header			aVP_Header,//<AVP header: 1050 ....>
    Address         	aVP_Data
};*/
ADDRESS_AVP_COMMON_PreDecodeField(AN_GW_Address_AVP)
ADDRESS_AVP_COMMON_PostDecode(AN_GW_Address_AVP)

/*type record CoA_IP_Address_AVP{
//Ref: ETSI TS 129 212 CoA_IP_Address_AVP
    AVP_Header			aVP_Header,//<AVP header: 1035 ....>
    Address         	aVP_Data
};*/
ADDRESS_AVP_COMMON_PreDecodeField(CoA_IP_Address_AVP)
ADDRESS_AVP_COMMON_PostDecode(CoA_IP_Address_AVP)

//TODO: type not in standard
/*type record Redirect_Host_AVP{
// Ref: RFC3588 6.12.  Redirect-Host AVP
//NOTE: In Ref aVP_Data type is not defined, I presume it should be Address. rmag		
	AVP_Header         	aVP_Header,//<AVP header: 292 ....>
	Address				aVP_Data							
};*/
ADDRESS_AVP_COMMON_PreDecodeField(Redirect_Host_AVP)
ADDRESS_AVP_COMMON_PostDecode(Redirect_Host_AVP)

//////////////////////////////////////////////////////////
///////////////  DiameterURI AVPs  //////////////////
//////////////////////////////////////////////////////////

void skip_sp (Buffer & buffer) 
{
	static Regex reg_ws ("^[" SIPCHARS_WSP "]+");
	if(reg_ws.Match (buffer) && reg_ws.GetMatchedLength())
		buffer.SetPosition (buffer.GetPosition() + reg_ws.GetMatchedLength());
}

/*type record Diameter_GenericParam{
/* pid :  ";transport=" or ";protocol="
 // paramValue : 
 //	- for pid ";transport=" paramValue can be "tcp" / "udp" / "sctp"
 // - for pid ";protocol=" paramValue can be "diameter" / "radius" / "tacacs+"

  charstring	pid optional,
  charstring	paramValue optional
}*/
void Diameter_GenericParam::PreDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
#ifdef DEBUG_LOG
	std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
	logfile << "Diameter_GenericParam::PreDecodeField: " << field_id << std::endl;
	logfile.close();
#endif
	
	//transport = ";transport=" transport-protocol 
	//transport-protocol = ( "tcp" / "sctp" / "udp" )
	static Regex reg_sepSemi("^" SIPREG_SEMI);
	static Regex reg_paramStart("^;[0-9a-zA-z]+=");
	static Regex reg_paramValue("^[0-9a-zA-Z+]+");
	

	switch (field_id)
	{
		case id_pid:
			reg_paramStart.AssertMatch(buffer, this);
			SetHypFieldLength(field_id, reg_paramStart.GetMatchedLength());
			SetHypFieldIsPresent(field_id, 1);
			break;
		case id_paramValue:
			reg_paramValue.AssertMatch(buffer, this);
			SetHypFieldLength(field_id, reg_paramValue.GetMatchedLength());
			SetHypFieldIsPresent(field_id, 1);
			break;
		default:
			break;
	}
}

//type set of Diameter_GenericParam Diameter_SemicolonParam_List;
void Diameter_SemicolonParam_List::PostDecodeField(int id, Buffer& buffer) throw (DecodeError)
{
#ifdef DEBUG_LOG
	std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
	logfile << "Diameter_SemicolonParam_List::PostDecodeField: " << id << std::endl;
	logfile.close();
#endif
	static Regex reg_sepSemi("^" SIPREG_SEMI);
	if(reg_sepSemi.Match(buffer))
		SetHypSize(GetSize() +1);
	else
		SetHypSize(-2);
}

/*
type record DiameterURI{
    // 	The DiameterURI MUST follow the Uniform Resource Identifiers (URI)
    * 	syntax [URI] rules specified below:
    * 	No transport security used : "aaa://" FQDN [ port ] [ transport ] [ protocol ] 
    * 	Transport security used    : "aaas://" FQDN [ port ] [ transport ] [ protocol ]
    *  		- port = ":" 1*DIGIT       (If absent, the default Diameter port (3868) is assumed.) 
    *   	- transport = ";transport=" transport-protocol
    *   		transport-protocol = ( "tcp" / "sctp" / "udp" )
    *   	- protocol = ";protocol=" aaa-protocol (If absent, the default AAA protocol is diameter.)     
    * 			aaa-protocol       = ( "diameter" / "radius" / "tacacs+" )
    *	Examples:
    *     	aaa://host.example.com;transport=tcp
    *     	aaa://host.example.com;protocol=diameter
    *    	aaa://host.example.com:6666;protocol=diameter
    *     	aaa://host.example.com:6666;transport=tcp;protocol=diameter
    *     	aaa://host.example.com:1813;transport=udp;protocol=radius
    //	
    				charstring scheme, // "aaa://"
    				charstring diameterId_FQDN,
          			UInt16 portField optional,
    				SemicolonParam_List	uriParameters optional
    			}
*/
void DiameterURI::PreEncodeField (int field_id, Buffer& buffer) throw (EncodeError)
{
	Charstring cs;
	
	/*
	charstring scheme, // "aaa://"
	charstring diameterId_FQDN,
	UInt16 portField optional,
	SemicolonParam_List	uriParameters optional
	*/

	switch(field_id) {
	case id_scheme:
	case id_diameterId_FQDN:
	case id_portField:
		cs.SetValue(" ");
		cs.Encode(buffer);
		break;
	case id_uriParameters:
		cs.SetValue(" from ");
		cs.Encode(buffer);
		break;
	default:
		break;
	}
}

void DiameterURI::PostDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
#ifdef DEBUG_LOG
	std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
	logfile << "DiameterURI::PreDecodeField:value " << id << std::endl;

	if(id == id_scheme)
		logfile << Get_scheme().GetValue() << std::endl;
	else if(id == id_diameterId_FQDN)
		logfile << Get_diameterId_FQDN().GetValue() << std::endl;
	else if(id == id_portField)
		logfile << Get_portField().GetValue() << std::endl;
	logfile.close();
#endif
}

void DiameterURI::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	debug_log_PreDecodeField("DiameterURI", id);
	
	static Regex reg_scheme ("^(aaa://|aaas://)");
	static Regex reg_FQHN ("^[a-zA-Z][0-9a-zA-Z.-_]+");
	
	//port = ":" 1*DIGIT
	static Regex reg_sepColon("^" SIPREG_COLON);
	static Regex reg_portField("^[0-9]+");
	
	static Regex reg_sepSemi("^" SIPREG_SEMI);
	
	skip_sp(buffer);
	/*
	charstring scheme,
	charstring diameterId_FQDN,
	UInt16 portField optional,
	SemicolonParam_List	uriParameters optional
	*/

	//"aaa://" FQDN [ port ] [ transport ] [ protocol ]
	switch (id) {
		case id_scheme:
			reg_scheme.AssertMatch (buffer, this);
			SetHypFieldLength (id, reg_scheme.GetMatchedLength());
			break;
		case id_diameterId_FQDN:
			reg_FQHN.AssertMatch (buffer, this);
			SetHypFieldLength (id, reg_FQHN.GetMatchedLength());
			break;
		case id_portField:
			if(reg_sepColon.Match(buffer))
			{
				buffer.SetPosition(buffer.GetPosition() + reg_sepColon.GetMatchedLength());
				reg_portField.AssertMatch (buffer, this);
				Get_portField().SetFormat(Integer::AsciiDecimal);
				SetHypFieldLength (id, reg_portField.GetMatchedLength());
				SetHypFieldIsPresent(id, 1);
			}else
				SetHypFieldIsPresent(id, 0);
			break;
		case id_uriParameters:
			if(reg_sepSemi.Match(buffer))
				SetHypFieldIsPresent(id, 1);
			else
				SetHypFieldIsPresent(id, 0);
			break;
		default:
			break;
	}
}


#define DIAMETER_URI_AVP_COMMON_PreDecodeField(type) \
	void type::PreDecodeField(int field_id, Buffer& buffer) throw (DecodeError)	\
	{	\
		debug_log_PreDecodeField(#type, field_id);	\
		if(field_id == id_aVP_Data)	\
		{	\
			unsigned int nDataLength = getAVPDataLength(Get_aVP_Header()); \
			SetHypFieldLength(id_aVP_Data, nDataLength * 8);	\
		}	\
	}
#define DIAMETER_URI_AVP_COMMON_PostDecode(type) \
	void type::PostDecode(Buffer& buffer) throw (DecodeError)	\
	{	\
			unsigned int nDataLength = getAVPDataLength(Get_aVP_Header()); \
			int nPadding = 0; \
			while(nDataLength%4){	\
				nPadding++;	\
				nDataLength++;	\
			}	\
			buffer.SetPosition(buffer.GetPosition() + nPadding * 8);	\
	}

#define DIAMETER_URI_AVP_SET_COMMON_PreDecode(type) \
	void type::PreDecode(Buffer& buffer) throw (DecodeError)	\
	{	\
		SetHypNextField(id_aVP_Header);	\
	}

#define DIAMETER_URI_AVP_SET_COMMON_PreDecodeField(type) \
	void type::PreDecodeField(Buffer& buffer) throw (DecodeError)	\
	{	\
		if(GetHypNextField() != id_aVP_Header)	\
		{	\
			unsigned int nDataLength = getAVPDataLength(Get_aVP_Header()); \
			SetHypNextField(id_aVP_Data);	\
			SetHypFieldLength(id_aVP_Data, nDataLength * 8);	\
		}	\
	}
#define DIAMETER_URI_AVP_SET_COMMON_PostDecode(type) \
	void type::PostDecode(Buffer& buffer) throw (DecodeError)	\
	{	\
			unsigned int nDataLength = getAVPDataLength(Get_aVP_Header()); \
			int nPadding = 0; \
			while(nDataLength%4){	\
				nPadding++;	\
				nDataLength++;	\
			}	\
			buffer.SetPosition(buffer.GetPosition() + nPadding * 8);	\
	}

/*type record Primary_Event_Charging_Function_Name_AVP{
//Ref: ETSI TS 129 299 Primary_Event_Charging_Function_Name_AVP
    AVP_Header	aVP_Header, //<AVP header: 619 ....>
 	DiameterURI	aVP_Data
};*/
DIAMETER_URI_AVP_COMMON_PreDecodeField(Primary_Event_Charging_Function_Name_AVP)
DIAMETER_URI_AVP_COMMON_PostDecode(Primary_Event_Charging_Function_Name_AVP)

/*type record Secondary_Event_Charging_Function_Name_AVP{
//Ref: ETSI TS 129 299 Secondary_Event_Charging_Function_Name_AVP
    AVP_Header	aVP_Header, //<AVP header: 620 ....>
 	DiameterURI	aVP_Data
};*/
DIAMETER_URI_AVP_COMMON_PreDecodeField(Secondary_Event_Charging_Function_Name_AVP)
DIAMETER_URI_AVP_COMMON_PostDecode(Secondary_Event_Charging_Function_Name_AVP)

/*type record Primary_Charging_Collection_Function_Name_AVP{
//Ref: ETSI TS 129 299 Primary_Charging_Collection_Function_Name_AVP
    AVP_Header						aVP_Header, //<AVP header: 621 ....>
 	DiameterURI aVP_Data
};*/
DIAMETER_URI_AVP_COMMON_PreDecodeField(Primary_Charging_Collection_Function_Name_AVP)
DIAMETER_URI_AVP_COMMON_PostDecode(Primary_Charging_Collection_Function_Name_AVP)

/*type record Secondary_Charging_Collection_Function_Name_AVP{
//Ref: ETSI TS 129 299 Secondary_Charging_Collection_Function_Name_AVP
    AVP_Header	aVP_Header, //<AVP header: 622 ....>
 	DiameterURI aVP_Data
};*/
DIAMETER_URI_AVP_COMMON_PreDecodeField(Secondary_Charging_Collection_Function_Name_AVP)
DIAMETER_URI_AVP_COMMON_PostDecode(Secondary_Charging_Collection_Function_Name_AVP)

/*type  DiameterURI SIP_AOR_Type;// RFC 4740 sec. 9.8
type record SIP_AOR_AVP{
//	Ref: RFC4740 9.8.  SIP-AOR AVP			
	AVP_Header         	aVP_Header,//<AVP header:  ....>
	SIP_AOR_Type		aVP_Data
};*/
DIAMETER_URI_AVP_COMMON_PreDecodeField(SIP_AOR_AVP)
DIAMETER_URI_AVP_COMMON_PostDecode(SIP_AOR_AVP)


//////////////////////////////////////////////////////////
/////////  set instead of Record Grouped AVPs  ///////////
//////////////////////////////////////////////////////////
/*type set SIP_Accounting_Server_URI_AVP{
//Ref: RFC4740 9.1.1.  SIP-Accounting-Server-URI AVP
	AVP_Header         	aVP_Header,//<AVP header: 369 ....>
	DiameterURI 		aVP_Data
};*/
DIAMETER_URI_AVP_SET_COMMON_PreDecode(SIP_Accounting_Server_URI_AVP)
DIAMETER_URI_AVP_SET_COMMON_PreDecodeField(SIP_Accounting_Server_URI_AVP)
DIAMETER_URI_AVP_SET_COMMON_PostDecode(SIP_Accounting_Server_URI_AVP)


/*type set SIP_Credit_Control_Server_URI_AVP{
//Ref: RFC4740 9.1.2.  SIP-Credit-Control-Server-URI AVP
	AVP_Header         	aVP_Header,//<AVP header: 370 ....>
	DiameterURI 		aVP_Data
};*/
DIAMETER_URI_AVP_SET_COMMON_PreDecode(SIP_Credit_Control_Server_URI_AVP)
DIAMETER_URI_AVP_SET_COMMON_PreDecodeField(SIP_Credit_Control_Server_URI_AVP)
DIAMETER_URI_AVP_SET_COMMON_PostDecode(SIP_Credit_Control_Server_URI_AVP)

//////////////////////////////////////////////////////////
///////////////  Octetstring AVPs  //////////////////
//////////////////////////////////////////////////////////

#define OCTETSTRING_AVP_COMMON_PostEncode(type) \
	void type::PostEncode(Buffer& buffer) throw (EncodeError)	\
	{	\
		Unsigned padding(8);	\
		padding.SetValue(0);	\
		int nStrLen = Get_aVP_Data().GetLength()/8;	\
		while(nStrLen%4)	\
		{	\
			nStrLen++;	\
			padding.Encode(buffer);	\
		}	\
	}

#define OCTETSTRING_AVP_COMMON_PreDecodeField(type) \
	void type::PreDecodeField(int field_id, Buffer& buffer) throw (DecodeError)	\
	{	\
		debug_log_PreDecodeField(#type, field_id);	\
		if(field_id == id_aVP_Data)	\
		{	\
			unsigned int nDataLength = getAVPDataLength(Get_aVP_Header()); \
			SetHypFieldLength(id_aVP_Data, nDataLength * 8);	\
		}	\
	}
#define OCTETSTRING_AVP_COMMON_PostDecode(type) \
	void type::PostDecode(Buffer& buffer) throw (DecodeError)	\
	{	\
			unsigned int nDataLength = getAVPDataLength(Get_aVP_Header()); \
			int nPadding = 0; \
			while(nDataLength%4){	\
				nPadding++;	\
				nDataLength++;	\
			}	\
			buffer.SetPosition(buffer.GetPosition() + nPadding * 8);	\
	}

/*type record Access_Network_Charging_Identifier_Value_AVP{
//Ref: ETSI TS 129 214  Access_Network_Charging_Identifier_Value AVP
    AVP_Header			aVP_Header,//<AVP header: 503 ....>
    octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Access_Network_Charging_Identifier_Value_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Access_Network_Charging_Identifier_Value_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Access_Network_Charging_Identifier_Value_AVP)

/*type record Class_AVP{
//Ref: RFC3588 8.20.  Class AVP
	AVP_Header         	aVP_Header,//<AVP header: 25 ....>
	octetstring			aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Class_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Class_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Class_AVP)

/*type record Bearer_Identifier_AVP{
//Ref: ETSI TS 129 212 Bearer_Identifier_AVP
    AVP_Header			aVP_Header,//<AVP header: 1020 ....>
    octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Bearer_Identifier_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Bearer_Identifier_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Bearer_Identifier_AVP)

/*type record Charging_Rule_Name_AVP{
//Ref: ETSI TS 129 212 Charging_Rule_Name_AVP
    AVP_Header			aVP_Header,//<AVP header: 1005 ....>
    octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Charging_Rule_Name_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Charging_Rule_Name_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Charging_Rule_Name_AVP)

/*type record Flow_Label_AVP{
//Ref: ETSI TS 129 212 Flow_Label_AVP
    AVP_Header			aVP_Header,//<AVP header: 1057 ....>
    octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Flow_Label_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Flow_Label_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Flow_Label_AVP)

/*type record Monitoring_Key_AVP{
//Ref: ETSI TS 129 212 Monitoring_Key_AVP
    AVP_Header			aVP_Header,//<AVP header: 1066 ....>
    octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Monitoring_Key_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Monitoring_Key_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Monitoring_Key_AVP)

/*type record Packet_Filter_Identifier_AVP{
//Ref: ETSI TS 129 212 Packet_Filter_Identifier_AVP
    AVP_Header			aVP_Header,//<AVP header: 1060 ....>
    octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Packet_Filter_Identifier_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Packet_Filter_Identifier_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Packet_Filter_Identifier_AVP)

/*type record PDN_Connection_ID_AVP{
//Ref: ETSI TS 129 212 PDN_Connection_ID_AVP
    AVP_Header			aVP_Header,//<AVP header: 1065 ....>
    octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(PDN_Connection_ID_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(PDN_Connection_ID_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(PDN_Connection_ID_AVP)


/*type record Security_Parameter_Index_AVP{
//Ref: ETSI TS 129 212 Security_Parameter_Index_AVP
    AVP_Header			aVP_Header,//<AVP header: 1056 ....>
    octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Security_Parameter_Index_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Security_Parameter_Index_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Security_Parameter_Index_AVP)

/*type record ToS_Traffic_Class_AVP{
//Ref: ETSI TS 129 212 ToS_Traffic_Class_AVP
    AVP_Header			aVP_Header,//<AVP header: 1014 ....>
    octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(ToS_Traffic_Class_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(ToS_Traffic_Class_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(ToS_Traffic_Class_AVP)

/*type record ThreeGPP_RAT_Type_AVP{
//Ref: ETSI TS 129 061 ThreeGPP_RAT_Type_AVP
    AVP_Header			aVP_Header, //<AVP header: 21 ....>
    octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(ThreeGPP_RAT_Type_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(ThreeGPP_RAT_Type_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(ThreeGPP_RAT_Type_AVP)

/*type record ThreeGPP_User_Location_Info_AVP{
//Ref: ETSI TS 129 061 ThreeGPP_User_Location_Info_AVP
    AVP_Header			aVP_Header, //<AVP header: 22 ....>
    octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(ThreeGPP_User_Location_Info_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(ThreeGPP_User_Location_Info_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(ThreeGPP_User_Location_Info_AVP)

/*type record ThreeGPP_MS_TimeZone_AVP{
//Ref: ETSI TS 129 061 ThreeGPP_MS_TimeZone_AVP
    AVP_Header			aVP_Header, //<AVP header: 23 ....>
    octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(ThreeGPP_MS_TimeZone_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(ThreeGPP_MS_TimeZone_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(ThreeGPP_MS_TimeZone_AVP)

/*type record Trace_Reference_AVP{
//Ref: ETSI TS129 272 Trace_Reference_AVP
    AVP_Header			aVP_Header, //<AVP header: 1459 ....>
	octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Trace_Reference_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Trace_Reference_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Trace_Reference_AVP)

/*type record Trace_NE_Type_List_AVP{
//Ref: ETSI TS129 272 Trace_NE_Type_List_AVP
    AVP_Header			aVP_Header, //<AVP header: 1463 ....>
	octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Trace_NE_Type_List_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Trace_NE_Type_List_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Trace_NE_Type_List_AVP)

/*type record Trace_Interface_List_AVP{
//Ref: ETSI TS129 272 Trace_Interface_List_AVP
    AVP_Header			aVP_Header, //<AVP header: 1464 ....>
	octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Trace_Interface_List_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Trace_Interface_List_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Trace_Interface_List_AVP)

/*type record Trace_Event_List_AVP{
//Ref: ETSI TS129 272 Trace_Event_List_AVP
    AVP_Header			aVP_Header, //<AVP header: 1465 ....>
	octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Trace_Event_List_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Trace_Event_List_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Trace_Event_List_AVP)

/*type record OMC_Id_AVP{
//Ref: ETSI TS129 272 OMC_Id_AVP
    AVP_Header			aVP_Header, //<AVP header: 1466 ....>
	octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(OMC_Id_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(OMC_Id_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(OMC_Id_AVP)

/*type record Cell_Global_Identity_AVP{
//Ref: ETSI TS129 272 Cell_Global_Identity_AVP
    AVP_Header			aVP_Header, //<AVP header: 1604 ....>
	octetstring			aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Cell_Global_Identity_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Cell_Global_Identity_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Cell_Global_Identity_AVP)

/*type record E_UTRAN_Cell_Global_Identity_AVP{
//Ref: ETSI TS129 272 E_UTRAN_Cell_Global_Identity_AVP
    AVP_Header			aVP_Header, //<AVP header: 1602 ....>
	octetstring			aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(E_UTRAN_Cell_Global_Identity_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(E_UTRAN_Cell_Global_Identity_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(E_UTRAN_Cell_Global_Identity_AVP)

/*type record Routing_Area_Identity_AVP{
//Ref: ETSI TS129 272 Routing_Area_Identity_AVP
    AVP_Header			aVP_Header, //<AVP header: 1605 ....>
	octetstring			aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Routing_Area_Identity_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Routing_Area_Identity_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Routing_Area_Identity_AVP)

/*type record Location_Area_Identity_AVP{
//Ref: ETSI TS129 272 Location_Area_Identity_AVP
    AVP_Header			aVP_Header, //<AVP header: 1606 ....>
	octetstring			aVP_Data	
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Location_Area_Identity_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Location_Area_Identity_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Location_Area_Identity_AVP)

/*type record Tracking_Area_Identity_AVP{
//Ref: ETSI TS129 272 Tracking_Area_Identity_AVP
    AVP_Header			aVP_Header, //<AVP header: 1603 ....>
	octetstring			aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Tracking_Area_Identity_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Tracking_Area_Identity_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Tracking_Area_Identity_AVP)

/*type record ThreeGPP_SGSN_Address_AVP{
//Ref: ETSI TS 129 061 3GPP_SGSN_Address
    AVP_Header			aVP_Header, //<AVP header: 6 ....>
    octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(ThreeGPP_SGSN_Address_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(ThreeGPP_SGSN_Address_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(ThreeGPP_SGSN_Address_AVP)

/*type record ThreeGPP_SGSN_IPv6_Address_AVP{
//Ref: ETSI TS 129 061 3GPP_SGSN_Address
    AVP_Header			aVP_Header, //<AVP header: 15 ....>
    octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(ThreeGPP_SGSN_IPv6_Address_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(ThreeGPP_SGSN_IPv6_Address_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(ThreeGPP_SGSN_IPv6_Address_AVP)

/*type record AF_Application_Identifier_AVP{
//Ref: ETSI TS 129 214 AF_Application_Identifier AVP
    AVP_Header			aVP_Header,//<AVP header: 504 ....>
    octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(AF_Application_Identifier_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(AF_Application_Identifier_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(AF_Application_Identifier_AVP)

/*type record AF_Charging_Identifier_AVP{
//Ref: ETSI TS 129 214 AF_Charging_Identifier AVP
    AVP_Header			aVP_Header,//<AVP header: 505 ....>
    octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(AF_Charging_Identifier_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(AF_Charging_Identifier_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(AF_Charging_Identifier_AVP)

/*type record Codec_Data_AVP{
//Ref: ETSI TS 129 214 Codec_data AVP
    AVP_Header			aVP_Header,//<AVP header: 524 ....>
    octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Codec_Data_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Codec_Data_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Codec_Data_AVP)

/*type record Service_URN_AVP{
//Ref: ETSI TS 129 214 Service_URN AVP
    AVP_Header			aVP_Header,//<AVP header: 525 ....>
    octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Service_URN_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Service_URN_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Service_URN_AVP)

/*type record Proxy_State_AVP{
//Ref: RFC3588 6.7.4.  Proxy-State AVP
	AVP_Header         	aVP_Header,//<AVP header: 33 ....>
	octetstring			aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Proxy_State_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Proxy_State_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Proxy_State_AVP)

//TODO: incorrectly named, actual name is Accounting_Session_Id
/*type record Acct_Session_Id_AVP{
//Ref: RFC3588 9.8.4.  Acct-Session-Id AVP 			
	AVP_Header         	aVP_Header,//<AVP header: 44 ....>
	octetstring			aVP_Data			
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Acct_Session_Id_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Acct_Session_Id_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Acct_Session_Id_AVP)

/*type record Framed_IP_Address_AVP{
//  Ref: RFC4005 6.11.1 Framed_IP_Address AVP
    AVP_Header         			aVP_Header,//<AVP header: 8 ....>	
    octetstring                 aVP_Data		
}*/
OCTETSTRING_AVP_COMMON_PostEncode(Framed_IP_Address_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Framed_IP_Address_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Framed_IP_Address_AVP)

/*type record Framed_IPv6_Prefix_AVP{
//  Ref: RFC4005 6.11.1 Framed_IPv6_Prefix AVP
    AVP_Header         			aVP_Header,//<AVP header: 97 ....>	
    octetstring                 aVP_Data		
}*/
OCTETSTRING_AVP_COMMON_PostEncode(Framed_IPv6_Prefix_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Framed_IPv6_Prefix_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Framed_IPv6_Prefix_AVP)

/*type record Logical_Access_ID_AVP{
//Ref: Draft TS283_034 Logical_Access_ID_AVP
    AVP_Header			aVP_Header, //<AVP header: 302 ....>
    octetstring     		aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Logical_Access_ID_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Logical_Access_ID_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Logical_Access_ID_AVP)

/*type record Routing_Rule_Identifier_AVP{
//Ref: ETSI TS 129 212 Routing_Rule_Identifier_AVP
    AVP_Header			aVP_Header,//<AVP header: 1077 ....>
    octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Routing_Rule_Identifier_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Routing_Rule_Identifier_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Routing_Rule_Identifier_AVP)

/*type record SIP_User_Data_Contents_AVP{
// Ref: RFC4740 9.12.2.  SIP-User-Data-Contents AVP
	AVP_Header         	aVP_Header,//<AVP header: 391 ....>
	octetstring 		aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(SIP_User_Data_Contents_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(SIP_User_Data_Contents_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(SIP_User_Data_Contents_AVP)

/*type record MSISDN_AVP{
//	Ref: 3GPP TS 29.329	6.3.2 MSISDN AVP			
	AVP_Header         			aVP_Header,//<AVP header: 701 ....>
	octetstring					aVP_Data							
};*/
OCTETSTRING_AVP_COMMON_PostEncode(MSISDN_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(MSISDN_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(MSISDN_AVP)

/*type record Service_Indication_AVP{
//	Ref: 3GPP TS 29.329	6.3.5 Service-Indication AVP			
	AVP_Header         			aVP_Header,//<AVP header: 704 ....>
	octetstring					aVP_Data							
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Service_Indication_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Service_Indication_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Service_Indication_AVP)

/*type record DSAI_Tag_AVP{
//	Ref: 3GPP TS 29.329	6.3.18 DSAI-Tag AVP
	AVP_Header         			aVP_Header,//<AVP header: 711 ....>
	octetstring				  	aVP_Data										
};*/
OCTETSTRING_AVP_COMMON_PostEncode(DSAI_Tag_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(DSAI_Tag_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(DSAI_Tag_AVP)

/*type record User_Data_AVP{
//	Ref: 3GPP TS 29.229	6.3.7 User-Data AVP			
//	Ref:
	AVP_Header         			aVP_Header,//<AVP header: 606 ....>
	octetstring					aVP_Data							
};*/
OCTETSTRING_AVP_COMMON_PostEncode(User_Data_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(User_Data_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(User_Data_AVP)

/*type record Service_Parameter_Value_AVP{
//	Ref: RFC4006 8.45.  Service-Parameter-Value AVP
	AVP_Header         			aVP_Header,//< AVP Header: 442 >
	octetstring					aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(Service_Parameter_Value_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(Service_Parameter_Value_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(Service_Parameter_Value_AVP)

/*type record CC_Correlation_Id_AVP{
//	Ref: RFC4006 8.1.  CC-Correlation-Id AVP
	AVP_Header         			aVP_Header,//< AVP Header: 411 >
	octetstring					aVP_Data							
};*/
OCTETSTRING_AVP_COMMON_PostEncode(CC_Correlation_Id_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(CC_Correlation_Id_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(CC_Correlation_Id_AVP)

/*type record User_Equipment_Info_Value_AVP{
//	Ref: RFC4006 8.51.  User-Equipment-Info-Value AVP
	AVP_Header         			aVP_Header,//< AVP Header: 460 >
	octetstring					aVP_Data				
};*/
OCTETSTRING_AVP_COMMON_PostEncode(User_Equipment_Info_Value_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(User_Equipment_Info_Value_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(User_Equipment_Info_Value_AVP)

/*type record MPS_Identifier_AVP{
//Ref: ETSI TS 129 214 MPS_Identifier AVP
    AVP_Header			aVP_Header,//<AVP header: 528 ....>
    octetstring        	aVP_Data
};*/
OCTETSTRING_AVP_COMMON_PostEncode(MPS_Identifier_AVP)
OCTETSTRING_AVP_COMMON_PreDecodeField(MPS_Identifier_AVP)
OCTETSTRING_AVP_COMMON_PostDecode(MPS_Identifier_AVP)


//////////////////////////////////////////////////////////
///////////////  UTF8String AVPs  ////////////////////////
//////////////////////////////////////////////////////////

#define UTF8STRING_AVP_COMMON_PostEncode(type) \
	void type::PostEncode(Buffer& buffer) throw (EncodeError)	\
	{	\
		Unsigned padding(8);	\
		padding.SetValue(0);	\
		int nStrLen = Get_aVP_Data().GetLength()/8;	\
		while(nStrLen%4)	\
		{	\
			nStrLen++;	\
			padding.Encode(buffer);	\
		}	\
	}

#define UTF8STRING_AVP_COMMON_PreDecodeField(type) \
	void type::PreDecodeField(int field_id, Buffer& buffer) throw (DecodeError)	\
	{	\
		debug_log_PreDecodeField(#type, field_id);	\
		if(field_id == id_aVP_Data)	\
		{	\
			unsigned int nDataLength = getAVPDataLength(Get_aVP_Header()); \
			SetHypFieldLength(id_aVP_Data, nDataLength * 8);	\
		}	\
	}
#define UTF8STRING_AVP_COMMON_PostDecode(type) \
	void type::PostDecode(Buffer& buffer) throw (DecodeError)	\
	{	\
			unsigned int nDataLength = getAVPDataLength(Get_aVP_Header()); \
			int nPadding = 0; \
			while(nDataLength%4){	\
				nPadding++;	\
				nDataLength++;	\
			}	\
			buffer.SetPosition(buffer.GetPosition() + nPadding * 8);	\
	}

//RFC 3588

/*type record Acct_Multi_Session_Id_AVP{
//Ref: RFC3588 9.8.5.  Acct-Multi-Session-Id AVP
	AVP_Header         	aVP_Header,//<AVP header: 50 ....>
	UTF8String 			aVP_Data			
};*/
UTF8STRING_AVP_COMMON_PostEncode(Acct_Multi_Session_Id_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(Acct_Multi_Session_Id_AVP)
UTF8STRING_AVP_COMMON_PostDecode(Acct_Multi_Session_Id_AVP)

/*type record Error_Message_AVP{
//Ref: RFC3588 7.3.  Error-Message AVP
	AVP_Header         	aVP_Header,//<AVP header: 281 ....>
	UTF8String			aVP_Data						
};*/
UTF8STRING_AVP_COMMON_PostEncode(Error_Message_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(Error_Message_AVP)
UTF8STRING_AVP_COMMON_PostDecode(Error_Message_AVP)

/*type record Product_Name_AVP{
//Ref: RFC3588 5.3.7.  Product-Name AVP
	AVP_Header         	aVP_Header,//<AVP header: 269 ....>
	UTF8String			aVP_Data							
};*/
UTF8STRING_AVP_COMMON_PostEncode(Product_Name_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(Product_Name_AVP)
UTF8STRING_AVP_COMMON_PostDecode(Product_Name_AVP)

/*type record Session_Id_AVP{
//Ref: RFC3588 8.8.  Session-Id AVP
	AVP_Header         	aVP_Header,//<AVP header: 263 ....>
	UTF8String 			aVP_Data						
};*/
UTF8STRING_AVP_COMMON_PostEncode(Session_Id_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(Session_Id_AVP)
UTF8STRING_AVP_COMMON_PostDecode(Session_Id_AVP)

/*type record User_Name_AVP{
//Ref: RFC3588 8.14.  User-Name AVP						
	AVP_Header         	aVP_Header,//<AVP header: 1 ....>
	UTF8String 			aVP_Data
};*/
UTF8STRING_AVP_COMMON_PostEncode(User_Name_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(User_Name_AVP)
UTF8STRING_AVP_COMMON_PostDecode(User_Name_AVP)

//RFC 4740
/*type record SIP_Server_URI_AVP{
//	Ref: RFC4740 9.2 SIP-Server-URI AVP
	AVP_Header         	aVP_Header,//<AVP header: 371 ....>
	UTF8String			aVP_Data
};*/
UTF8STRING_AVP_COMMON_PostEncode(SIP_Server_URI_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(SIP_Server_URI_AVP)
UTF8STRING_AVP_COMMON_PostDecode(SIP_Server_URI_AVP)

/*type record SIP_Reason_Info_AVP{ 
	//Ref: RFC4740 9.7.2.  SIP-Reason-Info AVP
	AVP_Header         			aVP_Header,//<AVP header: 385 ....>
	UTF8String					aVP_Data
};*/
UTF8STRING_AVP_COMMON_PostEncode(SIP_Reason_Info_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(SIP_Reason_Info_AVP)
UTF8STRING_AVP_COMMON_PostDecode(SIP_Reason_Info_AVP)

/*type record SIP_Visited_Network_Id_AVP{
//	Ref: RFC4740 9.9.  SIP-Visited-Network-Id AVP			
	AVP_Header         	aVP_Header,//<AVP header: 386 ....>
	UTF8String			aVP_Data
};*/
UTF8STRING_AVP_COMMON_PostEncode(SIP_Visited_Network_Id_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(SIP_Visited_Network_Id_AVP)
UTF8STRING_AVP_COMMON_PostDecode(SIP_Visited_Network_Id_AVP)

/*type record SIP_Supported_User_Data_Type_AVP{
//Ref: RFC4740 9.12.1.  SIP-User-Data-Type AVP
	AVP_Header         	aVP_Header,//<AVP header: 388 ....>
	UTF8String			aVP_Data
};*/
UTF8STRING_AVP_COMMON_PostEncode(SIP_Supported_User_Data_Type_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(SIP_Supported_User_Data_Type_AVP)
UTF8STRING_AVP_COMMON_PostDecode(SIP_Supported_User_Data_Type_AVP)

/*type record SIP_User_Data_Type_AVP{
// Ref: RFC4740 9.12.1.  SIP-User-Data-Type AVP
	AVP_Header         	aVP_Header,//<AVP header: 390 ....>
	UTF8String			aVP_Data
};*/
UTF8STRING_AVP_COMMON_PostEncode(SIP_User_Data_Type_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(SIP_User_Data_Type_AVP)
UTF8STRING_AVP_COMMON_PostDecode(SIP_User_Data_Type_AVP)

/*type record SIP_Method_AVP{
//Ref: RFC4740 9.14.  SIP-Method AVP
	AVP_Header         	aVP_Header,//<AVP header: 393 ....>
	UTF8String			aVP_Data
};*/
UTF8STRING_AVP_COMMON_PostEncode(SIP_Method_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(SIP_Method_AVP)
UTF8STRING_AVP_COMMON_PostDecode(SIP_Method_AVP)

//From 129.214

/*type record Application_Service_Provider_Identity_AVP{
//Ref: ETSI TS 129 214 Application_Service_Provider_Identity AVP
    AVP_Header			aVP_Header,//<AVP header: 532 ....>
    UTF8String        	aVP_Data
}; */
UTF8STRING_AVP_COMMON_PostEncode(Application_Service_Provider_Identity_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(Application_Service_Provider_Identity_AVP)
UTF8STRING_AVP_COMMON_PostDecode(Application_Service_Provider_Identity_AVP)

/*type record Sponsor_Identity_AVP{
 //Ref: ETSI TS 129 214 Sponsor_Identity AVP
     AVP_Header			aVP_Header,//<AVP header: 531 ....>
     UTF8String     	aVP_Data
 };*/
UTF8STRING_AVP_COMMON_PostEncode(Sponsor_Identity_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(Sponsor_Identity_AVP)
UTF8STRING_AVP_COMMON_PostDecode(Sponsor_Identity_AVP)


//From RFC 4006
/*type record Subscription_Id_Data_AVP{
//	Ref: RFC4006 
	AVP_Header         			aVP_Header,//<AVP header: 444 ....>
	UTF8String                  aVP_Data							
};*/
UTF8STRING_AVP_COMMON_PostEncode(Subscription_Id_Data_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(Subscription_Id_Data_AVP)
UTF8STRING_AVP_COMMON_PostDecode(Subscription_Id_Data_AVP)


/*type record RAI_AVP{
//Ref: ETSI TS 129 061 RAI_AVP
    AVP_Header			aVP_Header, //<AVP header: 909 ....>
    UTF8String     		aVP_Data
};*/
UTF8STRING_AVP_COMMON_PostEncode(RAI_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(RAI_AVP)
UTF8STRING_AVP_COMMON_PostDecode(RAI_AVP)

/*type record ThreeGPP2_BSID_AVP{
//Ref: Draft X.S0057-1 ThreeGPP2_BSID_AVP
    AVP_Header			aVP_Header, //<AVP header: 5535 ....>
    UTF8String     		aVP_Data
};*/
UTF8STRING_AVP_COMMON_PostEncode(ThreeGPP2_BSID_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(ThreeGPP2_BSID_AVP)
UTF8STRING_AVP_COMMON_PostDecode(ThreeGPP2_BSID_AVP)

/*type record Charging_Rule_Base_Name_AVP {
 //Ref: ETSI TS 129 212 Charging_Rule_Base_Name_AVP  AVP
	AVP_Header			aVP_Header,//<AVP header: 1004 ....>
    UTF8String     		aVP_Data
 };*/
UTF8STRING_AVP_COMMON_PostEncode(Charging_Rule_Base_Name_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(Charging_Rule_Base_Name_AVP)
UTF8STRING_AVP_COMMON_PostDecode(Charging_Rule_Base_Name_AVP)

/*type record ThreeGPP_SGSN_MCC_MNC_AVP{
//Ref: ETSI TS 129 061 ThreeGPP_SGSN_MCC_MNC_AVP
    AVP_Header			aVP_Header, //<AVP header: 18 ....>
    UTF8String        	aVP_Data
};*/
UTF8STRING_AVP_COMMON_PostEncode(ThreeGPP_SGSN_MCC_MNC_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(ThreeGPP_SGSN_MCC_MNC_AVP)
UTF8STRING_AVP_COMMON_PostDecode(ThreeGPP_SGSN_MCC_MNC_AVP)

/*type record Physical_Access_ID_AVP{
//Ref: Draft TS283_034 Physical_Access_ID_AVP
    AVP_Header			aVP_Header, //<AVP header: 313 ....>
    UTF8String     		aVP_Data
};*/
UTF8STRING_AVP_COMMON_PostEncode(Physical_Access_ID_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(Physical_Access_ID_AVP)
UTF8STRING_AVP_COMMON_PostDecode(Physical_Access_ID_AVP)

/*type record Public_Identity_AVP{
//	Ref: 3GPP TS 29.329	6.3.15 Public-Identity AVP
//  3GPP TS 29.229 6.3.2 Public-Identity AVP			
	AVP_Header         			aVP_Header,//<AVP header: 601 ....>
	UTF8String					aVP_Data							
};*/
UTF8STRING_AVP_COMMON_PostEncode(Public_Identity_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(Public_Identity_AVP)
UTF8STRING_AVP_COMMON_PostDecode(Public_Identity_AVP)


/*type record Server_Name_AVP{
//	Ref: 3GPP TS 29.329	6.3.9 Server-Name AVP	
	AVP_Header         			aVP_Header,//<AVP header: 602 ....>	
	UTF8String				  	aVP_Data						
};*/
UTF8STRING_AVP_COMMON_PostEncode(Server_Name_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(Server_Name_AVP)
UTF8STRING_AVP_COMMON_PostDecode(Server_Name_AVP)

/*type record Wildcarded_PSI_AVP{
//	Ref: 3GPP TS 29.329	6.3.19 Wildcarded-PSI AVP , 3GPP TS 29.229	
	AVP_Header         			aVP_Header,//<AVP header: 634 ....>
	UTF8String				  	aVP_Data										
};*/
UTF8STRING_AVP_COMMON_PostEncode(Wildcarded_PSI_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(Wildcarded_PSI_AVP)
UTF8STRING_AVP_COMMON_PostDecode(Wildcarded_PSI_AVP)

/*type record Wildcarded_IMPU_AVP{
//	Ref: 3GPP TS 29.329	6.3.20 Wildcarded-IMPU AVP , 3GPP TS 29.229	
	AVP_Header         			aVP_Header,//<AVP header: 636 ....>
	UTF8String				  	aVP_Data										
};*/
UTF8STRING_AVP_COMMON_PostEncode(Wildcarded_IMPU_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(Wildcarded_IMPU_AVP)
UTF8STRING_AVP_COMMON_PostDecode(Wildcarded_IMPU_AVP)

/*type record Called_Station_Id_AVP{
//  Ref: RFC4005 4.5  Called_Station_Id AVP
    AVP_Header         			aVP_Header,//<AVP header: 30 ....>	
    UTF8String                  aVP_Data		
}*/
UTF8STRING_AVP_COMMON_PostEncode(Called_Station_Id_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(Called_Station_Id_AVP)
UTF8STRING_AVP_COMMON_PostDecode(Called_Station_Id_AVP)

/*type record Service_Context_Id_AVP{			
//	Ref: RFC4006 8.42.  Service-Context-Id AVP
	AVP_Header         			aVP_Header,//<AVP header: 461 ....>	
	UTF8String                  aVP_Data		
};*/
UTF8STRING_AVP_COMMON_PostEncode(Service_Context_Id_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(Service_Context_Id_AVP)
UTF8STRING_AVP_COMMON_PostDecode(Service_Context_Id_AVP)

/*type record Filter_Id_AVP{
//	Ref: RFC4005 6.7.  Filter-Id AVP
	AVP_Header         			aVP_Header,//< AVP Header: 11 >
	UTF8String                  aVP_Data							
};*/
UTF8STRING_AVP_COMMON_PostEncode(Filter_Id_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(Filter_Id_AVP)
UTF8STRING_AVP_COMMON_PostDecode(Filter_Id_AVP)

/*type record Redirect_Server_Address_AVP{
//	Ref: RFC4006 8.39.  Redirect-Server-Address AVP			
	AVP_Header         			aVP_Header,//< AVP Header: 435 >
	UTF8String					aVP_Data
};*/
UTF8STRING_AVP_COMMON_PostEncode(Redirect_Server_Address_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(Redirect_Server_Address_AVP)
UTF8STRING_AVP_COMMON_PostDecode(Redirect_Server_Address_AVP)

/*type record Cost_Unit_AVP{
//	Ref: RFC4006 8.12.  Cost-Unit AVP
	AVP_Header         			aVP_Header,//< AVP Header: 424 >
	UTF8String					aVP_Data
};*/
UTF8STRING_AVP_COMMON_PostEncode(Cost_Unit_AVP)
UTF8STRING_AVP_COMMON_PreDecodeField(Cost_Unit_AVP)
UTF8STRING_AVP_COMMON_PostDecode(Cost_Unit_AVP)



////////////////////////////////////////////////////////
////////////////  SPECIAL AVPs  ////////////////////////
////////////////////////////////////////////////////////
#define SPECIAL_AVP_COMMON_PostEncode(type) \
	void type::PostEncode(Buffer& buffer) throw (EncodeError)	\
	{	\
		Unsigned padding(8);	\
		padding.SetValue(0);	\
		int nStrLen = Get_Text().GetLength()/8;	\
		while(nStrLen%4)	\
		{	\
			nStrLen++;	\
			padding.Encode(buffer);	\
		}	\
	}

#define SPECIAL_AVP_COMMON_PreDecodeField(type) \
	void type::PreDecodeField(int field_id, Buffer& buffer) throw (DecodeError)	\
	{	\
		debug_log_PreDecodeField(#type, field_id);	\
		if(field_id == id_Text)	\
		{	\
			unsigned int nDataLength = getAVPDataLength(Get_aVP_Header()); \
			SetHypFieldLength(id_Text, nDataLength * 8);	\
		}	\
	}
#define SPECIAL_AVP_COMMON_PostDecode(type) \
	void type::PostDecode(Buffer& buffer) throw (DecodeError)	\
	{	\
			unsigned int nDataLength = getAVPDataLength(Get_aVP_Header()); \
			int nPadding = 0; \
			while(nDataLength%4){	\
				nPadding++;	\
				nDataLength++;	\
			}	\
			buffer.SetPosition(buffer.GetPosition() + nPadding * 8);	\
	}
/*type record Digest_Realm_AVP{
	//Ref:RFC4590 3.2.  Digest-Realm Attribute
	Digest_Ty_Type 	Type,//104
	UInt8  			Length, 
	UTF8String		Text
};*/
SPECIAL_AVP_COMMON_PostEncode(Digest_Realm_AVP)
SPECIAL_AVP_COMMON_PreDecodeField(Digest_Realm_AVP)
SPECIAL_AVP_COMMON_PostDecode(Digest_Realm_AVP)

/*type record Digest_Nonce_AVP{
//Ref:RFC4590 3.3.  Digest-Nonce Attribute
	Digest_Ty_Type 	Type,//105
	UInt8  			Length, 
	UTF8String		Text
};*/
SPECIAL_AVP_COMMON_PostEncode(Digest_Nonce_AVP)
SPECIAL_AVP_COMMON_PreDecodeField(Digest_Nonce_AVP)
SPECIAL_AVP_COMMON_PostDecode(Digest_Nonce_AVP)

/*type record Digest_Domain_AVP{
//Ref:RFC4590 3.17.  Digest-Domain Attribute
	Digest_Ty_Type 	Type,//119
	UInt8  			Length, 
	UTF8String		Text
};*/
SPECIAL_AVP_COMMON_PostEncode(Digest_Domain_AVP)
SPECIAL_AVP_COMMON_PreDecodeField(Digest_Domain_AVP)
SPECIAL_AVP_COMMON_PostDecode(Digest_Domain_AVP)

/*type record Digest_Opaque_AVP{
//Ref:RFC4590 3.14.  Digest-Opaque Attribute
	Digest_Ty_Type 	Type,//116
	UInt8  			Length, 
	UTF8String		Text
};*/
SPECIAL_AVP_COMMON_PostEncode(Digest_Opaque_AVP)
SPECIAL_AVP_COMMON_PreDecodeField(Digest_Opaque_AVP)
SPECIAL_AVP_COMMON_PostDecode(Digest_Opaque_AVP)

/*type record Digest_Stale_AVP{
//Ref:RFC4590 3.18.  Digest-Stale Attribute
	Digest_Ty_Type 	Type,//120
	UInt8  			Length, 
	UTF8String		Text
};*/
SPECIAL_AVP_COMMON_PostEncode(Digest_Stale_AVP)
SPECIAL_AVP_COMMON_PreDecodeField(Digest_Stale_AVP)
SPECIAL_AVP_COMMON_PostDecode(Digest_Stale_AVP)

/*type record Digest_Algorithm_AVP{
//Ref:RFC4590 3.9.  Digest-Algorithm Attribute
	Digest_Ty_Type 	Type,//111
	UInt8  			Length, 
	UTF8String		Text
};*/
SPECIAL_AVP_COMMON_PostEncode(Digest_Algorithm_AVP)
SPECIAL_AVP_COMMON_PreDecodeField(Digest_Algorithm_AVP)
SPECIAL_AVP_COMMON_PostDecode(Digest_Algorithm_AVP)

/*type record Digest_QoP_AVP{
//Ref:RFC4590 3.8.  Digest-Qop Attribute
	Digest_Ty_Type 	Type, //110
	UInt8  			Length, 
	UTF8String		Text
};*/
SPECIAL_AVP_COMMON_PostEncode(Digest_QoP_AVP)
SPECIAL_AVP_COMMON_PreDecodeField(Digest_QoP_AVP)
SPECIAL_AVP_COMMON_PostDecode(Digest_QoP_AVP)

/*type record Digest_HA1_AVP{
	//Ref:RFC4590 3.19.  Digest-HA1 Attribute
	Digest_Ty_Type 	Type,//121
	UInt8  			Length, 
	UTF8String		Text
};*/
SPECIAL_AVP_COMMON_PostEncode(Digest_HA1_AVP)
SPECIAL_AVP_COMMON_PreDecodeField(Digest_HA1_AVP)
SPECIAL_AVP_COMMON_PostDecode(Digest_HA1_AVP)

/*type record Digest_Auth_Param_AVP{
//Ref:RFC4590 3.15.  Digest-Auth-Param Attribute
	Digest_Ty_Type 	Type,//117
	UInt8  			Length, 
	UTF8String		Text
};*/
SPECIAL_AVP_COMMON_PostEncode(Digest_Auth_Param_AVP)
SPECIAL_AVP_COMMON_PreDecodeField(Digest_Auth_Param_AVP)
SPECIAL_AVP_COMMON_PostDecode(Digest_Auth_Param_AVP)

/*type record Digest_Username_AVP{
//Ref:RFC4590 3.13.  Digest-Username Attribute
	Digest_Ty_Type 	Type, //115
	UInt8  			Length, 
	UTF8String		Text
};*/
SPECIAL_AVP_COMMON_PostEncode(Digest_Username_AVP)
SPECIAL_AVP_COMMON_PreDecodeField(Digest_Username_AVP)
SPECIAL_AVP_COMMON_PostDecode(Digest_Username_AVP)

/*type record Digest_URI_AVP{
//Ref:RFC4590 3.7.  Digest-URI Attribute
	Digest_Ty_Type 	Type, //109
	UInt8  			Length, 
	UTF8String		Text
};*/
SPECIAL_AVP_COMMON_PostEncode(Digest_URI_AVP)
SPECIAL_AVP_COMMON_PreDecodeField(Digest_URI_AVP)
SPECIAL_AVP_COMMON_PostDecode(Digest_URI_AVP)

/*type record Digest_Response_AVP{
//Ref:RFC4590 
	Digest_Ty_Type 	Type,//103
	UInt8  			Length, 
	UTF8String		Text
};*/
SPECIAL_AVP_COMMON_PostEncode(Digest_Response_AVP)
SPECIAL_AVP_COMMON_PreDecodeField(Digest_Response_AVP)
SPECIAL_AVP_COMMON_PostDecode(Digest_Response_AVP)

/*type record Digest_CNonce_AVP{
//Ref:RFC4590 3.11.  Digest-CNonce Attribute
	Digest_Ty_Type 	Type, //113
	UInt8  			Length, 
	UTF8String		Text
};*/
SPECIAL_AVP_COMMON_PostEncode(Digest_CNonce_AVP)
SPECIAL_AVP_COMMON_PreDecodeField(Digest_CNonce_AVP)
SPECIAL_AVP_COMMON_PostDecode(Digest_CNonce_AVP)

/*type record Digest_Nonce_Count_AVP{
//Ref:RFC4590 3.12.  Digest-Nonce-Count Attribute
	Digest_Ty_Type 	Type,//114
	UInt8  			Length, 
	UTF8String		Text
};*/
SPECIAL_AVP_COMMON_PostEncode(Digest_Nonce_Count_AVP)
SPECIAL_AVP_COMMON_PreDecodeField(Digest_Nonce_Count_AVP)
SPECIAL_AVP_COMMON_PostDecode(Digest_Nonce_Count_AVP)

/*type record Digest_Method_AVP{
//Ref:RFC4590 3.6.  Digest-Method Attribute
	Digest_Ty_Type 	Type, //108
	UInt8  			Length, 
	UTF8String		Text
};*/
SPECIAL_AVP_COMMON_PostEncode(Digest_Method_AVP)
SPECIAL_AVP_COMMON_PreDecodeField(Digest_Method_AVP)
SPECIAL_AVP_COMMON_PostDecode(Digest_Method_AVP)

/*type record Digest_Entity_Body_Hash_AVP{
//Ref:RFC4590 3.10.  Digest-Entity-Body-Hash Attribute
	Digest_Ty_Type 	Type,//112
	UInt8  			Length, 
	UTF8String		Text
};*/
SPECIAL_AVP_COMMON_PostEncode(Digest_Entity_Body_Hash_AVP)
SPECIAL_AVP_COMMON_PreDecodeField(Digest_Entity_Body_Hash_AVP)
SPECIAL_AVP_COMMON_PostDecode(Digest_Entity_Body_Hash_AVP)

/*type record Digest_Nextnonce_AVP{
//Ref:RFC4590 
	Digest_Ty_Type 	Type,//107
	UInt8  			Length, 
	UTF8String		Text
};*/
SPECIAL_AVP_COMMON_PostEncode(Digest_Nextnonce_AVP)
SPECIAL_AVP_COMMON_PreDecodeField(Digest_Nextnonce_AVP)
SPECIAL_AVP_COMMON_PostDecode(Digest_Nextnonce_AVP)

/*type record Digest_Response_Auth_AVP{
//Ref:RFC4590 
	Digest_Ty_Type 	Type,//106
	UInt8  			Length, 
	UTF8String		Text
};*/
SPECIAL_AVP_COMMON_PostEncode(Digest_Response_Auth_AVP)
SPECIAL_AVP_COMMON_PreDecodeField(Digest_Response_Auth_AVP)
SPECIAL_AVP_COMMON_PostDecode(Digest_Response_Auth_AVP)

//////////////////////////////////////////////////////////
///////////////  DiameterIdentity AVPs  //////////////////
//////////////////////////////////////////////////////////

//type charstring Diameter_Identity;
#define DIAMETER_IDENTITY_AVP_COMMON_PostEncode(type) \
	void type::PostEncode(Buffer& buffer) throw (EncodeError)	\
	{	\
		Unsigned padding(8);	\
		padding.SetValue(0);	\
		int nStrLen = Get_aVP_Data().GetLength()/8;	\
		while(nStrLen%4)	\
		{	\
			nStrLen++;	\
			padding.Encode(buffer);	\
		}	\
	}
#define DIAMETER_IDENTITY_AVP_COMMON_PreDecodeField(type) \
	void type::PreDecodeField(int field_id, Buffer& buffer) throw (DecodeError)	\
	{	\
		debug_log_PreDecodeField(#type, field_id);	\
		if(field_id == id_aVP_Data)	\
		{	\
			unsigned int nDataLength = getAVPDataLength(Get_aVP_Header()); \
			SetHypFieldLength(id_aVP_Data, nDataLength * 8);	\
		}	\
	}

#define DIAMETER_IDENTITY_AVP_COMMON_PostDecode(type) \
	void type::PostDecode(Buffer& buffer) throw (DecodeError)	\
	{	\
			unsigned int nDataLength = getAVPDataLength(Get_aVP_Header()); \
			int nPadding = 0; \
			while(nDataLength%4){	\
				nPadding++;	\
				nDataLength++;	\
			}	\
			buffer.SetPosition(buffer.GetPosition() + nPadding * 8);	\
	}

/*type record Origin_Host_AVP{
//Ref: RFC3588 6.3.  Origin-Host AVP
	AVP_Header			aVP_Header,//<AVP header: 264 ....>
	Diameter_Identity  	aVP_Data			
};*/
DIAMETER_IDENTITY_AVP_COMMON_PostEncode(Origin_Host_AVP)
DIAMETER_IDENTITY_AVP_COMMON_PreDecodeField(Origin_Host_AVP)
DIAMETER_IDENTITY_AVP_COMMON_PostDecode(Origin_Host_AVP)

/*type record Origin_Realm_AVP{
//Ref: RFC3588 6.4.  Origin-Realm AVP
	AVP_Header			aVP_Header,//<AVP header: 296 ....>
	Diameter_Identity 	aVP_Data						
};*/
DIAMETER_IDENTITY_AVP_COMMON_PostEncode(Origin_Realm_AVP)
DIAMETER_IDENTITY_AVP_COMMON_PreDecodeField(Origin_Realm_AVP)
DIAMETER_IDENTITY_AVP_COMMON_PostDecode(Origin_Realm_AVP)

/*type record Destination_Realm_AVP{
//Ref: RFC3588 6.6.  Destination-Realm AVP
	AVP_Header         	aVP_Header,//<AVP header: 328 ....>
	Diameter_Identity 	aVP_Data						
};*/
DIAMETER_IDENTITY_AVP_COMMON_PostEncode(Destination_Realm_AVP)
DIAMETER_IDENTITY_AVP_COMMON_PreDecodeField(Destination_Realm_AVP)
DIAMETER_IDENTITY_AVP_COMMON_PostDecode(Destination_Realm_AVP)

/*type record Destination_Host_AVP{
//Ref: RFC3588 6.5.  Destination-Host AVP
	AVP_Header         	aVP_Header,//<AVP header: 293 ....>
	Diameter_Identity 	aVP_Data						
};*/
DIAMETER_IDENTITY_AVP_COMMON_PostEncode(Destination_Host_AVP)
DIAMETER_IDENTITY_AVP_COMMON_PreDecodeField(Destination_Host_AVP)
DIAMETER_IDENTITY_AVP_COMMON_PostDecode(Destination_Host_AVP)

/*type record Route_Record_AVP{
//Ref: RFC3588 6.7.1.  Route-Record AVP
	AVP_Header         	aVP_Header,//<AVP header: 282 ....>
	Diameter_Identity 	aVP_Data							
};		*/
DIAMETER_IDENTITY_AVP_COMMON_PostEncode(Route_Record_AVP)
DIAMETER_IDENTITY_AVP_COMMON_PreDecodeField(Route_Record_AVP)
DIAMETER_IDENTITY_AVP_COMMON_PostDecode(Route_Record_AVP)

/*type record Error_Reporting_Host_AVP{
//Ref: RFC3588 7.4.  Error-Reporting-Host AVP
	AVP_Header         	aVP_Header,//<AVP header: 294 ....>
	Diameter_Identity 	aVP_Data						
};*/
DIAMETER_IDENTITY_AVP_COMMON_PostEncode(Error_Reporting_Host_AVP)
DIAMETER_IDENTITY_AVP_COMMON_PreDecodeField(Error_Reporting_Host_AVP)
DIAMETER_IDENTITY_AVP_COMMON_PostDecode(Error_Reporting_Host_AVP)

/*type record Proxy_Host_AVP{
//Ref: RFC3588 6.7.3.  Proxy-Host AVP
	AVP_Header         	aVP_Header,//<AVP header: 280 ....>
	Diameter_Identity 	aVP_Data						
};*/
DIAMETER_IDENTITY_AVP_COMMON_PostEncode(Proxy_Host_AVP)
DIAMETER_IDENTITY_AVP_COMMON_PreDecodeField(Proxy_Host_AVP)
DIAMETER_IDENTITY_AVP_COMMON_PostDecode(Proxy_Host_AVP)


///////////////////////////////////////////////////////
///////////////  Time AVPs  //////////////////
///////////////////////////////////////////////////////

//type UInt32 Time;
#define TIME_AVP_COMMON(type) \
	void type::PreDecode(Buffer& buffer) throw (DecodeError)\
	{\
		debug_log_PreDecode(#type);\
	}

/*type record  Tariff_Time_Change_AVP{
//	Ref: RFC4006 8.20.  Tariff-Time-Change AVP
	AVP_Header         			aVP_Header,//< AVP Header: 451 >
	Time 						aVP_Data			
};*/
TIME_AVP_COMMON(Tariff_Time_Change_AVP)

/*type record Revalidation_Time_AVP{
//Ref: ETSI TS 129 212 Revalidation_Time_AVP
	AVP_Header         	aVP_Header,//<AVP header: 1042 ....>
	Time				aVP_Data
};*/
TIME_AVP_COMMON(Revalidation_Time_AVP)

/*type record Rule_Activation_Time_AVP{
//Ref: ETSI TS 129 212 Rule_Activation_Time_AVP
	AVP_Header         	aVP_Header,//<AVP header: 1043 ....>
	Time				aVP_Data
};*/
TIME_AVP_COMMON(Rule_Activation_Time_AVP)

/*type record Rule_DeActivation_Time_AVP{
//Ref: ETSI TS 129 212 Rule_DeActivation_Time_AVP
	AVP_Header         	aVP_Header,//<AVP header: 1044 ....>
	Time				aVP_Data
};*/
TIME_AVP_COMMON(Rule_DeActivation_Time_AVP)

/*type record Event_Timestamp_AVP{
//Ref: RFC3588 8.21.  Event-Timestamp AVP
	AVP_Header         	aVP_Header,//<AVP header: 55 ....>
	Time				aVP_Data
};*/
TIME_AVP_COMMON(Event_Timestamp_AVP)

/*type record Expiry_Time_AVP{
//	Ref: 3GPP TS 29.329	6.3.16 Expiry-Time	
	AVP_Header         			aVP_Header,//<AVP header: 709 ....>	
	Time  						aVP_Data						
};*/
TIME_AVP_COMMON(Expiry_Time_AVP)

///////////////////////////////////////////////////////
///////////////  IPFilterRule AVPs  ///////////////////
///////////////////////////////////////////////////////

//from RFC 3588
/*The IPFilterRule format is derived from the OctetString AVP Base
Format. It uses the ASCII charset. Packets may be filtered based
on the following information that is associated with it:*/

/*type record IP_AddressMask{
	//integer ipno, //ipv4 or ipv6
	UTF8String addr,
	UTF8String mask optional,
	UTF8String ports optional
}*/

void IP_AddressMask::PostEncodeField (int field_id, Buffer& buffer) throw (EncodeError)
{
	Charstring cs;
	
	switch(field_id) {
	case id_addr:
	case id_mask:
	case id_ports:
		cs.SetValue(" ");
		cs.Encode(buffer);
		break;
	default:
		break;
	}
}
void IP_AddressMask::PreEncodeField (int field_id, Buffer& buffer) throw (EncodeError)
{
	Charstring cs;
	
	switch(field_id) {
	case id_mask:
		cs.SetValue("/");
		cs.Encode(buffer);
		break;
	default:
		break;
	}
}
void IP_AddressMask::PostDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	/*
	UTF8String addr,
	UTF8String mask optional,
	UTF8String ports optional
	*/
#ifdef DEBUG_LOG
	std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
	logfile << "IP_AddressMask::PreDecodeField:value " << id << std::endl;

	if(id == id_addr)
	{
		logfile << Get_addr().GetValue() << std::endl;
	}
	else if(id == id_mask && GetHypFieldIsPresent(id))
		logfile << Get_mask().GetValue() << std::endl;
	else if(id == id_ports && GetHypFieldIsPresent(id))
		logfile << Get_ports().GetValue() << std::endl;

	logfile.close();
#endif
}
void IP_AddressMask::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	debug_log_PreDecodeField("IP_AddressMask", id);

	static Regex reg_addr_v4("^[ \t\v\f]*([!][ \t\v\f]*)?[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+");
	static Regex reg_addr_v6("^[ \t\v\f]*([!][ \t\v\f]*)?[a-fA-F0-9:.]+");
	
	static Regex reg_addr_mask_sep ("^" SIPREG_SLASH);
	static Regex reg_addr_bits ("^[0-9]+");

	/*
#define PORT "[0-9]+"
#define PORT_RANGE "[0-9]+" "(" SIPREG_SWS "-" SIPREG_SWS "[0-9]+" SIPREG_SWS ")?"
#define PORT_LIST 
	*/
	static Regex reg_ports ("^[0-9]+(" SIPREG_SWS "-" SIPREG_SWS "[0-9]+" SIPREG_SWS ")?(" SIPREG_COMMA "[0-9]+(" SIPREG_SWS "-" SIPREG_SWS "[0-9]+" SIPREG_SWS ")?)*");

	skip_sp(buffer);

	switch (id) {
		case id_addr:
			if(reg_addr_v4.Match(buffer))
				SetHypFieldLength (id, reg_addr_v4.GetMatchedLength());
			else
			{
				reg_addr_v6.AssertMatch(buffer, this);
				SetHypFieldLength (id, reg_addr_v6.GetMatchedLength());
			}
			break;
		case id_mask:
			if(reg_addr_mask_sep.Match(buffer) && reg_addr_mask_sep.GetMatchedLength())
			{
				#ifdef DEBUG_LOG
					std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
					logfile << "MASK match length: " << reg_addr_mask_sep.GetMatchedLength() << std::endl;
					logfile.close();
				#endif
				buffer.SetPosition(buffer.GetPosition() + reg_addr_mask_sep.GetMatchedLength());
				reg_addr_bits.AssertMatch(buffer, this);
				SetHypFieldIsPresent(id, 1);
				SetHypFieldLength (id, reg_addr_bits.GetMatchedLength());
			}
			else
			{
				#ifdef DEBUG_LOG
					std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
					logfile << "Setting MASK to omit" << std::endl;
					logfile.close();
				#endif
				SetHypFieldIsPresent(id, 0);
			}
			break;
		case id_ports:
			if(reg_ports.Match(buffer))
			{
				SetHypFieldIsPresent(id, 1);
				SetHypFieldLength (id, reg_ports.GetMatchedLength());
			}
			else
				SetHypFieldIsPresent(id, 0);
			break;
		default:
			break;
	}
}


#define DIAREG_PERMIT_OR_DENY "permit|deny"

#define DIAREG_IN_OR_OUT "in|out"

#define DIAREG_IP_PROTO_NUMBER "[0-9]+"
#define DIAREG_IP_PROTO_KEYWORD "ip"

#define DIAREG_FROM "from"
#define DIAREG_TO "to" 

//#define DIAREG_EXCLAMATION SIPREG_SWS "[!]" SIPREG_SWS

#define ANY_KEYWORD "any"
#define ASSIGNED_KEYWORD "assigned"

#define IP_V4 "[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"
#define IP_V6 "[a-fA-F0-9:.]+"
#define BITS "[0-9]+"
//#define ADDRESS "((" + IP_V4 + "|" + IP_V6 + ")(" + MASK_SEP + BITS + ")?)"
#define MASK_SEP "/"

#define NOT_INVERSION_OPTIONAL_TOKEN NOT_INVERSION + "?"
#define SRC_OR_DST "(" + ANY_KEYWORD + "|" + ASSIGNED_KEYWORD + "|" + ADDRESS + ")"
#define SRC_AND_DST_TOKEN "^(" + NOT_INVERSION_OPTIONAL_TOKEN + SRC_OR_DST + ")"

#define PORT "[0-9]+"
#define PORT_RANGE PORT "(" SIPREG_SWS "-" SIPREG_SWS PORT SIPREG_SWS ")?"
#define PORT_LIST PORT_RANGE "(" SIPREG_COMMA PORT_RANGE ")*"

/*The absence of a particular option
			may be denoted with a ’!’.*/
/*
#define FRAG_KEYWORD "frag"

#define IPOPTIONS_KEYWORD "ipoptions"
#define SSRR_KEYWORD "ssrr"
#define LSRR_KEYWORD "lsrr"
#define RR_KEYWORD "rr"
#define TS_KEYWORD "ts"

#define IPOPTIONS_SPEC ""

#define TCPOPTIONS_KEYWORD "tcpoptions"
#define MSS_KEYWORD "mss"
#define WINDOW_KEYWORD "window"
#define SACK_KEYWORD "sack"
//#define TS_KEYWORD "ts"
#define CC_KEYWORD "cc"

#define TCPOPTIONS_SPEC ""

#define ESTABLISHED_KEYWORD "established"
#define SETUP_KEYWORD "setup"

#define TCPFLAGS_KEYWORD "tcpflags"

#define FIN_KEYWORD "fin"
#define SYN_KEYWORD "syn"
#define RST_KEYWORD "rst"
#define PSH_KEYWORD "psh"
#define ACK_KEYWORD "ack"
#define URG_KEYWORD "urg"


#define TCPFLAGS_SPEC ""

#define ICMPTYPES_KEYWORD "icmptypes"

#define ECHO_REPLY_TOKEN "echo reply|0"
#define DESTINATION_UNREACHABLE_TOKEN "destination unreachable|3"
#define SOURCE_QUENCH_TOKEN "source quench|4"
#define REDIRECT_TOKEN "redirect|5"
#define ECHO_REQUEST_TOKEN "echo request|8"
#define ROUTER_ADVERTISEMENT_TOKEN "router advertisement|9"
#define ROUTER_SOLICITATION_TOKEN "router solicitation|10"
#define TTL_EXCEEDED_TOKEN "time-to-live exceeded|11"
#define IP_HEADER_BAD_TOKEN "IP header bad|12"
#define TIMESTAMP_REQUEST_TOKEN "timestamp request|13"
#define TIMESTAMP_REPLY_TOKEN "timestamp reply|14"
#define INFORMATION_REQUEST_TOKEN "information request|15"
#define INFORMATION_REPLY_TOKEN "information reply|16"
#define ADDRESS_MASK_REQUEST_TOKEN "address mask request|17"
#define ADDRESS_MASK_REPLY_TOKEN "address mask reply|18"

#define ICMPTYPES_TYPES ""
*/
#define OPTION "[a-zA-Z0-9,!" SIPCHARS_WSP "]+"//any of the characters incuding whitespace

//#define SRC_AND_DST_TOKEN "^(" + WSP + OPTIONAL_PORTS_TOKEN ")"
/*
IPFilterRule filters MUST follow the format:

action dir proto from src to dst [options]

action			permit - Allow packets that match the rule.
				deny - Drop packets that match the rule.

dir				"in" is from the terminal, "out" is to the
				terminal.

proto			An IP protocol specified by number. The "ip"
				keyword means any protocol will match.

src and dst		<address/mask> [ports]
				The <address/mask> may be specified as:
				ipno		An IPv4 or IPv6 number in dottedquad
							or canonical IPv6 form. Only
							this exact IP number will match the
							rule.
				ipno/bits	An IP number as above with a mask
							width of the form 1.2.3.4/24. In
							this case, all IP numbers from
							1.2.3.0 to 1.2.3.255 will match.
							The bit width MUST be valid for the
							IP version and the IP number MUST
							NOT have bits set beyond the mask.
							For a match to occur, the same IP
							version must be present in the
							packet that was used in describing
							the IP address. To test for a
							particular IP version, the bits part
							can be set to zero. The keyword
							"any" is 0.0.0.0/0 or the IPv6
							equivalent. The keyword "assigned"
							is the address or set of addresses
							assigned to the terminal. For IPv4,
							a typical first rule is often "deny
							in ip! assigned"

				The sense of the match can be inverted by
				preceding an address with the not modifier (!),
				causing all other addresses to be matched
				instead. This does not affect the selection of
				port numbers.
				With the TCP, UDP and SCTP protocols, optional
				ports may be specified as:
				{port/port-port}[,ports[,...]]
				The ’-’ notation specifies a range of ports
				(including boundaries).
				Fragmented packets that have a non-zero offset
				(i.e., not the first fragment) will never match
				a rule that has one or more port
				specifications. See the frag option for
				details on matching fragmented packets.
options:
	frag	Match if the packet is a fragment and this is not
			the first fragment of the datagram. frag may not
			be used in conjunction with either tcpflags or
			TCP/UDP port specifications.
	ipoptions spec
			Match if the IP header contains the comma
			separated list of options specified in spec. The
			supported IP options are:
			ssrr (strict source route), lsrr (loose source
			route), rr (record packet route) and ts
			(timestamp). The absence of a particular option
			may be denoted with a ’!’.
	tcpoptions spec
			Match if the TCP header contains the comma
			separated list of options specified in spec. The
			supported TCP options are:
			mss (maximum segment size), window (tcp window
			advertisement), sack (selective ack), ts (rfc1323
			timestamp) and cc (rfc1644 t/tcp connection
			count). The absence of a particular option may
			be denoted with a ’!’.
	established
			TCP packets only. Match packets that have the RST
			or ACK bits set.
	setup	TCP packets only. Match packets that have the SYN
			bit set but no ACK bit.
	tcpflags spec
			TCP packets only. Match if the TCP header
			contains the comma separated list of flags
			specified in spec. The supported TCP flags are:
			fin, syn, rst, psh, ack and urg. The absence of a
			particular flag may be denoted with a ’!’. A rule
			that contains a tcpflags specification can never
			match a fragmented packet that has a non-zero
			offset. See the frag option for details on
			matching fragmented packets.
	icmptypes types
			ICMP packets only. Match if the ICMP type is in
			the list types. The list may be specified as any
			combination of ranges or individual types
			separated by commas. Both the numeric values and
			the symbolic values listed below can be used. The
			supported ICMP types are:
			echo reply (0), destination unreachable (3),
			source quench (4), redirect (5), echo request
			(8), router advertisement (9), router
			solicitation (10), time-to-live exceeded (11), IP
			header bad (12), timestamp request (13),
			timestamp reply (14), information request (15),
			information reply (16), address mask request (17)
			and address mask reply (18).

*/

/*type record IPFilterRule_Type{
//RFC3588
  	UTF8String	action_,
  	UTF8String	direction,
  	UTF8String	proto,
  	IP_AddressMask src, //including optional ports
  	IP_AddressMask dst, //including optional ports
  	UTF8String options optional	
}*/
void IPFilterRule_Type::PreEncodeField (int field_id, Buffer& buffer) throw (EncodeError)
{
	Charstring cs;
	/*UTF8String	action_,
  	UTF8String	direction,
  	UTF8String	proto,
  	IP_AddressMask src, //including optional ports
  	IP_AddressMask dst, //including optional ports
  	UTF8String options optional
*/
	switch(field_id) {
	case id_direction:
	case id_proto:
	case id_options:
		cs.SetValue(" ");
		cs.Encode(buffer);
		break;
	case id_src:
		cs.SetValue(" from ");
		cs.Encode(buffer);
		break;
	case id_dst:
		cs.SetValue(" to ");
		cs.Encode(buffer);
		break;
	default:
		break;
	}
}

void IPFilterRule_Type::PostDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
#ifdef DEBUG_LOG
	std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
	logfile << "IPFilterRule_Type::PreDecodeField:value " << id << std::endl;

	if(id == id_action_)
	{
		logfile << Get_action_().GetValue() << std::endl;
	}
	else if(id == id_direction)
	{
		logfile << Get_direction().GetValue() << std::endl;
	}
	else if(id == id_proto)
	{
		logfile << Get_proto().GetValue() << std::endl;
	}
	else if(id == id_options && GetHypFieldIsPresent(id))
		logfile << Get_options().GetValue() << std::endl;
	logfile.close();
#endif
}
void IPFilterRule_Type::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	debug_log_PreDecodeField("IPFilterRule_Type", id);

	/*
	UTF8String	action_,
  	UTF8String	direction,
  	UTF8String	proto,
  	IP_AddressMask src, //including optional ports
  	IP_AddressMask dst, //including optional ports
  	UTF8String options optional
	*/

	static Regex reg_action ("^(" DIAREG_PERMIT_OR_DENY ")");
	static Regex reg_direction ("^(" DIAREG_IN_OR_OUT ")");
	static Regex reg_proto ("^(" DIAREG_IP_PROTO_NUMBER "|" DIAREG_IP_PROTO_KEYWORD ")");
	
	static Regex reg_from("^" DIAREG_FROM);
	static Regex reg_to("^" DIAREG_TO);

	static Regex reg_option ("^" OPTION);
	
	skip_sp(buffer);
	//SIPCHARS_WSP

	//action dir proto from src to dst [options]
	switch (id) {
		case id_action_:
			reg_action.AssertMatch (buffer, this);
			SetHypFieldLength (id, reg_action.GetMatchedLength());
			break;
		case id_direction:
			reg_direction.AssertMatch (buffer, this);
			SetHypFieldLength (id, reg_direction.GetMatchedLength());
			break;
		case id_proto:
			reg_proto.AssertMatch (buffer, this);
			SetHypFieldLength (id, reg_proto.GetMatchedLength());
			break;
		case id_src:
			if(reg_from.Match(buffer))
				buffer.SetPosition(buffer.GetPosition() + reg_from.GetMatchedLength());
			break;
		case id_dst:
			if(reg_to.Match(buffer))
				buffer.SetPosition(buffer.GetPosition() + reg_to.GetMatchedLength());
			break;
		case id_options:
			if(reg_option.Match(buffer) && reg_option.GetMatchedLength())
			{
				#ifdef DEBUG_LOG
					std::ofstream logfile("C:\\Temp\\LibDiameter.log", ios::app);
					logfile << "OPTIONS match length: " << reg_option.GetMatchedLength() << std::endl;
					logfile.close();
				#endif
				SetHypFieldIsPresent(id, 1);
				SetHypFieldLength (id, reg_option.GetMatchedLength());
			}
			else
				SetHypFieldIsPresent(id, 0);
			break;
		default:
			break;
	}
}

//this is a copy of the code above, keep them in sync!!!
/*type record QoSFilterRule{
	//RFC3588 page 49
    UTF8String	action_,
  	UTF8String	direction,
  	UTF8String	proto,
  	IP_AddressMask src, //including optional ports
  	IP_AddressMask dst, //including optional ports
  	UTF8String options optional	   
}*/
void QoSFilterRule::PreEncodeField (int field_id, Buffer& buffer) throw (EncodeError)
{
	Charstring cs;

	switch(field_id) {
	case id_direction:
	case id_proto:
	case id_options:
		cs.SetValue(" ");
		cs.Encode(buffer);
		break;
	case id_src:
		cs.SetValue(" from ");
		cs.Encode(buffer);
		break;
	case id_dst:
		cs.SetValue(" to ");
		cs.Encode(buffer);
		break;
	default:
		break;
	}
}

void QoSFilterRule::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
{
	debug_log_PreDecodeField("IPFilterRule_Type", id);

	static Regex reg_action ("^(" DIAREG_PERMIT_OR_DENY ")");
	static Regex reg_direction ("^(" DIAREG_IN_OR_OUT ")");
	static Regex reg_proto ("^(" DIAREG_IP_PROTO_NUMBER "|" DIAREG_IP_PROTO_KEYWORD ")");
	
	static Regex reg_from("^" DIAREG_FROM);
	static Regex reg_to("^" DIAREG_TO);

	static Regex reg_option ("^" OPTION);
	
	skip_sp(buffer);
	
	//action dir proto from src to dst [options]
	switch (id) {
		case id_action_:
			reg_action.AssertMatch (buffer, this);
			SetHypFieldLength (id, reg_action.GetMatchedLength());
			break;
		case id_direction:
			reg_direction.AssertMatch (buffer, this);
			SetHypFieldLength (id, reg_direction.GetMatchedLength());
			break;
		case id_proto:
			reg_proto.AssertMatch (buffer, this);
			SetHypFieldLength (id, reg_proto.GetMatchedLength());
			break;
		case id_src:
			if(reg_from.Match(buffer))
				buffer.SetPosition(buffer.GetPosition() + reg_from.GetMatchedLength());
			break;
		case id_dst:
			if(reg_to.Match(buffer))
				buffer.SetPosition(buffer.GetPosition() + reg_to.GetMatchedLength());
			break;
		case id_options:
			if(reg_option.Match(buffer) && reg_option.GetMatchedLength())
			{
				SetHypFieldIsPresent(id, 1);
				SetHypFieldLength (id, reg_option.GetMatchedLength());
			}
			else
				SetHypFieldIsPresent(id, 0);
			break;
		default:
			break;
	}
}


///////////////////////////////////////////////////////
////////////  IPFilterRule_Type AVPs  /////////////////
///////////////////////////////////////////////////////
//TODO:

/*type record Packet_Filter_Content_AVP{
//Ref: ETSI TS 129 212 Packet_Filter_Content_AVP
    AVP_Header			aVP_Header,//<AVP header: 1059 ....>
    IPFilterRule_Type  	aVP_Data
};*/

/*type record TFT_Filter_AVP{
//Ref: ETSI TS 129 212 TFT_Filter_AVP
    AVP_Header			aVP_Header,//<AVP header: 1012 ....>
    IPFilterRule_Type  	aVP_Data
};*/

/*type record Tunnel_Header_Filter_AVP{
//Ref: ETSI TS 129 212 Tunnel_Header_Filter_AVP
    AVP_Header			aVP_Header,//<AVP header: 1036 ....>
    IPFilterRule_Type  	aVP_Data
};*/

/*type record Flow_Description_AVP{
//Ref: ETSI TS 129 214 Flow_Description AVP
    AVP_Header			aVP_Header,//<AVP header: 507 ....>
    IPFilterRule_Type  	aVP_Data
};*/

/*type record Restriction_Filter_Rule_AVP{
//	Ref: RFC4006 8.36.  Restriction-Filter-Rule AVP
	AVP_Header         			aVP_Header,//< AVP Header: 438 >
	IPFilterRule_Type			aVP_Data
};*/


///////////////////////////////////////////////////////
///////////////  INT32, UINT32 AVPs  //////////////////
///////////////////////////////////////////////////////
#define INT32_AVP_COMMON(type) \
	void type::PreDecode(Buffer& buffer) throw (DecodeError)\
	{\
		debug_log_PreDecode(#type);\
	}

#define UINT32_AVP_COMMON(type) \
	void type::PreDecode(Buffer& buffer) throw (DecodeError)\
	{\
		debug_log_PreDecode(#type);\
	}

/*type record Supported_Vendor_Id_AVP{
//Ref; 5.3.6.  Supported-Vendor-Id AVP
	AVP_Header        	aVP_Header,//<AVP header: 265 ....>
	Int32				aVP_Data							
};*/
INT32_AVP_COMMON(Supported_Vendor_Id_AVP)

/*type record Origin_State_Id_AVP{
//Ref: RFC3588 8.16.  Origin-State-Id AVP
	AVP_Header         	aVP_Header,//<AVP header: 278 ....>
	UInt32 				aVP_Data
};*/
UINT32_AVP_COMMON(Origin_State_Id_AVP)


/*type record Vendor_Id_AVP{
//Ref: RFC3588 5.3.3.  Vendor-Id AVP
	AVP_Header         	aVP_Header,//<AVP header: 266 ....>
	UInt32				aVP_Data	
};*/
UINT32_AVP_COMMON(Vendor_Id_AVP)

/*type record Inband_Security_Id_AVP{
//Ref: RFC3588 6.10.  Inband-Security-Id AVP
	AVP_Header         	aVP_Header,//<AVP header: 299 ....>
	UInt32 				aVP_Data							
};*/
UINT32_AVP_COMMON(Inband_Security_Id_AVP)

/*type record Auth_Application_Id_AVP{
//Ref: RFC3588 6.8.  Auth-Application-Id AVP
	AVP_Header         	aVP_Header,//<AVP header: 258 ....>
	UInt32 				aVP_Data							
};*/
UINT32_AVP_COMMON(Auth_Application_Id_AVP)

/*type record Acct_Application_Id_AVP{
//Ref: RFC3588 6.9.  Acct-Application-Id AVP				
	AVP_Header         	aVP_Header,//<AVP header: 259 ....>
	UInt32 				aVP_Data							
};*/
UINT32_AVP_COMMON(Acct_Application_Id_AVP)

/*type record Firmware_Revision_AVP{
//Ref: RFC3588 5.3.4.  Firmware-Revision AVP
	AVP_Header        	aVP_Header,//<AVP header: 267 ....>
	UInt32 				aVP_Data							
};*/
UINT32_AVP_COMMON(Firmware_Revision_AVP)

/*type record Media_Component_Number_AVP{
 //Ref: ETSI TS 129 214 Media_Component_Number_AVP
     AVP_Header			aVP_Header,//<AVP header: 518 ....>
     UInt32             aVP_Data
 };*/
UINT32_AVP_COMMON(Media_Component_Number_AVP)

/*type record Flow_Number_AVP{
//Ref: ETSI TS 129 214 Flow_Number AVP
    AVP_Header			aVP_Header,//<AVP header: 509 ....>
    UInt32          	aVP_Data
};*/
UINT32_AVP_COMMON(Flow_Number_AVP)

/*type record CC_Time_AVP{
//	Ref: RFC4006 8.21.  CC-Time AVP
	AVP_Header         			aVP_Header,//< AVP Header: 420 >
	UInt32                  	aVP_Data											
};*/
UINT32_AVP_COMMON(CC_Time_AVP)

/*type record Exponent_AVP{
//	Ref: RFC4006 8.9.  Exponent AVP
	AVP_Header         			aVP_Header,//< AVP Header: 429 >
	Int32                   	aVP_Data							
};*/
INT32_AVP_COMMON(Exponent_AVP)

/*type record Currency_Code_AVP{
//	Ref: RFC4006 8.11.  Currency-Code AVP
	AVP_Header         			aVP_Header,//< AVP Header: 425 >				
	UInt32						aVP_Data
};*/
UINT32_AVP_COMMON(Currency_Code_AVP)

/*type record CSG_Id_AVP{
//Ref: ETSI TS 132 299 & TS129 272 CSG_Id_AVP
    AVP_Header			aVP_Header, //<AVP header: 1437 ....>
    UInt32        		aVP_Data
};*/
UINT32_AVP_COMMON(CSG_Id_AVP)

/*type record Max_Requested_Bandwidth_DL_AVP{
//Ref: ETSI TS 129 214 FMax_Requested_Bandwidth_DL AVP
    AVP_Header			aVP_Header,//<AVP header: 515 ....>
    UInt32          	aVP_Data
};*/                    
UINT32_AVP_COMMON(Max_Requested_Bandwidth_DL_AVP)

/*type record Max_Requested_Bandwidth_UL_AVP{
//Ref: ETSI TS 129 214 FMax_Requested_Bandwidth_UL AVP
    AVP_Header			aVP_Header,//<AVP header: 516 ....>
    UInt32          	aVP_Data
};*/
UINT32_AVP_COMMON(Max_Requested_Bandwidth_UL_AVP)

/*type record APN_Aggregate_Max_Bitrate_DL_AVP{
//Ref: ETSI TS 129 212 APN_Aggregate_Max_Bitrate_DL_AVP
    AVP_Header			aVP_Header,//<AVP header: 1040 ....>
    UInt32        		aVP_Data
};*/ 			    
UINT32_AVP_COMMON(APN_Aggregate_Max_Bitrate_DL_AVP)

/*type record APN_Aggregate_Max_Bitrate_UL_AVP{
//Ref: ETSI TS 129 212 APN_Aggregate_Max_Bitrate_UL_AVP
    AVP_Header			aVP_Header,//<AVP header: 1041 ....>
    UInt32        		aVP_Data
};*/ 			    
UINT32_AVP_COMMON(APN_Aggregate_Max_Bitrate_UL_AVP)

/*type record Guaranteed_Bitrate_DL_AVP{
//Ref: ETSI TS 129 212 Guaranteed_Bitrate_DL_AVP
    AVP_Header			aVP_Header,//<AVP header: 1025 ....>
    UInt32        		aVP_Data
};*/ 			    
UINT32_AVP_COMMON(Guaranteed_Bitrate_DL_AVP)

/*type record Guaranteed_Bitrate_UL_AVP{
//Ref: ETSI TS 129 212 Guaranteed_Bitrate_UL_AVP
    AVP_Header			aVP_Header,//<AVP header: 1026 ....>
    UInt32        		aVP_Data
};*/
UINT32_AVP_COMMON(Guaranteed_Bitrate_UL_AVP)

/*type record Precedence_AVP{
//Ref: ETSI TS 129 212 Precedence_AVP
    AVP_Header			aVP_Header,//<AVP header: 1010 ....>
    UInt32        		aVP_Data
};*/
UINT32_AVP_COMMON(Precedence_AVP)

/*type record Priority_Level_AVP{
//Ref: ETSI TS 129 212 Priority_Level_AVP
    AVP_Header			aVP_Header,//<AVP header: 1046 ....>
    UInt32        		aVP_Data
};*/
UINT32_AVP_COMMON(Priority_Level_AVP)

/*type record Tunnel_Header_Length_AVP{
//Ref: ETSI TS 129 212 Tunnel_Header_Length_AVP
    AVP_Header			aVP_Header,//<AVP header: 1037 ....>
    UInt32        		aVP_Data
};*/
UINT32_AVP_COMMON(Tunnel_Header_Length_AVP)

/*type record List_Of_Measurements_AVP{
//Ref: ETSI TS129 272 List_Of_Measurements_AVP
    AVP_Header			aVP_Header, //<AVP header: 1625 ....>
	UInt32        		aVP_Data
};*/
UINT32_AVP_COMMON(List_Of_Measurements_AVP)
                
/*type record Reporting_Trigger_AVP{
//Ref: ETSI TS129 272 Reporting_Trigger_AVP
    AVP_Header			aVP_Header, //<AVP header: 1626 ....>
	UInt32        		aVP_Data
};*/
UINT32_AVP_COMMON(Reporting_Trigger_AVP)

/*type record Event_Treshold_RSRP_AVP{
//Ref: ETSI TS129 272 Event_Treshold_RSRP_AVP
    AVP_Header			aVP_Header, //<AVP header: 1629 ....>
	UInt32        		aVP_Data
};*/
UINT32_AVP_COMMON(Event_Treshold_RSRP_AVP)

/*type record Event_Treshold_RSRQ_AVP{
//Ref: ETSI TS129 272 Event_Treshold_RSRQ_AVP
    AVP_Header			aVP_Header, //<AVP header: 1630 ....>
	UInt32        		aVP_Data
};*/
UINT32_AVP_COMMON(Event_Treshold_RSRQ_AVP)

/*type record Service_Identifier_AVP{
//	Ref: RFC4006 8.28.  Service-Identifier AVP
	AVP_Header         			aVP_Header,//< AVP Header: 439 >
	UInt32                  	aVP_Data
};*/
UINT32_AVP_COMMON(Service_Identifier_AVP)

/*type record Validity_Time_AVP{
//	Ref: RFC4006 8.33.  Validity-Time AVP
	AVP_Header         			aVP_Header,//< AVP Header: 448 >			
	UInt32						aVP_Data
};*/
UINT32_AVP_COMMON(Validity_Time_AVP)

/*type record CC_Request_Number_AVP{
//	Ref: RFC4006 8.2.  CC-Request-Number AVP			
	AVP_Header         			aVP_Header,//<AVP header: 415 ....>
	UInt32                  	aVP_Data			
};*/
UINT32_AVP_COMMON(CC_Request_Number_AVP)

/*type record  Rating_Group_AVP{
//	Ref: RFC4006 8.29.  Rating-Group AVP
	AVP_Header         			aVP_Header,//< AVP Header: 433 >
	UInt32  					aVP_Data			
};*/
UINT32_AVP_COMMON(Rating_Group_AVP)

/*type record G_S_U_Pool_Identifier_AVP{
	//	Ref: RFC4006 8.31.  G-S-U-Pool-Identifier AVP
	AVP_Header         				aVP_Header,//< AVP Header: 453 >
	UInt32  						aVP_Data			
};*/
UINT32_AVP_COMMON(G_S_U_Pool_Identifier_AVP)

/*type record RR_Bandwidth_AVP{
//Ref: ETSI TS 129 214 RR Bandwidth_AVP
   AVP_Header			aVP_Header,//<AVP header: 521 ....>
   UInt32               aVP_Data
};*/  
UINT32_AVP_COMMON(RR_Bandwidth_AVP)

/*type record RS_Bandwidth_AVP{
//Ref: ETSI TS 129 214 RS Bandwidth_AVP
   AVP_Header			aVP_Header,//<AVP header: 522 ....>
   UInt32               aVP_Data
};*/
UINT32_AVP_COMMON(RS_Bandwidth_AVP)

/*type record Acct_Interim_Interval_AVP{
//Ref: RFC3588 9.8.2.  Acct-Interim-Interval
	AVP_Header         	aVP_Header,//<AVP header: 85 ....>
	UInt32				aVP_Data
}*/
UINT32_AVP_COMMON(Acct_Interim_Interval_AVP)

/*type record Accounting_Record_Number_AVP{
//Ref: RFC3588 9.8.3.  Accounting-Record-Number AVP
	AVP_Header         	aVP_Header,//<AVP header: 485 ....>
	UInt32				aVP_Data							
};*/
UINT32_AVP_COMMON(Accounting_Record_Number_AVP)

/*type record Auth_Grace_Period_AVP{
//Ref: RFC35888.10.  Auth-Grace-Period AVP			
	AVP_Header         	aVP_Header,//<AVP header: 276 ....>
	UInt32				aVP_Data
};*/
UINT32_AVP_COMMON(Auth_Grace_Period_AVP)

/*type record Authorization_Lifetime_AVP{
//Ref: RFC35888.9.  Authorization-Lifetime AVP
	AVP_Header         	aVP_Header,//<AVP header: 291 ....>			
	UInt32				aVP_Data
};*/
UINT32_AVP_COMMON(Authorization_Lifetime_AVP)

/*type record Redirect_Max_Cache_Time_AVP	{
//Ref: RFC3588  6.14.  Redirect-Max-Cache-Time AVP
	AVP_Header         	aVP_Header,//<AVP header: 262 ....>
	UInt32				aVP_Data
};*/
UINT32_AVP_COMMON(Redirect_Max_Cache_Time_AVP)

/*type record SIP_MandatoryCapability_AVP{
//Ref: RFC4740 9.3.1.  SIP-Mandatory-Capability AVP
	AVP_Header         	aVP_Header,//<AVP header: 373 ....>
	UInt32				aVP_Data
};*/
UINT32_AVP_COMMON(SIP_MandatoryCapability_AVP)

/*type record SIP_OptionalCapability_AVP{
//Ref: RFC4740 9.3.2.  SIP-Optional-Capability AVP
	AVP_Header         	aVP_Header,//<AVP header: 374 ....>
	UInt32				aVP_Data
};*/
UINT32_AVP_COMMON(SIP_OptionalCapability_AVP)

/*type record SIP_Item_Number_AVP{
	//Ref: RFC4740 9.5.2 SIP-Item-Number AVP
	AVP_Header         			aVP_Header,//<AVP header: 378 ....>
	UInt32						aVP_Data
};*/
UINT32_AVP_COMMON(SIP_Item_Number_AVP)

/*type record SIP_Number_Auth_Items_AVP{
//Ref: RFC4740 9.6.  SIP-Number-Auth-Items AVP
	AVP_Header         	aVP_Header,//<AVP header: 382 ....>
	UInt32				aVP_Data
};*/
UINT32_AVP_COMMON(SIP_Number_Auth_Items_AVP)

/*type record Max_Supported_Bandwidth_DL_AVP{
//Ref: ETSI TS 129 212 Max_Supported_Bandwidth_DL_AVP
    AVP_Header			aVP_Header,//<AVP header: 1083 ....>
    UInt32        		aVP_Data
};*/
UINT32_AVP_COMMON(Max_Supported_Bandwidth_DL_AVP)
                
/*type record Max_Supported_Bandwidth_UL_AVP{
//Ref: ETSI TS 129 212 Max_Supported_Bandwidth_UL_AVP
    AVP_Header			aVP_Header,//<AVP header: 1084 ....>
    UInt32        		aVP_Data
};*/
UINT32_AVP_COMMON(Max_Supported_Bandwidth_UL_AVP)

/*type record Service_Parameter_Type_AVP{
//	Ref: RFC4006 8.44.  Service-Parameter-Type AVP
	AVP_Header         			aVP_Header,//< AVP Header: 441 >
	UInt32						aVP_Data				
};*/
UINT32_AVP_COMMON(Service_Parameter_Type_AVP)

/*type record Feature_List_AVP{
//	Ref: 3GPP TS 29.229, clause 6.3.31	
	AVP_Header         			aVP_Header,//<AVP header: 634 ....>
	UInt32				  		aVP_Data										
};*/
UINT32_AVP_COMMON(Feature_List_AVP)

/*type record Feature_List_ID_AVP{
//	Ref: 3GPP TS 29.229, clause 6.3.30	
	AVP_Header         			aVP_Header,//<AVP header: 634 ....>
	UInt32				  		aVP_Data										
};*/
UINT32_AVP_COMMON(Feature_List_ID_AVP)

///////////////////////////////////////////////////////
////////  INT32 as ENUMERATED AVPs  //////////////////
///////////////////////////////////////////////////////

/*type record Subscription_Id_Type_AVP{
//	Ref: RFC4006 8.47.  Subscription-Id-Type AVP
	AVP_Header         			aVP_Header,//<AVP header: 450 ....>
	Subscription_Id_Ty_Type     aVP_Data			
};*/
INT32_AVP_COMMON(Subscription_Id_Type_AVP)

/*type record Abort_Cause_AVP{
//Ref: ETSI TS 129 214 Abort Cause AVP
    AVP_Header			aVP_Header,//<AVP header: 500 ....>
    Abort_Cause_Type	aVP_Data
};*/
INT32_AVP_COMMON(Abort_Cause_AVP)

/*type record IP_CAN_Type_AVP{
//Ref: ETSI TS 129 212 IP CAN Type AVP
    AVP_Header			aVP_Header,//<AVP header: 1027 ....>
    IP_CAN_Type			aVP_Data
};*/
INT32_AVP_COMMON(IP_CAN_Type_AVP)

/*type record RAT_Type_AVP{
//Ref: ETSI TS 129 212 RAT Type AVP
    AVP_Header			aVP_Header,//<AVP header: 1032 ....>
    RAT_Type			aVP_Data
};*/
INT32_AVP_COMMON(RAT_Type_AVP)

/*type record Tariff_Change_Usage_AVP{
//	Ref: RFC4006 8.27.  Tariff-Change-Usage AVP
	AVP_Header         			aVP_Header,//< AVP Header: 452 >
	Tariff_Change_Usage_Type    aVP_Data			
};*/
INT32_AVP_COMMON(Tariff_Change_Usage_AVP)

/*type record Session_Release_Cause_AVP{
//Ref: ETSI TS 129 212 Session_Release_Cause_AVP
    AVP_Header				aVP_Header,//<AVP header: 1045 ....>
    Session_Release_Cause	aVP_Data
};*/
INT32_AVP_COMMON(Session_Release_Cause_AVP)

/*type record Event_Trigger_AVP{
//Ref: ETSI TS 129 212 Event_Trigger_AVP
    AVP_Header			aVP_Header,//<AVP header: 1006 ....>
    Event_Trigger		aVP_Data
};*/
INT32_AVP_COMMON(Event_Trigger_AVP)

/*type record CSG_Access_Mode_AVP{
//Ref: ETSI TS 132 299 CSG_Access_Mode_AVP
    AVP_Header		aVP_Header, //<AVP header: 2317 ....>
    CSG_Access_Mode	aVP_Data
};*/
INT32_AVP_COMMON(CSG_Access_Mode_AVP)

/*type record CSG_Membership_Indication_AVP{
//Ref: ETSI TS 132 299 CSG_Membership_Indication_AVP
    AVP_Header					aVP_Header, //<AVP header: 2318 ....>
    CSG_Membership_Indication	aVP_Data
};*/
INT32_AVP_COMMON(CSG_Membership_Indication_AVP)

/*type record QoS_Class_Identifier_AVP{
//Ref: ETSI TS 129 212 QoS_Class_Identifier_AVP
    AVP_Header				aVP_Header,//<AVP header: 1028 ....>
    QoS_Class_Identifier	aVP_Data
};*/
INT32_AVP_COMMON(QoS_Class_Identifier_AVP)

/*type record QoS_Negotiation_AVP{
//Ref: ETSI TS 129 212 QoS_Negotiation_AVP
    AVP_Header			aVP_Header,//<AVP header: 1029 ....>
    QoS_Negotiation		aVP_Data
};*/
INT32_AVP_COMMON(QoS_Negotiation_AVP)

/*type record QoS_Upgrade_AVP{
//Ref: ETSI TS 129 212 QoS_Upgrade_AVP
    AVP_Header			aVP_Header,//<AVP header: 1030 ....>
    QoS_Upgrade			aVP_Data
};*/
INT32_AVP_COMMON(QoS_Upgrade_AVP)

/*type record Resource_Allocation_Notification_AVP{
//Ref: ETSI TS 129 212 Resource_Allocation_Notification_AVP
    AVP_Header							aVP_Header,//<AVP header: 1063 ....>
    Resource_Allocation_Notification	aVP_Data
};*/
INT32_AVP_COMMON(Resource_Allocation_Notification_AVP)

/*type record Rule_Failure_Code_AVP{
//Ref: ETSI TS 129 212 Rule_Failure_Code_AVP
    AVP_Header			aVP_Header,//<AVP header: 1031 ....>
    Rule_Failure_Code	aVP_Data
};*/
INT32_AVP_COMMON(Rule_Failure_Code_AVP)

/*type record Usage_Monitoring_Level_AVP{
//Ref: ETSI TS 129 212 Usage_Monitoring_Level_AVP
    AVP_Header				aVP_Header,//<AVP header: 1068 ....>
    Usage_Monitoring_Level	aVP_Data
};*/
INT32_AVP_COMMON(Usage_Monitoring_Level_AVP)

/*type record Usage_Monitoring_Report_AVP{
//Ref: ETSI TS 129 212 Usage_Monitoring_Report_AVP
    AVP_Header				aVP_Header,//<AVP header: 1069 ....>
    Usage_Monitoring_Report	aVP_Data
};*/
INT32_AVP_COMMON(Usage_Monitoring_Report_AVP)

/*type record Usage_Monitoring_Support_AVP{
//Ref: ETSI TS 129 212 Usage_Monitoring_Support_AVP
    AVP_Header					aVP_Header,//<AVP header: 1070 ....>
    Usage_Monitoring_Support	aVP_Data
};*/
INT32_AVP_COMMON(Usage_Monitoring_Support_AVP)

/*type record Flow_Direction_AVP{
//Ref: ETSI TS 129 212 Flow_Direction_AVP
    AVP_Header			aVP_Header,//<AVP header: 1080 ....>
    Flow_Direction		aVP_Data
};*/
INT32_AVP_COMMON(Flow_Direction_AVP)

/*type record Metering_Method_AVP{
//Ref: ETSI TS 129 212 Metering_Method_AVP
    AVP_Header			aVP_Header,//<AVP header: 1007 ....>
    Metering_Method		aVP_Data
};*/
INT32_AVP_COMMON(Metering_Method_AVP)

/*type record Network_Request_Support_AVP{
//Ref: ETSI TS 129 212 Network_Request_Support_AVP
    AVP_Header				aVP_Header,//<AVP header: 1024 ....>
    Network_Request_Support	aVP_Data
};*/
INT32_AVP_COMMON(Network_Request_Support_AVP)

/*type record Offline_AVP{
//Ref: ETSI TS 129 212 Offlinet_AVP
    AVP_Header				aVP_Header,//<AVP header: 1008 ....>
    Offline					aVP_Data
};*/
INT32_AVP_COMMON(Offline_AVP)

/*type record Online_AVP{
//Ref: ETSI TS 129 212 Online_AVP
    AVP_Header				aVP_Header,//<AVP header: 1009 ....>
    Online					aVP_Data
};*/
INT32_AVP_COMMON(Online_AVP)

/*type record Packet_Filter_Operation_AVP{
//Ref: ETSI TS 129 212 Packet_Filter_Operation_AVP
    AVP_Header				aVP_Header,//<AVP header: 1062 ....>
    Packet_Filter_Operation	aVP_Data
};*/
INT32_AVP_COMMON(Packet_Filter_Operation_AVP)

/*type record Packet_Filter_Usage_AVP{
//Ref: ETSI TS 129 212 Packet_Filter_Usage_AVP
    AVP_Header				aVP_Header,//<AVP header: 1072 ....>
    Packet_Filter_Usage		aVP_Data
};*/
INT32_AVP_COMMON(Packet_Filter_Usage_AVP)

/*type record Pre_emption_Capability_AVP{
//Ref: ETSI TS 129 212 Pre_emption_Capability_AVP
    AVP_Header				aVP_Header,//<AVP header: 1047 ....>
    Pre_emption_Capability	aVP_Data
};*/
INT32_AVP_COMMON(Pre_emption_Capability_AVP)

/*type record Pre_emption_Vulnerability_AVP{
//Ref: ETSI TS 129 212 Pre_emption_Vulnerabilitye_AVP
    AVP_Header					aVP_Header,//<AVP header: 1048 ....>
    Pre_emption_Vulnerability	aVP_Data
};*/
INT32_AVP_COMMON(Pre_emption_Vulnerability_AVP)

/*type record Reporting_Level_AVP{
//Ref: ETSI TS 129 212 Reporting_Levele_AVP
    AVP_Header			aVP_Header,//<AVP header: 1011 ....>
    Reporting_Level		aVP_Data
};*/
INT32_AVP_COMMON(Reporting_Level_AVP)

/*type record PCC_Rule_Status_AVP{
//Ref: ETSI TS 129 212 PCC_Rule_Status_AVP
    AVP_Header			aVP_Header,//<AVP header: 1019 ....>
    PCC_Rule_Status		aVP_Data
};*/
INT32_AVP_COMMON(PCC_Rule_Status_AVP)

/*type record Trace_Depth_AVP{
//Ref: ETSI TS129 272 Trace_Depth_AVP
    AVP_Header			aVP_Header, //<AVP header: 1462 ....>
	Trace_Depth			aVP_Data
};*/
INT32_AVP_COMMON(Trace_Depth_AVP)

/*type record Job_Type_AVP{
//Ref: ETSI TS129 272 Job_Type_AVP
    AVP_Header		aVP_Header, //<AVP header: 1623 ....>
	Job_Type		aVP_Data
};*/
INT32_AVP_COMMON(Job_Type_AVP)

/*type record Report_Interval_AVP{
//Ref: ETSI TS129 272 Report_Interval_AVP
    AVP_Header			aVP_Header, //<AVP header: 1627 ....>
	Report_Interval		aVP_Data
};*/
INT32_AVP_COMMON(Report_Interval_AVP)

/*type record Report_Amount_AVP{
//Ref: ETSI TS129 272 Report_Amount_AVP
    AVP_Header			aVP_Header, //<AVP header: 1628 ....>
	Report_Amount		aVP_Data
};*/
INT32_AVP_COMMON(Report_Amount_AVP)

/*type record Logging_Interval_AVP{
//Ref: ETSI TS129 272 Logging_Interval_AVP
    AVP_Header			aVP_Header, //<AVP header: 1631 ....>
	Logging_Interval	aVP_Data
};*/
INT32_AVP_COMMON(Logging_Interval_AVP)

/*type record Logging_Duration_AVP{
//Ref: ETSI TS129 272 Logging_Duration_AVP
    AVP_Header			aVP_Header, //<AVP header: 1632 ....>
	Logging_Duration	aVP_Data
};*/
INT32_AVP_COMMON(Logging_Duration_AVP)

/*type record Media_Type_AVP{
//Ref: ETSI TS 129 214 Media_Type AVP
	AVP_Header			aVP_Header,//<AVP header: 520 ....>
	Media_Type_Type	aVP_Data
};*/
INT32_AVP_COMMON(Media_Type_AVP)

/*type record Service_Info_Status_AVP{
//Ref: ETSI TS 129 214 Service_Info AVP
	AVP_Header			aVP_Header,//<AVP header: 527 ....>
	Service_Info_Type	aVP_Data
};*/
INT32_AVP_COMMON(Service_Info_Status_AVP)

/*type record SIP_Forking_Indication_AVP{
//Ref: ETSI TS 129 214 SIP_Forking_Indication AVP
	AVP_Header			aVP_Header,//<AVP header: 523 ....>
	SIP_Forking_Indication_Type	aVP_Data
};*/
INT32_AVP_COMMON(SIP_Forking_Indication_AVP)

/*type record AF_Signalling_Protocol_AVP{
//Ref: ETSI TS 129 214 AF_Signalling_Protocol AVP
	AVP_Header			aVP_Header,//<AVP header: 529 ....>
	AF_Signalling_Protocol_Type	aVP_Data
};*/
INT32_AVP_COMMON(AF_Signalling_Protocol_AVP)

/*type record Bearer_Control_Mode_AVP{
//Ref: ETSI TS 129 212 Bearer_Control_Mode_AVP
    AVP_Header			aVP_Header,//<AVP header: 1023 ....>
    Bearer_Control_Mode	aVP_Data
};*/
INT32_AVP_COMMON(Bearer_Control_Mode_AVP)

/*type record Bearer_Operation_AVP{
//Ref: ETSI TS 129 212 Bearer_Operation_AVP
    AVP_Header			aVP_Header,//<AVP header: 1021 ....>
    Bearer_Operation	aVP_Data
};*/
INT32_AVP_COMMON(Bearer_Operation_AVP)

/*type record Bearer_Usage_AVP{
//Ref: ETSI TS 129 212 Bearer_Usage_AVP
    AVP_Header			aVP_Header,//<AVP header: 1000 ....>
    Bearer_Usage		aVP_Data
};*/
INT32_AVP_COMMON(Bearer_Usage_AVP)

/*type record Charging_Correlation_Indicator_AVP{
//Ref: ETSI TS 129 212 Charging_Correlation_Indicator_AVP
    AVP_Header						aVP_Header,//<AVP header: 1073 ....>
    Charging_Correlation_Indicator	aVP_Data
};*/
INT32_AVP_COMMON(Charging_Correlation_Indicator_AVP)

/*type record CSG_Information_Reporting_AVP{
//Ref: ETSI TS 129 212 CSG_Information_Reporting_AVP
    AVP_Header						aVP_Header,//<AVP header: 1071 ....>
    CSG_Information_Reporting		aVP_Data
};*/
INT32_AVP_COMMON(CSG_Information_Reporting_AVP)

//TODO: cannot find a proper definition for tat in the standards
/*type record Experimental_Result_Code_AVP{
//	Ref: 3GPP TS 29.229	6.2 Result-Code AVP values
	AVP_Header         			aVP_Header,//<AVP header: 278 ....>
	Experimental_Result_Type    aVP_Data							
};*/
INT32_AVP_COMMON(Experimental_Result_Code_AVP)

/*type record Reservation_Priority_AVP{
//Ref: ETSI TS 183 017 Reservation_Priority AVP
	AVP_Header			aVP_Header,//<AVP header: 458 ....>
	Reservation_Priority_Type aVP_Data
}*/
INT32_AVP_COMMON(Reservation_Priority_AVP)

/*type record Redirect_Host_Usage_AVP{
//Ref: RFC3588 6.13.  Redirect-Host-Usage AVP
	AVP_Header         			aVP_Header,//<AVP header: 261 ....>
	Redirect_Host_Usage_Type	aVP_Data
};*/
INT32_AVP_COMMON(Redirect_Host_Usage_AVP)

/*type record Accounting_Record_Type_AVP{
//Ref: RFC3588 9.8.1.  Accounting-Record-Type AVP
	AVP_Header         	aVP_Header,//<AVP header: 480 ....>
	Acc_Record_Type  	aVP_Data
};*/
INT32_AVP_COMMON(Accounting_Record_Type_AVP)

/*type record Accounting_Realtime_Required_AVP{
//Ref: RFC3588 9.8.7.  Accounting-Realtime-Required AVP
	AVP_Header         		aVP_Header,//<AVP header: 483 ....>
	Acc_Realtime_Req_Type 	aVP_Data
};*/
INT32_AVP_COMMON(Accounting_Realtime_Required_AVP)

/*type record Termination_Cause_AVP{
//Ref: RFC3588 8.15.  Termination-Cause AVP
	AVP_Header         		aVP_Header,//<AVP header: 295 ....>
	Termination_Cause_Type	aVP_Data
};*/
INT32_AVP_COMMON(Termination_Cause_AVP)

/*type record Disconnect_Cause_AVP{
//Ref: RFC3588 5.4.3.  Disconnect-Cause AVP
	AVP_Header         		aVP_Header,//<AVP header: 273 ....>
	Disconnect_Cause_Type 	aVP_Data			
};*/
INT32_AVP_COMMON(Disconnect_Cause_AVP)

/*type record Auth_Session_State_AVP{
//	Ref: RFC3588  8.11.  Auth-Session-State AVP
	AVP_Header         		aVP_Header,//<AVP header: 277 ....>
	Auth_Session_State_Type aVP_Data
};*/
INT32_AVP_COMMON(Auth_Session_State_AVP)

/*type record SIP_User_Authorization_Type_AVP{
	//	Ref: RFC4740 9.10.  SIP-User-Authorization-Type AVP
	AVP_Header         		aVP_Header,//<AVP header: 387 ....>
	SIP_User_Auth_Ty_Type	aVP_Data
};*/
INT32_AVP_COMMON(SIP_User_Authorization_Type_AVP)

/*type record SIP_Server_Assignment_Type_AVP{
//Ref: RFC4740 9.4.  SIP-Server-Assignment-Type AVP
	AVP_Header         	aVP_Header,//<AVP header: 375 ....>
	SIP_Srv_Assgmt_Type aVP_Data
};*/
INT32_AVP_COMMON(SIP_Server_Assignment_Type_AVP)

/*type record SIP_Authentication_Scheme_AVP{
	//Ref: RFC4740 9.5.1.  SIP-Authentication-Scheme AVP
	AVP_Header         			aVP_Header,//<AVP header: 377 ....>
	SIP_Auth_Schm_Type			aVP_Data
};*/
INT32_AVP_COMMON(SIP_Authentication_Scheme_AVP)

/*type record SIP_User_Data_Already_Available_AVP{
//Ref: RFC4740 9.13.  SIP-User-Data-Already-Available AVP
	AVP_Header         		aVP_Header,//<AVP header: 392 ....>
	SIP_Usr_Dat_Al_Av_Type 	aVP_Data
};*/
INT32_AVP_COMMON(SIP_User_Data_Already_Available_AVP)

/*type record Direct_Debiting_Failure_Handling_AVP{
//	Ref: RFC4006 8.15.  Direct-Debiting-Failure-Handling AVP
	AVP_Header         			aVP_Header,//< AVP Header: 428 >
	Direct_Debi_Fail_Hand_Type	avp_Data
};*/
INT32_AVP_COMMON(Direct_Debiting_Failure_Handling_AVP)

/*type record Credit_Control_Failure_Handling_AVP{
//	Ref: RFC4006 8.14.  Credit-Control-Failure-Handling AVP
	AVP_Header         			aVP_Header,//< AVP Header: 427 >
	Credit_Cont_Fail_Hand_Type 	aVP_Data
};*/
INT32_AVP_COMMON(Credit_Control_Failure_Handling_AVP)

/*type record Check_Balance_Result_AVP{
//	Ref: RFC4006 8.6.  Check-Balance-Result AVP 12.8.  Check-Balance-Result AVP
	AVP_Header         				aVP_Header,//< AVP Header: 422 >				
	Check_Balance_Result_Type 		aVP_Data			
}*/
INT32_AVP_COMMON(Check_Balance_Result_AVP)

/*type record CC_Session_Failover_AVP{
//	Ref: RFC4006 8.4.  CC-Session-Failover AVP
	AVP_Header         			aVP_Header,//< AVP Header: 418 >				
	CC_Session_Failover_Type    aVP_Data			
};*/
INT32_AVP_COMMON(CC_Session_Failover_AVP)

/*type record User_Equipment_Info_Type_AVP{
//	Ref: RFC4006 8.50.  User-Equipment-Info-Type AVP
	AVP_Header         			aVP_Header,//< AVP Header: 459 >
	User_Equipment_Info_Ty_Type	aVP_Data
};*/
INT32_AVP_COMMON(User_Equipment_Info_Type_AVP)

/*type record Redirect_Address_Type_AVP{
//	Ref: RFC4006 8.38.  Redirect-Address-Type AVP
	AVP_Header         			aVP_Header,//< AVP Header: 433 >
	Redirect_Address_Ty_Type    aVP_Data			
};*/
INT32_AVP_COMMON(Redirect_Address_Type_AVP)

/*type record CC_Unit_Type_AVP{
//	Ref: RFC4006 8.32.  CC-Unit-Type AVP
	AVP_Header         			aVP_Header,//< AVP Header: 454 >
	CC_Unit_Ty_Type             aVP_Data
};*/
INT32_AVP_COMMON(CC_Unit_Type_AVP)

/*type record CC_Request_Type_AVP{
//	Ref: RFC4006 8.3.  CC-Request-Type AVP	
	AVP_Header         			aVP_Header,//<AVP header: 416 ....>	
	CC_Request_Ty_Type          aVP_Data			
};*/
INT32_AVP_COMMON(CC_Request_Type_AVP)

/*type record Multiple_Services_Indicator_AVP{
//	Ref: RFC4006 8.40.  Multiple-Services-Indicator AVP
	AVP_Header         			aVP_Header,//< AVP Header: 455 >
	Multiple_Serv_Indi_Type 	aVP_Data			
};*/
INT32_AVP_COMMON(Multiple_Services_Indicator_AVP)

/*type record Requested_Action_AVP{
//	Ref: RFC4006 8.41.  Requested-Action AVP
	AVP_Header         			aVP_Header,//< AVP Header: 436 >
	Requested_Action_Type       avp_data
};*/
INT32_AVP_COMMON(Requested_Action_AVP)

/*type record Send_Data_Indication_AVP{
//	Ref: 3GPP TS 29.329	6.3.17 Send-Data-Indication AVP	
	AVP_Header         			aVP_Header,//<AVP header: 710 ....>	
	Send_Data_Indication_Type  	aVP_Data						
};*/
INT32_AVP_COMMON(Send_Data_Indication_AVP)

/*type record Identity_Set_AVP{
//	Ref: 3GPP TS 29.329	6.3.10 Identity-Set AVP	
	AVP_Header         			aVP_Header,//<AVP header: 708 ....>	
	Identity_Set_Type  			aVP_Data						
};*/
INT32_AVP_COMMON(Identity_Set_AVP)

/*type record Current_Location_AVP{
//	Ref: 3GPP TS 29.329	6.3.8 Current-Location AVP
	AVP_Header         			aVP_Header,//<AVP header: 707 ....>	
	Current_Location_Type  		aVP_Data						
};*/
INT32_AVP_COMMON(Current_Location_AVP)

/*type record Requested_Domain_AVP{			
//	Ref: 3GPP TS 29.329	6.3.7 Requested-Domain AVP
	AVP_Header         			aVP_Header,//<AVP header: 706 ....>			
	Request_Domain_Type			aVP_Data
};*/
INT32_AVP_COMMON(Requested_Domain_AVP)

/*type record Subs_Req_Type_AVP{			
//	Ref: 3GPP TS 29.329	6.3.6 Subs-Req-Type AVP
	AVP_Header         			aVP_Header,//<AVP header: 705 ....>			
	Subs_Req_Ty_Type      		aVP_Data			
};*/
INT32_AVP_COMMON(Subs_Req_Type_AVP)

/*type record Data_Reference_AVP{
//	Ref: 3GPP TS 29.3296.3.4 Data-Reference AVP
	AVP_Header         			aVP_Header,//<AVP header: 703 ....>
	Data_Reference_Type         aVP_Data
};*/
INT32_AVP_COMMON(Data_Reference_AVP)

/*type record SIP_Reason_Code_AVP{
// Ref: RFC4740 .7.1.  SIP-Reason-Code AVP
	AVP_Header         			aVP_Header,//<AVP header: 384 ....>
	SIP_Reason_Code_Type		aVP_Data
};*/
INT32_AVP_COMMON(SIP_Reason_Code_AVP)

/*type record Flow_Usage_AVP{
//Ref: ETSI TS 129 214 Flow_Usage AVP
	AVP_Header			aVP_Header,//<AVP header: 512 ....>
	Flow_Usage_Type	aVP_Data
};*/
INT32_AVP_COMMON(Flow_Usage_AVP)

///////////////////////////////////////////////////////
////////  UINT32 as ENUMERATED AVPs  //////////////////
///////////////////////////////////////////////////////

/*type record Result_Code_AVP{
//Ref: RFC3588 7.1.  Result-Code AVP
	AVP_Header         	aVP_Header,//<AVP header: 268 ....>
	//UInt32
	Result_Code_Type 				aVP_Data		
};*/
UINT32_AVP_COMMON(Result_Code_AVP)

/*type record Specific_Action_AVP{
 //Ref: ETSI TS 129 214 Specific_Action AVP
     AVP_Header			aVP_Header,//<AVP header: 513 ....>
     Specific_Action_Type	aVP_Data
 }; */
UINT32_AVP_COMMON(Specific_Action_AVP)

/*type record Re_Auth_Request_Type_AVP{
//Ref: RFC3588 8.12.  Re-Auth-Request-Type AVP
	AVP_Header         	aVP_Header,//<AVP header: 285 ....>
	Re_Auth_Req_Type 	aVP_Data						
};*/
UINT32_AVP_COMMON(Re_Auth_Request_Type_AVP)

/*type record Final_Unit_Action_AVP{
//	Ref: RFC4006 8.35.  Final-Unit-Action AVP
	AVP_Header         			aVP_Header,//< AVP Header: 449 >
	Final_Unit_Action_Type		aVP_Data							
};*/
UINT32_AVP_COMMON(Final_Unit_Action_AVP)

/*type record Flow_Status_AVP{
//Ref: ETSI TS 129 214 Flow_Status AVP
    AVP_Header			aVP_Header,//<AVP header: 511 ...>
    Flow_Status_Type	aVP_Data
};*/
UINT32_AVP_COMMON(Flow_Status_AVP)



///////////////////////////////////////////////////////
///////////////  INT64, UINT64 AVPs  //////////////////
///////////////////////////////////////////////////////

#define INT64_AVP_COMMON(type) \
	void type::PreDecode(Buffer& buffer) throw (DecodeError)\
	{\
		debug_log_PreDecode(#type);\
	}

#define UINT64_AVP_COMMON(type) \
	void type::PreDecode(Buffer& buffer) throw (DecodeError)\
	{\
		debug_log_PreDecode(#type);\
	}

/*type record Value_Digits_AVP{
//	Ref: RFC4006 8.10.  Value-Digits AVP
	AVP_Header         			aVP_Header,//< AVP Header: 447 >
	Int64                  		aVP_Data				
};*/
INT64_AVP_COMMON(Value_Digits_AVP)

/*type record CC_Total_Octets_AVP{
//	Ref: RFC4006 8.23.  CC-Total-Octets AVP
	AVP_Header         			aVP_Header,//< AVP Header: 421 >
	UInt64                  	aVP_Data							
};*/
UINT64_AVP_COMMON(CC_Total_Octets_AVP)

/*type record CC_Input_Octets_AVP{
//	Ref: RFC4006 8.24.  CC-Input-Octets AVP
	AVP_Header         			aVP_Header,//< AVP Header: 412 >
	UInt64                  	aVP_Data											
};*/
UINT64_AVP_COMMON(CC_Input_Octets_AVP)

/*type record CC_Output_Octets_AVP{
//	Ref: RFC4006 8.25.  CC-Output-Octets AVP
	AVP_Header         			aVP_Header,//< AVP Header: 414 >
	UInt64                  	aVP_Data											
};*/
UINT64_AVP_COMMON(CC_Output_Octets_AVP)

/*type record CC_Service_Specific_Units_AVP{
//	Ref: RFC4006 8.26.  CC-Service-Specific-Units AVP
	AVP_Header         			aVP_Header,//< AVP Header: 417 >
	UInt64                  	aVP_Data								
};*/
UINT64_AVP_COMMON(CC_Service_Specific_Units_AVP)

/*type record Accounting_Sub_Session_Id_AVP{
//Ref: RFC3588 9.8.6.  Accounting-Sub-Session-Id AVP
	AVP_Header         	aVP_Header,//<AVP header: 287 ....>
	UInt64				aVP_Data			
};*/
UINT64_AVP_COMMON(Accounting_Sub_Session_Id_AVP)

/*type record CC_Sub_Session_Id_AVP{
//	Ref: RFC4006 8.5.  CC-Sub-Session-Id AVP
	AVP_Header         			aVP_Header,//<AVP header: 419 ....>
	UInt64                  	aVP_Data								
};*/
UINT64_AVP_COMMON(CC_Sub_Session_Id_AVP)

///////////////////////////////////////////////////////
////////////////  SET OF AVPs  ////////////////////////
///////////////////////////////////////////////////////
//common code for all set_of_*AVP types
/*#define SET_OF_AVP_COMMON_PreDecode(type, avp_id) \
	void type::PreDecode(Buffer& buffer) throw (DecodeError)\
	{\
		debug_log_PreDecode(#type);\
		int nStartingPos = buffer.GetPosition();\
		Unsigned code(32);\
		code.Decode(buffer);\
		unsigned int nCode = code.GetValue();\
		if(nCode == avp_id)\
			SetHypSize(1);\
		else\
			SetHypSize(0);\
		buffer.SetPosition(nStartingPos);\
	}

#define SET_OF_AVP_COMMON_PostDecodeField(type, avp_id) \
	void type::PostDecodeField(int id, Buffer& buffer) throw (DecodeError)\
	{\
		debug_log_PostDecodeField(#type, id);\
		int nStartingPos = buffer.GetPosition();\
		Unsigned code(32);\
		code.Decode(buffer);\
		unsigned int nCode = code.GetValue();\
		if(nCode == avp_id)\
			SetHypSize(GetSize() + 1);\
		buffer.SetPosition(nStartingPos);\
	}
*/
#define SET_OF_AVP_COMMON_PreDecode(type, avp_id) \
	void type::PreDecode(Buffer& buffer) throw (DecodeError)\
	{\
		debug_log_PreDecode(#type);\
		SetHypSize(m_lAVP_Offsets.size());\
		if(m_lAVP_Offsets.size() > 0)	\
			buffer.SetPosition(m_lAVP_Offsets.at(0)); \
	}

#define SET_OF_AVP_COMMON_PostDecodeField(type, avp_id) \
	void type::PostDecodeField(int id, Buffer& buffer) throw (DecodeError)\
	{\
		debug_log_PostDecodeField(#type, id);\
		if(m_lAVP_Offsets.size() > (id + 1))	\
			buffer.SetPosition(m_lAVP_Offsets.at(id+1));	\
	}

#define SET_OF_AVP_COMMON_SetOffsets(type, avp_id) \
	void type::SetOffsets(std::vector<unsigned int> &lAVP_Codes, std::vector<unsigned int> &lOffsets)	\
	{	\
		for(int i=0; i < lAVP_Codes.size(); i++)	\
		{	\
			if(lAVP_Codes.at(i) == avp_id)	\
			{	\
				m_lAVP_Offsets.push_back(lOffsets.at(i));	\
				lAVP_Codes[i] = AVP_CODE_NOT_IN_USE;	\
			}	\
		}	\
	}

//type set of Auth_Application_Id_AVP set_of_Auth_Application_Id_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Auth_Application_Id_AVP, AVP_CODE_Auth_Application_Id)
SET_OF_AVP_COMMON_PreDecode(set_of_Auth_Application_Id_AVP, AVP_CODE_Auth_Application_Id)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Auth_Application_Id_AVP, AVP_CODE_Auth_Application_Id)

//type set of Supported_Vendor_Id_AVP set_of_Supported_Vendor_Id_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Supported_Vendor_Id_AVP, AVP_CODE_Supported_Vendor_Id)
SET_OF_AVP_COMMON_PreDecode(set_of_Supported_Vendor_Id_AVP, AVP_CODE_Supported_Vendor_Id)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Supported_Vendor_Id_AVP, AVP_CODE_Supported_Vendor_Id)

//type set of Origin_State_Id_AVP set_of_Origin_State_Id_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Origin_State_Id_AVP, AVP_CODE_Origin_State_Id)
SET_OF_AVP_COMMON_PreDecode(set_of_Origin_State_Id_AVP, AVP_CODE_Origin_State_Id)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Origin_State_Id_AVP, AVP_CODE_Origin_State_Id)

//type set of Host_IP_Address_AVP set_of_Host_IP_Address_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Host_IP_Address_AVP, AVP_CODE_Host_IP_Address)
SET_OF_AVP_COMMON_PreDecode(set_of_Host_IP_Address_AVP, AVP_CODE_Host_IP_Address)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Host_IP_Address_AVP, AVP_CODE_Host_IP_Address)

//type set of Inband_Security_Id_AVP set_of_Inband_Security_Id_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Inband_Security_Id_AVP, AVP_CODE_Inband_Security_Id)
SET_OF_AVP_COMMON_PreDecode(set_of_Inband_Security_Id_AVP, AVP_CODE_Inband_Security_Id)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Inband_Security_Id_AVP, AVP_CODE_Inband_Security_Id)

//type set of Acct_Application_Id_AVP set_of_Acct_Application_Id_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Acct_Application_Id_AVP, AVP_CODE_Acct_Application_Id)
SET_OF_AVP_COMMON_PreDecode(set_of_Acct_Application_Id_AVP, AVP_CODE_Acct_Application_Id)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Acct_Application_Id_AVP, AVP_CODE_Acct_Application_Id)

//type set of Vendor_Specific_Appl_Id_AVP set_of_Vendor_Specific_Appl_Id_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Vendor_Specific_Appl_Id_AVP, AVP_CODE_Vendor_Specific_Application_Id)
SET_OF_AVP_COMMON_PreDecode(set_of_Vendor_Specific_Appl_Id_AVP, AVP_CODE_Vendor_Specific_Application_Id)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Vendor_Specific_Appl_Id_AVP, AVP_CODE_Vendor_Specific_Application_Id)

//type set of Vendor_Id_AVP set_of_Vendor_Id_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Vendor_Id_AVP, AVP_CODE_Vendor_Id)
SET_OF_AVP_COMMON_PreDecode(set_of_Vendor_Id_AVP, AVP_CODE_Vendor_Id)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Vendor_Id_AVP, AVP_CODE_Vendor_Id)

//type set of Failed_AVP set_of_Failed_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Failed_AVP, AVP_CODE_Failed_AVP)
SET_OF_AVP_COMMON_PreDecode(set_of_Failed_AVP, AVP_CODE_Failed_AVP)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Failed_AVP, AVP_CODE_Failed_AVP)

//type set of Flow_Number_AVP set_of_Flow_Number_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Flow_Number_AVP, AVP_CODE_Flow_Number)
SET_OF_AVP_COMMON_PreDecode(set_of_Flow_Number_AVP, AVP_CODE_Flow_Number)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Flow_Number_AVP, AVP_CODE_Flow_Number)

//type set of Flows_AVP set_of_Flows_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Flows_AVP, AVP_CODE_Flows)
SET_OF_AVP_COMMON_PreDecode(set_of_Flows_AVP, AVP_CODE_Flows)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Flows_AVP, AVP_CODE_Flows)

//type set of Access_Network_Charging_Identifier_AVP set_of_Access_Network_Charging_Identifier_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Access_Network_Charging_Identifier_AVP, AVP_CODE_Access_Network_Charging_Identifier)
SET_OF_AVP_COMMON_PreDecode(set_of_Access_Network_Charging_Identifier_AVP, AVP_CODE_Access_Network_Charging_Identifier)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Access_Network_Charging_Identifier_AVP, AVP_CODE_Access_Network_Charging_Identifier)

//type set of Subscription_Id_AVP set_of_Subscription_Id_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Subscription_Id_AVP, AVP_CODE_Subscription_Id)
SET_OF_AVP_COMMON_PreDecode(set_of_Subscription_Id_AVP, AVP_CODE_Subscription_Id)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Subscription_Id_AVP, AVP_CODE_Subscription_Id)

//type set of Class_AVP set_of_Class_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Class_AVP, AVP_CODE_Class)
SET_OF_AVP_COMMON_PreDecode(set_of_Class_AVP, AVP_CODE_Class)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Class_AVP, AVP_CODE_Class)

//type set of Event_Trigger_AVP set_of_Event_Trigger_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Event_Trigger_AVP, AVP_CODE_Event_Trigger)
SET_OF_AVP_COMMON_PreDecode(set_of_Event_Trigger_AVP, AVP_CODE_Event_Trigger)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Event_Trigger_AVP, AVP_CODE_Event_Trigger)

//type set of Cell_Global_Identity_AVP set_of_Cell_Global_Identity_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Cell_Global_Identity_AVP, AVP_CODE_Cell_Global_Identity)
SET_OF_AVP_COMMON_PreDecode(set_of_Cell_Global_Identity_AVP, AVP_CODE_Cell_Global_Identity)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Cell_Global_Identity_AVP, AVP_CODE_Cell_Global_Identity)

//type set of E_UTRAN_Cell_Global_Identity_AVP set_of_E_UTRAN_Cell_Global_Identity_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_E_UTRAN_Cell_Global_Identity_AVP, AVP_CODE_E_UTRAN_Cell_Global_Identity)
SET_OF_AVP_COMMON_PreDecode(set_of_E_UTRAN_Cell_Global_Identity_AVP, AVP_CODE_E_UTRAN_Cell_Global_Identity)
SET_OF_AVP_COMMON_PostDecodeField(set_of_E_UTRAN_Cell_Global_Identity_AVP, AVP_CODE_E_UTRAN_Cell_Global_Identity)

//type set of Routing_Area_Identity_AVP set_of_Routing_Area_Identity_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Routing_Area_Identity_AVP, AVP_CODE_Routing_Area_Identity)
SET_OF_AVP_COMMON_PreDecode(set_of_Routing_Area_Identity_AVP, AVP_CODE_Routing_Area_Identity)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Routing_Area_Identity_AVP, AVP_CODE_Routing_Area_Identity)

//type set of Location_Area_Identity_AVP set_of_Location_Area_Identity_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Location_Area_Identity_AVP, AVP_CODE_Location_Area_Identity)
SET_OF_AVP_COMMON_PreDecode(set_of_Location_Area_Identity_AVP, AVP_CODE_Location_Area_Identity)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Location_Area_Identity_AVP, AVP_CODE_Location_Area_Identity)

//type set of Tracking_Area_Identity_AVP set_of_Tracking_Area_Identity_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Tracking_Area_Identity_AVP, AVP_CODE_Tracking_Area_Identity)
SET_OF_AVP_COMMON_PreDecode(set_of_Tracking_Area_Identity_AVP, AVP_CODE_Tracking_Area_Identity)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Tracking_Area_Identity_AVP, AVP_CODE_Tracking_Area_Identity)

//type set of Charging_Rule_Name_AVP set_of_Charging_Rule_Name_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Charging_Rule_Name_AVP, AVP_CODE_Charging_Rule_Name)
SET_OF_AVP_COMMON_PreDecode(set_of_Charging_Rule_Name_AVP, AVP_CODE_Charging_Rule_Name)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Charging_Rule_Name_AVP, AVP_CODE_Charging_Rule_Name)

//type set of Charging_Rule_Base_Name_AVP set_of_Charging_Rule_Base_Name_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Charging_Rule_Base_Name_AVP, AVP_CODE_Charging_Rule_Base_Name)
SET_OF_AVP_COMMON_PreDecode(set_of_Charging_Rule_Base_Name_AVP, AVP_CODE_Charging_Rule_Base_Name)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Charging_Rule_Base_Name_AVP, AVP_CODE_Charging_Rule_Base_Name)

//type set of Charging_Rule_Remove_AVP set_of_Charging_Rule_Remove_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Charging_Rule_Remove_AVP, AVP_CODE_Charging_Rule_Remove)
SET_OF_AVP_COMMON_PreDecode(set_of_Charging_Rule_Remove_AVP, AVP_CODE_Charging_Rule_Remove)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Charging_Rule_Remove_AVP, AVP_CODE_Charging_Rule_Remove)

//type set of Flow_Information_AVP set_of_Flow_Information_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Flow_Information_AVP, AVP_CODE_Flow_Information)
SET_OF_AVP_COMMON_PreDecode(set_of_Flow_Information_AVP, AVP_CODE_Flow_Information)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Flow_Information_AVP, AVP_CODE_Flow_Information)

//type set of Charging_Rule_Definition_AVP set_of_Charging_Rule_Definition_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Charging_Rule_Definition_AVP, AVP_CODE_Charging_Rule_Definition)
SET_OF_AVP_COMMON_PreDecode(set_of_Charging_Rule_Definition_AVP, AVP_CODE_Charging_Rule_Definition)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Charging_Rule_Definition_AVP, AVP_CODE_Charging_Rule_Definition)

//type set of Charging_Rule_Install_AVP set_of_Charging_Rule_Install_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Charging_Rule_Install_AVP, AVP_CODE_Charging_Rule_Install)
SET_OF_AVP_COMMON_PreDecode(set_of_Charging_Rule_Install_AVP, AVP_CODE_Charging_Rule_Install)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Charging_Rule_Install_AVP, AVP_CODE_Charging_Rule_Install)

//type set of QoS_Information_AVP set_of_QoS_Information_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_QoS_Information_AVP, AVP_CODE_QoS_Information)
SET_OF_AVP_COMMON_PreDecode(set_of_QoS_Information_AVP, AVP_CODE_QoS_Information)
SET_OF_AVP_COMMON_PostDecodeField(set_of_QoS_Information_AVP, AVP_CODE_QoS_Information)

//type set of Usage_Monitoring_Information_AVP set_of_Usage_Monitoring_Information_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Usage_Monitoring_Information_AVP, AVP_CODE_Usage_Monitoring_Information)
SET_OF_AVP_COMMON_PreDecode(set_of_Usage_Monitoring_Information_AVP, AVP_CODE_Usage_Monitoring_Information)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Usage_Monitoring_Information_AVP, AVP_CODE_Usage_Monitoring_Information)

//type set of Proxy_Info_AVP set_of_Proxy_Info_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Proxy_Info_AVP, AVP_CODE_Proxy_Info)
SET_OF_AVP_COMMON_PreDecode(set_of_Proxy_Info_AVP, AVP_CODE_Proxy_Info)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Proxy_Info_AVP, AVP_CODE_Proxy_Info)

//type set of Route_Record_AVP set_of_Route_Record_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Route_Record_AVP, AVP_CODE_Route_Record)
SET_OF_AVP_COMMON_PreDecode(set_of_Route_Record_AVP, AVP_CODE_Route_Record)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Route_Record_AVP, AVP_CODE_Route_Record)

//type set of Codec_Data_AVP set_of_Codec_Data_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Codec_Data_AVP, AVP_CODE_Codec_Data)
SET_OF_AVP_COMMON_PreDecode(set_of_Codec_Data_AVP, AVP_CODE_Codec_Data)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Codec_Data_AVP, AVP_CODE_Codec_Data)

//type set of Media_Component_Description_AVP set_of_Media_Component_Description_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Media_Component_Description_AVP, AVP_CODE_Media_Component_Description)
SET_OF_AVP_COMMON_PreDecode(set_of_Media_Component_Description_AVP, AVP_CODE_Media_Component_Description)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Media_Component_Description_AVP, AVP_CODE_Media_Component_Description)

//type set of Redirect_Host_AVP set_of_Redirect_Host_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Redirect_Host_AVP, AVP_CODE_Redirect_Host)
SET_OF_AVP_COMMON_PreDecode(set_of_Redirect_Host_AVP, AVP_CODE_Redirect_Host)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Redirect_Host_AVP, AVP_CODE_Redirect_Host)

//type set of CSG_Information_Reporting_AVP set_of_CSG_Information_Reporting_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_CSG_Information_Reporting_AVP, AVP_CODE_CSG_Information_Reporting)
SET_OF_AVP_COMMON_PreDecode(set_of_CSG_Information_Reporting_AVP, AVP_CODE_CSG_Information_Reporting)
SET_OF_AVP_COMMON_PostDecodeField(set_of_CSG_Information_Reporting_AVP, AVP_CODE_CSG_Information_Reporting)

//type set of Multiple_Services_Credit_Control_AVP set_of_Multiple_Services_Credit_Control_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Multiple_Services_Credit_Control_AVP, AVP_CODE_Multiple_Services_Credit_Control)
SET_OF_AVP_COMMON_PreDecode(set_of_Multiple_Services_Credit_Control_AVP, AVP_CODE_Multiple_Services_Credit_Control)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Multiple_Services_Credit_Control_AVP, AVP_CODE_Multiple_Services_Credit_Control)

//type set of Service_Parameter_Info_AVP set_of_Service_Parameter_Info_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Service_Parameter_Info_AVP, AVP_CODE_Service_Parameter_Info)
SET_OF_AVP_COMMON_PreDecode(set_of_Service_Parameter_Info_AVP, AVP_CODE_Service_Parameter_Info)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Service_Parameter_Info_AVP, AVP_CODE_Service_Parameter_Info)

//type set of Packet_Filter_Information_AVP set_of_Packet_Filter_Information_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Packet_Filter_Information_AVP, AVP_CODE_Packet_Filter_Information)
SET_OF_AVP_COMMON_PreDecode(set_of_Packet_Filter_Information_AVP, AVP_CODE_Packet_Filter_Information)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Packet_Filter_Information_AVP, AVP_CODE_Packet_Filter_Information)

//type set of TFT_Packet_Filter_Information_AVP set_of_TFT_Packet_Filter_Information_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_TFT_Packet_Filter_Information_AVP, AVP_CODE_TFT_Packet_Filter_Information)
SET_OF_AVP_COMMON_PreDecode(set_of_TFT_Packet_Filter_Information_AVP, AVP_CODE_TFT_Packet_Filter_Information)
SET_OF_AVP_COMMON_PostDecodeField(set_of_TFT_Packet_Filter_Information_AVP, AVP_CODE_TFT_Packet_Filter_Information)

//type set of Access_Network_Charging_Identifier_Gx_AVP set_of_Access_Network_Charging_Identifier_Gx_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Access_Network_Charging_Identifier_Gx_AVP, AVP_CODE_Access_Network_Charging_Identifier_Gx)
SET_OF_AVP_COMMON_PreDecode(set_of_Access_Network_Charging_Identifier_Gx_AVP, AVP_CODE_Access_Network_Charging_Identifier_Gx)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Access_Network_Charging_Identifier_Gx_AVP, AVP_CODE_Access_Network_Charging_Identifier_Gx)

//type set of CoA_Information_AVP set_of_CoA_Information_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_CoA_Information_AVP, AVP_CODE_CoA_Information)
SET_OF_AVP_COMMON_PreDecode(set_of_CoA_Information_AVP, AVP_CODE_CoA_Information)
SET_OF_AVP_COMMON_PostDecodeField(set_of_CoA_Information_AVP, AVP_CODE_CoA_Information)

//type set of Service_Indication_AVP set_of_Service_Indication_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Service_Indication_AVP, AVP_CODE_Service_Indication)
SET_OF_AVP_COMMON_PreDecode(set_of_Service_Indication_AVP, AVP_CODE_Service_Indication)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Service_Indication_AVP, AVP_CODE_Service_Indication)

//type set of Data_Reference_AVP set_of_Data_Reference_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Data_Reference_AVP, AVP_CODE_Data_Reference)
SET_OF_AVP_COMMON_PreDecode(set_of_Data_Reference_AVP, AVP_CODE_Data_Reference)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Data_Reference_AVP, AVP_CODE_Data_Reference)

//type set of Identity_Set_AVP set_of_Identity_Set_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Identity_Set_AVP, AVP_CODE_Identity_Set)
SET_OF_AVP_COMMON_PreDecode(set_of_Identity_Set_AVP, AVP_CODE_Identity_Set)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Identity_Set_AVP, AVP_CODE_Identity_Set)

//type set of DSAI_Tag_AVP set_of_DSAI_Tag_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_DSAI_Tag_AVP, AVP_CODE_DSAI_Tag)
SET_OF_AVP_COMMON_PreDecode(set_of_DSAI_Tag_AVP, AVP_CODE_DSAI_Tag)
SET_OF_AVP_COMMON_PostDecodeField(set_of_DSAI_Tag_AVP, AVP_CODE_DSAI_Tag)

//type set of SIP_Auth_Data_Item_AVP set_of_SIP_Auth_Data_Item_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_SIP_Auth_Data_Item_AVP, AVP_CODE_SIP_Auth_Data_Item)
SET_OF_AVP_COMMON_PreDecode(set_of_SIP_Auth_Data_Item_AVP, AVP_CODE_SIP_Auth_Data_Item)
SET_OF_AVP_COMMON_PostDecodeField(set_of_SIP_Auth_Data_Item_AVP, AVP_CODE_SIP_Auth_Data_Item)

//type set of SIP_User_Data_AVP set_of_SIP_User_Data_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_SIP_User_Data_AVP, AVP_CODE_SIP_User_Data)
SET_OF_AVP_COMMON_PreDecode(set_of_SIP_User_Data_AVP, AVP_CODE_SIP_User_Data)
SET_OF_AVP_COMMON_PostDecodeField(set_of_SIP_User_Data_AVP, AVP_CODE_SIP_User_Data)

//type set of SIP_Supported_User_Data_Type_AVP set_of_SIP_Supported_User_Data_Type_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_SIP_Supported_User_Data_Type_AVP, AVP_CODE_SIP_Supported_User_Data_Type)
SET_OF_AVP_COMMON_PreDecode(set_of_SIP_Supported_User_Data_Type_AVP, AVP_CODE_SIP_Supported_User_Data_Type)
SET_OF_AVP_COMMON_PostDecodeField(set_of_SIP_Supported_User_Data_Type_AVP, AVP_CODE_SIP_Supported_User_Data_Type)

//type set of SIP_AOR_AVP set_of_SIP_AOR_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_SIP_AOR_AVP, AVP_CODE_SIP_AOR)
SET_OF_AVP_COMMON_PreDecode(set_of_SIP_AOR_AVP, AVP_CODE_SIP_AOR)
SET_OF_AVP_COMMON_PostDecodeField(set_of_SIP_AOR_AVP, AVP_CODE_SIP_AOR)

//type set of Supported_Features_AVP set_of_Supported_Features_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Supported_Features_AVP, AVP_CODE_Supported_Features)
SET_OF_AVP_COMMON_PreDecode(set_of_Supported_Features_AVP, AVP_CODE_Supported_Features)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Supported_Features_AVP, AVP_CODE_Supported_Features)

//type set of Charging_Rule_Report_AVP set_of_Charging_Rule_Report_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Charging_Rule_Report_AVP, AVP_CODE_Charging_Rule_Report)
SET_OF_AVP_COMMON_PreDecode(set_of_Charging_Rule_Report_AVP, AVP_CODE_Charging_Rule_Report)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Charging_Rule_Report_AVP, AVP_CODE_Charging_Rule_Report)

//type set of Routing_Rule_Identifier_AVP set_of_Routing_Rule_Identifier_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Routing_Rule_Identifier_AVP, AVP_CODE_Routing_Rule_Identifier)
SET_OF_AVP_COMMON_PreDecode(set_of_Routing_Rule_Identifier_AVP, AVP_CODE_Routing_Rule_Identifier)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Routing_Rule_Identifier_AVP, AVP_CODE_Routing_Rule_Identifier)

//type set of Routing_Rule_Definition_AVP set_of_Routing_Rule_Definition_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Routing_Rule_Definition_AVP, AVP_CODE_Routing_Rule_Definition)
SET_OF_AVP_COMMON_PreDecode(set_of_Routing_Rule_Definition_AVP, AVP_CODE_Routing_Rule_Definition)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Routing_Rule_Definition_AVP, AVP_CODE_Routing_Rule_Definition)

//type set of Routing_Filter_AVP set_of_Routing_Filter_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Routing_Filter_AVP, AVP_CODE_Routing_Filter)
SET_OF_AVP_COMMON_PreDecode(set_of_Routing_Filter_AVP, AVP_CODE_Routing_Filter)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Routing_Filter_AVP, AVP_CODE_Routing_Filter)

//type set of Specific_Action_AVP set_of_Specific_Action_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Specific_Action_AVP, AVP_CODE_Specific_Action)
SET_OF_AVP_COMMON_PreDecode(set_of_Specific_Action_AVP, AVP_CODE_Specific_Action)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Specific_Action_AVP, AVP_CODE_Specific_Action)

//type set of Media_Sub_Component_AVP set_of_Media_Sub_Component_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Media_Sub_Component_AVP, AVP_CODE_Media_Sub_Component)
SET_OF_AVP_COMMON_PreDecode(set_of_Media_Sub_Component_AVP, AVP_CODE_Media_Sub_Component)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Media_Sub_Component_AVP, AVP_CODE_Media_Sub_Component)

//type set of Used_Service_Unit_AVP set_of_Used_Service_Unit_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Used_Service_Unit_AVP, AVP_CODE_Used_Service_Unit)
SET_OF_AVP_COMMON_PreDecode(set_of_Used_Service_Unit_AVP, AVP_CODE_Used_Service_Unit)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Used_Service_Unit_AVP, AVP_CODE_Used_Service_Unit)

//type set of Service_Identifier_AVP set_of_Service_Identifier_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Service_Identifier_AVP, AVP_CODE_Service_Identifier)
SET_OF_AVP_COMMON_PreDecode(set_of_Service_Identifier_AVP, AVP_CODE_Service_Identifier)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Service_Identifier_AVP, AVP_CODE_Service_Identifier)

//type set of G_S_U_Pool_Reference_AVP set_of_G_S_U_Pool_Reference_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_G_S_U_Pool_Reference_AVP, AVP_CODE_G_S_U_Pool_Reference)
SET_OF_AVP_COMMON_PreDecode(set_of_G_S_U_Pool_Reference_AVP, AVP_CODE_G_S_U_Pool_Reference)
SET_OF_AVP_COMMON_PostDecodeField(set_of_G_S_U_Pool_Reference_AVP, AVP_CODE_G_S_U_Pool_Reference)

//type set of Restriction_Filter_Rule_AVP set_of_Restriction_Filter_Rule_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Restriction_Filter_Rule_AVP, AVP_CODE_Restriction_Filter_Rule)
SET_OF_AVP_COMMON_PreDecode(set_of_Restriction_Filter_Rule_AVP, AVP_CODE_Restriction_Filter_Rule)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Restriction_Filter_Rule_AVP, AVP_CODE_Restriction_Filter_Rule)

//type set of Filter_Id_AVP set_of_Filter_Id_AVP; 
SET_OF_AVP_COMMON_SetOffsets(set_of_Filter_Id_AVP, AVP_CODE_Filter_Id)
SET_OF_AVP_COMMON_PreDecode(set_of_Filter_Id_AVP, AVP_CODE_Filter_Id)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Filter_Id_AVP, AVP_CODE_Filter_Id)

//type set of Digest_Auth_Param_AVP set_of_Digest_Auth_Param_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_Digest_Auth_Param_AVP, AVP_CODE_Digest_Auth_Param)
SET_OF_AVP_COMMON_PreDecode(set_of_Digest_Auth_Param_AVP, AVP_CODE_Digest_Auth_Param)
SET_OF_AVP_COMMON_PostDecodeField(set_of_Digest_Auth_Param_AVP, AVP_CODE_Digest_Auth_Param)

//type set of SIP_Accounting_Server_URI_AVP set_of_SIP_Accounting_Server_URI_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_SIP_Accounting_Server_URI_AVP, AVP_CODE_SIP_Accounting_Server_URI)
SET_OF_AVP_COMMON_PreDecode(set_of_SIP_Accounting_Server_URI_AVP, AVP_CODE_SIP_Accounting_Server_URI)
SET_OF_AVP_COMMON_PostDecodeField(set_of_SIP_Accounting_Server_URI_AVP, AVP_CODE_SIP_Accounting_Server_URI)

//type set of SIP_Credit_Control_Server_URI_AVP set_of_SIP_Credit_Control_Server_URI_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_SIP_Credit_Control_Server_URI_AVP, AVP_CODE_SIP_Credit_Control_Server_URI)
SET_OF_AVP_COMMON_PreDecode(set_of_SIP_Credit_Control_Server_URI_AVP, AVP_CODE_SIP_Credit_Control_Server_URI)
SET_OF_AVP_COMMON_PostDecodeField(set_of_SIP_Credit_Control_Server_URI_AVP, AVP_CODE_SIP_Credit_Control_Server_URI)

//type set of SIP_MandatoryCapability_AVP set_of_SIP_MandatoryCapability_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_SIP_MandatoryCapability_AVP, AVP_CODE_SIP_MandatoryCapability)
SET_OF_AVP_COMMON_PreDecode(set_of_SIP_MandatoryCapability_AVP, AVP_CODE_SIP_MandatoryCapability)
SET_OF_AVP_COMMON_PostDecodeField(set_of_SIP_MandatoryCapability_AVP, AVP_CODE_SIP_MandatoryCapability)

//type set of SIP_OptionalCapability_AVP set_of_SIP_OptionalCapability_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_SIP_OptionalCapability_AVP, AVP_CODE_SIP_OptionalCapability)
SET_OF_AVP_COMMON_PreDecode(set_of_SIP_OptionalCapability_AVP, AVP_CODE_SIP_OptionalCapability)
SET_OF_AVP_COMMON_PostDecodeField(set_of_SIP_OptionalCapability_AVP, AVP_CODE_SIP_OptionalCapability)

//type set of SIP_Server_URI_AVP set_of_SIP_Server_URI_AVP;
SET_OF_AVP_COMMON_SetOffsets(set_of_SIP_Server_URI_AVP, AVP_CODE_SIP_Server_URI)
SET_OF_AVP_COMMON_PreDecode(set_of_SIP_Server_URI_AVP, AVP_CODE_SIP_Server_URI)
SET_OF_AVP_COMMON_PostDecodeField(set_of_SIP_Server_URI_AVP, AVP_CODE_SIP_Server_URI)

////////////////////////////////////////////////////////
////////////////  record of sub  ///////////////////////
////////////////////////////////////////////////////////
//type record length (0..2) of AN_GW_Address_AVP record_of_AN_GW_Address_AVP;
SET_OF_AVP_COMMON_SetOffsets(record_of_AN_GW_Address_AVP, AVP_CODE_AN_GW_Address)
SET_OF_AVP_COMMON_PreDecode(record_of_AN_GW_Address_AVP, AVP_CODE_AN_GW_Address)
SET_OF_AVP_COMMON_PostDecodeField(record_of_AN_GW_Address_AVP, AVP_CODE_AN_GW_Address)

//type record length (0..2) of Flow_Description_AVP record_of_Flow_Description_AVP;
SET_OF_AVP_COMMON_SetOffsets(record_of_Flow_Description_AVP, AVP_CODE_Flow_Description)
SET_OF_AVP_COMMON_PreDecode(record_of_Flow_Description_AVP, AVP_CODE_Flow_Description)
SET_OF_AVP_COMMON_PostDecodeField(record_of_Flow_Description_AVP, AVP_CODE_Flow_Description)

//type record length (0..2) of Tunnel_Header_Filter_AVP record_of_Tunnel_Header_Filter_AVP;
SET_OF_AVP_COMMON_SetOffsets(record_of_Tunnel_Header_Filter_AVP, AVP_CODE_Tunnel_Header_Filter)
SET_OF_AVP_COMMON_PreDecode(record_of_Tunnel_Header_Filter_AVP, AVP_CODE_Tunnel_Header_Filter)
SET_OF_AVP_COMMON_PostDecodeField(record_of_Tunnel_Header_Filter_AVP, AVP_CODE_Tunnel_Header_Filter)

///////////////////////////////////////////////////////
////////////////  GROUPED AVPs  ////////////////////////
///////////////////////////////////////////////////////
#define GROUPED_PreDecode(type)	\
	void type::PreDecode(Buffer& buffer) throw (DecodeError)	\
	{	\
		m_nStartingPosition = buffer.GetPosition();	\
	}

#define GROUPED_PostDecodeField(type)	\
	void type::PostDecodeField(int field_id, Buffer& buffer) throw (DecodeError)	\
	{	\
		if(field_id == id_aVP_Header)	\
		{	\
			unsigned int nFirstAVP_Offset = buffer.GetPosition();	\
			unsigned int nAVPLen = Get_aVP_Header().Get_aVP_len().GetValue();	\
			while(nAVPLen%4)	\
				nAVPLen++;	\
			unsigned int nEndOffset = m_nStartingPosition + (nAVPLen * 8);	\
			unsigned int nCurrentOffset = buffer.GetPosition();	\
			while(nCurrentOffset < nEndOffset)	\
			{	\
				unsigned int nAVP_Code = skip_AVP(buffer);	\
				m_lAVP_Codes.push_back(nAVP_Code);	\
				m_lAVP_Offsets.push_back(nCurrentOffset);	\
				nCurrentOffset = buffer.GetPosition();	\
			}	\
			buffer.SetPosition(nFirstAVP_Offset);	\
		}	\
	}

#define GROUPED_PreDecodeField_START(type) \
	void type::PreDecodeField(int field_id, Buffer& buffer) throw (DecodeError)	\
	{	\
		debug_log_PreDecodeField(#type, field_id);	\
		if(false) {}

#define GROUPED_PreDecodeField_SINGLE_MANDATORY(avpcode, fid) \
	else if(field_id == id_##fid)	\
	{	\
		int nOffset = get_AVP_offset(m_lAVP_Codes, m_lAVP_Offsets, avpcode);	\
		if(nOffset == -1)	\
		{	\
			DecodeError ex (this);	\
			ex.Msg() << "Mandatory AVP not present: "	\
					<< #avpcode << endl;	\
			throw ex;	\
		}	\
		m_lAVP_Codes[nOffset] = AVP_CODE_NOT_IN_USE;	\
		buffer.SetPosition(m_lAVP_Offsets.at(nOffset));	\
	}

#define GROUPED_PreDecodeField_SET_OF_MANDATORY(avpcode, fid) \
	else if(field_id == id_##fid)	\
	{	\
		int nOffset = get_AVP_offset(m_lAVP_Codes, m_lAVP_Offsets, avpcode);	\
		if(nOffset == -1)	\
		{	\
			DecodeError ex (this);	\
			ex.Msg() << "Mandatory AVP not present: "	\
					<< #avpcode << endl;	\
			throw ex;	\
		}	\
		Get_##fid().SetOffsets(m_lAVP_Codes, m_lAVP_Offsets);	\
	}

#define GROUPED_PreDecodeField_SINGLE_OPTIONAL(avpcode, fid) \
	else if(field_id == id_##fid)	\
	{	\
		int nOffset = get_AVP_offset(m_lAVP_Codes, m_lAVP_Offsets, avpcode);	\
		if(nOffset != -1)	\
		{	\
			SetHypFieldIsPresent(field_id, 1);	\
			buffer.SetPosition(m_lAVP_Offsets.at(nOffset));	\
			m_lAVP_Codes[nOffset] = AVP_CODE_NOT_IN_USE;	\
		}	\
		else SetHypFieldIsPresent(field_id, 0);	\
	}

#define GROUPED_PreDecodeField_SET_OF_OPTIONAL(avpcode, fieldName) \
	else if(field_id == id_##fieldName)	\
	{	\
		int nOffset = get_AVP_offset(m_lAVP_Codes, m_lAVP_Offsets, avpcode);	\
		if(nOffset != -1)	\
		{	\
			SetHypFieldIsPresent(field_id, 1);	\
			Get_##fieldName().SetOffsets(m_lAVP_Codes, m_lAVP_Offsets);	\
		}	\
		else SetHypFieldIsPresent(field_id, 0);	\
	}

#define GROUPED_PreDecodeField_END(type) \
	}

//TODO: if items present, but should be ignored, the collection should remain empty
#define GROUPED_PreDecodeField_REMAINING_t \
	else if(field_id == id_aVP_Type)	\
	{	\
		int nOffset = get_Remaining_AVP_offset(m_lAVP_Codes);	\
		if(nOffset != -1)	\
		{	\
			SetHypFieldIsPresent(field_id, 1);	\
			std::vector<unsigned int> lIgnored;	\
			Get_aVP_Type().SetRemaining(m_lAVP_Codes, m_lAVP_Offsets, lIgnored);	\
		}	\
		else SetHypFieldIsPresent(field_id, 0);	\
	}

#define GROUPED_PreDecodeField_REMAINING_d \
	else if(field_id == id_aVP_Data)	\
	{	\
		int nOffset = get_Remaining_AVP_offset(m_lAVP_Codes);	\
		if(nOffset != -1)	\
		{	\
			SetHypFieldIsPresent(field_id, 1);	\
			std::vector<unsigned int> lIgnored;	\
			Get_aVP_Data().SetRemaining(m_lAVP_Codes, m_lAVP_Offsets, lIgnored);	\
		}	\
		else SetHypFieldIsPresent(field_id, 0);	\
	}


/*type record Vendor_Specific_Appl_Id_AVP{
//Ref: RFC3588 6.11.  Vendor-Specific-Application-Id AVP
	AVP_Header         	aVP_Header,//<Vendor-Specific-Application-Id> ::= < AVP Header: 260 >
	set_of_Vendor_Id_AVP vendor_Id optional,
	set_of_Auth_Application_Id_AVP 	auth_Application_Id optional,
	set_of_Acct_Application_Id_AVP	acct_Application_Id optional
};*/
GROUPED_PreDecode(Vendor_Specific_Appl_Id_AVP)
GROUPED_PreDecodeField_START(Vendor_Specific_Appl_Id_AVP)

GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Vendor_Id, vendor_Id)
GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Auth_Application_Id, auth_Application_Id)
GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Acct_Application_Id, acct_Application_Id)

GROUPED_PreDecodeField_END(Vendor_Specific_Appl_Id_AVP)

GROUPED_PostDecodeField(Vendor_Specific_Appl_Id_AVP)

/*type record Failed_AVP{
//Ref: RFC3588 7.5.  Failed-AVP AVP
	AVP_Header         	aVP_Header,//<AVP header: 279 ....>			
	set_of_AVP_Type 			aVP
};*/
GROUPED_PreDecode(Failed_AVP)
GROUPED_PreDecodeField_START(Failed_AVP)
//GROUPED_PreDecodeField_REMAINING
	else if(field_id == id_aVP)
	{
		int nOffset = get_Remaining_AVP_offset(m_lAVP_Codes);
		if(nOffset != -1)
		{
			SetHypFieldIsPresent(field_id, 1);
			std::vector<unsigned int> lIgnored;
			Get_aVP().SetRemaining(m_lAVP_Codes, m_lAVP_Offsets, lIgnored);
		}
		else SetHypFieldIsPresent(field_id, 0);
	}

GROUPED_PreDecodeField_END(Failed_AVP)

GROUPED_PostDecodeField(Failed_AVP)

/*type record Flows_AVP{
 //Ref: ETSI TS 129 214 Flows_AVP
     AVP_Header			aVP_Header,//<AVP header: 510 ....>
     Media_Component_Number_AVP	media_component_number,
     set_of_Flow_Number_AVP	flow_Number optional,
     Final_Unit_Action_AVP	final_unit_action optional
 };*/
GROUPED_PreDecode(Flows_AVP)
GROUPED_PreDecodeField_START(Flows_AVP)

GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Media_Component_Number, media_component_number)
GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Flow_Number, flow_Number)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Final_Unit_Action, final_unit_action)

GROUPED_PreDecodeField_END(Flows_AVP)

GROUPED_PostDecodeField(Flows_AVP)


/*type record Access_Network_Charging_Identifier_AVP{
//Ref: ETSI TS 129 214 Access_Network_Charging_Identifier AVP
    AVP_Header										aVP_Header, //<AVP header: 502 ....>
    Access_Network_Charging_Identifier_Value_AVP 	acc_Net_Charging_Id_Val,
    set_of_Flows_AVP								flows
};*/
GROUPED_PreDecode(Access_Network_Charging_Identifier_AVP)
GROUPED_PreDecodeField_START(Access_Network_Charging_Identifier_AVP)

GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Access_Network_Charging_Identifier_Value, acc_Net_Charging_Id_Val)
GROUPED_PreDecodeField_SET_OF_MANDATORY(AVP_CODE_Flows, flows)

GROUPED_PreDecodeField_END(Access_Network_Charging_Identifier_AVP)

GROUPED_PostDecodeField(Access_Network_Charging_Identifier_AVP)


/*type record Subscription_Id_AVP{
//	Ref: RFC4006 8.46.  Subscription-Id AVP
	AVP_Header         			aVP_Header,//< AVP Header: 443 >
	Subscription_Id_Type_AVP 	subscription_Id_Type,
	Subscription_Id_Data_AVP 	subscription_Id_Data
};*/
GROUPED_PreDecode(Subscription_Id_AVP)
GROUPED_PreDecodeField_START(Subscription_Id_AVP)

GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Subscription_Id_Type, subscription_Id_Type)
GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Subscription_Id_Data, subscription_Id_Data)

GROUPED_PreDecodeField_END(Subscription_Id_AVP)

GROUPED_PostDecodeField(Subscription_Id_AVP)


/*type record Unit_Value_AVP{
//	Ref: RFC4006 8.8.  Unit-Value AVP
	AVP_Header         			aVP_Header,//< AVP Header: 445 >
	Value_Digits				value_Digits,
	Exponent_AVP 				exponent optional				
};*/
GROUPED_PreDecode(Unit_Value_AVP)
GROUPED_PreDecodeField_START(Unit_Value_AVP)

GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Value_Digits, value_Digits)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Exponent, exponent)

GROUPED_PreDecodeField_END(Unit_Value_AVP)

GROUPED_PostDecodeField(Unit_Value_AVP)

/*type record Sponsored_Connectivity_Data_AVP{
 //Ref: ETSI TS 129 214 Sponsored_Conectivity_Data AVP
     AVP_Header									aVP_Header, //<AVP header: 530 ....>
     Sponsor_Identity_AVP						sponsor_Identity optional,
     Application_Service_Provider_Identity_AVP 	application_service_provider_Id optional,
     Granted_Service_Unit_AVP					granted_Service_Unit optional,
     Used_Service_Unit_AVP						used_service_unit optional,
     set_of_AVP_Type   							aVP_Type optional
 };*/
GROUPED_PreDecode(Sponsored_Connectivity_Data_AVP)
GROUPED_PreDecodeField_START(Sponsored_Connectivity_Data_AVP)

GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Sponsor_Identity, sponsor_Identity)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Application_Service_Provider_Identity, application_service_provider_Id)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Granted_Service_Unit, granted_Service_Unit)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Used_Service_Unit, used_service_unit)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(Sponsored_Connectivity_Data_AVP)

GROUPED_PostDecodeField(Sponsored_Connectivity_Data_AVP)

/*type record User_CSG_Information_AVP{
//Ref: ETSI TS 132 299 User_CSG_Information_AVP
    AVP_Header						aVP_Header, //<AVP header: 2319 ....>
    CSG_Id_AVP						cSG_Id,
    CSG_Access_Mode_AVP				cSG_Access_Mode,
    CSG_Membership_Indication_AVP	CSG_Membership_Indication_AVP optional
};*/
GROUPED_PreDecode(User_CSG_Information_AVP)
GROUPED_PreDecodeField_START(User_CSG_Information_AVP)

GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_CSG_Id, cSG_Id)
GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_CSG_Access_Mode, cSG_Access_Mode)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_CSG_Membership_Indication, CSG_Membership_Indication_AVP)

GROUPED_PreDecodeField_END(User_CSG_Information_AVP)

GROUPED_PostDecodeField(User_CSG_Information_AVP)


/*type record Allocation_Retention_Priority_AVP{
//Ref: ETSI TS 129 212 Allocation_Retention_Priority_AVP
    AVP_Header						aVP_Header, //<AVP header: 1034 ....>
    Priority_Level_AVP 				priority_Level,
    Pre_emption_Capability_AVP 		pre_emption_Capability optional,
    Pre_emption_Vulnerability_AVP	pre_emption_Vulnerability optional
};*/
GROUPED_PreDecode(Allocation_Retention_Priority_AVP)
GROUPED_PreDecodeField_START(Allocation_Retention_Priority_AVP)

GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Priority_Level, priority_Level)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Pre_emption_Capability, pre_emption_Capability)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Pre_emption_Vulnerability, pre_emption_Vulnerability)

GROUPED_PreDecodeField_END(Allocation_Retention_Priority_AVP)

GROUPED_PostDecodeField(Allocation_Retention_Priority_AVP)


/*type record QoS_Information_AVP{
//Ref: ETSI TS 129 212 QoS_Information_AVP
    AVP_Header								aVP_Header, //<AVP header: 1016 ....>
    QoS_Class_Identifier_AVP				qoS_Class_Identifier optional,
    Max_Requested_Bandwidth_UL_AVP			max_Requested_Bandwidth_UL optional,
    Max_Requested_Bandwidth_DL_AVP			max_Requested_Bandwidth_DL optional,
    Guaranteed_Bitrate_UL_AVP				guaranteed_Bitrate_UL optional,
    Guaranteed_Bitrate_DL_AVP				guaranteed_Bitrate_DL optional,
    Bearer_Identifier_AVP					bearer_Identifier optional,
    Allocation_Retention_Priority_AVP		allocation_Retention_Priority optional,
    APN_Aggregate_Max_Bitrate_UL_AVP		aPN_Aggregate_Max_Bitrate_UL optional,
    APN_Aggregate_Max_Bitrate_DL_AVP		aPN_Aggregate_Max_Bitrate_DL optional,
    set_of_AVP_Type	     					aVP_Type optional
};*/
GROUPED_PreDecode(QoS_Information_AVP)
GROUPED_PreDecodeField_START(QoS_Information_AVP)

GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_QoS_Class_Identifier, qoS_Class_Identifier)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Max_Requested_Bandwidth_UL, max_Requested_Bandwidth_UL)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Max_Requested_Bandwidth_DL, max_Requested_Bandwidth_DL)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Guaranteed_Bitrate_UL, guaranteed_Bitrate_UL)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Guaranteed_Bitrate_DL, guaranteed_Bitrate_DL)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Bearer_Identifier, bearer_Identifier)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Allocation_Retention_Priority, allocation_Retention_Priority)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_APN_Aggregate_Max_Bitrate_UL, aPN_Aggregate_Max_Bitrate_UL)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_APN_Aggregate_Max_Bitrate_DL, aPN_Aggregate_Max_Bitrate_DL)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(QoS_Information_AVP)

GROUPED_PostDecodeField(QoS_Information_AVP)


/*type record Area_Scope_AVP{
//Ref: ETSI TS129 272 Area_Scope_AVP
    AVP_Header			aVP_Header, //<AVP header: 1624 ....>
	set_of_Cell_Global_Identity_AVP			cell_Global_Identity optional,
	set_of_E_UTRAN_Cell_Global_Identity_AVP	e_UTRAN_Cell_Global_Identity_AVP optional,
	set_of_Routing_Area_Identity_AVP		routing_Area_Identity optional,
	set_of_Location_Area_Identity_AVP		location_Area_Identity optional,
	set_of_Tracking_Area_Identity_AVP		tracking_Area_Identity optional,
	set_of_AVP_Type     					aVP_Type optional
};*/
GROUPED_PreDecode(Area_Scope_AVP)
GROUPED_PreDecodeField_START(Area_Scope_AVP)

GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Cell_Global_Identity, cell_Global_Identity)
GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_E_UTRAN_Cell_Global_Identity, e_UTRAN_Cell_Global_Identity_AVP)
GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Routing_Area_Identity, routing_Area_Identity)
GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Location_Area_Identity, location_Area_Identity)
GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Tracking_Area_Identity, tracking_Area_Identity)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(Area_Scope_AVP)

GROUPED_PostDecodeField(Area_Scope_AVP)


/*type record MDT_Configuration_AVP{
//Ref: ETSI TS129 272 MDT_Configuration_AVP
    AVP_Header					aVP_Header, //<AVP header: 1622 ....>
    Job_Type_AVP				job_Type,
    Area_Scope_AVP				area_Scope optional,
    List_Of_Measurements_AVP	list_Of_Measurements optional,
    Reporting_Trigger_AVP		reporting_Trigger optional,
    Report_Interval_AVP			report_Interval optional,
    Report_Amount_AVP			report_Amount optional,
    Event_Treshold_RSRP_AVP		event_Treshold_RSRP optional,
    Event_Treshold_RSRQ_AVP		event_Treshold_RSRQ optional,
    Logging_Interval_AVP		logging_Interval optional,
    Logging_Duration_AVP		logging_Duration optional,
    set_of_AVP_Type     		aVP_Type optional
};*/
GROUPED_PreDecode(MDT_Configuration_AVP)
GROUPED_PreDecodeField_START(MDT_Configuration_AVP)

GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Job_Type, job_Type)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Area_Scope, area_Scope)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_List_Of_Measurements, list_Of_Measurements)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Reporting_Trigger, reporting_Trigger)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Report_Interval, report_Interval)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Report_Amount, report_Amount)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Event_Treshold_RSRP, event_Treshold_RSRP)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Event_Treshold_RSRQ, event_Treshold_RSRQ)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Logging_Interval, logging_Interval)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Logging_Duration, logging_Duration)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(MDT_Configuration_AVP)

GROUPED_PostDecodeField(MDT_Configuration_AVP)


/*type record Trace_Data_AVP{
//Ref: ETSI TS 129 272 Trace_Data_AVP
    AVP_Header						aVP_Header, //<AVP header: 1485 ....>
	Trace_Reference_AVP				trace_Reference,
	Trace_Depth_AVP					trace_Depth,
	Trace_NE_Type_List_AVP			trace_NE_Type_List,
	Trace_Event_List_AVP			trace_Event_List,
	Trace_Collection_Entity_AVP		trace_Collection_Entityt,
	Trace_Interface_List_AVP		trace_Interface_List optional,
	OMC_Id_AVP						oMC_Id optional,
	MDT_Configuration_AVP			mDT_Configuration optional,
	set_of_AVP_Type     			aVP_Type optional
};*/
GROUPED_PreDecode(Trace_Data_AVP)
GROUPED_PreDecodeField_START(Trace_Data_AVP)

GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Trace_Reference, trace_Reference)
GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Trace_Depth, trace_Depth)
GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Trace_NE_Type_List, trace_NE_Type_List)
GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Trace_Event_List, trace_Event_List)
GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Trace_Collection_Entity, trace_Collection_Entityt)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Trace_Interface_List, trace_Interface_List)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_OMC_Id, oMC_Id)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_MDT_Configuration, mDT_Configuration)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(Trace_Data_AVP)

GROUPED_PostDecodeField(Trace_Data_AVP)

/*type record Event_Report_Indication_AVP{
//Ref: ETSI TS 129 212 Event_Report_Indication_AVP
    AVP_Header							aVP_Header, //<AVP header: 1033 ....>
    set_of_Event_Trigger_AVP			event_Trigger optional,
    User_CSG_Information_AVP			user_CSG_Information optional,
    RAT_Type_AVP						rAT_Type optional,
    QoS_Information_AVP					qoS_Information optional,
    RAI_AVP								rAI optional,
    ThreeGPP_User_Location_Info_AVP		threeGPP_User_Location_Info optional,
    Trace_Data_AVP						trace_Data optional,
    Trace_Reference_AVP					trace_Reference optional,
    ThreeGPP2_BSID_AVP					threeGPP2_BSID optional,
    ThreeGPP_MS_TimeZone_AVP			threeGPP_MS_TimeZone optional,
    ThreeGPP_SGSN_Address_AVP			threeGPP_SGSN_Address optional,
    ThreeGPP_SGSN_IPv6_Address_AVP		threeGPP_SGSN_IPv6_Address optional,
    Routing_IP_Address_AVP				routing_IP_Address optional,
    set_of_AVP_Type	     				aVP_Type optional
};*/
GROUPED_PreDecode(Event_Report_Indication_AVP)
GROUPED_PreDecodeField_START(Event_Report_Indication_AVP)

GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Event_Trigger, event_Trigger)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_User_CSG_Information, user_CSG_Information)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_RAT_Type, rAT_Type)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_QoS_Information, qoS_Information)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_RAI, rAI)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_ThreeGPP_User_Location_Info, threeGPP_User_Location_Info)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Trace_Data, trace_Data)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Trace_Reference, trace_Reference)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_ThreeGPP2_BSID, threeGPP2_BSID)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_ThreeGPP_MS_TimeZone, threeGPP_MS_TimeZone)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_ThreeGPP_SGSN_Address, threeGPP_SGSN_Address)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_ThreeGPP_SGSN_IPv6_Address, threeGPP_SGSN_IPv6_Address)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Routing_IP_Address, routing_IP_Address)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(Event_Report_Indication_AVP)

GROUPED_PostDecodeField(Event_Report_Indication_AVP)


/*type record Charging_Rule_Remove_AVP{
//Ref: ETSI TS 129 212 Charging_Rule_Install_AVP
    AVP_Header							aVP_Header, //<AVP header: 1002 ....>
    set_of_Charging_Rule_Name_AVP		charging_Rule_Name optional,
    set_of_Charging_Rule_Base_Name_AVP	charging_Rule_Base_Name optional,
    set_of_AVP_Type     				aVP_Type optional
};*/
GROUPED_PreDecode(Charging_Rule_Remove_AVP)
GROUPED_PreDecodeField_START(Charging_Rule_Remove_AVP)

GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Charging_Rule_Name, charging_Rule_Name)
GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Charging_Rule_Base_Name, charging_Rule_Base_Name)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(Charging_Rule_Remove_AVP)

GROUPED_PostDecodeField(Charging_Rule_Remove_AVP)


/*type record Flow_Information_AVP{
//Ref: ETSI TS 129 212 Flow_Information_AVP
    AVP_Header								aVP_Header, //<AVP header: 1058 ....>
    Flow_Description_AVP					flow_Description optional,
    Packet_Filter_Identifier_AVP			packet_Filter_Identifier optional,
    Packet_Filter_Usage_AVP					packet_Filter_Usage optional,
    ToS_Traffic_Class_AVP					toS_Traffic_Class optional,
    Security_Parameter_Index_AVP			security_Parameter_Index optional,
    Flow_Label_AVP							flow_Label optional,						
    Flow_Direction_AVP						flow_Direction optional,
    set_of_AVP_Type 	    				aVP_Type optional
};*/
GROUPED_PreDecode(Flow_Information_AVP)
GROUPED_PreDecodeField_START(Flow_Information_AVP)

GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Flow_Description, flow_Description)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Packet_Filter_Identifier, packet_Filter_Identifier)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Packet_Filter_Usage, packet_Filter_Usage)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_ToS_Traffic_Class, toS_Traffic_Class)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Security_Parameter_Index, security_Parameter_Index)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Flow_Label, flow_Label)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Flow_Direction, flow_Direction)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(Flow_Information_AVP)

GROUPED_PostDecodeField(Flow_Information_AVP)


/*type record Charging_Rule_Definition_AVP{
//Ref: ETSI TS 129 212 Charging_Rule_Definition_AVP
    AVP_Header									aVP_Header, //<AVP header: 1003 ....>
    Charging_Rule_Name_AVP						charging_Rule_Name,
    Service_Identifier_AVP						service_Identifier optional,
    Rating_Group_AVP							rating_Group optional,
    set_of_Flow_Information_AVP					flow_Information optional,
    Flow_Status_AVP								flow_Status optional,
    QoS_Information_AVP							qoS_Information optional,
    Reporting_Level_AVP							reporting_Level optional,
    Online_AVP									online optional,
    Offline_AVP									offline optional,
    Metering_Method_AVP							metering_Method optional,
    Precedence_AVP								precedence optional,
    AF_Charging_Identifier_AVP					aF_Charging_Identifier optional,
    set_of_Flows_AVP							flows optional,
    Monitoring_Key_AVP							monitoring_Key optional,
    AF_Signalling_Protocol_AVP					aF_Signalling_Protocol optional,
    Sponsor_Identity_AVP						sponsor_Identity optional,
    Application_Service_Provider_Identity_AVP	application_Service_Provider_Identity optional,
    set_of_AVP_Type	     						aVP_Type optional
};*/
GROUPED_PreDecode(Charging_Rule_Definition_AVP)
GROUPED_PreDecodeField_START(Charging_Rule_Definition_AVP)

GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Charging_Rule_Name, charging_Rule_Name)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Service_Identifier, service_Identifier)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Rating_Group, rating_Group)
GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Flow_Information, flow_Information)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Flow_Status, flow_Status)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_QoS_Information, qoS_Information)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Reporting_Level, reporting_Level)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Online, online)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Offline, offline)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Metering_Method, metering_Method)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Precedence, precedence)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_AF_Charging_Identifier, aF_Charging_Identifier)
GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Flows, flows)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Monitoring_Key, monitoring_Key)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_AF_Signalling_Protocol, aF_Signalling_Protocol)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Sponsor_Identity, sponsor_Identity)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Application_Service_Provider_Identity, application_Service_Provider_Identity)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(Charging_Rule_Definition_AVP)

GROUPED_PostDecodeField(Charging_Rule_Definition_AVP)


/*type record Charging_Rule_Install_AVP{
//Ref: ETSI TS 129 212 Charging_Rule_Install_AVP
    AVP_Header								aVP_Header, //<AVP header: 1001 ....>
    set_of_Charging_Rule_Definition_AVP		charging_Rule_Definition optional,
    set_of_Charging_Rule_Name_AVP			charging_Rule_Name optional,
    set_of_Charging_Rule_Base_Name_AVP		charging_Rule_Base_Name optional,
    Bearer_Identifier_AVP					bearer_Identifier optional,
    Rule_Activation_Time_AVP				rule_Activation_Time optional,
    Rule_DeActivation_Time_AVP				rule_DeActivation_Time optional,
    Resource_Allocation_Notification_AVP	resource_Allocation_Notification optional,
    Charging_Correlation_Indicator_AVP		charging_Correlation_Indicator optional,
    set_of_AVP_Type     					aVP_Type optional
};*/
GROUPED_PreDecode(Charging_Rule_Install_AVP)
GROUPED_PreDecodeField_START(Charging_Rule_Install_AVP)

GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Charging_Rule_Definition, charging_Rule_Definition)
GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Charging_Rule_Name, charging_Rule_Name)
GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Charging_Rule_Base_Name, charging_Rule_Base_Name)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Bearer_Identifier, bearer_Identifier)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Rule_Activation_Time, rule_Activation_Time)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Rule_DeActivation_Time, rule_DeActivation_Time)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Resource_Allocation_Notification, resource_Allocation_Notification)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Charging_Correlation_Indicator, charging_Correlation_Indicator)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(Charging_Rule_Install_AVP)

GROUPED_PostDecodeField(Charging_Rule_Install_AVP)


/*type record Default_EPS_Bearer_QoS_AVP{
//Ref: ETSI TS 129 212 Default_EPS_Bearer_QoS_AVP
    AVP_Header							aVP_Header, //<AVP header: 1049 ....>
	QoS_Class_Identifier_AVP			qoS_Class_Identifier optional,
    Allocation_Retention_Priority_AVP	allocation_Retention_Priority optional,
    set_of_AVP_Type	     				aVP_Type optional
};*/
GROUPED_PreDecode(Default_EPS_Bearer_QoS_AVP)
GROUPED_PreDecodeField_START(Default_EPS_Bearer_QoS_AVP)

GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_QoS_Class_Identifier, qoS_Class_Identifier)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Allocation_Retention_Priority, allocation_Retention_Priority)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(Default_EPS_Bearer_QoS_AVP)

GROUPED_PostDecodeField(Default_EPS_Bearer_QoS_AVP)


/*type record Usage_Monitoring_Information_AVP{
//Ref: ETSI TS 129 212 Usage_Monitoring_Information_AVP
    AVP_Header						aVP_Header, //<AVP header: 1067 ....>
    Monitoring_Key_AVP				monitoring_Key optional,
    Granted_Service_Unit_AVP		granted_Service_Unit optional,
    Used_Service_Unit_AVP			used_Service_Unit optional,
    Usage_Monitoring_Level_AVP		usage_Monitoring_Level optional,
    Usage_Monitoring_Report_AVP		usage_Monitoring_Report optional,
    Usage_Monitoring_Support_AVP	usage_Monitoring_Support optional,
    set_of_AVP_Type     			aVP_Type optional
};*/
GROUPED_PreDecode(Usage_Monitoring_Information_AVP)
GROUPED_PreDecodeField_START(Usage_Monitoring_Information_AVP)

GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Monitoring_Key, monitoring_Key)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Granted_Service_Unit, granted_Service_Unit)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Used_Service_Unit, used_Service_Unit)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Usage_Monitoring_Level, usage_Monitoring_Level)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Usage_Monitoring_Report, usage_Monitoring_Report)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Usage_Monitoring_Support, usage_Monitoring_Support)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(Usage_Monitoring_Information_AVP)

GROUPED_PostDecodeField(Usage_Monitoring_Information_AVP)


//TODO: this is very strange, I cannot find the proper definitions for that in standards
/*type record Experimental_Result_AVP{
//	Ref: 3GPP TS 29.229	6.2 Result-Code AVP values
//  FUN 766300-PCL-030 :  Experimental-Result AVP shall be used for Sh/Dh errors. 
//  This is a grouped AVP which contains the 3GPP Vendor ID in the Vendor-Id AVP, and the error code in 
//  the Experimental-Result-Code AVP.
	AVP_Header         				aVP_Header,//<AVP header: 297 ....>
	Vendor_Id_AVP					vendor_Id,
	Experimental_Result_Code_AVP	experimental_Result_Code		
};*/
GROUPED_PreDecode(Experimental_Result_AVP)
GROUPED_PreDecodeField_START(Experimental_Result_AVP)

GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Vendor_Id, vendor_Id)
GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Experimental_Result_Code, experimental_Result_Code)

GROUPED_PreDecodeField_END(Experimental_Result_AVP)

GROUPED_PostDecodeField(Experimental_Result_AVP)


/*type record Media_Component_Description_AVP{
//Ref: ETSI TS 129 214 Media_Component_Decription_AVP
	AVP_Header			aVP_Header,//<AVP header: 517 ....>
	Media_Component_Number_AVP 	media_Component_Nr,
	set_of_Media_Sub_Component_AVP media_Sub_component optional,
	AF_Application_Identifier_AVP	af_Application_Id optional,
	Media_Type_AVP					media_type optional,
	Max_Requested_Bandwidth_UL_AVP	max_Requested_Bw_Ul optional,
	Max_Requested_Bandwidth_DL_AVP	max_Requested_Bw_Dl optional,
	Flow_Status_AVP				flow_Status optional,
	Reservation_Priority_AVP		reservation_Priority optional,
	RS_Bandwidth_AVP				rs_Bw optional,
	RR_Bandwidth_AVP				rr_Bw optional,
	set_of_Codec_Data_AVP			codec_data optional
};*/
GROUPED_PreDecode(Media_Component_Description_AVP)
GROUPED_PreDecodeField_START(Media_Component_Description_AVP)

GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Media_Component_Number, media_Component_Nr)
GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Media_Sub_Component, media_Sub_component)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_AF_Application_Identifier, af_Application_Id)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Media_Type, media_type)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Max_Requested_Bandwidth_UL, max_Requested_Bw_Ul)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Max_Requested_Bandwidth_DL, max_Requested_Bw_Dl)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Flow_Status, flow_Status)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Reservation_Priority, reservation_Priority)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_RS_Bandwidth, rs_Bw)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_RR_Bandwidth, rr_Bw)
GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Codec_Data, codec_data)

GROUPED_PreDecodeField_END(Media_Component_Description_AVP)

GROUPED_PostDecodeField(Media_Component_Description_AVP)


/*type record Routing_Rule_Install_AVP{
//Ref: ETSI TS 129 212 Routing_Rule_Install_AVP
    AVP_Header							aVP_Header, //<AVP header: 1081 ....>
    set_of_Routing_Rule_Definition_AVP	routing_Rule_Definition optional,
    set_of_AVP_Type	     				aVP_Type optional
};*/
GROUPED_PreDecode(Routing_Rule_Install_AVP)
GROUPED_PreDecodeField_START(Routing_Rule_Install_AVP)

GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Routing_Rule_Definition, routing_Rule_Definition)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(Routing_Rule_Install_AVP)

GROUPED_PostDecodeField(Routing_Rule_Install_AVP)


/*type record Routing_Rule_Remove_AVP{
//Ref: ETSI TS 129 212 Routing_Rule_Remove_AVP
    AVP_Header							aVP_Header, //<AVP header: 1075 ....>
    set_of_Routing_Rule_Identifier_AVP	routing_Rule_Identifier optional,
    set_of_AVP_Type	     				aVP_Type optional
};*/
GROUPED_PreDecode(Routing_Rule_Remove_AVP)
GROUPED_PreDecodeField_START(Routing_Rule_Remove_AVP)

GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Routing_Rule_Identifier, routing_Rule_Identifier)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(Routing_Rule_Remove_AVP)

GROUPED_PostDecodeField(Routing_Rule_Remove_AVP)


/*type record Maximum_Bandwidth_AVP{
//Ref: ETSI TS 129 212 Maximum_Bandwidth_AVP
    AVP_Header						aVP_Header, //<AVP header: 1082 ....>
	Max_Supported_Bandwidth_UL_AVP	max_Supported_Bandwidth_UL optional,
	Max_Supported_Bandwidth_DL_AVP	max_Supported_Bandwidth_DL optional,
    set_of_AVP_Type	     			aVP_Type optional
};*/
GROUPED_PreDecode(Maximum_Bandwidth_AVP)
GROUPED_PreDecodeField_START(Maximum_Bandwidth_AVP)

GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Max_Supported_Bandwidth_UL, max_Supported_Bandwidth_UL)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Max_Supported_Bandwidth_DL, max_Supported_Bandwidth_DL)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(Maximum_Bandwidth_AVP)

GROUPED_PostDecodeField(Maximum_Bandwidth_AVP)


/*type record Charging_Information_AVP{
//Ref: ETSI TS 129 299 Charging_Information_AVP
    AVP_Header										aVP_Header, //<AVP header: 618 ....>
    Primary_Event_Charging_Function_Name_AVP		primary_Event_Charging_Function_Name optional,
    Secondary_Event_Charging_Function_Name_AVP		secondary_Event_Charging_Function_Name optional,
    Primary_Charging_Collection_Function_Name_AVP	primary_Charging_Collection_Function_Name optional,
    Secondary_Charging_Collection_Function_Name_AVP	secondary_Charging_Collection_Function_Name optional,
    set_of_AVP_Type     							aVP_Type optional
};*/
GROUPED_PreDecode(Charging_Information_AVP)
GROUPED_PreDecodeField_START(Charging_Information_AVP)

GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Primary_Event_Charging_Function_Name, primary_Event_Charging_Function_Name)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Secondary_Event_Charging_Function_Name, secondary_Event_Charging_Function_Name)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Primary_Charging_Collection_Function_Name, primary_Charging_Collection_Function_Name)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Secondary_Charging_Collection_Function_Name, secondary_Charging_Collection_Function_Name)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(Charging_Information_AVP)

GROUPED_PostDecodeField(Charging_Information_AVP)


/*type record Routing_Rule_Definition_AVP{
//Ref: ETSI TS 129 212 Routing_Rule_Definition_AVP
    AVP_Header					aVP_Header, //<AVP header: 1076 ....>
    Routing_Rule_Identifier_AVP	routing_Rule_Identifier,
    set_of_Routing_Filter_AVP	routing_Filter optional,
    Precedence_AVP				precedence optional,
    Routing_IP_Address_AVP		routing_IP_Address optional,
    set_of_AVP_Type	     		aVP_Type optional
};*/
GROUPED_PreDecode(Routing_Rule_Definition_AVP)
GROUPED_PreDecodeField_START(Routing_Rule_Definition_AVP)

GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Routing_Rule_Identifier, routing_Rule_Identifier)
GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Routing_Filter, routing_Filter)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Precedence, precedence)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Routing_IP_Address, routing_IP_Address)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(Routing_Rule_Definition_AVP)

GROUPED_PostDecodeField(Routing_Rule_Definition_AVP)


/*type record Routing_Filter_AVP{
//Ref: ETSI TS 129 212 Routing_Filter_AVP
    AVP_Header						aVP_Header, //<AVP header: 1078 ....>
    Flow_Description_AVP			flow_Description,
    Flow_Direction_AVP				flow_Direction,
    ToS_Traffic_Class_AVP			toS_Traffic_Class optional,
    Security_Parameter_Index_AVP	security_Parameter_Index optional,
    Flow_Label_AVP					flow_Label optional,
    set_of_AVP_Type	     			aVP_Type optional
};*/
GROUPED_PreDecode(Routing_Filter_AVP)
GROUPED_PreDecodeField_START(Routing_Filter_AVP)

GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Flow_Description, flow_Description)
GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Flow_Direction, flow_Direction)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_ToS_Traffic_Class, toS_Traffic_Class)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Security_Parameter_Index, security_Parameter_Index)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Flow_Label, flow_Label)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(Routing_Filter_AVP)

GROUPED_PostDecodeField(Routing_Filter_AVP)

/*type record SIP_Server_Capabilities_AVP{
//Ref: RFC4740 9.3.  SIP-Server-Capabilities AVP
	AVP_Header         	aVP_Header,//<AVP header: 372 ....>
	set_of_SIP_MandatoryCapability_AVP sIP_MandatoryCapability optional,
	set_of_SIP_OptionalCapability_AVP sIP_OptionalCapability optional,
	set_of_SIP_Server_URI_AVP  sIPServerURI optional,
	set_of_AVP_Type 			aVP_Type optional		
};*/
GROUPED_PreDecode(SIP_Server_Capabilities_AVP)
GROUPED_PreDecodeField_START(SIP_Server_Capabilities_AVP)

GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_SIP_MandatoryCapability, sIP_MandatoryCapability)
GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_SIP_OptionalCapability, sIP_OptionalCapability)
GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_SIP_Server_URI, sIPServerURI)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(SIP_Server_Capabilities_AVP)

GROUPED_PostDecodeField(SIP_Server_Capabilities_AVP)


/*type record Supported_Features_AVP{						
//	Ref: 3GPP TS 29.329	6.3.11 Supported-Features AVP (See 3GPP TS 29.229, clause 6.3.29)
	AVP_Header         			aVP_Header,//<AVP header: 628 ....>
	Vendor_Id_AVP				vendor_Id,
	Feature_List_ID_AVP 		feature_list_Id optional,
	Feature_List_AVP 			feature_list,						
	set_of_AVP_Type				aVP_Data optional	//other parameters.					
};*/
GROUPED_PreDecode(Supported_Features_AVP)
GROUPED_PreDecodeField_START(Supported_Features_AVP)

GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Vendor_Id, vendor_Id)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Feature_List_ID, feature_list_Id)
GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Feature_List, feature_list)
GROUPED_PreDecodeField_REMAINING_d

GROUPED_PreDecodeField_END(Supported_Features_AVP)

GROUPED_PostDecodeField(Supported_Features_AVP)

/*type record Redirect_Server_AVP{
//	Ref: RFC4006 8.37.  Redirect-Server AVP
	AVP_Header         			aVP_Header,//< AVP Header: 434 >
	Redirect_Address_Type_AVP 	redirect_Address_Type,
	Redirect_Server_Address_AVP redirect_Server_Address		
};*/
GROUPED_PreDecode(Redirect_Server_AVP)
GROUPED_PreDecodeField_START(Redirect_Server_AVP)

GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Redirect_Address_Type, redirect_Address_Type)
GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Redirect_Server_Address, redirect_Server_Address)

GROUPED_PreDecodeField_END(Redirect_Server_AVP)

GROUPED_PostDecodeField(Redirect_Server_AVP)

/*type record Acceptable_Service_Info_AVP{
//Ref: ETSI TS 129 214 Acceptable_Service_Info_AVP
	AVP_Header			aVP_Header,//<AVP header: 526 ....>
	set_of_Media_Component_Description_AVP			media_component_description optional,
	Max_Requested_Bandwidth_UL_AVP					max_Requested_Bw_Ul optional,
	Max_Requested_Bandwidth_DL_AVP					max_Requested_Bw_Dl optional,
	set_of_AVP_Type     aVP_Type optional
};*/
GROUPED_PreDecode(Acceptable_Service_Info_AVP)
GROUPED_PreDecodeField_START(Acceptable_Service_Info_AVP)

GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Media_Component_Description, media_component_description)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Max_Requested_Bandwidth_UL, max_Requested_Bw_Ul)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Max_Requested_Bandwidth_DL, max_Requested_Bw_Dl)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(Acceptable_Service_Info_AVP)

GROUPED_PostDecodeField(Acceptable_Service_Info_AVP)

/*type record Media_Sub_Component_AVP{
//Ref: ETSI TS 129 214 Media_Sub_Component_AVP
	AVP_Header										aVP_Header,//<AVP header: 519 ....>
	Flow_Number_AVP								flow_Number,
	record_of_Flow_Description_AVP 	flow_Description optional,
	Flow_Status_AVP								flow_Status optional,
	Flow_Usage_AVP									flow_Usage optional,
	Max_Requested_Bandwidth_UL_AVP					max_Requested_Bw_Ul optional,
	Max_Requested_Bandwidth_DL_AVP					max_Requested_Bw_Dl optional,
	AF_Signalling_Protocol_AVP						af_Signalling_Protocol optional,
	set_of_AVP_Type   								aVP_Type optional
};*/
GROUPED_PreDecode(Media_Sub_Component_AVP)
GROUPED_PreDecodeField_START(Media_Sub_Component_AVP)

GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Flow_Number, flow_Number)
GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Flow_Description, flow_Description)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Flow_Status, flow_Status)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Flow_Usage, flow_Usage)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Max_Requested_Bandwidth_UL, max_Requested_Bw_Ul)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Max_Requested_Bandwidth_DL, max_Requested_Bw_Dl)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_AF_Signalling_Protocol, af_Signalling_Protocol)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(Media_Sub_Component_AVP)

GROUPED_PostDecodeField(Media_Sub_Component_AVP)

/*type record Access_Network_Charging_Identifier_Gx_AVP{
//Ref: ETSI TS 129 212 Access_Network_Charging_Identifier_Gx_AVP
    AVP_Header										aVP_Header, //<AVP header: 1022 ....>
    Access_Network_Charging_Identifier_Value_AVP 	acc_Net_Charging_Id_Val,
    set_of_Charging_Rule_Base_Name_AVP 				charging_Rule_Base_Name optional,
    set_of_Charging_Rule_Name_AVP 					charging_Rule_Name optional
};*/
GROUPED_PreDecode(Access_Network_Charging_Identifier_Gx_AVP)
GROUPED_PreDecodeField_START(Access_Network_Charging_Identifier_Gx_AVP)

GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Access_Network_Charging_Identifier_Value, acc_Net_Charging_Id_Val)
GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Charging_Rule_Base_Name, charging_Rule_Base_Name)
GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Charging_Rule_Name, charging_Rule_Name)

GROUPED_PreDecodeField_END(Access_Network_Charging_Identifier_Gx_AVP)

GROUPED_PostDecodeField(Access_Network_Charging_Identifier_Gx_AVP)

/*type record Charging_Rule_Report_AVP{
//Ref: ETSI TS 129 212 Charging_Rule_Report_AVP
    AVP_Header								aVP_Header, //<AVP header: 1018 ....>
    set_of_Charging_Rule_Name_AVP			charging_Rule_Name optional,
    set_of_Charging_Rule_Base_Name_AVP		charging_Rule_Base_Name optional,
    Bearer_Identifier_AVP					bearer_Identifier optional,
    PCC_Rule_Status_AVP						pCC_Rule_Status optional,
	Rule_Failure_Code_AVP					rule_Failure_Code optional,
	Final_Unit_Indication_AVP				final_Unit_Indication optional,
    set_of_AVP_Type	     					aVP_Type optional
};*/
GROUPED_PreDecode(Charging_Rule_Report_AVP)
GROUPED_PreDecodeField_START(Charging_Rule_Report_AVP)

GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Charging_Rule_Name, charging_Rule_Name)
GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Charging_Rule_Base_Name, charging_Rule_Base_Name)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Bearer_Identifier, bearer_Identifier)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_PCC_Rule_Status, pCC_Rule_Status)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Rule_Failure_Code, rule_Failure_Code)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Final_Unit_Indication, final_Unit_Indication)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(Charging_Rule_Report_AVP)

GROUPED_PostDecodeField(Charging_Rule_Report_AVP)


/*type record CoA_Information_AVP{
//Ref: ETSI TS 129 212 CoA_Information_AVP
    AVP_Header				aVP_Header, //<AVP header: 1039 ....>
    Tunnel_Information_AVP	tunnel_Information,
	CoA_IP_Address_AVP		coA_IP_Address,
	set_of_AVP_Type	     	aVP_Type optional
};*/
GROUPED_PreDecode(CoA_Information_AVP)
GROUPED_PreDecodeField_START(CoA_Information_AVP)

GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_Tunnel_Information, tunnel_Information)
GROUPED_PreDecodeField_SINGLE_MANDATORY(AVP_CODE_CoA_IP_Address, coA_IP_Address)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(CoA_Information_AVP)

GROUPED_PostDecodeField(CoA_Information_AVP)

/*type record Packet_Filter_Information_AVP{
//Ref: ETSI TS 129 212 Packet_Filter_Information_AVP
    AVP_Header						aVP_Header, //<AVP header: 1061 ....>
    Packet_Filter_Identifier_AVP	packet_Filter_Identifier optional,
    Precedence_AVP					precedence optional,
    Packet_Filter_Content_AVP		packet_Filter_Content optional,
    ToS_Traffic_Class_AVP			toS_Traffic_Class optional,
    Security_Parameter_Index_AVP	security_Parameter_Index optional,
    Flow_Label_AVP					flow_Label optional,
    Flow_Direction_AVP				flow_Direction optional,
    set_of_AVP_Type 	    			aVP_Type optional
};*/
GROUPED_PreDecode(Packet_Filter_Information_AVP)
GROUPED_PreDecodeField_START(Packet_Filter_Information_AVP)

GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Packet_Filter_Identifier, packet_Filter_Identifier)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Precedence, precedence)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Packet_Filter_Content, packet_Filter_Content)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_ToS_Traffic_Class, toS_Traffic_Class)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Security_Parameter_Index, security_Parameter_Index)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Flow_Label, flow_Label)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Flow_Direction, flow_Direction)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(Packet_Filter_Information_AVP)

GROUPED_PostDecodeField(Packet_Filter_Information_AVP)


/*type record TFT_Packet_Filter_Information_AVP{
//Ref: ETSI TS 129 212 TFT_Packet_Filter_Information_AVP
    AVP_Header						aVP_Header, //<AVP header: 1013 ....>
    Precedence_AVP					precedence optional,
    TFT_Filter_AVP					tFT_Filter optional,
    ToS_Traffic_Class_AVP			toS_Traffic_Class optional,
    Security_Parameter_Index_AVP	security_Parameter_Index optional,
    Flow_Label_AVP					flow_Label optional,
    Flow_Direction_AVP				flow_Direction optional,
    set_of_AVP_Type     			aVP_Type optional
};*/
GROUPED_PreDecode(TFT_Packet_Filter_Information_AVP)
GROUPED_PreDecodeField_START(TFT_Packet_Filter_Information_AVP)

GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Precedence, precedence)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_TFT_Filter, tFT_Filter)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_ToS_Traffic_Class, toS_Traffic_Class)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Security_Parameter_Index, security_Parameter_Index)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Flow_Label, flow_Label)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Flow_Direction, flow_Direction)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(TFT_Packet_Filter_Information_AVP)

GROUPED_PostDecodeField(TFT_Packet_Filter_Information_AVP)

/*type record Tunnel_Information_AVP{
//Ref: ETSI TS 129 212 Tunnel_Information_AVP
    AVP_Header											aVP_Header, //<AVP header: 1038 ....>
    Tunnel_Header_Length_AVP							tunnel_Header_Length optional,
	record_of_Tunnel_Header_Filter_AVP tunnel_Header_Filter optional,
    set_of_AVP_Type     								aVP_Type optional
};*/
GROUPED_PreDecode(Tunnel_Information_AVP)
GROUPED_PreDecodeField_START(Tunnel_Information_AVP)
GROUPED_PreDecodeField_SINGLE_OPTIONAL(AVP_CODE_Tunnel_Header_Length, tunnel_Header_Length)
GROUPED_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Tunnel_Header_Filter, tunnel_Header_Filter)
GROUPED_PreDecodeField_REMAINING_t

GROUPED_PreDecodeField_END(Tunnel_Information_AVP)

GROUPED_PostDecodeField(Tunnel_Information_AVP)


//////////////////////////////////////////////////////////////////
/////////      Grouped as set and not record      ////////////////
//////////////////////////////////////////////////////////////////


#define GROUPED_SET_PreDecode(type)	\
	void type::PreDecode(Buffer& buffer) throw (DecodeError)	\
	{	\
		m_nStartingPosition = buffer.GetPosition();	\
		SetHypNextField(id_aVP_Header);\
	}

#define GROUPED_SET_PostDecodeField_COMMON	\
		if(field_id == id_aVP_Header)	\
		{	\
			unsigned int nFirstAVP_Offset = buffer.GetPosition();	\
			unsigned int nAVPLen = Get_aVP_Header().Get_aVP_len().GetValue();	\
			while(nAVPLen%4)	\
				nAVPLen++;	\
			unsigned int nEndOffset = m_nStartingPosition + (nAVPLen * 8);	\
			unsigned int nCurrentOffset = buffer.GetPosition();	\
			while(nCurrentOffset < nEndOffset)	\
			{	\
				unsigned int nAVP_Code = skip_AVP(buffer);	\
				m_lAVP_Codes.push_back(nAVP_Code);	\
				m_lAVP_Offsets.push_back(nCurrentOffset);	\
				nCurrentOffset = buffer.GetPosition();	\
			}	\
			buffer.SetPosition(nFirstAVP_Offset); \
		}

#define GROUPED_SET_PreDecodeField_MANDATORY(nextavp, nextfid) \
	nOffset = get_AVP_offset(m_lAVP_Codes, m_lAVP_Offsets, nextavp);	\
	if(nOffset != -1)	\
	{	\
		m_lAVP_Codes[nOffset] = AVP_CODE_NOT_IN_USE;	\
		buffer.SetPosition(m_lAVP_Offsets.at(nOffset));	\
		SetHypNextField(id_##nextfid);	\
		return;	\
	}	\
	else	\
	{	\
		DecodeError ex (this);	\
		ex.Msg() << "Mandatory AVP not present: "	\
				<< #nextavp << endl;	\
		throw ex;	\
	}

#define GROUPED_SET_PreDecodeField_OPTIONAL(nextavp, nextfid) \
	nOffset = get_AVP_offset(m_lAVP_Codes, m_lAVP_Offsets, nextavp);	\
	if(nOffset != -1)	\
	{	\
		m_lAVP_Codes[nOffset] = AVP_CODE_NOT_IN_USE;	\
		buffer.SetPosition(m_lAVP_Offsets.at(nOffset));	\
		SetHypNextField(id_##nextfid);	\
		return;	\
	}


#define GROUPED_SET_PreDecodeField_SET_OF_OPTIONAL(nextavp, nextfid) \
	nOffset = get_AVP_offset(m_lAVP_Codes, m_lAVP_Offsets, nextavp);	\
	if(nOffset != -1)	\
	{	\
		m_lAVP_Codes[nOffset] = AVP_CODE_NOT_IN_USE;	\
		buffer.SetPosition(m_lAVP_Offsets.at(nOffset));	\
		Get_##nextfid().SetOffsets(m_lAVP_Codes, m_lAVP_Offsets);	\
		SetHypNextField(id_##nextfid);	\
		return;	\
	}

#define GROUPED_SET_PreDecodeField_REMAINING \
	nOffset = get_Remaining_AVP_offset(m_lAVP_Codes);	\
	if(nOffset != -1)	\
	{	\
		SetHypNextField(id_aVP_Type);	\
		std::vector<unsigned int> lIgnored;	\
		Get_aVP_Type().SetRemaining(m_lAVP_Codes, m_lAVP_Offsets, lIgnored);	\
		return;	\
	}


/*type set G_S_U_Pool_Reference_AVP{
//	Ref: RFC4006 8.30.  G-S-U-Pool-Reference AVP
	AVP_Header         			aVP_Header,//< AVP Header: 457 >
	G_S_U_Pool_Identifier_AVP	g_S_U_Pool_Identifier,
	CC_Unit_Type_AVP			cC_Unit_Type,
	Unit_Value_AVP				unit_Value		
};*/
GROUPED_SET_PreDecode(G_S_U_Pool_Reference_AVP)
void G_S_U_Pool_Reference_AVP::PostDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
	GROUPED_SET_PostDecodeField_COMMON
}

void G_S_U_Pool_Reference_AVP::PreDecodeField(Buffer& buffer) throw (DecodeError)
{
	if(GetHypNextField() == id_aVP_Header)
		return;
	int nOffset;
	
	GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_G_S_U_Pool_Identifier, g_S_U_Pool_Identifier)
	GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_CC_Unit_Type, cC_Unit_Type)
	GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_Unit_Value, unit_Value)

	SetHypNextField(-2);//no more fields to decode
}

/*type set CC_Money_AVP{
//	Ref: RFC4006 8.22.  CC-Money AVP
	AVP_Header         			aVP_Header,//< AVP Header: 413 >
	Unit_Value_AVP 				unit_Value, 
	Currency_Code_AVP 			currency_Code optional								
};*/
GROUPED_SET_PreDecode(CC_Money_AVP)
void CC_Money_AVP::PostDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
	GROUPED_SET_PostDecodeField_COMMON
}

void CC_Money_AVP::PreDecodeField(Buffer& buffer) throw (DecodeError)
{
	if(GetHypNextField() == id_aVP_Header)
		return;
	int nOffset;
	
	GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_Unit_Value, unit_Value)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Currency_Code, currency_Code)

	SetHypNextField(-2);//no more fields to decode
}

/*type set Requested_Service_Unit_AVP{
//	Ref: RFC4006 8.18.  Requested-Service-Unit AVP
	AVP_Header         				aVP_Header,//< AVP Header: 437 >
	CC_Time_AVP 					cC_Time optional,
	CC_Money_AVP 					cC_Money optional,
	CC_Total_Octets_AVP 			cC_Total_Octets optional,
	CC_Input_Octets_AVP 			cC_Input_Octets optional,
	CC_Output_Octets_AVP 			cC_Output_Octets optional,
	CC_Service_Specific_Units_AVP 	cC_Service_Specific_Units optional,
	set_of_AVP_Type  				aVP_Type optional
};*/
GROUPED_SET_PreDecode(Requested_Service_Unit_AVP)
void Requested_Service_Unit_AVP::PostDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
	GROUPED_SET_PostDecodeField_COMMON
}

void Requested_Service_Unit_AVP::PreDecodeField(Buffer& buffer) throw (DecodeError)
{
	if(GetHypNextField() == id_aVP_Header)
		return;
	int nOffset;
	
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_CC_Time, cC_Time)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_CC_Money, cC_Money)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_CC_Total_Octets, cC_Total_Octets)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_CC_Input_Octets, cC_Input_Octets)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_CC_Output_Octets, cC_Output_Octets)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_CC_Service_Specific_Units, cC_Service_Specific_Units)
	GROUPED_SET_PreDecodeField_REMAINING

	SetHypNextField(-2);//no more fields to decode
}


/*type set Granted_Service_Unit_AVP{
//	Ref: RFC4006 8.17.  Granted-Service-Unit AVP
	AVP_Header         			aVP_Header,//< AVP Header: 431 >
	Tariff_Time_Change_AVP 		tariff_Time_Change optional,
	CC_Time_AVP 				cC_Time optional,
	CC_Money_AVP 				cC_Money optional,
	CC_Total_Octets_AVP 		cC_Total_Octets optional,
	CC_Input_Octets_AVP 		cC_Input_Octets optional,
	CC_Output_Octets_AVP 		cC_Output_Octets optional,
	CC_Service_Specific_Units_AVP 	cC_Service_Specific_Units optional,
	set_of_AVP_Type 				aVP_Type optional				
};*/
GROUPED_SET_PreDecode(Granted_Service_Unit_AVP)
void Granted_Service_Unit_AVP::PostDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
	GROUPED_SET_PostDecodeField_COMMON
}

void Granted_Service_Unit_AVP::PreDecodeField(Buffer& buffer) throw (DecodeError)
{
	if(GetHypNextField() == id_aVP_Header)
		return;
	int nOffset;
	
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Tariff_Time_Change, tariff_Time_Change)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_CC_Time, cC_Time)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_CC_Money, cC_Money)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_CC_Total_Octets, cC_Total_Octets)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_CC_Input_Octets, cC_Input_Octets)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_CC_Output_Octets, cC_Output_Octets)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_CC_Service_Specific_Units, cC_Service_Specific_Units)
	GROUPED_SET_PreDecodeField_REMAINING

	SetHypNextField(-2);//no more fields to decode
}

/*type set Used_Service_Unit_AVP{
//	Ref: RFC4006 8.19.  Used-Service-Unit AVP
	AVP_Header         			aVP_Header,//< AVP Header: 446 >
	Tariff_Change_Usage_AVP 	tariff_Change_Usage optional,
	CC_Time_AVP 				cC_Time optional,
	CC_Money_AVP 				cC_Money optional,
	CC_Total_Octets_AVP 		cC_Total_Octets optional,
	CC_Input_Octets_AVP 		cC_Input_Octets optional,
	CC_Output_Octets_AVP 		cC_Output_Octets optional,
	CC_Service_Specific_Units_AVP 	cC_Service_Specific_Units optional,
	set_of_AVP_Type 				aVP_Type optional
};*/
GROUPED_SET_PreDecode(Used_Service_Unit_AVP)
void Used_Service_Unit_AVP::PostDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
	GROUPED_SET_PostDecodeField_COMMON
}

void Used_Service_Unit_AVP::PreDecodeField(Buffer& buffer) throw (DecodeError)
{
	if(GetHypNextField() == id_aVP_Header)
		return;
	int nOffset;
	
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Tariff_Change_Usage, tariff_Change_Usage)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_CC_Time, cC_Time)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_CC_Money, cC_Money)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_CC_Total_Octets, cC_Total_Octets)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_CC_Input_Octets, cC_Input_Octets)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_CC_Output_Octets, cC_Output_Octets)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_CC_Service_Specific_Units, cC_Service_Specific_Units)
	GROUPED_SET_PreDecodeField_REMAINING

	SetHypNextField(-2);//no more fields to decode
}

/*type set Proxy_Info_AVP{
//Ref: RFC3588 6.7.2.  Proxy-Info AVP
	AVP_Header         	aVP_Header,//<AVP header: 284 ....>
	Proxy_Host_AVP		proxy_Host,//requi.
	Proxy_State_AVP		proxy_State,//requi.
	set_of_AVP_Type 	aVP_Type optional						
};*/
GROUPED_SET_PreDecode(Proxy_Info_AVP)
void Proxy_Info_AVP::PostDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
	GROUPED_SET_PostDecodeField_COMMON
}

void Proxy_Info_AVP::PreDecodeField(Buffer& buffer) throw (DecodeError)
{
	if(GetHypNextField() == id_aVP_Header)
		return;
	int nOffset;
	
	GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_Proxy_Host, proxy_Host)//requi.
	GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_Proxy_State, proxy_State)//requi.
	GROUPED_SET_PreDecodeField_REMAINING

	SetHypNextField(-2);//no more fields to decode
}

/*type set SIP_User_Data_AVP{
//Ref: RFC4740 9.12.  SIP-User-Data AVP
	AVP_Header         			aVP_Header,// < AVP Header: 389 >
	SIP_User_Data_Type_AVP 		sIP_User_Data_Type,//req.
	SIP_User_Data_Contents_AVP 	sIP_User_Data_Contents,//req.
	set_of_AVP_Type 			aVP_Type optional
};*/
GROUPED_SET_PreDecode(SIP_User_Data_AVP)
void SIP_User_Data_AVP::PostDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
	GROUPED_SET_PostDecodeField_COMMON
}

void SIP_User_Data_AVP::PreDecodeField(Buffer& buffer) throw (DecodeError)
{
	if(GetHypNextField() == id_aVP_Header)
		return;
	int nOffset;
	
	GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_SIP_User_Data_Type, sIP_User_Data_Type)
	GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_SIP_User_Data_Contents, sIP_User_Data_Contents)
	GROUPED_SET_PreDecodeField_REMAINING

	SetHypNextField(-2);//no more fields to decode
}

/*type set SIP_Auth_Data_Item_AVP{
//Ref: RFC4740 9.5.  SIP-Auth-Data-Item AVP
	AVP_Header         				aVP_Header,//SIP-Auth-Data-Item ::= < AVP Header: 376 >
	SIP_Authentication_Scheme_AVP  	sIP_Authentication_Scheme,//requ.
	SIP_Item_Number_AVP 			sIP_Item_Number optional, 
	SIP_Authenticate_AVP 			sIP_Authenticate optional,
	SIP_Authorization_AVP 			sIP_Authorization optional,
	SIP_Authentication_Info_AVP		sIP_Authentication_Info optional,
	set_of_AVP_Type 					aVP_Type optional
};*/
GROUPED_SET_PreDecode(SIP_Auth_Data_Item_AVP)
void SIP_Auth_Data_Item_AVP::PostDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
	GROUPED_SET_PostDecodeField_COMMON
}

void SIP_Auth_Data_Item_AVP::PreDecodeField(Buffer& buffer) throw (DecodeError)
{
	if(GetHypNextField() == id_aVP_Header)
		return;
	int nOffset;
	
	GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_SIP_Authentication_Scheme, sIP_Authentication_Scheme)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_SIP_Item_Number, sIP_Item_Number)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_SIP_Authenticate, sIP_Authenticate)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_SIP_Authorization, sIP_Authorization)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_SIP_Authentication_Info, sIP_Authentication_Info)
	GROUPED_SET_PreDecodeField_REMAINING

	SetHypNextField(-2);//no more fields to decode
}

/*type set SIP_Deregistration_Reason_AVP{
//	Ref: RFC4740 9.5.5.  SIP-Authentication-Info AVP
	AVP_Header         			aVP_Header,//SIP-Deregistration-Reason ::= < AVP Header: 383 >
	SIP_Reason_Code_AVP 		sIP_Reason_Code_AVP,//requi.
	SIP_Reason_Info_AVP 		sIP_Reason_Info_AVP optional,
	set_of_AVP_Type	 			aVP_Type optional
};*/
GROUPED_SET_PreDecode(SIP_Deregistration_Reason_AVP)
void SIP_Deregistration_Reason_AVP::PostDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
	GROUPED_SET_PostDecodeField_COMMON
}

void SIP_Deregistration_Reason_AVP::PreDecodeField(Buffer& buffer) throw (DecodeError)
{
	if(GetHypNextField() == id_aVP_Header)
		return;
	int nOffset;
	
	GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_SIP_Reason_Code, sIP_Reason_Code_AVP)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_SIP_Reason_Info, sIP_Reason_Info_AVP)
	GROUPED_SET_PreDecodeField_REMAINING

	SetHypNextField(-2);//no more fields to decode
}

/*type set User_Identity_AVP{
//	Ref: 3GPP TS 29.329	6.3.1 User-Identity AVP
	AVP_Header         			aVP_Header,//<AVP header: 700 10415>
	Public_Identity_AVP 		public_Identity_AVP optional,
	MSISDN_AVP 					mSISDN_AVP optional,
	set_of_AVP_Type	 			aVP_Type optional						
};*/
GROUPED_SET_PreDecode(User_Identity_AVP)
void User_Identity_AVP::PostDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
	GROUPED_SET_PostDecodeField_COMMON
}

void User_Identity_AVP::PreDecodeField(Buffer& buffer) throw (DecodeError)
{
	if(GetHypNextField() == id_aVP_Header)
		return;
	int nOffset;
	
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Public_Identity, public_Identity_AVP)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_MSISDN, mSISDN_AVP)
	GROUPED_SET_PreDecodeField_REMAINING

	SetHypNextField(-2);//no more fields to decode
}

/*type set Service_Parameter_Info_AVP{
//	Ref: RFC4006 8.43.  Service-Parameter-Info AVP			
	AVP_Header         			aVP_Header,//< AVP Header: 440 >
	Service_Parameter_Type_AVP	service_Parameter_Type,
	Service_Parameter_Value_AVP service_Parameter_Value
};*/
GROUPED_SET_PreDecode(Service_Parameter_Info_AVP)
void Service_Parameter_Info_AVP::PostDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
	GROUPED_SET_PostDecodeField_COMMON
}

void Service_Parameter_Info_AVP::PreDecodeField(Buffer& buffer) throw (DecodeError)
{
	if(GetHypNextField() == id_aVP_Header)
		return;
	int nOffset;

	GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_Service_Parameter_Type, service_Parameter_Type)
	GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_Service_Parameter_Value, service_Parameter_Value)

	SetHypNextField(-2);//no more fields to decode
}

/*type set User_Equipment_Info_AVP{
//	Ref: RFC4006 8.49.  User-Equipment-Info AVP			
	AVP_Header         				aVP_Header,//< AVP Header: 458 >
    User_Equipment_Info_Type_AVP 	user_Equipment_Info_Type,
    User_Equipment_Info_Value_AVP 	user_Equipment_Info_Value
};*/
GROUPED_SET_PreDecode(User_Equipment_Info_AVP)
void User_Equipment_Info_AVP::PostDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
	GROUPED_SET_PostDecodeField_COMMON
}

void User_Equipment_Info_AVP::PreDecodeField(Buffer& buffer) throw (DecodeError)
{
	if(GetHypNextField() == id_aVP_Header)
		return;
	int nOffset;

	GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_User_Equipment_Info_Type, user_Equipment_Info_Type)
    GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_User_Equipment_Info_Value, user_Equipment_Info_Value)

	SetHypNextField(-2);//no more fields to decode
}

/*type set Cost_Information_AVP{
//	Ref: RFC4006 8.7.  Cost-Information AVP
	AVP_Header         			aVP_Header,//< AVP Header: 423 >
	Unit_Value_AVP 				unit_Value,
	Currency_Code_AVP 			currency_Code,
 	Cost_Unit_AVP 				cost_Unit optional
};*/
GROUPED_SET_PreDecode(Cost_Information_AVP)
void Cost_Information_AVP::PostDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
	GROUPED_SET_PostDecodeField_COMMON
}

void Cost_Information_AVP::PreDecodeField(Buffer& buffer) throw (DecodeError)
{
	if(GetHypNextField() == id_aVP_Header)
		return;
	int nOffset;

	GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_Unit_Value, unit_Value)
	GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_Currency_Code, currency_Code)
 	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Cost_Unit, cost_Unit)

	SetHypNextField(-2);//no more fields to decode
}

/*type set Multiple_Services_Credit_Control_AVP{
//	Ref: RFC4006 8.16.  Multiple-Services-Credit-Control AVP		
	AVP_Header         			aVP_Header,//< AVP Header: 456 >
	Granted_Service_Unit_AVP 	granted_Service_Unit optional,
	Requested_Service_Unit_AVP 	requested_Service_Unit optional,
	set_of_Used_Service_Unit_AVP used_Service_Unit optional,
	Tariff_Change_Usage_AVP 	tariff_Change_Usage optional,
	set_of_Service_Identifier_AVP service_Identifier optional,
	Rating_Group_AVP 			rating_Group optional,
	set_of_G_S_U_Pool_Reference_AVP g_S_U_Pool_Reference optional,
	Validity_Time_AVP 			validity_Time optional,
	Result_Code_AVP 			result_Codeoptional optional,
	Final_Unit_Indication_AVP 	final_Unit_Indication optional,
	set_of_AVP_Type	 			aVP_Type optional
}*/
GROUPED_SET_PreDecode(Multiple_Services_Credit_Control_AVP)
void Multiple_Services_Credit_Control_AVP::PostDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
	GROUPED_SET_PostDecodeField_COMMON
}

void Multiple_Services_Credit_Control_AVP::PreDecodeField(Buffer& buffer) throw (DecodeError)
{
	if(GetHypNextField() == id_aVP_Header)
		return;
	int nOffset;
	

	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Granted_Service_Unit, granted_Service_Unit)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Requested_Service_Unit, requested_Service_Unit)
	GROUPED_SET_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Used_Service_Unit, used_Service_Unit)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Tariff_Change_Usage, tariff_Change_Usage)
	GROUPED_SET_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Service_Identifier, service_Identifier)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Rating_Group, rating_Group)
	GROUPED_SET_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_G_S_U_Pool_Reference, g_S_U_Pool_Reference)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Validity_Time, validity_Time)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Result_Code, result_Codeoptional)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Final_Unit_Indication, final_Unit_Indication)
	GROUPED_SET_PreDecodeField_REMAINING

	SetHypNextField(-2);//no more fields to decode
}

/*type set Final_Unit_Indication_AVP{
//	Ref: RFC4006 8.34.  Final-Unit-Indication AVP			
	AVP_Header         			aVP_Header,//< AVP Header: 430 >
	Final_Unit_Action_AVP 		final_Unit_Action,
	set_of_Restriction_Filter_Rule_AVP restriction_Filter_Rule optional,
	set_of_Filter_Id_AVP 		filter_Id optional,
	Redirect_Server_AVP 		redirect_Server optional
};*/
GROUPED_SET_PreDecode(Final_Unit_Indication_AVP)
void Final_Unit_Indication_AVP::PostDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
	GROUPED_SET_PostDecodeField_COMMON
}

void Final_Unit_Indication_AVP::PreDecodeField(Buffer& buffer) throw (DecodeError)
{
	if(GetHypNextField() == id_aVP_Header)
		return;
	int nOffset;
	
	GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_Final_Unit_Action, final_Unit_Action)
	GROUPED_SET_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Restriction_Filter_Rule, restriction_Filter_Rule)
	GROUPED_SET_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Filter_Id, filter_Id)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Redirect_Server, redirect_Server)

	SetHypNextField(-2);//no more fields to decode
}

/*type set SIP_Accounting_Information_AVP{
//Ref: RFC4740 9.1.  SIP-Accounting-Information AVP
	AVP_Header         							aVP_Header,//<AVP header: 368 ....>
	set_of_SIP_Accounting_Server_URI_AVP 		sIP_Accounting_Server_URI optional,
	set_of_SIP_Credit_Control_Server_URI_AVP 	sIP_Credit_Control_Server_URI optional,
	set_of_AVP_Type 							aVP_Type optional
};*/
GROUPED_SET_PreDecode(SIP_Accounting_Information_AVP)
void SIP_Accounting_Information_AVP::PostDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
	GROUPED_SET_PostDecodeField_COMMON
}

void SIP_Accounting_Information_AVP::PreDecodeField(Buffer& buffer) throw (DecodeError)
{
	if(GetHypNextField() == id_aVP_Header)
		return;
	int nOffset;
	

	GROUPED_SET_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_SIP_Accounting_Server_URI, sIP_Accounting_Server_URI)
	GROUPED_SET_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_SIP_Credit_Control_Server_URI, sIP_Credit_Control_Server_URI)
	GROUPED_SET_PreDecodeField_REMAINING

	SetHypNextField(-2);//no more fields to decode
}

/*type set SIP_Authenticate_AVP{
//Ref: RFC4740 9.5.3.  SIP-Authenticate AVP
	AVP_Header         			aVP_Header,//SIP-Authenticate ::= < AVP Header: 379 >
	Digest_Realm_AVP 			digest_Realm,//requ.
	Digest_Nonce_AVP 			digest_Nonce,//requ.
	Digest_Domain_AVP			digest_Domain  optional,
	Digest_Opaque_AVP 			digest_Opaque optional,
	Digest_Stale_AVP 			digest_Stale optional,
	Digest_Algorithm_AVP 		digest_Algorithm optional,
	Digest_QoP_AVP 				digest_QoP optional,
	Digest_HA1_AVP 				digest_HA1 optional,
	set_of_Digest_Auth_Param_AVP 	digest_Auth_Param  optional,
	set_of_AVP_Type 				aVP_Type optional
};*/
GROUPED_SET_PreDecode(SIP_Authenticate_AVP)
void SIP_Authenticate_AVP::PostDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
	GROUPED_SET_PostDecodeField_COMMON
}

void SIP_Authenticate_AVP::PreDecodeField(Buffer& buffer) throw (DecodeError)
{
	if(GetHypNextField() == id_aVP_Header)
		return;
	int nOffset;
	
	GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_Digest_Realm, digest_Realm)//requ.
	GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_Digest_Nonce, digest_Nonce)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Digest_Domain, digest_Domain)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Digest_Opaque, digest_Opaque)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Digest_Stale, digest_Stale)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Digest_Algorithm, digest_Algorithm)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Digest_QoP, digest_QoP)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Digest_HA1, digest_HA1)
	GROUPED_SET_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Digest_Auth_Param, digest_Auth_Param)
	GROUPED_SET_PreDecodeField_REMAINING

	SetHypNextField(-2);//no more fields to decode
}

/*type set SIP_Authorization_AVP{ 
//	Ref: RFC4740 9.5.4.  SIP-Authorization AVP
	AVP_Header         			aVP_Header,//SIP-Authorization ::= < AVP Header: 380 >
	Digest_Username_AVP 		digest_Username,//requi.
	Digest_Realm_AVP 			digest_Realm,
	Digest_Nonce_AVP 			digest_Nonce,
	Digest_URI_AVP 				digest_URI,
	Digest_Response_AVP         digest_Response,//requi.
	Digest_Algorithm_AVP 		digest_Algorithm optional,
	Digest_CNonce_AVP  			digest_CNonce optional,
	Digest_Opaque_AVP 			digest_Opaque optional,
	Digest_QoP_AVP  			digest_QoP optional,
	Digest_Nonce_Count_AVP 		digest_Nonce_Count optional,
	Digest_Method_AVP 			digest_Method optional,
	Digest_Entity_Body_Hash_AVP 	digest_Entity_Body_Hash optional,
	set_of_Digest_Auth_Param_AVP 	digest_Auth_Param  optional,
	set_of_AVP_Type				aVP_Type optional
};*/
GROUPED_SET_PreDecode(SIP_Authorization_AVP)
void SIP_Authorization_AVP::PostDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
	GROUPED_SET_PostDecodeField_COMMON
}

void SIP_Authorization_AVP::PreDecodeField(Buffer& buffer) throw (DecodeError)
{
	if(GetHypNextField() == id_aVP_Header)
		return;
	int nOffset;
	


	GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_Digest_Username, digest_Username)
	GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_Digest_Realm, digest_Realm)
	GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_Digest_Nonce, digest_Nonce)
	GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_Digest_URI, digest_URI)
	GROUPED_SET_PreDecodeField_MANDATORY(AVP_CODE_Digest_Response, digest_Response)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Digest_Algorithm, digest_Algorithm)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Digest_CNonce, digest_CNonce)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Digest_Opaque, digest_Opaque)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Digest_QoP, digest_QoP)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Digest_Nonce_Count, digest_Nonce_Count)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Digest_Method, digest_Method)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Digest_Entity_Body_Hash, digest_Entity_Body_Hash)
	GROUPED_SET_PreDecodeField_SET_OF_OPTIONAL(AVP_CODE_Digest_Auth_Param, digest_Auth_Param)
	GROUPED_SET_PreDecodeField_REMAINING

	SetHypNextField(-2);//no more fields to decode
}

/*type set SIP_Authentication_Info_AVP{ 
//	Ref: RFC4740 9.5.5.  SIP-Authentication-Info AVP
	AVP_Header         			aVP_Header,//SIP-Authentication-Info ::= < AVP Header: 381 >      
	Digest_Nextnonce_AVP 		digest_Nextnonce optional,
	Digest_QoP_AVP 				digest_QoP optional,
	Digest_Response_Auth_AVP 	digest_Response_Auth optional,
	Digest_CNonce_AVP 			digest_CNonce optional,
	Digest_Nonce_Count_AVP 		digest_Nonce_Count optional,
	set_of_AVP_Type	 			aVP_Type optional	
};*/
GROUPED_SET_PreDecode(SIP_Authentication_Info_AVP)
void SIP_Authentication_Info_AVP::PostDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
{
	GROUPED_SET_PostDecodeField_COMMON
}

void SIP_Authentication_Info_AVP::PreDecodeField(Buffer& buffer) throw (DecodeError)
{
	if(GetHypNextField() == id_aVP_Header)
		return;
	int nOffset;
	
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Digest_Nextnonce, digest_Nextnonce)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Digest_QoP, digest_QoP)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Digest_Response_Auth, digest_Response_Auth)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Digest_CNonce, digest_CNonce)
	GROUPED_SET_PreDecodeField_OPTIONAL(AVP_CODE_Digest_Nonce_Count, digest_Nonce_Count)
	GROUPED_SET_PreDecodeField_REMAINING

	SetHypNextField(-2);//no more fields to decode
}

///////////////////////////////////////////////////////
////////////////  ENUMERATIONS ////////////////////////
///////////////////////////////////////////////////////

/*type enumerated Result_Code_Type{
    DIAMETER_DUMMY_E (0),
    
    DIAMETER_MULTI_ROUND_AUTH_E (1001),
    
    DIAMETER_SUCCESS_E (2001),
    DIAMETER_LIMITED_SUCCESS_E (2002),
    
    DIAMETER_COMMAND_UNSUPPORTED_E (3001),
    DIAMETER_UNABLE_TO_DELIVER_E (3002),			
    DIAMETER_REALM_NOT_SERVED_E (3003),
    DIAMETER_TOO_BUSY_E (3004),
    DIAMETER_LOOP_DETECTED_E (3005),
    DIAMETER_REDIRECT_INDICATION_E (3006),
    DIAMETER_APPLICATION_UNSUPPORTED_E (3007),
    DIAMETER_INVALID_HDR_BITS_E (3008),
    DIAMETER_INVALID_AVP_BITS_E (3009),
    DIAMETER_UNKNOWN_PEER_E (3010),
    
    DIAMETER_AUTHENTICATION_REJECTED_E (4001),
    DIAMETER_OUT_OF_SPACE_E (4002),			
    DIAMETER_ELECTION_LOST_E (4003),
    
    DIAMETER_AVP_UNSUPPORTED_E (5001),
    DIAMETER_UNKNOWN_SESSION_ID_E (5002),
    DIAMETER_AUTHORIZATION_REJECTED_E (5003),
    DIAMETER_INVALID_AVP_VALUE_E (5004),
    DIAMETER_MISSING_AVP_E (5005),
    DIAMETER_RESOURCES_EXCEEDED_E (5006),
    DIAMETER_CONTRADICTING_AVPS_E (5007),
    DIAMETER_AVP_NOT_ALLOWED_E (5008),
    DIAMETER_AVP_OCCURS_TOO_MANY_TIMES_E (5009),
    DIAMETER_NO_COMMON_APPLICATION_E (5010),
    DIAMETER_UNSUPPORTED_VERSION_E (5011),
    DIAMETER_UNABLE_TO_COMPLY_E (5012),
    DIAMETER_INVALID_BIT_IN_HEADER_E (5013),
    DIAMETER_INVALID_AVP_LENGTH_E (5014),
    DIAMETER_INVALID_MESSAGE_LENGTH_E (5015),
    DIAMETER_INVALID_AVP_BIT_COMBO_E (5016),
    DIAMETER_NO_COMMON_SECURITY_E (5017)	
};*/

const char* Result_Code_Type::msKeywordEnums[] = { 
		"DIAMETER_DUMMY_E",// (0),
    
		"DIAMETER_MULTI_ROUND_AUTH_E",// (1001),
	    
		"DIAMETER_SUCCESS_E",// (2001),
		"DIAMETER_LIMITED_SUCCESS_E",// (2002),
	    
		"DIAMETER_COMMAND_UNSUPPORTED_E",// (3001),
		"DIAMETER_UNABLE_TO_DELIVER_E",// (3002),			
		"DIAMETER_REALM_NOT_SERVED_E",// (3003),
		"DIAMETER_TOO_BUSY_E",// (3004),
		"DIAMETER_LOOP_DETECTED_E",// (3005),
		"DIAMETER_REDIRECT_INDICATION_E",// (3006),
		"DIAMETER_APPLICATION_UNSUPPORTED_E",// (3007),
		"DIAMETER_INVALID_HDR_BITS_E",// (3008),
		"DIAMETER_INVALID_AVP_BITS_E",// (3009),
		"DIAMETER_UNKNOWN_PEER_E",// (3010),
	    
		"DIAMETER_AUTHENTICATION_REJECTED_E",// (4001),
		"DIAMETER_OUT_OF_SPACE_E",// (4002),			
		"DIAMETER_ELECTION_LOST_E",// (4003),
	    
		"DIAMETER_AVP_UNSUPPORTED_E",// (5001),
		"DIAMETER_UNKNOWN_SESSION_ID_E",// (5002),
		"DIAMETER_AUTHORIZATION_REJECTED_E",// (5003),
		"DIAMETER_INVALID_AVP_VALUE_E",// (5004),
		"DIAMETER_MISSING_AVP_E",// (5005),
		"DIAMETER_RESOURCES_EXCEEDED_E",// (5006),
		"DIAMETER_CONTRADICTING_AVPS_E",// (5007),
		"DIAMETER_AVP_NOT_ALLOWED_E",// (5008),
		"DIAMETER_AVP_OCCURS_TOO_MANY_TIMES_E",// (5009),
		"DIAMETER_NO_COMMON_APPLICATION_E",// (5010),
		"DIAMETER_UNSUPPORTED_VERSION_E",// (5011),
		"DIAMETER_UNABLE_TO_COMPLY_E",// (5012),
		"DIAMETER_INVALID_BIT_IN_HEADER_E",// (5013),
		"DIAMETER_INVALID_AVP_LENGTH_E",// (5014),
		"DIAMETER_INVALID_MESSAGE_LENGTH_E",// (5015),
		"DIAMETER_INVALID_AVP_BIT_COMBO_E",// (5016),
		"DIAMETER_NO_COMMON_SECURITY_E",// (5017)	
		"" };

const unsigned int Result_Code_Type::msKeywordIds[] = { 
		0, //DIAMETER_DUMMY_E (),
    
		1001, //DIAMETER_MULTI_ROUND_AUTH_E (),
	    
		2001, //DIAMETER_SUCCESS_E (),
		2002, //DIAMETER_LIMITED_SUCCESS_E (),
	    
		3001, //DIAMETER_COMMAND_UNSUPPORTED_E (),
		3002, //DIAMETER_UNABLE_TO_DELIVER_E (),			
		3003, //DIAMETER_REALM_NOT_SERVED_E (),
		3004, //DIAMETER_TOO_BUSY_E (),
		3005, //DIAMETER_LOOP_DETECTED_E (),
		3006, //DIAMETER_REDIRECT_INDICATION_E (),
		3007, //DIAMETER_APPLICATION_UNSUPPORTED_E (),
		3008, //DIAMETER_INVALID_HDR_BITS_E (),
		3009, //DIAMETER_INVALID_AVP_BITS_E (),
		3010, //DIAMETER_UNKNOWN_PEER_E (),
	    
		4001, //DIAMETER_AUTHENTICATION_REJECTED_E (),
		4002, //DIAMETER_OUT_OF_SPACE_E (),			
		4003, //DIAMETER_ELECTION_LOST_E (),
	    
		5001, //DIAMETER_AVP_UNSUPPORTED_E (),
		5002, //DIAMETER_UNKNOWN_SESSION_ID_E (),
		5003, //DIAMETER_AUTHORIZATION_REJECTED_E (),
		5004, //DIAMETER_INVALID_AVP_VALUE_E (),
		5005, //DIAMETER_MISSING_AVP_E (),
		5006, //DIAMETER_RESOURCES_EXCEEDED_E (),
		5007, //DIAMETER_CONTRADICTING_AVPS_E (),
		5008, //DIAMETER_AVP_NOT_ALLOWED_E (),
		5009, //DIAMETER_AVP_OCCURS_TOO_MANY_TIMES_E (),
		5010, //DIAMETER_NO_COMMON_APPLICATION_E (),
		5011, //DIAMETER_UNSUPPORTED_VERSION_E (),
		5012, //DIAMETER_UNABLE_TO_COMPLY_E (),
		5013, //DIAMETER_INVALID_BIT_IN_HEADER_E (),
		5014, //DIAMETER_INVALID_AVP_LENGTH_E (),
		5015, //DIAMETER_INVALID_MESSAGE_LENGTH_E (),
		5016, //DIAMETER_INVALID_AVP_BIT_COMBO_E (),
		5017//DIAMETER_NO_COMMON_SECURITY_E	
		};

/*type enumerated Re_Auth_Req_Type{
	//Ref: RFC3588 8.12.  Re-Auth-Request-Type AVP
	AUTHORIZE_ONLY_E (0),
	AUTHORIZE_AUTHENTICATE_E (1)                 
};*/
const char* Re_Auth_Req_Type::msKeywordEnums[] = { 
		"AUTHORIZE_ONLY_E",// (0),
    	"AUTHORIZE_AUTHENTICATE_E",// (1)    
		"" };
const int Re_Auth_Req_Type::msKeywordIds[] = { 
		0,//AUTHORIZE_ONLY_E (),
    	1//AUTHORIZE_AUTHENTICATE_E ()    
		};

/*type enumerated Redirect_Host_Usage_Type{
	DONT_CACHE_E (0),
	ALL_SESSION_E (1),
	ALL_REALM_E (2),
	REALM_AND_APPLICATION_E (3),
	ALL_APPLICATION_E (4),
	ALL_HOST_E (5),
	ALL_USER_E  (6)
};*/
const char* Redirect_Host_Usage_Type::msKeywordEnums[] = { 
		"DONT_CACHE_E",// (0),
		"ALL_SESSION_E",// (1),
		"ALL_REALM_E",// (2),
		"REALM_AND_APPLICATION_E",// (3),
		"ALL_APPLICATION_E",// (4),
		"ALL_HOST_E",// (5),
		"ALL_USER_E",//  (6)
		"" };
const int Redirect_Host_Usage_Type::msKeywordIds[] = { 
		0,//DONT_CACHE_E (),
		1,//ALL_SESSION_E (),
		2,//ALL_REALM_E (),
		3,//REALM_AND_APPLICATION_E (),
		4,//ALL_APPLICATION_E (),
		5,//ALL_HOST_E (),
		6//ALL_USER_E  ()
		};

/*type enumerated Acc_Record_Type{
	EVENT_RECORD_E (1),                  
	START_RECORD_E  (2),                 
	INTERIM_RECORD_E (3),              
	STOP_RECORD_E    (4)                 
};*/
const char* Acc_Record_Type::msKeywordEnums[] = { 
		"EVENT_RECORD_E",// (1),                  
		"START_RECORD_E",//  (2),                 
		"INTERIM_RECORD_E",// (3),              
		"STOP_RECORD_E",//    (4) 
		"" };
const int Acc_Record_Type::msKeywordIds[] = { 
		1,//EVENT_RECORD_E (),                  
		2,//START_RECORD_E  (),                 
		3,//INTERIM_RECORD_E (),              
		4//STOP_RECORD_E    () 
		};

/*type enumerated Acc_Realtime_Req_Type{
	DELIVER_AND_GRANT_E (1),
	GRANT_AND_STORE_E (2),
	GRANT_AND_LOSE_E (3)
};*/
const char* Acc_Realtime_Req_Type::msKeywordEnums[] = { 
		"DELIVER_AND_GRANT_E",// (1),
		"GRANT_AND_STORE_E",// (2),
		"GRANT_AND_LOSE_E",// (3)
		"" };
const int Acc_Realtime_Req_Type::msKeywordIds[] = { 
		1,//DELIVER_AND_GRANT_E (),
		2,//GRANT_AND_STORE_E (),
		3//GRANT_AND_LOSE_E ()
		};

/*type enumerated Termination_Cause_Type{
	DIAMETER_LOGOUT_E (1),
	DIAMETER_SERVICE_NOT_PROVIDED_E (2),
	DIAMETER_BAD_ANSWER_E (3),
	DIAMETER_ADMINISTRATIVE_E (4),
	DIAMETER_LINK_BROKEN_E (5),
	DIAMETER_AUTH_EXPIRED_E (6),
	DIAMETER_USER_MOVED_E (7),
	DIAMETER_SESSION_TIMEOUT_E (8)
};*/
const char* Termination_Cause_Type::msKeywordEnums[] = { 
		"DIAMETER_LOGOUT_E",// (1),
		"DIAMETER_SERVICE_NOT_PROVIDED_E",// (2),
		"DIAMETER_BAD_ANSWER_E",// (3),
		"DIAMETER_ADMINISTRATIVE_E",// (4),
		"DIAMETER_LINK_BROKEN_E",// (5),
		"DIAMETER_AUTH_EXPIRED_E",// (6),
		"DIAMETER_USER_MOVED_E",// (7),
		"DIAMETER_SESSION_TIMEOUT_E",// (8)
		"" };
const int Termination_Cause_Type::msKeywordIds[] = { 
		1,//DIAMETER_LOGOUT_E (),
		2,//DIAMETER_SERVICE_NOT_PROVIDED_E (),
		3,//DIAMETER_BAD_ANSWER_E (),
		4,//DIAMETER_ADMINISTRATIVE_E (),
		5,//DIAMETER_LINK_BROKEN_E (),
		6,//DIAMETER_AUTH_EXPIRED_E (),
		7,//DIAMETER_USER_MOVED_E (),
		8//DIAMETER_SESSION_TIMEOUT_E ()
		};

/*type enumerated Disconnect_Cause_Type{
	REBOOTING_E (0),
	BUSY_E (1),
	DO_NOT_WANT_TO_TALK_TO_YOU_E (2)
};*/
const char* Disconnect_Cause_Type::msKeywordEnums[] = { 
		"REBOOTING_E",// (0),
    	"BUSY_E",// (1),
    	"DO_NOT_WANT_TO_TALK_TO_YOU_E",// (2)
		"" };
const int Disconnect_Cause_Type::msKeywordIds[] = { 
		0,//REBOOTING_E (),
		1,//BUSY_E (),
		2//DO_NOT_WANT_TO_TALK_TO_YOU_E ()
		};


/*type enumerated Auth_Session_State_Type{
	STATE_MAINTAINED_E (0),
	NO_STATE_MAINTAINED_E (1)
};*/
const char* Auth_Session_State_Type::msKeywordEnums[] = { 
		"STATE_MAINTAINED_E",// (0),
    	"NO_STATE_MAINTAINED_E",// (1)
		"" };
const int Auth_Session_State_Type::msKeywordIds[] = { 
		0,//STATE_MAINTAINED_E (),
    	1//NO_STATE_MAINTAINED_E ()
		};

/*type enumerated SIP_User_Auth_Ty_Type{
	//Ref: RFC4740, section 9.10
	REGISTRATION_E (0),
	DEREGISTRATION_E (1),
	REGISTRATION_AND_CAPABILITIES_E (2)
};*/

const char* SIP_User_Auth_Ty_Type::msKeywordEnums[] = { 
		"REGISTRATION_E",// (0),
		"DEREGISTRATION_E",// (1),
		"REGISTRATION_AND_CAPABILITIES_E",// (2)
		"" };
const int SIP_User_Auth_Ty_Type::msKeywordIds[] = { 
		0,//REGISTRATION_E (),
		1,//DEREGISTRATION_E (),
		2//REGISTRATION_AND_CAPABILITIES_E ()
		};

///////////////////////
/*type enumerated SIP_Srv_Assgmt_Type{
	NO_ASSIGNMENT_E (0),
	REGISTRATION_E (1), 
	RE_REGISTRATION_E (2), 
	UNREGISTERED_USER_E (3),
	TIMEOUT_DEREGISTRATION_E (4),
	USER_DEREGISTRATION_E (5),
	TIMEOUT_DEREGISTRATION_STORE_SERVER_NAME_E (6),
	USER_DEREGISTRATION_STORE_SERVER_NAME_E (7),
	ADMINISTRATIVE_DEREGISTRATION_E (8),
	AUTHENTICATION_FAILURE_E (9),
	AUTHENTICATION_TIMEOUT_E (10),
	DEREGISTRATION_TOO_MUCH_DATA_E (11)	
};*/
const char* SIP_Srv_Assgmt_Type::msKeywordEnums[] = { 
	"NO_ASSIGNMENT_E",// (0),
	"REGISTRATION_E",// (1), 
	"RE_REGISTRATION_E",// (2), 
	"UNREGISTERED_USER_E",// (3),
	"TIMEOUT_DEREGISTRATION_E",// (4),
	"USER_DEREGISTRATION_E",// (5),
	"TIMEOUT_DEREGISTRATION_STORE_SERVER_NAME_E",// (6),
	"USER_DEREGISTRATION_STORE_SERVER_NAME_E",// (7),
	"ADMINISTRATIVE_DEREGISTRATION_E",// (8),
	"AUTHENTICATION_FAILURE_E",// (9),
	"AUTHENTICATION_TIMEOUT_E",// (10),
	"DEREGISTRATION_TOO_MUCH_DATA_E",// (11)	
		"" };
const int SIP_Srv_Assgmt_Type::msKeywordIds[] = { 
		0,//NO_ASSIGNMENT_E (),
		1,//REGISTRATION_E (), 
		2,//RE_REGISTRATION_E (), 
		3,//UNREGISTERED_USER_E (),
		4,//TIMEOUT_DEREGISTRATION_E (),
		5,//USER_DEREGISTRATION_E (),
		6,//TIMEOUT_DEREGISTRATION_STORE_SERVER_NAME_E (),
		7,//USER_DEREGISTRATION_STORE_SERVER_NAME_E (),
		8,//ADMINISTRATIVE_DEREGISTRATION_E (),
		9,//AUTHENTICATION_FAILURE_E (),
		10,//AUTHENTICATION_TIMEOUT_E (),
		11//DEREGISTRATION_TOO_MUCH_DATA_E ()	
		};


/*type enumerated SIP_Usr_Dat_Al_Av_Type{
	USER_DATA_NOT_AVAILABLE_E (0),
	USER_DATA_ALREADY_AVAILABLE_E (1)
};*/
const char* SIP_Usr_Dat_Al_Av_Type::msKeywordEnums[] = { 
		"USER_DATA_NOT_AVAILABLE_E",// (0),
		"USER_DATA_ALREADY_AVAILABLE_E",// (1)
		"" };
const int SIP_Usr_Dat_Al_Av_Type::msKeywordIds[] = { 
		0,//USER_DATA_NOT_AVAILABLE_E (),
		1//USER_DATA_ALREADY_AVAILABLE_E ()
		};

/*type enumerated SIP_Auth_Schm_Type{
	DIGEST_E (0)
};*/
const char* SIP_Auth_Schm_Type::msKeywordEnums[] = { 
		"DIGEST_E",// (0)
		"" };
const int SIP_Auth_Schm_Type::msKeywordIds[] = { 
		0//DIGEST_E ()
		};

/*type enumerated SIP_Reason_Code_Type{			
  	PERMANENT_TERMINATION_E (0),
	NEW_SIP_SERVER_ASSIGNED_E (1),
	SIP_SERVER_CHANGE_E (2),
	REMOVE_SIP_SERVER_E (3)
};*/
const char* SIP_Reason_Code_Type::msKeywordEnums[] = { 
		"PERMANENT_TERMINATION_E",// (0),
		"NEW_SIP_SERVER_ASSIGNED_E",// (1),
		"SIP_SERVER_CHANGE_E",// (2),
		"REMOVE_SIP_SERVER_E",// (3)
		"" };
const int SIP_Reason_Code_Type::msKeywordIds[] = { 
		0,//PERMANENT_TERMINATION_E (),
		1,//NEW_SIP_SERVER_ASSIGNED_E (),
		2,//SIP_SERVER_CHANGE_E (),
		3//REMOVE_SIP_SERVER_E ()
		};




/*type enumerated Data_Reference_Type{
	REPOSITORY_DATA_E (0),
	IMS_PUBLIC_IDENTITY_E (10),
	IMS_USER_STATE_E (11),
	S_CSCF_NAME_E (12),
	INITIAL_FILTER_CRITERIA_E (13),
	LOCATION_INFORMATION_E (14),
	USER_STATE_E (15),
	CHARGING_INFORMATION_E (16),
	MSISDN_E (17),
	PSI_ACTIVATION_E (18),
	DSAI_E (19),
	SERVICE_TRACE_LEVEL_INFO_E (21)						
};*/
const char* Data_Reference_Type::msKeywordEnums[] = { 
		"REPOSITORY_DATA_E",// (0),
		"IMS_PUBLIC_IDENTITY_E",// (10),
		"IMS_USER_STATE_E",// (11),
		"S_CSCF_NAME_E",// (12),
		"INITIAL_FILTER_CRITERIA_E",// (13),
		"LOCATION_INFORMATION_E",// (14),
		"USER_STATE_E",// (15),
		"CHARGING_INFORMATION_E",// (16),
		"MSISDN_E",// (17),
		"PSI_ACTIVATION_E",// (18),
		"DSAI_E",// (19),
		"SERVICE_TRACE_LEVEL_INFO_E",// (21)	
		"" };
const int Data_Reference_Type::msKeywordIds[] = { 
		0,//REPOSITORY_DATA_E (),
		10,//IMS_PUBLIC_IDENTITY_E (),
		11,//IMS_USER_STATE_E (),
		12,//S_CSCF_NAME_E (),
		13,//INITIAL_FILTER_CRITERIA_E (),
		14,//LOCATION_INFORMATION_E (),
		15,//USER_STATE_E (),
		16,//CHARGING_INFORMATION_E (),
		17,//MSISDN_E (),
		18,//PSI_ACTIVATION_E (),
		19,//DSAI_E (),
		21//SERVICE_TRACE_LEVEL_INFO_E ()	
		};


/*type enumerated Subs_Req_Ty_Type{
	SUBSCRIBE_E (0),
	UNSUBSCRIBE_E (1)
};*/
const char* Subs_Req_Ty_Type::msKeywordEnums[] = { 
		"SUBSCRIBE_E",// (0),
		"UNSUBSCRIBE_E",// (1)
		"" };
const int Subs_Req_Ty_Type::msKeywordIds[] = { 
		0,//SUBSCRIBE_E (),
		1//UNSUBSCRIBE_E ()
		};



/*type enumerated Request_Domain_Type{
	CS_DOMAIN_E (0),
	PS_DOMAIN_E (1)			
};*/
const char* Request_Domain_Type::msKeywordEnums[] = { 
		"CS_DOMAIN_E",// (0),
		"PS_DOMAIN_E",// (1)			
		"" };
const int Request_Domain_Type::msKeywordIds[] = { 
		0,//CS_DOMAIN_E (),
		1//PS_DOMAIN_E ()			
		};


/*type enumerated Current_Location_Type{
	DO_NOT_NEED_INITIATE_ACTIVATE_LOCATION_RETRIEVAL_E (0),
    INITIATE_ACTIVATE_LOCATION_RETRIEVAL_E (1)			
};*/
const char* Current_Location_Type::msKeywordEnums[] = { 
		"DO_NOT_NEED_INITIATE_ACTIVATE_LOCATION_RETRIEVAL_E",// (0),
		"INITIATE_ACTIVATE_LOCATION_RETRIEVAL_E",// (1)			
		"" };
const int Current_Location_Type::msKeywordIds[] = { 
		0,//DO_NOT_NEED_INITIATE_ACTIVATE_LOCATION_RETRIEVAL_E (),
		1//INITIATE_ACTIVATE_LOCATION_RETRIEVAL_E ()			
		};


/*type enumerated Identity_Set_Type{
	ALL_IDENTITIES_E (0),
	REGISTERED_IDENTITIES_E (1),
	IMPLICIT_IDENTITIES_E (2),
	ALIAS_IDENTITIES_E (3)			
};	*/
const char* Identity_Set_Type::msKeywordEnums[] = { 
		"ALL_IDENTITIES_E",// (0),
		"REGISTERED_IDENTITIES_E",// (1),
		"IMPLICIT_IDENTITIES_E",// (2),
		"ALIAS_IDENTITIES_E",// (3)			
		"" };
const int Identity_Set_Type::msKeywordIds[] = { 
		0,//ALL_IDENTITIES_E (),
		1,//REGISTERED_IDENTITIES_E (),
		2,//IMPLICIT_IDENTITIES_E (),
		3//ALIAS_IDENTITIES_E ()			
		};



/*type enumerated Send_Data_Indication_Type{
	USER_DATA_NOT_REQUESTED_E (0),
	USER_DATA_REQUESTED_E (1)
};*/
const char* Send_Data_Indication_Type::msKeywordEnums[] = { 
	"USER_DATA_NOT_REQUESTED_E",// (0),
	"USER_DATA_REQUESTED_E",// (1)
		"" };
const int Send_Data_Indication_Type::msKeywordIds[] = { 
		0,//USER_DATA_NOT_REQUESTED_E (),
		1//USER_DATA_REQUESTED_E ()
		};

//TODO: I cannot find a definition for this in the standards with the same ID...???
/*type enumerated Experimental_Result_Type{
	DIAMETER_FIRST_REGISTRATION_E (2001),
	DIAMETER_SUBSEQUENT_REGISTRATION_E (2002),
	DIAMETER_UNREGISTERED_SERVICE_E (2003),
	DIAMETER_SUCCESS_SERVER_NAME_NOT_STORED_E (2004),			
	DIAMETER_ERROR_USER_UNKNOWN_E (5001),
	DIAMETER_ERROR_IDENTITIES_DONT_MATCH_E (5002),
	DIAMETER_ERROR_IDENTITY_NOT_REGISTERED_E (5003),
	DIAMETER_ERROR_ROAMING_NOT_ALLOWED_E (5004),
	DIAMETER_ERROR_IDENTITY_ALREADY_REGISTERED_E (5005),
	DIAMETER_ERROR_AUTH_SCHEME_NOT_SUPPORTED_E (5006),
	DIAMETER_ERROR_IN_ASSIGNMENT_TYPE_E (5007),
	DIAMETER_ERROR_TOO_MUCH_DATA_E (5008),
	DIAMETER_ERROR_NOT_SUPPORTED_USER_DATA_E (5009),
    // Ref: ETSI TS 129 214 5.5
    INVALID_SERVICE_INFORMATION_E (5061),
    FILTER_RESTRICTIONS_E (5062),
    REQUESTED_SERVICE_NOT_AUTHORIZED_E (5063),
    DUPLICATED_AF_SESSION_E (5064),
    IP_CAN_SESSION_NOT_AVAILABLE_E (5065),
    UNAUTHORIZED_NON_EMERGENCY_SESSION_E (5066),
    UNAUTHORIZED_SPONSORED_DATA_CONNECTIVITY_E (5067),
    DIAMETER_ERROR_INITIAL_PARAMETERS_E (5140),
    DIAMETER_ERROR_TRIGGER_EVENT_E (5141),
    DIAMETER_PCC_RULE_EVENT_E (5142),
    DIAMETER_ERROR_BEARER_NOT_AUTHORIZED_E (5143),
    DIAMETER_ERROR_TRAFFIC_MAPPING_INFO_REJECTED_E (5144),
    DIAMETER_ERROR_CONFLICTING_REQUEST_E (5147)			
}; */
const char* Experimental_Result_Type::msKeywordEnums[] = {
		"DIAMETER_FIRST_REGISTRATION_E",// (2001),
		"DIAMETER_SUBSEQUENT_REGISTRATION_E",// (2002),
		"DIAMETER_UNREGISTERED_SERVICE_E",// (2003),
		"DIAMETER_SUCCESS_SERVER_NAME_NOT_STORED_E",// (2004),			
		"DIAMETER_ERROR_USER_UNKNOWN_E",// (5001),
		"DIAMETER_ERROR_IDENTITIES_DONT_MATCH_E",// (5002),
		"DIAMETER_ERROR_IDENTITY_NOT_REGISTERED_E",// (5003),
		"DIAMETER_ERROR_ROAMING_NOT_ALLOWED_E",// (5004),
		"DIAMETER_ERROR_IDENTITY_ALREADY_REGISTERED_E",// (5005),
		"DIAMETER_ERROR_AUTH_SCHEME_NOT_SUPPORTED_E",// (5006),
		"DIAMETER_ERROR_IN_ASSIGNMENT_TYPE_E",// (5007),
		"DIAMETER_ERROR_TOO_MUCH_DATA_E",// (5008),
		"DIAMETER_ERROR_NOT_SUPPORTED_USER_DATA_E",// (5009),
		// Ref: ETSI TS 129 214 5.5
		"INVALID_SERVICE_INFORMATION_E",// (5061),
		"FILTER_RESTRICTIONS_E",// (5062),
		"REQUESTED_SERVICE_NOT_AUTHORIZED_E",// (5063),
		"DUPLICATED_AF_SESSION_E",// (5064),
		"IP_CAN_SESSION_NOT_AVAILABLE_E",// (5065),
		"UNAUTHORIZED_NON_EMERGENCY_SESSION_E",// (5066),
		"UNAUTHORIZED_SPONSORED_DATA_CONNECTIVITY_E",// (5067),
		"DIAMETER_ERROR_INITIAL_PARAMETERS_E",// (5140),
		"DIAMETER_ERROR_TRIGGER_EVENT_E",// (5141),
		"DIAMETER_PCC_RULE_EVENT_E",// (5142),
		"DIAMETER_ERROR_BEARER_NOT_AUTHORIZED_E",// (5143),
		"DIAMETER_ERROR_TRAFFIC_MAPPING_INFO_REJECTED_E",// (5144),
		"DIAMETER_ERROR_CONFLICTING_REQUEST_E",// (5147)		
		"" };
const unsigned int Experimental_Result_Type::msKeywordIds[] = { 
		2001,//DIAMETER_FIRST_REGISTRATION_E (),
		2002,//DIAMETER_SUBSEQUENT_REGISTRATION_E (),
		2003,//DIAMETER_UNREGISTERED_SERVICE_E (),
		2004,//DIAMETER_SUCCESS_SERVER_NAME_NOT_STORED_E (),			
		5001,//DIAMETER_ERROR_USER_UNKNOWN_E (),
		5002,//DIAMETER_ERROR_IDENTITIES_DONT_MATCH_E (),
		5003,//DIAMETER_ERROR_IDENTITY_NOT_REGISTERED_E (),
		5004,//DIAMETER_ERROR_ROAMING_NOT_ALLOWED_E (),
		5005,//DIAMETER_ERROR_IDENTITY_ALREADY_REGISTERED_E (),
		5006,//DIAMETER_ERROR_AUTH_SCHEME_NOT_SUPPORTED_E (),
		5007,//DIAMETER_ERROR_IN_ASSIGNMENT_TYPE_E (),
		5008,//DIAMETER_ERROR_TOO_MUCH_DATA_E (),
		5009,//DIAMETER_ERROR_NOT_SUPPORTED_USER_DATA_E (),
		// Ref: ETSI TS 129 214 5.5
		5061,//INVALID_SERVICE_INFORMATION_E (),
		5062,//FILTER_RESTRICTIONS_E (),
		5063,//REQUESTED_SERVICE_NOT_AUTHORIZED_E (),
		5064,//DUPLICATED_AF_SESSION_E (),
		5065,//IP_CAN_SESSION_NOT_AVAILABLE_E (),
		5066,//UNAUTHORIZED_NON_EMERGENCY_SESSION_E (),
		5067,//UNAUTHORIZED_SPONSORED_DATA_CONNECTIVITY_E (),
		5140,//DIAMETER_ERROR_INITIAL_PARAMETERS_E (),
		5141,//DIAMETER_ERROR_TRIGGER_EVENT_E (),
		5142,//DIAMETER_PCC_RULE_EVENT_E (),
		5143,//DIAMETER_ERROR_BEARER_NOT_AUTHORIZED_E (),
		5144,//DIAMETER_ERROR_TRAFFIC_MAPPING_INFO_REJECTED_E (),
		5147//DIAMETER_ERROR_CONFLICTING_REQUEST_E ()		
		 };



/*type enumerated CC_Request_Ty_Type{
// Ref: RFC4006 8.3.  CC-Request-Type AVP
	INITIAL_REQUEST_E (1),
	UPDATE_REQUEST_E (2),
	TERMINATION_REQUEST_E (3),
	EVENT_REQUEST_E  (4)
};*/
const char* CC_Request_Ty_Type::msKeywordEnums[] = { 
		"INITIAL_REQUEST_E",// (1),
    	"UPDATE_REQUEST_E",// (2),
     	"TERMINATION_REQUEST_E",// (3),
    	"EVENT_REQUEST_E",//  (4)
		"" };
const int CC_Request_Ty_Type::msKeywordIds[] = { 
		1,//INITIAL_REQUEST_E (),
    	2,//UPDATE_REQUEST_E (),
     	3,//TERMINATION_REQUEST_E (),
    	4,//EVENT_REQUEST_E  ()
		};


/*type enumerated Subscription_Id_Ty_Type{
	// Ref: RFC4006 8.47.  Subscription-Id-Type AVP
	END_USER_E164_E (0),
	END_USER_IMSI_E (1),
	END_USER_SIP_URI_E (2),
	END_USER_NAI_E  (3),
	END_USER_PRIVATE_E (4)
};*/
const char* Subscription_Id_Ty_Type::msKeywordEnums[] = { 
		"END_USER_E164_E",// (0),
		"END_USER_IMSI_E",// (1),
		"END_USER_SIP_URI_E",// (2),
		"END_USER_NAI_E",//  (3),
		"END_USER_PRIVATE_E",// (4)
		"" };
const int Subscription_Id_Ty_Type::msKeywordIds[] = { 
		0,//END_USER_E164_E (),
    	1,//END_USER_IMSI_E (),
    	2,//END_USER_SIP_URI_E (),
    	3,//END_USER_NAI_E  (),
    	4,//END_USER_PRIVATE_E ()
		};


/*type enumerated Requested_Action_Type{
	// Ref: RFC4006 8.41.  Requested-Action AVP
	DIRECT_DEBITING_E (0),
	REFUND_ACCOUNT_E (1),
	CHECK_BALANCE_E (2),
	PRICE_ENQUIRY_E (3)
};*/
const char* Requested_Action_Type::msKeywordEnums[] = { 
		"DIRECT_DEBITING_E",// (0),
		"REFUND_ACCOUNT_E",// (1),
		"CHECK_BALANCE_E",// (2),
		"PRICE_ENQUIRY_E",// (3)
		"" };
const int Requested_Action_Type::msKeywordIds[] = { 
		0,//DIRECT_DEBITING_E (),
    	1,//REFUND_ACCOUNT_E (),
    	2,//CHECK_BALANCE_E (),
    	3,//PRICE_ENQUIRY_E ()
		};


/*type enumerated Tariff_Change_Usage_Type{
	// Ref: RFC4006 8.27.  Tariff-Change-Usage AVP
	UNIT_BEFORE_TARIFF_CHANGE_E (0),
	UNIT_AFTER_TARIFF_CHANGE_E (1),
  	UNIT_INDETERMINATE_E (2)
};*/
const char* Tariff_Change_Usage_Type::msKeywordEnums[] = { 
		"UNIT_BEFORE_TARIFF_CHANGE_E",// (0),
		"UNIT_AFTER_TARIFF_CHANGE_E",// (1),
 	  	"UNIT_INDETERMINATE_E",// (2)
		"" };
const int Tariff_Change_Usage_Type::msKeywordIds[] = { 
		0,//UNIT_BEFORE_TARIFF_CHANGE_E (),
    	1,//UNIT_AFTER_TARIFF_CHANGE_E (),
    	2,//UNIT_INDETERMINATE_E ()
		};


/*type enumerated Multiple_Serv_Indi_Type{
	// Ref: RFC4006 8.40.  Multiple-Services-Indicator AVP
	MULTIPLE_SERVICES_NOT_SUPPORTED_E (0),
	MULTIPLE_SERVICES_SUPPORTED_E     (1)		
};*/
const char* Multiple_Serv_Indi_Type::msKeywordEnums[] = { 
		"MULTIPLE_SERVICES_NOT_SUPPORTED_E",// (0),
      	"MULTIPLE_SERVICES_SUPPORTED_E",//     (1)	
		"" };
const int Multiple_Serv_Indi_Type::msKeywordIds[] = { 
		0,//MULTIPLE_SERVICES_NOT_SUPPORTED_E (),
      	1,//MULTIPLE_SERVICES_SUPPORTED_E     ()	
		};


/*type enumerated CC_Unit_Ty_Type {
	// Ref: RFC4006 8.31.  G-S-U-Pool-Identifier AVP
	TIME_E (0),
	MONEY_E (1),
	TOTAL_OCTETS_E (2),
	INPUT_OCTETS_E (3),
	OUTPUT_OCTETS_E (4),
	SERVICE_SPECIFIC_UNITS_E (5)		
};*/
const char* CC_Unit_Ty_Type::msKeywordEnums[] = { 
		"TIME_E",// (0),
		"MONEY_E",// (1),
		"TOTAL_OCTETS_E",// (2),
		"INPUT_OCTETS_E",// (3),
		"OUTPUT_OCTETS_E",// (4),
		"SERVICE_SPECIFIC_UNITS_E",// (5)
		"" };
const int CC_Unit_Ty_Type::msKeywordIds[] = { 
		0,//TIME_E (),
        1,//MONEY_E (),
        2,//TOTAL_OCTETS_E (),
        3,//INPUT_OCTETS_E (),
        4,//OUTPUT_OCTETS_E (),
        5,//SERVICE_SPECIFIC_UNITS_E ()
		};


/*type enumerated Final_Unit_Action_Type{
	// Ref: RFC4006 8.35.  Final-Unit-Action AVP
	TERMINATE_E (0),
	REDIRECT_E (1),
	RESTRICT_ACCESS_E (2)				
};*/
const char* Final_Unit_Action_Type::msKeywordEnums[] = { 
		"TERMINATE_E",// (0),
		"REDIRECT_E",// (1),
		"RESTRICT_ACCESS_E",// (2)	
		"" };
const int Final_Unit_Action_Type::msKeywordIds[] = { 
		0,//TERMINATE_E (),
    	1,//REDIRECT_E (),
    	2,//RESTRICT_ACCESS_E ()	
		};


/*type enumerated Redirect_Address_Ty_Type{
	// Ref: RFC4006 8.38.  Redirect-Address-Type AVP
	IPV4_ADDRESS_E (0),
	IPV6_ADDRESS_E (1),
	URL_E (2),
	SIP_URI_E (3)
};*/
const char* Redirect_Address_Ty_Type::msKeywordEnums[] = { 
		"IPV4_ADDRESS_E",// (0),
		"IPV6_ADDRESS_E",// (1),
		"URL_E",// (2),
		"SIP_URI_E",// (3)
		"" };
const int Redirect_Address_Ty_Type::msKeywordIds[] = { 
		0,//IPV4_ADDRESS_E (),
    	1,//IPV6_ADDRESS_E (),
     	2,//URL_E (),
    	3,//SIP_URI_E ()
		};


/*type enumerated User_Equipment_Info_Ty_Type	{
	// Ref: RFC4006 8.50.  User-Equipment-Info-Type AVP
	IMEISV_E (0),
	MAC_E (1),
	EUI64_E (2),
	MODIFIED_EUI64_E (3)
};*/
const char* User_Equipment_Info_Ty_Type::msKeywordEnums[] = {
		"IMEISV_E",// (0),
    	"MAC_E",// (1),
    	"EUI64_E",// (2),
    	"MODIFIED_EUI64_E",// (3)
		"" };
const int User_Equipment_Info_Ty_Type::msKeywordIds[] = { 
		0,//IMEISV_E (),
		1,//MAC_E (),
		2,//EUI64_E (),
		3,//MODIFIED_EUI64_E ()
		};


/*type enumerated CC_Session_Failover_Type{
	// Ref: RFC4006 8.4.  CC-Session-Failover AVP
	FAILOVER_NOT_SUPPORTED_E (0),
	FAILOVER_SUPPORTED_E  (1)
};*/
const char* CC_Session_Failover_Type::msKeywordEnums[] = { 
		"FAILOVER_NOT_SUPPORTED_E",// (0),
		"FAILOVER_SUPPORTED_E",//  (1)
		"" };
const int CC_Session_Failover_Type::msKeywordIds[] = { 
		0,//FAILOVER_NOT_SUPPORTED_E (),
    	1,//FAILOVER_SUPPORTED_E  ()
		};


/*type enumerated Check_Balance_Result_Type{
	// Ref: RFC4006	8.6.  Check-Balance-Result AVP
	ENOUGH_CREDIT_E (0),
	NO_CREDIT_E (1)
};	*/
const char* Check_Balance_Result_Type::msKeywordEnums[] = { 
		"ENOUGH_CREDIT_E",// (0),
    	"NO_CREDIT_E",// (1)
		"" };
const int Check_Balance_Result_Type::msKeywordIds[] = { 
		0,//ENOUGH_CREDIT_E (),
    	1,//NO_CREDIT_E ()
		};


/*type enumerated Credit_Cont_Fail_Hand_Type{
	// Ref: RFC4006 8.14.  Credit-Control-Failure-Handling AVP
	TERMINATE_E (0),
	CONTINUE_E  (1),
	RETRY_AND_TERMINATE_E (2)				
};*/
const char* Credit_Cont_Fail_Hand_Type::msKeywordEnums[] = { 
		"TERMINATE_E",// (0),
    	"CONTINUE_E",//  (1),
    	"RETRY_AND_TERMINATE_E",// (2)		
		"" };
const int Credit_Cont_Fail_Hand_Type::msKeywordIds[] = { 
		0,//TERMINATE_E (),
		1,//CONTINUE_E  (),
		2,//RETRY_AND_TERMINATE_E ()		
		};


/*type enumerated Direct_Debi_Fail_Hand_Type{
	// Ref: RFC4006 8.15.  Direct-Debiting-Failure-Handling AVP
	TERMINATE_OR_BUFFER_E (0),
	CONTINUE_E (1)
};*/
const char* Direct_Debi_Fail_Hand_Type::msKeywordEnums[] = { 
		"TERMINATE_OR_BUFFER_E",// (0),
    	"CONTINUE_E",// (1)
		"" };
const int Direct_Debi_Fail_Hand_Type::msKeywordIds[] = { 
		0,//TERMINATE_OR_BUFFER_E (),
    	1,//CONTINUE_E ()
		};




/*type enumerated Abort_Cause_Type{
    // Ref: ETSI TS 129 214 5.3.1
    BEARER_RELEASED_E (0),
    INSUFFICIENT_SERVER_RESOURCES_E (1),
    INSUFFICIENT_BEARER_RESOURCES_E (2),
    PS_TO_CS_HANDOVER_E (3),
    SPONSORED_DATA_CONNECTIVITY_DISALLOWED_E (4)
};*/
const char* Abort_Cause_Type::msKeywordEnums[] = { 
		"BEARER_RELEASED_E",// (0),
        "INSUFFICIENT_SERVER_RESOURCES_E",// (1),
        "INSUFFICIENT_BEARER_RESOURCES_E",// (2),
        "PS_TO_CS_HANDOVER_E",// (3),
        "SPONSORED_DATA_CONNECTIVITY_DISALLOWED_E",// (4)
		"" };
const int Abort_Cause_Type::msKeywordIds[] = { 
		0,//BEARER_RELEASED_E (),
        1,//INSUFFICIENT_SERVER_RESOURCES_E (),
        2,//INSUFFICIENT_BEARER_RESOURCES_E (),
        3,//PS_TO_CS_HANDOVER_E (),
        4,//SPONSORED_DATA_CONNECTIVITY_DISALLOWED_E ()
		};


/*type enumerated Flow_Status_Type{
    // Ref: ETSI TS 129 214 5.3.11
    ENABLED_UPLINK_E (0),
    ENABLED_DOWNLINK_E (1),
    ENABLED_E (2),
    DISABLED_E (3),
    REMOVED_E (4)
};*/
const char* Flow_Status_Type::msKeywordEnums[] = { 
		"ENABLED_UPLINK_E",// (0),
        "ENABLED_DOWNLINK_E",// (1),
        "ENABLED_E",// (2),
        "DISABLED_E",// (3),
        "REMOVED_E",// (4)
		"" };
const int Flow_Status_Type::msKeywordIds[] = { 
		0,//ENABLED_UPLINK_E (),
        1,//ENABLED_DOWNLINK_E (),
        2,//ENABLED_E (),
        3,//DISABLED_E (),
        4,//REMOVED_E ()
		};


/*type enumerated Flow_Usage_Type{
    // Ref: ETSI TS 129 214 5.3.12
    NO_INFORMATION_E (0),
    RTCP_E (1),
    AF_SIGNALLING_E (2)
};*/
const char* Flow_Usage_Type::msKeywordEnums[] = { 
		"NO_INFORMATION_E",// (0),
        "RTCP_E",// (1),
        "AF_SIGNALLING_E",// (2)
		"" };
const int Flow_Usage_Type::msKeywordIds[] = { 
		0,//NO_INFORMATION_E (),
        1,//RTCP_E (),
        2,//AF_SIGNALLING_E ()
		};

/*type enumerated Specific_Action_Type{
    // Ref: ETSI TS 129 214 5.3.13
    VOID_0_E (0),
    CHARGING_CORRELATION_EXCHANGE_E (1),
    INDICATION_OF_LOSS_OF_BEARER_E (2),
    INDICATION_OF_RECOVERY_OF_BEARER_E (3),
    INDICATION_OF_RELEASE_OF_BEARER_E (4),
    VOID_5_E (5),
    IP_CAN_CHANGE_E (6),
    INDICATION_OF_OUT_OF_CREDIT_E (7),
    INDICATION_OF_SUCCESSFUL_RESOURCES_ALLOCATION_E (8),
    INDICATION_OF_FAILED_RESOURCES_ALLOCATION_E (9),
    INDICATION_OF_LIMITED_PCC_DEPLOYMENT_E (10),
    USAGE_REPORT_E (11)
}; */
const char* Specific_Action_Type::msKeywordEnums[] = { 
		"VOID_0_E",// (0),
        "CHARGING_CORRELATION_EXCHANGE_E",// (1),
        "INDICATION_OF_LOSS_OF_BEARER_E",// (2),
        "INDICATION_OF_RECOVERY_OF_BEARER_E",// (3),
        "INDICATION_OF_RELEASE_OF_BEARER_E",// (4),
        "VOID_5_E",// (5),
        "IP_CAN_CHANGE_E",// (6),
        "INDICATION_OF_OUT_OF_CREDIT_E",// (7),
        "INDICATION_OF_SUCCESSFUL_RESOURCES_ALLOCATION_E",// (8),
        "INDICATION_OF_FAILED_RESOURCES_ALLOCATION_E",// (9),
        "INDICATION_OF_LIMITED_PCC_DEPLOYMENT_E",// (10),
        "USAGE_REPORT_E",// (11)
		"" };
const int Specific_Action_Type::msKeywordIds[] = { 
		0,//VOID_0_E (),
        1,//CHARGING_CORRELATION_EXCHANGE_E (),
        2,//INDICATION_OF_LOSS_OF_BEARER_E (),
        3,//INDICATION_OF_RECOVERY_OF_BEARER_E (),
        4,//INDICATION_OF_RELEASE_OF_BEARER_E (),
        5,//VOID_5_E (),
        6,//IP_CAN_CHANGE_E (),
        7,//INDICATION_OF_OUT_OF_CREDIT_E (),
        8,//INDICATION_OF_SUCCESSFUL_RESOURCES_ALLOCATION_E (),
        9,//INDICATION_OF_FAILED_RESOURCES_ALLOCATION_E (),
        10,//INDICATION_OF_LIMITED_PCC_DEPLOYMENT_E (),
        11,//USAGE_REPORT_E ()
		};


/*type enumerated Media_Type_Type{
    // Ref: ETSI TS 129 214 5.3.19
    AUDIO_E (0),
    VIDEO_E (1),
    DATA_E (2),
    APPLICATION_E (3),
    CONTROL_E (4),
    TEXT_E (5),
    MESSAGE_E (6),
    OTHER_E (7) // OTHER is defined as c_uInt32Max = 0xFFFFFFFF
};*/
const char* Media_Type_Type::msKeywordEnums[] = { 
		"AUDIO_E",// (0),
        "VIDEO_E",// (1),
        "DATA_E",// (2),
        "APPLICATION_E",// (3),
        "CONTROL_E",// (4),
        "TEXT_E",// (5),
        "MESSAGE_E",// (6),
        "OTHER_E",// (7) // OTHER is defined as c_uInt32Max = 0xFFFFFFFF
		"" };
const int Media_Type_Type::msKeywordIds[] = { 
		0,//AUDIO_E (),
        1,//VIDEO_E (),
        2,//DATA_E (),
        3,//APPLICATION_E (),
        4,//CONTROL_E (),
        5,//TEXT_E (),
        6,//MESSAGE_E (),
        7,//OTHER_E () // OTHER is defined as c_uInt32Max = 0xFFFFFFFF
		};


/*type enumerated Service_Info_Type{
    // Ref: ETSI TS 129 214 5.3.25
    FINAL_SERVICE_INFORMATION_E (0),
    PRELIMINARY_SERVICE_INFORMATION_E (1)
};*/
const char* Service_Info_Type::msKeywordEnums[] = { 
		"FINAL_SERVICE_INFORMATION_E",// (0),
        "PRELIMINARY_SERVICE_INFORMATION_E",// (1)
		"" };
const int Service_Info_Type::msKeywordIds[] = { 
		0,//FINAL_SERVICE_INFORMATION_E (),
        1,//PRELIMINARY_SERVICE_INFORMATION_E ()
		};


/*type enumerated SIP_Forking_Indication_Type{
    // Ref: ETSI TS 129 214 5.3.22
    SINGLE_DIALOGUE_E (0),
    SEVERAL_DIALOGUES_E (1)
};*/
const char* SIP_Forking_Indication_Type::msKeywordEnums[] = { 
		"SINGLE_DIALOGUE_E",// (0),
        "SEVERAL_DIALOGUES_E",// (1)
		"" };
const int SIP_Forking_Indication_Type::msKeywordIds[] = { 
		0,//SINGLE_DIALOGUE_E (),
        1,//SEVERAL_DIALOGUES_E ()
		-1 };


/*type enumerated AF_Signalling_Protocol_Type{
                    // Ref: ETSI TS 129 214 5.3.26
                    NO_INFORMATION_E (0),
                    SIP_E (1)
                };*/
const char* AF_Signalling_Protocol_Type::msKeywordEnums[] = { 
		"NO_INFORMATION_E",// (0),
        "SIP_E",// (1)
		"" };
const int AF_Signalling_Protocol_Type::msKeywordIds[] = { 
		0,//NO_INFORMATION_E (),
        1,//SIP_E ()
		};




/*type enumerated Reservation_Priority_Type{
    // Ref: ETSI TS 183 017 7.3.9
    PRIORITY_ONE_E (1),
    PRIORITY_TWO_E (2),
    PRIORITY_THREE_E (3),
    PRIORITY_FOUR_E (4),
    PRIORITY_FIVE_E (5),
    PRIORITY_SIX_E (6),
    PRIORITY_SEVEN_E (7),
    PRIORITY_EIGHT_E (8),
    PRIORITY_NINE_E (9),
    PRIORITY_TEN_E(10),
    PRIORITY_ELEVEN_E (11),
    PRIORITY_TWELVE_E (12),
    PRIORITY_THIRTEEN_E (13),
    PRIORITY_FOURTEEN_E (14),
    PRIORITY_FIFTEEN_E (15)
};*/
const char* Reservation_Priority_Type::msKeywordEnums[] = { 
		"PRIORITY_ONE_E",// (1),
        "PRIORITY_TWO_E",// (2),
        "PRIORITY_THREE_E",// (3),
        "PRIORITY_FOUR_E",// (4),
        "PRIORITY_FIVE_E",// (5),
        "PRIORITY_SIX_E",// (6),
        "PRIORITY_SEVEN_E",// (7),
        "PRIORITY_EIGHT_E",// (8),
        "PRIORITY_NINE_E",// (9),
        "PRIORITY_TEN_E",//(10),
        "PRIORITY_ELEVEN_E",// (11),
        "PRIORITY_TWELVE_E",// (12),
        "PRIORITY_THIRTEEN_E",// (13),
        "PRIORITY_FOURTEEN_E",// (14),
        "PRIORITY_FIFTEEN_E",// (15)
		"" };
const int Reservation_Priority_Type::msKeywordIds[] = { 
		1,//PRIORITY_ONE_E (),
        2,//PRIORITY_TWO_E (),
        3,//PRIORITY_THREE_E (),
        4,//PRIORITY_FOUR_E (),
        5,//PRIORITY_FIVE_E (),
        6,//PRIORITY_SIX_E (),
        7,//PRIORITY_SEVEN_E (),
        8,//PRIORITY_EIGHT_E (),
        9,//PRIORITY_NINE_E (),
        10,//PRIORITY_TEN_E(),
        11,//PRIORITY_ELEVEN_E (),
        12,//PRIORITY_TWELVE_E (),
        13,//PRIORITY_THIRTEEN_E (),
        14,//PRIORITY_FOURTEEN_E (),
        15,//PRIORITY_FIFTEEN_E ()
		};


/*type enumerated IP_CAN_Type{
    // Ref: ETSI TS 129 212 5.3.27
    ThreeGPP_GPRS_E (0),
    DOCSIS_E (1),
    XDSL_E (2),
    WIMAX_E (3),
    ThreeGPP2_E (4),
    ThreeGPP_EPS_E (5),
    NON_3GPP_EPS_E (6)
};*/
const char* IP_CAN_Type::msKeywordEnums[] = { 
		"ThreeGPP_GPRS_E",// (0),
        "DOCSIS_E",// (1),
        "XDSL_E",// (2),
        "WIMAX_E",// (3),
        "ThreeGPP2_E",// (4),
        "ThreeGPP_EPS_E",// (5),
        "NON_3GPP_EPS_E",// (6)
		"" };
const int IP_CAN_Type::msKeywordIds[] = { 
		0,//ThreeGPP_GPRS_E (),
        1,//DOCSIS_E (),
        2,//XDSL_E (),
        3,//WIMAX_E (),
        4,//ThreeGPP2_E (),
        5,//ThreeGPP_EPS_E (),
        6,//NON_3GPP_EPS_E ()
		};


/*type enumerated RAT_Type{
    // Ref: ETSI TS 129 212 5.3.31
    WLAN_E (0),
    VIRTUAL_E (1),
    UTRAN_E (1000),
    GERAN_E (1001),
    GAN_E (1002),
    HSPA_EVOLUTION_E (1003),
    EUTRAN_E (1004),
    CDMA2000_IX_E (2000),
    HRPD_E(2001),
    UMB_E(2002),
    EHRPD_E(2003)
};*/
const char* RAT_Type::msKeywordEnums[] = { 
		"WLAN_E",// (0),
        "VIRTUAL_E",// (1),
        "UTRAN_E",// (1000),
        "GERAN_E",// (1001),
        "GAN_E",// (1002),
        "HSPA_EVOLUTION_E",// (1003),
        "EUTRAN_E",// (1004),
        "CDMA2000_IX_E",// (2000),
        "HRPD_E",//(2001),
        "UMB_E",//(2002),
        "EHRPD_E",//(2003)
		"" };
const int RAT_Type::msKeywordIds[] = { 
		0,//WLAN_E (),
        1,//VIRTUAL_E (),
        1000,//UTRAN_E (),
        1001,//GERAN_E (),
        1002,//GAN_E (),
        1003,//HSPA_EVOLUTION_E (),
        1004,//EUTRAN_E (),
        2000,//CDMA2000_IX_E (),
        2001,//HRPD_E(),
        2002,//UMB_E(),
        2003,//EHRPD_E()
		};


/*type enumerated Bearer_Control_Mode{
    // Ref: ETSI TS 129 212 5.3.23
    UE_ONLY_E (0),
    RESERVED_E (1),
    UE_NW_E (2)
};*/
const char* Bearer_Control_Mode::msKeywordEnums[] = { 
		"UE_ONLY_E",// (0),
        "RESERVED_E",// (1),
        "UE_NW_E",// (2)
		"" };
const int Bearer_Control_Mode::msKeywordIds[] = { 
		0,//UE_ONLY_E (),
        1,//RESERVED_E (),
        2,//UE_NW_E ()
		};


/*type enumerated Bearer_Operation{
    // Ref: ETSI TS 129 212 5.3.21
    TERMINATION_E (0),
    ESTABLISHMENT_E (1),
    MODIFICATION_E (2)
};*/
const char* Bearer_Operation::msKeywordEnums[] = { 
		"TERMINATION_E",// (0),
        "ESTABLISHMENT_E",// (1),
        "MODIFICATION_E",// (2)
		"" };
const int Bearer_Operation::msKeywordIds[] = { 
		0,//TERMINATION_E (),
        1,//ESTABLISHMENT_E (),
        2,//MODIFICATION_E ()
		};


/*type enumerated Bearer_Usage{
    // Ref: ETSI TS 129 212 5.3.1
    GENERAL_E (0),
    IMS_SIGNALLING_E (1)
};*/
const char* Bearer_Usage::msKeywordEnums[] = { 
		"GENERAL_E",// (0),
        "IMS_SIGNALLING_E",// (1)
		"" };
const int Bearer_Usage::msKeywordIds[] = { 
		0,//GENERAL_E (),
        1,//IMS_SIGNALLING_E ()
		};


/*type enumerated Charging_Correlation_Indicator{
    // Ref: ETSI TS 129 212 5.3.67
	CHARGING_IDENTIFIER_REQUIRED_E (0)   
};*/
const char* Charging_Correlation_Indicator::msKeywordEnums[] = { 
		"CHARGING_IDENTIFIER_REQUIRED_E",// (0)   
		"" };
const int Charging_Correlation_Indicator::msKeywordIds[] = { 
		0,//CHARGING_IDENTIFIER_REQUIRED_E ()   
		};


/*type enumerated CSG_Information_Reporting{
    // Ref: ETSI TS 129 212 5.3.64
	CHANGE_CSG_CELL_E (0),
	CHANGE_CSG_SUBSCRIBED_HYBRID_CELL_E (1),
	CHANGE_CSG_UNSUBSCRIBED_HYBRID_CELL_E (2)   
};*/
const char* CSG_Information_Reporting::msKeywordEnums[] = { 
		"CHANGE_CSG_CELL_E",// (0),
		"CHANGE_CSG_SUBSCRIBED_HYBRID_CELL_E",// (1),
		"CHANGE_CSG_UNSUBSCRIBED_HYBRID_CELL_E",// (2)   
		"" };
const int CSG_Information_Reporting::msKeywordIds[] = { 
		0,//CHANGE_CSG_CELL_E (),
		1,//CHANGE_CSG_SUBSCRIBED_HYBRID_CELL_E (),
		2,//CHANGE_CSG_UNSUBSCRIBED_HYBRID_CELL_E ()   
		};


/*type enumerated Event_Trigger{
    // Ref: ETSI TS 129 212 5.3.7
	SGSN_CHANGE_E (0),
    QOS_CHANGE_E (1),
    RAT_CHANGE_E (2),
    TFT_CHANGE_E (3),
    PLMN_CHANGE_E (4),
    LOSS_OF_BEARER_E (5),
    RECOVERY_OF_BEARER_E (6),
    IP_CAN_CHANGE_E (7),
    QOS_CHANGE_EXCEEDING_AUTHORIZATION_E (11),
    RAI_CHANGE_E (12),
    USER_LOCATION_CHANGE_E (13),
    NO_EVENT_TRIGGERS_E (14),
    OUT_OF_CREDIT_E (15),
    REALLOCATION_OF_CREDIT_E (16),
    REVALIDATION_TIMEOUT_E (17),
    UE_IP_ADDRESS_ALLOCATE_E (18),
    UE_IP_ADDRESS_RELEASE_E (19),
    DEFAULT_EPS_BEARER_QOS_CHANGE_E (20),
    AN_GW_CHANGE_E (21),
    SUCCESSFUL_RESOURCE_ALLOCATION_E (22),
    RESOURCE_MODIFICATION_REQUEST_E (23),
    PGW_TRACE_CONTROL_E (24),
    UE_TIME_ZONE_CHANGE_E (25),
    TAI_CHANGE_E (26),
    ECGI_CHANGE_E (27),
    CHARGING_CORRELATION_EXCHANGE_E (28),
    APN_AMBR_MODIFICATION_FAILURE_E (29),
    USER_CSG_INFORMATION_CHANGE_E (30),
    USAGE_REPORT_E (33),
    DEFAULT_EPS_BEARER_QOS_MODIFICATION_FAILURE_E (34),
    USER_CSG_HYBRID_SUBSCRIBED_INFORMATION_CHANGE_E (35),
    USER_CSG_HYBRID_UNSUBSCRIBED_INFORMATION_CHANGE_E (36),
    ROUTING_RULE_CHANGE_E (37),
    MAX_MBR_APN_AMBR_CHANGE_E (38)  
};*/
const char* Event_Trigger::msKeywordEnums[] = { 
		"SGSN_CHANGE_E",// (0),
        "QOS_CHANGE_E",// (1),
        "RAT_CHANGE_E",// (2),
        "TFT_CHANGE_E",// (3),
        "PLMN_CHANGE_E",// (4),
        "LOSS_OF_BEARER_E",// (5),
        "RECOVERY_OF_BEARER_E",// (6),
        "IP_CAN_CHANGE_E",// (7),
        "QOS_CHANGE_EXCEEDING_AUTHORIZATION_E",// (11),
        "RAI_CHANGE_E",// (12),
        "USER_LOCATION_CHANGE_E",// (13),
        "NO_EVENT_TRIGGERS_E",// (14),
        "OUT_OF_CREDIT_E",// (15),
        "REALLOCATION_OF_CREDIT_E",// (16),
        "REVALIDATION_TIMEOUT_E",// (17),
        "UE_IP_ADDRESS_ALLOCATE_E",// (18),
        "UE_IP_ADDRESS_RELEASE_E",// (19),
        "DEFAULT_EPS_BEARER_QOS_CHANGE_E",// (20),
        "AN_GW_CHANGE_E",// (21),
        "SUCCESSFUL_RESOURCE_ALLOCATION_E",// (22),
        "RESOURCE_MODIFICATION_REQUEST_E",// (23),
        "PGW_TRACE_CONTROL_E",// (24),
        "UE_TIME_ZONE_CHANGE_E",// (25),
        "TAI_CHANGE_E",// (26),
        "ECGI_CHANGE_E",// (27),
        "CHARGING_CORRELATION_EXCHANGE_E",// (28),
        "APN_AMBR_MODIFICATION_FAILURE_E",// (29),
        "USER_CSG_INFORMATION_CHANGE_E",// (30),
        "USAGE_REPORT_E",// (33),
        "DEFAULT_EPS_BEARER_QOS_MODIFICATION_FAILURE_E",// (34),
        "USER_CSG_HYBRID_SUBSCRIBED_INFORMATION_CHANGE_E",// (35),
        "USER_CSG_HYBRID_UNSUBSCRIBED_INFORMATION_CHANGE_E",// (36),
        "ROUTING_RULE_CHANGE_E",// (37),
        "MAX_MBR_APN_AMBR_CHANGE_E",// (38)  
		"" };
const int Event_Trigger::msKeywordIds[] = { 
		0,//SGSN_CHANGE_E (),
        1,//QOS_CHANGE_E (),
        2,//RAT_CHANGE_E (),
        3,//TFT_CHANGE_E (),
        4,//PLMN_CHANGE_E (),
        5,//LOSS_OF_BEARER_E (),
        6,//RECOVERY_OF_BEARER_E (),
        7,//IP_CAN_CHANGE_E (),
        11,//QOS_CHANGE_EXCEEDING_AUTHORIZATION_E (),
        12,//RAI_CHANGE_E (),
        13,//USER_LOCATION_CHANGE_E (),
        14,//NO_EVENT_TRIGGERS_E (),
        15,//OUT_OF_CREDIT_E (),
        16,//REALLOCATION_OF_CREDIT_E (),
        17,//REVALIDATION_TIMEOUT_E (),
        18,//UE_IP_ADDRESS_ALLOCATE_E (),
        19,//UE_IP_ADDRESS_RELEASE_E (),
        20,//DEFAULT_EPS_BEARER_QOS_CHANGE_E (),
        21,//AN_GW_CHANGE_E (),
        22,//SUCCESSFUL_RESOURCE_ALLOCATION_E (),
        23,//RESOURCE_MODIFICATION_REQUEST_E (),
        24,//PGW_TRACE_CONTROL_E (),
        25,//UE_TIME_ZONE_CHANGE_E (),
        26,//TAI_CHANGE_E (),
        27,//ECGI_CHANGE_E (),
        28,//CHARGING_CORRELATION_EXCHANGE_E (),
        29,//APN_AMBR_MODIFICATION_FAILURE_E (),
        30,//USER_CSG_INFORMATION_CHANGE_E (),
        33,//USAGE_REPORT_E (),
        34,//DEFAULT_EPS_BEARER_QOS_MODIFICATION_FAILURE_E (),
        35,//USER_CSG_HYBRID_SUBSCRIBED_INFORMATION_CHANGE_E (),
        36,//USER_CSG_HYBRID_UNSUBSCRIBED_INFORMATION_CHANGE_E (),
        37,//ROUTING_RULE_CHANGE_E (),
        38,//MAX_MBR_APN_AMBR_CHANGE_E ()  
		};


/*type enumerated Flow_Direction{
    // Ref: ETSI TS 129 212 5.3.65
    UNSPECIFIED_E (0),
    DOWNLINK_E (1),
    UPLINK_E (2),
    BIDIRECTIONAL_E (3)
};*/
const char* Flow_Direction::msKeywordEnums[] = { 
		"UNSPECIFIED_E",// (0),
        "DOWNLINK_E",// (1),
        "UPLINK_E",// (2),
        "BIDIRECTIONAL_E",// (3)
		"" };
const int Flow_Direction::msKeywordIds[] = { 
		0,//UNSPECIFIED_E (),
        1,//DOWNLINK_E (),
        2,//UPLINK_E (),
        3,//BIDIRECTIONAL_E ()
		};


/*type enumerated Metering_Method{
    // Ref: ETSI TS 129 212 5.3.8
    DURATION_E (0),
    VOLUME_E (1),
	DURATION_VOLUME_E (2)
};*/
const char* Metering_Method::msKeywordEnums[] = { 
		"DURATION_E",// (0),
        "VOLUME_E",// (1),
		"DURATION_VOLUME_E",// (2)
		"" };
const int Metering_Method::msKeywordIds[] = { 
		0,//DURATION_E (),
        1,//VOLUME_E (),
		2,//DURATION_VOLUME_E ()
		};


/*type enumerated Network_Request_Support{
    // Ref: ETSI TS 129 212 5.3.24
    NETWORK_REQUEST_NOT_SUPPORTED_E (0),
	NETWORK_REQUEST_SUPPORTED_E (1)
};*/
const char* Network_Request_Support::msKeywordEnums[] = { 
		"NETWORK_REQUEST_NOT_SUPPORTED_E",// (0),
		"NETWORK_REQUEST_SUPPORTED_E",// (1)
		"" };
const int Network_Request_Support::msKeywordIds[] = { 
		0,//NETWORK_REQUEST_NOT_SUPPORTED_E (),
		1,//NETWORK_REQUEST_SUPPORTED_E ()
		};


/*type enumerated Offline{
    // Ref: ETSI TS 129 212 5.3.9
    DISABLE_OFFLINE_E (0),
	ENABLE_OFFLINE_E (1)
};*/
const char* Offline::msKeywordEnums[] = { 
		"DISABLE_OFFLINE_E",// (0),
		"ENABLE_OFFLINE_E",// (1)
		"" };
const int Offline::msKeywordIds[] = { 
		0,//DISABLE_OFFLINE_E (),
		1,//ENABLE_OFFLINE_E ()
		};


/*type enumerated Online{
    // Ref: ETSI TS 129 212 5.3.10
    DISABLE_ONLINE_E (0),
	ENABLE_ONLINE_E (1)
};*/
const char* Online::msKeywordEnums[] = { 
		"DISABLE_ONLINE_E",// (0),
		"ENABLE_ONLINE_E",// (1)
		"" };
const int Online::msKeywordIds[] = { 
		0,//DISABLE_ONLINE_E (),
		1,//ENABLE_ONLINE_E ()
		};


/*type enumerated Packet_Filter_Operation{
    // Ref: ETSI TS 129 212 5.3.57
    DELETION_E (0),
    ADDITION_E (1),
    MODIFICATION_E (2)
};*/
const char* Packet_Filter_Operation::msKeywordEnums[] = { 
		"DELETION_E",// (0),
        "ADDITION_E",// (1),
        "MODIFICATION_E",// (2)
		"" };
const int Packet_Filter_Operation::msKeywordIds[] = { 
		0,//DELETION_E (),
        1,//ADDITION_E (),
        2,//MODIFICATION_E ()
		};


/*type enumerated Packet_Filter_Usage{
    // Ref: ETSI TS 129 212 5.3.66
    SEND_TO_UE_E (1)
};*/
const char* Packet_Filter_Usage::msKeywordEnums[] = { 
		"SEND_TO_UE_E",// (1)
		"" };
const int Packet_Filter_Usage::msKeywordIds[] = { 
		1,//SEND_TO_UE_E ()
		};


/*type enumerated Pre_emption_Capability{
    // Ref: ETSI TS 129 212 5.3.46
    PRE_EMPTION_CAPABILITY_ENABLED_E (0),
    PRE_EMPTION_CAPABILITY_DISABLED_E (1)
};*/
const char* Pre_emption_Capability::msKeywordEnums[] = { 
		"PRE_EMPTION_CAPABILITY_ENABLED_E",// (0),
        "PRE_EMPTION_CAPABILITY_DISABLED_E",// (1)
		"" };
const int Pre_emption_Capability::msKeywordIds[] = { 
		0,//PRE_EMPTION_CAPABILITY_ENABLED_E (),
        1,//PRE_EMPTION_CAPABILITY_DISABLED_E ()
		};


/*type enumerated Pre_emption_Vulnerability{
    // Ref: ETSI TS 129 212 5.3.47
    PRE_EMPTION_VULNERABILITY_ENABLED_E (0),
    PRE_EMPTION_VULNERABILITY_DISABLED_E (1)
};*/
const char* Pre_emption_Vulnerability::msKeywordEnums[] = { 
		"PRE_EMPTION_VULNERABILITY_ENABLED_E",// (0),
        "PRE_EMPTION_VULNERABILITY_DISABLED_E",// (1)
		"" };
const int Pre_emption_Vulnerability::msKeywordIds[] = { 
		0,//PRE_EMPTION_VULNERABILITY_ENABLED_E (),
        1,//PRE_EMPTION_VULNERABILITY_DISABLED_E ()
		};


/*type enumerated Reporting_Level{
    // Ref: ETSI TS 129 212 5.3.12
    SERVICE_IDENTIFIER_LEVEL_E (0),
    RATING_GROUP_LEVEL_E (1),
    SPONSORED_CONNECTIVITY_LEVEL_E (2)
};*/
const char* Reporting_Level::msKeywordEnums[] = { 
		"SERVICE_IDENTIFIER_LEVEL_E",// (0),
        "RATING_GROUP_LEVEL_E",// (1),
        "SPONSORED_CONNECTIVITY_LEVEL_E",// (2)
		"" };
const int Reporting_Level::msKeywordIds[] = { 
		0,//SERVICE_IDENTIFIER_LEVEL_E (),
        1,//RATING_GROUP_LEVEL_E (),
        2,//SPONSORED_CONNECTIVITY_LEVEL_E ()
		};


/*type enumerated PCC_Rule_Status{
    // Ref: ETSI TS 129 212 5.3.19
    ACTIVE_E (0),
    INACTIVE_E (1),
    TEMPORARILY_INACTIVE_E (2)
};*/
const char* PCC_Rule_Status::msKeywordEnums[] = { 
		"ACTIVE_E",// (0),
        "INACTIVE_E",// (1),
        "TEMPORARILY_INACTIVE_E",// (2)
		"" };
const int PCC_Rule_Status::msKeywordIds[] = { 
		0,//ACTIVE_E (),
        1,//INACTIVE_E (),
        2,//TEMPORARILY_INACTIVE_E ()
		};


/*type enumerated Session_Release_Cause{
    // Ref: ETSI TS 129 212 5.3.44
    UNSPECIFIED_REASON_E (0),
    UE_SUBSCRIPTION_REASON_E (1),
    INSUFFICIENT_SERVER_RESOURCES_E (2)
};*/
const char* Session_Release_Cause::msKeywordEnums[] = { 
		"UNSPECIFIED_REASON_E",// (0),
        "UE_SUBSCRIPTION_REASON_E",// (1),
        "INSUFFICIENT_SERVER_RESOURCES_E",// (2)
		"" };
const int Session_Release_Cause::msKeywordIds[] = { 
		0,//UNSPECIFIED_REASON_E (),
        1,//UE_SUBSCRIPTION_REASON_E (),
        2,//INSUFFICIENT_SERVER_RESOURCES_E ()
		};


/*type enumerated QoS_Class_Identifier{
    // Ref: ETSI TS 129 212 5.3.17
    QCI_1_E (1),//examle service=conversational voice
    QCI_2_E (2),//examle service=conversational video
    QCI_3_E (3),//examle service=real time gaming
    QCI_4_E (4),//examle service=non-conversational video
    QCI_5_E (5),//examle service=IMS signalling
    QCI_6_E (6),//examle service=video(TCP based)
    QCI_7_E (7),//examle service=voice,video(life streaming)
    QCI_8_E (8),//examle service=video(buffered streaming)
    QCI_9_E (9)//examle service=video(buffered streaming)
};*/
const char* QoS_Class_Identifier::msKeywordEnums[] = { 
		"QCI_1_E",// (1),//examle service=conversational voice
        "QCI_2_E",// (2),//examle service=conversational video
        "QCI_3_E",// (3),//examle service=real time gaming
        "QCI_4_E",// (4),//examle service=non-conversational video
        "QCI_5_E",// (5),//examle service=IMS signalling
        "QCI_6_E",// (6),//examle service=video(TCP based)
        "QCI_7_E",// (7),//examle service=voice,video(life streaming)
        "QCI_8_E",// (8),//examle service=video(buffered streaming)
        "QCI_9_E",// (9)//examle service=video(buffered streaming)
		"" };
const int QoS_Class_Identifier::msKeywordIds[] = { 
		1,//QCI_1_E (),//examle service=conversational voice
        2,//QCI_2_E (),//examle service=conversational video
        3,//QCI_3_E (),//examle service=real time gaming
        4,//QCI_4_E (),//examle service=non-conversational video
        5,//QCI_5_E (),//examle service=IMS signalling
        6,//QCI_6_E (),//examle service=video(TCP based)
        7,//QCI_7_E (),//examle service=voice,video(life streaming)
        8,//QCI_8_E (),//examle service=video(buffered streaming)
        9,//QCI_9_E ()//examle service=video(buffered streaming)
		};


/*type enumerated QoS_Negotiation{
    // Ref: ETSI TS 129 212 5.3.28
    NO_QoS_NEGOTIATION_E (0),
	QoS_NEGOTIATION_SUPPORTED_E (1)
};*/
const char* QoS_Negotiation::msKeywordEnums[] = { 
		"NO_QoS_NEGOTIATION_E",// (0),
		"QoS_NEGOTIATION_SUPPORTED_E",// (1)
		"" };
const int QoS_Negotiation::msKeywordIds[] = { 
		0,//NO_QoS_NEGOTIATION_E (),
		1,//QoS_NEGOTIATION_SUPPORTED_E ()
		};


/*type enumerated QoS_Upgrade{
    // Ref: ETSI TS 129 212 5.3.29
    QoS_UPGRADE_NOT_SUPPORTED_E (0),
	QoS_UPGRADE_SUPPORTED_E (1)
};*/
const char* QoS_Upgrade::msKeywordEnums[] = { 
		"QoS_UPGRADE_NOT_SUPPORTED_E",// (0),
		"QoS_UPGRADE_SUPPORTED_E",// (1)
		"" };
const int QoS_Upgrade::msKeywordIds[] = { 
		0,//QoS_UPGRADE_NOT_SUPPORTED_E (),
		1,//QoS_UPGRADE_SUPPORTED_E ()
		};


/*type enumerated Resource_Allocation_Notification{
    // Ref: ETSI TS 129 212 5.3.50
    ENABLE_NOTIFICATION_E (0)
};*/
const char* Resource_Allocation_Notification::msKeywordEnums[] = { 
		"ENABLE_NOTIFICATION_E",// (0)
		"" };
const int Resource_Allocation_Notification::msKeywordIds[] = { 
		0,//ENABLE_NOTIFICATION_E ()
		};


/*type enumerated Rule_Failure_Code{
    // Ref: ETSI TS 129 212 5.3.38
    UNKNOWN_RULE_NAME_E (1),
    RATING_GROUP_ERROR_E (2),
    SERVICE_IDENTIFIER_ERROR_E (3),
    GW_PCEF_MALFUNCTION_E (4),
    RESOURCES_LIMITATION_E (5),
    MAX_NR_BEARERS_REACHED_E (6),
    UNKNOWN_BEARER_ID_E (7),
    MISSING_BEARER_ID_E (8),
    MISSING_FLOW_INFORMATION_E (9),
    RESOURCE_ALLOCATION_FAILURE_E (10),
    UNSUCCESSFUL_QOS_VALIDATION_E (11),
    INCORRECT_FLOW_INFORMATION_E (12),
    PS_TO_CS_HANDOVER_E (13),
    NO_BEARER_BOUND_E (15)
};*/
const char* Rule_Failure_Code::msKeywordEnums[] = { 
		"UNKNOWN_RULE_NAME_E",// (1),
        "RATING_GROUP_ERROR_E",// (2),
        "SERVICE_IDENTIFIER_ERROR_E",// (3),
        "GW_PCEF_MALFUNCTION_E",// (4),
        "RESOURCES_LIMITATION_E",// (5),
        "MAX_NR_BEARERS_REACHED_E",// (6),
        "UNKNOWN_BEARER_ID_E",// (7),
        "MISSING_BEARER_ID_E",// (8),
        "MISSING_FLOW_INFORMATION_E",// (9),
        "RESOURCE_ALLOCATION_FAILURE_E",// (10),
        "UNSUCCESSFUL_QOS_VALIDATION_E",// (11),
        "INCORRECT_FLOW_INFORMATION_E",// (12),
        "PS_TO_CS_HANDOVER_E",// (13),
        "NO_BEARER_BOUND_E",// (15)
		"" };
const int Rule_Failure_Code::msKeywordIds[] = { 
		1,//UNKNOWN_RULE_NAME_E (),
        2,//RATING_GROUP_ERROR_E (),
        3,//SERVICE_IDENTIFIER_ERROR_E (),
        4,//GW_PCEF_MALFUNCTION_E (),
        5,//RESOURCES_LIMITATION_E (),
        6,//MAX_NR_BEARERS_REACHED_E (),
        7,//UNKNOWN_BEARER_ID_E (),
        8,//MISSING_BEARER_ID_E (),
        9,//MISSING_FLOW_INFORMATION_E (),
        10,//RESOURCE_ALLOCATION_FAILURE_E (),
        11,//UNSUCCESSFUL_QOS_VALIDATION_E (),
        12,//INCORRECT_FLOW_INFORMATION_E (),
        13,//PS_TO_CS_HANDOVER_E (),
        15,//NO_BEARER_BOUND_E ()
		};


/*type enumerated Usage_Monitoring_Level{
    // Ref: ETSI TS 129 212 5.3.61
    SESSION_LEVEL_E (0),
	PCC_RULE_LEVEL_E (1)
};*/
const char* Usage_Monitoring_Level::msKeywordEnums[] = { 
		"SESSION_LEVEL_E",// (0),
		"PCC_RULE_LEVEL_E",// (1)
		"" };
const int Usage_Monitoring_Level::msKeywordIds[] = { 
		0,//SESSION_LEVEL_E (),
		1,//PCC_RULE_LEVEL_E ()
		};


/*type enumerated Usage_Monitoring_Report{
    // Ref: ETSI TS 129 212 5.3.62
    USAGE_MONITORING_REPORT_REQUIRED_E (0)
};*/
const char* Usage_Monitoring_Report::msKeywordEnums[] = { 
		"USAGE_MONITORING_REPORT_REQUIRED_E",// (0)
		"" };
const int Usage_Monitoring_Report::msKeywordIds[] = { 
		0,//USAGE_MONITORING_REPORT_REQUIRED_E ()
		};


/*type enumerated Usage_Monitoring_Support{
    // Ref: ETSI TS 129 212 5.3.63
    USAGE_MONITORING_DISABLED_E (0)
};*/
const char* Usage_Monitoring_Support::msKeywordEnums[] = { 
		"USAGE_MONITORING_DISABLED_E",// (0)
		"" };
const int Usage_Monitoring_Support::msKeywordIds[] = { 
		0,//USAGE_MONITORING_DISABLED_E ()
		};


/*type enumerated CSG_Access_Mode{
    // Ref: ETSI TS 132 299 7.2.46A
    CLOSED_MODE_E (0),
    HYBRID_MODE_E (1)
};*/
const char* CSG_Access_Mode::msKeywordEnums[] = { 
		"CLOSED_MODE_E",// (0),
		"HYBRID_MODE_E",// (1)
		"" };
const int CSG_Access_Mode::msKeywordIds[] = { 
		0,//CLOSED_MODE_E (),
		1,//HYBRID_MODE_E ()
		};


/*type enumerated CSG_Membership_Indication{
    // Ref: ETSI TS 132 299 7.2.46B
    NOT_CSG_MEMBER_E (0),
    CSG_MEMBER_E (1)
};*/
const char* CSG_Membership_Indication::msKeywordEnums[] = { 
		"NOT_CSG_MEMBER_E",// (0),
		"CSG_MEMBER_E",// (1)
		"" };
const int CSG_Membership_Indication::msKeywordIds[] = { 
		0,//NOT_CSG_MEMBER_E (),
		1,//CSG_MEMBER_E ()
		};




/*type enumerated Trace_Depth{
    // Ref: ETSI TS 132 422 5.3
    MINIMUM_E (0),
    MEDIUM_E (1),
    MAXIMUM_E (2),
    MINIMUM_WITHOUT_VENDOR_SPECIFIC_EXTENSION_E (3),
    MEDIUM_WITHOUT_VENDOR_SPECIFIC_EXTENSION_E (4),
    MAXIMUM_WITHOUT_VENDOR_SPECIFIC_EXTENSION_E (5)
};*/
const char* Trace_Depth::msKeywordEnums[] = { 
		"MINIMUM_E",// (0),
        "MEDIUM_E",// (1),
        "MAXIMUM_E",// (2),
        "MINIMUM_WITHOUT_VENDOR_SPECIFIC_EXTENSION_E",// (3),
        "MEDIUM_WITHOUT_VENDOR_SPECIFIC_EXTENSION_E",// (4),
        "MAXIMUM_WITHOUT_VENDOR_SPECIFIC_EXTENSION_E",// (5)
		"" };
const int Trace_Depth::msKeywordIds[] = { 
		0,//MINIMUM_E (),
		1,//MEDIUM_E (),
		2,//MAXIMUM_E (),
		3,//MINIMUM_WITHOUT_VENDOR_SPECIFIC_EXTENSION_E (),
		4,//MEDIUM_WITHOUT_VENDOR_SPECIFIC_EXTENSION_E (),
		5,//MAXIMUM_WITHOUT_VENDOR_SPECIFIC_EXTENSION_E ()
		};


/*type enumerated Job_Type{
    // Ref: ETSI TS 132 422 5.10.1
    IMMEDIATE_MDT_ONLY_E (0),
    LOGGED_MDT_ONLY_E (1),
    TRACE_ONLY_E (2),
    IMMEDIATE_MDT_AND_TRACE_E (3)
};*/
const char* Job_Type::msKeywordEnums[] = { 
		"IMMEDIATE_MDT_ONLY_E",// (0),
        "LOGGED_MDT_ONLY_E",// (1),
        "TRACE_ONLY_E",// (2),
        "IMMEDIATE_MDT_AND_TRACE_E",// (3)
		"" };
const int Job_Type::msKeywordIds[] = { 
		0,//IMMEDIATE_MDT_ONLY_E (),
        1,//LOGGED_MDT_ONLY_E (),
        2,//TRACE_ONLY_E (),
        3,//IMMEDIATE_MDT_AND_TRACE_E ()
		};


/*type enumerated Report_Interval{
    // Ref: ETSI TS 132 422 5.10.5
    REPORT_INTERVAL_250MS_E (0),
    REPORT_INTERVAL_500MS_E (1),
    REPORT_INTERVAL_1000MS_E (2),
    REPORT_INTERVAL_2000MS_E (3),
    REPORT_INTERVAL_3000MS_E (4),
    REPORT_INTERVAL_4000MS_E (5),
    REPORT_INTERVAL_6000MS_E (6),
    REPORT_INTERVAL_8000MS_E (7),
    REPORT_INTERVAL_12000MS_E (8),
    REPORT_INTERVAL_16000MS_E (9),
    REPORT_INTERVAL_20000MS_E (10),
    REPORT_INTERVAL_24000MS_E (11),
    REPORT_INTERVAL_28000MS_E (12),
    REPORT_INTERVAL_32000MS_E (13),
    REPORT_INTERVAL_64000MS_E (14),
    REPORT_INTERVAL_120MS_E (15),
    REPORT_INTERVAL_240MS_E (16),
    REPORT_INTERVAL_480MS_E (17),
    REPORT_INTERVAL_640MS_E (18),
    REPORT_INTERVAL_1024MS_E (19),
    REPORT_INTERVAL_2048MS_E (20),
    REPORT_INTERVAL_5120MS_E (21),
    REPORT_INTERVAL_10240MS_E (22),
    REPORT_INTERVAL_60000MS_E (23),
    REPORT_INTERVAL_360000MS_E (24),
    REPORT_INTERVAL_720000MS_E (25),
    REPORT_INTERVAL_1800000MS_E (26),
    REPORT_INTERVAL_3600000MS_E (27)
};*/
const char* Report_Interval::msKeywordEnums[] = { 
		"REPORT_INTERVAL_250MS_E",// (0),
        "REPORT_INTERVAL_500MS_E",// (1),
        "REPORT_INTERVAL_1000MS_E",// (2),
        "REPORT_INTERVAL_2000MS_E",// (3),
        "REPORT_INTERVAL_3000MS_E",// (4),
        "REPORT_INTERVAL_4000MS_E",// (5),
        "REPORT_INTERVAL_6000MS_E",// (6),
        "REPORT_INTERVAL_8000MS_E",// (7),
        "REPORT_INTERVAL_12000MS_E",// (8),
        "REPORT_INTERVAL_16000MS_E",// (9),
        "REPORT_INTERVAL_20000MS_E",// (10),
        "REPORT_INTERVAL_24000MS_E",// (11),
        "REPORT_INTERVAL_28000MS_E",// (12),
        "REPORT_INTERVAL_32000MS_E",// (13),
        "REPORT_INTERVAL_64000MS_E",// (14),
        "REPORT_INTERVAL_120MS_E",// (15),
        "REPORT_INTERVAL_240MS_E",// (16),
        "REPORT_INTERVAL_480MS_E",// (17),
        "REPORT_INTERVAL_640MS_E",// (18),
        "REPORT_INTERVAL_1024MS_E",// (19),
        "REPORT_INTERVAL_2048MS_E",// (20),
        "REPORT_INTERVAL_5120MS_E",// (21),
        "REPORT_INTERVAL_10240MS_E",// (22),
        "REPORT_INTERVAL_60000MS_E",// (23),
        "REPORT_INTERVAL_360000MS_E",// (24),
        "REPORT_INTERVAL_720000MS_E",// (25),
        "REPORT_INTERVAL_1800000MS_E",// (26),
        "REPORT_INTERVAL_3600000MS_E",// (27)
		"" };
const int Report_Interval::msKeywordIds[] = { 
		0,//REPORT_INTERVAL_250MS_E (),
        1,//REPORT_INTERVAL_500MS_E (),
        2,//REPORT_INTERVAL_1000MS_E (),
        3,//REPORT_INTERVAL_2000MS_E (),
        4,//REPORT_INTERVAL_3000MS_E (),
        5,//REPORT_INTERVAL_4000MS_E (),
        6,//REPORT_INTERVAL_6000MS_E (),
        7,//REPORT_INTERVAL_8000MS_E (),
        8,//REPORT_INTERVAL_12000MS_E (),
        9,//REPORT_INTERVAL_16000MS_E (),
        10,//REPORT_INTERVAL_20000MS_E (),
        11,//REPORT_INTERVAL_24000MS_E (),
        12,//REPORT_INTERVAL_28000MS_E (),
        13,//REPORT_INTERVAL_32000MS_E (),
        14,//REPORT_INTERVAL_64000MS_E (),
        15,//REPORT_INTERVAL_120MS_E (),
        16,//REPORT_INTERVAL_240MS_E (),
        17,//REPORT_INTERVAL_480MS_E (),
        18,//REPORT_INTERVAL_640MS_E (),
        19,//REPORT_INTERVAL_1024MS_E (),
        20,//REPORT_INTERVAL_2048MS_E (),
        21,//REPORT_INTERVAL_5120MS_E (),
        22,//REPORT_INTERVAL_10240MS_E (),
        23,//REPORT_INTERVAL_60000MS_E (),
        24,//REPORT_INTERVAL_360000MS_E (),
        25,//REPORT_INTERVAL_720000MS_E (),
        26,//REPORT_INTERVAL_1800000MS_E (),
        27,//REPORT_INTERVAL_3600000MS_E ()
		};


/*type enumerated Report_Amount{
    // Ref: ETSI TS 132 422 5.10.6
    AMOUNT_1_E (0),
    AMOUNT_2_E (1),
    AMOUNT_4_E (2),
    AMOUNT_8_E (3),
    AMOUNT_16_E (4),
    AMOUNT_32_E (5),
    AMOUNT_64_E (6),
    AMOUNT_INFINITY_E (7)
};*/
const char* Report_Amount::msKeywordEnums[] = { 
		"AMOUNT_1_E",// (0),
        "AMOUNT_2_E",// (1),
        "AMOUNT_4_E",// (2),
        "AMOUNT_8_E",// (3),
        "AMOUNT_16_E",// (4),
        "AMOUNT_32_E",// (5),
        "AMOUNT_64_E",// (6),
        "AMOUNT_INFINITY_E",// (7)
		"" };
const int Report_Amount::msKeywordIds[] = { 
		0,//AMOUNT_1_E (),
        1,//AMOUNT_2_E (),
        2,//AMOUNT_4_E (),
        3,//AMOUNT_8_E (),
        4,//AMOUNT_16_E (),
        5,//AMOUNT_32_E (),
        6,//AMOUNT_64_E (),
        7,//AMOUNT_INFINITY_E ()
		};


/*type enumerated Logging_Interval{
    // Ref: ETSI TS 132 422 5.10.8
    LOGGING_INTERVAL_1_28_E (0),
    LOGGING_INTERVAL_2_56_E (1),
    LOGGING_INTERVAL_3_12_E (2),
    LOGGING_INTERVAL_10_24_E (3),
    LOGGING_INTERVAL_20_49_E (4),
    LOGGING_INTERVAL_30_72_E (5),
    LOGGING_INTERVAL_40_96_E (6),
    LOGGING_INTERVAL_61_44_E (7)
};*/
const char* Logging_Interval::msKeywordEnums[] = { 
		"LOGGING_INTERVAL_1_28_E",// (0),
        "LOGGING_INTERVAL_2_56_E",// (1),
        "LOGGING_INTERVAL_3_12_E",// (2),
        "LOGGING_INTERVAL_10_24_E",// (3),
        "LOGGING_INTERVAL_20_49_E",// (4),
        "LOGGING_INTERVAL_30_72_E",// (5),
        "LOGGING_INTERVAL_40_96_E",// (6),
        "LOGGING_INTERVAL_61_44_E",// (7)
		"" };
const int Logging_Interval::msKeywordIds[] = { 
		0,//LOGGING_INTERVAL_1_28_E (),
        1,//LOGGING_INTERVAL_2_56_E (),
        2,//LOGGING_INTERVAL_3_12_E (),
        3,//LOGGING_INTERVAL_10_24_E (),
        4,//LOGGING_INTERVAL_20_49_E (),
        5,//LOGGING_INTERVAL_30_72_E (),
        6,//LOGGING_INTERVAL_40_96_E (),
        7,//LOGGING_INTERVAL_61_44_E ()
		};


/*type enumerated Logging_Duration{
    // Ref: ETSI TS 132 422 5.10.9
    LOGGING_DURATION_600SEC_E (0),
    LOGGING_DURATION_1200SEC_E (1),
    LOGGING_DURATION_2400SEC_E (2),
    LOGGING_DURATION_3600SEC_E (3),
    LOGGING_DURATION_5400SEC_E (4),
    LOGGING_DURATION_7200SEC_E (5)
};*/
const char* Logging_Duration::msKeywordEnums[] = { 
		"LOGGING_DURATION_600SEC_E",// (0),
        "LOGGING_DURATION_1200SEC_E",// (1),
        "LOGGING_DURATION_2400SEC_E",// (2),
        "LOGGING_DURATION_3600SEC_E",// (3),
        "LOGGING_DURATION_5400SEC_E",// (4),
        "LOGGING_DURATION_7200SEC_E",// (5)
		"" };
const int Logging_Duration::msKeywordIds[] = { 
		0,//LOGGING_DURATION_600SEC_E (),
        1,//LOGGING_DURATION_1200SEC_E (),
        2,//LOGGING_DURATION_2400SEC_E (),
        3,//LOGGING_DURATION_3600SEC_E (),
        4,//LOGGING_DURATION_5400SEC_E (),
        5,//LOGGING_DURATION_7200SEC_E ()
		};


//TODO: not sure where this one is defined????
/*type enumerated ASP_type {
                CONNECT_REQUEST_E(1),
                CONNECT_INDICATION_E(2),
                CONNECT_CONFIRM_E(3),
                DISCONNECT_REQUEST_E(4),
                DISCONNECT_INDICATION_E(5),
                DATA_REQUEST_E(6),
                DATA_INDICATION_E(7),
                LISTEN_REQUEST_E(8)
            }*/
const char* ASP_type::msKeywordEnums[] = { 
		"CONNECT_REQUEST_E",//(1),
        "CONNECT_INDICATION_E",//(2),
        "CONNECT_CONFIRM_E",//(3),
        "DISCONNECT_REQUEST_E",//(4),
        "DISCONNECT_INDICATION_E",//(5),
        "DATA_REQUEST_E",//(6),
        "DATA_INDICATION_E",//(7),
        "LISTEN_REQUEST_E",//(8)
		"" };
const unsigned int ASP_type::msKeywordIds[] = { 
		1,//CONNECT_REQUEST_E(),
        2,//CONNECT_INDICATION_E(),
        3,//CONNECT_CONFIRM_E(),
        4,//DISCONNECT_REQUEST_E(),
        5,//DISCONNECT_INDICATION_E(),
        6,//DATA_REQUEST_E(),
        7,//DATA_INDICATION_E(),
        8,//LISTEN_REQUEST_E()
		};

}} // namespaces
