diff --git a/src/modules/ss7ops/isup_generated.c b/src/modules/ss7ops/isup_generated.c index 164f3c53228..a82e6389835 100644 --- a/src/modules/ss7ops/isup_generated.c +++ b/src/modules/ss7ops/isup_generated.c @@ -2,466 +2,570 @@ #include "isup_generated.h" static const struct isup_ie_fixed acm_fixed[] = { - { - .name = "ISUPBackwardCallIndicators", - .type = ISUPBackwardCallIndicators, - .len = 2, - }, - { 0, }, + { + .name = "ISUPBackwardCallIndicators", + .type = ISUPBackwardCallIndicators, + .len = 2, + }, + { + 0, + }, }; static const struct isup_ie_fixed cgb_fixed[] = { - { - .name = "ISUPCircuitGroupSupervisionMessageType", - .type = ISUPCircuitGroupSupervisionMessageType, - .len = 1, - }, - { 0, }, + { + .name = "ISUPCircuitGroupSupervisionMessageType", + .type = ISUPCircuitGroupSupervisionMessageType, + .len = 1, + }, + { + 0, + }, }; static const struct isup_ie_fixed cgba_fixed[] = { - { - .name = "ISUPCircuitGroupSupervisionMessageType", - .type = ISUPCircuitGroupSupervisionMessageType, - .len = 1, - }, - { 0, }, + { + .name = "ISUPCircuitGroupSupervisionMessageType", + .type = ISUPCircuitGroupSupervisionMessageType, + .len = 1, + }, + { + 0, + }, }; static const struct isup_ie_fixed cgu_fixed[] = { - { - .name = "ISUPCircuitGroupSupervisionMessageType", - .type = ISUPCircuitGroupSupervisionMessageType, - .len = 1, - }, - { 0, }, + { + .name = "ISUPCircuitGroupSupervisionMessageType", + .type = ISUPCircuitGroupSupervisionMessageType, + .len = 1, + }, + { + 0, + }, }; static const struct isup_ie_fixed cgua_fixed[] = { - { - .name = "ISUPCircuitGroupSupervisionMessageType", - .type = ISUPCircuitGroupSupervisionMessageType, - .len = 1, - }, - { 0, }, + { + .name = "ISUPCircuitGroupSupervisionMessageType", + .type = ISUPCircuitGroupSupervisionMessageType, + .len = 1, + }, + { + 0, + }, }; static const struct isup_ie_fixed con_fixed[] = { - { - .name = "ISUPBackwardCallIndicators", - .type = ISUPBackwardCallIndicators, - .len = 2, - }, - { 0, }, + { + .name = "ISUPBackwardCallIndicators", + .type = ISUPBackwardCallIndicators, + .len = 2, + }, + { + 0, + }, }; static const struct isup_ie_fixed cot_fixed[] = { - { - .name = "ISUPContinuityIndicators", - .type = ISUPContinuityIndicators, - .len = 1, - }, - { 0, }, + { + .name = "ISUPContinuityIndicators", + .type = ISUPContinuityIndicators, + .len = 1, + }, + { + 0, + }, }; static const struct isup_ie_fixed cpg_fixed[] = { - { - .name = "ISUPEventInformation", - .type = ISUPEventInformation, - .len = 1, - }, - { 0, }, + { + .name = "ISUPEventInformation", + .type = ISUPEventInformation, + .len = 1, + }, + { + 0, + }, }; static const struct isup_ie_fixed faa_fixed[] = { - { - .name = "ISUPFacilityIndicator", - .type = ISUPFacilityIndicator, - .len = 1, - }, - { 0, }, + { + .name = "ISUPFacilityIndicator", + .type = ISUPFacilityIndicator, + .len = 1, + }, + { + 0, + }, }; static const struct isup_ie_fixed far_fixed[] = { - { - .name = "ISUPFacilityIndicator", - .type = ISUPFacilityIndicator, - .len = 1, - }, - { 0, }, + { + .name = "ISUPFacilityIndicator", + .type = ISUPFacilityIndicator, + .len = 1, + }, + { + 0, + }, }; static const struct isup_ie_fixed frj_fixed[] = { - { - .name = "ISUPFacilityIndicator", - .type = ISUPFacilityIndicator, - .len = 1, - }, - { 0, }, + { + .name = "ISUPFacilityIndicator", + .type = ISUPFacilityIndicator, + .len = 1, + }, + { + 0, + }, }; static const struct isup_ie_fixed iam_fixed[] = { - { - .name = "ISUPNatureOfConnectionIndicators", - .type = ISUPNatureOfConnectionIndicators, - .len = 1, - }, - { - .name = "ISUPForwardCallIndicators", - .type = ISUPForwardCallIndicators, - .len = 2, - }, - { - .name = "ISUPCallingPartysCategory", - .type = ISUPCallingPartysCategory, - .len = 1, - }, - { - .name = "ISUPTransmissionMediumRequirement", - .type = ISUPTransmissionMediumRequirement, - .len = 1, - }, - { 0, }, + { + .name = "ISUPNatureOfConnectionIndicators", + .type = ISUPNatureOfConnectionIndicators, + .len = 1, + }, + { + .name = "ISUPForwardCallIndicators", + .type = ISUPForwardCallIndicators, + .len = 2, + }, + { + .name = "ISUPCallingPartysCategory", + .type = ISUPCallingPartysCategory, + .len = 1, + }, + { + .name = "ISUPTransmissionMediumRequirement", + .type = ISUPTransmissionMediumRequirement, + .len = 1, + }, + { + 0, + }, }; static const struct isup_ie_fixed inf_fixed[] = { - { - .name = "ISUPInformationIndicators", - .type = ISUPInformationIndicators, - .len = 2, - }, - { 0, }, + { + .name = "ISUPInformationIndicators", + .type = ISUPInformationIndicators, + .len = 2, + }, + { + 0, + }, }; static const struct isup_ie_fixed inr_fixed[] = { - { - .name = "ISUPInformationRequestIndicators", - .type = ISUPInformationRequestIndicators, - .len = 2, - }, - { 0, }, + { + .name = "ISUPInformationRequestIndicators", + .type = ISUPInformationRequestIndicators, + .len = 2, + }, + { + 0, + }, }; static const struct isup_ie_fixed res_fixed[] = { - { - .name = "ISUPSuspendResumeIndicators", - .type = ISUPSuspendResumeIndicators, - .len = 1, - }, - { 0, }, + { + .name = "ISUPSuspendResumeIndicators", + .type = ISUPSuspendResumeIndicators, + .len = 1, + }, + { + 0, + }, }; static const struct isup_ie_fixed sus_fixed[] = { - { - .name = "ISUPSuspendResumeIndicators", - .type = ISUPSuspendResumeIndicators, - .len = 1, - }, - { 0, }, + { + .name = "ISUPSuspendResumeIndicators", + .type = ISUPSuspendResumeIndicators, + .len = 1, + }, + { + 0, + }, }; static const struct isup_ie_variable cfn_variable[] = { - { - .name = "ISUPCauseIndicators", - .type = ISUPCauseIndicators, - .min_len = 2, - .max_len = UINT8_MAX, - }, - { 0, }, + { + .name = "ISUPCauseIndicators", + .type = ISUPCauseIndicators, + .min_len = 2, + .max_len = UINT8_MAX, + }, + { + 0, + }, }; static const struct isup_ie_variable cgb_variable[] = { - { - .name = "ISUPRangeAndStatus", - .type = ISUPRangeAndStatus, - .min_len = 2, - .max_len = 33, - }, - { 0, }, + { + .name = "ISUPRangeAndStatus", + .type = ISUPRangeAndStatus, + .min_len = 2, + .max_len = 33, + }, + { + 0, + }, }; static const struct isup_ie_variable cgba_variable[] = { - { - .name = "ISUPRangeAndStatus", - .type = ISUPRangeAndStatus, - .min_len = 2, - .max_len = 33, - }, - { 0, }, + { + .name = "ISUPRangeAndStatus", + .type = ISUPRangeAndStatus, + .min_len = 2, + .max_len = 33, + }, + { + 0, + }, }; static const struct isup_ie_variable cgu_variable[] = { - { - .name = "ISUPRangeAndStatus", - .type = ISUPRangeAndStatus, - .min_len = 2, - .max_len = 33, - }, - { 0, }, + { + .name = "ISUPRangeAndStatus", + .type = ISUPRangeAndStatus, + .min_len = 2, + .max_len = 33, + }, + { + 0, + }, }; static const struct isup_ie_variable cgua_variable[] = { - { - .name = "ISUPRangeAndStatus", - .type = ISUPRangeAndStatus, - .min_len = 2, - .max_len = 33, - }, - { 0, }, + { + .name = "ISUPRangeAndStatus", + .type = ISUPRangeAndStatus, + .min_len = 2, + .max_len = 33, + }, + { + 0, + }, }; static const struct isup_ie_variable cqr_variable[] = { - { - .name = "ISUPRange", - .type = ISUPRange, - .min_len = 1, - .max_len = UINT8_MAX, - }, - { - .name = "ISUPCircuitStateIndicator", - .type = ISUPCircuitStateIndicator, - .min_len = 1, - .max_len = 32, - }, - { 0, }, + { + .name = "ISUPRange", + .type = ISUPRange, + .min_len = 1, + .max_len = UINT8_MAX, + }, + { + .name = "ISUPCircuitStateIndicator", + .type = ISUPCircuitStateIndicator, + .min_len = 1, + .max_len = 32, + }, + { + 0, + }, }; static const struct isup_ie_variable frj_variable[] = { - { - .name = "ISUPCauseIndicators", - .type = ISUPCauseIndicators, - .min_len = 2, - .max_len = UINT8_MAX, - }, - { 0, }, + { + .name = "ISUPCauseIndicators", + .type = ISUPCauseIndicators, + .min_len = 2, + .max_len = UINT8_MAX, + }, + { + 0, + }, }; static const struct isup_ie_variable grs_variable[] = { - { - .name = "ISUPRange", - .type = ISUPRange, - .min_len = 1, - .max_len = UINT8_MAX, - }, - { 0, }, + { + .name = "ISUPRange", + .type = ISUPRange, + .min_len = 1, + .max_len = UINT8_MAX, + }, + { + 0, + }, }; static const struct isup_ie_variable gra_variable[] = { - { - .name = "ISUPRange", - .type = ISUPRange, - .min_len = 1, - .max_len = UINT8_MAX, - }, - { 0, }, + { + .name = "ISUPRange", + .type = ISUPRange, + .min_len = 1, + .max_len = UINT8_MAX, + }, + { + 0, + }, }; static const struct isup_ie_variable iam_variable[] = { - { - .name = "ISUPCalledPartyNumber", - .type = ISUPCalledPartyNumber, - .min_len = 3, - .max_len = UINT8_MAX, - }, - { 0, }, + { + .name = "ISUPCalledPartyNumber", + .type = ISUPCalledPartyNumber, + .min_len = 3, + .max_len = UINT8_MAX, + }, + { + 0, + }, }; static const struct isup_ie_variable rel_variable[] = { - { - .name = "ISUPCauseIndicators", - .type = ISUPCauseIndicators, - .min_len = 2, - .max_len = UINT8_MAX, - }, - { 0, }, + { + .name = "ISUPCauseIndicators", + .type = ISUPCauseIndicators, + .min_len = 2, + .max_len = UINT8_MAX, + }, + { + 0, + }, }; static const struct isup_ie_variable sam_variable[] = { - { - .name = "ISUPSubsequentNumber", - .type = ISUPSubsequentNumber, - .min_len = 2, - .max_len = UINT8_MAX, - }, - { 0, }, + { + .name = "ISUPSubsequentNumber", + .type = ISUPSubsequentNumber, + .min_len = 2, + .max_len = UINT8_MAX, + }, + { + 0, + }, }; static const struct isup_ie_variable usr_variable[] = { - { - .name = "ISUPUserToUserInformation", - .type = ISUPUserToUserInformation, - .min_len = 1, - .max_len = 129, - }, - { 0, }, + { + .name = "ISUPUserToUserInformation", + .type = ISUPUserToUserInformation, + .min_len = 1, + .max_len = 129, + }, + { + 0, + }, }; const struct isup_msg isup_msgs[256] = { - [1] = { - .name = "IAM", - .fixed_ies = iam_fixed, - .variable_ies = iam_variable, - .has_optional = 1, - }, - [2] = { - .name = "SAM", - .variable_ies = sam_variable, - .has_optional = 1, - }, - [3] = { - .name = "INR", - .fixed_ies = inr_fixed, - .has_optional = 1, - }, - [4] = { - .name = "INF", - .fixed_ies = inf_fixed, - .has_optional = 1, - }, - [5] = { - .name = "COT", - .fixed_ies = cot_fixed, - }, - [6] = { - .name = "ACM", - .fixed_ies = acm_fixed, - .has_optional = 1, - }, - [7] = { - .name = "CON", - .fixed_ies = con_fixed, - .has_optional = 1, - }, - [8] = { - .name = "FOT", - .has_optional = 1, - }, - [9] = { - .name = "AMN", - .has_optional = 1, - }, - [12] = { - .name = "REL", - .variable_ies = rel_variable, - .has_optional = 1, - }, - [13] = { - .name = "SUS", - .fixed_ies = sus_fixed, - .has_optional = 1, - }, - [14] = { - .name = "RES", - .fixed_ies = res_fixed, - .has_optional = 1, - }, - [16] = { - .name = "RLC", - .has_optional = 1, - }, - [17] = { - .name = "CCR", - }, - [18] = { - .name = "RSC", - }, - [19] = { - .name = "BLO", - }, - [20] = { - .name = "UBL", - }, - [21] = { - .name = "BLA", - }, - [22] = { - .name = "UBA", - }, - [23] = { - .name = "GRS", - .variable_ies = grs_variable, - }, - [24] = { - .name = "CGB", - .fixed_ies = cgb_fixed, - .variable_ies = cgb_variable, - }, - [25] = { - .name = "CGU", - .fixed_ies = cgu_fixed, - .variable_ies = cgu_variable, - }, - [26] = { - .name = "CGBA", - .fixed_ies = cgba_fixed, - .variable_ies = cgba_variable, - }, - [27] = { - .name = "CGUA", - .fixed_ies = cgua_fixed, - .variable_ies = cgua_variable, - }, - [31] = { - .name = "FAR", - .fixed_ies = far_fixed, - .has_optional = 1, - }, - [32] = { - .name = "FAA", - .fixed_ies = faa_fixed, - .has_optional = 1, - }, - [33] = { - .name = "FRJ", - .fixed_ies = frj_fixed, - .variable_ies = frj_variable, - .has_optional = 1, - }, - [36] = { - .name = "LPA", - }, - [41] = { - .name = "GRA", - .variable_ies = gra_variable, - }, - [43] = { - .name = "CQR", - .variable_ies = cqr_variable, - }, - [44] = { - .name = "CPG", - .fixed_ies = cpg_fixed, - .has_optional = 1, - }, - [45] = { - .name = "USR", - .variable_ies = usr_variable, - .has_optional = 1, - }, - [46] = { - .name = "UCIC", - }, - [47] = { - .name = "CFN", - .variable_ies = cfn_variable, - .has_optional = 1, - }, - [48] = { - .name = "OLM", - }, - [50] = { - .name = "NRM", - .has_optional = 1, - }, - [51] = { - .name = "FAC", - .has_optional = 1, - }, - [52] = { - .name = "UPT", - .has_optional = 1, - }, - [53] = { - .name = "UPA", - .has_optional = 1, - }, - [54] = { - .name = "IDR", - .has_optional = 1, - }, - [55] = { - .name = "IDS", - .has_optional = 1, - }, - [56] = { - .name = "SEG", - .has_optional = 1, - }, - [64] = { - .name = "LPR", - .has_optional = 1, - }, - [65] = { - .name = "APT", - .has_optional = 1, - }, - [66] = { - .name = "PRI", - .has_optional = 1, - }, - [67] = { - .name = "SAN", - .has_optional = 1, - }, + [1] = + { + .name = "IAM", + .fixed_ies = iam_fixed, + .variable_ies = iam_variable, + .has_optional = 1, + }, + [2] = + { + .name = "SAM", + .variable_ies = sam_variable, + .has_optional = 1, + }, + [3] = + { + .name = "INR", + .fixed_ies = inr_fixed, + .has_optional = 1, + }, + [4] = + { + .name = "INF", + .fixed_ies = inf_fixed, + .has_optional = 1, + }, + [5] = + { + .name = "COT", + .fixed_ies = cot_fixed, + }, + [6] = + { + .name = "ACM", + .fixed_ies = acm_fixed, + .has_optional = 1, + }, + [7] = + { + .name = "CON", + .fixed_ies = con_fixed, + .has_optional = 1, + }, + [8] = + { + .name = "FOT", + .has_optional = 1, + }, + [9] = + { + .name = "AMN", + .has_optional = 1, + }, + [12] = + { + .name = "REL", + .variable_ies = rel_variable, + .has_optional = 1, + }, + [13] = + { + .name = "SUS", + .fixed_ies = sus_fixed, + .has_optional = 1, + }, + [14] = + { + .name = "RES", + .fixed_ies = res_fixed, + .has_optional = 1, + }, + [16] = + { + .name = "RLC", + .has_optional = 1, + }, + [17] = + { + .name = "CCR", + }, + [18] = + { + .name = "RSC", + }, + [19] = + { + .name = "BLO", + }, + [20] = + { + .name = "UBL", + }, + [21] = + { + .name = "BLA", + }, + [22] = + { + .name = "UBA", + }, + [23] = + { + .name = "GRS", + .variable_ies = grs_variable, + }, + [24] = + { + .name = "CGB", + .fixed_ies = cgb_fixed, + .variable_ies = cgb_variable, + }, + [25] = + { + .name = "CGU", + .fixed_ies = cgu_fixed, + .variable_ies = cgu_variable, + }, + [26] = + { + .name = "CGBA", + .fixed_ies = cgba_fixed, + .variable_ies = cgba_variable, + }, + [27] = + { + .name = "CGUA", + .fixed_ies = cgua_fixed, + .variable_ies = cgua_variable, + }, + [31] = + { + .name = "FAR", + .fixed_ies = far_fixed, + .has_optional = 1, + }, + [32] = + { + .name = "FAA", + .fixed_ies = faa_fixed, + .has_optional = 1, + }, + [33] = + { + .name = "FRJ", + .fixed_ies = frj_fixed, + .variable_ies = frj_variable, + .has_optional = 1, + }, + [36] = + { + .name = "LPA", + }, + [41] = + { + .name = "GRA", + .variable_ies = gra_variable, + }, + [43] = + { + .name = "CQR", + .variable_ies = cqr_variable, + }, + [44] = + { + .name = "CPG", + .fixed_ies = cpg_fixed, + .has_optional = 1, + }, + [45] = + { + .name = "USR", + .variable_ies = usr_variable, + .has_optional = 1, + }, + [46] = + { + .name = "UCIC", + }, + [47] = + { + .name = "CFN", + .variable_ies = cfn_variable, + .has_optional = 1, + }, + [48] = + { + .name = "OLM", + }, + [50] = + { + .name = "NRM", + .has_optional = 1, + }, + [51] = + { + .name = "FAC", + .has_optional = 1, + }, + [52] = + { + .name = "UPT", + .has_optional = 1, + }, + [53] = + { + .name = "UPA", + .has_optional = 1, + }, + [54] = + { + .name = "IDR", + .has_optional = 1, + }, + [55] = + { + .name = "IDS", + .has_optional = 1, + }, + [56] = + { + .name = "SEG", + .has_optional = 1, + }, + [64] = + { + .name = "LPR", + .has_optional = 1, + }, + [65] = + { + .name = "APT", + .has_optional = 1, + }, + [66] = + { + .name = "PRI", + .has_optional = 1, + }, + [67] = + { + .name = "SAN", + .has_optional = 1, + }, }; diff --git a/src/modules/ss7ops/isup_generated.h b/src/modules/ss7ops/isup_generated.h index 42eaf4aa3c5..1ca9eb05d08 100644 --- a/src/modules/ss7ops/isup_generated.h +++ b/src/modules/ss7ops/isup_generated.h @@ -3,125 +3,161 @@ #include #define ISUPEndOfOptionalParameters 0 /* End of optional parameters spec: 3.20*/ -#define ISUPCallReference 1 /* Call reference spec: 3.8*/ -#define ISUPTransmissionMediumRequirement 2 /* Transmission medium requirement spec: 3.54*/ -#define ISUPAccessTransport 3 /* Access transport spec: 3.3*/ +#define ISUPCallReference 1 /* Call reference spec: 3.8*/ +#define ISUPTransmissionMediumRequirement \ + 2 /* Transmission medium requirement spec: 3.54*/ +#define ISUPAccessTransport 3 /* Access transport spec: 3.3*/ #define ISUPCalledPartyNumber 4 /* Called party number spec: 3.9*/ -#define ISUPSubsequentNumber 5 /* Subsequent number spec: 3.51*/ -#define ISUPNatureOfConnectionIndicators 6 /* Nature of connection indicators spec: 3.35*/ +#define ISUPSubsequentNumber 5 /* Subsequent number spec: 3.51*/ +#define ISUPNatureOfConnectionIndicators \ + 6 /* Nature of connection indicators spec: 3.35*/ #define ISUPForwardCallIndicators 7 /* Forward call indicators spec: 3.23*/ -#define ISUPOptionalForwardCallIndicators 8 /* Optional forward call indicators spec: 3.38*/ +#define ISUPOptionalForwardCallIndicators \ + 8 /* Optional forward call indicators spec: 3.38*/ #define ISUPCallingPartysCategory 9 /* Calling party's category spec: 3.11*/ -#define ISUPCallingPartyNumber 10 /* Calling party number spec: 3.10*/ -#define ISUPRedirectingNumber 11 /* Redirecting number spec: 3.44*/ -#define ISUPRedirectionNumber 12 /* Redirection number spec: 3.46*/ -#define ISUPConnectionRequest 13 /* Connection request spec: 3.17*/ -#define ISUPInformationRequestIndicators 14 /* Information request indicators spec: 3.29*/ -#define ISUPInformationIndicators 15 /* Information indicators spec: 3.28*/ -#define ISUPContinuityIndicators 16 /* Continuity indicators spec: 3.18*/ +#define ISUPCallingPartyNumber 10 /* Calling party number spec: 3.10*/ +#define ISUPRedirectingNumber 11 /* Redirecting number spec: 3.44*/ +#define ISUPRedirectionNumber 12 /* Redirection number spec: 3.46*/ +#define ISUPConnectionRequest 13 /* Connection request spec: 3.17*/ +#define ISUPInformationRequestIndicators \ + 14 /* Information request indicators spec: 3.29*/ +#define ISUPInformationIndicators 15 /* Information indicators spec: 3.28*/ +#define ISUPContinuityIndicators 16 /* Continuity indicators spec: 3.18*/ #define ISUPBackwardCallIndicators 17 /* Backward call indicators spec: 3.5*/ -#define ISUPCauseIndicators 18 /* Cause indicators spec: 3.12*/ +#define ISUPCauseIndicators 18 /* Cause indicators spec: 3.12*/ #define ISUPRedirectionInformation 19 /* Redirection information spec: 3.45*/ -#define ISUPCircuitGroupSupervisionMessageType 21 /* Circuit group supervision message type spec: 3.13*/ +#define ISUPCircuitGroupSupervisionMessageType \ + 21 /* Circuit group supervision message type spec: 3.13*/ #define ISUPRange 22 /* Range spec: 3.43b*/ -#define ISUPRangeAndStatus 22 /* Range and status spec: 3.43*/ +#define ISUPRangeAndStatus 22 /* Range and status spec: 3.43*/ #define ISUPFacilityIndicator 24 /* Facility indicator spec: 3.22*/ -#define ISUPClosedUserGroupInterlockCode 26 /* Closed user group interlock code spec: 3.15*/ -#define ISUPUserServiceInformation 29 /* User service information spec: 3.57*/ -#define ISUPSignallingPointCode 30 /* Signalling point code spec: 3.50*/ -#define ISUPUserToUserInformation 32 /* User-to-user information spec: 3.61*/ -#define ISUPConnectedNumber 33 /* Connected number spec: 3.16*/ +#define ISUPClosedUserGroupInterlockCode \ + 26 /* Closed user group interlock code spec: 3.15*/ +#define ISUPUserServiceInformation 29 /* User service information spec: 3.57*/ +#define ISUPSignallingPointCode 30 /* Signalling point code spec: 3.50*/ +#define ISUPUserToUserInformation 32 /* User-to-user information spec: 3.61*/ +#define ISUPConnectedNumber 33 /* Connected number spec: 3.16*/ #define ISUPSuspendResumeIndicators 34 /* Suspend/resume indicators spec: 3.52*/ #define ISUPTransitNetworkSelection 35 /* Transit network selection spec: 3.53*/ -#define ISUPEventInformation 36 /* Event information spec: 3.21*/ -#define ISUPCircuitAssignmentMap 37 /* Circuit assignment map spec: 3.69*/ -#define ISUPCircuitStateIndicator 38 /* Circuit state indicator spec: 3.14*/ -#define ISUPAutomaticCongestionLevel 39 /* Automatic congestion level spec: 3.4*/ +#define ISUPEventInformation 36 /* Event information spec: 3.21*/ +#define ISUPCircuitAssignmentMap 37 /* Circuit assignment map spec: 3.69*/ +#define ISUPCircuitStateIndicator 38 /* Circuit state indicator spec: 3.14*/ +#define ISUPAutomaticCongestionLevel \ + 39 /* Automatic congestion level spec: 3.4*/ #define ISUPOriginalCalledNumber 40 /* Original called number spec: 3.39*/ -#define ISUPOptionalBackwardCallIndicators 41 /* Optional backward call indicators spec: 3.37*/ +#define ISUPOptionalBackwardCallIndicators \ + 41 /* Optional backward call indicators spec: 3.37*/ #define ISUPUserToUserIndicators 42 /* User-to-user indicators spec: 3.60*/ -#define ISUPOriginationISCPointCode 43 /* Origination ISC point code spec: 3.40*/ -#define ISUPGenericNotificationIndicator 44 /* Generic notification indicator spec: 3.25*/ +#define ISUPOriginationISCPointCode \ + 43 /* Origination ISC point code spec: 3.40*/ +#define ISUPGenericNotificationIndicator \ + 44 /* Generic notification indicator spec: 3.25*/ #define ISUPCallHistoryInformation 45 /* Call history information spec: 3.7*/ -#define ISUPAccessDeliveryInformation 46 /* Access delivery information spec: 3.2*/ +#define ISUPAccessDeliveryInformation \ + 46 /* Access delivery information spec: 3.2*/ #define ISUPNetworkSpecificFacility 47 /* Network specific facility spec: 3.36*/ -#define ISUPUserServiceInformationPrime 48 /* User service information prime spec: 3.58*/ +#define ISUPUserServiceInformationPrime \ + 48 /* User service information prime spec: 3.58*/ #define ISUPPropagationDelayCounter 49 /* Propagation delay counter spec: 3.42*/ -#define ISUPRemoteOperations 50 /* Remote operations spec: 3.48*/ -#define ISUPServiceActivation 51 /* Service activation spec: 3.49*/ -#define ISUPUserTeleserviceInformation 52 /* User teleservice information spec: 3.59*/ +#define ISUPRemoteOperations 50 /* Remote operations spec: 3.48*/ +#define ISUPServiceActivation 51 /* Service activation spec: 3.49*/ +#define ISUPUserTeleserviceInformation \ + 52 /* User teleservice information spec: 3.59*/ #define ISUPTransmissionMediumUsed 53 /* Transmission medium used spec: 3.56*/ -#define ISUPCallDiversionInformation 54 /* Call diversion information spec: 3.6*/ +#define ISUPCallDiversionInformation \ + 54 /* Call diversion information spec: 3.6*/ #define ISUPEchoControlInformation 55 /* Echo control information spec: 3.19*/ -#define ISUPMessageCompatibilityInformation 56 /* Message compatibility information spec: 3.33*/ -#define ISUPParameterCompatibilityInformation 57 /* Parameter compatibility information spec: 3.41*/ -#define ISUPMLPPPrecedence 58 /* MLPP precedence spec: 3.34*/ -#define ISUPMCIDRequestIndicators 59 /* MCID request indicators spec: 3.31*/ +#define ISUPMessageCompatibilityInformation \ + 56 /* Message compatibility information spec: 3.33*/ +#define ISUPParameterCompatibilityInformation \ + 57 /* Parameter compatibility information spec: 3.41*/ +#define ISUPMLPPPrecedence 58 /* MLPP precedence spec: 3.34*/ +#define ISUPMCIDRequestIndicators 59 /* MCID request indicators spec: 3.31*/ #define ISUPMCIDResponseIndicators 60 /* MCID response indicators spec: 3.32*/ -#define ISUPHopCounter 61 /* Hop counter spec: 3.80*/ -#define ISUPTransmissionMediumRequirementPrime 62 /* Transmission medium requirement prime spec: 3.55*/ +#define ISUPHopCounter 61 /* Hop counter spec: 3.80*/ +#define ISUPTransmissionMediumRequirementPrime \ + 62 /* Transmission medium requirement prime spec: 3.55*/ #define ISUPLocationNumber 63 /* Location number spec: 3.30*/ -#define ISUPRedirectionNumberRestriction 64 /* Redirection number restriction spec: 3.47*/ +#define ISUPRedirectionNumberRestriction \ + 64 /* Redirection number restriction spec: 3.47*/ #define ISUPCallTransferReference 67 /* Call transfer reference spec: 3.65*/ -#define ISUPLoopPreventionIndicators 68 /* Loop prevention indicators spec: 3.67*/ +#define ISUPLoopPreventionIndicators \ + 68 /* Loop prevention indicators spec: 3.67*/ #define ISUPCallTransferNumber 69 /* Call transfer number spec: 3.64*/ -#define ISUPCCSS 75 /* CCSS spec: 3.63*/ -#define ISUPForwardGVNS 76 /* Forward GVNS spec: 3.66*/ -#define ISUPBackwardGVNS 77 /* Backward GVNS spec: 3.62*/ +#define ISUPCCSS 75 /* CCSS spec: 3.63*/ +#define ISUPForwardGVNS 76 /* Forward GVNS spec: 3.66*/ +#define ISUPBackwardGVNS 77 /* Backward GVNS spec: 3.62*/ #define ISUPRedirectCapability 78 /* Redirect capability spec: 3.96*/ -#define ISUPNetworkManagementControls 91 /* Network management controls spec: 3.68*/ +#define ISUPNetworkManagementControls \ + 91 /* Network management controls spec: 3.68*/ #define ISUPCorrelationId 101 /* Correlation id spec: 3.70*/ -#define ISUPSCFId 102 /* SCF id spec: 3.71*/ -#define ISUPCallDiversionTreatmentIndicators 110 /* Call diversion treatment indicators spec: 3.72*/ +#define ISUPSCFId 102 /* SCF id spec: 3.71*/ +#define ISUPCallDiversionTreatmentIndicators \ + 110 /* Call diversion treatment indicators spec: 3.72*/ #define ISUPCalledINNumber 111 /* Called IN number spec: 3.73*/ -#define ISUPCallOfferingTreatmentIndicators 112 /* Call offering treatment indicators spec: 3.74*/ -#define ISUPChargedPartyIdentification 113 /* Charged party identification spec: 3.75*/ -#define ISUPConferenceTreatmentIndicators 114 /* Conference treatment indicators spec: 3.76*/ -#define ISUPDisplayInformation 115 /* Display information spec: 3.77*/ +#define ISUPCallOfferingTreatmentIndicators \ + 112 /* Call offering treatment indicators spec: 3.74*/ +#define ISUPChargedPartyIdentification \ + 113 /* Charged party identification spec: 3.75*/ +#define ISUPConferenceTreatmentIndicators \ + 114 /* Conference treatment indicators spec: 3.76*/ +#define ISUPDisplayInformation 115 /* Display information spec: 3.77*/ #define ISUPUIDActionIndicators 116 /* UID action indicators spec: 3.78*/ -#define ISUPUIDCapabilityIndicators 117 /* UID capability indicators spec: 3.79*/ +#define ISUPUIDCapabilityIndicators \ + 117 /* UID capability indicators spec: 3.79*/ #define ISUPRedirectCounter 119 /* Redirect counter spec: 3.97*/ -#define ISUPApplicationTransportParameter 120 /* Application transport parameter spec: 3.82*/ -#define ISUPCollectCallRequest 121 /* Collect call request spec: 3.81*/ -#define ISUPCCNRPossibleIndicator 122 /* CCNR possible indicator spec: 3.83*/ -#define ISUPPivotCapability 123 /* Pivot capability spec: 3.84*/ +#define ISUPApplicationTransportParameter \ + 120 /* Application transport parameter spec: 3.82*/ +#define ISUPCollectCallRequest 121 /* Collect call request spec: 3.81*/ +#define ISUPCCNRPossibleIndicator 122 /* CCNR possible indicator spec: 3.83*/ +#define ISUPPivotCapability 123 /* Pivot capability spec: 3.84*/ #define ISUPPivotRoutingIndicators 124 /* Pivot routing indicators spec: 3.85*/ -#define ISUPCalledDirectoryNumber 125 /* Called directory number spec: 3.86*/ +#define ISUPCalledDirectoryNumber 125 /* Called directory number spec: 3.86*/ #define ISUPOriginalCalledINNumber 127 /* Original called IN number spec: 3.87*/ -#define ISUPCallingGeodeticLocation 129 /* Calling geodetic location spec: 3.88*/ -#define ISUPGenericReference 130 /* Generic reference spec: 3.27*/ -#define ISUPHTRInformation 130 /* HTR information spec: 3.89*/ +#define ISUPCallingGeodeticLocation \ + 129 /* Calling geodetic location spec: 3.88*/ +#define ISUPGenericReference 130 /* Generic reference spec: 3.27*/ +#define ISUPHTRInformation 130 /* HTR information spec: 3.89*/ #define ISUPNetworkRoutingNumber 132 /* Network routing number spec: 3.90*/ -#define ISUPQoRCapability 133 /* QoR capability spec: 3.91*/ -#define ISUPPivotStatus 134 /* Pivot status spec: 3.92*/ -#define ISUPPivotCounter 135 /* Pivot counter spec: 3.93*/ -#define ISUPPivotRoutingForwardInformation 136 /* Pivot routing forward information spec: 3.94*/ -#define ISUPPivotRoutingBackwardInformation 137 /* Pivot routing backward information spec: 3.95*/ +#define ISUPQoRCapability 133 /* QoR capability spec: 3.91*/ +#define ISUPPivotStatus 134 /* Pivot status spec: 3.92*/ +#define ISUPPivotCounter 135 /* Pivot counter spec: 3.93*/ +#define ISUPPivotRoutingForwardInformation \ + 136 /* Pivot routing forward information spec: 3.94*/ +#define ISUPPivotRoutingBackwardInformation \ + 137 /* Pivot routing backward information spec: 3.95*/ #define ISUPRedirectStatus 138 /* Redirect status spec: 3.98*/ -#define ISUPRedirectForwardInformation 139 /* Redirect forward information spec: 3.99*/ -#define ISUPRedirectBackwardInformation 140 /* Redirect backward information spec: 3.100*/ -#define ISUPNumberPortabilityForwardInformation 141 /* Number portability forward information spec: 3.101*/ +#define ISUPRedirectForwardInformation \ + 139 /* Redirect forward information spec: 3.99*/ +#define ISUPRedirectBackwardInformation \ + 140 /* Redirect backward information spec: 3.100*/ +#define ISUPNumberPortabilityForwardInformation \ + 141 /* Number portability forward information spec: 3.101*/ #define ISUPGenericNumber 192 /* Generic number spec: 3.26*/ #define ISUPGenericDigits 193 /* Generic digits spec: 3.24*/ -struct isup_ie_fixed { +struct isup_ie_fixed +{ const char *name; uint8_t type; uint8_t len; }; -struct isup_ie_variable { +struct isup_ie_variable +{ const char *name; uint8_t type; uint8_t min_len; uint8_t max_len; }; -struct isup_ie_optional { +struct isup_ie_optional +{ const char *name; uint8_t type; uint8_t min_len; uint8_t max_len; }; -struct isup_msg { - const char *name; +struct isup_msg +{ + const char *name; const struct isup_ie_fixed *fixed_ies; const struct isup_ie_variable *variable_ies; diff --git a/src/modules/ss7ops/isup_parsed.c b/src/modules/ss7ops/isup_parsed.c index a55d43d3e0f..5ebc2d7f348 100644 --- a/src/modules/ss7ops/isup_parsed.c +++ b/src/modules/ss7ops/isup_parsed.c @@ -31,459 +31,548 @@ #include -typedef void (*visit)(uint8_t type, const uint8_t *data, uint8_t len, struct isup_state *ptrs); +typedef void (*visit)(uint8_t type, const uint8_t *data, uint8_t len, + struct isup_state *ptrs); -struct key_val { - uint8_t key; - const char *value; +struct key_val +{ + uint8_t key; + const char *value; }; static const struct key_val itu_cause_class[] = { - { 0x00, "normal event" }, - { 0x01, "normal event" }, - { 0x02, "resource unavailable" }, - { 0x03, "service or option not available" }, - { 0x04, "service or option not implemented" }, - { 0x05, "invalid message" }, - { 0x06, "protocol error" }, - { 0x07, "interworking"} , - { 0, }, + {0x00, "normal event"}, + {0x01, "normal event"}, + {0x02, "resource unavailable"}, + {0x03, "service or option not available"}, + {0x04, "service or option not implemented"}, + {0x05, "invalid message"}, + {0x06, "protocol error"}, + {0x07, "interworking"}, + { + 0, + }, }; static const struct key_val cause_value[] = { - { 1, "Unallocated (unassigned) number" }, - { 2, "No route to specified transit network" }, - { 3, "No route to destination" }, - { 4, "Send special information tone" }, - { 5, "Misdialled trunk prefix" }, - { 6, "Channel unacceptable" }, - { 7, "Call awarded and being delivered in an established channel" }, - { 8, "Preemption" }, - { 9, "Preemption - circuit reserved for reuse" }, - { 14, "QoR: ported number" }, /* Add.1 */ - { 16, "Normal call clearing" }, - { 17, "User busy" }, - { 18, "No user responding" }, - { 19, "No answer from user (user alerted)" }, - { 20, "Subscriber absent" }, - { 21, "Call rejected" }, - { 22, "Number changed" }, - { 23, "Redirection to new destination" }, - { 24, "Call rejected due to failure at the destination" }, /* Amd.1 */ - { 25, "Exchange routing error" }, - { 26, "Non-selected user clearing" }, - { 27, "Destination out of order" }, - { 28, "Invalid number format (address incomplete)" }, - { 29, "Facility rejected" }, - { 30, "Response to STATUS ENQUIRY" }, - { 31, "Normal, unspecified" }, - { 34, "No circuit/channel available" }, - { 38, "Network out of order" }, - { 39, "Permanent frame mode connection out of service" }, - { 40, "Permanent frame mode connection operational" }, - { 41, "Temporary failure" }, - { 42, "Switching equipment congestion" }, - { 43, "Access information discarded" }, - { 44, "Requested circuit/channel not available" }, - { 46, "Precedence call blocked" }, - { 47, "Resource unavailable, unspecified" }, - { 49, "Quality of service not available" }, - { 50, "Requested facility not subscribed" }, - { 53, "Outgoing calls barred within CUG" }, - { 55, "Incoming calls barred within CUG" }, - { 57, "Bearer capability not authorized" }, - { 58, "Bearer capability not presently available" }, - { 62, "Inconsistency in designated outgoing access information and subscriber class" }, - { 63, "Service or option not available, unspecified" }, - { 65, "Bearer capability not implemented" }, - { 66, "Channel type not implemented" }, - { 69, "Requested facility not implemented" }, - { 70, "Only restricted digital information bearer capability is available" }, - { 79, "Service or option not implemented, unspecified" }, - { 81, "Invalid call reference value" }, - { 82, "Identified channel does not exist" }, - { 83, "A suspended call exists, but this call identity does not" }, - { 84, "Call identity in use" }, - { 85, "No call suspended" }, - { 86, "Call having the requested call identity has been cleared" }, - { 87, "User not member of CUG" }, - { 88, "Incompatible destination" }, - { 90, "Non-existent CUG" }, - { 91, "Invalid transit network selection" }, - { 95, "Invalid message, unspecified" }, - { 96, "Mandatory information element is missing" }, - { 97, "Message type non-existent or not implemented" }, - { 98, "Message not compatible with call state or message type non-existent or not implemented" }, - { 99, "Information element /parameter non-existent or not implemented" }, - { 100, "Invalid information element contents" }, - { 101, "Message not compatible with call state" }, - { 102, "Recovery on timer expiry" }, - { 103, "Parameter non-existent or not implemented, passed on" }, - { 110, "Message with unrecognized parameter, discarded" }, - { 111, "Protocol error, unspecified" }, - { 127, "Interworking, unspecified" }, - { 0, }, + {1, "Unallocated (unassigned) number"}, + {2, "No route to specified transit network"}, + {3, "No route to destination"}, + {4, "Send special information tone"}, + {5, "Misdialled trunk prefix"}, + {6, "Channel unacceptable"}, + {7, "Call awarded and being delivered in an established channel"}, + {8, "Preemption"}, + {9, "Preemption - circuit reserved for reuse"}, + {14, "QoR: ported number"}, /* Add.1 */ + {16, "Normal call clearing"}, + {17, "User busy"}, + {18, "No user responding"}, + {19, "No answer from user (user alerted)"}, + {20, "Subscriber absent"}, + {21, "Call rejected"}, + {22, "Number changed"}, + {23, "Redirection to new destination"}, + {24, "Call rejected due to failure at the destination"}, /* Amd.1 */ + {25, "Exchange routing error"}, + {26, "Non-selected user clearing"}, + {27, "Destination out of order"}, + {28, "Invalid number format (address incomplete)"}, + {29, "Facility rejected"}, + {30, "Response to STATUS ENQUIRY"}, + {31, "Normal, unspecified"}, + {34, "No circuit/channel available"}, + {38, "Network out of order"}, + {39, "Permanent frame mode connection out of service"}, + {40, "Permanent frame mode connection operational"}, + {41, "Temporary failure"}, + {42, "Switching equipment congestion"}, + {43, "Access information discarded"}, + {44, "Requested circuit/channel not available"}, + {46, "Precedence call blocked"}, + {47, "Resource unavailable, unspecified"}, + {49, "Quality of service not available"}, + {50, "Requested facility not subscribed"}, + {53, "Outgoing calls barred within CUG"}, + {55, "Incoming calls barred within CUG"}, + {57, "Bearer capability not authorized"}, + {58, "Bearer capability not presently available"}, + {62, "Inconsistency in designated outgoing access information and " + "subscriber class"}, + {63, "Service or option not available, unspecified"}, + {65, "Bearer capability not implemented"}, + {66, "Channel type not implemented"}, + {69, "Requested facility not implemented"}, + {70, "Only restricted digital information bearer capability is " + "available"}, + {79, "Service or option not implemented, unspecified"}, + {81, "Invalid call reference value"}, + {82, "Identified channel does not exist"}, + {83, "A suspended call exists, but this call identity does not"}, + {84, "Call identity in use"}, + {85, "No call suspended"}, + {86, "Call having the requested call identity has been cleared"}, + {87, "User not member of CUG"}, + {88, "Incompatible destination"}, + {90, "Non-existent CUG"}, + {91, "Invalid transit network selection"}, + {95, "Invalid message, unspecified"}, + {96, "Mandatory information element is missing"}, + {97, "Message type non-existent or not implemented"}, + {98, "Message not compatible with call state or message type " + "non-existent or not implemented"}, + {99, "Information element /parameter non-existent or not implemented"}, + {100, "Invalid information element contents"}, + {101, "Message not compatible with call state"}, + {102, "Recovery on timer expiry"}, + {103, "Parameter non-existent or not implemented, passed on"}, + {110, "Message with unrecognized parameter, discarded"}, + {111, "Protocol error, unspecified"}, + {127, "Interworking, unspecified"}, + { + 0, + }, }; static const struct key_val cause_std[] = { - { 0x00, "ITU-T" }, - { 0x01, "ISO/IEC" }, - { 0x02, "National" }, - { 0x03, "Specific" }, - { 0, }, + {0x00, "ITU-T"}, + {0x01, "ISO/IEC"}, + {0x02, "National"}, + {0x03, "Specific"}, + { + 0, + }, }; static const struct key_val cause_location[] = { - { 0x0, "user (U)" }, - { 0x01, "private network serving the local user (LPN)" }, - { 0x02, "public network serving the local user (LN)" }, - { 0x03, "transit network (TN)" }, - { 0x04, "public network serving the remote user (RLN)" }, - { 0x05, "private network serving the remote user (RPN)" }, - { 0x07, "international network (INTL)" }, - { 0x0A, "network beyond interworking point (BI)" }, - { 0, }, + {0x0, "user (U)"}, + {0x01, "private network serving the local user (LPN)"}, + {0x02, "public network serving the local user (LN)"}, + {0x03, "transit network (TN)"}, + {0x04, "public network serving the remote user (RLN)"}, + {0x05, "private network serving the remote user (RPN)"}, + {0x07, "international network (INTL)"}, + {0x0A, "network beyond interworking point (BI)"}, + { + 0, + }, }; static const struct key_val event_info[] = { - { 0x01, "ALERTING" }, - { 0x02, "PROGRESS" }, - { 0x03, "in-band" }, - { 0x04, "call forwarded on busy" }, - { 0x05, "call forwarded on no reply" }, - { 0x06, "call forwarded unconditional" }, - { 0, }, + {0x01, "ALERTING"}, + {0x02, "PROGRESS"}, + {0x03, "in-band"}, + {0x04, "call forwarded on busy"}, + {0x05, "call forwarded on no reply"}, + {0x06, "call forwarded unconditional"}, + { + 0, + }, }; static const struct key_val nai_vals[] = { - { 0x00, "spare" }, - { 0x01, "subscriber number (national use)" }, - { 0x02, "unknown (national use)" }, - { 0x03, "national (significant) number" }, - { 0x04, "international number" }, - { 0x05, "network-specific number (national use)" }, - { 0x06, "network routing number in national (significant) number format (national use)" }, - { 0x07, "network routing number in network-specific number format (national use)" }, - { 0x08, "network routing number concatenated with Called Directory Number (national use)" }, - { 0, }, + {0x00, "spare"}, + {0x01, "subscriber number (national use)"}, + {0x02, "unknown (national use)"}, + {0x03, "national (significant) number"}, + {0x04, "international number"}, + {0x05, "network-specific number (national use)"}, + {0x06, "network routing number in national (significant) number format " + "(national use)"}, + {0x07, "network routing number in network-specific number format " + "(national use)"}, + {0x08, "network routing number concatenated with Called Directory " + "Number (national use)"}, + { + 0, + }, }; static const struct key_val inn_vals[] = { - { 0x00, "routing to internal network number allowed" }, - { 0x01, "routing to internal network number not allowed" }, - { 0, }, + {0x00, "routing to internal network number allowed"}, + {0x01, "routing to internal network number not allowed"}, + { + 0, + }, }; static const struct key_val ni_vals[] = { - { 0x00, "complete" }, - { 0x01, "incomplete" }, - { 0, }, + {0x00, "complete"}, + {0x01, "incomplete"}, + { + 0, + }, }; static const struct key_val npi_vals[] = { - { 0x00, "spare" }, - { 0x01, "ISDN (Telephony) numbering plan (ITU-T Recommendation E.164)" }, - { 0x02, "spare" }, - { 0x03, "Data numbering plan (ITU-T Recommendation X.121) (national use)" }, - { 0x04, "Telex numbering plan (ITU-T Recommendation F.69) (national use)" }, - { 0x05, "reserved for national use" }, - { 0x06, "reserved for national use" }, - { 0, }, + {0x00, "spare"}, + {0x01, "ISDN (Telephony) numbering plan (ITU-T Recommendation E.164)"}, + {0x02, "spare"}, + {0x03, "Data numbering plan (ITU-T Recommendation X.121) (national " + "use)"}, + {0x04, "Telex numbering plan (ITU-T Recommendation F.69) (national " + "use)"}, + {0x05, "reserved for national use"}, + {0x06, "reserved for national use"}, + { + 0, + }, }; static const struct key_val restrict_vals[] = { - { 0x00, "presentation allowed" }, - { 0x01, "presentation restricted" }, - { 0x02, "address not available (Note 1) (national use)" }, - { 0x03, "reserved for restriction by the network" }, - { 0, }, + {0x00, "presentation allowed"}, + {0x01, "presentation restricted"}, + {0x02, "address not available (Note 1) (national use)"}, + {0x03, "reserved for restriction by the network"}, + { + 0, + }, }; static const struct key_val screened_vals[] = { - { 0x00, "reserved (Note 2)" }, - { 0x01, "user provided, verified and passed" }, - { 0x02, "reserved (Note 2)" }, - { 0x03, "network provided" }, - { 0, }, + {0x00, "reserved (Note 2)"}, + {0x01, "user provided, verified and passed"}, + {0x02, "reserved (Note 2)"}, + {0x03, "network provided"}, + { + 0, + }, }; static const struct key_val calling_cat_vals[] = { - { 0x00, "calling party's category unknown at this time (national use)" }, - { 0x01, "operator, language French" }, - { 0x02, "operator, language English" }, - { 0x03, "operator, language German" }, - { 0x04, "operator, language Russian" }, - { 0x05, "operator, language Spanish" }, - { 0x09, "reserved (see ITU-T Recommendation Q.104) (Note) (national use)" }, - { 0x0A, "ordinary calling subscriber" }, - { 0x0B, "calling subscriber with priority" }, - { 0x0C, "data call (voice band data)" }, - { 0x0D, "test call" }, - { 0x0E, "spare" }, - { 0x0F, "payphone" }, - { 0, }, + {0x00, "calling party's category unknown at this time (national use)"}, + {0x01, "operator, language French"}, + {0x02, "operator, language English"}, + {0x03, "operator, language German"}, + {0x04, "operator, language Russian"}, + {0x05, "operator, language Spanish"}, + {0x09, "reserved (see ITU-T Recommendation Q.104) (Note) (national " + "use)"}, + {0x0A, "ordinary calling subscriber"}, + {0x0B, "calling subscriber with priority"}, + {0x0C, "data call (voice band data)"}, + {0x0D, "test call"}, + {0x0E, "spare"}, + {0x0F, "payphone"}, + { + 0, + }, }; static const struct key_val nci_sat_vals[] = { - { 0x00, "no satellite circuit in the connection" }, - { 0x01, "one satellite circuit in the connection" }, - { 0x02, "two satellite circuits in the connection" }, - { 0x03, "spare" }, - { 0, }, + {0x00, "no satellite circuit in the connection"}, + {0x01, "one satellite circuit in the connection"}, + {0x02, "two satellite circuits in the connection"}, + {0x03, "spare"}, + { + 0, + }, }; static const struct key_val nci_con_vals[] = { - { 0x00, "continuity check not required" }, - { 0x01, "continuity check required on this circuit" }, - { 0x02, "continuity check performed on a previous circuit" }, - { 0x03, "spare" }, - { 0, }, + {0x00, "continuity check not required"}, + {0x01, "continuity check required on this circuit"}, + {0x02, "continuity check performed on a previous circuit"}, + {0x03, "spare"}, + { + 0, + }, }; static const struct key_val nci_echo_vals[] = { - { 0x00, "outgoing echo control device not included" }, - { 0x01, "outgoing echo control device included" }, - { 0, }, + {0x00, "outgoing echo control device not included"}, + {0x01, "outgoing echo control device included"}, + { + 0, + }, }; /* Forward call indicators National/international call indicator */ static const struct key_val fwc_nic_vals[] = { - { 0x00, "call to be treated as a national call" }, - { 0x01, "call to be treated as an international call" }, - { 0, }, + {0x00, "call to be treated as a national call"}, + {0x01, "call to be treated as an international call"}, + { + 0, + }, }; /* End-to-end method indicator */ static const struct key_val fwc_etem_vals[] = { - { 0x00, "no end-to-end method available (only link-by-link method available)" }, - { 0x01, "pass-along method available (national use)" }, - { 0x02, "SCCP method available" }, - { 0x03, "pass-along and SCCP methods available (national use)" }, - { 0, }, + {0x00, "no end-to-end method available (only link-by-link method " + "available)"}, + {0x01, "pass-along method available (national use)"}, + {0x02, "SCCP method available"}, + {0x03, "pass-along and SCCP methods available (national use)"}, + { + 0, + }, }; /* Interworking indicator */ static const struct key_val fwc_iw_vals[] = { - { 0x00, "no interworking encountered (No. 7 signalling all the way)" }, - { 0x01, "interworking encountered" }, - { 0, }, + {0x00, "no interworking encountered (No. 7 signalling all the way)"}, + {0x01, "interworking encountered"}, + { + 0, + }, }; /* End-to-end information indicator */ static const struct key_val fwc_etei_vals[] = { - { 0x00, "no end-to-end information available" }, - { 0x01, "end-to-end information available" }, - { 0, }, + {0x00, "no end-to-end information available"}, + {0x01, "end-to-end information available"}, + { + 0, + }, }; /* ISDN user part indicator */ static const struct key_val fwc_isup_vals[] = { - { 0x00, "ISDN user part not used all the way" }, - { 0x01, "ISDN user part used all the way" }, - { 0, }, + {0x00, "ISDN user part not used all the way"}, + {0x01, "ISDN user part used all the way"}, + { + 0, + }, }; /* ISDN user part preference indicator */ static const struct key_val fwc_isup_pref_vals[] = { - { 0x00, "ISDN user part preferred all the way" }, - { 0x01, "ISDN user part not required all the way" }, - { 0x02, "ISDN user part required all the way" }, - { 0x03, "spare" }, - { 0, }, + {0x00, "ISDN user part preferred all the way"}, + {0x01, "ISDN user part not required all the way"}, + {0x02, "ISDN user part required all the way"}, + {0x03, "spare"}, + { + 0, + }, }; /* ISDN access indicator */ static const struct key_val fwc_ia_vals[] = { - { 0x00, "originating access non-ISDN" }, - { 0x01, "originating access ISD" }, - { 0, }, + {0x00, "originating access non-ISDN"}, + {0x01, "originating access ISD"}, + { + 0, + }, }; /* SCCP method indicator */ static const struct key_val fwc_sccpm_vals[] = { - { 0x00, "no indication" }, - { 0x01, "connectionless method available (national use)" }, - { 0x02, "connection oriented method available" }, - { 0x03, "connectionless and connection oriented methods available (national use)" }, - { 0, }, + {0x00, "no indication"}, + {0x01, "connectionless method available (national use)"}, + {0x02, "connection oriented method available"}, + {0x03, "connectionless and connection oriented methods available " + "(national use)"}, + { + 0, + }, }; /* Transmission medium */ static const struct key_val trans_medium_vals[] = { - { 0x00, "speech" }, - { 0x01, "spare" }, - { 0x02, "64 kbit/s unrestricted" }, - { 0x03, "3.1 kHz audio" }, - { 0x04, "reserved for alternate speech (service 2)/64 kbit/s unrestricted (service 1)" }, - { 0x05, "reserved for alternate 64 kbit/s unrestricted (service 1)/speech (service 2)" }, - { 0x06, "64 kbit/s preferred" }, - { 0x07, "2 × 64 kbit/s unrestricted" }, - { 0x08, "384 kbit/s unrestricted" }, - { 0x09, "1536 kbit/s unrestricted" }, - { 0x0A, "1920 kbit/s unrestricted" }, - { 0x10, "3 × 64 kbit/s unrestricted" }, - { 0x11, "4 × 64 kbit/s unrestricted" }, - { 0x12, "5 × 64 kbit/s unrestricted" }, - { 0x13, "spare" }, - { 0x14, "7 × 64 kbit/s unrestricted" }, - { 0x15, "8 × 64 kbit/s unrestricted" }, - { 0x16, "9 × 64 kbit/s unrestricted" }, - { 0x17, "10 × 64 kbit/s unrestricted" }, - { 0x18, "11 × 64 kbit/s unrestricted" }, - { 0x19, "12 × 64 kbit/s unrestricted" }, - { 0x1A, "13 × 64 kbit/s unrestricted" }, - { 0x1B, "14 × 64 kbit/s unrestricted" }, - { 0x1C, "15 × 64 kbit/s unrestricted" }, - { 0x1D, "16 × 64 kbit/s unrestricted" }, - { 0x1E, "17 × 64 kbit/s unrestricted" }, - { 0x1F, "18 × 64 kbit/s unrestricted" }, - { 0x20, "19 × 64 kbit/s unrestricted" }, - { 0x21, "20 × 64 kbit/s unrestricted" }, - { 0x22, "21 × 64 kbit/s unrestricted" }, - { 0x23, "22 × 64 kbit/s unrestricted" }, - { 0x24, "23 × 64 kbit/s unrestricted" }, - { 0x25, "spare" }, - { 0x26, "25 × 64 kbit/s unrestricted" }, - { 0x27, "26 × 64 kbit/s unrestricted" }, - { 0x28, "27 × 64 kbit/s unrestricted" }, - { 0x29, "28 × 64 kbit/s unrestricted" }, - { 0x2A, "29 × 64 kbit/s unrestricted" }, - { 0, }, + {0x00, "speech"}, + {0x01, "spare"}, + {0x02, "64 kbit/s unrestricted"}, + {0x03, "3.1 kHz audio"}, + {0x04, "reserved for alternate speech (service 2)/64 kbit/s " + "unrestricted (service 1)"}, + {0x05, "reserved for alternate 64 kbit/s unrestricted (service " + "1)/speech (service 2)"}, + {0x06, "64 kbit/s preferred"}, + {0x07, "2 × 64 kbit/s unrestricted"}, + {0x08, "384 kbit/s unrestricted"}, + {0x09, "1536 kbit/s unrestricted"}, + {0x0A, "1920 kbit/s unrestricted"}, + {0x10, "3 × 64 kbit/s unrestricted"}, + {0x11, "4 × 64 kbit/s unrestricted"}, + {0x12, "5 × 64 kbit/s unrestricted"}, + {0x13, "spare"}, + {0x14, "7 × 64 kbit/s unrestricted"}, + {0x15, "8 × 64 kbit/s unrestricted"}, + {0x16, "9 × 64 kbit/s unrestricted"}, + {0x17, "10 × 64 kbit/s unrestricted"}, + {0x18, "11 × 64 kbit/s unrestricted"}, + {0x19, "12 × 64 kbit/s unrestricted"}, + {0x1A, "13 × 64 kbit/s unrestricted"}, + {0x1B, "14 × 64 kbit/s unrestricted"}, + {0x1C, "15 × 64 kbit/s unrestricted"}, + {0x1D, "16 × 64 kbit/s unrestricted"}, + {0x1E, "17 × 64 kbit/s unrestricted"}, + {0x1F, "18 × 64 kbit/s unrestricted"}, + {0x20, "19 × 64 kbit/s unrestricted"}, + {0x21, "20 × 64 kbit/s unrestricted"}, + {0x22, "21 × 64 kbit/s unrestricted"}, + {0x23, "22 × 64 kbit/s unrestricted"}, + {0x24, "23 × 64 kbit/s unrestricted"}, + {0x25, "spare"}, + {0x26, "25 × 64 kbit/s unrestricted"}, + {0x27, "26 × 64 kbit/s unrestricted"}, + {0x28, "27 × 64 kbit/s unrestricted"}, + {0x29, "28 × 64 kbit/s unrestricted"}, + {0x2A, "29 × 64 kbit/s unrestricted"}, + { + 0, + }, }; /* Q931 bearer capabilities */ -static const struct key_val q931_cstd_vals[] = { - { 0x00, "ITU-T standardized coding as described below" }, - { 0x01, "ISO/IEC Standard" }, - { 0x02, "National standard" }, - { 0x03, "Standard defined for the network (either public or private) present on the network side of the interface" }, - { 0, }, +static const struct key_val q931_cstd_vals[] = { + {0x00, "ITU-T standardized coding as described below"}, + {0x01, "ISO/IEC Standard"}, + {0x02, "National standard"}, + {0x03, "Standard defined for the network (either public or private) " + "present on the network side of the interface"}, + { + 0, + }, }; static const struct key_val q931_trs_cap_vals[] = { - { 0x00, "Speech" }, - { 0x08, "Unrestricted digital information" }, - { 0x09, "Restricted digital information" }, - { 0x10, "3.1 kHz audio" }, - { 0x11, "Unrestricted digital information with tones/announcements (Note 2)" }, - { 0x18, "Video" }, - { 0, }, + {0x00, "Speech"}, + {0x08, "Unrestricted digital information"}, + {0x09, "Restricted digital information"}, + {0x10, "3.1 kHz audio"}, + {0x11, "Unrestricted digital information with tones/announcements " + "(Note 2)"}, + {0x18, "Video"}, + { + 0, + }, }; static const struct key_val q931_trs_mde_vals[] = { - { 0x00, "Circuit mode" }, - { 0x01, "Packet mode" }, - { 0, }, + {0x00, "Circuit mode"}, + {0x01, "Packet mode"}, + { + 0, + }, }; static const struct key_val q931_trs_rte_vals[] = { - { 0x00, "packet-mode calls" }, - { 0x10, "64 kbit/s" }, - { 0x11, "2 × 64 kbit/s" }, - { 0x13, "384 kbit/s" }, - { 0x15, "1536 kbit/s" }, - { 0x17, "1920 kbit/s" }, - { 0x18, "Multirate (64 kbit/s base rate)" }, - { 0, }, + {0x00, "packet-mode calls"}, + {0x10, "64 kbit/s"}, + {0x11, "2 × 64 kbit/s"}, + {0x13, "384 kbit/s"}, + {0x15, "1536 kbit/s"}, + {0x17, "1920 kbit/s"}, + {0x18, "Multirate (64 kbit/s base rate)"}, + { + 0, + }, }; static const struct key_val q931_usr_info_vals[] = { - { 0x00, "ITU-T standardized rate adaption V.110, I.460 and X.30. This implies the presence of octet 5a and optionally octets 5b, 5c and 5d as defined below" }, - { 0x02, "G.711 u-law" }, - { 0x03, "G.711 a-law" }, - { 0x04, "G.721 ADPCM" }, - { 0x05, "H.221 and H.242" }, - { 0x06, "H.223 and H.245" }, - { 0x07, "Non-ITU-T standardized rate adaption" }, - { 0x08, "V.120" }, - { 0x09, "X.31" }, - { 0, }, + {0x00, "ITU-T standardized rate adaption V.110, I.460 and X.30. This " + "implies the presence of octet 5a and optionally octets 5b, 5c " + "and 5d as defined below"}, + {0x02, "G.711 u-law"}, + {0x03, "G.711 a-law"}, + {0x04, "G.721 ADPCM"}, + {0x05, "H.221 and H.242"}, + {0x06, "H.223 and H.245"}, + {0x07, "Non-ITU-T standardized rate adaption"}, + {0x08, "V.120"}, + {0x09, "X.31"}, + { + 0, + }, }; -static const char *lookup(const struct key_val *table, const uint8_t val, const char *deflt) +static const char *lookup( + const struct key_val *table, const uint8_t val, const char *deflt) { - while (1) { - if (!table->value) + while(1) { + if(!table->value) return deflt; - if (table->key == val) + if(table->key == val) return table->value; table += 1; } } -static inline char from_bcd(const uint8_t item) { - if (item >= 0x0A) +static inline char from_bcd(const uint8_t item) +{ + if(item >= 0x0A) return 'A' + (item - 0x0A); return '0' + item; } -static inline void decode_bcd(char *dest, const uint8_t *data, size_t len, int odd) +static inline void decode_bcd( + char *dest, const uint8_t *data, size_t len, int odd) { int i; - for (i = 0; i < len; ++i) { + for(i = 0; i < len; ++i) { uint8_t lo = data[i] & 0x0F; uint8_t hi = (data[i] & 0xF0) >> 4; *dest++ = from_bcd(lo); /* ignore the last digit */ - if (i + 1 == len && odd) + if(i + 1 == len && odd) break; *dest++ = from_bcd(hi); } *dest = '\0'; } -static void append_e164(srjson_doc_t *doc, const char *name, const uint8_t *data, uint8_t len, const uint8_t type) +static void append_e164(srjson_doc_t *doc, const char *name, + const uint8_t *data, uint8_t len, const uint8_t type) { - char num[17] = { 0, }; + char num[17] = { + 0, + }; srjson_t *obj; int odd; /* at least TON/NPI in there */ - if (len < 2) { + if(len < 2) { LM_ERR("Too short %s %u\n", name, len); return; } /* E.164 is limited to 15 digits so 8 octets */ - if (len - 2 > 8) { + if(len - 2 > 8) { LM_ERR("Too big %s %u\n", name, len); return; } obj = srjson_CreateObject(doc); - if (!obj) { + if(!obj) { LM_ERR("Can not allocate json object for %s\n", name); return; } odd = !!(data[0] & 0x80); - if (type == ISUPCalledPartyNumber) { + if(type == ISUPCalledPartyNumber) { uint8_t inn = data[1] >> 7; srjson_AddNumberToObject(doc, obj, "inn", inn); - srjson_AddStringToObject(doc, obj, "inn_name", lookup(inn_vals, inn, "Unknown")); + srjson_AddStringToObject( + doc, obj, "inn_name", lookup(inn_vals, inn, "Unknown")); } else { uint8_t ni = data[1] >> 7; uint8_t ap = (data[1] & 0x0C) >> 2; uint8_t si = (data[1] & 0x03); srjson_AddNumberToObject(doc, obj, "ni", ni); - srjson_AddStringToObject(doc, obj, "ni_name", lookup(ni_vals, ni, "Unknown")); + srjson_AddStringToObject( + doc, obj, "ni_name", lookup(ni_vals, ni, "Unknown")); srjson_AddNumberToObject(doc, obj, "restrict", ap); - srjson_AddStringToObject(doc, obj, "restrict_name", lookup(restrict_vals, ap, "Unknown")); + srjson_AddStringToObject(doc, obj, "restrict_name", + lookup(restrict_vals, ap, "Unknown")); srjson_AddNumberToObject(doc, obj, "screened", si); - srjson_AddStringToObject(doc, obj, "screened_name", lookup(screened_vals, si, "Unknown")); + srjson_AddStringToObject(doc, obj, "screened_name", + lookup(screened_vals, si, "Unknown")); } srjson_AddNumberToObject(doc, obj, "ton", data[0] & 0x7F); - srjson_AddStringToObject(doc, obj, "ton_name", lookup(nai_vals, data[0] & 0x7F, "Unknown")); + srjson_AddStringToObject( + doc, obj, "ton_name", lookup(nai_vals, data[0] & 0x7F, "Unknown")); srjson_AddNumberToObject(doc, obj, "npi", (data[1] >> 4) & 0x07); - srjson_AddStringToObject(doc, obj, "npi_name", lookup(npi_vals, (data[1] >> 4) & 0x07, "Unknown")); + srjson_AddStringToObject(doc, obj, "npi_name", + lookup(npi_vals, (data[1] >> 4) & 0x07, "Unknown")); decode_bcd(num, &data[2], len - 2, odd); srjson_AddStringToObject(doc, obj, "num", num); @@ -491,17 +580,21 @@ static void append_e164(srjson_doc_t *doc, const char *name, const uint8_t *data srjson_AddItemToObject(doc, doc->root, name, obj); } -static void append_itu_cause(srjson_doc_t *doc, srjson_t *obj, const uint8_t cause) +static void append_itu_cause( + srjson_doc_t *doc, srjson_t *obj, const uint8_t cause) { /* ignore the "extension bit" */ uint8_t itu_class = (cause & 0x60) >> 5; - srjson_AddStringToObject(doc, obj, "itu_class_name", lookup(itu_cause_class, itu_class, "Unknown")); + srjson_AddStringToObject(doc, obj, "itu_class_name", + lookup(itu_cause_class, itu_class, "Unknown")); srjson_AddNumberToObject(doc, obj, "itu_class_num", itu_class); - srjson_AddStringToObject(doc, obj, "itu_cause_name", lookup(cause_value, cause & 0x7F, "Unknown")); + srjson_AddStringToObject(doc, obj, "itu_cause_name", + lookup(cause_value, cause & 0x7F, "Unknown")); srjson_AddNumberToObject(doc, obj, "itu_cause_num", cause & 0x7F); } -static void append_cause(srjson_doc_t *doc, const char *name, const uint8_t *data, uint8_t len) +static void append_cause( + srjson_doc_t *doc, const char *name, const uint8_t *data, uint8_t len) { uint8_t std_loc; uint8_t cause_val; @@ -509,13 +602,13 @@ static void append_cause(srjson_doc_t *doc, const char *name, const uint8_t *dat int is_itu = 0; srjson_t *obj; - if (len < 2) { + if(len < 2) { LM_ERR("Not enough data for cause\n"); return; } obj = srjson_CreateObject(doc); - if (!obj) { + if(!obj) { LM_ERR("Can not allocate json object for %s\n", name); return; } @@ -533,31 +626,32 @@ static void append_cause(srjson_doc_t *doc, const char *name, const uint8_t *dat srjson_AddNumberToObject(doc, obj, "location_num", (std_loc & 0x0F)); srjson_AddStringToObject(doc, obj, "location_name", loc); - if (is_itu) + if(is_itu) append_itu_cause(doc, obj, cause_val); srjson_AddItemToObject(doc, doc->root, name, obj); } -static void append_event_information(srjson_doc_t *doc, const char *name, const uint8_t *data, uint8_t len) +static void append_event_information( + srjson_doc_t *doc, const char *name, const uint8_t *data, uint8_t len) { const char *event_str; const char *pres_str; srjson_t *obj; - if (len < 1) { + if(len < 1) { LM_ERR("Not enough data for event information\n"); return; } obj = srjson_CreateObject(doc); - if (!obj) { + if(!obj) { LM_ERR("Can not allocate json object for %s\n", name); return; } event_str = lookup(event_info, data[0] & 0x7F, "spare"); - if (data[0] & 0x80) + if(data[0] & 0x80) pres_str = "presentation restricted"; else pres_str = "no indication"; @@ -569,11 +663,12 @@ static void append_event_information(srjson_doc_t *doc, const char *name, const srjson_AddItemToObject(doc, doc->root, name, obj); } -static void append_hop_counter(srjson_doc_t *doc, const char *name, const uint8_t *data, uint8_t len) +static void append_hop_counter( + srjson_doc_t *doc, const char *name, const uint8_t *data, uint8_t len) { uint8_t hop; - if (len < 1) { + if(len < 1) { LM_ERR("Not enough data for hop counter\n"); return; } @@ -582,41 +677,46 @@ static void append_hop_counter(srjson_doc_t *doc, const char *name, const uint8_ srjson_AddNumberToObject(doc, doc->root, name, hop); } -static void append_calling_party_category(srjson_doc_t *doc, const uint8_t *data, uint8_t len) +static void append_calling_party_category( + srjson_doc_t *doc, const uint8_t *data, uint8_t len) { srjson_t *obj; uint8_t cat; - if (len < 1) { + if(len < 1) { LM_ERR("Not enough data for transport medium requirement\n"); return; } obj = srjson_CreateObject(doc); - if (!obj) { - LM_ERR("Can not allocate json object for transport medium requirement\n"); + if(!obj) { + LM_ERR("Can not allocate json object for transport medium " + "requirement\n"); return; } memcpy(&cat, data, 1); srjson_AddNumberToObject(doc, obj, "num", cat); - srjson_AddStringToObject(doc, obj, "name", lookup(calling_cat_vals, cat, "Unknown")); + srjson_AddStringToObject( + doc, obj, "name", lookup(calling_cat_vals, cat, "Unknown")); srjson_AddItemToObject(doc, doc->root, "calling_party", obj); } -static void append_nci(srjson_doc_t *doc, const char *name, const uint8_t *data, uint8_t len) +static void append_nci( + srjson_doc_t *doc, const char *name, const uint8_t *data, uint8_t len) { uint8_t sat, con, ech; srjson_t *obj; - if (len != 1) { - LM_ERR("Unpexected size(%u) for nature of connection indicators\n", len); + if(len != 1) { + LM_ERR("Unpexected size(%u) for nature of connection indicators\n", + len); return; } obj = srjson_CreateObject(doc); - if (!obj) { + if(!obj) { LM_ERR("Can not allocate json object for %s\n", name); return; } @@ -626,89 +726,97 @@ static void append_nci(srjson_doc_t *doc, const char *name, const uint8_t *data, ech = (data[0] & 0x10) >> 4; srjson_AddNumberToObject(doc, obj, "satellite", sat); - srjson_AddStringToObject(doc, obj, "satellite_name", lookup(nci_sat_vals, sat, "Unknown")); + srjson_AddStringToObject( + doc, obj, "satellite_name", lookup(nci_sat_vals, sat, "Unknown")); srjson_AddNumberToObject(doc, obj, "continuity_check", con); - srjson_AddStringToObject(doc, obj, "continuity_check_name", lookup(nci_con_vals, sat, "Unknown")); + srjson_AddStringToObject(doc, obj, "continuity_check_name", + lookup(nci_con_vals, sat, "Unknown")); srjson_AddNumberToObject(doc, obj, "echo_device", ech); - srjson_AddStringToObject(doc, obj, "echo_device_name", lookup(nci_echo_vals, ech, "Unknown")); + srjson_AddStringToObject(doc, obj, "echo_device_name", + lookup(nci_echo_vals, ech, "Unknown")); srjson_AddItemToObject(doc, doc->root, name, obj); } -static void append_forward_call(srjson_doc_t *doc, const char *name, const uint8_t *data, uint8_t len) +static void append_forward_call( + srjson_doc_t *doc, const char *name, const uint8_t *data, uint8_t len) { uint16_t val; srjson_t *obj; size_t i; uint8_t off = 0; - static const struct bit_masks { + static const struct bit_masks + { uint8_t num_bits; const struct key_val *vals; const char *name; const char *bit_names; } bits[] = { - { 1, fwc_nic_vals, "national_international_call", "A" }, - { 2, fwc_etem_vals, "end_to_end_method", "CB" }, - { 1, fwc_iw_vals, "interworking", "D" }, - { 1, fwc_etei_vals, "end_to_end_information", "E" }, - { 1, fwc_isup_vals, "isup", "F" }, - { 2, fwc_isup_pref_vals, "isup_preference", "HG" }, - { 1, fwc_ia_vals, "isdn_access", "I" }, - { 2, fwc_sccpm_vals, "sccp_method", "KJ" }, + {1, fwc_nic_vals, "national_international_call", "A"}, + {2, fwc_etem_vals, "end_to_end_method", "CB"}, + {1, fwc_iw_vals, "interworking", "D"}, + {1, fwc_etei_vals, "end_to_end_information", "E"}, + {1, fwc_isup_vals, "isup", "F"}, + {2, fwc_isup_pref_vals, "isup_preference", "HG"}, + {1, fwc_ia_vals, "isdn_access", "I"}, + {2, fwc_sccpm_vals, "sccp_method", "KJ"}, }; - if (len != 2) { + if(len != 2) { LM_ERR("Unpexected size(%u) for forward call indicators\n", len); return; } obj = srjson_CreateObject(doc); - if (!obj) { + if(!obj) { LM_ERR("Can not allocate json object for %s\n", name); return; } memcpy(&val, data, sizeof(val)); - for (i = 0; i < (sizeof(bits)/sizeof(bits[0])); ++i) { + for(i = 0; i < (sizeof(bits) / sizeof(bits[0])); ++i) { char buf[128]; const struct bit_masks *mask_info = &bits[i]; uint8_t mask = 0, tmp; int b; /* build a mask */ - for (b = 0; b < mask_info->num_bits; ++b) + for(b = 0; b < mask_info->num_bits; ++b) mask = (mask << 1) | 0x01; snprintf(buf, sizeof(buf), "%s_name", mask_info->name); tmp = (val >> off) & mask; srjson_AddNumberToObject(doc, obj, mask_info->name, tmp); - srjson_AddStringToObject(doc, obj, buf, lookup(mask_info->vals, tmp, mask_info->bit_names)); + srjson_AddStringToObject(doc, obj, buf, + lookup(mask_info->vals, tmp, mask_info->bit_names)); off += mask_info->num_bits; } srjson_AddItemToObject(doc, doc->root, name, obj); } -static void append_transmission_medium(srjson_doc_t *doc, const uint8_t *data, const uint8_t len) +static void append_transmission_medium( + srjson_doc_t *doc, const uint8_t *data, const uint8_t len) { srjson_t *obj; - if (len != 1) { + if(len != 1) { LM_ERR("Unpexected size(%u)\n", len); return; } obj = srjson_CreateObject(doc); - if (!obj) { + if(!obj) { LM_ERR("Can not allocate json object\n"); return; } srjson_AddNumberToObject(doc, obj, "num", data[0]); - srjson_AddStringToObject(doc, obj, "name", lookup(trans_medium_vals, data[0], "Unknown")); + srjson_AddStringToObject( + doc, obj, "name", lookup(trans_medium_vals, data[0], "Unknown")); srjson_AddItemToObject(doc, doc->root, "transmission_medium", obj); } @@ -718,7 +826,8 @@ static void append_transmission_medium(srjson_doc_t *doc, const uint8_t *data, c * but for some channels it will be four. Also only ITU caps will * be parsed. */ -static void append_user_information(srjson_doc_t *doc, const uint8_t *data, const uint8_t len) +static void append_user_information( + srjson_doc_t *doc, const uint8_t *data, const uint8_t len) { srjson_t *obj; uint8_t coding_standard, transfer_capability; @@ -727,7 +836,7 @@ static void append_user_information(srjson_doc_t *doc, const uint8_t *data, cons uint8_t octet5; int rate_multiplier = -1; - if (len < 3) { + if(len < 3) { LM_ERR("Insufficient size(%u)\n", len); return; } @@ -737,8 +846,8 @@ static void append_user_information(srjson_doc_t *doc, const uint8_t *data, cons transfer_mode = (data[1] & 0x60) >> 5; transfer_rate = data[1] & 0x1F; - if (transfer_rate == 0x18) { - if (len < 4) { + if(transfer_rate == 0x18) { + if(len < 4) { LM_ERR("Insufficient size(%u) for multirate\n", len); return; } @@ -751,72 +860,77 @@ static void append_user_information(srjson_doc_t *doc, const uint8_t *data, cons layer1_protocol = octet5 & 0x1F; obj = srjson_CreateObject(doc); - if (!obj) { + if(!obj) { LM_ERR("Can not allocate json object\n"); return; } /* numbers first and maybe names if it is ITU */ - srjson_AddStringToObject(doc, obj, "coding_standard_name", lookup(q931_cstd_vals, coding_standard, "Unknown")); + srjson_AddStringToObject(doc, obj, "coding_standard_name", + lookup(q931_cstd_vals, coding_standard, "Unknown")); srjson_AddNumberToObject(doc, obj, "coding_standard", coding_standard); - srjson_AddNumberToObject(doc, obj, "transfer_capability", transfer_capability); + srjson_AddNumberToObject( + doc, obj, "transfer_capability", transfer_capability); srjson_AddNumberToObject(doc, obj, "transfer_mode", transfer_mode); srjson_AddNumberToObject(doc, obj, "transfer_rate", transfer_rate); - if (rate_multiplier >= 0) + if(rate_multiplier >= 0) srjson_AddNumberToObject(doc, obj, "rate_multiplier", rate_multiplier); srjson_AddNumberToObject(doc, obj, "layer1_ident", layer1_ident); srjson_AddNumberToObject(doc, obj, "layer1_protocol", layer1_protocol); /* ITU-T coding values */ - if (coding_standard == 0x00) { + if(coding_standard == 0x00) { srjson_AddStringToObject(doc, obj, "transfer_capability_name", - lookup(q931_trs_cap_vals, transfer_capability, "Unknown")); + lookup(q931_trs_cap_vals, transfer_capability, "Unknown")); srjson_AddStringToObject(doc, obj, "transfer_mode_name", - lookup(q931_trs_mde_vals, transfer_mode, "Unknown")); + lookup(q931_trs_mde_vals, transfer_mode, "Unknown")); srjson_AddStringToObject(doc, obj, "transfer_rate_name", - lookup(q931_trs_rte_vals, transfer_rate, "Unknown")); + lookup(q931_trs_rte_vals, transfer_rate, "Unknown")); srjson_AddStringToObject(doc, obj, "layer1_protocol_name", - lookup(q931_usr_info_vals, layer1_protocol, "Unknown")); + lookup(q931_usr_info_vals, layer1_protocol, "Unknown")); } srjson_AddItemToObject(doc, doc->root, "user_information", obj); } -static void isup_visitor(uint8_t type, const uint8_t *data, uint8_t len, struct isup_state *ptrs) +static void isup_visitor( + uint8_t type, const uint8_t *data, uint8_t len, struct isup_state *ptrs) { - switch (type) { - case ISUPCalledPartyNumber: - append_e164(ptrs->json, "called_number", data, len, ISUPCalledPartyNumber); - break; - case ISUPCallingPartyNumber: - append_e164(ptrs->json, "calling_number", data, len, ISUPCallingPartyNumber); - break; - case ISUPCallingPartysCategory: - append_calling_party_category(ptrs->json, data, len); - break; - case ISUPCauseIndicators: - append_cause(ptrs->json, "cause", data, len); - break; - case ISUPEventInformation: - append_event_information(ptrs->json, "event", data, len); - break; - case ISUPHopCounter: - append_hop_counter(ptrs->json, "hop_counter", data, len); - break; - case ISUPNatureOfConnectionIndicators: - append_nci(ptrs->json, "nature_of_connnection", data, len); - break; - case ISUPForwardCallIndicators: - append_forward_call(ptrs->json, "forward_call", data, len); - break; - case ISUPTransmissionMediumRequirement: - append_transmission_medium(ptrs->json, data, len); - break; - case ISUPUserServiceInformation: - append_user_information(ptrs->json, data, len); - break; + switch(type) { + case ISUPCalledPartyNumber: + append_e164(ptrs->json, "called_number", data, len, + ISUPCalledPartyNumber); + break; + case ISUPCallingPartyNumber: + append_e164(ptrs->json, "calling_number", data, len, + ISUPCallingPartyNumber); + break; + case ISUPCallingPartysCategory: + append_calling_party_category(ptrs->json, data, len); + break; + case ISUPCauseIndicators: + append_cause(ptrs->json, "cause", data, len); + break; + case ISUPEventInformation: + append_event_information(ptrs->json, "event", data, len); + break; + case ISUPHopCounter: + append_hop_counter(ptrs->json, "hop_counter", data, len); + break; + case ISUPNatureOfConnectionIndicators: + append_nci(ptrs->json, "nature_of_connnection", data, len); + break; + case ISUPForwardCallIndicators: + append_forward_call(ptrs->json, "forward_call", data, len); + break; + case ISUPTransmissionMediumRequirement: + append_transmission_medium(ptrs->json, data, len); + break; + case ISUPUserServiceInformation: + append_user_information(ptrs->json, data, len); + break; } } @@ -831,28 +945,31 @@ static uint16_t parse_cic(const uint8_t *data) #endif } -static int do_parse(const uint8_t *data, size_t len, visit visitor, struct isup_state *ptr) +static int do_parse( + const uint8_t *data, size_t len, visit visitor, struct isup_state *ptr) { const struct isup_msg *msg_class; const uint8_t *ptrs; size_t ptrs_size; size_t left; - if (len < 3) { + if(len < 3) { LM_ERR("ISUP message too short %zu\n", len); return -1; } /* extract the basics */ - srjson_AddNumberToObject(ptr->json, ptr->json->root, "cic", parse_cic(data)); + srjson_AddNumberToObject( + ptr->json, ptr->json->root, "cic", parse_cic(data)); srjson_AddNumberToObject(ptr->json, ptr->json->root, "msg_type", data[2]); msg_class = &isup_msgs[data[2]]; - if (!msg_class->name) { + if(!msg_class->name) { LM_ERR("ISUP message not known %d\n", data[2]); return -2; } - srjson_AddStringToObject(ptr->json, ptr->json->root, "msg_name", msg_class->name); + srjson_AddStringToObject( + ptr->json, ptr->json->root, "msg_name", msg_class->name); data += 3; left = len - 3; @@ -862,13 +979,13 @@ static int do_parse(const uint8_t *data, size_t len, visit visitor, struct isup_ * 3.) Variable elements pointed * 4.) Optional ones.. */ - if (msg_class->fixed_ies) { + if(msg_class->fixed_ies) { const struct isup_ie_fixed *fixed = msg_class->fixed_ies; - while (1) { - if (!fixed->name) + while(1) { + if(!fixed->name) break; - if (left < fixed->len) { + if(left < fixed->len) { LM_ERR("ISUP fixed too short %zu vs. %un", left, fixed->len); return -3; } @@ -889,34 +1006,36 @@ static int do_parse(const uint8_t *data, size_t len, visit visitor, struct isup_ /* consume variables */ - if (msg_class->variable_ies) { + if(msg_class->variable_ies) { const struct isup_ie_variable *variable = msg_class->variable_ies; - while (1) { + while(1) { const uint8_t *ie_data; size_t ie_left; uint8_t ie_len; - if (!variable->name) + if(!variable->name) break; - if (ptrs_size < 1) { + if(ptrs_size < 1) { LM_ERR("ISUP no space for ptr %zu\n", ptrs_size); return -1; } ie_left = ptrs_size; ie_data = ptrs; - if (ie_left < ie_data[0]) { - LM_ERR("ISUP no space for len %zu vs. %u\n", ie_left, ie_data[0]); + if(ie_left < ie_data[0]) { + LM_ERR("ISUP no space for len %zu vs. %u\n", ie_left, + ie_data[0]); return -1; } ie_left -= ie_data[0]; ie_data += ie_data[0]; ie_len = ie_data[0]; - if (ie_left < ie_len + 1) { - LM_ERR("ISUP no space for data %zu vs. %u\n", ie_left, ie_len + 1); + if(ie_left < ie_len + 1) { + LM_ERR("ISUP no space for data %zu vs. %u\n", ie_left, + ie_len + 1); return -1; } @@ -929,32 +1048,33 @@ static int do_parse(const uint8_t *data, size_t len, visit visitor, struct isup_ } } - if (msg_class->has_optional) { + if(msg_class->has_optional) { size_t opt_left = ptrs_size; const uint8_t *opt_data = ptrs; - if (opt_left < 1) { + if(opt_left < 1) { LM_ERR("ISUP no space for optional ptr\n"); return -1; } - if (opt_left < opt_data[0]) { - LM_ERR("ISUP optional beyond msg %zu vs. %u\n", opt_left, opt_data[0]); + if(opt_left < opt_data[0]) { + LM_ERR("ISUP optional beyond msg %zu vs. %u\n", opt_left, + opt_data[0]); return -1; } opt_left -= opt_data[0]; opt_data += opt_data[0]; - while (opt_left > 0) { + while(opt_left > 0) { uint8_t ie = opt_data[0]; size_t len; opt_data += 1; opt_left -= 1; - if (ie == ISUPEndOfOptionalParameters) + if(ie == ISUPEndOfOptionalParameters) break; - if (opt_left < 1) { + if(opt_left < 1) { LM_ERR("ISUP no space for len %zu\n", opt_left); return -1; } @@ -962,8 +1082,9 @@ static int do_parse(const uint8_t *data, size_t len, visit visitor, struct isup_ opt_left -= 1; opt_data += 1; - if (opt_left < len) { - LM_ERR("ISUP no space optional data %zu vs. %zu\n", opt_left, len); + if(opt_left < len) { + LM_ERR("ISUP no space optional data %zu vs. %zu\n", opt_left, + len); return -1; } diff --git a/src/modules/ss7ops/isup_parsed.h b/src/modules/ss7ops/isup_parsed.h index c48d65fc4ba..198365576b7 100644 --- a/src/modules/ss7ops/isup_parsed.h +++ b/src/modules/ss7ops/isup_parsed.h @@ -30,11 +30,13 @@ /** * State structure */ -struct isup_state { - srjson_doc_t* json; +struct isup_state +{ + srjson_doc_t *json; }; -enum { +enum +{ ISUP_JSON_STRING, ISUP_FIELD_METHOD, ISUP_FIELD_OPC, diff --git a/src/modules/ss7ops/ss7ops_mod.c b/src/modules/ss7ops/ss7ops_mod.c index f53f48626cb..b0f84694658 100644 --- a/src/modules/ss7ops/ss7ops_mod.c +++ b/src/modules/ss7ops/ss7ops_mod.c @@ -29,36 +29,29 @@ MODULE_VERSION /* hep defines */ -#define HEP_M2UA 0x08 -#define HEP_M2PA 0x0d +#define HEP_M2UA 0x08 +#define HEP_M2PA 0x0d /* M2UA messages */ -#define M2UA_MSG 6 -#define M2UA_DATA 1 -#define M2UA_IE_DATA 0x0300 +#define M2UA_MSG 6 +#define M2UA_DATA 1 +#define M2UA_IE_DATA 0x0300 /* M2PA messages */ -#define M2PA_CLASS 11 -#define M2PA_DATA 1 +#define M2PA_CLASS 11 +#define M2PA_DATA 1 /* MTPl3 */ -#define MTP_ISUP 0x05 +#define MTP_ISUP 0x05 -struct mtp_level_3_hdr { +struct mtp_level_3_hdr +{ #ifdef __IS_LITTLE_ENDIAN - uint8_t ser_ind : 4, - spare : 2, - ni : 2; - uint32_t dpc : 14, - opc : 14, - sls : 4; + uint8_t ser_ind : 4, spare : 2, ni : 2; + uint32_t dpc : 14, opc : 14, sls : 4; #else /* ignore middle endian */ - uint8_t ni : 2, - spare : 2, - ser_ind : 4; - uint32_t sls : 4, - opc : 14, - dpc : 14; + uint8_t ni : 2, spare : 2, ser_ind : 4; + uint32_t sls : 4, opc : 14, dpc : 14; #endif uint8_t data[0]; } __attribute__((packed)); @@ -70,20 +63,18 @@ struct mtp_level_3_hdr { static const char *isup_last = NULL; static srjson_doc_t *isup_json = NULL; -static int w_isup_to_json(struct sip_msg* _m, char* param1, char* param2); +static int w_isup_to_json(struct sip_msg *_m, char *param1, char *param2); static int pv_get_isup(struct sip_msg *msg, pv_param_t *param, pv_value_t *res); static int pv_parse_isup_name(pv_spec_p sp, str *in); static cmd_export_t cmds[] = { - {"isup_to_json", (cmd_function)w_isup_to_json, 1, 0, 0, ANY_ROUTE}, - {0, 0, 0, 0, 0, 0} -}; + {"isup_to_json", (cmd_function)w_isup_to_json, 1, 0, 0, ANY_ROUTE}, + {0, 0, 0, 0, 0, 0}}; static pv_export_t mod_pvs[] = { - { {"isup", sizeof("isup")-1}, PVT_OTHER, pv_get_isup, - 0, pv_parse_isup_name, 0, 0, 0 }, - { {0, 0}, 0, 0, 0, 0, 0, 0, 0 } -}; + {{"isup", sizeof("isup") - 1}, PVT_OTHER, pv_get_isup, 0, + pv_parse_isup_name, 0, 0, 0}, + {{0, 0}, 0, 0, 0, 0, 0, 0, 0}}; static int mod_init(void) { @@ -97,41 +88,41 @@ static void destroy(void) } struct module_exports exports = { - "ss7", /*!< module name */ - DEFAULT_DLFLAGS, /*!< dlopen flags */ - cmds, /*!< exported functions */ - 0, /*!< exported parameters */ - 0, /*!< exported rpc functions */ - mod_pvs, /*!< exported pseudo-variables */ - 0, /*!< response handling function */ - mod_init, /*!< module init function */ - 0, /*!< child init function */ - destroy /*!< module destroy function */ + "ss7", /*!< module name */ + DEFAULT_DLFLAGS, /*!< dlopen flags */ + cmds, /*!< exported functions */ + 0, /*!< exported parameters */ + 0, /*!< exported rpc functions */ + mod_pvs, /*!< exported pseudo-variables */ + 0, /*!< response handling function */ + mod_init, /*!< module init function */ + 0, /*!< child init function */ + destroy /*!< module destroy function */ }; static const uint8_t *extract_from_m2ua(const uint8_t *data, size_t *len) { uint32_t data_len; - if (*len <= 8) { + if(*len <= 8) { LM_ERR("M2UA hdr too short %zu\n", *len); return NULL; } /* check the header */ - if (data[0] != 0x01) { + if(data[0] != 0x01) { LM_ERR("M2UA unknown version number %d\n", data[0]); return NULL; } - if (data[1] != 0x00) { + if(data[1] != 0x00) { LM_ERR("M2UA unknown reserved fields %d\n", data[1]); return NULL; } - if (data[2] != M2UA_MSG) { + if(data[2] != M2UA_MSG) { LM_ERR("M2UA unhandled message class %d\n", data[2]); return NULL; } - if (data[3] != M2UA_DATA) { + if(data[3] != M2UA_DATA) { LM_ERR("M2UA not data msg but %d\n", data[3]); return NULL; } @@ -139,7 +130,7 @@ static const uint8_t *extract_from_m2ua(const uint8_t *data, size_t *len) /* check the length */ memcpy(&data_len, &data[4], sizeof(data_len)); data_len = ntohl(data_len); - if (*len < data_len) { + if(*len < data_len) { LM_ERR("M2UA data can't fit %zu vs. %zu\n", *len, (size_t)data_len); return NULL; } @@ -147,31 +138,31 @@ static const uint8_t *extract_from_m2ua(const uint8_t *data, size_t *len) /* skip the header */ data += 8; data_len -= 8; - while (data_len > 4) { + while(data_len > 4) { uint16_t ie_tag, ie_len, padding; memcpy(&ie_tag, &data[0], sizeof(ie_tag)); memcpy(&ie_len, &data[2], sizeof(ie_len)); ie_tag = ntohs(ie_tag); ie_len = ntohs(ie_len); - if (ie_len > data_len) { + if(ie_len > data_len) { LM_ERR("M2UA premature end %u vs. %zu\n", ie_len, (size_t)data_len); return NULL; } - if (ie_tag != M2UA_IE_DATA) + if(ie_tag != M2UA_IE_DATA) goto next; *len = ie_len - 4; return &data[4]; -next: + next: data += ie_len; data_len -= ie_len; /* and now padding... */ - padding = (4 - (ie_len % 4)) & 0x3; - if (data_len < padding) { + padding = (4 - (ie_len % 4)) & 0x3; + if(data_len < padding) { LM_ERR("M2UA no place for padding %u vs. %zu\n", padding, (size_t)data_len); return NULL; @@ -188,25 +179,25 @@ static const uint8_t *extract_from_m2pa(const uint8_t *data, size_t *len) { uint32_t data_len; - if (*len < 8) { + if(*len < 8) { LM_ERR("M2PA hdr too short %zu\n", *len); return NULL; } /* check the header */ - if (data[0] != 0x01) { + if(data[0] != 0x01) { LM_ERR("M2PA unknown version number %d\n", data[0]); return NULL; } - if (data[1] != 0x00) { + if(data[1] != 0x00) { LM_ERR("M2PA unknown reserved fields %d\n", data[1]); return NULL; } - if (data[2] != M2PA_CLASS) { + if(data[2] != M2PA_CLASS) { LM_ERR("M2PA unhandled message class %d\n", data[2]); return NULL; } - if (data[3] != M2PA_DATA) { + if(data[3] != M2PA_DATA) { LM_ERR("M2PA not data msg but %d\n", data[3]); return NULL; } @@ -214,7 +205,7 @@ static const uint8_t *extract_from_m2pa(const uint8_t *data, size_t *len) /* check the length */ memcpy(&data_len, &data[4], sizeof(data_len)); data_len = ntohl(data_len); - if (*len < data_len) { + if(*len < data_len) { LM_ERR("M2PA data can't fit %zu vs. %u\n", *len, data_len); return NULL; } @@ -224,15 +215,15 @@ static const uint8_t *extract_from_m2pa(const uint8_t *data, size_t *len) data_len -= 8; /* BSN, FSN and then priority */ - if (data_len < 8) { + if(data_len < 8) { LM_ERR("M2PA no space for BSN/FSN %u\n", data_len); return NULL; } data += 8; data_len -= 8; - if (data_len == 0) + if(data_len == 0) return NULL; - else if (data_len < 1) { + else if(data_len < 1) { LM_ERR("M2PA no space for prio %u\n", data_len); return NULL; } @@ -243,23 +234,23 @@ static const uint8_t *extract_from_m2pa(const uint8_t *data, size_t *len) return data; } -static const uint8_t *extract_from_mtp(const uint8_t *data, size_t *len, - int *opc, int *dpc, int *type) +static const uint8_t *extract_from_mtp( + const uint8_t *data, size_t *len, int *opc, int *dpc, int *type) { struct mtp_level_3_hdr *hdr; *opc = INT_MAX; *dpc = INT_MAX; - if (!data) + if(!data) return NULL; - if (*len < sizeof(*hdr)) { + if(*len < sizeof(*hdr)) { LM_ERR("MTP not enough space for mtp hdr %zu vs. %zu", *len, sizeof(*hdr)); return NULL; } - hdr = (struct mtp_level_3_hdr *) data; + hdr = (struct mtp_level_3_hdr *)data; *opc = hdr->opc; *dpc = hdr->dpc; *type = hdr->ser_ind; @@ -271,17 +262,17 @@ static const uint8_t *extract_from_mtp(const uint8_t *data, size_t *len, static const uint8_t *ss7_extract_payload(const uint8_t *data, size_t *len, int proto, int *opc, int *dpc, int *mtp_type) { - switch (proto) { - case HEP_M2UA: - return extract_from_mtp(extract_from_m2ua(data, len), len, opc, - dpc, mtp_type); - break; - case HEP_M2PA: - return extract_from_mtp(extract_from_m2pa(data, len), len, opc, - dpc, mtp_type); - default: - LM_ERR("Unknown HEP type %d/0x%c\n", proto, proto); - return NULL; + switch(proto) { + case HEP_M2UA: + return extract_from_mtp( + extract_from_m2ua(data, len), len, opc, dpc, mtp_type); + break; + case HEP_M2PA: + return extract_from_mtp( + extract_from_m2pa(data, len), len, opc, dpc, mtp_type); + default: + LM_ERR("Unknown HEP type %d/0x%c\n", proto, proto); + return NULL; } } @@ -295,73 +286,77 @@ static uint8_t *fetch_payload(struct sip_msg *_m, char *pname, int *len) s.s = pname; s.len = strlen(pname); pv = pv_cache_get(&s); - if (!pv) { + if(!pv) { LM_ERR("Can't get %s\n", s.s); return NULL; } rc = pv->getf(_m, &pv->pvp, &pt); - if (rc < 0) { + if(rc < 0) { LM_ERR("Can't getf rc=%d\n", rc); return NULL; } *len = pt.rs.len; - return (uint8_t *) pt.rs.s; + return (uint8_t *)pt.rs.s; } static int ki_isup_to_json(sip_msg_t *_m, int proto) { - struct isup_state isup_state = { 0, }; + struct isup_state isup_state = { + 0, + }; const uint8_t *data; int opc, dpc, mtp_type, int_len, rc; size_t len; - free((char *) isup_last); + free((char *)isup_last); srjson_DeleteDoc(isup_json); isup_last = NULL; isup_json = NULL; mtp_type = 0; data = fetch_payload(_m, "$var(payload)", &int_len); - if (!data) + if(!data) return -1; - if (int_len < 0) { + if(int_len < 0) { LM_ERR("Payload length low %d\n", int_len); return -1; } len = int_len; data = ss7_extract_payload(data, &len, proto, &opc, &dpc, &mtp_type); - if (!data) + if(!data) return -1; - if (mtp_type != MTP_ISUP) { + if(mtp_type != MTP_ISUP) { LM_DBG("Non ISUP payload %d\n", mtp_type); return -1; } /* parse isup... */ isup_state.json = srjson_NewDoc(NULL); - if (!isup_state.json) { + if(!isup_state.json) { LM_ERR("Failed to allocate JSON document\n"); return -1; } isup_state.json->root = srjson_CreateObject(isup_state.json); - if (!isup_state.json->root) { + if(!isup_state.json->root) { LM_ERR("Failed to allocate JSON object\n"); srjson_DeleteDoc(isup_state.json); return -1; } rc = isup_parse(data, len, &isup_state); - if (rc != 0) { + if(rc != 0) { srjson_DeleteDoc(isup_state.json); return rc; } - srjson_AddNumberToObject(isup_state.json, isup_state.json->root, "opc", opc); - srjson_AddNumberToObject(isup_state.json, isup_state.json->root, "dpc", dpc); + srjson_AddNumberToObject( + isup_state.json, isup_state.json->root, "opc", opc); + srjson_AddNumberToObject( + isup_state.json, isup_state.json->root, "dpc", dpc); isup_last = srjson_PrintUnformatted(isup_state.json, isup_state.json->root); isup_json = isup_state.json; return 1; @@ -369,309 +364,345 @@ static int ki_isup_to_json(sip_msg_t *_m, int proto) static int w_isup_to_json(struct sip_msg *_m, char *param1, char *param2) { - return ki_isup_to_json(_m, atoi(param1)); + return ki_isup_to_json(_m, atoi(param1)); } -#define UINT_OR_NULL(msg, param, res, node) \ - node ? pv_get_uintval(msg, param, res, node->valuedouble) : pv_get_null(msg, param, res) - -#define STR_OR_NULL(msg, param, res, tmpstr, node, out_res) \ - if (node && node->type == srjson_String) { \ - tmpstr.s = node->valuestring; \ - tmpstr.len = strlen(tmpstr.s); \ - out_res = pv_get_strval(msg, param, res, &tmpstr); \ - } else { \ - out_res = pv_get_null(msg, param, res); \ +#define UINT_OR_NULL(msg, param, res, node) \ + node ? pv_get_uintval(msg, param, res, node->valuedouble) \ + : pv_get_null(msg, param, res) + +#define STR_OR_NULL(msg, param, res, tmpstr, node, out_res) \ + if(node && node->type == srjson_String) { \ + tmpstr.s = node->valuestring; \ + tmpstr.len = strlen(tmpstr.s); \ + out_res = pv_get_strval(msg, param, res, &tmpstr); \ + } else { \ + out_res = pv_get_null(msg, param, res); \ } static int pv_get_isup(struct sip_msg *msg, pv_param_t *param, pv_value_t *res) { srjson_t *node; - str tmpstr = { 0, }; + str tmpstr = { + 0, + }; int out_res; - if (!param) + if(!param) return -1; - if (!isup_last) + if(!isup_last) return -1; - if (!isup_json) + if(!isup_json) return -1; - switch (param->pvn.u.isname.name.n) { - case ISUP_JSON_STRING: - tmpstr.s = (char *) isup_last; - tmpstr.len = strlen(isup_last); - return pv_get_strval(msg, param, res, &tmpstr); - case ISUP_FIELD_METHOD: - node = srjson_GetObjectItem(isup_json, isup_json->root, "msg_name"); - STR_OR_NULL(msg, param, res, tmpstr, node, out_res); - return out_res; - case ISUP_FIELD_OPC: - node = srjson_GetObjectItem(isup_json, isup_json->root, "opc"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_DPC: - node = srjson_GetObjectItem(isup_json, isup_json->root, "dpc"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_CIC: - node = srjson_GetObjectItem(isup_json, isup_json->root, "cic"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_CALLED_INN: - node = srjson_GetObjectItem(isup_json, isup_json->root, "called_number"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "inn"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_CALLED_TON: - node = srjson_GetObjectItem(isup_json, isup_json->root, "called_number"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "ton"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_CALLED_NPI: - node = srjson_GetObjectItem(isup_json, isup_json->root, "called_number"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "npi"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_CALLED_NUM: - node = srjson_GetObjectItem(isup_json, isup_json->root, "called_number"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "num"); - STR_OR_NULL(msg, param, res, tmpstr, node, out_res); - return out_res; - case ISUP_FIELD_CALLING_NI: - node = srjson_GetObjectItem(isup_json, isup_json->root, "calling_number"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "ni"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_CALLING_RESTRICT: - node = srjson_GetObjectItem(isup_json, isup_json->root, "calling_number"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "restrict"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_CALLING_SCREENED: - node = srjson_GetObjectItem(isup_json, isup_json->root, "calling_number"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "screened"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_CALLING_TON: - node = srjson_GetObjectItem(isup_json, isup_json->root, "calling_number"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "ton"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_CALLING_NPI: - node = srjson_GetObjectItem(isup_json, isup_json->root, "calling_number"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "npi"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_CALLING_NUM: - node = srjson_GetObjectItem(isup_json, isup_json->root, "calling_number"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "num"); - STR_OR_NULL(msg, param, res, tmpstr, node, out_res); - return out_res; - case ISUP_FIELD_CALLING_CAT: - node = srjson_GetObjectItem(isup_json, isup_json->root, "calling_party"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "num"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_CAUSE_STD: - node = srjson_GetObjectItem(isup_json, isup_json->root, "cause"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "standard_num"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_CAUSE_LOC: - node = srjson_GetObjectItem(isup_json, isup_json->root, "cause"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "location_num"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_CAUSE_ITU_CLASS: - node = srjson_GetObjectItem(isup_json, isup_json->root, "cause"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "itu_class_num"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_CAUSE_ITU_NUM: - node = srjson_GetObjectItem(isup_json, isup_json->root, "cause"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "itu_cause_num"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_EVENT_NUM: - node = srjson_GetObjectItem(isup_json, isup_json->root, "event"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "event_num"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_HOP_COUNTER: - node = srjson_GetObjectItem(isup_json, isup_json->root, "hop_counter"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_NOC_SAT: - node = srjson_GetObjectItem(isup_json, isup_json->root, "nature_of_connnection"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "satellite"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_NOC_CHECK: - node = srjson_GetObjectItem(isup_json, isup_json->root, "nature_of_connnection"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "continuity_check"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_NOC_ECHO: - node = srjson_GetObjectItem(isup_json, isup_json->root, "nature_of_connnection"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "echo_device"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_FWD_INTE: - node = srjson_GetObjectItem(isup_json, isup_json->root, "forward_call"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "national_international_call"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_FWD_INTW: - node = srjson_GetObjectItem(isup_json, isup_json->root, "forward_call"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "interworking"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_FWD_EE_METH: - node = srjson_GetObjectItem(isup_json, isup_json->root, "forward_call"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "end_to_end_method"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_FWD_EE_INF: - node = srjson_GetObjectItem(isup_json, isup_json->root, "forward_call"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "end_to_end_information"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_FWD_ISUP_NUM: - node = srjson_GetObjectItem(isup_json, isup_json->root, "forward_call"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "isup"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_FWD_ISUP_PREF: - node = srjson_GetObjectItem(isup_json, isup_json->root, "forward_call"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "isup_preference"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_FWD_ISDN: - node = srjson_GetObjectItem(isup_json, isup_json->root, "forward_call"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "isdn_access"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_FWD_SCCP_METHOD: - node = srjson_GetObjectItem(isup_json, isup_json->root, "forward_call"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "sccp_method"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_MEDIUM: - node = srjson_GetObjectItem(isup_json, isup_json->root, "transmission_medium"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "num"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FILED_UI_CODING: - node = srjson_GetObjectItem(isup_json, isup_json->root, "user_information"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "coding_standard"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_UI_TRANS_CAP: - node = srjson_GetObjectItem(isup_json, isup_json->root, "user_information"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "transfer_capability"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_UI_TRANS_MODE: - node = srjson_GetObjectItem(isup_json, isup_json->root, "user_information"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "transfer_mode"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_UI_TRANS_RATE: - node = srjson_GetObjectItem(isup_json, isup_json->root, "user_information"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "transfer_rate"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_UI_LAYER1_IDENT: - node = srjson_GetObjectItem(isup_json, isup_json->root, "user_information"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "layer1_ident"); - return UINT_OR_NULL(msg, param, res, node); - case ISUP_FIELD_UI_LAYER1_PROTOCOL: - node = srjson_GetObjectItem(isup_json, isup_json->root, "user_information"); - if (!node) - return pv_get_null(msg, param, res); - node = srjson_GetObjectItem(isup_json, node, "layer1_protocol"); - return UINT_OR_NULL(msg, param, res, node); + switch(param->pvn.u.isname.name.n) { + case ISUP_JSON_STRING: + tmpstr.s = (char *)isup_last; + tmpstr.len = strlen(isup_last); + return pv_get_strval(msg, param, res, &tmpstr); + case ISUP_FIELD_METHOD: + node = srjson_GetObjectItem(isup_json, isup_json->root, "msg_name"); + STR_OR_NULL(msg, param, res, tmpstr, node, out_res); + return out_res; + case ISUP_FIELD_OPC: + node = srjson_GetObjectItem(isup_json, isup_json->root, "opc"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_DPC: + node = srjson_GetObjectItem(isup_json, isup_json->root, "dpc"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_CIC: + node = srjson_GetObjectItem(isup_json, isup_json->root, "cic"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_CALLED_INN: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "called_number"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "inn"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_CALLED_TON: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "called_number"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "ton"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_CALLED_NPI: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "called_number"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "npi"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_CALLED_NUM: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "called_number"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "num"); + STR_OR_NULL(msg, param, res, tmpstr, node, out_res); + return out_res; + case ISUP_FIELD_CALLING_NI: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "calling_number"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "ni"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_CALLING_RESTRICT: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "calling_number"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "restrict"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_CALLING_SCREENED: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "calling_number"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "screened"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_CALLING_TON: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "calling_number"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "ton"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_CALLING_NPI: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "calling_number"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "npi"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_CALLING_NUM: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "calling_number"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "num"); + STR_OR_NULL(msg, param, res, tmpstr, node, out_res); + return out_res; + case ISUP_FIELD_CALLING_CAT: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "calling_party"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "num"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_CAUSE_STD: + node = srjson_GetObjectItem(isup_json, isup_json->root, "cause"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "standard_num"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_CAUSE_LOC: + node = srjson_GetObjectItem(isup_json, isup_json->root, "cause"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "location_num"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_CAUSE_ITU_CLASS: + node = srjson_GetObjectItem(isup_json, isup_json->root, "cause"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "itu_class_num"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_CAUSE_ITU_NUM: + node = srjson_GetObjectItem(isup_json, isup_json->root, "cause"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "itu_cause_num"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_EVENT_NUM: + node = srjson_GetObjectItem(isup_json, isup_json->root, "event"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "event_num"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_HOP_COUNTER: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "hop_counter"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_NOC_SAT: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "nature_of_connnection"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "satellite"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_NOC_CHECK: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "nature_of_connnection"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "continuity_check"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_NOC_ECHO: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "nature_of_connnection"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "echo_device"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_FWD_INTE: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "forward_call"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem( + isup_json, node, "national_international_call"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_FWD_INTW: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "forward_call"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "interworking"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_FWD_EE_METH: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "forward_call"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "end_to_end_method"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_FWD_EE_INF: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "forward_call"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem( + isup_json, node, "end_to_end_information"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_FWD_ISUP_NUM: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "forward_call"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "isup"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_FWD_ISUP_PREF: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "forward_call"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "isup_preference"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_FWD_ISDN: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "forward_call"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "isdn_access"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_FWD_SCCP_METHOD: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "forward_call"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "sccp_method"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_MEDIUM: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "transmission_medium"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "num"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FILED_UI_CODING: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "user_information"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "coding_standard"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_UI_TRANS_CAP: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "user_information"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "transfer_capability"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_UI_TRANS_MODE: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "user_information"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "transfer_mode"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_UI_TRANS_RATE: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "user_information"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "transfer_rate"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_UI_LAYER1_IDENT: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "user_information"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "layer1_ident"); + return UINT_OR_NULL(msg, param, res, node); + case ISUP_FIELD_UI_LAYER1_PROTOCOL: + node = srjson_GetObjectItem( + isup_json, isup_json->root, "user_information"); + if(!node) + return pv_get_null(msg, param, res); + node = srjson_GetObjectItem(isup_json, node, "layer1_protocol"); + return UINT_OR_NULL(msg, param, res, node); } return -1; } -static const struct { +static const struct +{ const char *name; int index; } pv_isup_names[] = { - { "method", ISUP_FIELD_METHOD }, - { "opc", ISUP_FIELD_OPC }, - { "dpc", ISUP_FIELD_DPC }, - { "cic", ISUP_FIELD_CIC }, - { "called_inn", ISUP_FIELD_CALLED_INN }, - { "called_ton", ISUP_FIELD_CALLED_TON }, - { "called_npi", ISUP_FIELD_CALLED_NPI }, - { "called_num", ISUP_FIELD_CALLED_NUM }, - { "calling_ni", ISUP_FIELD_CALLING_NI }, - { "calling_restrict", ISUP_FIELD_CALLING_RESTRICT }, - { "calling_screened", ISUP_FIELD_CALLING_SCREENED }, - { "calling_ton", ISUP_FIELD_CALLING_TON }, - { "calling_npi", ISUP_FIELD_CALLING_NPI }, - { "calling_num", ISUP_FIELD_CALLING_NUM }, - { "calling_category", ISUP_FIELD_CALLING_CAT }, - { "cause_standard", ISUP_FIELD_CAUSE_STD }, - { "cause_location", ISUP_FIELD_CAUSE_LOC }, - { "cause_itu_class", ISUP_FIELD_CAUSE_ITU_CLASS }, - { "cause_itu_num", ISUP_FIELD_CAUSE_ITU_NUM }, - { "event_num", ISUP_FIELD_EVENT_NUM }, - { "hop_counter", ISUP_FIELD_HOP_COUNTER }, - { "nature_of_conn_sat", ISUP_FIELD_NOC_SAT }, - { "nature_of_conn_con_check", ISUP_FIELD_NOC_CHECK }, - { "nature_of_conn_echo_device", ISUP_FIELD_NOC_ECHO }, - { "fwd_call_international", ISUP_FIELD_FWD_INTE }, - { "fwd_call_interworking", ISUP_FIELD_FWD_INTW }, - { "fwd_call_end_to_end_method", ISUP_FIELD_FWD_EE_METH }, - { "fwd_call_end_to_end_information", ISUP_FIELD_FWD_EE_INF }, - { "fwd_call_isup", ISUP_FIELD_FWD_ISUP_NUM }, - { "fwd_call_isup_preference", ISUP_FIELD_FWD_ISUP_PREF }, - { "fwd_call_sccp_method", ISUP_FIELD_FWD_SCCP_METHOD }, - { "fwd_call_isdn", ISUP_FIELD_FWD_ISDN }, - { "transmission_medium", ISUP_FIELD_MEDIUM }, - { "user_info_coding_standard", ISUP_FILED_UI_CODING }, - { "user_info_transfer_cap", ISUP_FIELD_UI_TRANS_CAP }, - { "user_info_transfer_mode", ISUP_FIELD_UI_TRANS_MODE }, - { "user_info_transfer_rate", ISUP_FIELD_UI_TRANS_RATE }, - { "user_info_layer1_ident", ISUP_FIELD_UI_LAYER1_IDENT }, - { "user_info_layer1_protocol", ISUP_FIELD_UI_LAYER1_PROTOCOL }, + {"method", ISUP_FIELD_METHOD}, + {"opc", ISUP_FIELD_OPC}, + {"dpc", ISUP_FIELD_DPC}, + {"cic", ISUP_FIELD_CIC}, + {"called_inn", ISUP_FIELD_CALLED_INN}, + {"called_ton", ISUP_FIELD_CALLED_TON}, + {"called_npi", ISUP_FIELD_CALLED_NPI}, + {"called_num", ISUP_FIELD_CALLED_NUM}, + {"calling_ni", ISUP_FIELD_CALLING_NI}, + {"calling_restrict", ISUP_FIELD_CALLING_RESTRICT}, + {"calling_screened", ISUP_FIELD_CALLING_SCREENED}, + {"calling_ton", ISUP_FIELD_CALLING_TON}, + {"calling_npi", ISUP_FIELD_CALLING_NPI}, + {"calling_num", ISUP_FIELD_CALLING_NUM}, + {"calling_category", ISUP_FIELD_CALLING_CAT}, + {"cause_standard", ISUP_FIELD_CAUSE_STD}, + {"cause_location", ISUP_FIELD_CAUSE_LOC}, + {"cause_itu_class", ISUP_FIELD_CAUSE_ITU_CLASS}, + {"cause_itu_num", ISUP_FIELD_CAUSE_ITU_NUM}, + {"event_num", ISUP_FIELD_EVENT_NUM}, + {"hop_counter", ISUP_FIELD_HOP_COUNTER}, + {"nature_of_conn_sat", ISUP_FIELD_NOC_SAT}, + {"nature_of_conn_con_check", ISUP_FIELD_NOC_CHECK}, + {"nature_of_conn_echo_device", ISUP_FIELD_NOC_ECHO}, + {"fwd_call_international", ISUP_FIELD_FWD_INTE}, + {"fwd_call_interworking", ISUP_FIELD_FWD_INTW}, + {"fwd_call_end_to_end_method", ISUP_FIELD_FWD_EE_METH}, + {"fwd_call_end_to_end_information", ISUP_FIELD_FWD_EE_INF}, + {"fwd_call_isup", ISUP_FIELD_FWD_ISUP_NUM}, + {"fwd_call_isup_preference", ISUP_FIELD_FWD_ISUP_PREF}, + {"fwd_call_sccp_method", ISUP_FIELD_FWD_SCCP_METHOD}, + {"fwd_call_isdn", ISUP_FIELD_FWD_ISDN}, + {"transmission_medium", ISUP_FIELD_MEDIUM}, + {"user_info_coding_standard", ISUP_FILED_UI_CODING}, + {"user_info_transfer_cap", ISUP_FIELD_UI_TRANS_CAP}, + {"user_info_transfer_mode", ISUP_FIELD_UI_TRANS_MODE}, + {"user_info_transfer_rate", ISUP_FIELD_UI_TRANS_RATE}, + {"user_info_layer1_ident", ISUP_FIELD_UI_LAYER1_IDENT}, + {"user_info_layer1_protocol", ISUP_FIELD_UI_LAYER1_PROTOCOL}, }; static int pv_parse_isup_name(pv_spec_p sp, str *in) @@ -679,14 +710,14 @@ static int pv_parse_isup_name(pv_spec_p sp, str *in) size_t i; unsigned int input, name_n; - if(sp==NULL || in==NULL || in->len<=0) + if(sp == NULL || in == NULL || in->len <= 0) return -1; /* check strings */ - for (i = 0; i < (sizeof(pv_isup_names)/sizeof(pv_isup_names[0])); ++i) { - if (strlen(pv_isup_names[i].name) != in->len) + for(i = 0; i < (sizeof(pv_isup_names) / sizeof(pv_isup_names[0])); ++i) { + if(strlen(pv_isup_names[i].name) != in->len) continue; - if (strncmp(in->s, pv_isup_names[i].name, in->len) != 0) + if(strncmp(in->s, pv_isup_names[i].name, in->len) != 0) continue; sp->pvp.pvn.type = PV_NAME_INTSTR; @@ -695,16 +726,16 @@ static int pv_parse_isup_name(pv_spec_p sp, str *in) return 0; } - if (str2int(in, &input) < 0) + if(str2int(in, &input) < 0) goto error; - switch (input) { - case 1: - /* all valid input */ - name_n = ISUP_JSON_STRING; - break; - default: - goto error; + switch(input) { + case 1: + /* all valid input */ + name_n = ISUP_JSON_STRING; + break; + default: + goto error; } sp->pvp.pvn.type = PV_NAME_INTSTR;