diff --git a/libs/freetdm/src/isdn/5ESSStateNT.c b/libs/freetdm/src/isdn/5ESSStateNT.c index d2a5540c32..1eb9415422 100644 --- a/libs/freetdm/src/isdn/5ESSStateNT.c +++ b/libs/freetdm/src/isdn/5ESSStateNT.c @@ -4,11 +4,11 @@ Contents: AT&T 5ESS ISDN State Engine for NT (Network Mode). - The controlling state engine for Q.931 is the state engine - on the NT side. The state engine on the TE side is a slave - of this. The TE side maintain it's own states as described in - ITU-T Q931, but will in raise conditions be overridden by - the NT side. + The controlling state engine for Q.931 is the state engine + on the NT side. The state engine on the TE side is a slave + of this. The TE side maintain it's own states as described in + ITU-T Q931, but will in raise conditions be overridden by + the NT side. License/Copyright: @@ -25,14 +25,14 @@ modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Case Labs, Ltd nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the Case Labs, Ltd nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -53,80 +53,80 @@ Function: ATT5ESSCreateNT Description: Will create the AT&T 5ESS ISDN NT as a Dialect in the stack. The first - bulk set up the message handlers, the second bulk the IE - encoders/coders, and the last bulk set up the state table. + bulk set up the message handlers, the second bulk the IE + encoders/coders, and the last bulk set up the state table. Parameters: i Dialect index *****************************************************************************/ void ATT5ESSCreateNT(L3UCHAR i) { - Q931SetMesProc(Q931mes_ALERTING, i,Q931ProcAlertingNT, Q931Umes_Alerting, Q931Pmes_Alerting); - Q931SetMesProc(Q931mes_CALL_PROCEEDING, i,Q931ProcCallProceedingNT, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); - Q931SetMesProc(Q931mes_CONNECT, i,Q931ProcConnectNT, Q931Umes_Connect, Q931Pmes_Connect); - Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i,Q931ProcConnectAckNT, Q931Umes_ConnectAck, Q931Pmes_ConnectAck); - Q931SetMesProc(Q931mes_PROGRESS, i,Q931ProcProgressNT, Q931Umes_Progress, Q931Pmes_Progress); - Q931SetMesProc(Q931mes_SETUP, i,Q931ProcSetupNT, Q931Umes_Setup, Q931Pmes_Setup); - Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i,Q931ProcSetupAckNT, Q931Umes_SetupAck, Q931Pmes_SetupAck); - Q931SetMesProc(Q931mes_RESUME, i,Q931ProcResumeNT, Q931Umes_Resume, Q931Pmes_Resume); - Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i,Q931ProcResumeAckNT, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); - Q931SetMesProc(Q931mes_RESUME_REJECT, i,Q931ProcResumeRejectNT, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); - Q931SetMesProc(Q931mes_SUSPEND, i,Q931ProcSuspendNT, Q931Umes_Suspend, Q931Pmes_Suspend); - Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i,Q931ProcSuspendAckNT, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); - Q931SetMesProc(Q931mes_SUSPEND_REJECT, i,Q931ProcSuspendRejectNT, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); - Q931SetMesProc(Q931mes_USER_INFORMATION, i,Q931ProcUserInformationNT, Q931Umes_UserInformation, Q931Pmes_UserInformation); - Q931SetMesProc(Q931mes_DISCONNECT, i,Q931ProcDisconnectNT, Q931Umes_Disconnect, Q931Pmes_Disconnect); - Q931SetMesProc(Q931mes_RELEASE, i,Q931ProcReleaseNT, Q931Umes_Release, Q931Pmes_Release); - Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i,Q931ProcReleaseCompleteNT, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); - Q931SetMesProc(Q931mes_RESTART, i,Q931ProcRestartNT, Q931Umes_Restart, Q931Pmes_Restart); - Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i,Q931ProcRestartAckNT, Q931Umes_RestartAck, Q931Pmes_RestartAck); - Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i,Q931ProcCongestionControlNT, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); - Q931SetMesProc(Q931mes_INFORMATION, i,Q931ProcInformationNT, Q931Umes_Information, Q931Pmes_Information); - Q931SetMesProc(Q931mes_NOTIFY, i,Q931ProcNotifyNT, Q931Umes_Notify, Q931Pmes_Notify); - Q931SetMesProc(Q931mes_STATUS, i,Q931ProcStatusNT, Q931Umes_Status, Q931Pmes_Status); - Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i,Q931ProcStatusEnquiryNT, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); - Q931SetMesProc(Q931mes_SEGMENT, i,Q931ProcSegmentNT, Q931Umes_Segment, Q931Pmes_Segment); + Q931SetMesProc(Q931mes_ALERTING, i, Q931ProcAlertingNT, Q931Umes_Alerting, Q931Pmes_Alerting); + Q931SetMesProc(Q931mes_CALL_PROCEEDING, i, Q931ProcCallProceedingNT, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); + Q931SetMesProc(Q931mes_CONNECT, i, Q931ProcConnectNT, Q931Umes_Connect, Q931Pmes_Connect); + Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i, Q931ProcConnectAckNT, Q931Umes_ConnectAck, Q931Pmes_ConnectAck); + Q931SetMesProc(Q931mes_PROGRESS, i, Q931ProcProgressNT, Q931Umes_Progress, Q931Pmes_Progress); + Q931SetMesProc(Q931mes_SETUP, i, Q931ProcSetupNT, Q931Umes_Setup, Q931Pmes_Setup); + Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i, Q931ProcSetupAckNT, Q931Umes_SetupAck, Q931Pmes_SetupAck); + Q931SetMesProc(Q931mes_RESUME, i, Q931ProcResumeNT, Q931Umes_Resume, Q931Pmes_Resume); + Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i, Q931ProcResumeAckNT, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); + Q931SetMesProc(Q931mes_RESUME_REJECT, i, Q931ProcResumeRejectNT, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); + Q931SetMesProc(Q931mes_SUSPEND, i, Q931ProcSuspendNT, Q931Umes_Suspend, Q931Pmes_Suspend); + Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i, Q931ProcSuspendAckNT, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); + Q931SetMesProc(Q931mes_SUSPEND_REJECT, i, Q931ProcSuspendRejectNT, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); + Q931SetMesProc(Q931mes_USER_INFORMATION, i, Q931ProcUserInformationNT, Q931Umes_UserInformation, Q931Pmes_UserInformation); + Q931SetMesProc(Q931mes_DISCONNECT, i, Q931ProcDisconnectNT, Q931Umes_Disconnect, Q931Pmes_Disconnect); + Q931SetMesProc(Q931mes_RELEASE, i, Q931ProcReleaseNT, Q931Umes_Release, Q931Pmes_Release); + Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i, Q931ProcReleaseCompleteNT, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); + Q931SetMesProc(Q931mes_RESTART, i, Q931ProcRestartNT, Q931Umes_Restart, Q931Pmes_Restart); + Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i, Q931ProcRestartAckNT, Q931Umes_RestartAck, Q931Pmes_RestartAck); + Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i, Q931ProcCongestionControlNT, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); + Q931SetMesProc(Q931mes_INFORMATION, i, Q931ProcInformationNT, Q931Umes_Information, Q931Pmes_Information); + Q931SetMesProc(Q931mes_NOTIFY, i, Q931ProcNotifyNT, Q931Umes_Notify, Q931Pmes_Notify); + Q931SetMesProc(Q931mes_STATUS, i, Q931ProcStatusNT, Q931Umes_Status, Q931Pmes_Status); + Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i, Q931ProcStatusEnquiryNT, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); + Q931SetMesProc(Q931mes_SEGMENT, i, Q931ProcSegmentNT, Q931Umes_Segment, Q931Pmes_Segment); - Q931SetMesProc(Q932mes_FACILITY, i,Q932ProcFacilityNT, Q932Umes_Facility, Q932Pmes_Facility); - Q931SetMesProc(Q932mes_HOLD, i,Q932ProcHoldNT, Q932Umes_Hold, Q932Pmes_Hold); - Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i,Q932ProcHoldAckNT, Q932Umes_HoldAck, Q932Pmes_HoldAck); - Q931SetMesProc(Q932mes_HOLD_REJECT, i,Q932ProcHoldRejectNT, Q932Umes_HoldReject, Q932Pmes_HoldReject); - Q931SetMesProc(Q932mes_REGISTER, i,Q932ProcRegisterNT, Q932Umes_Register, Q932Pmes_Register); - Q931SetMesProc(Q932mes_RETRIEVE, i,Q932ProcRetrieveNT, Q932Umes_Retrieve, Q932Pmes_Retrieve); - Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE,i,Q932ProcRetrieveAckNT, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); - Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i,Q932ProcRetrieveRejectNT, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); + Q931SetMesProc(Q932mes_FACILITY, i, Q932ProcFacilityNT, Q932Umes_Facility, Q932Pmes_Facility); + Q931SetMesProc(Q932mes_HOLD, i, Q932ProcHoldNT, Q932Umes_Hold, Q932Pmes_Hold); + Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i, Q932ProcHoldAckNT, Q932Umes_HoldAck, Q932Pmes_HoldAck); + Q931SetMesProc(Q932mes_HOLD_REJECT, i, Q932ProcHoldRejectNT, Q932Umes_HoldReject, Q932Pmes_HoldReject); + Q931SetMesProc(Q932mes_REGISTER, i, Q932ProcRegisterNT, Q932Umes_Register, Q932Pmes_Register); + Q931SetMesProc(Q932mes_RETRIEVE, i, Q932ProcRetrieveNT, Q932Umes_Retrieve, Q932Pmes_Retrieve); + Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE, i, Q932ProcRetrieveAckNT, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); + Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i, Q932ProcRetrieveRejectNT, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); - /* Set up the IE encoder/decoder handle table.*/ - Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i,Q931Pie_Segment, Q931Uie_Segment); - Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i,Q931Pie_BearerCap, Q931Uie_BearerCap); - Q931SetIEProc(Q931ie_CAUSE, i,Q931Pie_Cause, Q931Uie_Cause); - Q931SetIEProc(Q931ie_CALL_IDENTITY, i,Q931Pie_CallID, Q931Uie_CallID); - Q931SetIEProc(Q931ie_CALL_STATE, i,Q931Pie_CallState, Q931Uie_CallState); - Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i,Q931Pie_ChanID, Q931Uie_ChanID); - Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i,Q931Pie_ProgInd, Q931Uie_ProgInd); - Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i,Q931Pie_NetFac, Q931Uie_NetFac); - Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i,Q931Pie_NotifInd, Q931Uie_NotifInd); - Q931SetIEProc(Q931ie_DISPLAY, i,Q931Pie_Display, Q931Uie_Display); - Q931SetIEProc(Q931ie_DATETIME, i,Q931Pie_DateTime, Q931Uie_DateTime); - Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i,Q931Pie_KeypadFac, Q931Uie_KeypadFac); - Q931SetIEProc(Q931ie_SIGNAL, i,Q931Pie_Signal, Q931Uie_Signal); - Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i,Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i,Q931Pie_CallingNum, Q931Uie_CallingNum); - Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i,Q931Pie_CallingSub, Q931Uie_CallingSub); - Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i,Q931Pie_CalledNum, Q931Uie_CalledNum); - Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i,Q931Pie_CalledSub, Q931Uie_CalledSub); - Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i,Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_RESTART_INDICATOR, i,Q931Pie_RestartInd, Q931Uie_RestartInd); - Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i,Q931Pie_LLComp, Q931Uie_LLComp); - Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i,Q931Pie_HLComp, Q931Uie_HLComp); - Q931SetIEProc(Q931ie_USER_USER, i,Q931Pie_UserUser, Q931Uie_UserUser); - Q931SetIEProc(Q931ie_GENERIC_DIGITS, i,Q931Pie_GenericDigits, Q931Uie_GenericDigits); + /* Set up the IE encoder/decoder handle table.*/ + Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i, Q931Pie_Segment, Q931Uie_Segment); + Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i, Q931Pie_BearerCap, Q931Uie_BearerCap); + Q931SetIEProc(Q931ie_CAUSE, i, Q931Pie_Cause, Q931Uie_Cause); + Q931SetIEProc(Q931ie_CALL_IDENTITY, i, Q931Pie_CallID, Q931Uie_CallID); + Q931SetIEProc(Q931ie_CALL_STATE, i, Q931Pie_CallState, Q931Uie_CallState); + Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i, Q931Pie_ChanID, Q931Uie_ChanID); + Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i, Q931Pie_ProgInd, Q931Uie_ProgInd); + Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i, Q931Pie_NetFac, Q931Uie_NetFac); + Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i, Q931Pie_NotifInd, Q931Uie_NotifInd); + Q931SetIEProc(Q931ie_DISPLAY, i, Q931Pie_Display, Q931Uie_Display); + Q931SetIEProc(Q931ie_DATETIME, i, Q931Pie_DateTime, Q931Uie_DateTime); + Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i, Q931Pie_KeypadFac, Q931Uie_KeypadFac); + Q931SetIEProc(Q931ie_SIGNAL, i, Q931Pie_Signal, Q931Uie_Signal); + Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); + Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i, Q931Pie_CallingNum, Q931Uie_CallingNum); + Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i, Q931Pie_CallingSub, Q931Uie_CallingSub); + Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i, Q931Pie_CalledNum, Q931Uie_CalledNum); + Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i, Q931Pie_CalledSub, Q931Uie_CalledSub); + Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); + Q931SetIEProc(Q931ie_RESTART_INDICATOR, i, Q931Pie_RestartInd, Q931Uie_RestartInd); + Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i, Q931Pie_LLComp, Q931Uie_LLComp); + Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i, Q931Pie_HLComp, Q931Uie_HLComp); + Q931SetIEProc(Q931ie_USER_USER, i, Q931Pie_UserUser, Q931Uie_UserUser); + Q931SetIEProc(Q931ie_GENERIC_DIGITS, i, Q931Pie_GenericDigits, Q931Uie_GenericDigits); Q931SetIEProc(Q931ie_CONNECTED_NUMBER, i, Q931Pie_Generic, Q931Uie_Generic); Q931SetIEProc(Q931ie_FACILITY, i, Q931Pie_Generic, Q931Uie_Generic); - /* The following define a state machine. The point is that the Message */ - /* procs can when search this to find out if the message/state */ - /* combination is legale. If not, the proc for unexpected message apply.*/ + /* The following define a state machine. The point is that the Message */ + /* procs can when search this to find out if the message/state */ + /* combination is legale. If not, the proc for unexpected message apply.*/ - /* TODO define state table here */ + /* TODO define state table here */ } diff --git a/libs/freetdm/src/isdn/5ESSStateTE.c b/libs/freetdm/src/isdn/5ESSStateTE.c index 62594212e3..ce2425e0e0 100644 --- a/libs/freetdm/src/isdn/5ESSStateTE.c +++ b/libs/freetdm/src/isdn/5ESSStateTE.c @@ -4,18 +4,18 @@ Contents: AT&T 5ESS ISDN State Engine for TE (User Mode). - The controlling state engine for Q.931 is the state engine - on the NT side. The state engine on the TE side is a slave - of this. The TE side maintain it's own states as described in - ITU-T Q931, but will in raise conditions be overridden by - the NT side. + The controlling state engine for Q.931 is the state engine + on the NT side. The state engine on the TE side is a slave + of this. The TE side maintain it's own states as described in + ITU-T Q931, but will in raise conditions be overridden by + the NT side. - This reference implementation uses a process per message, - meaning that each message must check call states. This - is easier for dialect maintenance as each message proc - can be replaced individually. A new TE variant only - need to copy the Q931CreateTE and replace those procs or - need to override. + This reference implementation uses a process per message, + meaning that each message must check call states. This + is easier for dialect maintenance as each message proc + can be replaced individually. A new TE variant only + need to copy the Q931CreateTE and replace those procs or + need to override. License/Copyright: @@ -32,14 +32,14 @@ modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Case Labs, Ltd nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the Case Labs, Ltd nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -61,159 +61,159 @@ extern L3INT Q931L4HeaderSpace; Function: ATT5ESSCreateTE Description: Will create the AT&T 5ESS TE as a Dialect in the stack. The first - bulk set up the message handlers, the second bulk the IE - encoders/coders, and the last bulk set up the state table. + bulk set up the message handlers, the second bulk the IE + encoders/coders, and the last bulk set up the state table. Parameters: i Dialect index *****************************************************************************/ void ATT5ESSCreateTE(L3UCHAR i) { - Q931SetMesProc(Q931mes_ALERTING, i,Q931ProcAlertingTE, Q931Umes_Alerting, Q931Pmes_Alerting); - Q931SetMesProc(Q931mes_CALL_PROCEEDING, i,Q931ProcCallProceedingTE, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); - Q931SetMesProc(Q931mes_CONNECT, i,ATT5ESSProc0x07TE, ATT5ESSUmes_0x07, ATT5ESSPmes_0x07); - Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i,ATT5ESSProc0x0fTE, ATT5ESSUmes_0x0f, ATT5ESSPmes_0x0f); - Q931SetMesProc(Q931mes_PROGRESS, i,Q931ProcProgressTE, Q931Umes_Progress, Q931Pmes_Progress); - Q931SetMesProc(Q931mes_SETUP, i,Q931ProcSetupTE, ATT5ESSUmes_Setup, ATT5ESSPmes_Setup); - Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i,Q931ProcSetupAckTE, Q931Umes_SetupAck, Q931Pmes_SetupAck); - Q931SetMesProc(Q931mes_RESUME, i,Q931ProcResumeTE, Q931Umes_Resume, Q931Pmes_Resume); - Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i,Q931ProcResumeAckTE, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); - Q931SetMesProc(Q931mes_RESUME_REJECT, i,Q931ProcResumeRejectTE, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); - Q931SetMesProc(Q931mes_SUSPEND, i,Q931ProcSuspendTE, Q931Umes_Suspend, Q931Pmes_Suspend); - Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i,Q931ProcSuspendAckTE, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); - Q931SetMesProc(Q931mes_SUSPEND_REJECT, i,Q931ProcSuspendRejectTE, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); - Q931SetMesProc(Q931mes_USER_INFORMATION, i,Q931ProcUserInformationTE, Q931Umes_UserInformation, Q931Pmes_UserInformation); - Q931SetMesProc(Q931mes_DISCONNECT, i,Q931ProcDisconnectTE, Q931Umes_Disconnect, Q931Pmes_Disconnect); - Q931SetMesProc(Q931mes_RELEASE, i,Q931ProcReleaseTE, Q931Umes_Release, Q931Pmes_Release); - Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i,Q931ProcReleaseCompleteTE, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); - Q931SetMesProc(Q931mes_RESTART, i,Q931ProcRestartTE, Q931Umes_Restart, Q931Pmes_Restart); - Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i,Q931ProcRestartAckTE, Q931Umes_RestartAck, Q931Pmes_RestartAck); - Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i,Q931ProcCongestionControlTE, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); - Q931SetMesProc(Q931mes_INFORMATION, i,Q931ProcInformationTE, Q931Umes_Information, Q931Pmes_Information); - Q931SetMesProc(Q931mes_NOTIFY, i,Q931ProcNotifyTE, Q931Umes_Notify, Q931Pmes_Notify); - Q931SetMesProc(Q931mes_STATUS, i,Q931ProcStatusTE, Q931Umes_Status, Q931Pmes_Status); - Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i,Q931ProcStatusEnquiryTE, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); - Q931SetMesProc(Q931mes_SEGMENT, i,Q931ProcSegmentTE, Q931Umes_Segment, Q931Pmes_Segment); + Q931SetMesProc(Q931mes_ALERTING, i, Q931ProcAlertingTE, Q931Umes_Alerting, Q931Pmes_Alerting); + Q931SetMesProc(Q931mes_CALL_PROCEEDING, i, Q931ProcCallProceedingTE, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); + Q931SetMesProc(Q931mes_CONNECT, i, ATT5ESSProc0x07TE, ATT5ESSUmes_0x07, ATT5ESSPmes_0x07); + Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i, ATT5ESSProc0x0fTE, ATT5ESSUmes_0x0f, ATT5ESSPmes_0x0f); + Q931SetMesProc(Q931mes_PROGRESS, i, Q931ProcProgressTE, Q931Umes_Progress, Q931Pmes_Progress); + Q931SetMesProc(Q931mes_SETUP, i, Q931ProcSetupTE, ATT5ESSUmes_Setup, ATT5ESSPmes_Setup); + Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i, Q931ProcSetupAckTE, Q931Umes_SetupAck, Q931Pmes_SetupAck); + Q931SetMesProc(Q931mes_RESUME, i, Q931ProcResumeTE, Q931Umes_Resume, Q931Pmes_Resume); + Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i, Q931ProcResumeAckTE, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); + Q931SetMesProc(Q931mes_RESUME_REJECT, i, Q931ProcResumeRejectTE, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); + Q931SetMesProc(Q931mes_SUSPEND, i, Q931ProcSuspendTE, Q931Umes_Suspend, Q931Pmes_Suspend); + Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i, Q931ProcSuspendAckTE, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); + Q931SetMesProc(Q931mes_SUSPEND_REJECT, i, Q931ProcSuspendRejectTE, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); + Q931SetMesProc(Q931mes_USER_INFORMATION, i, Q931ProcUserInformationTE, Q931Umes_UserInformation, Q931Pmes_UserInformation); + Q931SetMesProc(Q931mes_DISCONNECT, i, Q931ProcDisconnectTE, Q931Umes_Disconnect, Q931Pmes_Disconnect); + Q931SetMesProc(Q931mes_RELEASE, i, Q931ProcReleaseTE, Q931Umes_Release, Q931Pmes_Release); + Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i, Q931ProcReleaseCompleteTE, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); + Q931SetMesProc(Q931mes_RESTART, i, Q931ProcRestartTE, Q931Umes_Restart, Q931Pmes_Restart); + Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i, Q931ProcRestartAckTE, Q931Umes_RestartAck, Q931Pmes_RestartAck); + Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i, Q931ProcCongestionControlTE, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); + Q931SetMesProc(Q931mes_INFORMATION, i, Q931ProcInformationTE, Q931Umes_Information, Q931Pmes_Information); + Q931SetMesProc(Q931mes_NOTIFY, i, Q931ProcNotifyTE, Q931Umes_Notify, Q931Pmes_Notify); + Q931SetMesProc(Q931mes_STATUS, i, Q931ProcStatusTE, Q931Umes_Status, Q931Pmes_Status); + Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i, Q931ProcStatusEnquiryTE, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); + Q931SetMesProc(Q931mes_SEGMENT, i, Q931ProcSegmentTE, Q931Umes_Segment, Q931Pmes_Segment); - Q931SetMesProc(Q932mes_FACILITY, i,Q932ProcFacilityTE, Q932Umes_Facility, Q932Pmes_Facility); - Q931SetMesProc(Q932mes_HOLD, i,Q932ProcHoldTE, Q932Umes_Hold, Q932Pmes_Hold); - Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i,Q932ProcHoldAckTE, Q932Umes_HoldAck, Q932Pmes_HoldAck); - Q931SetMesProc(Q932mes_HOLD_REJECT, i,Q932ProcHoldRejectTE, Q932Umes_HoldReject, Q932Pmes_HoldReject); - Q931SetMesProc(Q932mes_REGISTER, i,Q932ProcRegisterTE, Q932Umes_Register, Q932Pmes_Register); - Q931SetMesProc(Q932mes_RETRIEVE, i,Q932ProcRetrieveTE, Q932Umes_Retrieve, Q932Pmes_Retrieve); - Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE,i,Q932ProcRetrieveAckTE, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); - Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i,Q932ProcRetrieveRejectTE, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); + Q931SetMesProc(Q932mes_FACILITY, i, Q932ProcFacilityTE, Q932Umes_Facility, Q932Pmes_Facility); + Q931SetMesProc(Q932mes_HOLD, i, Q932ProcHoldTE, Q932Umes_Hold, Q932Pmes_Hold); + Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i, Q932ProcHoldAckTE, Q932Umes_HoldAck, Q932Pmes_HoldAck); + Q931SetMesProc(Q932mes_HOLD_REJECT, i, Q932ProcHoldRejectTE, Q932Umes_HoldReject, Q932Pmes_HoldReject); + Q931SetMesProc(Q932mes_REGISTER, i, Q932ProcRegisterTE, Q932Umes_Register, Q932Pmes_Register); + Q931SetMesProc(Q932mes_RETRIEVE, i, Q932ProcRetrieveTE, Q932Umes_Retrieve, Q932Pmes_Retrieve); + Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE, i, Q932ProcRetrieveAckTE, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); + Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i, Q932ProcRetrieveRejectTE, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); - /* Set up the IE encoder/decoder handle table.*/ - Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i,Q931Pie_Segment, Q931Uie_Segment); - Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i,Q931Pie_BearerCap, Q931Uie_BearerCap); - Q931SetIEProc(Q931ie_CAUSE, i,Q931Pie_Cause, Q931Uie_Cause); - Q931SetIEProc(Q931ie_CALL_IDENTITY, i,Q931Pie_CallID, Q931Uie_CallID); - Q931SetIEProc(Q931ie_CALL_STATE, i,Q931Pie_CallState, Q931Uie_CallState); - Q931SetIEProc(Q931ie_CHANGE_STATUS, i,Q931Pie_ChangeStatus, Q931Uie_ChangeStatus); - Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i,Q931Pie_ChanID, Q931Uie_ChanID); - Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i,Q931Pie_ProgInd, Q931Uie_ProgInd); - Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i,Q931Pie_NetFac, Q931Uie_NetFac); - Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i,Q931Pie_NotifInd, Q931Uie_NotifInd); - Q931SetIEProc(Q931ie_DISPLAY, i,Q931Pie_Display, Q931Uie_Display); - Q931SetIEProc(Q931ie_DATETIME, i,Q931Pie_DateTime, Q931Uie_DateTime); - Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i,Q931Pie_KeypadFac, Q931Uie_KeypadFac); - Q931SetIEProc(Q931ie_SIGNAL, i,Q931Pie_Signal, Q931Uie_Signal); - Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i,Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i,Q931Pie_CallingNum, Q931Uie_CallingNum); - Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i,Q931Pie_CallingSub, Q931Uie_CallingSub); - Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i,Q931Pie_CalledNum, Q931Uie_CalledNum); - Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i,Q931Pie_CalledSub, Q931Uie_CalledSub); - Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i,Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_RESTART_INDICATOR, i,Q931Pie_RestartInd, Q931Uie_RestartInd); - Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i,Q931Pie_LLComp, Q931Uie_LLComp); - Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i,Q931Pie_HLComp, Q931Uie_HLComp); - Q931SetIEProc(Q931ie_USER_USER, i,Q931Pie_UserUser, Q931Uie_UserUser); - Q931SetIEProc(Q931ie_GENERIC_DIGITS, i,Q931Pie_GenericDigits, Q931Uie_GenericDigits); + /* Set up the IE encoder/decoder handle table.*/ + Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i, Q931Pie_Segment, Q931Uie_Segment); + Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i, Q931Pie_BearerCap, Q931Uie_BearerCap); + Q931SetIEProc(Q931ie_CAUSE, i, Q931Pie_Cause, Q931Uie_Cause); + Q931SetIEProc(Q931ie_CALL_IDENTITY, i, Q931Pie_CallID, Q931Uie_CallID); + Q931SetIEProc(Q931ie_CALL_STATE, i, Q931Pie_CallState, Q931Uie_CallState); + Q931SetIEProc(Q931ie_CHANGE_STATUS, i, Q931Pie_ChangeStatus, Q931Uie_ChangeStatus); + Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i, Q931Pie_ChanID, Q931Uie_ChanID); + Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i, Q931Pie_ProgInd, Q931Uie_ProgInd); + Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i, Q931Pie_NetFac, Q931Uie_NetFac); + Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i, Q931Pie_NotifInd, Q931Uie_NotifInd); + Q931SetIEProc(Q931ie_DISPLAY, i, Q931Pie_Display, Q931Uie_Display); + Q931SetIEProc(Q931ie_DATETIME, i, Q931Pie_DateTime, Q931Uie_DateTime); + Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i, Q931Pie_KeypadFac, Q931Uie_KeypadFac); + Q931SetIEProc(Q931ie_SIGNAL, i, Q931Pie_Signal, Q931Uie_Signal); + Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); + Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i, Q931Pie_CallingNum, Q931Uie_CallingNum); + Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i, Q931Pie_CallingSub, Q931Uie_CallingSub); + Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i, Q931Pie_CalledNum, Q931Uie_CalledNum); + Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i, Q931Pie_CalledSub, Q931Uie_CalledSub); + Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); + Q931SetIEProc(Q931ie_RESTART_INDICATOR, i, Q931Pie_RestartInd, Q931Uie_RestartInd); + Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i, Q931Pie_LLComp, Q931Uie_LLComp); + Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i, Q931Pie_HLComp, Q931Uie_HLComp); + Q931SetIEProc(Q931ie_USER_USER, i, Q931Pie_UserUser, Q931Uie_UserUser); + Q931SetIEProc(Q931ie_GENERIC_DIGITS, i, Q931Pie_GenericDigits, Q931Uie_GenericDigits); Q931SetIEProc(Q931ie_CONNECTED_NUMBER, i, Q931Pie_Generic, Q931Uie_Generic); Q931SetIEProc(Q931ie_FACILITY, i, Q931Pie_Generic, Q931Uie_Generic); - /* The following define a state machine. The point is that the Message */ - /* procs can when search this to find out if the message/state */ - /* combination is legale. If not, the proc for unexpected message apply.*/ + /* The following define a state machine. The point is that the Message */ + /* procs can when search this to find out if the message/state */ + /* combination is legale. If not, the proc for unexpected message apply.*/ - /* State 0 Idle */ - Q931AddStateEntry(i,Q931_U0, Q931mes_RESUME, 2); - Q931AddStateEntry(i,Q931_U0, Q931mes_SETUP, 4); - Q931AddStateEntry(i,Q931_U0, Q931mes_SETUP, 2); - Q931AddStateEntry(i,Q931_U0, Q931mes_STATUS, 4); - Q931AddStateEntry(i,Q931_U0, Q931mes_RELEASE, 4); - Q931AddStateEntry(i,Q931_U0, Q931mes_RELEASE_COMPLETE, 4); + /* State 0 Idle */ + Q931AddStateEntry(i, Q931_U0, Q931mes_RESUME, 2); + Q931AddStateEntry(i, Q931_U0, Q931mes_SETUP, 4); + Q931AddStateEntry(i, Q931_U0, Q931mes_SETUP, 2); + Q931AddStateEntry(i, Q931_U0, Q931mes_STATUS, 4); + Q931AddStateEntry(i, Q931_U0, Q931mes_RELEASE, 4); + Q931AddStateEntry(i, Q931_U0, Q931mes_RELEASE_COMPLETE, 4); - /* State 1 Call Initiating */ - Q931AddStateEntry(i,Q931_U1, Q931mes_DISCONNECT, 2); - Q931AddStateEntry(i,Q931_U1, Q931mes_SETUP_ACKNOWLEDGE, 4); - Q931AddStateEntry(i,Q931_U1, Q931mes_RELEASE_COMPLETE, 4); - Q931AddStateEntry(i,Q931_U1, Q931mes_CALL_PROCEEDING, 4); - Q931AddStateEntry(i,Q931_U1, Q931mes_ALERTING, 4); - Q931AddStateEntry(i,Q931_U1, Q931mes_CONNECT, 4); + /* State 1 Call Initiating */ + Q931AddStateEntry(i, Q931_U1, Q931mes_DISCONNECT, 2); + Q931AddStateEntry(i, Q931_U1, Q931mes_SETUP_ACKNOWLEDGE, 4); + Q931AddStateEntry(i, Q931_U1, Q931mes_RELEASE_COMPLETE, 4); + Q931AddStateEntry(i, Q931_U1, Q931mes_CALL_PROCEEDING, 4); + Q931AddStateEntry(i, Q931_U1, Q931mes_ALERTING, 4); + Q931AddStateEntry(i, Q931_U1, Q931mes_CONNECT, 4); - /* State 2 Overlap Sending */ - Q931AddStateEntry(i,Q931_U2, Q931mes_INFORMATION, 2); - Q931AddStateEntry(i,Q931_U2, Q931mes_CALL_PROCEEDING, 4); - Q931AddStateEntry(i,Q931_U2, Q931mes_ALERTING, 4); - Q931AddStateEntry(i,Q931_U2, Q931mes_PROGRESS, 4); - Q931AddStateEntry(i,Q931_U2, Q931mes_CONNECT, 4); - Q931AddStateEntry(i,Q931_U2, Q931mes_RELEASE, 2); + /* State 2 Overlap Sending */ + Q931AddStateEntry(i, Q931_U2, Q931mes_INFORMATION, 2); + Q931AddStateEntry(i, Q931_U2, Q931mes_CALL_PROCEEDING, 4); + Q931AddStateEntry(i, Q931_U2, Q931mes_ALERTING, 4); + Q931AddStateEntry(i, Q931_U2, Q931mes_PROGRESS, 4); + Q931AddStateEntry(i, Q931_U2, Q931mes_CONNECT, 4); + Q931AddStateEntry(i, Q931_U2, Q931mes_RELEASE, 2); - /* State 3 Outgoing Call Proceeding */ - Q931AddStateEntry(i,Q931_U3, Q931mes_PROGRESS, 4); - Q931AddStateEntry(i,Q931_U3, Q931mes_ALERTING, 4); - Q931AddStateEntry(i,Q931_U3, Q931mes_CONNECT, 4); - Q931AddStateEntry(i,Q931_U3, Q931mes_RELEASE, 2); + /* State 3 Outgoing Call Proceeding */ + Q931AddStateEntry(i, Q931_U3, Q931mes_PROGRESS, 4); + Q931AddStateEntry(i, Q931_U3, Q931mes_ALERTING, 4); + Q931AddStateEntry(i, Q931_U3, Q931mes_CONNECT, 4); + Q931AddStateEntry(i, Q931_U3, Q931mes_RELEASE, 2); - /* State 4 Call Delivered */ - Q931AddStateEntry(i,Q931_U4, Q931mes_CONNECT, 4); + /* State 4 Call Delivered */ + Q931AddStateEntry(i, Q931_U4, Q931mes_CONNECT, 4); - /* State 6 Call Precent */ - Q931AddStateEntry(i,Q931_U6, Q931mes_INFORMATION, 2); - Q931AddStateEntry(i,Q931_U6, Q931mes_ALERTING, 2); - Q931AddStateEntry(i,Q931_U6, Q931mes_CALL_PROCEEDING, 2); - Q931AddStateEntry(i,Q931_U6, Q931mes_CONNECT, 2); - Q931AddStateEntry(i,Q931_U6, Q931mes_RELEASE_COMPLETE, 2); - Q931AddStateEntry(i,Q931_U6, Q931mes_RELEASE, 4); - Q931AddStateEntry(i,Q931_U6, Q931mes_DISCONNECT, 4); + /* State 6 Call Precent */ + Q931AddStateEntry(i, Q931_U6, Q931mes_INFORMATION, 2); + Q931AddStateEntry(i, Q931_U6, Q931mes_ALERTING, 2); + Q931AddStateEntry(i, Q931_U6, Q931mes_CALL_PROCEEDING, 2); + Q931AddStateEntry(i, Q931_U6, Q931mes_CONNECT, 2); + Q931AddStateEntry(i, Q931_U6, Q931mes_RELEASE_COMPLETE, 2); + Q931AddStateEntry(i, Q931_U6, Q931mes_RELEASE, 4); + Q931AddStateEntry(i, Q931_U6, Q931mes_DISCONNECT, 4); - /* State 7 Call Received */ - Q931AddStateEntry(i,Q931_U7, Q931mes_CONNECT, 2); + /* State 7 Call Received */ + Q931AddStateEntry(i, Q931_U7, Q931mes_CONNECT, 2); - /* State 8 Connect request */ - Q931AddStateEntry(i,Q931_U8, Q931mes_CONNECT_ACKNOWLEDGE,4); + /* State 8 Connect request */ + Q931AddStateEntry(i, Q931_U8, Q931mes_CONNECT_ACKNOWLEDGE, 4); - /* State 9 Incoming Call Proceeding */ - Q931AddStateEntry(i,Q931_U9, Q931mes_CONNECT, 2); - Q931AddStateEntry(i,Q931_U9, Q931mes_ALERTING, 2); - Q931AddStateEntry(i,Q931_U9, Q931mes_PROGRESS, 2); + /* State 9 Incoming Call Proceeding */ + Q931AddStateEntry(i, Q931_U9, Q931mes_CONNECT, 2); + Q931AddStateEntry(i, Q931_U9, Q931mes_ALERTING, 2); + Q931AddStateEntry(i, Q931_U9, Q931mes_PROGRESS, 2); - /* State 10 Active */ - Q931AddStateEntry(i,Q931_U10, Q931mes_SUSPEND, 2); - Q931AddStateEntry(i,Q931_U10, Q931mes_NOTIFY, 4); - Q931AddStateEntry(i,Q931_U10, Q931mes_NOTIFY, 2); + /* State 10 Active */ + Q931AddStateEntry(i, Q931_U10, Q931mes_SUSPEND, 2); + Q931AddStateEntry(i, Q931_U10, Q931mes_NOTIFY, 4); + Q931AddStateEntry(i, Q931_U10, Q931mes_NOTIFY, 2); - /* State 11 Disconnect Request */ - Q931AddStateEntry(i,Q931_U11, Q931mes_RELEASE, 4); - Q931AddStateEntry(i,Q931_U11, Q931mes_DISCONNECT, 4); - Q931AddStateEntry(i,Q931_U11, Q931mes_NOTIFY, 4); + /* State 11 Disconnect Request */ + Q931AddStateEntry(i, Q931_U11, Q931mes_RELEASE, 4); + Q931AddStateEntry(i, Q931_U11, Q931mes_DISCONNECT, 4); + Q931AddStateEntry(i, Q931_U11, Q931mes_NOTIFY, 4); - /* State 12 Disconnect Ind */ - Q931AddStateEntry(i,Q931_U12, Q931mes_RELEASE, 4); - Q931AddStateEntry(i,Q931_U12, Q931mes_RELEASE, 2); + /* State 12 Disconnect Ind */ + Q931AddStateEntry(i, Q931_U12, Q931mes_RELEASE, 4); + Q931AddStateEntry(i, Q931_U12, Q931mes_RELEASE, 2); - /* State 15 Suspend Request */ - Q931AddStateEntry(i,Q931_U15, Q931mes_SUSPEND_ACKNOWLEDGE,4); - Q931AddStateEntry(i,Q931_U15, Q931mes_SUSPEND_REJECT, 4); - Q931AddStateEntry(i,Q931_U15, Q931mes_DISCONNECT, 4); - Q931AddStateEntry(i,Q931_U15, Q931mes_RELEASE, 4); + /* State 15 Suspend Request */ + Q931AddStateEntry(i, Q931_U15, Q931mes_SUSPEND_ACKNOWLEDGE, 4); + Q931AddStateEntry(i, Q931_U15, Q931mes_SUSPEND_REJECT, 4); + Q931AddStateEntry(i, Q931_U15, Q931mes_DISCONNECT, 4); + Q931AddStateEntry(i, Q931_U15, Q931mes_RELEASE, 4); /* TODO - Q931AddStateEntry(i,Q931_U17, - Q931AddStateEntry(i,Q931_U19, - Q931AddStateEntry(i,Q931_U25, + Q931AddStateEntry(i, Q931_U17, + Q931AddStateEntry(i, Q931_U19, + Q931AddStateEntry(i, Q931_U25, */ } @@ -224,37 +224,33 @@ void ATT5ESSCreateTE(L3UCHAR i) *****************************************************************************/ L3INT ATT5ESSProc0x0fTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; if (pMes->ProtDisc == 8) { /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ Q931StartTimer(pTrunk, callIndex, 303); } - if(iFrom == 4) - { + if (iFrom == 4) { /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { + else if (iFrom ==2) { /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + ret = Q931Tx34(pTrunk, buf, pMes->Size); if (pMes->ProtDisc == 3 && pTrunk->autoServiceAck) { - printf("autoServiceAck is on, responding to Service Req from network...\n"); + printf("autoServiceAck is on, responding to Service Req from network...\n"); Q931AckService(pTrunk, buf); } - } return ret; @@ -267,31 +263,28 @@ L3INT ATT5ESSProc0x0fTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT ATT5ESSProc0x07TE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; if (pMes->ProtDisc == 8) { /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ Q931StartTimer(pTrunk, callIndex, 303); } - if(iFrom == 4) - { + if (iFrom == 4) { /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { + else if (iFrom == 2) { /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; diff --git a/libs/freetdm/src/isdn/5ESSmes.c b/libs/freetdm/src/isdn/5ESSmes.c index 3e4b316d98..17f7ec8c77 100644 --- a/libs/freetdm/src/isdn/5ESSmes.c +++ b/libs/freetdm/src/isdn/5ESSmes.c @@ -1,13 +1,13 @@ /***************************************************************************** - FileName: 5ESSmes.c + FileName: 5ESSmes.c - Contents: Pack/Unpack functions. These functions will unpack a 5ESS ISDN - message from the bit packed original format into structs - that contains variables sized by the user. It will also pack - the struct back into a Q.931 message as required. + Contents: Pack/Unpack functions. These functions will unpack a 5ESS ISDN + message from the bit packed original format into structs + that contains variables sized by the user. It will also pack + the struct back into a Q.931 message as required. - See 5ESS.h for description. + See 5ESS.h for description. License/Copyright: @@ -24,14 +24,14 @@ modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Case Labs, Ltd nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the Case Labs, Ltd nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -51,287 +51,300 @@ /***************************************************************************** - Function: ATT5ESSUmes_Setup + Function: ATT5ESSUmes_Setup *****************************************************************************/ L3INT ATT5ESSUmes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT ir=0; - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; - L3UCHAR last_codeset = 0, codeset = 0; - L3UCHAR shift_lock = 1; + L3INT ir = 0; + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; + L3UCHAR last_codeset = 0, codeset = 0; + L3UCHAR shift_lock = 1; - while(IOff < Size) - { - if (!shift_lock) { - codeset = last_codeset; - } + while (IOff < Size) + { + if (!shift_lock) { + codeset = last_codeset; + } - if ((IBuf[IOff] & 0xF0) == Q931ie_SHIFT ) { - shift_lock = (IBuf[IOff] & 0x08); - if (shift_lock) { - last_codeset = codeset; - } - codeset = ((IBuf[IOff] & 0x07)); - IOff++; - } + if ((IBuf[IOff] & 0xF0) == Q931ie_SHIFT ) { + shift_lock = (IBuf[IOff] & 0x08); + if (shift_lock) { + last_codeset = codeset; + } + codeset = ((IBuf[IOff] & 0x07)); + IOff++; + } - if (codeset == 0) { - switch(IBuf[IOff]) - { - case Q931ie_SENDING_COMPLETE: - case Q931ie_BEARER_CAPABILITY: - case Q931ie_CHANNEL_IDENTIFICATION: - case Q931ie_PROGRESS_INDICATOR: - case Q931ie_NETWORK_SPECIFIC_FACILITIES: - case Q931ie_DISPLAY: - case Q931ie_DATETIME: - case Q931ie_KEYPAD_FACILITY: - case Q931ie_SIGNAL: - case Q931ie_CALLING_PARTY_NUMBER: - case Q931ie_CALLING_PARTY_SUBADDRESS: - case Q931ie_CALLED_PARTY_NUMBER: - case Q931ie_CALLED_PARTY_SUBADDRESS: - case Q931ie_TRANSIT_NETWORK_SELECTION: - case Q931ie_LOW_LAYER_COMPATIBILITY: - case Q931ie_HIGH_LAYER_COMPATIBILITY: - case Q931ie_FACILITY: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) - return rc; - break; - case Q931ie_REPEAT_INDICATOR: - if(ir < 2) { - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - ir++; - } else { - return Q931E_ILLEGAL_IE; - } - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } else if (codeset == 6) { - switch(IBuf[IOff]) - { - case Q931ie_GENERIC_DIGITS: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } + if (codeset == 0) { + switch (IBuf[IOff]) + { + case Q931ie_SENDING_COMPLETE: + case Q931ie_BEARER_CAPABILITY: + case Q931ie_CHANNEL_IDENTIFICATION: + case Q931ie_PROGRESS_INDICATOR: + case Q931ie_NETWORK_SPECIFIC_FACILITIES: + case Q931ie_DISPLAY: + case Q931ie_DATETIME: + case Q931ie_KEYPAD_FACILITY: + case Q931ie_SIGNAL: + case Q931ie_CALLING_PARTY_NUMBER: + case Q931ie_CALLING_PARTY_SUBADDRESS: + case Q931ie_CALLED_PARTY_NUMBER: + case Q931ie_CALLED_PARTY_SUBADDRESS: + case Q931ie_TRANSIT_NETWORK_SELECTION: + case Q931ie_LOW_LAYER_COMPATIBILITY: + case Q931ie_HIGH_LAYER_COMPATIBILITY: + case Q931ie_FACILITY: + rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); + if (rc != Q931E_NO_ERROR) + return rc; + break; + case Q931ie_REPEAT_INDICATOR: + if (ir < 2) { + rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); + ir++; + } else { + return Q931E_ILLEGAL_IE; + } + break; + default: + return Q931E_ILLEGAL_IE; + break; + } + } else if (codeset == 6) { + switch (IBuf[IOff]) + { + case Q931ie_GENERIC_DIGITS: + rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); + if (rc != Q931E_NO_ERROR) + return rc; + break; + default: + return Q931E_ILLEGAL_IE; + break; + } - } else { - return Q931E_ILLEGAL_IE; - } - } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + } else { + return Q931E_ILLEGAL_IE; + } + } + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: ATT5ESSPmes_Setup + Function: ATT5ESSPmes_Setup Decription: Pack a Q931mes_Generic into a real Q.931 message. The user will - set up a SETUP message and issue this to the stack where it - is processed by Q931ProcSetup that processes and validates - it before it actually sends it out. This function is called - to compute the real Q.931 message. + set up a SETUP message and issue this to the stack where it + is processed by Q931ProcSetup that processes and validates + it before it actually sends it out. This function is called + to compute the real Q.931 message. - Parameters: IBuf[IN] Ptr to un-packed struct - ISize[IN] Size of input buffer (unpacked message). - OBuf[OUT] Ptr to packed 'octet' wise message. - OSize[OUT] Size of packed message. + Parameters: IBuf[IN] Ptr to un-packed struct + ISize[IN] Size of input buffer (unpacked message). + OBuf[OUT] Ptr to packed 'octet' wise message. + OSize[OUT] Size of packed message. - Called By: Q931ProcSetup + Called By: Q931ProcSetup *****************************************************************************/ L3INT ATT5ESSPmes_Setup(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3INT rc = Q931E_NO_ERROR; - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT Octet = 0; + L3INT rc = Q931E_NO_ERROR; + Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT Octet = 0; - /* Q931 Message Header */ + /* Q931 Message Header */ Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Sending Complete */ - if(Q931IsIEPresent(pMes->SendComplete)) - OBuf[Octet++] = (L3UCHAR)(pMes->SendComplete & 0x00ff); + + /* Sending Complete */ + if (Q931IsIEPresent(pMes->SendComplete)) { + OBuf[Octet++] = (L3UCHAR)(pMes->SendComplete & 0x00ff); + } - /* Repeat Indicator */ - if(Q931IsIEPresent(pMes->RepeatInd)) - OBuf[Octet++] = (L3UCHAR)(pMes->RepeatInd & 0x00ff); + /* Repeat Indicator */ + if (Q931IsIEPresent(pMes->RepeatInd)) { + OBuf[Octet++] = (L3UCHAR)(pMes->RepeatInd & 0x00ff); + } - /* Bearer capability */ - if(Q931IsIEPresent(pMes->BearerCap)) - { - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet))!=0) - return rc; - } - else - { - rc=Q931E_BEARERCAP; - } + /* Bearer capability */ + if (Q931IsIEPresent(pMes->BearerCap)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet))!=0) + return rc; + } else { + rc = Q931E_BEARERCAP; + } - /* Channel Identification */ - if(Q931IsIEPresent(pMes->ChanID)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet))!=0) - return rc; + /* Channel Identification */ + if (Q931IsIEPresent(pMes->ChanID)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet))!=0) + return rc; + } - /* Progress indicator */ - if(Q931IsIEPresent(pMes->ProgInd)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet))!=0) - return rc; + /* Progress indicator */ + if (Q931IsIEPresent(pMes->ProgInd)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet))!=0) + return rc; + } - /* Network specific facilities */ - if(Q931IsIEPresent(pMes->NetFac)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_NETWORK_SPECIFIC_FACILITIES](pTrunk, Q931GetIEPtr(pMes->NetFac,pMes->buf), OBuf, &Octet))!=0) - return rc; + /* Network specific facilities */ + if (Q931IsIEPresent(pMes->NetFac)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_NETWORK_SPECIFIC_FACILITIES](pTrunk, Q931GetIEPtr(pMes->NetFac,pMes->buf), OBuf, &Octet))!=0) + return rc; + } - /* Display */ - if(Q931IsIEPresent(pMes->Display)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) - return rc; + /* Display */ + if (Q931IsIEPresent(pMes->Display)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) + return rc; + } - /* Date/Time */ - if(Q931IsIEPresent(pMes->DateTime)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DATETIME](pTrunk, Q931GetIEPtr(pMes->DateTime,pMes->buf), OBuf, &Octet))!=0) - return rc; + /* Date/Time */ + if (Q931IsIEPresent(pMes->DateTime)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DATETIME](pTrunk, Q931GetIEPtr(pMes->DateTime,pMes->buf), OBuf, &Octet))!=0) + return rc; + } - /* Keypad Facility */ - if(Q931IsIEPresent(pMes->KeypadFac)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_KEYPAD_FACILITY](pTrunk, Q931GetIEPtr(pMes->KeypadFac,pMes->buf), OBuf, &Octet))!=0) - return rc; + /* Keypad Facility */ + if (Q931IsIEPresent(pMes->KeypadFac)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_KEYPAD_FACILITY](pTrunk, Q931GetIEPtr(pMes->KeypadFac,pMes->buf), OBuf, &Octet))!=0) + return rc; + } - /* Signal */ - if(Q931IsIEPresent(pMes->Signal)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet))!=0) - return rc; + /* Signal */ + if (Q931IsIEPresent(pMes->Signal)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet))!=0) + return rc; + } - /* Calling Party Number */ - if(Q931IsIEPresent(pMes->CallingNum)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CallingNum,pMes->buf), OBuf, &Octet))!=0) - return rc; + /* Calling Party Number */ + if (Q931IsIEPresent(pMes->CallingNum)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CallingNum,pMes->buf), OBuf, &Octet))!=0) + return rc; + } - /* Calling Party Subaddress */ - if(Q931IsIEPresent(pMes->CallingSub)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CallingSub,pMes->buf), OBuf, &Octet))!=0) - return rc; + /* Calling Party Subaddress */ + if (Q931IsIEPresent(pMes->CallingSub)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CallingSub,pMes->buf), OBuf, &Octet))!=0) + return rc; + } - /* Called Party number */ - if(Q931IsIEPresent(pMes->CalledNum)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CalledNum,pMes->buf), OBuf, &Octet))!=0) - return rc; + /* Called Party number */ + if (Q931IsIEPresent(pMes->CalledNum)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CalledNum,pMes->buf), OBuf, &Octet))!=0) + return rc; + } - /* Called party subaddress */ - if(Q931IsIEPresent(pMes->CalledSub)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CalledSub,pMes->buf), OBuf, &Octet))!=0) - return rc; + /* Called party subaddress */ + if (Q931IsIEPresent(pMes->CalledSub)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CalledSub,pMes->buf), OBuf, &Octet))!=0) + return rc; + } - /* Transit network selection */ - if(Q931IsIEPresent(pMes->TransNetSel)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_TRANSIT_NETWORK_SELECTION](pTrunk, Q931GetIEPtr(pMes->TransNetSel,pMes->buf), OBuf, &Octet))!=0) - return rc; + /* Transit network selection */ + if (Q931IsIEPresent(pMes->TransNetSel)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_TRANSIT_NETWORK_SELECTION](pTrunk, Q931GetIEPtr(pMes->TransNetSel,pMes->buf), OBuf, &Octet))!=0) + return rc; + } - /* Repeat Indicator */ - if(Q931IsIEPresent(pMes->LLRepeatInd)) - rc = Q931E_UNKNOWN_IE;/* TODO */ + /* Repeat Indicator */ + if (Q931IsIEPresent(pMes->LLRepeatInd)) { + rc = Q931E_UNKNOWN_IE;/* TODO */ + } - /* Low Layer Compatibility */ - if(Q931IsIEPresent(pMes->LLComp)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_LOW_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->LLComp,pMes->buf), OBuf, &Octet))!=0) - return rc; + /* Low Layer Compatibility */ + if (Q931IsIEPresent(pMes->LLComp)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_LOW_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->LLComp,pMes->buf), OBuf, &Octet))!=0) + return rc; + } - /* High Layer Compatibility */ - if(Q931IsIEPresent(pMes->HLComp)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet))!=0) - return rc; + /* High Layer Compatibility */ + if (Q931IsIEPresent(pMes->HLComp)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet))!=0) + return rc; + } - *OSize = Octet; - - return rc; + *OSize = Octet; + return rc; } /***************************************************************************** - Function: ATT5ESSUmes_0x0f + Function: ATT5ESSUmes_0x0f *****************************************************************************/ L3INT ATT5ESSUmes_0x0f(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - if (mes->ProtDisc == 8) { - return Q931Umes_ConnectAck(pTrunk, IBuf, mes, IOff, Size); - } + if (mes->ProtDisc == 8) { + return Q931Umes_ConnectAck(pTrunk, IBuf, mes, IOff, Size); + } - if (mes->ProtDisc == 3) { - return Q931Umes_Service(pTrunk, IBuf, mes, IOff, Size); - } + if (mes->ProtDisc == 3) { + return Q931Umes_Service(pTrunk, IBuf, mes, IOff, Size); + } - return Q931E_UNKNOWN_MESSAGE; + return Q931E_UNKNOWN_MESSAGE; } /***************************************************************************** - Function: ATT5ESSPmes_0x0f + Function: ATT5ESSPmes_0x0f *****************************************************************************/ L3INT ATT5ESSPmes_0x0f(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - Q931mes_Generic *mes = (Q931mes_Generic *)IBuf; + Q931mes_Generic *mes = (Q931mes_Generic *)IBuf; - if (mes->ProtDisc == 8) { - return Q931Pmes_ConnectAck(pTrunk, IBuf, ISize, OBuf, OSize); - } + if (mes->ProtDisc == 8) { + return Q931Pmes_ConnectAck(pTrunk, IBuf, ISize, OBuf, OSize); + } - if (mes->ProtDisc == 3) { - return Q931Pmes_Service(pTrunk, IBuf, ISize, OBuf, OSize); - } + if (mes->ProtDisc == 3) { + return Q931Pmes_Service(pTrunk, IBuf, ISize, OBuf, OSize); + } - return Q931E_UNKNOWN_MESSAGE; + return Q931E_UNKNOWN_MESSAGE; } /***************************************************************************** - Function: ATT5ESSUmes_0x07 + Function: ATT5ESSUmes_0x07 *****************************************************************************/ L3INT ATT5ESSUmes_0x07(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - if (mes->ProtDisc == 8) { - return Q931Umes_Connect(pTrunk, IBuf, mes, IOff, Size); - } + if (mes->ProtDisc == 8) { + return Q931Umes_Connect(pTrunk, IBuf, mes, IOff, Size); + } - if (mes->ProtDisc == 3) { - return Q931Umes_ServiceAck(pTrunk, IBuf, mes, IOff, Size); - } + if (mes->ProtDisc == 3) { + return Q931Umes_ServiceAck(pTrunk, IBuf, mes, IOff, Size); + } - return Q931E_UNKNOWN_MESSAGE; + return Q931E_UNKNOWN_MESSAGE; } /***************************************************************************** - Function: ATT5ESSPmes_0x07 + Function: ATT5ESSPmes_0x07 *****************************************************************************/ L3INT ATT5ESSPmes_0x07(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - Q931mes_Generic *mes = (Q931mes_Generic *)IBuf; + Q931mes_Generic *mes = (Q931mes_Generic *)IBuf; - if (mes->ProtDisc == 8) { - return Q931Pmes_Connect(pTrunk, IBuf, ISize, OBuf, OSize); - } + if (mes->ProtDisc == 8) { + return Q931Pmes_Connect(pTrunk, IBuf, ISize, OBuf, OSize); + } - if (mes->ProtDisc == 3) { - return Q931Pmes_ServiceAck(pTrunk, IBuf, ISize, OBuf, OSize); - } + if (mes->ProtDisc == 3) { + return Q931Pmes_ServiceAck(pTrunk, IBuf, ISize, OBuf, OSize); + } - return Q931E_UNKNOWN_MESSAGE; + return Q931E_UNKNOWN_MESSAGE; } diff --git a/libs/freetdm/src/isdn/DMSStateNT.c b/libs/freetdm/src/isdn/DMSStateNT.c index 6c75029665..e8814ba8ef 100644 --- a/libs/freetdm/src/isdn/DMSStateNT.c +++ b/libs/freetdm/src/isdn/DMSStateNT.c @@ -22,12 +22,12 @@ modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of the Case Labs, Ltd nor the names of its contributors + * Neither the name of the Case Labs, Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -57,66 +57,66 @@ *****************************************************************************/ void DMSCreateNT(L3UCHAR i) { - Q931SetMesProc(Q931mes_ALERTING, i,Q931ProcAlertingNT, Q931Umes_Alerting, Q931Pmes_Alerting); - Q931SetMesProc(Q931mes_CALL_PROCEEDING, i,Q931ProcCallProceedingNT, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); - Q931SetMesProc(Q931mes_CONNECT, i,Q931ProcConnectNT, Q931Umes_Connect, Q931Pmes_Connect); - Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i,Q931ProcConnectAckNT, Q931Umes_ConnectAck, Q931Pmes_ConnectAck); - Q931SetMesProc(Q931mes_PROGRESS, i,Q931ProcProgressNT, Q931Umes_Progress, Q931Pmes_Progress); - Q931SetMesProc(Q931mes_SETUP, i,Q931ProcSetupNT, DMSUmes_Setup, DMSPmes_Setup); - Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i,Q931ProcSetupAckNT, Q931Umes_SetupAck, Q931Pmes_SetupAck); - Q931SetMesProc(Q931mes_RESUME, i,Q931ProcResumeNT, Q931Umes_Resume, Q931Pmes_Resume); - Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i,Q931ProcResumeAckNT, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); - Q931SetMesProc(Q931mes_RESUME_REJECT, i,Q931ProcResumeRejectNT, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); - Q931SetMesProc(Q931mes_SUSPEND, i,Q931ProcSuspendNT, Q931Umes_Suspend, Q931Pmes_Suspend); - Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i,Q931ProcSuspendAckNT, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); - Q931SetMesProc(Q931mes_SUSPEND_REJECT, i,Q931ProcSuspendRejectNT, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); - Q931SetMesProc(Q931mes_USER_INFORMATION, i,Q931ProcUserInformationNT, Q931Umes_UserInformation, Q931Pmes_UserInformation); - Q931SetMesProc(Q931mes_DISCONNECT, i,Q931ProcDisconnectNT, Q931Umes_Disconnect, Q931Pmes_Disconnect); - Q931SetMesProc(Q931mes_RELEASE, i,Q931ProcReleaseNT, Q931Umes_Release, Q931Pmes_Release); - Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i,Q931ProcReleaseCompleteNT, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); - Q931SetMesProc(Q931mes_RESTART, i,Q931ProcRestartNT, Q931Umes_Restart, Q931Pmes_Restart); - Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i,Q931ProcRestartAckNT, Q931Umes_RestartAck, Q931Pmes_RestartAck); - Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i,Q931ProcCongestionControlNT, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); - Q931SetMesProc(Q931mes_INFORMATION, i,Q931ProcInformationNT, Q931Umes_Information, Q931Pmes_Information); - Q931SetMesProc(Q931mes_NOTIFY, i,Q931ProcNotifyNT, Q931Umes_Notify, Q931Pmes_Notify); - Q931SetMesProc(Q931mes_STATUS, i,Q931ProcStatusNT, Q931Umes_Status, Q931Pmes_Status); - Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i,Q931ProcStatusEnquiryNT, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); - Q931SetMesProc(Q931mes_SEGMENT, i,Q931ProcSegmentNT, Q931Umes_Segment, Q931Pmes_Segment); + Q931SetMesProc(Q931mes_ALERTING, i, Q931ProcAlertingNT, Q931Umes_Alerting, Q931Pmes_Alerting); + Q931SetMesProc(Q931mes_CALL_PROCEEDING, i, Q931ProcCallProceedingNT, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); + Q931SetMesProc(Q931mes_CONNECT, i, Q931ProcConnectNT, Q931Umes_Connect, Q931Pmes_Connect); + Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i, Q931ProcConnectAckNT, Q931Umes_ConnectAck, Q931Pmes_ConnectAck); + Q931SetMesProc(Q931mes_PROGRESS, i, Q931ProcProgressNT, Q931Umes_Progress, Q931Pmes_Progress); + Q931SetMesProc(Q931mes_SETUP, i, Q931ProcSetupNT, DMSUmes_Setup, DMSPmes_Setup); + Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i, Q931ProcSetupAckNT, Q931Umes_SetupAck, Q931Pmes_SetupAck); + Q931SetMesProc(Q931mes_RESUME, i, Q931ProcResumeNT, Q931Umes_Resume, Q931Pmes_Resume); + Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i, Q931ProcResumeAckNT, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); + Q931SetMesProc(Q931mes_RESUME_REJECT, i, Q931ProcResumeRejectNT, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); + Q931SetMesProc(Q931mes_SUSPEND, i, Q931ProcSuspendNT, Q931Umes_Suspend, Q931Pmes_Suspend); + Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i, Q931ProcSuspendAckNT, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); + Q931SetMesProc(Q931mes_SUSPEND_REJECT, i, Q931ProcSuspendRejectNT, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); + Q931SetMesProc(Q931mes_USER_INFORMATION, i, Q931ProcUserInformationNT, Q931Umes_UserInformation, Q931Pmes_UserInformation); + Q931SetMesProc(Q931mes_DISCONNECT, i, Q931ProcDisconnectNT, Q931Umes_Disconnect, Q931Pmes_Disconnect); + Q931SetMesProc(Q931mes_RELEASE, i, Q931ProcReleaseNT, Q931Umes_Release, Q931Pmes_Release); + Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i, Q931ProcReleaseCompleteNT, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); + Q931SetMesProc(Q931mes_RESTART, i, Q931ProcRestartNT, Q931Umes_Restart, Q931Pmes_Restart); + Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i, Q931ProcRestartAckNT, Q931Umes_RestartAck, Q931Pmes_RestartAck); + Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i, Q931ProcCongestionControlNT, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); + Q931SetMesProc(Q931mes_INFORMATION, i, Q931ProcInformationNT, Q931Umes_Information, Q931Pmes_Information); + Q931SetMesProc(Q931mes_NOTIFY, i, Q931ProcNotifyNT, Q931Umes_Notify, Q931Pmes_Notify); + Q931SetMesProc(Q931mes_STATUS, i, Q931ProcStatusNT, Q931Umes_Status, Q931Pmes_Status); + Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i, Q931ProcStatusEnquiryNT, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); + Q931SetMesProc(Q931mes_SEGMENT, i, Q931ProcSegmentNT, Q931Umes_Segment, Q931Pmes_Segment); - Q931SetMesProc(Q932mes_FACILITY, i,Q932ProcFacilityNT, Q932Umes_Facility, Q932Pmes_Facility); - Q931SetMesProc(Q932mes_HOLD, i,Q932ProcHoldNT, Q932Umes_Hold, Q932Pmes_Hold); - Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i,Q932ProcHoldAckNT, Q932Umes_HoldAck, Q932Pmes_HoldAck); - Q931SetMesProc(Q932mes_HOLD_REJECT, i,Q932ProcHoldRejectNT, Q932Umes_HoldReject, Q932Pmes_HoldReject); - Q931SetMesProc(Q932mes_REGISTER, i,Q932ProcRegisterNT, Q932Umes_Register, Q932Pmes_Register); - Q931SetMesProc(Q932mes_RETRIEVE, i,Q932ProcRetrieveNT, Q932Umes_Retrieve, Q932Pmes_Retrieve); - Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE,i,Q932ProcRetrieveAckNT, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); - Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i,Q932ProcRetrieveRejectNT, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); + Q931SetMesProc(Q932mes_FACILITY, i, Q932ProcFacilityNT, Q932Umes_Facility, Q932Pmes_Facility); + Q931SetMesProc(Q932mes_HOLD, i, Q932ProcHoldNT, Q932Umes_Hold, Q932Pmes_Hold); + Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i, Q932ProcHoldAckNT, Q932Umes_HoldAck, Q932Pmes_HoldAck); + Q931SetMesProc(Q932mes_HOLD_REJECT, i, Q932ProcHoldRejectNT, Q932Umes_HoldReject, Q932Pmes_HoldReject); + Q931SetMesProc(Q932mes_REGISTER, i, Q932ProcRegisterNT, Q932Umes_Register, Q932Pmes_Register); + Q931SetMesProc(Q932mes_RETRIEVE, i, Q932ProcRetrieveNT, Q932Umes_Retrieve, Q932Pmes_Retrieve); + Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE, i, Q932ProcRetrieveAckNT, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); + Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i, Q932ProcRetrieveRejectNT, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); /* Set up the IE encoder/decoder handle table.*/ - Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i,Q931Pie_Segment, Q931Uie_Segment); - Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i,Q931Pie_BearerCap, Q931Uie_BearerCap); - Q931SetIEProc(Q931ie_CAUSE, i,Q931Pie_Cause, Q931Uie_Cause); - Q931SetIEProc(Q931ie_CALL_IDENTITY, i,Q931Pie_CallID, Q931Uie_CallID); - Q931SetIEProc(Q931ie_CALL_STATE, i,Q931Pie_CallState, Q931Uie_CallState); - Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i,Q931Pie_ChanID, Q931Uie_ChanID); - Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i,Q931Pie_ProgInd, Q931Uie_ProgInd); - Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i,Q931Pie_NetFac, Q931Uie_NetFac); - Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i,Q931Pie_NotifInd, Q931Uie_NotifInd); - Q931SetIEProc(Q931ie_DISPLAY, i,Q931Pie_Display, Q931Uie_Display); - Q931SetIEProc(Q931ie_DATETIME, i,Q931Pie_DateTime, Q931Uie_DateTime); - Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i,Q931Pie_KeypadFac, Q931Uie_KeypadFac); - Q931SetIEProc(Q931ie_SIGNAL, i,Q931Pie_Signal, Q931Uie_Signal); - Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i,Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i,Q931Pie_CallingNum, Q931Uie_CallingNum); - Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i,Q931Pie_CallingSub, Q931Uie_CallingSub); - Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i,Q931Pie_CalledNum, Q931Uie_CalledNum); - Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i,Q931Pie_CalledSub, Q931Uie_CalledSub); - Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i,Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_RESTART_INDICATOR, i,Q931Pie_RestartInd, Q931Uie_RestartInd); - Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i,Q931Pie_LLComp, Q931Uie_LLComp); - Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i,Q931Pie_HLComp, Q931Uie_HLComp); - Q931SetIEProc(Q931ie_USER_USER, i,Q931Pie_UserUser, Q931Uie_UserUser); - Q931SetIEProc(Q931ie_GENERIC_DIGITS, i,Q931Pie_GenericDigits, Q931Uie_GenericDigits); + Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i, Q931Pie_Segment, Q931Uie_Segment); + Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i, Q931Pie_BearerCap, Q931Uie_BearerCap); + Q931SetIEProc(Q931ie_CAUSE, i, Q931Pie_Cause, Q931Uie_Cause); + Q931SetIEProc(Q931ie_CALL_IDENTITY, i, Q931Pie_CallID, Q931Uie_CallID); + Q931SetIEProc(Q931ie_CALL_STATE, i, Q931Pie_CallState, Q931Uie_CallState); + Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i, Q931Pie_ChanID, Q931Uie_ChanID); + Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i, Q931Pie_ProgInd, Q931Uie_ProgInd); + Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i, Q931Pie_NetFac, Q931Uie_NetFac); + Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i, Q931Pie_NotifInd, Q931Uie_NotifInd); + Q931SetIEProc(Q931ie_DISPLAY, i, Q931Pie_Display, Q931Uie_Display); + Q931SetIEProc(Q931ie_DATETIME, i, Q931Pie_DateTime, Q931Uie_DateTime); + Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i, Q931Pie_KeypadFac, Q931Uie_KeypadFac); + Q931SetIEProc(Q931ie_SIGNAL, i, Q931Pie_Signal, Q931Uie_Signal); + Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); + Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i, Q931Pie_CallingNum, Q931Uie_CallingNum); + Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i, Q931Pie_CallingSub, Q931Uie_CallingSub); + Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i, Q931Pie_CalledNum, Q931Uie_CalledNum); + Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i, Q931Pie_CalledSub, Q931Uie_CalledSub); + Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); + Q931SetIEProc(Q931ie_RESTART_INDICATOR, i, Q931Pie_RestartInd, Q931Uie_RestartInd); + Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i, Q931Pie_LLComp, Q931Uie_LLComp); + Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i, Q931Pie_HLComp, Q931Uie_HLComp); + Q931SetIEProc(Q931ie_USER_USER, i, Q931Pie_UserUser, Q931Uie_UserUser); + Q931SetIEProc(Q931ie_GENERIC_DIGITS, i, Q931Pie_GenericDigits, Q931Uie_GenericDigits); /* The following define a state machine. The point is that the Message */ /* procs can when search this to find out if the message/state */ diff --git a/libs/freetdm/src/isdn/DMSStateTE.c b/libs/freetdm/src/isdn/DMSStateTE.c index 8c435fa8c2..5de657d7d9 100644 --- a/libs/freetdm/src/isdn/DMSStateTE.c +++ b/libs/freetdm/src/isdn/DMSStateTE.c @@ -4,18 +4,18 @@ Contents: DMS-100 ISDN State Engine for TE (User Mode). - The controlling state engine for Q.931 is the state engine - on the NT side. The state engine on the TE side is a slave - of this. The TE side maintain it's own states as described in - ITU-T Q931, but will in raise conditions be overridden by - the NT side. + The controlling state engine for Q.931 is the state engine + on the NT side. The state engine on the TE side is a slave + of this. The TE side maintain it's own states as described in + ITU-T Q931, but will in raise conditions be overridden by + the NT side. - This reference implementation uses a process per message, - meaning that each message must check call states. This - is easier for dialect maintenance as each message proc - can be replaced individually. A new TE variant only - need to copy the Q931CreateTE and replace those procs or - need to override. + This reference implementation uses a process per message, + meaning that each message must check call states. This + is easier for dialect maintenance as each message proc + can be replaced individually. A new TE variant only + need to copy the Q931CreateTE and replace those procs or + need to override. License/Copyright: @@ -29,12 +29,12 @@ modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of the Case Labs, Ltd nor the names of its contributors + * Neither the name of the Case Labs, Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -65,149 +65,149 @@ extern L3INT Q931L4HeaderSpace; *****************************************************************************/ void DMSCreateTE(L3UCHAR i) { - Q931SetMesProc(Q931mes_ALERTING, i,Q931ProcAlertingTE, Q931Umes_Alerting, Q931Pmes_Alerting); - Q931SetMesProc(Q931mes_CALL_PROCEEDING, i,Q931ProcCallProceedingTE, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); - Q931SetMesProc(Q931mes_CONNECT, i,DMSProc0x07TE, DMSUmes_0x07, DMSPmes_0x07); - Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i,DMSProc0x0fTE, DMSUmes_0x0f, DMSPmes_0x0f); - Q931SetMesProc(Q931mes_PROGRESS, i,Q931ProcProgressTE, Q931Umes_Progress, Q931Pmes_Progress); - Q931SetMesProc(Q931mes_SETUP, i,Q931ProcSetupTE, DMSUmes_Setup, DMSPmes_Setup); - Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i,Q931ProcSetupAckTE, Q931Umes_SetupAck, Q931Pmes_SetupAck); - Q931SetMesProc(Q931mes_RESUME, i,Q931ProcResumeTE, Q931Umes_Resume, Q931Pmes_Resume); - Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i,Q931ProcResumeAckTE, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); - Q931SetMesProc(Q931mes_RESUME_REJECT, i,Q931ProcResumeRejectTE, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); - Q931SetMesProc(Q931mes_SUSPEND, i,Q931ProcSuspendTE, Q931Umes_Suspend, Q931Pmes_Suspend); - Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i,Q931ProcSuspendAckTE, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); - Q931SetMesProc(Q931mes_SUSPEND_REJECT, i,Q931ProcSuspendRejectTE, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); - Q931SetMesProc(Q931mes_USER_INFORMATION, i,Q931ProcUserInformationTE, Q931Umes_UserInformation, Q931Pmes_UserInformation); - Q931SetMesProc(Q931mes_DISCONNECT, i,Q931ProcDisconnectTE, Q931Umes_Disconnect, Q931Pmes_Disconnect); - Q931SetMesProc(Q931mes_RELEASE, i,Q931ProcReleaseTE, Q931Umes_Release, Q931Pmes_Release); - Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i,Q931ProcReleaseCompleteTE, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); - Q931SetMesProc(Q931mes_RESTART, i,Q931ProcRestartTE, Q931Umes_Restart, Q931Pmes_Restart); - Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i,Q931ProcRestartAckTE, Q931Umes_RestartAck, Q931Pmes_RestartAck); - Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i,Q931ProcCongestionControlTE, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); - Q931SetMesProc(Q931mes_INFORMATION, i,Q931ProcInformationTE, Q931Umes_Information, Q931Pmes_Information); - Q931SetMesProc(Q931mes_NOTIFY, i,Q931ProcNotifyTE, Q931Umes_Notify, Q931Pmes_Notify); - Q931SetMesProc(Q931mes_STATUS, i,Q931ProcStatusTE, Q931Umes_Status, Q931Pmes_Status); - Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i,Q931ProcStatusEnquiryTE, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); - Q931SetMesProc(Q931mes_SEGMENT, i,Q931ProcSegmentTE, Q931Umes_Segment, Q931Pmes_Segment); + Q931SetMesProc(Q931mes_ALERTING, i, Q931ProcAlertingTE, Q931Umes_Alerting, Q931Pmes_Alerting); + Q931SetMesProc(Q931mes_CALL_PROCEEDING, i, Q931ProcCallProceedingTE, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); + Q931SetMesProc(Q931mes_CONNECT, i, DMSProc0x07TE, DMSUmes_0x07, DMSPmes_0x07); + Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i, DMSProc0x0fTE, DMSUmes_0x0f, DMSPmes_0x0f); + Q931SetMesProc(Q931mes_PROGRESS, i, Q931ProcProgressTE, Q931Umes_Progress, Q931Pmes_Progress); + Q931SetMesProc(Q931mes_SETUP, i, Q931ProcSetupTE, DMSUmes_Setup, DMSPmes_Setup); + Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i, Q931ProcSetupAckTE, Q931Umes_SetupAck, Q931Pmes_SetupAck); + Q931SetMesProc(Q931mes_RESUME, i, Q931ProcResumeTE, Q931Umes_Resume, Q931Pmes_Resume); + Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i, Q931ProcResumeAckTE, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); + Q931SetMesProc(Q931mes_RESUME_REJECT, i, Q931ProcResumeRejectTE, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); + Q931SetMesProc(Q931mes_SUSPEND, i, Q931ProcSuspendTE, Q931Umes_Suspend, Q931Pmes_Suspend); + Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i, Q931ProcSuspendAckTE, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); + Q931SetMesProc(Q931mes_SUSPEND_REJECT, i, Q931ProcSuspendRejectTE, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); + Q931SetMesProc(Q931mes_USER_INFORMATION, i, Q931ProcUserInformationTE, Q931Umes_UserInformation, Q931Pmes_UserInformation); + Q931SetMesProc(Q931mes_DISCONNECT, i, Q931ProcDisconnectTE, Q931Umes_Disconnect, Q931Pmes_Disconnect); + Q931SetMesProc(Q931mes_RELEASE, i, Q931ProcReleaseTE, Q931Umes_Release, Q931Pmes_Release); + Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i, Q931ProcReleaseCompleteTE, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); + Q931SetMesProc(Q931mes_RESTART, i, Q931ProcRestartTE, Q931Umes_Restart, Q931Pmes_Restart); + Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i, Q931ProcRestartAckTE, Q931Umes_RestartAck, Q931Pmes_RestartAck); + Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i, Q931ProcCongestionControlTE, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); + Q931SetMesProc(Q931mes_INFORMATION, i, Q931ProcInformationTE, Q931Umes_Information, Q931Pmes_Information); + Q931SetMesProc(Q931mes_NOTIFY, i, Q931ProcNotifyTE, Q931Umes_Notify, Q931Pmes_Notify); + Q931SetMesProc(Q931mes_STATUS, i, Q931ProcStatusTE, Q931Umes_Status, Q931Pmes_Status); + Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i, Q931ProcStatusEnquiryTE, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); + Q931SetMesProc(Q931mes_SEGMENT, i, Q931ProcSegmentTE, Q931Umes_Segment, Q931Pmes_Segment); - Q931SetMesProc(Q932mes_FACILITY, i,Q932ProcFacilityTE, Q932Umes_Facility, Q932Pmes_Facility); - Q931SetMesProc(Q932mes_HOLD, i,Q932ProcHoldTE, Q932Umes_Hold, Q932Pmes_Hold); - Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i,Q932ProcHoldAckTE, Q932Umes_HoldAck, Q932Pmes_HoldAck); - Q931SetMesProc(Q932mes_HOLD_REJECT, i,Q932ProcHoldRejectTE, Q932Umes_HoldReject, Q932Pmes_HoldReject); - Q931SetMesProc(Q932mes_REGISTER, i,Q932ProcRegisterTE, Q932Umes_Register, Q932Pmes_Register); - Q931SetMesProc(Q932mes_RETRIEVE, i,Q932ProcRetrieveTE, Q932Umes_Retrieve, Q932Pmes_Retrieve); - Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE,i,Q932ProcRetrieveAckTE, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); - Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i,Q932ProcRetrieveRejectTE, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); + Q931SetMesProc(Q932mes_FACILITY, i, Q932ProcFacilityTE, Q932Umes_Facility, Q932Pmes_Facility); + Q931SetMesProc(Q932mes_HOLD, i, Q932ProcHoldTE, Q932Umes_Hold, Q932Pmes_Hold); + Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i, Q932ProcHoldAckTE, Q932Umes_HoldAck, Q932Pmes_HoldAck); + Q931SetMesProc(Q932mes_HOLD_REJECT, i, Q932ProcHoldRejectTE, Q932Umes_HoldReject, Q932Pmes_HoldReject); + Q931SetMesProc(Q932mes_REGISTER, i, Q932ProcRegisterTE, Q932Umes_Register, Q932Pmes_Register); + Q931SetMesProc(Q932mes_RETRIEVE, i, Q932ProcRetrieveTE, Q932Umes_Retrieve, Q932Pmes_Retrieve); + Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE, i, Q932ProcRetrieveAckTE, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); + Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i, Q932ProcRetrieveRejectTE, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); /* Set up the IE encoder/decoder handle table.*/ - Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i,Q931Pie_Segment, Q931Uie_Segment); - Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i,Q931Pie_BearerCap, Q931Uie_BearerCap); - Q931SetIEProc(Q931ie_CAUSE, i,Q931Pie_Cause, Q931Uie_Cause); - Q931SetIEProc(Q931ie_CALL_IDENTITY, i,Q931Pie_CallID, Q931Uie_CallID); - Q931SetIEProc(Q931ie_CALL_STATE, i,Q931Pie_CallState, Q931Uie_CallState); - Q931SetIEProc(Q931ie_CHANGE_STATUS, i,Q931Pie_ChangeStatus, Q931Uie_ChangeStatus); - Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i,Q931Pie_ChanID, Q931Uie_ChanID); - Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i,Q931Pie_ProgInd, Q931Uie_ProgInd); - Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i,Q931Pie_NetFac, Q931Uie_NetFac); - Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i,Q931Pie_NotifInd, Q931Uie_NotifInd); - Q931SetIEProc(Q931ie_DISPLAY, i,Q931Pie_Display, Q931Uie_Display); - Q931SetIEProc(Q931ie_DATETIME, i,Q931Pie_DateTime, Q931Uie_DateTime); - Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i,Q931Pie_KeypadFac, Q931Uie_KeypadFac); - Q931SetIEProc(Q931ie_SIGNAL, i,Q931Pie_Signal, Q931Uie_Signal); - Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i,Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i,Q931Pie_CallingNum, Q931Uie_CallingNum); - Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i,Q931Pie_CallingSub, Q931Uie_CallingSub); - Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i,Q931Pie_CalledNum, Q931Uie_CalledNum); - Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i,Q931Pie_CalledSub, Q931Uie_CalledSub); - Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i,Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_RESTART_INDICATOR, i,Q931Pie_RestartInd, Q931Uie_RestartInd); - Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i,Q931Pie_LLComp, Q931Uie_LLComp); - Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i,Q931Pie_HLComp, Q931Uie_HLComp); - Q931SetIEProc(Q931ie_USER_USER, i,Q931Pie_UserUser, Q931Uie_UserUser); - Q931SetIEProc(Q931ie_GENERIC_DIGITS, i,Q931Pie_GenericDigits, Q931Uie_GenericDigits); + Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i, Q931Pie_Segment, Q931Uie_Segment); + Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i, Q931Pie_BearerCap, Q931Uie_BearerCap); + Q931SetIEProc(Q931ie_CAUSE, i, Q931Pie_Cause, Q931Uie_Cause); + Q931SetIEProc(Q931ie_CALL_IDENTITY, i, Q931Pie_CallID, Q931Uie_CallID); + Q931SetIEProc(Q931ie_CALL_STATE, i, Q931Pie_CallState, Q931Uie_CallState); + Q931SetIEProc(Q931ie_CHANGE_STATUS, i, Q931Pie_ChangeStatus, Q931Uie_ChangeStatus); + Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i, Q931Pie_ChanID, Q931Uie_ChanID); + Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i, Q931Pie_ProgInd, Q931Uie_ProgInd); + Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i, Q931Pie_NetFac, Q931Uie_NetFac); + Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i, Q931Pie_NotifInd, Q931Uie_NotifInd); + Q931SetIEProc(Q931ie_DISPLAY, i, Q931Pie_Display, Q931Uie_Display); + Q931SetIEProc(Q931ie_DATETIME, i, Q931Pie_DateTime, Q931Uie_DateTime); + Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i, Q931Pie_KeypadFac, Q931Uie_KeypadFac); + Q931SetIEProc(Q931ie_SIGNAL, i, Q931Pie_Signal, Q931Uie_Signal); + Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); + Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i, Q931Pie_CallingNum, Q931Uie_CallingNum); + Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i, Q931Pie_CallingSub, Q931Uie_CallingSub); + Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i, Q931Pie_CalledNum, Q931Uie_CalledNum); + Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i, Q931Pie_CalledSub, Q931Uie_CalledSub); + Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); + Q931SetIEProc(Q931ie_RESTART_INDICATOR, i, Q931Pie_RestartInd, Q931Uie_RestartInd); + Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i, Q931Pie_LLComp, Q931Uie_LLComp); + Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i, Q931Pie_HLComp, Q931Uie_HLComp); + Q931SetIEProc(Q931ie_USER_USER, i, Q931Pie_UserUser, Q931Uie_UserUser); + Q931SetIEProc(Q931ie_GENERIC_DIGITS, i, Q931Pie_GenericDigits, Q931Uie_GenericDigits); /* The following define a state machine. The point is that the Message */ /* procs can when search this to find out if the message/state */ /* combination is legale. If not, the proc for unexpected message apply.*/ /* State 0 Idle */ - Q931AddStateEntry(i,Q931_U0, Q931mes_RESUME, 2); - Q931AddStateEntry(i,Q931_U0, Q931mes_SETUP, 4); - Q931AddStateEntry(i,Q931_U0, Q931mes_SETUP, 2); - Q931AddStateEntry(i,Q931_U0, Q931mes_STATUS, 4); - Q931AddStateEntry(i,Q931_U0, Q931mes_RELEASE, 4); - Q931AddStateEntry(i,Q931_U0, Q931mes_RELEASE_COMPLETE,4); + Q931AddStateEntry(i, Q931_U0, Q931mes_RESUME, 2); + Q931AddStateEntry(i, Q931_U0, Q931mes_SETUP, 4); + Q931AddStateEntry(i, Q931_U0, Q931mes_SETUP, 2); + Q931AddStateEntry(i, Q931_U0, Q931mes_STATUS, 4); + Q931AddStateEntry(i, Q931_U0, Q931mes_RELEASE, 4); + Q931AddStateEntry(i, Q931_U0, Q931mes_RELEASE_COMPLETE, 4); /* State 1 Call Initiating */ - Q931AddStateEntry(i,Q931_U1, Q931mes_DISCONNECT, 2); - Q931AddStateEntry(i,Q931_U1, Q931mes_SETUP_ACKNOWLEDGE, 4); - Q931AddStateEntry(i,Q931_U1, Q931mes_RELEASE_COMPLETE,4); - Q931AddStateEntry(i,Q931_U1, Q931mes_CALL_PROCEEDING, 4); - Q931AddStateEntry(i,Q931_U1, Q931mes_ALERTING, 4); - Q931AddStateEntry(i,Q931_U1, Q931mes_CONNECT, 4); + Q931AddStateEntry(i, Q931_U1, Q931mes_DISCONNECT, 2); + Q931AddStateEntry(i, Q931_U1, Q931mes_SETUP_ACKNOWLEDGE, 4); + Q931AddStateEntry(i, Q931_U1, Q931mes_RELEASE_COMPLETE, 4); + Q931AddStateEntry(i, Q931_U1, Q931mes_CALL_PROCEEDING, 4); + Q931AddStateEntry(i, Q931_U1, Q931mes_ALERTING, 4); + Q931AddStateEntry(i, Q931_U1, Q931mes_CONNECT, 4); /* State 2 Overlap Sending */ - Q931AddStateEntry(i,Q931_U2, Q931mes_INFORMATION, 2); - Q931AddStateEntry(i,Q931_U2, Q931mes_CALL_PROCEEDING, 4); - Q931AddStateEntry(i,Q931_U2, Q931mes_ALERTING, 4); - Q931AddStateEntry(i,Q931_U2, Q931mes_PROGRESS, 4); - Q931AddStateEntry(i,Q931_U2, Q931mes_CONNECT, 4); - Q931AddStateEntry(i,Q931_U2, Q931mes_RELEASE, 2); + Q931AddStateEntry(i, Q931_U2, Q931mes_INFORMATION, 2); + Q931AddStateEntry(i, Q931_U2, Q931mes_CALL_PROCEEDING, 4); + Q931AddStateEntry(i, Q931_U2, Q931mes_ALERTING, 4); + Q931AddStateEntry(i, Q931_U2, Q931mes_PROGRESS, 4); + Q931AddStateEntry(i, Q931_U2, Q931mes_CONNECT, 4); + Q931AddStateEntry(i, Q931_U2, Q931mes_RELEASE, 2); /* State 3 Outgoing Call Proceeding */ - Q931AddStateEntry(i,Q931_U3, Q931mes_PROGRESS, 4); - Q931AddStateEntry(i,Q931_U3, Q931mes_ALERTING, 4); - Q931AddStateEntry(i,Q931_U3, Q931mes_CONNECT, 4); - Q931AddStateEntry(i,Q931_U3, Q931mes_RELEASE, 2); + Q931AddStateEntry(i, Q931_U3, Q931mes_PROGRESS, 4); + Q931AddStateEntry(i, Q931_U3, Q931mes_ALERTING, 4); + Q931AddStateEntry(i, Q931_U3, Q931mes_CONNECT, 4); + Q931AddStateEntry(i, Q931_U3, Q931mes_RELEASE, 2); /* State 4 Call Delivered */ - Q931AddStateEntry(i,Q931_U4, Q931mes_CONNECT, 4); + Q931AddStateEntry(i, Q931_U4, Q931mes_CONNECT, 4); /* State 6 Call Precent */ - Q931AddStateEntry(i,Q931_U6, Q931mes_INFORMATION, 2); - Q931AddStateEntry(i,Q931_U6, Q931mes_ALERTING, 2); - Q931AddStateEntry(i,Q931_U6, Q931mes_CALL_PROCEEDING,2); - Q931AddStateEntry(i,Q931_U6, Q931mes_CONNECT, 2); - Q931AddStateEntry(i,Q931_U6, Q931mes_RELEASE_COMPLETE,2); - Q931AddStateEntry(i,Q931_U6, Q931mes_RELEASE, 4); - Q931AddStateEntry(i,Q931_U6, Q931mes_DISCONNECT, 4); + Q931AddStateEntry(i, Q931_U6, Q931mes_INFORMATION, 2); + Q931AddStateEntry(i, Q931_U6, Q931mes_ALERTING, 2); + Q931AddStateEntry(i, Q931_U6, Q931mes_CALL_PROCEEDING, 2); + Q931AddStateEntry(i, Q931_U6, Q931mes_CONNECT, 2); + Q931AddStateEntry(i, Q931_U6, Q931mes_RELEASE_COMPLETE, 2); + Q931AddStateEntry(i, Q931_U6, Q931mes_RELEASE, 4); + Q931AddStateEntry(i, Q931_U6, Q931mes_DISCONNECT, 4); /* State 7 Call Received */ - Q931AddStateEntry(i,Q931_U7, Q931mes_CONNECT, 2); + Q931AddStateEntry(i, Q931_U7, Q931mes_CONNECT, 2); /* State 8 Connect request */ - Q931AddStateEntry(i,Q931_U8, Q931mes_CONNECT_ACKNOWLEDGE, 4); + Q931AddStateEntry(i, Q931_U8, Q931mes_CONNECT_ACKNOWLEDGE, 4); /* State 9 Incoming Call Proceeding */ - Q931AddStateEntry(i,Q931_U9, Q931mes_CONNECT, 2); - Q931AddStateEntry(i,Q931_U9, Q931mes_ALERTING, 2); - Q931AddStateEntry(i,Q931_U9, Q931mes_PROGRESS, 2); + Q931AddStateEntry(i, Q931_U9, Q931mes_CONNECT, 2); + Q931AddStateEntry(i, Q931_U9, Q931mes_ALERTING, 2); + Q931AddStateEntry(i, Q931_U9, Q931mes_PROGRESS, 2); /* State 10 Active */ - Q931AddStateEntry(i,Q931_U10, Q931mes_SUSPEND, 2); - Q931AddStateEntry(i,Q931_U10, Q931mes_NOTIFY, 4); - Q931AddStateEntry(i,Q931_U10, Q931mes_NOTIFY, 2); + Q931AddStateEntry(i, Q931_U10, Q931mes_SUSPEND, 2); + Q931AddStateEntry(i, Q931_U10, Q931mes_NOTIFY, 4); + Q931AddStateEntry(i, Q931_U10, Q931mes_NOTIFY, 2); /* State 11 Disconnect Request */ - Q931AddStateEntry(i,Q931_U11, Q931mes_RELEASE, 4); - Q931AddStateEntry(i,Q931_U11, Q931mes_DISCONNECT, 4); - Q931AddStateEntry(i,Q931_U11, Q931mes_NOTIFY, 4); + Q931AddStateEntry(i, Q931_U11, Q931mes_RELEASE, 4); + Q931AddStateEntry(i, Q931_U11, Q931mes_DISCONNECT, 4); + Q931AddStateEntry(i, Q931_U11, Q931mes_NOTIFY, 4); /* State 12 Disconnect Ind */ - Q931AddStateEntry(i,Q931_U12, Q931mes_RELEASE, 4); - Q931AddStateEntry(i,Q931_U12, Q931mes_RELEASE, 2); + Q931AddStateEntry(i, Q931_U12, Q931mes_RELEASE, 4); + Q931AddStateEntry(i, Q931_U12, Q931mes_RELEASE, 2); /* State 15 Suspend Request */ - Q931AddStateEntry(i,Q931_U15, Q931mes_SUSPEND_ACKNOWLEDGE, 4); - Q931AddStateEntry(i,Q931_U15, Q931mes_SUSPEND_REJECT, 4); - Q931AddStateEntry(i,Q931_U15, Q931mes_DISCONNECT, 4); - Q931AddStateEntry(i,Q931_U15, Q931mes_RELEASE, 4); + Q931AddStateEntry(i, Q931_U15, Q931mes_SUSPEND_ACKNOWLEDGE, 4); + Q931AddStateEntry(i, Q931_U15, Q931mes_SUSPEND_REJECT, 4); + Q931AddStateEntry(i, Q931_U15, Q931mes_DISCONNECT, 4); + Q931AddStateEntry(i, Q931_U15, Q931mes_RELEASE, 4); /* TODO - Q931AddStateEntry(i,Q931_U17, - Q931AddStateEntry(i,Q931_U19, - Q931AddStateEntry(i,Q931_U25, + Q931AddStateEntry(i, Q931_U17, + Q931AddStateEntry(i, Q931_U19, + Q931AddStateEntry(i, Q931_U25, */ } @@ -218,36 +218,32 @@ void DMSCreateTE(L3UCHAR i) *****************************************************************************/ L3INT DMSProc0x0fTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; if (pMes->ProtDisc == 8) { /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ Q931StartTimer(pTrunk, callIndex, 303); } - if(iFrom == 4) - { + if (iFrom == 4) { /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { + else if (iFrom == 2) { /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + ret = Q931Tx34(pTrunk, buf, pMes->Size); if (pMes->ProtDisc == 3 && pTrunk->autoServiceAck) { Q931AckService(pTrunk, buf); } - } return ret; @@ -260,31 +256,28 @@ L3INT DMSProc0x0fTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT DMSProc0x07TE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; if (pMes->ProtDisc == 8) { /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ Q931StartTimer(pTrunk, callIndex, 303); } - if(iFrom == 4) - { + if (iFrom == 4) { /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { + else if (iFrom == 2) { /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; diff --git a/libs/freetdm/src/isdn/DMSmes.c b/libs/freetdm/src/isdn/DMSmes.c index b32664b767..3ce82f2ded 100644 --- a/libs/freetdm/src/isdn/DMSmes.c +++ b/libs/freetdm/src/isdn/DMSmes.c @@ -1,13 +1,13 @@ /***************************************************************************** - FileName: DMSmes.c + FileName: DMSmes.c - Contents: Pack/Unpack functions. These functions will unpack a DMS-100 ISDN - message from the bit packed original format into structs - that contains variables sized by the user. It will also pack - the struct back into a Q.931 message as required. + Contents: Pack/Unpack functions. These functions will unpack a DMS-100 ISDN + message from the bit packed original format into structs + that contains variables sized by the user. It will also pack + the struct back into a Q.931 message as required. - See national.h for description. + See national.h for description. License/Copyright: @@ -21,12 +21,12 @@ modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of the Case Labs, Ltd nor the names of its contributors + * Neither the name of the Case Labs, Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -48,19 +48,18 @@ /***************************************************************************** - Function: DMSUmes_Setup + Function: DMSUmes_Setup *****************************************************************************/ L3INT DMSUmes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT ir=0; - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; + L3INT ir = 0; + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; L3UCHAR last_codeset = 0, codeset = 0; L3UCHAR shift_lock = 1; - while(IOff < Size) - { + while (IOff < Size) { if (!shift_lock) { codeset = last_codeset; } @@ -75,8 +74,7 @@ L3INT DMSUmes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *me } if (codeset == 0) { - switch(IBuf[IOff]) - { + switch (IBuf[IOff]) { case Q931ie_SENDING_COMPLETE: case Q931ie_BEARER_CAPABILITY: case Q931ie_CHANNEL_IDENTIFICATION: @@ -94,11 +92,11 @@ L3INT DMSUmes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *me case Q931ie_LOW_LAYER_COMPATIBILITY: case Q931ie_HIGH_LAYER_COMPATIBILITY: rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; case Q931ie_REPEAT_INDICATOR: - if(ir < 2) { + if (ir < 2) { rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); ir++; } else { @@ -110,11 +108,10 @@ L3INT DMSUmes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *me break; } } else if (codeset == 6) { - switch(IBuf[IOff]) - { + switch (IBuf[IOff]) { case Q931ie_GENERIC_DIGITS: rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; default: @@ -126,13 +123,13 @@ L3INT DMSUmes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *me return Q931E_ILLEGAL_IE; } } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: DMSPmes_Setup + Function: DMSPmes_Setup Decription: Pack a Q931mes_Generic into a real Q.931 message. The user will set up a SETUP message and issue this to the stack where it @@ -150,115 +147,129 @@ L3INT DMSUmes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *me *****************************************************************************/ L3INT DMSPmes_Setup(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3INT rc = Q931E_NO_ERROR; + L3INT rc = Q931E_NO_ERROR; Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; L3INT Octet = 0; /* Q931 Message Header */ Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - /* Sending Complete */ - if(Q931IsIEPresent(pMes->SendComplete)) + /* Sending Complete */ + if (Q931IsIEPresent(pMes->SendComplete)) { OBuf[Octet++] = (L3UCHAR)(pMes->SendComplete & 0x00ff); + } /* Repeat Indicator */ - if(Q931IsIEPresent(pMes->RepeatInd)) + if (Q931IsIEPresent(pMes->RepeatInd)) { OBuf[Octet++] = (L3UCHAR)(pMes->RepeatInd & 0x00ff); + } /* Bearer capability */ - if(Q931IsIEPresent(pMes->BearerCap)) - { - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->BearerCap)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet)) != 0) return rc; - } - else - { - rc=Q931E_BEARERCAP; + } else { + rc = Q931E_BEARERCAP; } /* Channel Identification */ - if(Q931IsIEPresent(pMes->ChanID)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->ChanID)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Progress indicator */ - if(Q931IsIEPresent(pMes->ProgInd)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->ProgInd)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Network spesific facilities */ - if(Q931IsIEPresent(pMes->NetFac)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_NETWORK_SPECIFIC_FACILITIES](pTrunk, Q931GetIEPtr(pMes->NetFac,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->NetFac)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_NETWORK_SPECIFIC_FACILITIES](pTrunk, Q931GetIEPtr(pMes->NetFac,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Display */ - if(Q931IsIEPresent(pMes->Display)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Display)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Date/Time */ - if(Q931IsIEPresent(pMes->DateTime)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DATETIME](pTrunk, Q931GetIEPtr(pMes->DateTime,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->DateTime)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DATETIME](pTrunk, Q931GetIEPtr(pMes->DateTime,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Keypad Facility */ - if(Q931IsIEPresent(pMes->KeypadFac)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_KEYPAD_FACILITY](pTrunk, Q931GetIEPtr(pMes->KeypadFac,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->KeypadFac)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_KEYPAD_FACILITY](pTrunk, Q931GetIEPtr(pMes->KeypadFac,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Signal */ - if(Q931IsIEPresent(pMes->Signal)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Signal)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Calling Party Number */ - if(Q931IsIEPresent(pMes->CallingNum)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CallingNum,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->CallingNum)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CallingNum,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Calling Party Subaddress */ - if(Q931IsIEPresent(pMes->CallingSub)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CallingSub,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->CallingSub)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CallingSub,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Called Party number */ - if(Q931IsIEPresent(pMes->CalledNum)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CalledNum,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->CalledNum)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CalledNum,pMes->buf), OBuf, &Octet)) != 0) return rc; + } + /* Called party subaddress */ - if(Q931IsIEPresent(pMes->CalledSub)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CalledSub,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->CalledSub)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CalledSub,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Transit network selection */ - if(Q931IsIEPresent(pMes->TransNetSel)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_TRANSIT_NETWORK_SELECTION](pTrunk, Q931GetIEPtr(pMes->TransNetSel,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->TransNetSel)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_TRANSIT_NETWORK_SELECTION](pTrunk, Q931GetIEPtr(pMes->TransNetSel,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Repeat Indicator */ - if(Q931IsIEPresent(pMes->LLRepeatInd)) + if (Q931IsIEPresent(pMes->LLRepeatInd)) { rc = Q931E_UNKNOWN_IE;/* TODO */ + } /* Low Layer Compatibility */ - if(Q931IsIEPresent(pMes->LLComp)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_LOW_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->LLComp,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->LLComp)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_LOW_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->LLComp,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* High Layer Compatibility */ - if(Q931IsIEPresent(pMes->HLComp)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->HLComp)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet)) != 0) return rc; + } *OSize = Octet; - - return rc; + return rc; } /***************************************************************************** - Function: DMSUmes_0x0f + Function: DMSUmes_0x0f *****************************************************************************/ L3INT DMSUmes_0x0f(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) @@ -276,7 +287,7 @@ L3INT DMSUmes_0x0f(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes /***************************************************************************** - Function: DMSPmes_0x0f + Function: DMSPmes_0x0f *****************************************************************************/ L3INT DMSPmes_0x0f(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) @@ -296,7 +307,7 @@ L3INT DMSPmes_0x0f(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, /***************************************************************************** - Function: DMSUmes_0x07 + Function: DMSUmes_0x07 *****************************************************************************/ L3INT DMSUmes_0x07(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) @@ -314,7 +325,7 @@ L3INT DMSUmes_0x07(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes /***************************************************************************** - Function: DMSPmes_0x07 + Function: DMSPmes_0x07 *****************************************************************************/ L3INT DMSPmes_0x07(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) diff --git a/libs/freetdm/src/isdn/EuroISDNStateNT.c b/libs/freetdm/src/isdn/EuroISDNStateNT.c index ccfaba0d16..6b26c91e04 100644 --- a/libs/freetdm/src/isdn/EuroISDNStateNT.c +++ b/libs/freetdm/src/isdn/EuroISDNStateNT.c @@ -4,11 +4,11 @@ Contents: EuroISDN State Engine for NT (Network Mode). - The controlling state engine for Q.931 is the state engine - on the NT side. The state engine on the TE side is a slave - of this. The TE side maintain it's own states as described in - ITU-T Q931, but will in raise conditions be overridden by - the NT side. + The controlling state engine for Q.931 is the state engine + on the NT side. The state engine on the TE side is a slave + of this. The TE side maintain it's own states as described in + ITU-T Q931, but will in raise conditions be overridden by + the NT side. License/Copyright: @@ -19,12 +19,12 @@ modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of the Case Labs, Ltd nor the names of its contributors + * Neither the name of the Case Labs, Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -42,5 +42,3 @@ *****************************************************************************/ #include "Q931.h" - - diff --git a/libs/freetdm/src/isdn/EuroISDNStateTE.c b/libs/freetdm/src/isdn/EuroISDNStateTE.c index 7b7433e567..ef6b39e8e5 100644 --- a/libs/freetdm/src/isdn/EuroISDNStateTE.c +++ b/libs/freetdm/src/isdn/EuroISDNStateTE.c @@ -4,11 +4,11 @@ Contents: EuroISDN State Engine for TE (User Mode). - The controlling state engine for Q.931 is the state engine - on the NT side. The state engine on the TE side is a slave - of this. The TE side maintain it's own states as described in - ITU-T Q931, but will in raise conditions be overridden by - the NT side. + The controlling state engine for Q.931 is the state engine + on the NT side. The state engine on the TE side is a slave + of this. The TE side maintain it's own states as described in + ITU-T Q931, but will in raise conditions be overridden by + the NT side. License/Copyright: @@ -19,12 +19,12 @@ modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of the Case Labs, Ltd nor the names of its contributors + * Neither the name of the Case Labs, Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/libs/freetdm/src/isdn/Q931.c b/libs/freetdm/src/isdn/Q931.c index 6591613d71..9b9b6331bd 100644 --- a/libs/freetdm/src/isdn/Q931.c +++ b/libs/freetdm/src/isdn/Q931.c @@ -1,9 +1,9 @@ /***************************************************************************** - FileName: Q931.c + FileName: Q931.c - Contents: Implementation of Q.931 stack main interface functions. - See q931.h for description. + Contents: Implementation of Q.931 stack main interface functions. + See q931.h for description. License/Copyright: @@ -14,14 +14,14 @@ modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Case Labs, Ltd nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the Case Labs, Ltd nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -71,11 +71,7 @@ q931pie_func_t *Q931Pie[Q931MAXDLCT][Q931MAXIE]; q931timeout_func_t *Q931Timeout[Q931MAXDLCT][Q931MAXTIMER]; q931timer_t Q931Timer[Q931MAXDLCT][Q931MAXTIMER]; -void (*Q931CreateDialectCB[Q931MAXDLCT]) (L3UCHAR iDialect)= -{ - NULL, - NULL -}; +void (*Q931CreateDialectCB[Q931MAXDLCT])(L3UCHAR iDialect) = { NULL, NULL }; Q931State Q931st[Q931MAXSTATE]; @@ -85,10 +81,10 @@ Q931State Q931st[Q931MAXSTATE]; *****************************************************************************/ -L3INT Q931L4HeaderSpace = {0}; /* header space to be ignoder/inserted */ - /* at head of each message. */ +L3INT Q931L4HeaderSpace = {0}; /* header space to be ignoder/inserted */ + /* at head of each message. */ -L3INT Q931L2HeaderSpace = {4}; /* Q921 header space, sapi, tei etc */ +L3INT Q931L2HeaderSpace = {4}; /* Q921 header space, sapi, tei etc */ /***************************************************************************** @@ -96,201 +92,195 @@ L3INT Q931L2HeaderSpace = {4}; /* Q921 header space, sapi, tei etc */ *****************************************************************************/ -Q931ErrorCB_t Q931ErrorProc; - /* callback for error messages. */ - -L3ULONG (*Q931GetTimeProc) (void) = NULL; /* callback for func reading time in ms */ +Q931ErrorCB_t Q931ErrorProc; /* callback for error messages. */ +L3ULONG (*Q931GetTimeProc) (void) = NULL; /* callback for func reading time in ms */ /***************************************************************************** - Function: Q931SetL4HeaderSpace + Function: Q931SetL4HeaderSpace Description: Set the # of bytes to be inserted/ignored at the head of - each message. Q931 will issue a message with space for header - and the user will use this to fill in whatever header info - is required to support the architecture used. + each message. Q931 will issue a message with space for header + and the user will use this to fill in whatever header info + is required to support the architecture used. *****************************************************************************/ void Q931SetL4HeaderSpace(L3INT space) { - Q931L4HeaderSpace = space; + Q931L4HeaderSpace = space; } /***************************************************************************** - Function: Q931SetL2HeaderSpace + Function: Q931SetL2HeaderSpace Description: Set the # of bytes to be inserted/ignored at the head of - each message. Q931 will issue a message with space for header - and the user will use this to fill in whatever header info - is required to support the architecture used. + each message. Q931 will issue a message with space for header + and the user will use this to fill in whatever header info + is required to support the architecture used. *****************************************************************************/ void Q931SetL2HeaderSpace(L3INT space) { - Q931L2HeaderSpace = space; + Q931L2HeaderSpace = space; } /***************************************************************************** - Function: Q931ProcDummy + Function: Q931ProcDummy Description: Dummy function for message processing. *****************************************************************************/ L3INT Q931ProcDummy(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b,L3INT c) { - return Q931E_INTERNAL; + return Q931E_INTERNAL; } /***************************************************************************** - Function: Q931UmesDummy + Function: Q931UmesDummy Description: Dummy function for message processing *****************************************************************************/ L3INT Q931UmesDummy(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT IOff, L3INT Size) { - return Q931E_UNKNOWN_MESSAGE; + return Q931E_UNKNOWN_MESSAGE; } /***************************************************************************** - Function: Q931UieDummy + Function: Q931UieDummy Description: Dummy function for message processing *****************************************************************************/ L3INT Q931UieDummy(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - return Q931E_UNKNOWN_IE; + return Q931E_UNKNOWN_IE; } /***************************************************************************** - Function: Q931PmesDummy + Function: Q931PmesDummy Description: Dummy function for message processing *****************************************************************************/ L3INT Q931PmesDummy(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - return Q931E_UNKNOWN_MESSAGE; + return Q931E_UNKNOWN_MESSAGE; } /***************************************************************************** - Function: Q931PieDummy + Function: Q931PieDummy Description: Dummy function for message processing *****************************************************************************/ L3INT Q931PieDummy(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - return Q931E_UNKNOWN_IE; + return Q931E_UNKNOWN_IE; } /***************************************************************************** - Function: Q931TxDummy + Function: Q931TxDummy Description: Dummy function for message processing *****************************************************************************/ L3INT Q931TxDummy(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b, L3INT n) { - return Q931E_MISSING_CB; + return Q931E_MISSING_CB; } /***************************************************************************** - Function: Q931ErrorDummy + Function: Q931ErrorDummy Description: Dummy function for error processing *****************************************************************************/ L3INT Q931ErrorDummy(void *priv, L3INT a, L3INT b, L3INT c) { - return 0; + return 0; } /***************************************************************************** - Function: Q931Initialize + Function: Q931Initialize Description: This function Initialize the stack. - Will set up the trunk array, channel - arrays and initialize Q931 function arrays before it finally - set up EuroISDN processing with User as dialect 0 and - Network as dialect 1. + Will set up the trunk array, channel + arrays and initialize Q931 function arrays before it finally + set up EuroISDN processing with User as dialect 0 and + Network as dialect 1. - Note: Initialization of other stacks should be inserted after - the initialization of EuroISDN. + Note: Initialization of other stacks should be inserted after + the initialization of EuroISDN. *****************************************************************************/ void Q931Initialize() { - L3INT x,y; + L3INT x,y; - /* Secure the callbacks to default procs */ - Q931ErrorProc = Q931ErrorDummy; + /* Secure the callbacks to default procs */ + Q931ErrorProc = Q931ErrorDummy; - /* The user will only add the message handlers and IE handlers he need, */ - /* so we need to initialize every single entry to a default function */ - /* that will throw an appropriate error if they are ever called. */ - for(x=0; x < Q931MAXDLCT; x++) - { - for(y=0; y < Q931MAXMES; y++) - { - Q931Proc[x][y] = Q931ProcDummy; - Q931Umes[x][y] = Q931UmesDummy; - Q931Pmes[x][y] = Q931PmesDummy; - } - for(y=0; y < Q931MAXIE; y++) - { - Q931Pie[x][y] = Q931PieDummy; - Q931Uie[x][y] = Q931UieDummy; - } - for(y=0; y < Q931MAXTIMER; y++) { - Q931Timeout[x][y] = Q931TimeoutDummy; - Q931Timer[x][y] = 0; + /* The user will only add the message handlers and IE handlers he need, + * so we need to initialize every single entry to a default function + * that will throw an appropriate error if they are ever called. + */ + for (x = 0; x < Q931MAXDLCT; x++) { + for (y = 0; y < Q931MAXMES; y++) { + Q931Proc[x][y] = Q931ProcDummy; + Q931Umes[x][y] = Q931UmesDummy; + Q931Pmes[x][y] = Q931PmesDummy; + } + for (y = 0; y < Q931MAXIE; y++) { + Q931Pie[x][y] = Q931PieDummy; + Q931Uie[x][y] = Q931UieDummy; + } + for (y = 0; y < Q931MAXTIMER; y++) { + Q931Timeout[x][y] = Q931TimeoutDummy; + Q931Timer[x][y] = 0; + } } - } - if(Q931CreateDialectCB[Q931_Dialect_Q931 + Q931_TE] == NULL) - Q931AddDialect(Q931_Dialect_Q931 + Q931_TE, Q931CreateTE); + if (Q931CreateDialectCB[Q931_Dialect_Q931 + Q931_TE] == NULL) + Q931AddDialect(Q931_Dialect_Q931 + Q931_TE, Q931CreateTE); - if(Q931CreateDialectCB[Q931_Dialect_Q931 + Q931_NT] == NULL) - Q931AddDialect(Q931_Dialect_Q931 + Q931_NT, Q931CreateNT); + if (Q931CreateDialectCB[Q931_Dialect_Q931 + Q931_NT] == NULL) + Q931AddDialect(Q931_Dialect_Q931 + Q931_NT, Q931CreateNT); - if(Q931CreateDialectCB[Q931_Dialect_National + Q931_TE] == NULL) - Q931AddDialect(Q931_Dialect_National + Q931_TE, nationalCreateTE); + if (Q931CreateDialectCB[Q931_Dialect_National + Q931_TE] == NULL) + Q931AddDialect(Q931_Dialect_National + Q931_TE, nationalCreateTE); - if(Q931CreateDialectCB[Q931_Dialect_National + Q931_NT] == NULL) - Q931AddDialect(Q931_Dialect_National + Q931_NT, nationalCreateNT); + if (Q931CreateDialectCB[Q931_Dialect_National + Q931_NT] == NULL) + Q931AddDialect(Q931_Dialect_National + Q931_NT, nationalCreateNT); - if(Q931CreateDialectCB[Q931_Dialect_DMS + Q931_TE] == NULL) - Q931AddDialect(Q931_Dialect_DMS + Q931_TE, DMSCreateTE); + if (Q931CreateDialectCB[Q931_Dialect_DMS + Q931_TE] == NULL) + Q931AddDialect(Q931_Dialect_DMS + Q931_TE, DMSCreateTE); - if(Q931CreateDialectCB[Q931_Dialect_DMS + Q931_NT] == NULL) - Q931AddDialect(Q931_Dialect_DMS + Q931_NT, DMSCreateNT); + if (Q931CreateDialectCB[Q931_Dialect_DMS + Q931_NT] == NULL) + Q931AddDialect(Q931_Dialect_DMS + Q931_NT, DMSCreateNT); - if(Q931CreateDialectCB[Q931_Dialect_5ESS + Q931_TE] == NULL) - Q931AddDialect(Q931_Dialect_5ESS + Q931_TE, ATT5ESSCreateTE); + if (Q931CreateDialectCB[Q931_Dialect_5ESS + Q931_TE] == NULL) + Q931AddDialect(Q931_Dialect_5ESS + Q931_TE, ATT5ESSCreateTE); - if(Q931CreateDialectCB[Q931_Dialect_5ESS + Q931_NT] == NULL) - Q931AddDialect(Q931_Dialect_5ESS + Q931_NT, ATT5ESSCreateNT); + if (Q931CreateDialectCB[Q931_Dialect_5ESS + Q931_NT] == NULL) + Q931AddDialect(Q931_Dialect_5ESS + Q931_NT, ATT5ESSCreateNT); - /* The last step we do is to call the callbacks to create the dialects */ - for(x=0; x < Q931MAXDLCT; x++) - { - if(Q931CreateDialectCB[x] != NULL) - { - Q931CreateDialectCB[x]((L3UCHAR)x); - } - } + /* The last step we do is to call the callbacks to create the dialects */ + for (x = 0; x < Q931MAXDLCT; x++) { + if (Q931CreateDialectCB[x] != NULL) { + Q931CreateDialectCB[x]((L3UCHAR)x); + } + } } /** @@ -304,20 +294,20 @@ void Q931TimerTick(Q931_TrunkInfo_t *pTrunk) L3ULONG now = 0; L3INT x; - /* TODO: Loop through all active calls, check timers and call timout procs - * if timers are expired. - * Implement a function array so each dialect can deal with their own - * timeouts. + /* TODO: Loop through all active calls, check timers and call timout procs + * if timers are expired. + * Implement a function array so each dialect can deal with their own + * timeouts. */ now = Q931GetTime(); - for(x = 0; x < Q931MAXCALLPERTRUNK; x++) { + for (x = 0; x < Q931MAXCALLPERTRUNK; x++) { call = &pTrunk->call[x]; - if(!call->InUse || !call->Timer || !call->TimerID) + if (!call->InUse || !call->Timer || !call->TimerID) continue; - if(call->Timer <= now) { + if (call->Timer <= now) { /* Stop Timer */ Q931StopTimer(pTrunk, x, call->TimerID); @@ -329,23 +319,23 @@ void Q931TimerTick(Q931_TrunkInfo_t *pTrunk) /***************************************************************************** - Function: Q931Rx23 + Function: Q931Rx23 Description: Receive message from layer 2 (LAPD). Receiving a message - is always done in 2 steps. First the message must be - interpreted and translated to a static struct. Secondly - the message is processed and responded to. + is always done in 2 steps. First the message must be + interpreted and translated to a static struct. Secondly + the message is processed and responded to. - The Q.931 message contains a static header that is - interpreted in this function. The rest is interpreted - in a sub function according to mestype. + The Q.931 message contains a static header that is + interpreted in this function. The rest is interpreted + in a sub function according to mestype. - Parameters: pTrunk [IN] Ptr to trunk info. - buf [IN] Ptr to buffer containing message. - Size [IN] Size of message. + Parameters: pTrunk [IN] Ptr to trunk info. + buf [IN] Ptr to buffer containing message. + Size [IN] Size of message. Return Value: Error Code. 0 = No Error, < 0 :error, > 0 : Warning - see q931errors.h for details. + see q931errors.h for details. *****************************************************************************/ L3INT Q931Rx23(Q931_TrunkInfo_t *pTrunk, L3INT ind, L3UCHAR tei, L3UCHAR * buf, L3INT Size) @@ -357,7 +347,7 @@ L3INT Q931Rx23(Q931_TrunkInfo_t *pTrunk, L3INT ind, L3UCHAR tei, L3UCHAR * buf, L3INT IOff = 0; L3INT L2HSize = Q931L2HeaderSpace; - switch(ind) { + switch (ind) { case Q921_DL_UNIT_DATA: /* DL-UNITDATA indication (UI frame, 3 byte header) */ L2HSize = 3; @@ -382,12 +372,12 @@ L3INT Q931Rx23(Q931_TrunkInfo_t *pTrunk, L3INT ind, L3UCHAR tei, L3UCHAR * buf, * a) doing Q.921 work in the lower levels (extracting the TEI ourselves) * b) adding a tei parameter to _all_ Proc functions */ - if(tei) { + if (tei) { L3INT callIndex = 0; /* Find the call using CRV */ RetCode = Q931FindCRV(pTrunk, m->CRV, &callIndex); - if(RetCode == Q931E_NO_ERROR && !pTrunk->call[callIndex].Tei) { + if (RetCode == Q931E_NO_ERROR && !pTrunk->call[callIndex].Tei) { pTrunk->call[callIndex].Tei = tei; } } @@ -396,8 +386,7 @@ L3INT Q931Rx23(Q931_TrunkInfo_t *pTrunk, L3INT ind, L3UCHAR tei, L3UCHAR * buf, m->MesType, m->CRVFlag, m->CRVFlag ? "Terminator" : "Originator", m->CRV, pTrunk->Dialect); RetCode = Q931Umes[pTrunk->Dialect][m->MesType](pTrunk, Mes, (Q931mes_Generic *)pTrunk->L3Buf, IOff, Size - L2HSize); - if(RetCode >= Q931E_NO_ERROR) - { + if (RetCode >= Q931E_NO_ERROR) { RetCode = Q931Proc[pTrunk->Dialect][m->MesType](pTrunk, pTrunk->L3Buf, 2); } break; @@ -411,70 +400,70 @@ L3INT Q931Rx23(Q931_TrunkInfo_t *pTrunk, L3INT ind, L3UCHAR tei, L3UCHAR * buf, /***************************************************************************** - Function: Q931Tx34 + Function: Q931Tx34 Description: Called from the stack to send a message to layer 4. - Parameters: Mes[IN] Ptr to message buffer. - Size[IN] Message size in bytes. + Parameters: Mes[IN] Ptr to message buffer. + Size[IN] Message size in bytes. Return Value: Error Code. 0 = No Error, < 0 :error, > 0 : Warning - see q931errors.h for details. + see q931errors.h for details. *****************************************************************************/ L3INT Q931Tx34(Q931_TrunkInfo_t *pTrunk, L3UCHAR * Mes, L3INT Size) { Q931Log(pTrunk, Q931_LOG_DEBUG, "Sending message to Layer4 (size: %d)\n", Size); - if (pTrunk->Q931Tx34CBProc) { - return pTrunk->Q931Tx34CBProc(pTrunk->PrivateData34, Mes, Size); - } - return Q931E_MISSING_CB; + if (pTrunk->Q931Tx34CBProc) { + return pTrunk->Q931Tx34CBProc(pTrunk->PrivateData34, Mes, Size); + } + return Q931E_MISSING_CB; } /***************************************************************************** - Function: Q931Rx43 + Function: Q931Rx43 Description: Receive message from Layer 4 (application). Parameters: pTrunk[IN] Trunk #. - buf[IN] Message Pointer. - Size[IN] Message size in bytes. + buf[IN] Message Pointer. + Size[IN] Message size in bytes. Return Value: Error Code. 0 = No Error, < 0 :error, > 0 : Warning - see q931errors.h for details. + see q931errors.h for details. *****************************************************************************/ L3INT Q931Rx43(Q931_TrunkInfo_t *pTrunk,L3UCHAR * buf, L3INT Size) { - Q931mes_Header *ptr = (Q931mes_Header*)&buf[Q931L4HeaderSpace]; - L3INT RetCode = Q931E_NO_ERROR; + Q931mes_Header *ptr = (Q931mes_Header*)&buf[Q931L4HeaderSpace]; + L3INT RetCode = Q931E_NO_ERROR; Q931Log(pTrunk, Q931_LOG_DEBUG, "Receiving message from Layer4 (size: %d, type: %d)\n", Size, ptr->MesType); - RetCode = Q931Proc[pTrunk->Dialect][ptr->MesType](pTrunk, buf, 4); + RetCode = Q931Proc[pTrunk->Dialect][ptr->MesType](pTrunk, buf, 4); Q931Log(pTrunk, Q931_LOG_DEBUG, "Q931Rx43 return code: %d\n", RetCode); - return RetCode; + return RetCode; } /***************************************************************************** - Function: Q931Tx32 + Function: Q931Tx32 Description: Called from the stack to send a message to L2. The input is - always a non-packed message so it will first make a proper - call to create a packed message before it transmits that - message to layer 2. + always a non-packed message so it will first make a proper + call to create a packed message before it transmits that + message to layer 2. Parameters: pTrunk[IN] Trunk # - buf[IN] Ptr to message buffer. - Size[IN] Message size in bytes. + buf[IN] Ptr to message buffer. + Size[IN] Message size in bytes. Return Value: Error Code. 0 = No Error, < 0 :error, > 0 : Warning - see q931errors.h for details. + see q931errors.h for details. *****************************************************************************/ L3INT Q931Tx32Data(Q931_TrunkInfo_t *pTrunk, L3UCHAR bcast, L3UCHAR * Mes, L3INT Size) @@ -491,15 +480,14 @@ L3INT Q931Tx32Data(Q931_TrunkInfo_t *pTrunk, L3UCHAR bcast, L3UCHAR * Mes, L3INT /* Call pack function through table. */ RetCode = Q931Pmes[iDialect][ptr->MesType](pTrunk, (Q931mes_Generic *)Mes, Size, &pTrunk->L2Buf[Offset], &OSize); - if(RetCode >= Q931E_NO_ERROR) - { + if (RetCode >= Q931E_NO_ERROR) { L3INT callIndex; L3UCHAR tei = 0; - if(ptr->CRV) { + if (ptr->CRV) { /* Find the call using CRV */ RetCode = Q931FindCRV(pTrunk, ptr->CRV, &callIndex); - if(RetCode != Q931E_NO_ERROR) + if (RetCode != Q931E_NO_ERROR) return RetCode; tei = pTrunk->call[callIndex].Tei; @@ -518,54 +506,53 @@ L3INT Q931Tx32Data(Q931_TrunkInfo_t *pTrunk, L3UCHAR bcast, L3UCHAR * Mes, L3INT /***************************************************************************** - Function: Q931SetError + Function: Q931SetError Description: Called from the stack to indicate an error. - Parameters: ErrID ID of ie or message causing error. - ErrPar1 Error parameter 1 - ErrPar2 Error parameter 2. + Parameters: ErrID ID of ie or message causing error. + ErrPar1 Error parameter 1 + ErrPar2 Error parameter 2. *****************************************************************************/ void Q931SetError(Q931_TrunkInfo_t *pTrunk,L3INT ErrID, L3INT ErrPar1, L3INT ErrPar2) { - if (pTrunk->Q931ErrorCBProc) { - pTrunk->Q931ErrorCBProc(pTrunk->PrivateData34, ErrID, ErrPar1, ErrPar2); - } else { - Q931ErrorProc(pTrunk->PrivateData34, ErrID, ErrPar1, ErrPar2); - } + if (pTrunk->Q931ErrorCBProc) { + pTrunk->Q931ErrorCBProc(pTrunk->PrivateData34, ErrID, ErrPar1, ErrPar2); + } else { + Q931ErrorProc(pTrunk->PrivateData34, ErrID, ErrPar1, ErrPar2); + } } void Q931SetDefaultErrorCB(Q931ErrorCB_t Q931ErrorPar) { - Q931ErrorProc = Q931ErrorPar; + Q931ErrorProc = Q931ErrorPar; } /***************************************************************************** - Function: Q931CreateCRV + Function: Q931CreateCRV Description: Create a CRV entry and return it's index. The function will - locate a free entry in the call tables allocate it and - allocate a unique CRV value attached to it. + locate a free entry in the call tables allocate it and + allocate a unique CRV value attached to it. - Parameters: pTrunk [IN] Trunk number - callindex [OUT] return call table index. + Parameters: pTrunk [IN] Trunk number + callindex [OUT] return call table index. Return Value: Error Code. 0 = No Error, < 0 :error, > 0 : Warning - see q931errors.h for details. - -*****************************************************************************/ -L3INT Q931CreateCRV(Q931_TrunkInfo_t *pTrunk, L3INT * callIndex) + see q931errors.h for details. +****************************************************************************/ +L3INT Q931CreateCRV(Q931_TrunkInfo_t *pTrunk, L3INT * callIndex) { - L3INT CRV = Q931GetUniqueCRV(pTrunk); + L3INT CRV = Q931GetUniqueCRV(pTrunk); - return Q931AllocateCRV(pTrunk, CRV, callIndex); + return Q931AllocateCRV(pTrunk, CRV, callIndex); } -L3INT Q931ReleaseCRV(Q931_TrunkInfo_t *pTrunk, L3INT CRV) +L3INT Q931ReleaseCRV(Q931_TrunkInfo_t *pTrunk, L3INT CRV) { int callIndex; @@ -579,66 +566,61 @@ L3INT Q931ReleaseCRV(Q931_TrunkInfo_t *pTrunk, L3INT CRV) /***************************************************************************** - Function: Q931AllocateCRV + Function: Q931AllocateCRV Description: Allocate a call table entry and assigns the given CRV value - to it. + to it. - Parameters: pTrunk [IN] Trunk number - iCRV [IN] Call Reference Value. - callindex [OUT] return call table index. + Parameters: pTrunk [IN] Trunk number + iCRV [IN] Call Reference Value. + callindex [OUT] return call table index. Return Value: Error Code. 0 = No Error, < 0 :error, > 0 : Warning - see q931errors.h for details. + see q931errors.h for details. *****************************************************************************/ -L3INT Q931AllocateCRV(Q931_TrunkInfo_t *pTrunk, L3INT iCRV, L3INT * callIndex) +L3INT Q931AllocateCRV(Q931_TrunkInfo_t *pTrunk, L3INT iCRV, L3INT * callIndex) { - L3INT x; - for(x=0; x < Q931MAXCALLPERTRUNK; x++) - { - if(!pTrunk->call[x].InUse) - { - pTrunk->call[x].CRV = iCRV; - pTrunk->call[x].BChan = 255; - pTrunk->call[x].State = 0; /* null state - idle */ - pTrunk->call[x].TimerID = 0; /* no timer running */ - pTrunk->call[x].Timer = 0; - pTrunk->call[x].InUse = 1; /* mark as used */ - *callIndex = x; - return Q931E_NO_ERROR; - } - } - return Q931E_TOMANYCALLS; + L3INT x; + for (x = 0; x < Q931MAXCALLPERTRUNK; x++) { + if (!pTrunk->call[x].InUse) { + pTrunk->call[x].CRV = iCRV; + pTrunk->call[x].BChan = 255; + pTrunk->call[x].State = 0; /* null state - idle */ + pTrunk->call[x].TimerID = 0; /* no timer running */ + pTrunk->call[x].Timer = 0; + pTrunk->call[x].InUse = 1; /* mark as used */ + *callIndex = x; + return Q931E_NO_ERROR; + } + } + return Q931E_TOMANYCALLS; } /***************************************************************************** - Function: Q931GetCallState + Function: Q931GetCallState Description: Look up CRV and return current call state. A non existing - CRV is the same as state zero (0). + CRV is the same as state zero (0). - Parameters: pTrunk [IN] Trunk number. - iCRV [IN] CRV + Parameters: pTrunk [IN] Trunk number. + iCRV [IN] CRV Return Value: Call State. *****************************************************************************/ -L3INT Q931GetCallState(Q931_TrunkInfo_t *pTrunk, L3INT iCRV) +L3INT Q931GetCallState(Q931_TrunkInfo_t *pTrunk, L3INT iCRV) { - L3INT x; - for(x=0; x < Q931MAXCALLPERTRUNK; x++) - { - if(pTrunk->call[x].InUse) - { - if(pTrunk->call[x].CRV == iCRV) - { - return pTrunk->call[x].State; - } - } - } - return 0; /* assume state zero for non existing CRV's */ + L3INT x; + for (x = 0; x < Q931MAXCALLPERTRUNK; x++) { + if (pTrunk->call[x].InUse) { + if (pTrunk->call[x].CRV == iCRV) { + return pTrunk->call[x].State; + } + } + } + return 0; /* assume state zero for non existing CRV's */ } /** @@ -653,11 +635,10 @@ L3INT Q931StartTimer(Q931_TrunkInfo_t *pTrunk, L3INT callIndex, L3USHORT iTimerI { L3ULONG duration = Q931Timer[pTrunk->Dialect][iTimerID]; - if(duration) { + if (duration) { pTrunk->call[callIndex].Timer = Q931GetTime() + duration; pTrunk->call[callIndex].TimerID = iTimerID; } - return 0; } @@ -671,7 +652,7 @@ L3INT Q931StartTimer(Q931_TrunkInfo_t *pTrunk, L3INT callIndex, L3USHORT iTimerI */ L3INT Q931StopTimer(Q931_TrunkInfo_t *pTrunk, L3INT callindex, L3USHORT iTimerID) { - if(pTrunk->call[callindex].TimerID == iTimerID) + if (pTrunk->call[callindex].TimerID == iTimerID) pTrunk->call[callindex].TimerID = 0; return 0; @@ -679,148 +660,137 @@ L3INT Q931StopTimer(Q931_TrunkInfo_t *pTrunk, L3INT callindex, L3USHORT iTimerID L3INT Q931SetState(Q931_TrunkInfo_t *pTrunk, L3INT callIndex, L3INT iState) { - pTrunk->call[callIndex].State = iState; + pTrunk->call[callIndex].State = iState; - return 0; + return 0; } L3ULONG Q931GetTime() { - L3ULONG tNow = 0; - static L3ULONG tLast = 0; + L3ULONG tNow = 0; + static L3ULONG tLast = 0; - if(Q931GetTimeProc != NULL) - { - tNow = Q931GetTimeProc(); - if(tNow < tLast) /* wrapped */ - { - /* TODO */ - } - tLast = tNow; - } - return tNow; + if (Q931GetTimeProc != NULL) { + tNow = Q931GetTimeProc(); + if (tNow < tLast) { /* wrapped */ + /* TODO */ + } + tLast = tNow; + } + return tNow; } void Q931SetGetTimeCB(L3ULONG (*callback)(void)) { - Q931GetTimeProc = callback; + Q931GetTimeProc = callback; } L3INT Q931FindCRV(Q931_TrunkInfo_t *pTrunk, L3INT crv, L3INT *callindex) { - L3INT x; - for(x=0; x < Q931MAXCALLPERTRUNK; x++) - { - if(pTrunk->call[x].InUse) - { - if(pTrunk->call[x].CRV == crv) - { - *callindex = x; - return Q931E_NO_ERROR; - } - } - } - return Q931E_INVALID_CRV; + L3INT x; + for (x = 0; x < Q931MAXCALLPERTRUNK; x++) { + if (pTrunk->call[x].InUse) { + if (pTrunk->call[x].CRV == crv) { + *callindex = x; + return Q931E_NO_ERROR; + } + } + } + return Q931E_INVALID_CRV; } void Q931AddDialect(L3UCHAR i, void (*callback)(L3UCHAR iD )) { - if(i < Q931MAXDLCT) - { - Q931CreateDialectCB[i] = callback; - } + if (i < Q931MAXDLCT) { + Q931CreateDialectCB[i] = callback; + } } /***************************************************************************** - Function: Q931AddStateEntry + Function: Q931AddStateEntry Description: Find an empty entry in the dialects state table and add this - entry. + entry. *****************************************************************************/ void Q931AddStateEntry(L3UCHAR iD, L3INT iState, L3INT iMes, L3UCHAR cDir) { - int x; - for(x=0; x < Q931MAXSTATE; x++) - { - if(Q931st[x].Message == 0) - { - Q931st[x].State = iState; - Q931st[x].Message = iMes; - Q931st[x].Direction = cDir; - /* TODO Sort table and use bsearch */ - return; - } - } + int x; + for (x = 0; x < Q931MAXSTATE; x++) { + if (Q931st[x].Message == 0) { + Q931st[x].State = iState; + Q931st[x].Message = iMes; + Q931st[x].Direction = cDir; + /* TODO Sort table and use bsearch */ + return; + } + } } /***************************************************************************** - Function: Q931IsEventLegal + Function: Q931IsEventLegal Description: Check state table for matching criteria to indicate if this - Message is legal in this state or not. + Message is legal in this state or not. - Note: Someone write a bsearch or invent something smart here - please - sequential is ok for now. + Note: Someone write a bsearch or invent something smart here + please - sequential is ok for now. *****************************************************************************/ L3BOOL Q931IsEventLegal(L3UCHAR iD, L3INT iState, L3INT iMes, L3UCHAR cDir) { - int x; - /* TODO Sort table and use bsearch */ - for(x=0; x < Q931MAXSTATE; x++) - { - if( Q931st[x].State == iState - && Q931st[x].Message == iMes - && Q931st[x].Direction == cDir) - { - return L3TRUE; - } - } - return L3FALSE; + int x; + /* TODO Sort table and use bsearch */ + for (x = 0; x < Q931MAXSTATE; x++) { + if (Q931st[x].State == iState && Q931st[x].Message == iMes && + Q931st[x].Direction == cDir) { + return L3TRUE; + } + } + return L3FALSE; } /***************************************************************************** - Function: q931_error_to_name() + Function: q931_error_to_name() Description: Check state table for matching criteria to indicate if this - Message is legal in this state or not. + Message is legal in this state or not. - Note: Someone write a bsearch or invent something smart here - please - sequential is ok for now. + Note: Someone write a bsearch or invent something smart here + please - sequential is ok for now. *****************************************************************************/ static const char *q931_error_names[] = { - "Q931E_NO_ERROR", /* 0 */ + "Q931E_NO_ERROR", /* 0 */ - "Q931E_UNKNOWN_MESSAGE", /* -3001 */ - "Q931E_ILLEGAL_IE", /* -3002 */ - "Q931E_UNKNOWN_IE", /* -3003 */ - "Q931E_BEARERCAP", /* -3004 */ - "Q931E_HLCOMP", /* -3005 */ - "Q931E_LLCOMP", /* -3006 */ - "Q931E_INTERNAL", /* -3007 */ - "Q931E_MISSING_CB", /* -3008 */ - "Q931E_UNEXPECTED_MESSAGE", /* -3009 */ - "Q931E_ILLEGAL_MESSAGE", /* -3010 */ - "Q931E_TOMANYCALLS", /* -3011 */ - "Q931E_INVALID_CRV", /* -3012 */ - "Q931E_CALLID", /* -3013 */ - "Q931E_CALLSTATE", /* -3014 */ - "Q931E_CALLEDSUB", /* -3015 */ - "Q931E_CALLEDNUM", /* -3016 */ - "Q931E_CALLINGNUM", /* -3017 */ - "Q931E_CALLINGSUB", /* -3018 */ - "Q931E_CAUSE", /* -3019 */ - "Q931E_CHANID", /* -3020 */ - "Q931E_DATETIME", /* -3021 */ - "Q931E_DISPLAY", /* -3022 */ - "Q931E_KEYPADFAC", /* -3023 */ - "Q931E_NETFAC", /* -3024 */ - "Q931E_NOTIFIND", /* -3025 */ - "Q931E_PROGIND", /* -3026 */ - "Q931E_RESTARTIND", /* -3027 */ - "Q931E_SEGMENT", /* -3028 */ - "Q931E_SIGNAL", /* -3029 */ - "Q931E_GENERIC_DIGITS" /* -3030 */ + "Q931E_UNKNOWN_MESSAGE", /* -3001 */ + "Q931E_ILLEGAL_IE", /* -3002 */ + "Q931E_UNKNOWN_IE", /* -3003 */ + "Q931E_BEARERCAP", /* -3004 */ + "Q931E_HLCOMP", /* -3005 */ + "Q931E_LLCOMP", /* -3006 */ + "Q931E_INTERNAL", /* -3007 */ + "Q931E_MISSING_CB", /* -3008 */ + "Q931E_UNEXPECTED_MESSAGE", /* -3009 */ + "Q931E_ILLEGAL_MESSAGE", /* -3010 */ + "Q931E_TOMANYCALLS", /* -3011 */ + "Q931E_INVALID_CRV", /* -3012 */ + "Q931E_CALLID", /* -3013 */ + "Q931E_CALLSTATE", /* -3014 */ + "Q931E_CALLEDSUB", /* -3015 */ + "Q931E_CALLEDNUM", /* -3016 */ + "Q931E_CALLINGNUM", /* -3017 */ + "Q931E_CALLINGSUB", /* -3018 */ + "Q931E_CAUSE", /* -3019 */ + "Q931E_CHANID", /* -3020 */ + "Q931E_DATETIME", /* -3021 */ + "Q931E_DISPLAY", /* -3022 */ + "Q931E_KEYPADFAC", /* -3023 */ + "Q931E_NETFAC", /* -3024 */ + "Q931E_NOTIFIND", /* -3025 */ + "Q931E_PROGIND", /* -3026 */ + "Q931E_RESTARTIND", /* -3027 */ + "Q931E_SEGMENT", /* -3028 */ + "Q931E_SIGNAL", /* -3029 */ + "Q931E_GENERIC_DIGITS" /* -3030 */ }; @@ -828,14 +798,14 @@ static const char *q931_error_names[] = { const char *q931_error_to_name(q931_error_t error) { - int index = 0; - if ((int)error < 0) { - index = (((int)error * -1) -3000); - } - if (index < 0 || index > Q931_MAX_ERROR) { - return ""; - } - return q931_error_names[index]; + int index = 0; + if ((int)error < 0) { + index = (((int)error * -1) -3000); + } + if (index < 0 || index > Q931_MAX_ERROR) { + return ""; + } + return q931_error_names[index]; } /* * Logging @@ -844,24 +814,24 @@ const char *q931_error_to_name(q931_error_t error) L3INT Q931Log(Q931_TrunkInfo_t *trunk, Q931LogLevel_t level, const char *fmt, ...) { - char buf[Q931_LOGBUFSIZE]; + char buf[Q931_LOGBUFSIZE]; L3INT len; va_list ap; - if(!trunk->Q931LogCBProc) + if (!trunk->Q931LogCBProc) return 0; - if(trunk->loglevel < level) + if (trunk->loglevel < level) return 0; va_start(ap, fmt); len = vsnprintf(buf, sizeof(buf)-1, fmt, ap); - if(len <= 0) { + if (len <= 0) { /* TODO: error handling */ return -1; } - if(len >= sizeof(buf)) + if (len >= sizeof(buf)) len = sizeof(buf) - 1; buf[len] = '\0'; @@ -877,7 +847,7 @@ L3INT Q931Log(Q931_TrunkInfo_t *trunk, Q931LogLevel_t level, const char *fmt, .. */ void Q931SetLogCB(Q931_TrunkInfo_t *trunk, Q931LogCB_t func, void *priv) { - trunk->Q931LogCBProc = func; + trunk->Q931LogCBProc = func; trunk->PrivateDataLog = priv; } diff --git a/libs/freetdm/src/isdn/Q931StateNT.c b/libs/freetdm/src/isdn/Q931StateNT.c index af74ef0e8b..5b8b0860b4 100644 --- a/libs/freetdm/src/isdn/Q931StateNT.c +++ b/libs/freetdm/src/isdn/Q931StateNT.c @@ -4,11 +4,11 @@ Contents: Q.931 State Engine for NT (Network Mode). - The controlling state engine for Q.931 is the state engine - on the NT side. The state engine on the TE side is a slave - of this. The TE side maintain it's own states as described in - ITU-T Q931, but will in raise conditions be overridden by - the NT side. + The controlling state engine for Q.931 is the state engine + on the NT side. The state engine on the TE side is a slave + of this. The TE side maintain it's own states as described in + ITU-T Q931, but will in raise conditions be overridden by + the NT side. License/Copyright: @@ -19,12 +19,12 @@ modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of the Case Labs, Ltd nor the names of its contributors + * Neither the name of the Case Labs, Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -56,76 +56,76 @@ extern L3INT Q931L4HeaderSpace; *****************************************************************************/ void Q931CreateNT(L3UCHAR i) { - Q931SetMesProc(Q931mes_ALERTING, i,Q931ProcAlertingNT, Q931Umes_Alerting, Q931Pmes_Alerting); - Q931SetMesProc(Q931mes_CALL_PROCEEDING, i,Q931ProcCallProceedingNT, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); - Q931SetMesProc(Q931mes_CONNECT, i,Q931ProcConnectNT, Q931Umes_Connect, Q931Pmes_Connect); - Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i,Q931ProcConnectAckNT, Q931Umes_ConnectAck, Q931Pmes_ConnectAck); - Q931SetMesProc(Q931mes_PROGRESS, i,Q931ProcProgressNT, Q931Umes_Progress, Q931Pmes_Progress); - Q931SetMesProc(Q931mes_SETUP, i,Q931ProcSetupNT, Q931Umes_Setup, Q931Pmes_Setup); - Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i,Q931ProcSetupAckNT, Q931Umes_SetupAck, Q931Pmes_SetupAck); - Q931SetMesProc(Q931mes_RESUME, i,Q931ProcResumeNT, Q931Umes_Resume, Q931Pmes_Resume); - Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i,Q931ProcResumeAckNT, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); - Q931SetMesProc(Q931mes_RESUME_REJECT, i,Q931ProcResumeRejectNT, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); - Q931SetMesProc(Q931mes_SUSPEND, i,Q931ProcSuspendNT, Q931Umes_Suspend, Q931Pmes_Suspend); - Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i,Q931ProcSuspendAckNT, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); - Q931SetMesProc(Q931mes_SUSPEND_REJECT, i,Q931ProcSuspendRejectNT, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); - Q931SetMesProc(Q931mes_USER_INFORMATION, i,Q931ProcUserInformationNT, Q931Umes_UserInformation, Q931Pmes_UserInformation); - Q931SetMesProc(Q931mes_DISCONNECT, i,Q931ProcDisconnectNT, Q931Umes_Disconnect, Q931Pmes_Disconnect); - Q931SetMesProc(Q931mes_RELEASE, i,Q931ProcReleaseNT, Q931Umes_Release, Q931Pmes_Release); - Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i,Q931ProcReleaseCompleteNT, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); - Q931SetMesProc(Q931mes_RESTART, i,Q931ProcRestartNT, Q931Umes_Restart, Q931Pmes_Restart); - Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i,Q931ProcRestartAckNT, Q931Umes_RestartAck, Q931Pmes_RestartAck); - Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i,Q931ProcCongestionControlNT, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); - Q931SetMesProc(Q931mes_INFORMATION, i,Q931ProcInformationNT, Q931Umes_Information, Q931Pmes_Information); - Q931SetMesProc(Q931mes_NOTIFY, i,Q931ProcNotifyNT, Q931Umes_Notify, Q931Pmes_Notify); - Q931SetMesProc(Q931mes_STATUS, i,Q931ProcStatusNT, Q931Umes_Status, Q931Pmes_Status); - Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i,Q931ProcStatusEnquiryNT, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); - Q931SetMesProc(Q931mes_SEGMENT, i,Q931ProcSegmentNT, Q931Umes_Segment, Q931Pmes_Segment); + Q931SetMesProc(Q931mes_ALERTING, i, Q931ProcAlertingNT, Q931Umes_Alerting, Q931Pmes_Alerting); + Q931SetMesProc(Q931mes_CALL_PROCEEDING, i, Q931ProcCallProceedingNT, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); + Q931SetMesProc(Q931mes_CONNECT, i, Q931ProcConnectNT, Q931Umes_Connect, Q931Pmes_Connect); + Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i, Q931ProcConnectAckNT, Q931Umes_ConnectAck, Q931Pmes_ConnectAck); + Q931SetMesProc(Q931mes_PROGRESS, i, Q931ProcProgressNT, Q931Umes_Progress, Q931Pmes_Progress); + Q931SetMesProc(Q931mes_SETUP, i, Q931ProcSetupNT, Q931Umes_Setup, Q931Pmes_Setup); + Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i, Q931ProcSetupAckNT, Q931Umes_SetupAck, Q931Pmes_SetupAck); + Q931SetMesProc(Q931mes_RESUME, i, Q931ProcResumeNT, Q931Umes_Resume, Q931Pmes_Resume); + Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i, Q931ProcResumeAckNT, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); + Q931SetMesProc(Q931mes_RESUME_REJECT, i, Q931ProcResumeRejectNT, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); + Q931SetMesProc(Q931mes_SUSPEND, i, Q931ProcSuspendNT, Q931Umes_Suspend, Q931Pmes_Suspend); + Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i, Q931ProcSuspendAckNT, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); + Q931SetMesProc(Q931mes_SUSPEND_REJECT, i, Q931ProcSuspendRejectNT, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); + Q931SetMesProc(Q931mes_USER_INFORMATION, i, Q931ProcUserInformationNT, Q931Umes_UserInformation, Q931Pmes_UserInformation); + Q931SetMesProc(Q931mes_DISCONNECT, i, Q931ProcDisconnectNT, Q931Umes_Disconnect, Q931Pmes_Disconnect); + Q931SetMesProc(Q931mes_RELEASE, i, Q931ProcReleaseNT, Q931Umes_Release, Q931Pmes_Release); + Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i, Q931ProcReleaseCompleteNT, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); + Q931SetMesProc(Q931mes_RESTART, i, Q931ProcRestartNT, Q931Umes_Restart, Q931Pmes_Restart); + Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i, Q931ProcRestartAckNT, Q931Umes_RestartAck, Q931Pmes_RestartAck); + Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i, Q931ProcCongestionControlNT, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); + Q931SetMesProc(Q931mes_INFORMATION, i, Q931ProcInformationNT, Q931Umes_Information, Q931Pmes_Information); + Q931SetMesProc(Q931mes_NOTIFY, i, Q931ProcNotifyNT, Q931Umes_Notify, Q931Pmes_Notify); + Q931SetMesProc(Q931mes_STATUS, i, Q931ProcStatusNT, Q931Umes_Status, Q931Pmes_Status); + Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i, Q931ProcStatusEnquiryNT, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); + Q931SetMesProc(Q931mes_SEGMENT, i, Q931ProcSegmentNT, Q931Umes_Segment, Q931Pmes_Segment); - Q931SetMesProc(Q932mes_FACILITY, i,Q932ProcFacilityNT, Q932Umes_Facility, Q932Pmes_Facility); - Q931SetMesProc(Q932mes_HOLD, i,Q932ProcHoldNT, Q932Umes_Hold, Q932Pmes_Hold); - Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i,Q932ProcHoldAckNT, Q932Umes_HoldAck, Q932Pmes_HoldAck); - Q931SetMesProc(Q932mes_HOLD_REJECT, i,Q932ProcHoldRejectNT, Q932Umes_HoldReject, Q932Pmes_HoldReject); - Q931SetMesProc(Q932mes_REGISTER, i,Q932ProcRegisterNT, Q932Umes_Register, Q932Pmes_Register); - Q931SetMesProc(Q932mes_RETRIEVE, i,Q932ProcRetrieveNT, Q932Umes_Retrieve, Q932Pmes_Retrieve); - Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE,i,Q932ProcRetrieveAckNT, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); - Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i,Q932ProcRetrieveRejectNT, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); + Q931SetMesProc(Q932mes_FACILITY, i, Q932ProcFacilityNT, Q932Umes_Facility, Q932Pmes_Facility); + Q931SetMesProc(Q932mes_HOLD, i, Q932ProcHoldNT, Q932Umes_Hold, Q932Pmes_Hold); + Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i, Q932ProcHoldAckNT, Q932Umes_HoldAck, Q932Pmes_HoldAck); + Q931SetMesProc(Q932mes_HOLD_REJECT, i, Q932ProcHoldRejectNT, Q932Umes_HoldReject, Q932Pmes_HoldReject); + Q931SetMesProc(Q932mes_REGISTER, i, Q932ProcRegisterNT, Q932Umes_Register, Q932Pmes_Register); + Q931SetMesProc(Q932mes_RETRIEVE, i, Q932ProcRetrieveNT, Q932Umes_Retrieve, Q932Pmes_Retrieve); + Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE, i, Q932ProcRetrieveAckNT, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); + Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i, Q932ProcRetrieveRejectNT, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); /* Set up the IE encoder/decoder handle table.*/ - Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i,Q931Pie_Segment, Q931Uie_Segment); - Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i,Q931Pie_BearerCap, Q931Uie_BearerCap); - Q931SetIEProc(Q931ie_CAUSE, i,Q931Pie_Cause, Q931Uie_Cause); - Q931SetIEProc(Q931ie_CALL_IDENTITY, i,Q931Pie_CallID, Q931Uie_CallID); - Q931SetIEProc(Q931ie_CALL_STATE, i,Q931Pie_CallState, Q931Uie_CallState); - Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i,Q931Pie_ChanID, Q931Uie_ChanID); - Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i,Q931Pie_ProgInd, Q931Uie_ProgInd); - Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i,Q931Pie_NetFac, Q931Uie_NetFac); - Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i,Q931Pie_NotifInd, Q931Uie_NotifInd); - Q931SetIEProc(Q931ie_DISPLAY, i,Q931Pie_Display, Q931Uie_Display); - Q931SetIEProc(Q931ie_DATETIME, i,Q931Pie_DateTime, Q931Uie_DateTime); - Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i,Q931Pie_KeypadFac, Q931Uie_KeypadFac); - Q931SetIEProc(Q931ie_SIGNAL, i,Q931Pie_Signal, Q931Uie_Signal); - Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i,Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i,Q931Pie_CallingNum, Q931Uie_CallingNum); - Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i,Q931Pie_CallingSub, Q931Uie_CallingSub); - Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i,Q931Pie_CalledNum, Q931Uie_CalledNum); - Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i,Q931Pie_CalledSub, Q931Uie_CalledSub); - Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i,Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_RESTART_INDICATOR, i,Q931Pie_RestartInd, Q931Uie_RestartInd); - Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i,Q931Pie_LLComp, Q931Uie_LLComp); - Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i,Q931Pie_HLComp, Q931Uie_HLComp); - Q931SetIEProc(Q931ie_USER_USER, i,Q931Pie_UserUser, Q931Uie_UserUser); + Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i, Q931Pie_Segment, Q931Uie_Segment); + Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i, Q931Pie_BearerCap, Q931Uie_BearerCap); + Q931SetIEProc(Q931ie_CAUSE, i, Q931Pie_Cause, Q931Uie_Cause); + Q931SetIEProc(Q931ie_CALL_IDENTITY, i, Q931Pie_CallID, Q931Uie_CallID); + Q931SetIEProc(Q931ie_CALL_STATE, i, Q931Pie_CallState, Q931Uie_CallState); + Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i, Q931Pie_ChanID, Q931Uie_ChanID); + Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i, Q931Pie_ProgInd, Q931Uie_ProgInd); + Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i, Q931Pie_NetFac, Q931Uie_NetFac); + Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i, Q931Pie_NotifInd, Q931Uie_NotifInd); + Q931SetIEProc(Q931ie_DISPLAY, i, Q931Pie_Display, Q931Uie_Display); + Q931SetIEProc(Q931ie_DATETIME, i, Q931Pie_DateTime, Q931Uie_DateTime); + Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i, Q931Pie_KeypadFac, Q931Uie_KeypadFac); + Q931SetIEProc(Q931ie_SIGNAL, i, Q931Pie_Signal, Q931Uie_Signal); + Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); + Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i, Q931Pie_CallingNum, Q931Uie_CallingNum); + Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i, Q931Pie_CallingSub, Q931Uie_CallingSub); + Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i, Q931Pie_CalledNum, Q931Uie_CalledNum); + Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i, Q931Pie_CalledSub, Q931Uie_CalledSub); + Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); + Q931SetIEProc(Q931ie_RESTART_INDICATOR, i, Q931Pie_RestartInd, Q931Uie_RestartInd); + Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i, Q931Pie_LLComp, Q931Uie_LLComp); + Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i, Q931Pie_HLComp, Q931Uie_HLComp); + Q931SetIEProc(Q931ie_USER_USER, i, Q931Pie_UserUser, Q931Uie_UserUser); Q931SetIEProc(Q931ie_CONNECTED_NUMBER, i, Q931Pie_Generic, Q931Uie_Generic); Q931SetIEProc(Q931ie_FACILITY, i, Q931Pie_Generic, Q931Uie_Generic); - /* The following define a state machine. The point is that the Message */ - /* procs can when search this to find out if the message/state */ - /* combination is legale. If not, the proc for unexpected message apply.*/ + /* The following define a state machine. The point is that the Message + * procs can when search this to find out if the message/state + * combination is legale. If not, the proc for unexpected message apply. + */ /* TODO define state table here */ - /* Timer default values */ Q931SetTimerDefault(i, Q931_TIMER_T301, 180000); /* T301: 180s */ Q931SetTimerDefault(i, Q931_TIMER_T302, 15000); /* T302: 15s */ @@ -153,24 +153,22 @@ void Q931CreateNT(L3UCHAR i) *****************************************************************************/ L3INT Q931ProcAlertingNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* Reset 4 sec timer. */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -182,28 +180,26 @@ L3INT Q931ProcAlertingNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcCallProceedingNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -215,28 +211,26 @@ L3INT Q931ProcCallProceedingNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iF *****************************************************************************/ L3INT Q931ProcConnectNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -248,28 +242,26 @@ L3INT Q931ProcConnectNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcConnectAckNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -281,28 +273,26 @@ L3INT Q931ProcConnectAckNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcProgressNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -316,71 +306,61 @@ L3INT Q931ProcProgressNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcSetupNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT rc=0; Q931mes_Generic *pMes = (Q931mes_Generic *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; + L3INT rc = 0; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; - /* Reject SETUP on existing calls */ - if(Q931GetCallState(pTrunk, pMes->CRV) != Q931_U0) - { - Q931Disconnect(pTrunk, iFrom, pMes->CRV, 81); - return Q931E_UNEXPECTED_MESSAGE; - } + /* Reject SETUP on existing calls */ + if (Q931GetCallState(pTrunk, pMes->CRV) != Q931_U0) { + Q931Disconnect(pTrunk, iFrom, pMes->CRV, 81); + return Q931E_UNEXPECTED_MESSAGE; + } /* outgoing call */ - if(iFrom == 4) - { - ret = Q931CreateCRV(pTrunk, &callIndex); - if(ret) - return ret; - pMes->CRV = pTrunk->call[callIndex].CRV; + if (iFrom == 4) { + ret = Q931CreateCRV(pTrunk, &callIndex); + if (ret) + return ret; - /* - * Outgoing SETUP message will be broadcasted in PTMP mode - */ - ret = Q931Tx32Data(pTrunk, Q931_IS_PTP(pTrunk) ? 0 : 1, buf, pMes->Size); - if(ret) - return ret; + pMes->CRV = pTrunk->call[callIndex].CRV; - Q931StartTimer(pTrunk, callIndex, 303); + /* + * Outgoing SETUP message will be broadcasted in PTMP mode + */ + ret = Q931Tx32Data(pTrunk, Q931_IS_PTP(pTrunk) ? 0 : 1, buf, pMes->Size); + if (ret) + return ret; - Q931SetState(pTrunk, callIndex, Q931_U1); - } + Q931StartTimer(pTrunk, callIndex, 303); + Q931SetState(pTrunk, callIndex, Q931_U1); + } /* incoming call */ - else - { - /* Locate free CRV entry and store info */ - ret = Q931AllocateCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) - { - /* Not possible to allocate CRV entry, so must reject call */ - - Q931Disconnect(pTrunk, iFrom, pMes->CRV, 42); - - return ret; - } - - /* Send setup indication to user */ - ret = Q931Tx34(pTrunk,(L3UCHAR*)pMes,pMes->Size); - if(ret != Q931E_NO_ERROR) - return ret; - else - { - /* Must be full queue, meaning we can't process the call */ - /* so we must disconnect */ - Q931Disconnect(pTrunk, iFrom, pMes->CRV, 81); - return ret; + else { + /* Locate free CRV entry and store info */ + ret = Q931AllocateCRV(pTrunk, pMes->CRV, &callIndex); + if (ret != Q931E_NO_ERROR) { + /* Not possible to allocate CRV entry, so must reject call */ + Q931Disconnect(pTrunk, iFrom, pMes->CRV, 42); + return ret; } + /* Send setup indication to user */ + ret = Q931Tx34(pTrunk, (L3UCHAR*)pMes, pMes->Size); + if (ret != Q931E_NO_ERROR) { + return ret; + } else { + /* Must be full queue, meaning we can't process the call */ + /* so we must disconnect */ + Q931Disconnect(pTrunk, iFrom, pMes->CRV, 81); + return ret; + } #if 0 /* TODO: Unreachable code??? */ - /* Set state U6 */ - Q931SetState(pTrunk, callIndex, Q931_U6); - - Q931StartTimer(pTrunk, callIndex, 303); + /* Set state U6 */ + Q931SetState(pTrunk, callIndex, Q931_U6); + Q931StartTimer(pTrunk, callIndex, 303); #endif - } return rc; @@ -399,28 +379,26 @@ L3INT Q931ProcSetupNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcSetupAckNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -432,28 +410,26 @@ L3INT Q931ProcSetupAckNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcResumeNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -465,28 +441,26 @@ L3INT Q931ProcResumeNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcResumeAckNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -498,28 +472,26 @@ L3INT Q931ProcResumeAckNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcResumeRejectNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -531,28 +503,26 @@ L3INT Q931ProcResumeRejectNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFro *****************************************************************************/ L3INT Q931ProcSuspendNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -564,28 +534,26 @@ L3INT Q931ProcSuspendNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcSuspendAckNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -597,28 +565,26 @@ L3INT Q931ProcSuspendAckNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcSuspendRejectNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -630,28 +596,26 @@ L3INT Q931ProcSuspendRejectNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFr *****************************************************************************/ L3INT Q931ProcUserInformationNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -663,28 +627,26 @@ L3INT Q931ProcUserInformationNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT i *****************************************************************************/ L3INT Q931ProcDisconnectNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -696,28 +658,26 @@ L3INT Q931ProcDisconnectNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcReleaseNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -729,28 +689,26 @@ L3INT Q931ProcReleaseNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcReleaseCompleteNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -762,28 +720,26 @@ L3INT Q931ProcReleaseCompleteNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT i *****************************************************************************/ L3INT Q931ProcRestartNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -795,28 +751,26 @@ L3INT Q931ProcRestartNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcRestartAckNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -828,28 +782,26 @@ L3INT Q931ProcRestartAckNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcCongestionControlNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -861,28 +813,26 @@ L3INT Q931ProcCongestionControlNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT *****************************************************************************/ L3INT Q931ProcInformationNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -894,28 +844,26 @@ L3INT Q931ProcInformationNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom *****************************************************************************/ L3INT Q931ProcNotifyNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -927,28 +875,26 @@ L3INT Q931ProcNotifyNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcStatusNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -960,28 +906,26 @@ L3INT Q931ProcStatusNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcStatusEnquiryNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -993,28 +937,26 @@ L3INT Q931ProcStatusEnquiryNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFr *****************************************************************************/ L3INT Q931ProcSegmentNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -1030,28 +972,26 @@ L3INT Q931ProcSegmentNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q932ProcFacilityNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -1063,28 +1003,26 @@ L3INT Q932ProcFacilityNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q932ProcHoldNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -1096,28 +1034,26 @@ L3INT Q932ProcHoldNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q932ProcHoldAckNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -1129,28 +1065,26 @@ L3INT Q932ProcHoldAckNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q932ProcHoldRejectNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -1162,28 +1096,26 @@ L3INT Q932ProcHoldRejectNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q932ProcRegisterNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -1195,28 +1127,26 @@ L3INT Q932ProcRegisterNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q932ProcRetrieveNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -1228,28 +1158,26 @@ L3INT Q932ProcRetrieveNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q932ProcRetrieveAckNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -1261,29 +1189,26 @@ L3INT Q932ProcRetrieveAckNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom *****************************************************************************/ L3INT Q932ProcRetrieveRejectNT(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO chack against state table for illegal or unexpected message here*/ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } - diff --git a/libs/freetdm/src/isdn/Q931StateTE.c b/libs/freetdm/src/isdn/Q931StateTE.c index 552b39ff27..0d79daf656 100644 --- a/libs/freetdm/src/isdn/Q931StateTE.c +++ b/libs/freetdm/src/isdn/Q931StateTE.c @@ -4,18 +4,18 @@ Contents: Q.931 State Engine for TE (User Mode). - The controlling state engine for Q.931 is the state engine - on the NT side. The state engine on the TE side is a slave - of this. The TE side maintain it's own states as described in - ITU-T Q931, but will in raise conditions be overridden by - the NT side. + The controlling state engine for Q.931 is the state engine + on the NT side. The state engine on the TE side is a slave + of this. The TE side maintain it's own states as described in + ITU-T Q931, but will in raise conditions be overridden by + the NT side. - This reference implementation uses a process per message, - meaning that each message must check call states. This - is easier for dialect maintenance as each message proc - can be replaced individually. A new TE variant only - need to copy the Q931CreateTE and replace those procs or - need to override. + This reference implementation uses a process per message, + meaning that each message must check call states. This + is easier for dialect maintenance as each message proc + can be replaced individually. A new TE variant only + need to copy the Q931CreateTE and replace those procs or + need to override. License/Copyright: @@ -26,12 +26,12 @@ modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of the Case Labs, Ltd nor the names of its contributors + * Neither the name of the Case Labs, Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -63,150 +63,151 @@ extern L3INT Q931L4HeaderSpace; *****************************************************************************/ void Q931CreateTE(L3UCHAR i) { - Q931SetMesProc(Q931mes_ALERTING, i,Q931ProcAlertingTE, Q931Umes_Alerting, Q931Pmes_Alerting); - Q931SetMesProc(Q931mes_CALL_PROCEEDING, i,Q931ProcCallProceedingTE, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); - Q931SetMesProc(Q931mes_CONNECT, i,Q931ProcConnectTE, Q931Umes_Connect, Q931Pmes_Connect); - Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i,Q931ProcConnectAckTE, Q931Umes_ConnectAck, Q931Pmes_ConnectAck); - Q931SetMesProc(Q931mes_PROGRESS, i,Q931ProcProgressTE, Q931Umes_Progress, Q931Pmes_Progress); - Q931SetMesProc(Q931mes_SETUP, i,Q931ProcSetupTE, Q931Umes_Setup, Q931Pmes_Setup); - Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i,Q931ProcSetupAckTE, Q931Umes_SetupAck, Q931Pmes_SetupAck); - Q931SetMesProc(Q931mes_RESUME, i,Q931ProcResumeTE, Q931Umes_Resume, Q931Pmes_Resume); - Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i,Q931ProcResumeAckTE, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); - Q931SetMesProc(Q931mes_RESUME_REJECT, i,Q931ProcResumeRejectTE, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); - Q931SetMesProc(Q931mes_SUSPEND, i,Q931ProcSuspendTE, Q931Umes_Suspend, Q931Pmes_Suspend); - Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i,Q931ProcSuspendAckTE, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); - Q931SetMesProc(Q931mes_SUSPEND_REJECT, i,Q931ProcSuspendRejectTE, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); - Q931SetMesProc(Q931mes_USER_INFORMATION, i,Q931ProcUserInformationTE, Q931Umes_UserInformation, Q931Pmes_UserInformation); - Q931SetMesProc(Q931mes_DISCONNECT, i,Q931ProcDisconnectTE, Q931Umes_Disconnect, Q931Pmes_Disconnect); - Q931SetMesProc(Q931mes_RELEASE, i,Q931ProcReleaseTE, Q931Umes_Release, Q931Pmes_Release); - Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i,Q931ProcReleaseCompleteTE, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); - Q931SetMesProc(Q931mes_RESTART, i,Q931ProcRestartTE, Q931Umes_Restart, Q931Pmes_Restart); - Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i,Q931ProcRestartAckTE, Q931Umes_RestartAck, Q931Pmes_RestartAck); - Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i,Q931ProcCongestionControlTE, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); - Q931SetMesProc(Q931mes_INFORMATION, i,Q931ProcInformationTE, Q931Umes_Information, Q931Pmes_Information); - Q931SetMesProc(Q931mes_NOTIFY, i,Q931ProcNotifyTE, Q931Umes_Notify, Q931Pmes_Notify); - Q931SetMesProc(Q931mes_STATUS, i,Q931ProcStatusTE, Q931Umes_Status, Q931Pmes_Status); - Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i,Q931ProcStatusEnquiryTE, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); - Q931SetMesProc(Q931mes_SEGMENT, i,Q931ProcSegmentTE, Q931Umes_Segment, Q931Pmes_Segment); + Q931SetMesProc(Q931mes_ALERTING, i, Q931ProcAlertingTE, Q931Umes_Alerting, Q931Pmes_Alerting); + Q931SetMesProc(Q931mes_CALL_PROCEEDING, i, Q931ProcCallProceedingTE, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); + Q931SetMesProc(Q931mes_CONNECT, i, Q931ProcConnectTE, Q931Umes_Connect, Q931Pmes_Connect); + Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i, Q931ProcConnectAckTE, Q931Umes_ConnectAck, Q931Pmes_ConnectAck); + Q931SetMesProc(Q931mes_PROGRESS, i, Q931ProcProgressTE, Q931Umes_Progress, Q931Pmes_Progress); + Q931SetMesProc(Q931mes_SETUP, i, Q931ProcSetupTE, Q931Umes_Setup, Q931Pmes_Setup); + Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i, Q931ProcSetupAckTE, Q931Umes_SetupAck, Q931Pmes_SetupAck); + Q931SetMesProc(Q931mes_RESUME, i, Q931ProcResumeTE, Q931Umes_Resume, Q931Pmes_Resume); + Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i, Q931ProcResumeAckTE, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); + Q931SetMesProc(Q931mes_RESUME_REJECT, i, Q931ProcResumeRejectTE, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); + Q931SetMesProc(Q931mes_SUSPEND, i, Q931ProcSuspendTE, Q931Umes_Suspend, Q931Pmes_Suspend); + Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i, Q931ProcSuspendAckTE, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); + Q931SetMesProc(Q931mes_SUSPEND_REJECT, i, Q931ProcSuspendRejectTE, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); + Q931SetMesProc(Q931mes_USER_INFORMATION, i, Q931ProcUserInformationTE, Q931Umes_UserInformation, Q931Pmes_UserInformation); + Q931SetMesProc(Q931mes_DISCONNECT, i, Q931ProcDisconnectTE, Q931Umes_Disconnect, Q931Pmes_Disconnect); + Q931SetMesProc(Q931mes_RELEASE, i, Q931ProcReleaseTE, Q931Umes_Release, Q931Pmes_Release); + Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i, Q931ProcReleaseCompleteTE, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); + Q931SetMesProc(Q931mes_RESTART, i, Q931ProcRestartTE, Q931Umes_Restart, Q931Pmes_Restart); + Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i, Q931ProcRestartAckTE, Q931Umes_RestartAck, Q931Pmes_RestartAck); + Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i, Q931ProcCongestionControlTE, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); + Q931SetMesProc(Q931mes_INFORMATION, i, Q931ProcInformationTE, Q931Umes_Information, Q931Pmes_Information); + Q931SetMesProc(Q931mes_NOTIFY, i, Q931ProcNotifyTE, Q931Umes_Notify, Q931Pmes_Notify); + Q931SetMesProc(Q931mes_STATUS, i, Q931ProcStatusTE, Q931Umes_Status, Q931Pmes_Status); + Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i, Q931ProcStatusEnquiryTE, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); + Q931SetMesProc(Q931mes_SEGMENT, i, Q931ProcSegmentTE, Q931Umes_Segment, Q931Pmes_Segment); - Q931SetMesProc(Q932mes_FACILITY, i,Q932ProcFacilityTE, Q932Umes_Facility, Q932Pmes_Facility); - Q931SetMesProc(Q932mes_HOLD, i,Q932ProcHoldTE, Q932Umes_Hold, Q932Pmes_Hold); - Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i,Q932ProcHoldAckTE, Q932Umes_HoldAck, Q932Pmes_HoldAck); - Q931SetMesProc(Q932mes_HOLD_REJECT, i,Q932ProcHoldRejectTE, Q932Umes_HoldReject, Q932Pmes_HoldReject); - Q931SetMesProc(Q932mes_REGISTER, i,Q932ProcRegisterTE, Q932Umes_Register, Q932Pmes_Register); - Q931SetMesProc(Q932mes_RETRIEVE, i,Q932ProcRetrieveTE, Q932Umes_Retrieve, Q932Pmes_Retrieve); - Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE,i,Q932ProcRetrieveAckTE, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); - Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i,Q932ProcRetrieveRejectTE, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); + Q931SetMesProc(Q932mes_FACILITY, i, Q932ProcFacilityTE, Q932Umes_Facility, Q932Pmes_Facility); + Q931SetMesProc(Q932mes_HOLD, i, Q932ProcHoldTE, Q932Umes_Hold, Q932Pmes_Hold); + Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i, Q932ProcHoldAckTE, Q932Umes_HoldAck, Q932Pmes_HoldAck); + Q931SetMesProc(Q932mes_HOLD_REJECT, i, Q932ProcHoldRejectTE, Q932Umes_HoldReject, Q932Pmes_HoldReject); + Q931SetMesProc(Q932mes_REGISTER, i, Q932ProcRegisterTE, Q932Umes_Register, Q932Pmes_Register); + Q931SetMesProc(Q932mes_RETRIEVE, i, Q932ProcRetrieveTE, Q932Umes_Retrieve, Q932Pmes_Retrieve); + Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE, i, Q932ProcRetrieveAckTE, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); + Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i, Q932ProcRetrieveRejectTE, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); /* Set up the IE encoder/decoder handle table.*/ - Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i,Q931Pie_Segment, Q931Uie_Segment); - Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i,Q931Pie_BearerCap, Q931Uie_BearerCap); - Q931SetIEProc(Q931ie_CAUSE, i,Q931Pie_Cause, Q931Uie_Cause); - Q931SetIEProc(Q931ie_CALL_IDENTITY, i,Q931Pie_CallID, Q931Uie_CallID); - Q931SetIEProc(Q931ie_CALL_STATE, i,Q931Pie_CallState, Q931Uie_CallState); - Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i,Q931Pie_ChanID, Q931Uie_ChanID); - Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i,Q931Pie_ProgInd, Q931Uie_ProgInd); - Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i,Q931Pie_NetFac, Q931Uie_NetFac); - Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i,Q931Pie_NotifInd, Q931Uie_NotifInd); - Q931SetIEProc(Q931ie_DISPLAY, i,Q931Pie_Display, Q931Uie_Display); - Q931SetIEProc(Q931ie_DATETIME, i,Q931Pie_DateTime, Q931Uie_DateTime); - Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i,Q931Pie_KeypadFac, Q931Uie_KeypadFac); - Q931SetIEProc(Q931ie_SIGNAL, i,Q931Pie_Signal, Q931Uie_Signal); - Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i,Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i,Q931Pie_CallingNum, Q931Uie_CallingNum); - Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i,Q931Pie_CallingSub, Q931Uie_CallingSub); - Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i,Q931Pie_CalledNum, Q931Uie_CalledNum); - Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i,Q931Pie_CalledSub, Q931Uie_CalledSub); - Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i,Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_RESTART_INDICATOR, i,Q931Pie_RestartInd, Q931Uie_RestartInd); - Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i,Q931Pie_LLComp, Q931Uie_LLComp); - Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i,Q931Pie_HLComp, Q931Uie_HLComp); - Q931SetIEProc(Q931ie_USER_USER, i,Q931Pie_UserUser, Q931Uie_UserUser); + Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i, Q931Pie_Segment, Q931Uie_Segment); + Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i, Q931Pie_BearerCap, Q931Uie_BearerCap); + Q931SetIEProc(Q931ie_CAUSE, i, Q931Pie_Cause, Q931Uie_Cause); + Q931SetIEProc(Q931ie_CALL_IDENTITY, i, Q931Pie_CallID, Q931Uie_CallID); + Q931SetIEProc(Q931ie_CALL_STATE, i, Q931Pie_CallState, Q931Uie_CallState); + Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i, Q931Pie_ChanID, Q931Uie_ChanID); + Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i, Q931Pie_ProgInd, Q931Uie_ProgInd); + Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i, Q931Pie_NetFac, Q931Uie_NetFac); + Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i, Q931Pie_NotifInd, Q931Uie_NotifInd); + Q931SetIEProc(Q931ie_DISPLAY, i, Q931Pie_Display, Q931Uie_Display); + Q931SetIEProc(Q931ie_DATETIME, i, Q931Pie_DateTime, Q931Uie_DateTime); + Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i, Q931Pie_KeypadFac, Q931Uie_KeypadFac); + Q931SetIEProc(Q931ie_SIGNAL, i, Q931Pie_Signal, Q931Uie_Signal); + Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); + Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i, Q931Pie_CallingNum, Q931Uie_CallingNum); + Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i, Q931Pie_CallingSub, Q931Uie_CallingSub); + Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i, Q931Pie_CalledNum, Q931Uie_CalledNum); + Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i, Q931Pie_CalledSub, Q931Uie_CalledSub); + Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); + Q931SetIEProc(Q931ie_RESTART_INDICATOR, i, Q931Pie_RestartInd, Q931Uie_RestartInd); + Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i, Q931Pie_LLComp, Q931Uie_LLComp); + Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i, Q931Pie_HLComp, Q931Uie_HLComp); + Q931SetIEProc(Q931ie_USER_USER, i, Q931Pie_UserUser, Q931Uie_UserUser); Q931SetIEProc(Q931ie_CONNECTED_NUMBER, i, Q931Pie_Generic, Q931Uie_Generic); Q931SetIEProc(Q931ie_FACILITY, i, Q931Pie_Generic, Q931Uie_Generic); - /* The following define a state machine. The point is that the Message */ - /* procs can when search this to find out if the message/state */ - /* combination is legale. If not, the proc for unexpected message apply.*/ + /* The following define a state machine. The point is that the Message + * procs can when search this to find out if the message/state + * combination is legale. If not, the proc for unexpected message apply. + */ /* State 0 Idle */ - Q931AddStateEntry(i,Q931_U0, Q931mes_RESUME, 2); - Q931AddStateEntry(i,Q931_U0, Q931mes_SETUP, 4); - Q931AddStateEntry(i,Q931_U0, Q931mes_SETUP, 2); - Q931AddStateEntry(i,Q931_U0, Q931mes_STATUS, 4); - Q931AddStateEntry(i,Q931_U0, Q931mes_RELEASE, 4); - Q931AddStateEntry(i,Q931_U0, Q931mes_RELEASE_COMPLETE,4); + Q931AddStateEntry(i, Q931_U0, Q931mes_RESUME, 2); + Q931AddStateEntry(i, Q931_U0, Q931mes_SETUP, 4); + Q931AddStateEntry(i, Q931_U0, Q931mes_SETUP, 2); + Q931AddStateEntry(i, Q931_U0, Q931mes_STATUS, 4); + Q931AddStateEntry(i, Q931_U0, Q931mes_RELEASE, 4); + Q931AddStateEntry(i, Q931_U0, Q931mes_RELEASE_COMPLETE, 4); /* State 1 Call Initiating */ - Q931AddStateEntry(i,Q931_U1, Q931mes_DISCONNECT, 2); - Q931AddStateEntry(i,Q931_U1, Q931mes_SETUP_ACKNOWLEDGE, 4); - Q931AddStateEntry(i,Q931_U1, Q931mes_RELEASE_COMPLETE,4); - Q931AddStateEntry(i,Q931_U1, Q931mes_CALL_PROCEEDING, 4); - Q931AddStateEntry(i,Q931_U1, Q931mes_ALERTING, 4); - Q931AddStateEntry(i,Q931_U1, Q931mes_CONNECT, 4); + Q931AddStateEntry(i, Q931_U1, Q931mes_DISCONNECT, 2); + Q931AddStateEntry(i, Q931_U1, Q931mes_SETUP_ACKNOWLEDGE, 4); + Q931AddStateEntry(i, Q931_U1, Q931mes_RELEASE_COMPLETE, 4); + Q931AddStateEntry(i, Q931_U1, Q931mes_CALL_PROCEEDING, 4); + Q931AddStateEntry(i, Q931_U1, Q931mes_ALERTING, 4); + Q931AddStateEntry(i, Q931_U1, Q931mes_CONNECT, 4); /* State 2 Overlap Sending */ - Q931AddStateEntry(i,Q931_U2, Q931mes_INFORMATION, 2); - Q931AddStateEntry(i,Q931_U2, Q931mes_CALL_PROCEEDING, 4); - Q931AddStateEntry(i,Q931_U2, Q931mes_ALERTING, 4); - Q931AddStateEntry(i,Q931_U2, Q931mes_PROGRESS, 4); - Q931AddStateEntry(i,Q931_U2, Q931mes_CONNECT, 4); - Q931AddStateEntry(i,Q931_U2, Q931mes_RELEASE, 2); + Q931AddStateEntry(i, Q931_U2, Q931mes_INFORMATION, 2); + Q931AddStateEntry(i, Q931_U2, Q931mes_CALL_PROCEEDING, 4); + Q931AddStateEntry(i, Q931_U2, Q931mes_ALERTING, 4); + Q931AddStateEntry(i, Q931_U2, Q931mes_PROGRESS, 4); + Q931AddStateEntry(i, Q931_U2, Q931mes_CONNECT, 4); + Q931AddStateEntry(i, Q931_U2, Q931mes_RELEASE, 2); /* State 3 Outgoing Call Proceeding */ - Q931AddStateEntry(i,Q931_U3, Q931mes_PROGRESS, 4); - Q931AddStateEntry(i,Q931_U3, Q931mes_ALERTING, 4); - Q931AddStateEntry(i,Q931_U3, Q931mes_CONNECT, 4); - Q931AddStateEntry(i,Q931_U3, Q931mes_RELEASE, 2); + Q931AddStateEntry(i, Q931_U3, Q931mes_PROGRESS, 4); + Q931AddStateEntry(i, Q931_U3, Q931mes_ALERTING, 4); + Q931AddStateEntry(i, Q931_U3, Q931mes_CONNECT, 4); + Q931AddStateEntry(i, Q931_U3, Q931mes_RELEASE, 2); /* State 4 Call Delivered */ - Q931AddStateEntry(i,Q931_U4, Q931mes_CONNECT, 4); + Q931AddStateEntry(i, Q931_U4, Q931mes_CONNECT, 4); /* State 6 Call Precent */ - Q931AddStateEntry(i,Q931_U6, Q931mes_INFORMATION, 2); - Q931AddStateEntry(i,Q931_U6, Q931mes_ALERTING, 2); - Q931AddStateEntry(i,Q931_U6, Q931mes_CALL_PROCEEDING,2); - Q931AddStateEntry(i,Q931_U6, Q931mes_CONNECT, 2); - Q931AddStateEntry(i,Q931_U6, Q931mes_RELEASE_COMPLETE,2); - Q931AddStateEntry(i,Q931_U6, Q931mes_RELEASE, 4); - Q931AddStateEntry(i,Q931_U6, Q931mes_DISCONNECT, 4); + Q931AddStateEntry(i, Q931_U6, Q931mes_INFORMATION, 2); + Q931AddStateEntry(i, Q931_U6, Q931mes_ALERTING, 2); + Q931AddStateEntry(i, Q931_U6, Q931mes_CALL_PROCEEDING, 2); + Q931AddStateEntry(i, Q931_U6, Q931mes_CONNECT, 2); + Q931AddStateEntry(i, Q931_U6, Q931mes_RELEASE_COMPLETE, 2); + Q931AddStateEntry(i, Q931_U6, Q931mes_RELEASE, 4); + Q931AddStateEntry(i, Q931_U6, Q931mes_DISCONNECT, 4); /* State 7 Call Received */ - Q931AddStateEntry(i,Q931_U7, Q931mes_CONNECT, 2); + Q931AddStateEntry(i, Q931_U7, Q931mes_CONNECT, 2); /* State 8 Connect request */ - Q931AddStateEntry(i,Q931_U8, Q931mes_CONNECT_ACKNOWLEDGE, 4); + Q931AddStateEntry(i, Q931_U8, Q931mes_CONNECT_ACKNOWLEDGE, 4); /* State 9 Incoming Call Proceeding */ - Q931AddStateEntry(i,Q931_U9, Q931mes_CONNECT, 2); - Q931AddStateEntry(i,Q931_U9, Q931mes_ALERTING, 2); - Q931AddStateEntry(i,Q931_U9, Q931mes_PROGRESS, 2); + Q931AddStateEntry(i, Q931_U9, Q931mes_CONNECT, 2); + Q931AddStateEntry(i, Q931_U9, Q931mes_ALERTING, 2); + Q931AddStateEntry(i, Q931_U9, Q931mes_PROGRESS, 2); /* State 10 Active */ - Q931AddStateEntry(i,Q931_U10, Q931mes_SUSPEND, 2); - Q931AddStateEntry(i,Q931_U10, Q931mes_NOTIFY, 4); - Q931AddStateEntry(i,Q931_U10, Q931mes_NOTIFY, 2); + Q931AddStateEntry(i, Q931_U10, Q931mes_SUSPEND, 2); + Q931AddStateEntry(i, Q931_U10, Q931mes_NOTIFY, 4); + Q931AddStateEntry(i, Q931_U10, Q931mes_NOTIFY, 2); /* State 11 Disconnect Request */ - Q931AddStateEntry(i,Q931_U11, Q931mes_RELEASE, 4); - Q931AddStateEntry(i,Q931_U11, Q931mes_DISCONNECT, 4); - Q931AddStateEntry(i,Q931_U11, Q931mes_NOTIFY, 4); + Q931AddStateEntry(i, Q931_U11, Q931mes_RELEASE, 4); + Q931AddStateEntry(i, Q931_U11, Q931mes_DISCONNECT, 4); + Q931AddStateEntry(i, Q931_U11, Q931mes_NOTIFY, 4); /* State 12 Disconnect Ind */ - Q931AddStateEntry(i,Q931_U12, Q931mes_RELEASE, 4); - Q931AddStateEntry(i,Q931_U12, Q931mes_RELEASE, 2); + Q931AddStateEntry(i, Q931_U12, Q931mes_RELEASE, 4); + Q931AddStateEntry(i, Q931_U12, Q931mes_RELEASE, 2); /* State 15 Suspend Request */ - Q931AddStateEntry(i,Q931_U15, Q931mes_SUSPEND_ACKNOWLEDGE, 4); - Q931AddStateEntry(i,Q931_U15, Q931mes_SUSPEND_REJECT, 4); - Q931AddStateEntry(i,Q931_U15, Q931mes_DISCONNECT, 4); - Q931AddStateEntry(i,Q931_U15, Q931mes_RELEASE, 4); + Q931AddStateEntry(i, Q931_U15, Q931mes_SUSPEND_ACKNOWLEDGE, 4); + Q931AddStateEntry(i, Q931_U15, Q931mes_SUSPEND_REJECT, 4); + Q931AddStateEntry(i, Q931_U15, Q931mes_DISCONNECT, 4); + Q931AddStateEntry(i, Q931_U15, Q931mes_RELEASE, 4); /* TODO - Q931AddStateEntry(i,Q931_U17, - Q931AddStateEntry(i,Q931_U19, - Q931AddStateEntry(i,Q931_U25, + Q931AddStateEntry(i, Q931_U17, + Q931AddStateEntry(i, Q931_U19, + Q931AddStateEntry(i, Q931_U25, */ /* Timer default values */ @@ -235,24 +236,22 @@ void Q931CreateTE(L3UCHAR i) *****************************************************************************/ L3INT Q931ProcAlertingTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* Reset 4 sec timer. */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -264,28 +263,26 @@ L3INT Q931ProcAlertingTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcCallProceedingTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -297,32 +294,29 @@ L3INT Q931ProcCallProceedingTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iF *****************************************************************************/ L3INT Q931ProcConnectTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); if (pTrunk->autoConnectAck) { Q931AckConnect(pTrunk, buf); } - } return ret; } @@ -334,28 +328,26 @@ L3INT Q931ProcConnectTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcConnectAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -367,28 +359,26 @@ L3INT Q931ProcConnectAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcProgressTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -400,73 +390,64 @@ L3INT Q931ProcProgressTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcSetupTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT rc=0; Q931mes_Generic *pMes = (Q931mes_Generic *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; + L3INT rc = 0; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; - /* Reject SETUP on existing calls */ - if(Q931GetCallState(pTrunk, pMes->CRV) != Q931_U0) - { - Q931Disconnect(pTrunk, iFrom, pMes->CRV, 81); - return Q931E_UNEXPECTED_MESSAGE; - } + /* Reject SETUP on existing calls */ + if (Q931GetCallState(pTrunk, pMes->CRV) != Q931_U0) { + Q931Disconnect(pTrunk, iFrom, pMes->CRV, 81); + return Q931E_UNEXPECTED_MESSAGE; + } /* outgoing call */ - if(iFrom == 4) - { - ret = Q931CreateCRV(pTrunk, &callIndex); - if(ret) - return ret; - pMes->CRV = pTrunk->call[callIndex].CRV; + if (iFrom == 4) { + ret = Q931CreateCRV(pTrunk, &callIndex); + if (ret) + return ret; + pMes->CRV = pTrunk->call[callIndex].CRV; - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); - if(ret) - return ret; + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); + if (ret) + return ret; - Q931StartTimer(pTrunk, callIndex, 303); + Q931StartTimer(pTrunk, callIndex, 303); /* TODO: Add this back when we get the state stuff more filled out */ - //Q931SetState(pTrunk, callIndex, Q931_U1); - } + /*Q931SetState(pTrunk, callIndex, Q931_U1);*/ + } /* incoming call */ - else - { - /* Locate free CRV entry and store info */ - ret = Q931AllocateCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) - { - /* Not possible to allocate CRV entry, so must reject call */ + else { + /* Locate free CRV entry and store info */ + ret = Q931AllocateCRV(pTrunk, pMes->CRV, &callIndex); + if (ret != Q931E_NO_ERROR) { + /* Not possible to allocate CRV entry, so must reject call */ + Q931Disconnect(pTrunk, iFrom, pMes->CRV, 42); + return ret; + } - Q931Disconnect(pTrunk, iFrom, pMes->CRV, 42); - - return ret; - } - - /* Send setup indication to user */ - ret = Q931Tx34(pTrunk,(L3UCHAR*)pMes,pMes->Size); - if(ret != Q931E_NO_ERROR) { + /* Send setup indication to user */ + ret = Q931Tx34(pTrunk, (L3UCHAR*)pMes, pMes->Size); + if (ret != Q931E_NO_ERROR) { if (pTrunk->autoSetupAck) { Q931AckSetup(pTrunk, buf); } - return ret; - } - else - { + return ret; + } else { /* Must be full queue, meaning we can't process the call */ /* so we must disconnect */ - Q931Disconnect(pTrunk, iFrom, pMes->CRV, 81); - return ret; + Q931Disconnect(pTrunk, iFrom, pMes->CRV, 81); + return ret; } #if 0 /* TODO: Unreachable code??? */ - /* Set state U6 */ - Q931SetState(pTrunk, callIndex, Q931_U6); + /* Set state U6 */ + Q931SetState(pTrunk, callIndex, Q931_U6); - Q931StartTimer(pTrunk, callIndex, 303); + Q931StartTimer(pTrunk, callIndex, 303); #endif - } - + } return rc; } @@ -485,22 +466,20 @@ L3INT Q931ProcSetupTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcSetupAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - Q931StartTimer(pTrunk, callIndex, 303); + else if (iFrom == 2) { + Q931StartTimer(pTrunk, callIndex, 303); } return ret; } @@ -512,34 +491,31 @@ L3INT Q931ProcSetupAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcResumeTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - Q931mes_Generic * pMes = (Q931mes_Generic *)&buf[Q931L4HeaderSpace]; - L3INT callIndex; - L3INT ret = Q931E_NO_ERROR; + Q931mes_Generic * pMes = (Q931mes_Generic *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; - if(Q931GetCallState(pTrunk,pMes->CRV) == Q931_U0 && iFrom == 4) - { - /* Call reference selection */ - ret = Q931CreateCRV(pTrunk, &callIndex); - if(ret != Q931E_NO_ERROR) - return ret; - pMes->CRV = pTrunk->call[callIndex].CRV; + if (Q931GetCallState(pTrunk, pMes->CRV) == Q931_U0 && iFrom ==4) { + /* Call reference selection */ + ret = Q931CreateCRV(pTrunk, &callIndex); + if (ret != Q931E_NO_ERROR) + return ret; + pMes->CRV = pTrunk->call[callIndex].CRV; - /* Send RESUME to network */ - ret=Q931Tx32Data(pTrunk,0,buf, pMes->Size); - if(ret != Q931E_NO_ERROR) - return ret; + /* Send RESUME to network */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); + if (ret != Q931E_NO_ERROR) + return ret; - /* Start timer T318 */ - Q931StartTimer(pTrunk, callIndex, 318); + /* Start timer T318 */ + Q931StartTimer(pTrunk, callIndex, 318); - /*set state U17 */ - Q931SetState(pTrunk, callIndex, Q931_U17); - } - else - { - return Q931E_ILLEGAL_MESSAGE; - } - return ret; + /* set state U17 */ + Q931SetState(pTrunk, callIndex, Q931_U17); + } else { + return Q931E_ILLEGAL_MESSAGE; + } + return ret; } /***************************************************************************** @@ -549,28 +525,26 @@ L3INT Q931ProcResumeTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcResumeAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -582,28 +556,26 @@ L3INT Q931ProcResumeAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcResumeRejectTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -615,28 +587,26 @@ L3INT Q931ProcResumeRejectTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFro *****************************************************************************/ L3INT Q931ProcSuspendTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -648,28 +618,26 @@ L3INT Q931ProcSuspendTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcSuspendAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -681,28 +649,26 @@ L3INT Q931ProcSuspendAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcSuspendRejectTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -714,28 +680,26 @@ L3INT Q931ProcSuspendRejectTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFr *****************************************************************************/ L3INT Q931ProcUserInformationTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -747,31 +711,29 @@ L3INT Q931ProcUserInformationTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT i *****************************************************************************/ L3INT Q931ProcDisconnectTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; Q931Log(pTrunk, Q931_LOG_DEBUG, "Processing DISCONNECT message from %s for CRV: %d (%#hx)\n", iFrom == 4 ? "Local" : "Remote", pMes->CRV, pMes->CRV); /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -783,19 +745,21 @@ L3INT Q931ProcDisconnectTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcReleaseTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - Q931mes_Generic *pMes = (Q931mes_Generic *)&buf[Q931L4HeaderSpace]; - L3INT state = Q931GetCallState(pTrunk, pMes->CRV); - L3INT ret = Q931E_NO_ERROR; - if(iFrom == 4) { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); - } else if(state == Q931_U0 && iFrom == 2) { - Q931Tx34(pTrunk,buf,pMes->Size); - ret = Q931ReleaseComplete(pTrunk, buf); - } else { - ret = Q931ProcUnexpectedMessage(pTrunk, buf, iFrom); - } + Q931mes_Generic *pMes = (Q931mes_Generic *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT state = Q931GetCallState(pTrunk, pMes->CRV); + L3INT ret = Q931E_NO_ERROR; + + if (iFrom == 4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); + } + else if (state == Q931_U0 && iFrom == 2) { + Q931Tx34(pTrunk, buf, pMes->Size); + ret = Q931ReleaseComplete(pTrunk, buf); + } else { + ret = Q931ProcUnexpectedMessage(pTrunk, buf, iFrom); + } if (pMes->CRV && iFrom == 2) { /* Find the call using CRV */ if ((Q931FindCRV(pTrunk, pMes->CRV, &callIndex)) != Q931E_NO_ERROR) @@ -813,27 +777,24 @@ L3INT Q931ProcReleaseTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcReleaseCompleteTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Generic *pMes = (Q931mes_Generic *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; - if(iFrom == 2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); - } else { - + if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); + } else { if (pMes->CRV) { /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; pTrunk->call[callIndex].InUse = 0; /* TODO: experimental, send RELEASE_COMPLETE message */ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - } return ret; } @@ -845,32 +806,29 @@ L3INT Q931ProcReleaseCompleteTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT i *****************************************************************************/ L3INT Q931ProcRestartTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; if (pMes->CRV) { /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO - Set correct timer here */ Q931StartTimer(pTrunk, callIndex, 303); } - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); if (pTrunk->autoRestartAck) { Q931AckRestart(pTrunk, buf); @@ -886,30 +844,28 @@ L3INT Q931ProcRestartTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcRestartAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; if (pMes->CRV) { /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; /* TODO - Set correct timer here */ Q931StartTimer(pTrunk, callIndex, 303); } - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -921,28 +877,26 @@ L3INT Q931ProcRestartAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcCongestionControlTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -954,28 +908,26 @@ L3INT Q931ProcCongestionControlTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT *****************************************************************************/ L3INT Q931ProcInformationTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -987,28 +939,26 @@ L3INT Q931ProcInformationTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom *****************************************************************************/ L3INT Q931ProcNotifyTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -1020,28 +970,26 @@ L3INT Q931ProcNotifyTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcStatusTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -1053,28 +1001,26 @@ L3INT Q931ProcStatusTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q931ProcStatusEnquiryTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -1086,28 +1032,26 @@ L3INT Q931ProcStatusEnquiryTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFr *****************************************************************************/ L3INT Q931ProcSegmentTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -1123,28 +1067,26 @@ L3INT Q931ProcSegmentTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q932ProcFacilityTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -1156,28 +1098,26 @@ L3INT Q932ProcFacilityTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q932ProcHoldTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -1189,28 +1129,26 @@ L3INT Q932ProcHoldTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q932ProcHoldAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -1222,28 +1160,26 @@ L3INT Q932ProcHoldAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q932ProcHoldRejectTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -1255,28 +1191,26 @@ L3INT Q932ProcHoldRejectTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q932ProcRegisterTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -1288,28 +1222,26 @@ L3INT Q932ProcRegisterTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q932ProcRetrieveTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -1321,28 +1253,26 @@ L3INT Q932ProcRetrieveTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) *****************************************************************************/ L3INT Q932ProcRetrieveAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } @@ -1354,29 +1284,26 @@ L3INT Q932ProcRetrieveAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom *****************************************************************************/ L3INT Q932ProcRetrieveRejectTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) { - L3INT callIndex; - L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; + L3INT callIndex; + L3INT ret = Q931E_NO_ERROR; /* Find the call using CRV */ ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) + if (ret != Q931E_NO_ERROR) return ret; - /* TODO chack against state table for illegal or unexpected message here*/ + /* TODO chack against state table for illegal or unexpected message here */ /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); - if(iFrom == 4) - { - /* TODO Add proc here*/ - ret = Q931Tx32Data(pTrunk,0,buf,pMes->Size); + Q931StartTimer(pTrunk, callIndex, 303); + if (iFrom ==4) { + /* TODO Add proc here */ + ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size); } - else if (iFrom ==2) - { - /* TODO Add proc here*/ - ret = Q931Tx34(pTrunk,buf,pMes->Size); + else if (iFrom == 2) { + /* TODO Add proc here */ + ret = Q931Tx34(pTrunk, buf, pMes->Size); } return ret; } - diff --git a/libs/freetdm/src/isdn/Q931ie.c b/libs/freetdm/src/isdn/Q931ie.c index d7716bc3da..095e8cd577 100644 --- a/libs/freetdm/src/isdn/Q931ie.c +++ b/libs/freetdm/src/isdn/Q931ie.c @@ -1,28 +1,28 @@ /***************************************************************************** - FileName: Q931ie.c + FileName: Q931ie.c - Contents: Information Element Pack/Unpack functions. + Contents: Information Element Pack/Unpack functions. - These functions will pack out a Q931 message from the bit - packed original format into structs that are easier to process - and pack the same structs back into bit fields when sending - messages out. + These functions will pack out a Q931 message from the bit + packed original format into structs that are easier to process + and pack the same structs back into bit fields when sending + messages out. - The messages contains a short for each possible IE. The MSB - bit flags the precense of an IE, while the remaining bits - are the offset into a buffer to find the actual IE. + The messages contains a short for each possible IE. The MSB + bit flags the precense of an IE, while the remaining bits + are the offset into a buffer to find the actual IE. - Each IE are supported by 3 functions: + Each IE are supported by 3 functions: - Q931Pie_XXX Pack struct into Q.931 IE - Q931Uie_XXX Unpack Q.931 IE into struct - Q931InitIEXXX Initialize IE (see Q931api.c). + Q931Pie_XXX Pack struct into Q.931 IE + Q931Uie_XXX Unpack Q.931 IE into struct + Q931InitIEXXX Initialize IE (see Q931api.c). Dialect Note: This file will only contain standard DSS1 IE. Other IE as - used in QSIG, NI2, Q.932 etc are located in separate files. + used in QSIG, NI2, Q.932 etc are located in separate files. - See q931.h for description. + See q931.h for description. License/Copyright: @@ -33,12 +33,12 @@ modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of the Case Labs, Ltd nor the names of its contributors + * Neither the name of the Case Labs, Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -59,40 +59,39 @@ /***************************************************************************** - Macro: Q931MoreIE + Macro: Q931MoreIE Description: Local helper macro detecting if there is more IE space left - based on the 3 standard parameters Octet, Off and IESpace. - This can be used to test if the IE is completed to avoid - that the header of the next IE is interpreted as a part of - the current IE. + based on the 3 standard parameters Octet, Off and IESpace. + This can be used to test if the IE is completed to avoid + that the header of the next IE is interpreted as a part of + the current IE. *****************************************************************************/ -#define Q931MoreIE() (Octet+Off - 2 < IESize) +#define Q931MoreIE() (Octet + Off - 2 < IESize) -#define Q931IESizeTest(x) {\ - if(Octet+Off-2 != IESize)\ - {\ - Q931SetError(pTrunk,x, Octet, Off);\ - return x;\ - }\ - } +#define Q931IESizeTest(x) {\ + if (Octet + Off - 2 != IESize) {\ + Q931SetError(pTrunk, x, Octet, Off);\ + return x;\ + }\ +} /***************************************************************************** - Function: Q931ReadExt + Function: Q931ReadExt Description: Many of the octets in the standard have an MSB 'ext.1'. This - means that the octet usually is the latest octet, but that a - futhure standard may extend the octet. A stack must be able - to handle such extensions by skipping the extension octets. + means that the octet usually is the latest octet, but that a + futhure standard may extend the octet. A stack must be able + to handle such extensions by skipping the extension octets. - This function will increase the offset counter with 1 for - each octet with an MSB of zero. This will allow the stack to - skip extensions wihout knowing anything about them. + This function will increase the offset counter with 1 for + each octet with an MSB of zero. This will allow the stack to + skip extensions wihout knowing anything about them. - Parameters: IBuf ptr to octet array. - Off Starting offset counter + Parameters: IBuf ptr to octet array. + Off Starting offset counter Return Value: New offset value. @@ -100,27 +99,27 @@ L3INT Q931ReadExt(L3UCHAR * IBuf, L3INT Off) { - L3INT c =0; - while((IBuf[c] & 0x80) == 0) - c++; - - return Off + c; + L3INT c = 0; + while ((IBuf[c] & 0x80) == 0) { + c++; + } + return Off + c; } /***************************************************************************** - Function: Q931Uie_BearerCap + Function: Q931Uie_BearerCap Description: Unpack a bearer capability ie. - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message @@ -128,900 +127,852 @@ L3INT Q931ReadExt(L3UCHAR * IBuf, L3INT Off) L3INT Q931Uie_BearerCap(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_BearerCap * pie = (Q931ie_BearerCap*)OBuf; + Q931ie_BearerCap *pie = (Q931ie_BearerCap*)OBuf; ie *pIE = &pMsg->BearerCap; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; - *pIE=0; + L3INT Off = 0; + L3INT Octet = 0; + L3INT IESize; + *pIE = 0; - /* Octet 1 */ - pie->IEId = IBuf[Octet]; - Octet ++; + /* Octet 1 */ + pie->IEId = IBuf[Octet++]; - /* Octet 2 */ - IESize = IBuf[Octet ++]; + /* Octet 2 */ + IESize = IBuf[Octet++]; - /* Octet 3 */ - pie->CodStand = ieGetOctet((IBuf[Octet] & 0x60) >> 5); - pie->ITC = ieGetOctet(IBuf[Octet] & 0x1f); - Off = Q931ReadExt(&IBuf[Octet], Off); - Octet++; + /* Octet 3 */ + pie->CodStand = ieGetOctet((IBuf[Octet] & 0x60) >> 5); + pie->ITC = ieGetOctet(IBuf[Octet] & 0x1f); + Off = Q931ReadExt(&IBuf[Octet], Off); + Octet++; - /* Octet 4 */ - pie->TransMode = ieGetOctet((IBuf[Octet+Off] & 0x60) >> 5); - pie->ITR = ieGetOctet(IBuf[Octet+Off] & 0x1f); - Off = Q931ReadExt(&IBuf[Octet+Off], Off); - Octet++; + /* Octet 4 */ + pie->TransMode = ieGetOctet((IBuf[Octet + Off] & 0x60) >> 5); + pie->ITR = ieGetOctet(IBuf[Octet + Off] & 0x1f); + Off = Q931ReadExt(&IBuf[Octet + Off], Off); + Octet++; - /* Octet 4.1. Rate multiplier is only present if ITR = Multirate */ - if(pie->ITR == 0x18) - { - pie->RateMul = ieGetOctet(IBuf[Octet+Off] & 0x7f); - Off = Q931ReadExt(&IBuf[Octet+Off], Off); - Off ++; - } + /* Octet 4.1. Rate multiplier is only present if ITR = Multirate */ + if (pie->ITR == 0x18) { + pie->RateMul = ieGetOctet(IBuf[Octet + Off] & 0x7f); + Off = Q931ReadExt(&IBuf[Octet + Off], Off); + Off ++; + } - /* Octet 5 */ - if((IBuf[Octet+Off] & 0x60) == 0x20 && Q931MoreIE()) - { - pie->Layer1Ident = ieGetOctet((IBuf[Octet+Off] & 0x60) >> 5); - pie->UIL1Prot = ieGetOctet(IBuf[Octet+Off] & 0x1f); - Octet++; + /* Octet 5 */ + if ((IBuf[Octet + Off] & 0x60) == 0x20 && Q931MoreIE()) { + pie->Layer1Ident = ieGetOctet((IBuf[Octet + Off] & 0x60) >> 5); + pie->UIL1Prot = ieGetOctet(IBuf[Octet + Off] & 0x1f); + Octet++; - /* Octet 5a. The octet may be present if ITC is unrestrictd digital info*/ - /* and UIL1Prot is either V.110, I.460 and X.30 or V.120. It may also */ - /* be present if ITC = 3.1 kHz audio and UIL1Prot is G.711. */ - /* Bit 8 of Octet 5 = 0 indicates that 5a is present. */ + /* Octet 5a. The octet may be present if ITC is unrestrictd digital info + * and UIL1Prot is either V.110, I.460 and X.30 or V.120. It may also + * be present if ITC = 3.1 kHz audio and UIL1Prot is G.711. + * Bit 8 of Octet 5 = 0 indicates that 5a is present. + */ - if(IsQ931Ext(IBuf[Octet+Off-1])) - { - if(((pie->ITC == 0x08) && (pie->UIL1Prot == 0x01 || pie->UIL1Prot == 0x08)) - || ((pie->ITC == 0x10) && (pie->UIL1Prot == 0x02 || pie->UIL1Prot == 0x03))) - { - pie->SyncAsync = ieGetOctet((IBuf[Octet+Off] & 0x40) >> 6); - pie->Negot = ieGetOctet((IBuf[Octet+Off] & 0x20) >> 5); - pie->UserRate = ieGetOctet(IBuf[Octet+Off] & 0x1f); - Off ++; - } - else - { - /* We have detected bit 8 = 0, but no setting that require the */ - /* additional octets ??? */ - Q931SetError(pTrunk, Q931E_BEARERCAP, 5,Off); - return Q931E_BEARERCAP; - } + if (IsQ931Ext(IBuf[Octet + Off - 1])) { + if (((pie->ITC == 0x08) && (pie->UIL1Prot == 0x01 || pie->UIL1Prot == 0x08)) + || ((pie->ITC == 0x10) && (pie->UIL1Prot == 0x02 || pie->UIL1Prot == 0x03))) { + pie->SyncAsync = ieGetOctet((IBuf[Octet + Off] & 0x40) >> 6); + pie->Negot = ieGetOctet((IBuf[Octet + Off] & 0x20) >> 5); + pie->UserRate = ieGetOctet(IBuf[Octet + Off] & 0x1f); + Off ++; + } + else { + /* We have detected bit 8 = 0, but no setting that require the */ + /* additional octets ??? */ + Q931SetError(pTrunk, Q931E_BEARERCAP, 5,Off); + return Q931E_BEARERCAP; + } - /* Octet 5b. Two different structures used. */ - if(IsQ931Ext(IBuf[Octet+Off-1])) - { - if(pie->UIL1Prot == 0x01) /* ITU V.110, I.460 and X.30 */ - { - pie->InterRate = ieGetOctet((IBuf[Octet+Off] & 0x60) >> 5); - pie->NIConTx = ieGetOctet((IBuf[Octet+Off] & 0x10) >> 4); - pie->NIConRx = ieGetOctet((IBuf[Octet+Off] & 0x08) >> 3); - pie->FlowCtlTx = ieGetOctet((IBuf[Octet+Off] & 0x04) >> 2); - pie->FlowCtlRx = ieGetOctet((IBuf[Octet+Off] & 0x20) >> 1); - Off++; - } - else if(pie->UIL1Prot == 0x08) /* ITU V.120 */ - { - pie->HDR = ieGetOctet((IBuf[Octet+Off] & 0x40) >> 6); - pie->MultiFrame = ieGetOctet((IBuf[Octet+Off] & 0x20) >> 5); - pie->Mode = ieGetOctet((IBuf[Octet+Off] & 0x10) >> 4); - pie->LLInegot = ieGetOctet((IBuf[Octet+Off] & 0x08) >> 3); - pie->Assignor = ieGetOctet((IBuf[Octet+Off] & 0x04) >> 2); - pie->InBandNeg = ieGetOctet((IBuf[Octet+Off] & 0x02) >> 1); - Off++; - } - else - { - Q931SetError(pTrunk,Q931E_BEARERCAP, 5,Off); - return Q931E_BEARERCAP; + /* Octet 5b. Two different structures used. */ + if (IsQ931Ext(IBuf[Octet + Off - 1])) { + if (pie->UIL1Prot == 0x01) { /* ITU V.110, I.460 and X.30 */ + pie->InterRate = ieGetOctet((IBuf[Octet + Off] & 0x60) >> 5); + pie->NIConTx = ieGetOctet((IBuf[Octet + Off] & 0x10) >> 4); + pie->NIConRx = ieGetOctet((IBuf[Octet + Off] & 0x08) >> 3); + pie->FlowCtlTx = ieGetOctet((IBuf[Octet + Off] & 0x04) >> 2); + pie->FlowCtlRx = ieGetOctet((IBuf[Octet + Off] & 0x20) >> 1); + Off++; + } + else if (pie->UIL1Prot == 0x08) { /* ITU V.120 */ + pie->HDR = ieGetOctet((IBuf[Octet + Off] & 0x40) >> 6); + pie->MultiFrame = ieGetOctet((IBuf[Octet + Off] & 0x20) >> 5); + pie->Mode = ieGetOctet((IBuf[Octet + Off] & 0x10) >> 4); + pie->LLInegot = ieGetOctet((IBuf[Octet + Off] & 0x08) >> 3); + pie->Assignor = ieGetOctet((IBuf[Octet + Off] & 0x04) >> 2); + pie->InBandNeg = ieGetOctet((IBuf[Octet + Off] & 0x02) >> 1); + Off++; + } + else { + Q931SetError(pTrunk,Q931E_BEARERCAP, 5,Off); + return Q931E_BEARERCAP; + } - } + /* Octet 5c */ + if (IsQ931Ext(IBuf[Octet + Off - 1])) { + pie->NumStopBits = ieGetOctet((IBuf[Octet + Off] & 0x60) >> 5); + pie->NumDataBits = ieGetOctet((IBuf[Octet + Off] & 0x18) >> 3); + pie->Parity = ieGetOctet(IBuf[Octet + Off] & 0x07); + Off++; - /* Octet 5c */ - if(IsQ931Ext(IBuf[Octet+Off-1])) - { + /* Octet 5d */ + if (IsQ931Ext(IBuf[Octet + Off - 1])) { + pie->DuplexMode = ieGetOctet((IBuf[Octet + Off] & 0x40) >> 6); + pie->ModemType = ieGetOctet(IBuf[Octet + Off] & 0x3f); + Off ++; + } + } + } + } + } - pie->NumStopBits = ieGetOctet((IBuf[Octet+Off] & 0x60) >> 5); - pie->NumDataBits = ieGetOctet((IBuf[Octet+Off] & 0x18) >> 3); - pie->Parity = ieGetOctet(IBuf[Octet+Off] & 0x07); - Off++; + /* Octet 6 */ + if ((IBuf[Octet + Off] & 0x60) == 0x40 && Q931MoreIE()) { + pie->Layer2Ident = ieGetOctet((IBuf[Octet + Off] & 0x60) >> 5); + pie->UIL2Prot = ieGetOctet(IBuf[Octet + Off] & 0x1f); - /* Octet 5d */ - if(IsQ931Ext(IBuf[Octet+Off-1])) - { + Off = Q931ReadExt(&IBuf[Octet + Off], Off); + Octet ++; + } - pie->DuplexMode = ieGetOctet((IBuf[Octet+Off] & 0x40) >> 6); - pie->ModemType = ieGetOctet(IBuf[Octet+Off] & 0x3f); - Off ++; - } - } - } - } - } + /* Octet 7 */ + if ((IBuf[Octet + Off] & 0x60) == 0x60 && Q931MoreIE()) { + pie->Layer3Ident = ieGetOctet((IBuf[Octet + Off] & 0x60) >> 5); + pie->UIL3Prot = ieGetOctet(IBuf[Octet + Off] & 0x1f); + Octet++; - /* Octet 6 */ - if((IBuf[Octet+Off] & 0x60) == 0x40 && Q931MoreIE()) - { - pie->Layer2Ident = ieGetOctet((IBuf[Octet+Off] & 0x60) >> 5); - pie->UIL2Prot = ieGetOctet(IBuf[Octet+Off] & 0x1f); + /* Octet 7a */ + if (IsQ931Ext(IBuf[Octet + Off - 1])) { + if (pie->UIL3Prot == 0x0c) { + pie->AL3Info1 = ieGetOctet(IBuf[Octet + Off] & 0x0f); + Off++; - Off = Q931ReadExt(&IBuf[Octet+Off], Off); - Octet ++; - } + /* Octet 7b */ + if (IsQ931Ext(IBuf[Octet + Off])) { + pie->AL3Info2 = ieGetOctet(IBuf[Octet + Off] & 0x0f); + Off++; + } + } + else { + Q931SetError(pTrunk,Q931E_BEARERCAP, 7, Off); + return Q931E_BEARERCAP; - /* Octet 7 */ - if((IBuf[Octet+Off] & 0x60) == 0x60 && Q931MoreIE()) - { - pie->Layer3Ident = ieGetOctet((IBuf[Octet+Off] & 0x60) >> 5); - pie->UIL3Prot = ieGetOctet(IBuf[Octet+Off] & 0x1f); - Octet++; + } + } + } - /* Octet 7a */ - if(IsQ931Ext(IBuf[Octet+Off-1])) - { - if(pie->UIL3Prot == 0x0c) - { - pie->AL3Info1 = ieGetOctet(IBuf[Octet+Off] & 0x0f); - Off++; - - /* Octet 7b */ - if(IsQ931Ext(IBuf[Octet+Off])) - { - pie->AL3Info2 = ieGetOctet(IBuf[Octet+Off] & 0x0f); - Off++; - } - } - else - { - Q931SetError(pTrunk,Q931E_BEARERCAP, 7, Off); - return Q931E_BEARERCAP; - - } - } - } - - Q931IESizeTest(Q931E_BEARERCAP); - - Q931SetIE(*pIE, *OOff); + Q931IESizeTest(Q931E_BEARERCAP); + Q931SetIE(*pIE, *OOff); *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_BearerCap); - pie->Size = sizeof(Q931ie_BearerCap); + *OOff = (*OOff) + sizeof(Q931ie_BearerCap); + pie->Size = sizeof(Q931ie_BearerCap); - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_BearerCap + Function: Q931Pie_BearerCap Description: Packing a Q.931 Bearer Capability element from a generic - struct into a packed octet structure in accordance with the - standard. + struct into a packed octet structure in accordance with the + standard. - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_BearerCap(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_BearerCap * pIE = (Q931ie_BearerCap*)IBuf; - L3INT rc=0; - L3INT Beg=*Octet;/* remember current offset */ - L3INT li; + Q931ie_BearerCap *pIE = (Q931ie_BearerCap*)IBuf; + L3INT rc = 0; + L3INT Beg = *Octet; /* remember current offset */ + L3INT li; Q931Log(pTrunk, Q931_LOG_DEBUG, "Encoding Bearer Capability IE\n"); - OBuf[(*Octet)++] = Q931ie_BEARER_CAPABILITY ; - li=(*Octet)++; /* remember length position */ + OBuf[(*Octet)++] = Q931ie_BEARER_CAPABILITY ; + li = (*Octet)++; /* remember length position */ - /* Octet 3 - Coding standard / Information transfer capability */ + /* Octet 3 - Coding standard / Information transfer capability */ OBuf[(*Octet)++] = 0x80 | ((pIE->CodStand << 5) & 0x60) | (pIE->ITC & 0x1f); - /* Octet 4 - Transfer mode / Information transfer rate */ + /* Octet 4 - Transfer mode / Information transfer rate */ OBuf[(*Octet)++] = 0x80 | ((pIE->TransMode << 5) & 0x60) | (pIE->ITR & 0x1f); - if(pIE->ITR == 0x18) - { - /* Octet 4.1 - Rate Multiplier */ + if (pIE->ITR == 0x18) { + /* Octet 4.1 - Rate Multiplier */ OBuf[(*Octet)++] = 0x80 | (pIE->RateMul & 0x7f); - } + } /* Octet 5 - Layer 1 Ident / User information layer 1 protocol */ - if(pIE->Layer1Ident == 0x01) - { - if(((pIE->ITC == 0x08) && (pIE->UIL1Prot == 0x01 || pIE->UIL1Prot == 0x08)) || - ((pIE->ITC == 0x10) && (pIE->UIL1Prot == 0x02 || pIE->UIL1Prot == 0x03))) - { + if (pIE->Layer1Ident == 0x01) { + if (((pIE->ITC == 0x08) && (pIE->UIL1Prot == 0x01 || pIE->UIL1Prot == 0x08)) || + ((pIE->ITC == 0x10) && (pIE->UIL1Prot == 0x02 || pIE->UIL1Prot == 0x03))) { OBuf[(*Octet)++] = 0x00 | ((pIE->Layer1Ident << 5) & 0x60) | (pIE->UIL1Prot & 0x15); - - /* Octet 5a - SyncAsync/Negot/UserRate */ + + /* Octet 5a - SyncAsync/Negot/UserRate */ OBuf[(*Octet)++] = 0x00 | ((pIE->SyncAsync << 6) & 0x40) | ((pIE->Negot << 5) & 0x20) | (pIE->UserRate & 0x1f); - /* Octet 5b - one of two types */ - if(pIE->UIL1Prot == 0x01) /* ITU V.110, I.460 and X.30 */ - { - /* Octet 5b - Intermed rate/ Nic on Tx/Nix on Rx/FlowCtlTx/FlowCtlRx */ - OBuf[(*Octet)++] = 0x00 + /* Octet 5b - one of two types */ + if (pIE->UIL1Prot == 0x01) { /* ITU V.110, I.460 and X.30 */ + /* Octet 5b - Intermed rate/ Nic on Tx/Nix on Rx/FlowCtlTx/FlowCtlRx */ + OBuf[(*Octet)++] = 0x00 | ((pIE->InterRate << 6) & 0x60) | ((pIE->NIConTx << 4) & 0x10) | ((pIE->NIConRx << 3) & 0x08) | ((pIE->FlowCtlTx << 2) & 0x04) | ((pIE->FlowCtlRx << 1) & 0x02); - } - else if(pIE->UIL1Prot == 0x08) /* ITU V.120 */ - { - /* Octet 5b - HDR/Multiframe/Mode/LLINegot/Assignor/Inbandneg*/ - OBuf[(*Octet)++] = 0x00 + } + else if (pIE->UIL1Prot == 0x08) { /* ITU V.120 */ + /* Octet 5b - HDR/Multiframe/Mode/LLINegot/Assignor/Inbandneg*/ + OBuf[(*Octet)++] = 0x00 | ((pIE->InterRate << 6) & 0x60) | ((pIE->MultiFrame << 5) & 0x20) | ((pIE->Mode << 4) & 0x10) | ((pIE->LLInegot << 3) & 0x08) | ((pIE->Assignor << 2) & 0x04) | ((pIE->InBandNeg << 1) & 0x02); - } + } - /* Octet 5c - NumStopBits/NumStartBits/Parity */ - OBuf[(*Octet)++] = 0x00 + /* Octet 5c - NumStopBits/NumStartBits/Parity */ + OBuf[(*Octet)++] = 0x00 | ((pIE->NumStopBits << 5) & 0x60) | ((pIE->NumDataBits << 3) & 0x18) | (pIE->Parity & 0x07); - /* Octet 5d - Duplex Mode/Modem Type */ + /* Octet 5d - Duplex Mode/Modem Type */ OBuf[(*Octet)++] = 0x80 | ((pIE->DuplexMode << 6) & 0x40) | (pIE->ModemType & 0x3f); - } + } else { OBuf[(*Octet)++] = 0x80 | ((pIE->Layer1Ident << 5) & 0x60) | (pIE->UIL1Prot & 0x1f); - } - } + } + } - /* Octet 6 - Layer2Ident/User information layer 2 prtocol */ - if(pIE->Layer2Ident == 0x02) { + /* Octet 6 - Layer2Ident/User information layer 2 prtocol */ + if (pIE->Layer2Ident == 0x02) { OBuf[(*Octet)++] = 0x80 | ((pIE->Layer2Ident << 5) & 0x60) | (pIE->UIL2Prot & 0x1f); - } + } - /* Octet 7 - Layer 3 Ident/ User information layer 3 protocol */ - if(pIE->Layer3Ident == 0x03) - { - if(pIE->UIL3Prot == 0x0c) - { + /* Octet 7 - Layer 3 Ident/ User information layer 3 protocol */ + if (pIE->Layer3Ident == 0x03) { + if (pIE->UIL3Prot == 0x0c) { OBuf[(*Octet)++] = 0x00 | ((pIE->Layer3Ident << 5) & 0x60) | (pIE->UIL3Prot & 0x1f); - /* Octet 7a - Additional information layer 3 msb */ + /* Octet 7a - Additional information layer 3 msb */ OBuf[(*Octet)++] = 0x00 | (pIE->AL3Info1 & 0x0f); - /* Octet 7b - Additional information layer 3 lsb */ + /* Octet 7b - Additional information layer 3 lsb */ OBuf[(*Octet)++] = 0x80 | (pIE->AL3Info2 & 0x0f); - } + } else { OBuf[(*Octet)++] = 0x80 | ((pIE->Layer3Ident << 5) & 0x60) | (pIE->UIL3Prot & 0x1f); - } - } + } + } - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; + OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; + return rc; } /***************************************************************************** - Function: Q931Uie_CallID + Function: Q931Uie_CallID - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_CallID(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_CallID * pie = (Q931ie_CallID*)OBuf; + Q931ie_CallID *pie = (Q931ie_CallID*)OBuf; ie *pIE = &pMsg->CallID; - L3INT Off = 0; - L3INT Octet = 0; - L3INT x=0; - L3INT IESize; + L3INT Off = 0; + L3INT Octet = 0; + L3INT x = 0; + L3INT IESize; - *pIE=0; + *pIE = 0; - /* Octet 1 */ - pie->IEId = IBuf[Octet]; - Octet ++; + /* Octet 1 */ + pie->IEId = IBuf[Octet++]; - /* Octet 2 */ - IESize = IBuf[Octet ++]; + /* Octet 2 */ + IESize = IBuf[Octet++]; - /* Octet 3 */ - do{ - pie->CallId[x] = IBuf[Octet+Off] & 0x7f; - Off++; - x++; - }while(Q931MoreIE()); + /* Octet 3 */ + do { + pie->CallId[x] = IBuf[Octet + Off] & 0x7f; + Off++; + x++; + } while (Q931MoreIE()); - Q931IESizeTest(Q931E_CALLID); - - Q931SetIE(*pIE, *OOff); + Q931IESizeTest(Q931E_CALLID); + Q931SetIE(*pIE, *OOff); *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_CallID) + x -1; - pie->Size = (L3UCHAR)(sizeof(Q931ie_CallID) + x -1); + *OOff = (*OOff) + sizeof(Q931ie_CallID) + x - 1; + pie->Size = (L3UCHAR)(sizeof(Q931ie_CallID) + x - 1); - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_CallID + Function: Q931Pie_CallID - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_CallID(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_CallID * pIE = (Q931ie_CallID*)IBuf; - L3INT rc=0; - L3INT Beg=*Octet;/* remember current offset */ - L3INT li; - L3INT sCI = pIE->Size - sizeof(Q931ie_CallID) + 1; - L3INT x; + Q931ie_CallID *pIE = (Q931ie_CallID*)IBuf; + L3INT rc = 0; + L3INT Beg = *Octet;/* remember current offset */ + L3INT li; + L3INT sCI = pIE->Size - sizeof(Q931ie_CallID) + 1; + L3INT x; - OBuf[(*Octet)++] = Q931ie_CALL_IDENTITY ; - li=(*Octet)++; /* remember length position */ + OBuf[(*Octet)++] = Q931ie_CALL_IDENTITY ; + li = (*Octet)++; /* remember length position */ - for(x=0;x < sCI; x++) - { - OBuf[(*Octet)++] = pIE->CallId[x]; - } + for (x = 0; x < sCI; x++) { + OBuf[(*Octet)++] = pIE->CallId[x]; + } - OBuf[(*Octet)-1] |= 0x80; /* set complete flag at last octet*/ + OBuf[(*Octet) - 1] |= 0x80; /* set complete flag at last octet*/ - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; + OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; + return rc; } /***************************************************************************** - Function: Q931Uie_CallState + Function: Q931Uie_CallState - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_CallState(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_CallState * pie = (Q931ie_CallState*)OBuf; + Q931ie_CallState *pie = (Q931ie_CallState*)OBuf; ie *pIE = &pMsg->CallState; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; + L3INT Off = 0; + L3INT Octet = 0; + L3INT IESize; - *pIE=0; + *pIE = 0; - /* Octet 1 */ - pie->IEId = IBuf[Octet]; - Octet ++; + /* Octet 1 */ + pie->IEId = IBuf[Octet++]; - /* Octet 2 */ - IESize = IBuf[Octet ++]; + /* Octet 2 */ + IESize = IBuf[Octet++]; + /* Octet 3 */ + pie->CodStand = (IBuf[Octet + Off] >> 6) & 0x03; + pie->CallState = IBuf[Octet + Off] & 0x3f; + Octet++; - /* Octet 3 */ - pie->CodStand = (IBuf[Octet+Off] >> 6) & 0x03; - pie->CallState= IBuf[Octet+Off] & 0x3f; - - Octet++; - - Q931IESizeTest(Q931E_CALLSTATE); - - Q931SetIE(*pIE, *OOff); + Q931IESizeTest(Q931E_CALLSTATE); + Q931SetIE(*pIE, *OOff); *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_CallState); - pie->Size = sizeof(Q931ie_CallState); + *OOff = (*OOff) + sizeof(Q931ie_CallState); + pie->Size = sizeof(Q931ie_CallState); - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_CallState + Function: Q931Pie_CallState - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_CallState(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_CallState * pIE = (Q931ie_CallState*)IBuf; - L3INT rc=0; - L3INT Beg=*Octet;/* remember current offset */ - L3INT li; + Q931ie_CallState *pIE = (Q931ie_CallState*)IBuf; + L3INT rc = 0; + L3INT Beg = *Octet; /* remember current offset */ + L3INT li; - OBuf[(*Octet)++] = Q931ie_CALL_STATE; - li=(*Octet)++; /* remember length position */ + OBuf[(*Octet)++] = Q931ie_CALL_STATE; + li = (*Octet)++; /* remember length position */ - OBuf[(*Octet)++] = 0x80 | (pIE->CodStand<<6) | pIE->CallState; + OBuf[(*Octet)++] = 0x80 | (pIE->CodStand<<6) | pIE->CallState; - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; + OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; + return rc; } /***************************************************************************** - Function: Q931Uie_CalledSub + Function: Q931Uie_CalledSub - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_CalledSub(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_CalledSub * pie = (Q931ie_CalledSub*)OBuf; + Q931ie_CalledSub *pie = (Q931ie_CalledSub*)OBuf; ie *pIE = &pMsg->CalledSub; - L3INT Off = 0; - L3INT Octet = 0; - L3INT x; - L3INT IESize; + L3INT Off = 0; + L3INT Octet = 0; + L3INT x; + L3INT IESize; - *pIE=0; + *pIE = 0; - /* Octet 1 */ - pie->IEId = IBuf[Octet]; - Octet ++; + /* Octet 1 */ + pie->IEId = IBuf[Octet++]; - /* Octet 2 */ - IESize = IBuf[Octet ++]; + /* Octet 2 */ + IESize = IBuf[Octet++]; - /* Octet 3 */ - pie->TypNum = (IBuf[Octet+Off] >> 4) & 0x07; - pie->OddEvenInd = (IBuf[Octet+Off] >> 3) & 0x01; - Octet ++; - - /* Octet 4 */ - x=0; - do{ - pie->Digit[x] = IBuf[Octet+Off] & 0x7f; - Off++; - x++; - }while(Q931MoreIE() && x < 20); + /* Octet 3 */ + pie->TypNum = (IBuf[Octet + Off] >> 4) & 0x07; + pie->OddEvenInd = (IBuf[Octet + Off] >> 3) & 0x01; + Octet++; + + /* Octet 4 */ + x = 0; + do { + pie->Digit[x] = IBuf[Octet + Off] & 0x7f; + Off++; + x++; + } while (Q931MoreIE() && x < 20); - Q931IESizeTest(Q931E_CALLEDSUB); - - Q931SetIE(*pIE, *OOff); + Q931IESizeTest(Q931E_CALLEDSUB); + Q931SetIE(*pIE, *OOff); *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_CalledSub) + x - 1; - pie->Size = (L3UCHAR)(sizeof(Q931ie_CalledSub) + x - 1); + *OOff = (*OOff) + sizeof(Q931ie_CalledSub) + x - 1; + pie->Size = (L3UCHAR)(sizeof(Q931ie_CalledSub) + x - 1); - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_CalledSub + Function: Q931Pie_CalledSub - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_CalledSub(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_CalledSub * pIE = (Q931ie_CalledSub*)IBuf; - L3INT rc=0; - L3INT Beg=*Octet; - L3INT li; - L3INT sN = pIE->Size - sizeof(Q931ie_CalledSub) + 1; - L3INT x; + Q931ie_CalledSub *pIE = (Q931ie_CalledSub*)IBuf; + L3INT rc = 0; + L3INT Beg = *Octet; + L3INT li; + L3INT sN = pIE->Size - sizeof(Q931ie_CalledSub) + 1; + L3INT x; - /* Octet 1 */ - OBuf[(*Octet)++] = Q931ie_CALLED_PARTY_SUBADDRESS; - li=(*Octet)++; + /* Octet 1 */ + OBuf[(*Octet)++] = Q931ie_CALLED_PARTY_SUBADDRESS; + li = (*Octet)++; - /* Octet 3 */ - OBuf[(*Octet)++] = 0x80 | (pIE->TypNum << 4) | (pIE->OddEvenInd << 3); - - /* Octet 4 */ - for(x=0;xDigit[x]; - } + /* Octet 3 */ + OBuf[(*Octet)++] = 0x80 | (pIE->TypNum << 4) | (pIE->OddEvenInd << 3); + + /* Octet 4 */ + for (x = 0; xDigit[x]; + } - OBuf[(*Octet)-1] |= 0x80; /* Terminate bit */ + OBuf[(*Octet) - 1] |= 0x80; /* Terminate bit */ - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; + OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; + return rc; } /***************************************************************************** - Function: Q931Uie_CalledNum + Function: Q931Uie_CalledNum - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_CalledNum(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_CalledNum * pie = (Q931ie_CalledNum*)OBuf; + Q931ie_CalledNum *pie = (Q931ie_CalledNum*)OBuf; ie *pIE = &pMsg->CalledNum; - L3INT Off = 0; - L3INT Octet = 0; - L3INT x; - L3INT IESize; /* # digits in this case */ + L3INT Off = 0; + L3INT Octet = 0; + L3INT x; + L3INT IESize; /* # digits in this case */ - *pIE=0; + *pIE = 0; - /* Octet 1 */ - pie->IEId = IBuf[Octet++]; + /* Octet 1 */ + pie->IEId = IBuf[Octet++]; - /* Octet 2 */ - IESize = IBuf[Octet ++]; + /* Octet 2 */ + IESize = IBuf[Octet++]; - /* Octet 3 */ - pie->TypNum = (IBuf[Octet+Off] >> 4) & 0x07; - pie->NumPlanID = IBuf[Octet+Off] & 0x0f; - Octet ++; + /* Octet 3 */ + pie->TypNum = (IBuf[Octet + Off] >> 4) & 0x07; + pie->NumPlanID = IBuf[Octet + Off] & 0x0f; + Octet++; - /* Octet 4*/ - x=0; - do{ - pie->Digit[x] = IBuf[Octet+Off] & 0x7f; - Off++; - x++; - } while((IBuf[Octet+Off]&0x80) == 0 && Q931MoreIE()); + /* Octet 4*/ + x = 0; + do { + pie->Digit[x] = IBuf[Octet + Off] & 0x7f; + Off++; + x++; + } while ((IBuf[Octet + Off]&0x80) == 0 && Q931MoreIE()); pie->Digit[x] = '\0'; - Q931SetIE(*pIE, *OOff); + Q931SetIE(*pIE, *OOff); *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_CalledNum) + x; - pie->Size = (L3UCHAR)(sizeof(Q931ie_CalledNum) + x); + *OOff = (*OOff) + sizeof(Q931ie_CalledNum) + x; + pie->Size = (L3UCHAR)(sizeof(Q931ie_CalledNum) + x); - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_CalledNum + Function: Q931Pie_CalledNum - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_CalledNum(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_CalledNum * pIE = (Q931ie_CalledNum*)IBuf; - L3INT rc=0; - L3INT Beg=*Octet; - L3INT li; - L3INT sN = pIE->Size - sizeof(Q931ie_CalledNum); - L3INT x; + Q931ie_CalledNum *pIE = (Q931ie_CalledNum*)IBuf; + L3INT rc = 0; + L3INT Beg = *Octet; + L3INT li; + L3INT sN = pIE->Size - sizeof(Q931ie_CalledNum); + L3INT x; - /* Octet 1 */ - OBuf[(*Octet)++] = Q931ie_CALLED_PARTY_NUMBER; - + /* Octet 1 */ + OBuf[(*Octet)++] = Q931ie_CALLED_PARTY_NUMBER; + /* Octet 2 */ - li=(*Octet)++; + li = (*Octet)++; - /* Octet 3 */ - OBuf[(*Octet)++] = 0x80 | (pIE->TypNum << 4) | (pIE->NumPlanID); - - /* Octet 4 */ - for(x=0;xDigit[x]; - } + /* Octet 3 */ + OBuf[(*Octet)++] = 0x80 | (pIE->TypNum << 4) | (pIE->NumPlanID); + + /* Octet 4 */ + for (x = 0; xDigit[x]; + } - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; + OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; + return rc; } /***************************************************************************** - Function: Q931Uie_CallingNum + Function: Q931Uie_CallingNum - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_CallingNum(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_CallingNum * pie = (Q931ie_CallingNum*)OBuf; + Q931ie_CallingNum *pie = (Q931ie_CallingNum*)OBuf; ie *pIE = &pMsg->CallingNum; - L3INT Off = 0; - L3INT Octet = 0; - L3INT x; - L3INT IESize; + L3INT Off = 0; + L3INT Octet = 0; + L3INT x; + L3INT IESize; - *pIE=0; + *pIE = 0; - /* Octet 1 */ - pie->IEId = IBuf[Octet]; - Octet ++; + /* Octet 1 */ + pie->IEId = IBuf[Octet++]; - /* Octet 2 */ - IESize = IBuf[Octet ++]; + /* Octet 2 */ + IESize = IBuf[Octet++]; - /* Octet 3 */ - pie->TypNum = (IBuf[Octet+Off] >> 4) & 0x07; - pie->NumPlanID = IBuf[Octet+Off] & 0x0f; - - /* Octet 3a */ - if((IBuf[Octet+Off] & 0x80) != 0) - { - Off++; - pie->PresInd = (IBuf[Octet+Off] >> 5) & 0x03; - pie->ScreenInd = IBuf[Octet+Off] & 0x03; - } - Octet++; + /* Octet 3 */ + pie->TypNum = (IBuf[Octet + Off] >> 4) & 0x07; + pie->NumPlanID = IBuf[Octet + Off] & 0x0f; + + /* Octet 3a */ + if ((IBuf[Octet + Off] & 0x80) != 0) { + Off++; + pie->PresInd = (IBuf[Octet + Off] >> 5) & 0x03; + pie->ScreenInd = IBuf[Octet + Off] & 0x03; + } + Octet++; - /* Octet 4*/ - x=0; - do{ - pie->Digit[x] = IBuf[Octet+Off] & 0x7f; - Off++; - x++; - } while((IBuf[Octet+Off]&0x80) == 0 && Q931MoreIE()); + /* Octet 4*/ + x = 0; + do { + pie->Digit[x] = IBuf[Octet + Off] & 0x7f; + Off++; + x++; + } while ((IBuf[Octet + Off]&0x80) == 0 && Q931MoreIE()); pie->Digit[x] = '\0'; - Q931IESizeTest(Q931E_CALLINGNUM); + Q931IESizeTest(Q931E_CALLINGNUM); + Q931SetIE(*pIE, *OOff); - Q931SetIE(*pIE, *OOff); + *IOff = (*IOff) + Octet + Off; + *OOff = (*OOff) + sizeof(Q931ie_CallingNum) + x; + pie->Size = (L3UCHAR)(sizeof(Q931ie_CallingNum) + x); - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_CallingNum) + x; - pie->Size = (L3UCHAR)(sizeof(Q931ie_CallingNum) + x); - - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_CallingNum + Function: Q931Pie_CallingNum - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_CallingNum(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_CallingNum * pIE = (Q931ie_CallingNum*)IBuf; - L3INT rc=0; - L3INT Beg=*Octet; - L3INT li; - L3INT sN = pIE->Size - sizeof(Q931ie_CallingNum); - L3INT x; + Q931ie_CallingNum *pIE = (Q931ie_CallingNum*)IBuf; + L3INT rc = 0; + L3INT Beg = *Octet; + L3INT li; + L3INT sN = pIE->Size - sizeof(Q931ie_CallingNum); + L3INT x; - /* Octet 1 */ - OBuf[(*Octet)++] = Q931ie_CALLING_PARTY_NUMBER; + /* Octet 1 */ + OBuf[(*Octet)++] = Q931ie_CALLING_PARTY_NUMBER; /* Octet 2 */ - li=(*Octet)++; + li = (*Octet)++; - /* Octet 3 */ - OBuf[(*Octet)++] = 0x00 | (pIE->TypNum << 4) | (pIE->NumPlanID); - - /* Octet 4 */ - OBuf[(*Octet)++] = 0x80; + /* Octet 3 */ + OBuf[(*Octet)++] = 0x00 | (pIE->TypNum << 4) | (pIE->NumPlanID); + + /* Octet 4 */ + OBuf[(*Octet)++] = 0x80; - /* Octet 5 */ - for(x=0;xDigit[x]; - } + /* Octet 5 */ + for (x = 0; xDigit[x]; + } - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; + OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; + return rc; } /***************************************************************************** - Function: Q931Uie_CallingSub + Function: Q931Uie_CallingSub - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_CallingSub(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_CallingSub * pie = (Q931ie_CallingSub*)OBuf; + Q931ie_CallingSub *pie = (Q931ie_CallingSub*)OBuf; ie *pIE = &pMsg->CallingSub; - L3INT Off = 0; - L3INT Octet = 0; - L3INT x; - L3INT IESize; + L3INT Off = 0; + L3INT Octet = 0; + L3INT x; + L3INT IESize; - *pIE=0; + *pIE = 0; - /* Octet 1 */ - pie->IEId = IBuf[Octet]; - Octet ++; + /* Octet 1 */ + pie->IEId = IBuf[Octet++]; - /* Octet 2 */ - IESize = IBuf[Octet ++]; + /* Octet 2 */ + IESize = IBuf[Octet++]; - /* Octet 3 */ - pie->TypNum = (IBuf[Octet+Off] >> 4) & 0x07; - pie->OddEvenInd = (IBuf[Octet+Off] >> 3) & 0x01; - Octet ++; - - /* Octet 4*/ - x=0; - do{ - pie->Digit[x] = IBuf[Octet+Off] & 0x7f; - Off++; - x++; - }while(Q931MoreIE() && x < 20); + /* Octet 3 */ + pie->TypNum = (IBuf[Octet + Off] >> 4) & 0x07; + pie->OddEvenInd = (IBuf[Octet + Off] >> 3) & 0x01; + Octet++; + + /* Octet 4*/ + x = 0; + do { + pie->Digit[x] = IBuf[Octet + Off] & 0x7f; + Off++; + x++; + } while (Q931MoreIE() && x < 20); - Q931IESizeTest(Q931E_CALLINGSUB); + Q931IESizeTest(Q931E_CALLINGSUB); + Q931SetIE(*pIE, *OOff); - Q931SetIE(*pIE, *OOff); + *IOff = (*IOff) + Octet + Off; + *OOff = (*OOff) + sizeof(Q931ie_CallingSub) + x -1; + pie->Size = (L3UCHAR)(sizeof(Q931ie_CallingSub) + x -1); - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_CallingSub) + x -1; - pie->Size = (L3UCHAR)(sizeof(Q931ie_CallingSub) + x -1); - - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_CallingSub + Function: Q931Pie_CallingSub - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_CallingSub(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_CallingSub * pIE = (Q931ie_CallingSub*)IBuf; - L3INT rc=0; - L3INT Beg=*Octet; - L3INT li; - L3INT sN = pIE->Size - sizeof(Q931ie_CallingSub) + 1; - L3INT x; + Q931ie_CallingSub *pIE = (Q931ie_CallingSub*)IBuf; + L3INT rc = 0; + L3INT Beg = *Octet; + L3INT li; + L3INT sN = pIE->Size - sizeof(Q931ie_CallingSub) + 1; + L3INT x; - /* Octet 1 */ - OBuf[(*Octet)++] = Q931ie_CALLING_PARTY_SUBADDRESS; - li=(*Octet)++; + /* Octet 1 */ + OBuf[(*Octet)++] = Q931ie_CALLING_PARTY_SUBADDRESS; + li = (*Octet)++; - /* Octet 3 */ - OBuf[(*Octet)++] = 0x80 | (pIE->TypNum << 4) | (pIE->OddEvenInd << 3); - - /* Octet 4 */ - for(x=0;xDigit[x]; - } + /* Octet 3 */ + OBuf[(*Octet)++] = 0x80 | (pIE->TypNum << 4) | (pIE->OddEvenInd << 3); + + /* Octet 4 */ + for (x = 0; xDigit[x]; + } - OBuf[(*Octet)-1] |= 0x80; /* Terminate bit */ + OBuf[(*Octet) - 1] |= 0x80; /* Terminate bit */ - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; + OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; + return rc; } /***************************************************************************** - Function: Q931Uie_Cause + Function: Q931Uie_Cause - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_Cause(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_Cause * pie = (Q931ie_Cause*)OBuf; + Q931ie_Cause *pie = (Q931ie_Cause*)OBuf; ie *pIE = &pMsg->Cause; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; + L3INT Off = 0; + L3INT Octet = 0; + L3INT IESize; - *pIE=0; + *pIE = 0; - pie->IEId = IBuf[Octet]; - Octet ++; + pie->IEId = IBuf[Octet++]; - /* Octet 2*/ - IESize = IBuf[Octet ++]; + /* Octet 2*/ + IESize = IBuf[Octet++]; - /* Octet 3*/ - pie->CodStand = (IBuf[Octet+Off]>>5) & 0x03; - pie->Location = IBuf[Octet+Off] & 0x0f; + /* Octet 3*/ + pie->CodStand = (IBuf[Octet + Off]>>5) & 0x03; + pie->Location = IBuf[Octet + Off] & 0x0f; - /* Octet 3a */ - if((IBuf[Octet+Off] & 0x80) == 0) - { - Off++; - pie->Recom = IBuf[Octet+Off] & 0x7f; - } - Octet++; + /* Octet 3a */ + if ((IBuf[Octet + Off] & 0x80) == 0) { + Off++; + pie->Recom = IBuf[Octet + Off] & 0x7f; + } + Octet++; - /* Octet 4 */ - pie->Value = IBuf[Octet+Off] & 0x7f; + /* Octet 4 */ + pie->Value = IBuf[Octet + Off] & 0x7f; Octet++; /* Consume optional Diagnostic bytes */ @@ -1030,124 +981,123 @@ L3INT Q931Uie_Cause(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * I }; Q931IESizeTest(Q931E_CAUSE); + Q931SetIE(*pIE, *OOff); - Q931SetIE(*pIE, *OOff); + *IOff = (*IOff) + Octet + Off; + *OOff = (*OOff) + sizeof(Q931ie_Cause); + pie->Size = sizeof(Q931ie_Cause); - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_Cause); - pie->Size = sizeof(Q931ie_Cause); - - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_Cause + Function: Q931Pie_Cause - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_Cause(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_Cause * pIE = (Q931ie_Cause*)IBuf; - L3INT rc=0; - L3INT Beg=*Octet; - L3INT li; + Q931ie_Cause *pIE = (Q931ie_Cause*)IBuf; + L3INT rc = 0; + L3INT Beg = *Octet; + L3INT li; - OBuf[(*Octet)++] = Q931ie_CAUSE; - li=(*Octet)++; + OBuf[(*Octet)++] = Q931ie_CAUSE; + li = (*Octet)++; - /* Octet 3 */ - OBuf[(*Octet)++] = 0x80 | (pIE->CodStand<<5) | pIE->Location; + /* Octet 3 */ + OBuf[(*Octet)++] = 0x80 | (pIE->CodStand<<5) | pIE->Location; - /* Octet 3a - currently not supported in send */ + /* Octet 3a - currently not supported in send */ - /* Octet 4 */ - OBuf[(*Octet)++] = 0x80 | pIE->Value; + /* Octet 4 */ + OBuf[(*Octet)++] = 0x80 | pIE->Value; - /* Octet 5 - diagnostics not supported in send */ + /* Octet 5 - diagnostics not supported in send */ - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; + OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; + return rc; } /***************************************************************************** - Function: Q931Uie_CongLevel + Function: Q931Uie_CongLevel - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_CongLevel(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_CongLevel *pie = (Q931ie_CongLevel*)OBuf; + Q931ie_CongLevel *pie = (Q931ie_CongLevel*)OBuf; ie *pIE = &pMsg->CongestionLevel; - L3INT Off = 0; - L3INT Octet = 0; + L3INT Off = 0; + L3INT Octet = 0; - *pIE=0; + *pIE = 0; - pie->IEId = IBuf[Octet] & 0xf0; - pie->CongLevel = IBuf[Octet] & 0x0f; - Octet ++; + pie->IEId = IBuf[Octet] & 0xf0; + pie->CongLevel = IBuf[Octet] & 0x0f; + Octet ++; - Q931SetIE(*pIE, *OOff); + Q931SetIE(*pIE, *OOff); - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_CongLevel); - pie->Size = sizeof(Q931ie_CongLevel); + *IOff = (*IOff) + Octet + Off; + *OOff = (*OOff) + sizeof(Q931ie_CongLevel); + pie->Size = sizeof(Q931ie_CongLevel); - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_CongLevel + Function: Q931Pie_CongLevel - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_CongLevel(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_CongLevel * pIE = (Q931ie_CongLevel*)IBuf; - L3INT rc=0; - /* L3INT Beg=*Octet; */ + Q931ie_CongLevel *pIE = (Q931ie_CongLevel*)IBuf; + L3INT rc = 0; + /* L3INT Beg = *Octet; */ - OBuf[(*Octet)++] = Q931ie_CONGESTION_LEVEL | pIE->CongLevel; - - return rc; + OBuf[(*Octet)++] = Q931ie_CONGESTION_LEVEL | pIE->CongLevel; + + return rc; } /***************************************************************************** - Function: Q931Uie_ChanID + Function: Q931Uie_ChanID - Parameters: IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Uie_ChanID(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR *OBuf, L3INT *IOff, L3INT *OOff) @@ -1178,22 +1128,20 @@ L3INT Q931Uie_ChanID(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * Off = Q931ReadExt(&IBuf[Octet++], Off); /* Octet 3.1 */ - if(pie->IntIDPresent) - { - pie->InterfaceID = IBuf[Octet+Off] & 0x7f; + if (pie->IntIDPresent) { + pie->InterfaceID = IBuf[Octet + Off] & 0x7f; /* Temp fix. Interface id can be extended using the extension bit */ /* this will read the octets, but do nothing with them. this is done */ /* because the usage of this field is a little unclear */ /* 30.jan.2001/JVB */ - Off = Q931ReadExt(&IBuf[Octet+Off], Off); + Off = Q931ReadExt(&IBuf[Octet + Off], Off); Off++; } if ((Octet + Off - 2) != IESize) { /* Octet 3.2 */ - if(pie->IntType == 1) /* PRI etc */ - { + if (pie->IntType == 1) { /* PRI etc */ pie->CodStand = (IBuf[Octet + Off] >> 5) & 0x03; pie->NumMap = (IBuf[Octet + Off] >> 4) & 0x01; pie->ChanMapType = IBuf[Octet + Off] & 0x0f; @@ -1201,31 +1149,29 @@ L3INT Q931Uie_ChanID(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * /* Octet 3.3 */ /* Temp fix. Assume B channel. H channels not supported */ - pie->ChanSlot = IBuf[Octet+Off] & 0x7f; + pie->ChanSlot = IBuf[Octet + Off] & 0x7f; /* Some dialects don't follow the extension coding properly for this, but this should be safe for all */ - if((Octet + Off - 1) != IESize) { - Off = Q931ReadExt(&IBuf[Octet+Off], Off); + if ((Octet + Off - 1) != IESize) { + Off = Q931ReadExt(&IBuf[Octet + Off], Off); } Off++; } } Q931IESizeTest(Q931E_CHANID); - Q931SetIE(*pIE, *OOff); *IOff = (*IOff) + Octet + Off; *OOff = (*OOff) + sizeof(Q931ie_ChanID); pie->Size = sizeof(Q931ie_ChanID); - if(pTrunk->loglevel == Q931_LOG_DEBUG) - { + if (pTrunk->loglevel == Q931_LOG_DEBUG) { const char *iface; char tmp[100] = ""; - if(!pie->IntType) { - switch(pie->InfoChanSel) { + if (!pie->IntType) { + switch (pie->InfoChanSel) { case 0x0: iface = "None"; break; @@ -1251,1818 +1197,1714 @@ L3INT Q931Uie_ChanID(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * ((pie->IntType) ? "PRI/Other" : "BRI"), tmp); } - return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_ChanID + Function: Q931Pie_ChanID - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_ChanID(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_ChanID * pIE = (Q931ie_ChanID*)IBuf; + Q931ie_ChanID *pIE = (Q931ie_ChanID*)IBuf; L3INT rc = Q931E_NO_ERROR; L3INT Beg = *Octet; /* remember current offset */ - L3INT li; + L3INT li; - OBuf[(*Octet)++] = Q931ie_CHANNEL_IDENTIFICATION; - li = (*Octet)++; /* remember length position */ + OBuf[(*Octet)++] = Q931ie_CHANNEL_IDENTIFICATION; + li = (*Octet)++; /* remember length position */ - /* Octet 3 flags & BRI chan # */ - OBuf[(*Octet)++] = 0x80 + /* Octet 3 flags & BRI chan # */ + OBuf[(*Octet)++] = 0x80 | ((pIE->IntIDPresent << 6) & 0x40) | ((pIE->IntType << 5) & 0x20) | ((pIE->PrefExcl << 3) & 0x08) | (pIE->InfoChanSel & 0x03); - /* Octet 3.1 - Interface Identifier */ - if(pIE->IntIDPresent) - { + /* Octet 3.1 - Interface Identifier */ + if (pIE->IntIDPresent) { OBuf[(*Octet)++] = 0x80 | (pIE->InterfaceID & 0x7f); - } + } - /* Octet 3.2 & 3.3 - PRI */ - if(pIE->IntType) - { - OBuf[(*Octet)++] = 0x80 + /* Octet 3.2 & 3.3 - PRI */ + if (pIE->IntType) { + OBuf[(*Octet)++] = 0x80 | ((pIE->CodStand << 5) & 0x60) | ((pIE->NumMap << 4) & 0x10) | (pIE->ChanMapType & 0x0f); /* TODO: support all possible channel map types */ - /* Octet 3.3 Channel number */ - switch(pIE->ChanMapType) { - case 0x6: /* Slot map: H0 Channel Units */ /* unsupported, Octets 3.3.1 - 3.3.3 */ - return Q931E_CHANID; + /* Octet 3.3 Channel number */ + switch (pIE->ChanMapType) { + case 0x6: /* Slot map: H0 Channel Units */ /* unsupported, Octets 3.3.1 - 3.3.3 */ + return Q931E_CHANID; - case 0x8: /* Slot map: H11 Channel Units */ - case 0x9: /* Slot map: H12 Channel Units */ - default: /* Channel number */ - OBuf[(*Octet)++] = 0x80 | (pIE->ChanSlot & 0x7f); - break; + case 0x8: /* Slot map: H11 Channel Units */ + case 0x9: /* Slot map: H12 Channel Units */ + default: /* Channel number */ + OBuf[(*Octet)++] = 0x80 | (pIE->ChanSlot & 0x7f); + break; + } } - } - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; + OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; + return rc; } /***************************************************************************** - Function: Q931Uie_CRV + Function: Q931Uie_CRV Description: Reading CRV. - The CRV is currently returned in the return value that - Q921Rx23 will assign to the CRV field in the unpacked - message. CRV is basically 2 bytes etc, but the spec allows - the use of longer CRV values. + The CRV is currently returned in the return value that + Q921Rx23 will assign to the CRV field in the unpacked + message. CRV is basically 2 bytes etc, but the spec allows + the use of longer CRV values. - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: CRV *****************************************************************************/ L3USHORT Q931Uie_CRV(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *IOff, L3INT *OOff) { - L3USHORT CRV = 0; - L3INT Octet = *IOff; - L3INT l = IBuf[Octet++]; + L3USHORT CRV = 0; + L3INT Octet = *IOff; + L3INT l = IBuf[Octet++]; - if(l == 1) /* One octet CRV */ - { - CRV = IBuf[Octet++] & 0x7F; - } - else if(l == 2) /* two octet CRV */ - { - CRV = (IBuf[Octet++] & 0x7f) << 8; - CRV |= IBuf[Octet++]; - } - else - { - /* Long CRV is not used, so we skip this */ - /* TODO: is it right to set to 0 here? */ - CRV = 0; - Octet += l; - } + if (l == 1) { /* One octet CRV */ + CRV = IBuf[Octet++] & 0x7F; + } + else if (l == 2) { /* two octet CRV */ + CRV = (IBuf[Octet++] & 0x7f) << 8; + CRV |= IBuf[Octet++]; + } + else { + /* Long CRV is not used, so we skip this */ + /* TODO: is it right to set to 0 here? */ + CRV = 0; + Octet += l; + } - *IOff = Octet; - return CRV; + *IOff = Octet; + return CRV; } /***************************************************************************** - Function: Q931Uie_DateTime + Function: Q931Uie_DateTime Parameters: pTrunk [IN] Ptr to trunk information. pIE [OUT] ptr to Information Element id. - IBuf [IN] ptr to a packed ie. - OBuf [OUT] ptr to buffer for Unpacked ie. - IOff [IN\OUT] Input buffer offset - OOff [IN\OUT] Output buffer offset + IBuf [IN] ptr to a packed ie. + OBuf [OUT] ptr to buffer for Unpacked ie. + IOff [IN\OUT] Input buffer offset + OOff [IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_DateTime(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_DateTime * pie = (Q931ie_DateTime*)OBuf; + Q931ie_DateTime * pie = (Q931ie_DateTime*)OBuf; ie *pIE = &pMsg->DateTime; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize=0; + L3INT Off = 0; + L3INT Octet = 0; + L3INT IESize = 0; - *pIE=0; + *pIE = 0; - pie->IEId = IBuf[Octet++]; - - /* Octet 2 */ - IESize = IBuf[Octet++]; + pie->IEId = IBuf[Octet++]; + + /* Octet 2 */ + IESize = IBuf[Octet++]; - /* Octet 3 - Year */ - pie->Year = IBuf[Octet++]; + /* Octet 3 - Year */ + pie->Year = IBuf[Octet++]; - /* Octet 4 - Month */ - pie->Month = IBuf[Octet++]; + /* Octet 4 - Month */ + pie->Month = IBuf[Octet++]; - /* Octet 5 - Day */ - pie->Day = IBuf[Octet++]; + /* Octet 5 - Day */ + pie->Day = IBuf[Octet++]; - /******************************************************************* - The remaining part of the IE are optioinal, but only the length - can now tell us wherever these fields are present or not - (always remember: IESize does not include ID and Size octet) - ********************************************************************/ - pie->Format=0; + /******************************************************************* + The remaining part of the IE are optioinal, but only the length + can now tell us wherever these fields are present or not + (always remember: IESize does not include ID and Size octet) + ********************************************************************/ + pie->Format = 0; - /* Octet 6 - Hour (optional)*/ - if(IESize >= 4) - { - pie->Format = 1; - pie->Hour = IBuf[Octet++]; + /* Octet 6 - Hour (optional)*/ + if (IESize >= 4) { + pie->Format = 1; + pie->Hour = IBuf[Octet++]; - /* Octet 7 - Minute (optional)*/ - if(IESize >= 5) - { - pie->Format = 2; - pie->Minute = IBuf[Octet++]; + /* Octet 7 - Minute (optional)*/ + if (IESize >= 5) { + pie->Format = 2; + pie->Minute = IBuf[Octet++]; - /* Octet 8 - Second (optional)*/ - if(IESize >= 6) - { - pie->Format = 3; - pie->Second = IBuf[Octet++]; - } - } - } + /* Octet 8 - Second (optional)*/ + if (IESize >= 6) { + pie->Format = 3; + pie->Second = IBuf[Octet++]; + } + } + } - Q931IESizeTest(Q931E_DATETIME); + Q931IESizeTest(Q931E_DATETIME); + Q931SetIE(*pIE, *OOff); - Q931SetIE(*pIE, *OOff); + *IOff = (*IOff) + Octet + Off; + *OOff = (*OOff) + sizeof(Q931ie_DateTime); + pie->Size = sizeof(Q931ie_DateTime); - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_DateTime); - pie->Size = sizeof(Q931ie_DateTime); - - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_DateTime + Function: Q931Pie_DateTime - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_DateTime(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_DateTime * pIE = (Q931ie_DateTime*)IBuf; - L3INT rc=0; - L3INT Beg=*Octet; - L3INT li; + Q931ie_DateTime *pIE = (Q931ie_DateTime*)IBuf; + L3INT rc = 0; + L3INT Beg = *Octet; + L3INT li; - OBuf[(*Octet)++] = Q931ie_DATETIME; - li=(*Octet)++; + OBuf[(*Octet)++] = Q931ie_DATETIME; + li = (*Octet)++; - OBuf[(*Octet)++] = pIE->Year; - OBuf[(*Octet)++] = pIE->Month; - OBuf[(*Octet)++] = pIE->Day; - if(pIE->Format >= 1) - { - OBuf[(*Octet)++] = pIE->Hour; - if(pIE->Format >= 2) - { - OBuf[(*Octet)++] = pIE->Minute; - if(pIE->Format >= 3) - { - OBuf[(*Octet)++] = pIE->Second; - } - } - } + OBuf[(*Octet)++] = pIE->Year; + OBuf[(*Octet)++] = pIE->Month; + OBuf[(*Octet)++] = pIE->Day; + if (pIE->Format >= 1) { + OBuf[(*Octet)++] = pIE->Hour; - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; + if (pIE->Format >= 2) { + OBuf[(*Octet)++] = pIE->Minute; + + if (pIE->Format >= 3) { + OBuf[(*Octet)++] = pIE->Second; + } + } + } + + OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; + return rc; } /***************************************************************************** - Function: Q931Uie_Display + Function: Q931Uie_Display - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_Display(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_Display * pie = (Q931ie_Display*)OBuf; + Q931ie_Display *pie = (Q931ie_Display*)OBuf; ie *pIE = &pMsg->Display; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; - L3INT x; + L3INT Off = 0; + L3INT Octet = 0; + L3INT IESize; + L3INT x; - *pIE=0; + *pIE = 0; - pie->IEId = IBuf[Octet]; - Octet ++; + pie->IEId = IBuf[Octet++]; + IESize = IBuf[Octet++]; - IESize = IBuf[Octet ++]; + for (x = 0; xDisplay[x] = IBuf[Octet + Off] & 0x7f; + Off++; + } - for(x=0; xDisplay[x] = IBuf[Octet+Off] & 0x7f; - Off++; - } + Q931IESizeTest(Q931E_DISPLAY); + Q931SetIE(*pIE, *OOff); - Q931IESizeTest(Q931E_DISPLAY); + *IOff = (*IOff) + Octet + Off; + *OOff = (*OOff) + sizeof(Q931ie_Display) + x - 1; + pie->Size = (L3UCHAR)(sizeof(Q931ie_Display) + x - 1); - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_Display) + x - 1; - pie->Size = (L3UCHAR)(sizeof(Q931ie_Display) + x - 1); - - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_Display + Function: Q931Pie_Display - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_Display(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_Display * pIE = (Q931ie_Display*)IBuf; - L3INT rc=0; - L3INT Beg=*Octet; - L3INT li; - L3INT DSize; - L3INT x; + Q931ie_Display *pIE = (Q931ie_Display*)IBuf; + L3INT rc = 0; + L3INT Beg = *Octet; + L3INT li; + L3INT DSize; + L3INT x; - OBuf[(*Octet)++] = Q931ie_DISPLAY; - li=(*Octet)++; + OBuf[(*Octet)++] = Q931ie_DISPLAY; + li = (*Octet)++; - DSize = pIE->Size - sizeof(Q931ie_Display); + DSize = pIE->Size - sizeof(Q931ie_Display); - for(x=0; x< DSize; x++) - { - - OBuf[(*Octet)++] = pIE->Display[x]; - } + for (x = 0; x< DSize; x++) { + + OBuf[(*Octet)++] = pIE->Display[x]; + } - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; + OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; + return rc; } /***************************************************************************** - Function: Q931Uie_HLComp + Function: Q931Uie_HLComp - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_HLComp(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_HLComp * pie = (Q931ie_HLComp*)OBuf; + Q931ie_HLComp * pie = (Q931ie_HLComp*)OBuf; ie *pIE = &pMsg->HLComp; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; + L3INT Off = 0; + L3INT Octet = 0; + L3INT IESize; - *pIE=0; + *pIE = 0; - pie->IEId = IBuf[Octet]; - Octet ++; + pie->IEId = IBuf[Octet++]; - /* Octet */ - IESize = IBuf[Octet ++]; + /* Octet */ + IESize = IBuf[Octet++]; - /* Octet 3*/ - pie->CodStand = (IBuf[Octet + Off] >>5) & 0x03; - pie->Interpret= (IBuf[Octet + Off] >>2) & 0x07; - pie->PresMeth = IBuf[Octet + Off] & 0x03; - - Octet++; + /* Octet 3*/ + pie->CodStand = (IBuf[Octet + Off] >>5) & 0x03; + pie->Interpret = (IBuf[Octet + Off] >>2) & 0x07; + pie->PresMeth = IBuf[Octet + Off] & 0x03; + Octet++; - /* Octet 4 */ - pie->HLCharID = IBuf[Octet+Off] & 0x7f; - - Octet++; - - /* Octet 4a*/ - if((IBuf[Octet + Off-1] & 0x80) == 0 && Q931MoreIE()) - { - if(pie->HLCharID == 0x5e || pie->HLCharID == 0x5f) - { - pie->EHLCharID = IBuf[Octet+Off] & 0x7f; - Off++; - } - else if( pie->HLCharID >= 0xc3 && pie->HLCharID <= 0xcf) - { - pie->EVideoTlfCharID = IBuf[Octet+Off] & 0x7f; - Off++; - } - else - { - /* error Octet 4a indicated, but invalid value in Octet 4. */ - Q931SetError(pTrunk,Q931E_HLCOMP, 4, Off); - return Q931E_HLCOMP; - } - Off = Q931ReadExt(&IBuf[Octet+Off], Off); - } + /* Octet 4 */ + pie->HLCharID = IBuf[Octet + Off] & 0x7f; + Octet++; + + /* Octet 4a*/ + if ((IBuf[Octet + Off - 1] & 0x80) == 0 && Q931MoreIE()) { + if (pie->HLCharID == 0x5e || pie->HLCharID == 0x5f) { + pie->EHLCharID = IBuf[Octet + Off] & 0x7f; + Off++; + } + else if ( pie->HLCharID >= 0xc3 && pie->HLCharID <= 0xcf) { + pie->EVideoTlfCharID = IBuf[Octet + Off] & 0x7f; + Off++; + } + else { + /* error Octet 4a indicated, but invalid value in Octet 4. */ + Q931SetError(pTrunk,Q931E_HLCOMP, 4, Off); + return Q931E_HLCOMP; + } + Off = Q931ReadExt(&IBuf[Octet + Off], Off); + } - Q931IESizeTest(Q931E_HLCOMP); + Q931IESizeTest(Q931E_HLCOMP); + Q931SetIE(*pIE, *OOff); - Q931SetIE(*pIE, *OOff); + *IOff = (*IOff) + Octet + Off; + *OOff = (*OOff) + sizeof(Q931ie_HLComp); + pie->Size = sizeof(Q931ie_HLComp); - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_HLComp); - pie->Size = sizeof(Q931ie_HLComp); - - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_HLComp + Function: Q931Pie_HLComp - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_HLComp(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_HLComp * pIE = (Q931ie_HLComp*)IBuf; - L3INT rc=0; - L3INT Beg=*Octet; - L3INT li; + Q931ie_HLComp *pIE = (Q931ie_HLComp*)IBuf; + L3INT rc = 0; + L3INT Beg = *Octet; + L3INT li; - OBuf[(*Octet)++] = Q931ie_HIGH_LAYER_COMPATIBILITY; - li=(*Octet)++; + OBuf[(*Octet)++] = Q931ie_HIGH_LAYER_COMPATIBILITY; + li = (*Octet)++; - /* Octet 3 */ - OBuf[(*Octet)++] = 0x80 | ((pIE->CodStand << 5) & 0x60) | ((pIE->Interpret << 2) & 0x1c) | (pIE->PresMeth & 0x03); + /* Octet 3 */ + OBuf[(*Octet)++] = 0x80 | ((pIE->CodStand << 5) & 0x60) | ((pIE->Interpret << 2) & 0x1c) | (pIE->PresMeth & 0x03); - /* Octet 4 */ - OBuf[(*Octet)++] = pIE->HLCharID; + /* Octet 4 */ + OBuf[(*Octet)++] = pIE->HLCharID; - /* Octet 4a */ - if(pIE->HLCharID == 0x5e || pIE->HLCharID == 0x5f) - { - OBuf[(*Octet)++] = 0x80 | (pIE->EHLCharID & 0x7f); - } - else if( pIE->HLCharID >= 0xc3 && pIE->HLCharID <= 0xcf) - { - OBuf[(*Octet)++] = 0x80 | (pIE->EVideoTlfCharID & 0x7f); - } - else - { - OBuf[(*Octet)-1] |= 0x80; - } + /* Octet 4a */ + if (pIE->HLCharID == 0x5e || pIE->HLCharID == 0x5f) { + OBuf[(*Octet)++] = 0x80 | (pIE->EHLCharID & 0x7f); + } + else if ( pIE->HLCharID >= 0xc3 && pIE->HLCharID <= 0xcf) { + OBuf[(*Octet)++] = 0x80 | (pIE->EVideoTlfCharID & 0x7f); + } + else { + OBuf[(*Octet) - 1] |= 0x80; + } - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; + OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; + return rc; } /***************************************************************************** - Function: Q931Uie_KeypadFac + Function: Q931Uie_KeypadFac - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_KeypadFac(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_KeypadFac * pie = (Q931ie_KeypadFac*)OBuf; + Q931ie_KeypadFac *pie = (Q931ie_KeypadFac*)OBuf; ie *pIE = &pMsg->KeypadFac; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; - L3INT x; + L3INT Off = 0; + L3INT Octet = 0; + L3INT IESize; + L3INT x; - *pIE=0; + *pIE = 0; - pie->IEId = IBuf[Octet]; - Octet ++; + pie->IEId = IBuf[Octet++]; + IESize = IBuf[Octet++]; - IESize = IBuf[Octet ++]; + for (x = 0; xKeypadFac[x] = IBuf[Octet + Off] & 0x7f; + Off++; + } - for(x=0; xKeypadFac[x] = IBuf[Octet+Off] & 0x7f; - Off++; - } + Q931IESizeTest(Q931E_KEYPADFAC); + Q931SetIE(*pIE, *OOff); - Q931IESizeTest(Q931E_KEYPADFAC); + *IOff = (*IOff) + Octet + Off; + *OOff = (*OOff) + sizeof(Q931ie_KeypadFac) + x - 1; + pie->Size = (L3UCHAR)(sizeof(Q931ie_KeypadFac) + x - 1); - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_KeypadFac) + x - 1; - pie->Size = (L3UCHAR)(sizeof(Q931ie_KeypadFac) + x - 1); - - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_KeypadFac + Function: Q931Pie_KeypadFac - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_KeypadFac(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_KeypadFac * pIE = (Q931ie_KeypadFac*)IBuf; - L3INT rc=0; - L3INT Beg=*Octet; - L3INT li; - L3INT DSize; - L3INT x; + Q931ie_KeypadFac *pIE = (Q931ie_KeypadFac*)IBuf; + L3INT rc = 0; + L3INT Beg = *Octet; + L3INT li; + L3INT DSize; + L3INT x; - OBuf[(*Octet)++] = Q931ie_KEYPAD_FACILITY; - li=(*Octet)++; + OBuf[(*Octet)++] = Q931ie_KEYPAD_FACILITY; + li = (*Octet)++; - DSize = pIE->Size - sizeof(Q931ie_KeypadFac) + 1; + DSize = pIE->Size - sizeof(Q931ie_KeypadFac) + 1; - for(x=0; x< DSize; x++) - { - OBuf[(*Octet)++] = pIE->KeypadFac[x]; - } + for (x = 0; x< DSize; x++) { + OBuf[(*Octet)++] = pIE->KeypadFac[x]; + } - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; + OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; + return rc; } /***************************************************************************** - Function: Q931Uie_LLComp + Function: Q931Uie_LLComp - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_LLComp(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_LLComp * pie = (Q931ie_LLComp*)OBuf; + Q931ie_LLComp *pie = (Q931ie_LLComp*)OBuf; ie *pIE = &pMsg->LLComp; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; + L3INT Off = 0; + L3INT Octet = 0; + L3INT IESize; - *pIE=0; + *pIE = 0; - pie->IEId = IBuf[Octet]; - Octet ++; + pie->IEId = IBuf[Octet++]; - /* Octet 2 */ - IESize = IBuf[Octet ++]; + /* Octet 2 */ + IESize = IBuf[Octet++]; - /* Octet 3*/ + /* Octet 3 */ + pie->CodStand = (IBuf[Octet + Off] >> 5) & 0x03; + pie->ITransCap = IBuf[Octet + Off] & 0x1f; + Octet++; - pie->CodStand = (IBuf[Octet+Off] >> 5) & 0x03; - pie->ITransCap= IBuf[Octet+Off] & 0x1f; + /* Octet 3a*/ + if (IsQ931Ext(IBuf[Octet + Off - 1])) { + pie->NegotInd = (IBuf[Octet + Off] >> 6) & 0x01; + Off++; + } - Octet++; + /* Octet 4 */ + pie->TransMode = (IBuf[Octet + Off] >> 5) & 0x03; + pie->InfoRate = IBuf[Octet + Off] & 0x1f; - /* Octet 3a*/ - if(IsQ931Ext(IBuf[Octet+Off-1])) - { - pie->NegotInd = (IBuf[Octet+Off] >> 6) & 0x01; - Off++; - } + Octet++; - /* Octet 4 */ - pie->TransMode = (IBuf[Octet+Off] >> 5) & 0x03; - pie->InfoRate = IBuf[Octet+Off] & 0x1f; + /* Octet 4.1 */ + if (pie->InfoRate == 0x14) { /* Mutirate */ + pie->RateMul = IBuf[Octet + Off] & 0x7f; + Off++; + } - Octet++; + /* Octet 5 - Layer 1 Ident */ + if ((IBuf[Octet + Off] & 0x60) == 0x20) { /* Layer 1 Ident ? */ + pie->Layer1Ident = (IBuf[Octet + Off] >> 5) & 0x03; + pie->UIL1Prot = IBuf[Octet + Off] & 0x1f; + Octet++; - /* Octet 4.1 */ - if(pie->InfoRate == 0x14 ) /* Mutirate */ - { - pie->RateMul = IBuf[Octet+Off] & 0x7f; - Off++; - } + /* Octet 5a */ + if (IsQ931Ext(IBuf[Octet + Off - 1])) { + pie->SyncAsync = (IBuf[Octet + Off] >> 6) & 0x01; + pie->Negot = (IBuf[Octet + Off] >> 5) & 0x01; + pie->UserRate = IBuf[Octet + Off] & 0x1f; + Off++; - /* Octet 5 - Layer 1 Ident */ - if((IBuf[Octet+Off] & 0x60) == 0x20) /* Layer 1 Ident ? */ - { - pie->Layer1Ident = (IBuf[Octet+Off] >> 5) & 0x03; - pie->UIL1Prot = IBuf[Octet+Off] & 0x1f; + /* Octet 5b - 2 options */ + if (IsQ931Ext(IBuf[Octet + Off - 1])) { + if (pie->UIL1Prot == 0x01) { /* V.110, I.460 and X.30*/ + pie->InterRate = (IBuf[Octet + Off] >> 5) & 0x03; + pie->NIConTx = (IBuf[Octet + Off] >> 4) & 0x01; + pie->NIConRx = (IBuf[Octet + Off] >> 3) & 0x01; + pie->FlowCtlTx = (IBuf[Octet + Off] >> 2) & 0x01; + pie->FlowCtlRx = (IBuf[Octet + Off] >> 1) & 0x01; + Off++; + } + else if (pie->UIL1Prot == 0x80) { /* V.120 */ + pie->HDR = (IBuf[Octet + Off] >> 6) & 0x01; + pie->MultiFrame = (IBuf[Octet + Off] >> 5) & 0x01; + pie->ModeL1 = (IBuf[Octet + Off] >> 4) & 0x01; + pie->NegotLLI = (IBuf[Octet + Off] >> 3) & 0x01; + pie->Assignor = (IBuf[Octet + Off] >> 2) & 0x01; + pie->InBandNeg = (IBuf[Octet + Off] >> 1) & 0x01; + Off++; + } + else if (pie->UIL1Prot == 0x07) { /* non standard */ + Off = Q931ReadExt(&IBuf[Octet + Off], Off); + Off++; + } + else { + Q931SetError(pTrunk,Q931E_LLCOMP, 5,2); + return Q931E_LLCOMP; + } - Octet++; + /* Octet 5c */ + if (IsQ931Ext(IBuf[Octet + Off - 1])) { + pie->NumStopBits = (IBuf[Octet + Off] >> 5) & 0x03; + pie->NumDataBits = (IBuf[Octet + Off] >> 3) & 0x03; + pie->Parity = IBuf[Octet + Off] & 0x07; + Off++; - /* Octet 5a */ - if(IsQ931Ext(IBuf[Octet+Off-1])) - { - pie->SyncAsync = (IBuf[Octet+Off] >> 6) & 0x01; - pie->Negot = (IBuf[Octet+Off] >> 5) & 0x01; - pie->UserRate = IBuf[Octet+Off] & 0x1f; - Off++; + /* Octet 5d */ + if (IsQ931Ext(IBuf[Octet + Off - 1])) { + pie->DuplexMode = (IBuf[Octet + Off] >> 6) & 0x01; + pie->ModemType = IBuf[Octet + Off] & 0x3f; + Off = Q931ReadExt(&IBuf[Octet + Off], Off); + Off++; + } + } + } + } + } - /* Octet 5b - 2 options */ - if(IsQ931Ext(IBuf[Octet+Off-1])) - { - if(pie->UIL1Prot == 0x01) /* V.110, I.460 and X.30*/ - { - pie->InterRate = (IBuf[Octet+Off] >> 5) & 0x03; - pie->NIConTx = (IBuf[Octet+Off] >> 4) & 0x01; - pie->NIConRx = (IBuf[Octet+Off] >> 3) & 0x01; - pie->FlowCtlTx = (IBuf[Octet+Off] >> 2) & 0x01; - pie->FlowCtlRx = (IBuf[Octet+Off] >> 1) & 0x01; - Off++; - } - else if(pie->UIL1Prot == 0x80)/* V.120 */ - { - pie->HDR = (IBuf[Octet+Off] >> 6) & 0x01; - pie->MultiFrame = (IBuf[Octet+Off] >> 5) & 0x01; - pie->ModeL1 = (IBuf[Octet+Off] >> 4) & 0x01; - pie->NegotLLI = (IBuf[Octet+Off] >> 3) & 0x01; - pie->Assignor = (IBuf[Octet+Off] >> 2) & 0x01; - pie->InBandNeg = (IBuf[Octet+Off] >> 1) & 0x01; - Off++; - } - else if(pie->UIL1Prot == 0x07)/* non standard */ - { - Off = Q931ReadExt(&IBuf[Octet+Off], Off); - Off++; - } - else - { - Q931SetError(pTrunk,Q931E_LLCOMP, 5,2); - return Q931E_LLCOMP; - } + /* Octet 6 - Layer 2 Ident */ + if ((IBuf[Octet + Off] & 0x60) == 0x40) { /* Layer 1 Ident ? */ + pie->Layer2Ident = (IBuf[Octet + Off] >>5) & 0x03; + pie->UIL2Prot = IBuf[Octet + Off] & 0x1f; + Octet++; - /* Octet 5c */ - if(IsQ931Ext(IBuf[Octet+Off-1])) - { - pie->NumStopBits=(IBuf[Octet+Off] >> 5) & 0x03; - pie->NumDataBits=(IBuf[Octet+Off] >> 3) & 0x03; - pie->Parity =IBuf[Octet+Off] & 0x07; - Off++; + /* Octet 6a */ + if (IsQ931Ext(IBuf[Octet + Off - 1])) { + if (pie->UIL2Prot == 0x10) { /* 2nd 6a */ + pie->UsrSpcL2Prot = IBuf[Octet + Off] & 0x7f; + Off++; + } + else { /* assume 1st 6a */ + pie->ModeL2 = (IBuf[Octet + Off] >> 5) & 0x03; + pie->Q933use = IBuf[Octet + Off] & 0x03; + Off++; + } + /* Octet 6b */ + if (IsQ931Ext(IBuf[Octet + Off - 1])) { + pie->WindowSize = IBuf[Octet + Off] & 0x7f; + Off++; + } + } + } - /* Octet 5d */ - if(IsQ931Ext(IBuf[Octet+Off-1])) - { - pie->DuplexMode = (IBuf[Octet+Off] >> 6) & 0x01; - pie->ModemType = IBuf[Octet+Off] & 0x3f; - Off = Q931ReadExt(&IBuf[Octet+Off], Off); - Off++; - } - } - } - } - } + /* Octet 7 - layer 3 Ident */ + if ((IBuf[Octet + Off] & 0x60) == 0x60) { /* Layer 3 Ident ? */ + pie->Layer3Ident = (IBuf[Octet + Off] >> 5) & 0x03; + pie->UIL3Prot = IBuf[Octet + Off] & 0x1f; + Octet++; - /* Octet 6 - Layer 2 Ident */ - if((IBuf[Octet+Off] & 0x60) == 0x40) /* Layer 1 Ident ? */ - { - pie->Layer2Ident= (IBuf[Octet+Off] >>5) & 0x03; - pie->UIL2Prot = IBuf[Octet+Off] & 0x1f; - Octet++; + /* Octet 7a */ + if (IsQ931Ext(IBuf[Octet + Off - 1])) { + if (pie->UIL3Prot == 0x0b) { + /* Octet 7a + 7b AddL3Info */ + pie->AddL3Info = ((IBuf[Octet + Off] << 4) & 0xf0) + | (IBuf[Octet + Off + 1] & 0x0f); + Off += 2; + } + else { + if (pie->UIL3Prot == 0x1f) { + pie->ModeL3 = (IBuf[Octet + Off] >> 5) & 0x03; + Off++; + } + else { + pie->OptL3Info = IBuf[Octet + Off] & 0x7f; + Off++; + } - /* Octet 6a */ - if(IsQ931Ext(IBuf[Octet+Off-1])) - { - if(pie->UIL2Prot == 0x10) /* 2nd 6a */ - { - pie->UsrSpcL2Prot = IBuf[Octet+Off] & 0x7f; - Off++; - } - else /* assume 1st 6a*/ - { - pie->ModeL2 = (IBuf[Octet+Off] >> 5) & 0x03; - pie->Q933use=IBuf[Octet+Off] & 0x03; - Off++; - } - /* Octet 6b*/ - if(IsQ931Ext(IBuf[Octet+Off-1])) - { - pie->WindowSize = IBuf[Octet+Off] & 0x7f; - Off++; - } - } - } + /* Octet 7b*/ + if (IsQ931Ext(IBuf[Octet + Off - 1])) { + pie->DefPackSize = IBuf[Octet + Off] & 0x0f; + Off++; - /* Octet 7 - layer 3 Ident */ - if((IBuf[Octet+Off] & 0x60) == 0x60) /* Layer 3 Ident ? */ - { - pie->Layer3Ident= (IBuf[Octet+Off] >> 5) & 0x03; - pie->UIL3Prot = IBuf[Octet+Off] & 0x1f; - Octet++; + /* Octet 7c */ + if (IsQ931Ext(IBuf[Octet + Off - 1])) { + pie->PackWinSize= IBuf[Octet + Off] & 0x7f; + } + } + } + } + } - /* Octet 7a */ - if(IsQ931Ext(IBuf[Octet+Off-1])) - { - - if(pie->UIL3Prot == 0x0b) - { - /* Octet 7a + 7b AddL3Info */ - pie->AddL3Info = ((IBuf[Octet+Off] << 4) &0xf0) - |(IBuf[Octet+Off+1] & 0x0f); - Off+=2; - } - else - { - if(pie->UIL3Prot == 0x1f) - { - pie->ModeL3 = (IBuf[Octet+Off] >> 5) & 0x03; - Off++; - } - else - { - pie->OptL3Info = IBuf[Octet+Off] & 0x7f; - Off++; - } + Q931IESizeTest(Q931E_LLCOMP); + Q931SetIE(*pIE, *OOff); - /* Octet 7b*/ - if(IsQ931Ext(IBuf[Octet+Off-1])) - { - pie->DefPackSize = IBuf[Octet+Off] & 0x0f; - Off++; + *IOff = (*IOff) + Octet + Off; + *OOff = (*OOff) + sizeof(Q931ie_LLComp); + pie->Size = sizeof(Q931ie_LLComp); - /* Octet 7c */ - if(IsQ931Ext(IBuf[Octet+Off-1])) - { - pie->PackWinSize= IBuf[Octet+Off] & 0x7f; - } - } - } - } - } - - Q931IESizeTest(Q931E_LLCOMP); - - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_LLComp); - pie->Size = sizeof(Q931ie_LLComp); - - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_LLComp + Function: Q931Pie_LLComp - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_LLComp(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_LLComp * pIE = (Q931ie_LLComp*)IBuf; - L3INT rc=0; - L3INT Beg=*Octet; - L3INT li; + Q931ie_LLComp *pIE = (Q931ie_LLComp*)IBuf; + L3INT rc = 0; + L3INT Beg = *Octet; + L3INT li; - OBuf[(*Octet)++] = Q931ie_LOW_LAYER_COMPATIBILITY; - li=(*Octet)++; + OBuf[(*Octet)++] = Q931ie_LOW_LAYER_COMPATIBILITY; + li = (*Octet)++; - /* Octet 3*/ - OBuf[(*Octet)++] = (pIE->CodStand << 6) | pIE->ITransCap; + /* Octet 3 */ + OBuf[(*Octet)++] = (pIE->CodStand << 6) | pIE->ITransCap; - /* Octet 3a*/ - OBuf[(*Octet)++] = 0x80 | (pIE->NegotInd << 6); + /* Octet 3a */ + OBuf[(*Octet)++] = 0x80 | (pIE->NegotInd << 6); - /* Octet 4 */ - OBuf[(*Octet)++] = 0x80 | (pIE->TransMode << 5) | pIE->InfoRate; + /* Octet 4 */ + OBuf[(*Octet)++] = 0x80 | (pIE->TransMode << 5) | pIE->InfoRate; - /* Octet 4.1*/ - if(pIE->InfoRate == 0x18) - { - OBuf[(*Octet)++] = 0x80 | pIE->RateMul; - } + /* Octet 4.1 */ + if (pIE->InfoRate == 0x18) { + OBuf[(*Octet)++] = 0x80 | pIE->RateMul; + } - /* Octet 5*/ - if(pIE->Layer1Ident == 0x01) - { - OBuf[(*Octet)++] = (pIE->Layer1Ident << 5) | pIE->UIL1Prot; - - /* Octet 5a*/ - if((pIE->ITransCap == 0x08 && (pIE->UIL1Prot == 0x01 || pIE->UIL1Prot == 0x08)) - || (pIE->ITransCap == 0x10 && (pIE->UIL1Prot == 0x02 || pIE->UIL1Prot == 0x03))) - { - OBuf[(*Octet)++] = (pIE->SyncAsync<<6) | (pIE->Negot<<5) | pIE->UserRate; - - /* Octet 5b*/ - if(pIE->UIL1Prot == 0x01) - { - OBuf[(*Octet)++] = (pIE->InterRate << 5) - | (pIE->NIConTx << 4) - | (pIE->NIConTx << 3) - | (pIE->FlowCtlTx << 2) - | (pIE->FlowCtlRx << 1); - } - else if(pIE->UIL1Prot == 0x08) - { - OBuf[(*Octet)++] = (pIE->HDR << 6) - | (pIE->MultiFrame<< 5) - | (pIE->ModeL1 << 4) - | (pIE->NegotLLI << 3) - | (pIE->Assignor << 2) - | (pIE->InBandNeg << 1); - } - else - { - OBuf[(*Octet)-1] |= 0x80; - } + /* Octet 5 */ + if (pIE->Layer1Ident == 0x01) { + OBuf[(*Octet)++] = (pIE->Layer1Ident << 5) | pIE->UIL1Prot; + + /* Octet 5a */ + if ((pIE->ITransCap == 0x08 && (pIE->UIL1Prot == 0x01 || pIE->UIL1Prot == 0x08)) + || (pIE->ITransCap == 0x10 && (pIE->UIL1Prot == 0x02 || pIE->UIL1Prot == 0x03))) { + OBuf[(*Octet)++] = (pIE->SyncAsync<<6) | (pIE->Negot<<5) | pIE->UserRate; + + /* Octet 5b*/ + if (pIE->UIL1Prot == 0x01) { + OBuf[(*Octet)++] = (pIE->InterRate << 5) + | (pIE->NIConTx << 4) + | (pIE->NIConTx << 3) + | (pIE->FlowCtlTx << 2) + | (pIE->FlowCtlRx << 1); + } + else if (pIE->UIL1Prot == 0x08) { + OBuf[(*Octet)++] = (pIE->HDR << 6) + | (pIE->MultiFrame << 5) + | (pIE->ModeL1 << 4) + | (pIE->NegotLLI << 3) + | (pIE->Assignor << 2) + | (pIE->InBandNeg << 1); + } + else { + OBuf[(*Octet) - 1] |= 0x80; + } - /* How to detect wherever 5c and 5d is to present is not clear*/ - /* but they have been inculded as 'standard'*/ - /* Octet 5c*/ - if(pIE->UIL1Prot == 0x01 || pIE->UIL1Prot == 0x08) - { - OBuf[(*Octet)++] = (pIE->NumStopBits<<5) | (pIE->NumDataBits<<3) | pIE->Parity ; + /* How to detect wherever 5c and 5d is to present is not clear + * but they have been inculded as 'standard' + * Octet 5c + */ + if (pIE->UIL1Prot == 0x01 || pIE->UIL1Prot == 0x08) { + OBuf[(*Octet)++] = (pIE->NumStopBits << 5) | (pIE->NumDataBits << 3) | pIE->Parity ; - /* Octet 5d*/ - OBuf[(*Octet)++] = 0x80 | (pIE->DuplexMode<<6) | pIE->ModemType; - } - } - else - { - OBuf[(*Octet)-1] |= 0x80; - } - } + /* Octet 5d */ + OBuf[(*Octet)++] = 0x80 | (pIE->DuplexMode << 6) | pIE->ModemType; + } + } + else { + OBuf[(*Octet) - 1] |= 0x80; + } + } - /* Octet 6*/ - if(pIE->Layer2Ident == 0x02) - { - OBuf[(*Octet)++] = (pIE->Layer2Ident << 5) | pIE->UIL2Prot; + /* Octet 6 */ + if (pIE->Layer2Ident == 0x02) { + OBuf[(*Octet)++] = (pIE->Layer2Ident << 5) | pIE->UIL2Prot; - /* Octet 6a*/ - if(pIE->UIL2Prot == 0x02 /* Q.921/I.441 */ - || pIE->UIL2Prot == 0x06 /* X.25 link layer */ - || pIE->UIL2Prot == 0x07 /* X.25 multilink */ - || pIE->UIL2Prot == 0x09 /* HDLC ARM */ - || pIE->UIL2Prot == 0x0a /* HDLC NRM */ - || pIE->UIL2Prot == 0x0b /* HDLC ABM */ - || pIE->UIL2Prot == 0x0d /* X.75 SLP */ - || pIE->UIL2Prot == 0x0e /* Q.922 */ - || pIE->UIL2Prot == 0x11)/* ISO/ECE 7776 DTE-DCE */ - { - OBuf[(*Octet)++] = (pIE->ModeL2 << 5) | pIE->Q933use; + /* Octet 6a*/ + if (pIE->UIL2Prot == 0x02 /* Q.921/I.441 */ + || pIE->UIL2Prot == 0x06 /* X.25 link layer */ + || pIE->UIL2Prot == 0x07 /* X.25 multilink */ + || pIE->UIL2Prot == 0x09 /* HDLC ARM */ + || pIE->UIL2Prot == 0x0a /* HDLC NRM */ + || pIE->UIL2Prot == 0x0b /* HDLC ABM */ + || pIE->UIL2Prot == 0x0d /* X.75 SLP */ + || pIE->UIL2Prot == 0x0e /* Q.922 */ + || pIE->UIL2Prot == 0x11) { /* ISO/ECE 7776 DTE-DCE */ + OBuf[(*Octet)++] = (pIE->ModeL2 << 5) | pIE->Q933use; - /* Octet 6b*/ - OBuf[(*Octet)++] = 0x80 | pIE->WindowSize; - } - else if(pIE->UIL2Prot == 0x10) /* User Specific */ - { - OBuf[(*Octet)++] = 0x80 | pIE->UsrSpcL2Prot; - } - else - { - OBuf[(*Octet)-1] |= 0x80; - } - } + /* Octet 6b */ + OBuf[(*Octet)++] = 0x80 | pIE->WindowSize; + } + else if (pIE->UIL2Prot == 0x10) { /* User Specific */ + OBuf[(*Octet)++] = 0x80 | pIE->UsrSpcL2Prot; + } + else { + OBuf[(*Octet) - 1] |= 0x80; + } + } - /* Octet 7*/ - if(pIE->Layer3Ident == 0x03) - { - OBuf[(*Octet)++] = (pIE->Layer3Ident<<5) | pIE->UIL3Prot; + /* Octet 7 */ + if (pIE->Layer3Ident == 0x03) { + OBuf[(*Octet)++] = (pIE->Layer3Ident << 5) | pIE->UIL3Prot; - /* Octet 7a - 3 different ones */ - if(pIE->UIL3Prot == 0x10) - { - OBuf[(*Octet++)] = 0x80 | pIE->OptL3Info; - } - else if(pIE->UIL3Prot == 0x06 - || pIE->UIL3Prot == 0x07 - || pIE->UIL3Prot == 0x08) - { - OBuf[(*Octet)++] = pIE->ModeL3 << 5; + /* Octet 7a - 3 different ones */ + if (pIE->UIL3Prot == 0x10) { + OBuf[(*Octet++)] = 0x80 | pIE->OptL3Info; + } + else if (pIE->UIL3Prot == 0x06 + || pIE->UIL3Prot == 0x07 + || pIE->UIL3Prot == 0x08) { + OBuf[(*Octet)++] = pIE->ModeL3 << 5; - /* Octet 7b note 7*/ - OBuf[(*Octet)++] = pIE->DefPackSize; + /* Octet 7b note 7 */ + OBuf[(*Octet)++] = pIE->DefPackSize; - /* Octet 7c note 7*/ - OBuf[(*Octet)++] = 0x80 | pIE->PackWinSize; - } - else if(pIE->UIL3Prot == 0x0b) - { - OBuf[(*Octet)++] = (pIE->AddL3Info >> 4) & 0x0f; - OBuf[(*Octet)++] = 0x80 | (pIE->AddL3Info & 0x0f); - } - else - { - OBuf[(*Octet)-1] |= 0x80; - } - } - else - { - Q931SetError(pTrunk,Q931E_LLCOMP, 7,0); - rc = Q931E_LLCOMP; - } + /* Octet 7c note 7 */ + OBuf[(*Octet)++] = 0x80 | pIE->PackWinSize; + } + else if (pIE->UIL3Prot == 0x0b) { + OBuf[(*Octet)++] = (pIE->AddL3Info >> 4) & 0x0f; + OBuf[(*Octet)++] = 0x80 | (pIE->AddL3Info & 0x0f); + } + else { + OBuf[(*Octet) - 1] |= 0x80; + } + } + else { + Q931SetError(pTrunk,Q931E_LLCOMP, 7,0); + rc = Q931E_LLCOMP; + } - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; + OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; + return rc; } /***************************************************************************** - Function: Q931Uie_NetFac + Function: Q931Uie_NetFac - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_NetFac(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_NetFac * pie = (Q931ie_NetFac*)OBuf; + Q931ie_NetFac *pie = (Q931ie_NetFac*)OBuf; ie *pIE = &pMsg->NetFac; - L3INT Off = 0; - L3INT Octet = 0; - L3INT x=0; - L3INT IESize; + L3INT Off = 0; + L3INT Octet = 0; + L3INT x = 0; + L3INT IESize; - *pIE=0; + *pIE = 0; - pie->IEId = IBuf[Octet]; - Octet ++; + pie->IEId = IBuf[Octet++]; - /* Octet 2 */ - IESize = IBuf[Octet ++]; + /* Octet 2 */ + IESize = IBuf[Octet++]; - pie->LenNetID = IBuf[Octet+Off]; /* full octet is used */ - Octet++; + pie->LenNetID = IBuf[Octet + Off]; /* full octet is used */ + Octet++; - if(pie->LenNetID > 0) - { - /* Octet 3.1 */ - pie->TypeNetID = (IBuf[Octet+Off] >> 4) & 0x0f; - pie->NetIDPlan = IBuf[Octet+Off] & 0x0f; - Off = Q931ReadExt(&IBuf[Octet], Off); - Off++; + if (pie->LenNetID > 0) { + /* Octet 3.1 */ + pie->TypeNetID = (IBuf[Octet + Off] >> 4) & 0x0f; + pie->NetIDPlan = IBuf[Octet + Off] & 0x0f; + Off = Q931ReadExt(&IBuf[Octet], Off); + Off++; - /* Octet 3.2*/ - for(x=0; x < pie->LenNetID; x++) - { - pie->NetID[x] = IBuf[Octet+Off] & 0x7f; - Off++; - } - } + /* Octet 3.2*/ + for (x = 0; x < pie->LenNetID; x++) { + pie->NetID[x] = IBuf[Octet + Off] & 0x7f; + Off++; + } + } - /* Octet 4*/ - pie->NetFac = IBuf[Octet+Off]; /* Full Octet is used */ - Octet++; + /* Octet 4*/ + pie->NetFac = IBuf[Octet + Off]; /* Full Octet is used */ + Octet++; - Q931IESizeTest(Q931E_NETFAC); + Q931IESizeTest(Q931E_NETFAC); + Q931SetIE(*pIE, *OOff); - Q931SetIE(*pIE, *OOff); + *IOff = (*IOff) + Octet + Off; + *OOff = (*OOff) + sizeof(Q931ie_NetFac) + x - 1; + pie->Size = (L3UCHAR)(sizeof(Q931ie_NetFac) + x - 1); - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_NetFac) + x - 1; - pie->Size = (L3UCHAR)(sizeof(Q931ie_NetFac) + x - 1); - - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_NetFac + Function: Q931Pie_NetFac - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_NetFac(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_NetFac * pIE = (Q931ie_NetFac*)IBuf; - L3INT rc=Q931E_NO_ERROR; - L3INT Beg=*Octet; - L3INT li; - L3INT x; + Q931ie_NetFac *pIE = (Q931ie_NetFac*)IBuf; + L3INT rc = Q931E_NO_ERROR; + L3INT Beg = *Octet; + L3INT li; + L3INT x; - OBuf[(*Octet)++] = Q931ie_NETWORK_SPECIFIC_FACILITIES; - li=(*Octet)++; + OBuf[(*Octet)++] = Q931ie_NETWORK_SPECIFIC_FACILITIES; + li = (*Octet)++; - /* Octet 3 */ - OBuf[(*Octet)++] = pIE->LenNetID; + /* Octet 3 */ + OBuf[(*Octet)++] = pIE->LenNetID; - if(pIE->LenNetID > 0) - { - /* Octet 3.1 */ - OBuf[(*Octet)++] = 0x80 | (pIE->TypeNetID << 4) | pIE->NetIDPlan; + if (pIE->LenNetID > 0) { + /* Octet 3.1 */ + OBuf[(*Octet)++] = 0x80 | (pIE->TypeNetID << 4) | pIE->NetIDPlan; - /* Octet 3.2 */ - for(x=0; x LenNetID; x++) - { - OBuf[(*Octet)++] = pIE->NetID[x]; - } - } + /* Octet 3.2 */ + for (x = 0; x LenNetID; x++) { + OBuf[(*Octet)++] = pIE->NetID[x]; + } + } - /* Octet 4*/ - OBuf[(*Octet)++] = pIE->NetFac; + /* Octet 4 */ + OBuf[(*Octet)++] = pIE->NetFac; - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; + OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; + return rc; } /***************************************************************************** - Function: Q931Uie_NotifInd + Function: Q931Uie_NotifInd - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_NotifInd(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_NotifInd * pie = (Q931ie_NotifInd*)OBuf; + Q931ie_NotifInd *pie = (Q931ie_NotifInd*)OBuf; ie *pIE = &pMsg->NotifInd; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; + L3INT Off = 0; + L3INT Octet = 0; + L3INT IESize; - *pIE=0; + *pIE = 0; - pie->IEId = IBuf[Octet]; - Octet ++; + pie->IEId = IBuf[Octet++]; - /* Octet 2*/ - IESize = IBuf[Octet ++]; + /* Octet 2*/ + IESize = IBuf[Octet++]; - /* Octet 3 */ - pie->Notification = IBuf[Octet+Off] & 0x7f; + /* Octet 3 */ + pie->Notification = IBuf[Octet + Off] & 0x7f; - Off = Q931ReadExt(&IBuf[Octet], Off); - Octet++; + Off = Q931ReadExt(&IBuf[Octet], Off); + Octet++; - Q931IESizeTest(Q931E_NOTIFIND); + Q931IESizeTest(Q931E_NOTIFIND); + Q931SetIE(*pIE, *OOff); - Q931SetIE(*pIE, *OOff); + *IOff = (*IOff) + Octet + Off; + *OOff = (*OOff) + sizeof(Q931ie_NotifInd); + pie->Size = sizeof(Q931ie_NotifInd); - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_NotifInd); - pie->Size = sizeof(Q931ie_NotifInd); - - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_NotifInd + Function: Q931Pie_NotifInd - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_NotifInd(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_NotifInd * pIE = (Q931ie_NotifInd*)IBuf; - L3INT rc=Q931E_NO_ERROR; - L3INT Beg=*Octet; - L3INT li; + Q931ie_NotifInd *pIE = (Q931ie_NotifInd*)IBuf; + L3INT rc = Q931E_NO_ERROR; + L3INT Beg = *Octet; + L3INT li; - OBuf[(*Octet)++] = Q931ie_NOTIFICATION_INDICATOR; - li=(*Octet)++; + OBuf[(*Octet)++] = Q931ie_NOTIFICATION_INDICATOR; + li = (*Octet)++; - /* Octet 3*/ - OBuf[(*Octet)++] = pIE->Notification; + /* Octet 3 */ + OBuf[(*Octet)++] = pIE->Notification; - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; + OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; + return rc; } /***************************************************************************** - Function: Q931Uie_ProgInd + Function: Q931Uie_ProgInd - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_ProgInd(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_ProgInd * pie = (Q931ie_ProgInd*)OBuf; + Q931ie_ProgInd *pie = (Q931ie_ProgInd*)OBuf; ie *pIE = &pMsg->ProgInd; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; + L3INT Off = 0; + L3INT Octet = 0; + L3INT IESize; - *pIE=0; + *pIE = 0; - pie->IEId = IBuf[Octet]; - Octet ++; + pie->IEId = IBuf[Octet++]; - /* Octet 2*/ - IESize = IBuf[Octet ++]; + /* Octet 2 */ + IESize = IBuf[Octet++]; - /* Octet 3*/ - pie->CodStand = (IBuf[Octet+Off] >> 5) & 0x03; - pie->Location = IBuf[Octet+Off] & 0x0f; + /* Octet 3 */ + pie->CodStand = (IBuf[Octet + Off] >> 5) & 0x03; + pie->Location = IBuf[Octet + Off] & 0x0f; - Off = Q931ReadExt(&IBuf[Octet], Off); - Octet++; + Off = Q931ReadExt(&IBuf[Octet], Off); + Octet++; - /* Octet 4*/ - pie->ProgDesc = IBuf[Octet+Off] & 0x7f; - Off = Q931ReadExt(&IBuf[Octet], Off); - Octet++; + /* Octet 4 */ + pie->ProgDesc = IBuf[Octet + Off] & 0x7f; + Off = Q931ReadExt(&IBuf[Octet], Off); + Octet++; - Q931IESizeTest(Q931E_PROGIND); + Q931IESizeTest(Q931E_PROGIND); + Q931SetIE(*pIE, *OOff); - Q931SetIE(*pIE, *OOff); + *IOff = (*IOff) + Octet + Off; + *OOff = (*OOff) + sizeof(Q931ie_ProgInd); + pie->Size = sizeof(Q931ie_ProgInd); - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_ProgInd); - pie->Size = sizeof(Q931ie_ProgInd); - - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_ProgInd + Function: Q931Pie_ProgInd - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset L3INTo OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset L3INTo OBuf. Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_ProgInd(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_ProgInd * pIE = (Q931ie_ProgInd*)IBuf; - L3INT rc=Q931E_NO_ERROR; - L3INT Beg=*Octet; - L3INT li; + Q931ie_ProgInd *pIE = (Q931ie_ProgInd*)IBuf; + L3INT rc = Q931E_NO_ERROR; + L3INT Beg = *Octet; + L3INT li; - OBuf[(*Octet)++] = Q931ie_PROGRESS_INDICATOR; - li=(*Octet)++; + OBuf[(*Octet)++] = Q931ie_PROGRESS_INDICATOR; + li = (*Octet)++; - /* Octet 3*/ - OBuf[(*Octet)++] = 0x80 | (pIE->CodStand << 5) | pIE->Location; + /* Octet 3 */ + OBuf[(*Octet)++] = 0x80 | (pIE->CodStand << 5) | pIE->Location; - /* Octet 4*/ - OBuf[(*Octet)++] = 0x80 | pIE->ProgDesc; + /* Octet 4 */ + OBuf[(*Octet)++] = 0x80 | pIE->ProgDesc; - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; + OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; + return rc; } /***************************************************************************** - Function: Q931Uie_RepeatInd + Function: Q931Uie_RepeatInd - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_RepeatInd(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_RepeatInd *pie = (Q931ie_RepeatInd*)OBuf; + Q931ie_RepeatInd *pie = (Q931ie_RepeatInd*)OBuf; ie *pIE = &pMsg->RepeatInd; - L3INT Off = 0; - L3INT Octet = 0; + L3INT Off = 0; + L3INT Octet = 0; - *pIE=0; + *pIE = 0; - pie->IEId = IBuf[Octet] & 0xf0; - pie->RepeatInd = IBuf[Octet] & 0x0f; - Octet ++; + pie->IEId = IBuf[Octet] & 0xf0; + pie->RepeatInd = IBuf[Octet] & 0x0f; + Octet ++; - Q931SetIE(*pIE, *OOff); + Q931SetIE(*pIE, *OOff); - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_RepeatInd); - pie->Size = sizeof(Q931ie_RepeatInd); + *IOff = (*IOff) + Octet + Off; + *OOff = (*OOff) + sizeof(Q931ie_RepeatInd); + pie->Size = sizeof(Q931ie_RepeatInd); - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_RepeatInd + Function: Q931Pie_RepeatInd - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_RepeatInd(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_RepeatInd * pIE = (Q931ie_RepeatInd*)IBuf; - L3INT rc=0; - /* L3INT Beg=*Octet; */ + Q931ie_RepeatInd *pIE = (Q931ie_RepeatInd*)IBuf; + L3INT rc = 0; + /* L3INT Beg = *Octet; */ - OBuf[(*Octet)++] = Q931ie_REPEAT_INDICATOR | pIE->RepeatInd; - - return rc; + OBuf[(*Octet)++] = Q931ie_REPEAT_INDICATOR | pIE->RepeatInd; + + return rc; } /***************************************************************************** - Function: Q931Uie_RevChargeInd + Function: Q931Uie_RevChargeInd - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_RevChargeInd(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - ie iE; + ie iE; /* ie *pIE = &pMsg->RevChargeInd; */ - Q931SetIE(iE, *OOff); + Q931SetIE(iE, *OOff); - return iE; + return iE; } /***************************************************************************** - Function: Q931Pie_RevChargeInd + Function: Q931Pie_RevChargeInd - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_RevChargeInd(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - L3BOOL RetCode = L3FALSE; + L3BOOL RetCode = L3FALSE; - NoWarning(OBuf); - NoWarning(IBuf); + NoWarning(OBuf); + NoWarning(IBuf); - return RetCode; + return RetCode; } /***************************************************************************** - Function: Q931Uie_RestartInd + Function: Q931Uie_RestartInd - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_RestartInd(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_RestartInd * pie = (Q931ie_RestartInd*)OBuf; + Q931ie_RestartInd *pie = (Q931ie_RestartInd*)OBuf; ie *pIE = &pMsg->RestartInd; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; + L3INT Off = 0; + L3INT Octet = 0; + L3INT IESize; - *pIE=0; + *pIE = 0; - pie->IEId = IBuf[Octet]; - Octet ++; + pie->IEId = IBuf[Octet++]; - /* Octet 2*/ - IESize = IBuf[Octet ++]; + /* Octet 2 */ + IESize = IBuf[Octet++]; - /* Octet 3 */ - pie->Class = IBuf[Octet+Off] & 0x07; - pie->Spare = IBuf[Octet+Off] & 0x78; + /* Octet 3 */ + pie->Class = IBuf[Octet + Off] & 0x07; + pie->Spare = IBuf[Octet + Off] & 0x78; - Off = Q931ReadExt(&IBuf[Octet], Off); - Octet++; + Off = Q931ReadExt(&IBuf[Octet], Off); + Octet++; - Q931IESizeTest(Q931E_RESTARTIND); + Q931IESizeTest(Q931E_RESTARTIND); + Q931SetIE(*pIE, *OOff); - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_RestartInd); - pie->Size = sizeof(Q931ie_RestartInd); + *IOff = (*IOff) + Octet + Off; + *OOff = (*OOff) + sizeof(Q931ie_RestartInd); + pie->Size = sizeof(Q931ie_RestartInd); - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_RestartInd + Function: Q931Pie_RestartInd - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_RestartInd(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_RestartInd * pIE = (Q931ie_RestartInd*)IBuf; - L3INT rc=Q931E_NO_ERROR; - L3INT Beg=*Octet; - L3INT li; + Q931ie_RestartInd *pIE = (Q931ie_RestartInd*)IBuf; + L3INT rc = Q931E_NO_ERROR; + L3INT Beg = *Octet; + L3INT li; - OBuf[(*Octet)++] = Q931ie_RESTART_INDICATOR; - li=(*Octet)++; + OBuf[(*Octet)++] = Q931ie_RESTART_INDICATOR; + li = (*Octet)++; - /* Octet 3*/ - OBuf[(*Octet)++] = 0x80 | pIE->Class ; + /* Octet 3*/ + OBuf[(*Octet)++] = 0x80 | pIE->Class ; - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; + OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; + return rc; } /***************************************************************************** - Function: Q931Uie_Segment + Function: Q931Uie_Segment - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_Segment(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_Segment * pie = (Q931ie_Segment*)OBuf; + Q931ie_Segment *pie = (Q931ie_Segment*)OBuf; ie *pIE = &pMsg->Segment; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; + L3INT Off = 0; + L3INT Octet = 0; + L3INT IESize; - *pIE=0; + *pIE = 0; - pie->IEId = IBuf[Octet]; - Octet ++; + pie->IEId = IBuf[Octet++]; + Octet++; - /* Octet 2*/ - IESize = IBuf[Octet ++]; + /* Octet 2*/ + IESize = IBuf[Octet++]; - /* Octet 3 */ - pie->FSI = (IBuf[Octet+Off] & 0x80) >> 7; - pie->NumSegRem = IBuf[Octet+Off] & 0x7f; - Octet++; + /* Octet 3 */ + pie->FSI = (IBuf[Octet + Off] & 0x80) >> 7; + pie->NumSegRem = IBuf[Octet + Off] & 0x7f; + Octet++; - /* Octet 4 */ - pie->SegType = IBuf[Octet+Off] & 0x7f; - Octet++; - - Q931IESizeTest(Q931E_SEGMENT); + /* Octet 4 */ + pie->SegType = IBuf[Octet + Off] & 0x7f; + Octet++; + + Q931IESizeTest(Q931E_SEGMENT); + Q931SetIE(*pIE, *OOff); - Q931SetIE(*pIE, *OOff); + *IOff = (*IOff) + Octet + Off; + *OOff = (*OOff) + sizeof(Q931ie_Segment); + pie->Size = sizeof(Q931ie_Segment); - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_Segment); - pie->Size = sizeof(Q931ie_Segment); - - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_Segment + Function: Q931Pie_Segment - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_Segment(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_Segment * pIE = (Q931ie_Segment*)IBuf; - L3INT rc=Q931E_NO_ERROR; - L3INT Beg=*Octet; - L3INT li; + Q931ie_Segment *pIE = (Q931ie_Segment*)IBuf; + L3INT rc = Q931E_NO_ERROR; + L3INT Beg = *Octet; + L3INT li; - OBuf[(*Octet)++] = Q931ie_SEGMENTED_MESSAGE; - li=(*Octet)++; + OBuf[(*Octet)++] = Q931ie_SEGMENTED_MESSAGE; + li = (*Octet)++; - /* Octet 3*/ - OBuf[(*Octet)++] = (pIE->FSI<<7) | pIE->NumSegRem; + /* Octet 3 */ + OBuf[(*Octet)++] = (pIE->FSI << 7) | pIE->NumSegRem; - /* Octet 4 */ - OBuf[(*Octet)++] = pIE->SegType; + /* Octet 4 */ + OBuf[(*Octet)++] = pIE->SegType; - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; + OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; + return rc; } /***************************************************************************** - Function: Q931Uie_SendComplete + Function: Q931Uie_SendComplete - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_SendComplete(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_SendComplete *pie = (Q931ie_SendComplete*)OBuf; + Q931ie_SendComplete *pie = (Q931ie_SendComplete*)OBuf; ie *pIE = &pMsg->SendComplete; - L3INT Off = 0; - L3INT Octet = 0; + L3INT Off = 0; + L3INT Octet = 0; - *pIE=0; + *pIE = 0; + Octet++; - Octet ++; + Q931SetIE(*pIE, *OOff); - Q931SetIE(*pIE, *OOff); + *IOff = (*IOff) + Octet + Off; + *OOff = (*OOff) + sizeof(Q931ie_SendComplete); + pie->Size = sizeof(Q931ie_SendComplete); - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_SendComplete); - pie->Size = sizeof(Q931ie_SendComplete); - - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_ProgInd + Function: Q931Pie_ProgInd - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_SendComplete(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - /* Q931ie_SendComplete * pIE = (Q931ie_SendComplete*)IBuf; */ - L3INT rc=Q931E_NO_ERROR; - /* L3INT Beg=*Octet; */ + /* Q931ie_SendComplete * pIE = (Q931ie_SendComplete*)IBuf; */ + L3INT rc = Q931E_NO_ERROR; + /* L3INT Beg = *Octet; */ - OBuf[(*Octet)++] = 0x80 | (L3UCHAR)Q931ie_SENDING_COMPLETE; + OBuf[(*Octet)++] = 0x80 | (L3UCHAR)Q931ie_SENDING_COMPLETE; - return rc; + return rc; } /***************************************************************************** - Function: Q931Uie_Signal + Function: Q931Uie_Signal - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_Signal(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_Signal * pie = (Q931ie_Signal*)OBuf; + Q931ie_Signal *pie = (Q931ie_Signal*)OBuf; ie *pIE = &pMsg->Signal; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; + L3INT Off = 0; + L3INT Octet = 0; + L3INT IESize; - *pIE=0; + *pIE = 0; - pie->IEId = IBuf[Octet]; - Octet ++; + pie->IEId = IBuf[Octet++]; - /* Octet 2*/ - IESize = IBuf[Octet ++]; + /* Octet 2 */ + IESize = IBuf[Octet++]; - /* Octet 3 */ - pie->Signal = IBuf[Octet+Off]; - Octet++; + /* Octet 3 */ + pie->Signal = IBuf[Octet + Off]; + Octet++; - Q931IESizeTest(Q931E_SIGNAL); + Q931IESizeTest(Q931E_SIGNAL); + Q931SetIE(*pIE, *OOff); - Q931SetIE(*pIE, *OOff); + *IOff = (*IOff) + Octet + Off; + *OOff = (*OOff) + sizeof(Q931ie_Signal); + pie->Size = sizeof(Q931ie_Signal); - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_Signal); - pie->Size = sizeof(Q931ie_Signal); - - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_Signal + Function: Q931Pie_Signal - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_Signal(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_Signal * pIE = (Q931ie_Signal*)IBuf; - L3INT rc=Q931E_NO_ERROR; - L3INT Beg=*Octet; - L3INT li; + Q931ie_Signal *pIE = (Q931ie_Signal*)IBuf; + L3INT rc = Q931E_NO_ERROR; + L3INT Beg = *Octet; + L3INT li; - OBuf[(*Octet)++] = Q931ie_SIGNAL; - li=(*Octet)++; + OBuf[(*Octet)++] = Q931ie_SIGNAL; + li = (*Octet)++; - /* Octet 3*/ - OBuf[(*Octet)++] = pIE->Signal; + /* Octet 3 */ + OBuf[(*Octet)++] = pIE->Signal; - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; + OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; + return rc; } /***************************************************************************** - Function: Q931Uie_TransNetSel + Function: Q931Uie_TransNetSel - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_TransNetSel(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_TransNetSel * pie = (Q931ie_TransNetSel*)OBuf; + Q931ie_TransNetSel *pie = (Q931ie_TransNetSel*)OBuf; ie *pIE = &pMsg->TransNetSel; - L3INT Off = 0; - L3INT Octet = 0; - L3INT x=0; - L3INT l; + L3INT Off = 0; + L3INT Octet = 0; + L3INT x = 0; + L3INT l; - *pIE=0; + *pIE = 0; - pie->IEId = IBuf[Octet]; - Octet ++; + pie->IEId = IBuf[Octet++]; - /* Octet 2 */ - l = IBuf[Octet] - 3; - Octet++; + /* Octet 2 */ + l = IBuf[Octet++] - 3; - /* Octet 3*/ - pie->Type = (IBuf[Octet+Off] >> 4) & 0x07; + /* Octet 3 */ + pie->Type = (IBuf[Octet + Off] >> 4) & 0x07; - Off = Q931ReadExt(&IBuf[Octet], Off); - Octet++; + Off = Q931ReadExt(&IBuf[Octet], Off); + Octet++; - for(x=0; x < l; x++) - { - pie->NetID[x] = IBuf[Octet+Off] & 0x7f; - Off++; - } + for (x = 0; x < l; x++) { + pie->NetID[x] = IBuf[Octet + Off] & 0x7f; + Off++; + } - Q931SetIE(*pIE, *OOff); + Q931SetIE(*pIE, *OOff); - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_TransNetSel) + x - 1; - pie->Size = (L3UCHAR)(sizeof(Q931ie_TransNetSel) + x - 1); + *IOff = (*IOff) + Octet + Off; + *OOff = (*OOff) + sizeof(Q931ie_TransNetSel) + x - 1; + pie->Size = (L3UCHAR)(sizeof(Q931ie_TransNetSel) + x - 1); - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_TransNetSel + Function: Q931Pie_TransNetSel - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_TransNetSel(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_TransNetSel * pIE = (Q931ie_TransNetSel*)IBuf; - L3INT rc=Q931E_NO_ERROR; - L3INT Beg=*Octet; - L3INT li; - L3INT x; - L3INT l; + Q931ie_TransNetSel *pIE = (Q931ie_TransNetSel*)IBuf; + L3INT rc = Q931E_NO_ERROR; + L3INT Beg = *Octet; + L3INT li; + L3INT x; + L3INT l; - OBuf[(*Octet)++] = Q931ie_TRANSIT_NETWORK_SELECTION; - li=(*Octet)++; + OBuf[(*Octet)++] = Q931ie_TRANSIT_NETWORK_SELECTION; + li = (*Octet)++; - /* Octet 3 */ - OBuf[(*Octet)++] = 0x80 | (pIE->Type<<4) | pIE->NetIDPlan; + /* Octet 3 */ + OBuf[(*Octet)++] = 0x80 | (pIE->Type << 4) | pIE->NetIDPlan; - /* Octet 4 */ - l = pIE->Size - sizeof(Q931ie_TransNetSel) + 1; - for(x=0;xNetID[x]; - } + /* Octet 4 */ + l = pIE->Size - sizeof(Q931ie_TransNetSel) + 1; + for (x = 0; x < l; x++) { + OBuf[(*Octet)++] = pIE->NetID[x]; + } - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; + OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; + return rc; } /***************************************************************************** - Function: Q931Uie_UserUser + Function: Q931Uie_UserUser - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_UserUser(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_UserUser * pie = (Q931ie_UserUser*)OBuf; + Q931ie_UserUser *pie = (Q931ie_UserUser*)OBuf; ie *pIE = &pMsg->UserUser; - L3INT Off = 0; - L3INT Octet = 0; - L3INT x=0; - L3INT l; + L3INT Off = 0; + L3INT Octet = 0; + L3INT x = 0; + L3INT l; - *pIE=0; + *pIE = 0; - pie->IEId = IBuf[Octet]; - Octet ++; + pie->IEId = IBuf[Octet++]; - /* Octet 2 */ - l = IBuf[Octet] - 3; - Octet++; + /* Octet 2 */ + l = IBuf[Octet++] - 3; - /* Octet 3*/ - pie->ProtDisc = IBuf[Octet+Off]; - Octet++; + /* Octet 3 */ + pie->ProtDisc = IBuf[Octet + Off]; + Octet++; - for(x=0; x < l; x++) - { - pie->User[x] = IBuf[Octet+Off]; - Off++; - } + for (x = 0; x < l; x++) { + pie->User[x] = IBuf[Octet + Off]; + Off++; + } - Q931SetIE(*pIE, *OOff); + Q931SetIE(*pIE, *OOff); - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_UserUser) + x - 1; - pie->Size = (L3UCHAR)(sizeof(Q931ie_UserUser) + x - 1); + *IOff = (*IOff) + Octet + Off; + *OOff = (*OOff) + sizeof(Q931ie_UserUser) + x - 1; + pie->Size = (L3UCHAR)(sizeof(Q931ie_UserUser) + x - 1); - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_UserUser + Function: Q931Pie_UserUser - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_UserUser(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_UserUser * pIE = (Q931ie_UserUser*)IBuf; - L3INT rc=Q931E_NO_ERROR; - L3INT Beg=*Octet; - L3INT li; - L3INT x; - L3INT l; + Q931ie_UserUser *pIE = (Q931ie_UserUser*)IBuf; + L3INT rc = Q931E_NO_ERROR; + L3INT Beg = *Octet; + L3INT li; + L3INT x; + L3INT l; - OBuf[(*Octet)++] = Q931ie_USER_USER; - li=(*Octet)++; + OBuf[(*Octet)++] = Q931ie_USER_USER; + li = (*Octet)++; - /* Octet 3 */ - OBuf[(*Octet)++] = pIE->ProtDisc; + /* Octet 3 */ + OBuf[(*Octet)++] = pIE->ProtDisc; - /* Octet 4 */ - l = pIE->Size - sizeof(Q931ie_UserUser) + 1; - for(x=0;xUser[x]; - } + /* Octet 4 */ + l = pIE->Size - sizeof(Q931ie_UserUser) + 1; + for (x = 0; x < l; x++) { + OBuf[(*Octet)++] = pIE->User[x]; + } - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; + OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; + return rc; } /***************************************************************************** - Function: Q931Uie_GenericDigits + Function: Q931Uie_GenericDigits - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_GenericDigits(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_GenericDigits * pie = (Q931ie_GenericDigits*)OBuf; + Q931ie_GenericDigits *pie = (Q931ie_GenericDigits*)OBuf; ie *pIE = &pMsg->GenericDigits; - L3INT Off = 0; - L3INT Octet = 0; - L3INT x; - L3INT IESize; + L3INT Off = 0; + L3INT Octet = 0; + L3INT x; + L3INT IESize; - *pIE=0; + *pIE = 0; - /* Octet 1 */ - pie->IEId = IBuf[Octet]; - Octet ++; + /* Octet 1 */ + pie->IEId = IBuf[Octet++]; - /* Octet 2 */ - IESize = IBuf[Octet ++]; + /* Octet 2 */ + IESize = IBuf[Octet++]; - /* Octet 3 */ - pie->Type = (IBuf[Octet]) & 0x1F; - pie->Encoding = (IBuf[Octet] >> 5) & 0x07; - Octet ++; - - /* Octet 4*/ + /* Octet 3 */ + pie->Type = (IBuf[Octet]) & 0x1F; + pie->Encoding = (IBuf[Octet] >> 5) & 0x07; + Octet++; + + /* Octet 4*/ if (pie->Encoding == 0) { /* BCD Even */ x = 0; do { - pie->Digit[x++] = IBuf[Octet+Off] & 0x0f; - pie->Digit[x++] = (IBuf[Octet+Off] >> 4) & 0x0f; + pie->Digit[x++] = IBuf[Octet + Off] & 0x0f; + pie->Digit[x++] = (IBuf[Octet + Off] >> 4) & 0x0f; Off++; } while (Q931MoreIE()); } else if (pie->Encoding == 1) { /* BCD Odd */ x = 0; do { - pie->Digit[x++] = IBuf[Octet+Off] & 0x0f; + pie->Digit[x++] = IBuf[Octet + Off] & 0x0f; if (Q931MoreIE()) { - pie->Digit[x] = (IBuf[Octet+Off] >> 4) & 0x0f; + pie->Digit[x] = (IBuf[Octet + Off] >> 4) & 0x0f; } x++; Off++; @@ -3070,7 +2912,7 @@ L3INT Q931Uie_GenericDigits(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3U } else if (pie->Encoding == 2) { /* IA5 */ x = 0; do { - pie->Digit[x++] = IBuf[Octet+Off] & 0x7f; + pie->Digit[x++] = IBuf[Octet + Off] & 0x7f; Off++; } while (Q931MoreIE()); } else { @@ -3079,112 +2921,108 @@ L3INT Q931Uie_GenericDigits(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3U return Q931E_GENERIC_DIGITS; } - Q931IESizeTest(Q931E_GENERIC_DIGITS); + Q931IESizeTest(Q931E_GENERIC_DIGITS); + Q931SetIE(*pIE, *OOff); - Q931SetIE(*pIE, *OOff); + *IOff = (*IOff) + Octet + Off; + *OOff = (*OOff) + sizeof(Q931ie_CallingSub) + x - 1; + pie->Size = (L3UCHAR)(sizeof(Q931ie_CallingSub) + x - 1); - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_CallingSub) + x -1; - pie->Size = (L3UCHAR)(sizeof(Q931ie_CallingSub) + x -1); - - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_GenericDigits + Function: Q931Pie_GenericDigits - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_GenericDigits(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { OBuf[(*Octet)++] = (Q931ie_GENERIC_DIGITS & 0xFF); - OBuf[(*Octet)++] = 0; + OBuf[(*Octet)++] = 0; - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Uie_ChangeStatus + Function: Q931Uie_ChangeStatus - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset + Parameters: pIE[OUT] ptr to Information Element id. + IBuf[IN] ptr to a packed ie. + OBuf[OUT] ptr to buffer for Unpacked ie. + IOff[IN\OUT] Input buffer offset + OOff[IN\OUT] Output buffer offset - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. + Ibuf and OBuf points directly to buffers. The IOff and OOff + must be updated, but are otherwise not used in the ie unpack. Return Value: Error Message *****************************************************************************/ L3INT Q931Uie_ChangeStatus(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) { - Q931ie_ChangeStatus * pie = (Q931ie_ChangeStatus*)OBuf; + Q931ie_ChangeStatus *pie = (Q931ie_ChangeStatus*)OBuf; ie *pIE = &pMsg->ChangeStatus; - L3INT Off = 0; - L3INT Octet = 0; - L3INT IESize; + L3INT Off = 0; + L3INT Octet = 0; + L3INT IESize; - *pIE=0; + *pIE = 0; - pie->IEId = IBuf[Octet]; - Octet ++; + pie->IEId = IBuf[Octet++]; - /* Octet 2*/ - IESize = IBuf[Octet ++]; + /* Octet 2 */ + IESize = IBuf[Octet++]; - /* Octet 3 */ - pie->Preference = (IBuf[Octet+Off] >> 6) & 0x01; - pie->Spare = IBuf[Octet+Off] & 0x38; - pie->NewStatus = IBuf[Octet+Off] & 0x07; + /* Octet 3 */ + pie->Preference = (IBuf[Octet + Off] >> 6) & 0x01; + pie->Spare = IBuf[Octet + Off] & 0x38; + pie->NewStatus = IBuf[Octet + Off] & 0x07; + Octet++; - Octet++; + Q931SetIE(*pIE, *OOff); - Q931SetIE(*pIE, *OOff); + *IOff = (*IOff) + Octet + Off; + *OOff = (*OOff) + sizeof(Q931ie_ChangeStatus); + pie->Size = sizeof(Q931ie_ChangeStatus); - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_ChangeStatus); - pie->Size = sizeof(Q931ie_ChangeStatus); - - - return Q931E_NO_ERROR; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pie_ChangeStatus + Function: Q931Pie_ChangeStatus - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. + Parameters: IBuf[IN] Ptr to struct. + OBuf[OUT] Ptr tp packed output buffer. + Octet[IN/OUT] Offset into OBuf. - Return Value: Error code, 0 = OK + Return Value: Error code, 0 = OK *****************************************************************************/ L3INT Q931Pie_ChangeStatus(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) { - Q931ie_ChangeStatus * pIE = (Q931ie_ChangeStatus*)IBuf; - L3INT rc=Q931E_NO_ERROR; - L3INT Beg=*Octet; - L3INT li; + Q931ie_ChangeStatus *pIE = (Q931ie_ChangeStatus*)IBuf; + L3INT rc = Q931E_NO_ERROR; + L3INT Beg = *Octet; + L3INT li; - OBuf[(*Octet)++] = Q931ie_CHANGE_STATUS; - li=(*Octet)++; + OBuf[(*Octet)++] = Q931ie_CHANGE_STATUS; + li = (*Octet)++; - /* Octet 3*/ - OBuf[(*Octet)++] = 0x80 | pIE->NewStatus | ((pIE->Preference & 0x01) << 6); + /* Octet 3 */ + OBuf[(*Octet)++] = 0x80 | pIE->NewStatus | ((pIE->Preference & 0x01) << 6); - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; + OBuf[li] = (L3UCHAR)((*Octet) - Beg) - 2; + return rc; } diff --git a/libs/freetdm/src/isdn/Q931mes.c b/libs/freetdm/src/isdn/Q931mes.c index 43a5098f62..f77f3837f1 100644 --- a/libs/freetdm/src/isdn/Q931mes.c +++ b/libs/freetdm/src/isdn/Q931mes.c @@ -1,13 +1,13 @@ /***************************************************************************** - FileName: Q931mes.c + FileName: Q931mes.c - Contents: Pack/Unpack functions. These functions will unpack a Q931 - message from the bit packed original format into structs - that contains variables sized by the user. It will also pack - the struct back into a Q.931 message as required. + Contents: Pack/Unpack functions. These functions will unpack a Q931 + message from the bit packed original format into structs + that contains variables sized by the user. It will also pack + the struct back into a Q.931 message as required. - See q931.h for description. + See q931.h for description. License/Copyright: @@ -18,12 +18,12 @@ modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of the Case Labs, Ltd nor the names of its contributors + * Neither the name of the Case Labs, Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -54,38 +54,35 @@ L3INT Q931MesgHeader(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *mes, L3UCHAR *OB Q931Log(pTrunk, Q931_LOG_DEBUG, "Creating Q.931 Message Header:\n ProtDisc %d (%#x), CRV %d (%#x), CRVflag: %d (%#x), MesType: %d (%#x)\n", mes->ProtDisc, mes->ProtDisc, mes->CRV, mes->CRV, mes->CRVFlag, mes->CRVFlag, mes->MesType, mes->MesType); - OBuf[Octet++] = mes->ProtDisc; /* Protocol discriminator */ - if(!Q931_IS_BRI(pTrunk)) { - OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)((mes->CRV >> 8) & 0x7f) | ((mes->CRVFlag << 7) & 0x80); /* msb */ - OBuf[Octet++] = (L3UCHAR) (mes->CRV & 0xff); /* lsb */ + OBuf[Octet++] = mes->ProtDisc; /* Protocol discriminator */ + if (!Q931_IS_BRI(pTrunk)) { + OBuf[Octet++] = 2; /* length is 2 octets */ + OBuf[Octet++] = (L3UCHAR)((mes->CRV >> 8) & 0x7f) | ((mes->CRVFlag << 7) & 0x80); /* msb */ + OBuf[Octet++] = (L3UCHAR) (mes->CRV & 0xff); /* lsb */ } else { - OBuf[Octet++] = 1; /* length is 1 octet */ - OBuf[Octet++] = (L3UCHAR) (mes->CRV & 0x7f) | ((mes->CRVFlag << 7) & 0x80); /* CRV & flag */ + OBuf[Octet++] = 1; /* length is 1 octet */ + OBuf[Octet++] = (L3UCHAR) (mes->CRV & 0x7f) | ((mes->CRVFlag << 7) & 0x80); /* CRV & flag */ } - OBuf[Octet++] = mes->MesType; /* message header */ + OBuf[Octet++] = mes->MesType; /* message header */ *IOff = Octet; - return 0; } /***************************************************************************** - Function: Q931Umes_Alerting + Function: Q931Umes_Alerting *****************************************************************************/ L3INT Q931Umes_Alerting(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; - while(IOff < Size) - { - switch(IBuf[IOff]) - { + while (IOff < Size) { + switch (IBuf[IOff]) { case Q931ie_BEARER_CAPABILITY: case Q931ie_CHANNEL_IDENTIFICATION: case Q931ie_PROGRESS_INDICATOR: @@ -93,7 +90,7 @@ L3INT Q931Umes_Alerting(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic case Q931ie_SIGNAL: case Q931ie_HIGH_LAYER_COMPATIBILITY: rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; default: @@ -101,82 +98,84 @@ L3INT Q931Umes_Alerting(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic break; } } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_Alerting + Function: Q931Pmes_Alerting *****************************************************************************/ L3INT Q931Pmes_Alerting(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3INT rc = Q931E_NO_ERROR; Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; L3INT Octet = 0; /* Q931 Message Header */ Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); /* Bearer capability */ - if(Q931IsIEPresent(pMes->BearerCap)) - { - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->BearerCap)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet)) != 0) return rc; } /* Channel Identification */ - if(Q931IsIEPresent(pMes->ChanID)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->ChanID)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Progress indicator */ - if(Q931IsIEPresent(pMes->ProgInd)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->ProgInd)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Display */ - if(Q931IsIEPresent(pMes->Display)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Display)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Signal */ - if(Q931IsIEPresent(pMes->Signal)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Signal)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* High Layer Compatibility */ - if(Q931IsIEPresent(pMes->HLComp)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->HLComp)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet)) != 0) return rc; + } *OSize = Octet; - - return rc; + return rc; } /***************************************************************************** - Function: Q931Umes_CallProceeding + Function: Q931Umes_CallProceeding *****************************************************************************/ L3INT Q931Umes_CallProceeding(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; - while(IOff < Size) - { - switch(IBuf[IOff]) - { + while (IOff < Size) { + switch (IBuf[IOff]) { case Q931ie_BEARER_CAPABILITY: case Q931ie_CHANNEL_IDENTIFICATION: case Q931ie_PROGRESS_INDICATOR: case Q931ie_DISPLAY: case Q931ie_HIGH_LAYER_COMPATIBILITY: rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; default: @@ -184,103 +183,103 @@ L3INT Q931Umes_CallProceeding(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_G break; } } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_CallProceeding + Function: Q931Pmes_CallProceeding *****************************************************************************/ L3INT Q931Pmes_CallProceeding(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3INT rc = Q931E_NO_ERROR; Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; L3INT Octet = 0; /* Q931 Message Header */ Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); /* Bearer capability */ - if(Q931IsIEPresent(pMes->BearerCap)) - { - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->BearerCap)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet)) != 0) return rc; } /* Channel Identification */ - if(Q931IsIEPresent(pMes->ChanID)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->ChanID)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Progress indicator */ - if(Q931IsIEPresent(pMes->ProgInd)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->ProgInd)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Display */ - if(Q931IsIEPresent(pMes->Display)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Display)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* High Layer Compatibility */ - if(Q931IsIEPresent(pMes->HLComp)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->HLComp)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet)) != 0) return rc; + } *OSize = Octet; - - return rc; + return rc; } /***************************************************************************** - Function: Q931Umes_CongestionControl + Function: Q931Umes_CongestionControl *****************************************************************************/ L3INT Q931Umes_CongestionControl(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3BOOL RetCode = L3FALSE; + L3BOOL RetCode = L3FALSE; - NoWarning(mes); - NoWarning(IBuf); + NoWarning(mes); + NoWarning(IBuf); - return RetCode; + return RetCode; } /***************************************************************************** - Function: Q931Pmes_CongestionControl + Function: Q931Pmes_CongestionControl *****************************************************************************/ L3INT Q931Pmes_CongestionControl(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3BOOL RetCode = L3FALSE; + L3BOOL RetCode = L3FALSE; - NoWarning(OBuf); - NoWarning(IBuf); + NoWarning(OBuf); + NoWarning(IBuf); *OSize = 0; - - return RetCode; + return RetCode; } /***************************************************************************** - Function: Q931Umes_Connect + Function: Q931Umes_Connect *****************************************************************************/ L3INT Q931Umes_Connect(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; - while(IOff < Size) - { - switch(IBuf[IOff]) - { + while (IOff < Size) { + switch (IBuf[IOff]) { case Q931ie_BEARER_CAPABILITY: case Q931ie_CHANNEL_IDENTIFICATION: case Q931ie_PROGRESS_INDICATOR: @@ -291,7 +290,7 @@ L3INT Q931Umes_Connect(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic case Q931ie_HIGH_LAYER_COMPATIBILITY: case Q931ie_CONNECTED_NUMBER: /* not actually used, seen while testing BRI PTMP TE */ rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; @@ -304,89 +303,91 @@ L3INT Q931Umes_Connect(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic } mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_Connect + Function: Q931Pmes_Connect *****************************************************************************/ L3INT Q931Pmes_Connect(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3INT rc = Q931E_NO_ERROR; Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; L3INT Octet = 0; /* Q931 Message Header */ Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); /* Bearer capability */ - if(Q931IsIEPresent(pMes->BearerCap)) - { - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->BearerCap)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet)) != 0) return rc; } /* Channel Identification */ - if(Q931IsIEPresent(pMes->ChanID)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->ChanID)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) return rc; - + } + /* Progress indicator */ - if(Q931IsIEPresent(pMes->ProgInd)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->ProgInd)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Display */ - if(Q931IsIEPresent(pMes->Display)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Display)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Date/Time */ - if(Q931IsIEPresent(pMes->DateTime)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DATETIME](pTrunk, Q931GetIEPtr(pMes->DateTime,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->DateTime)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DATETIME](pTrunk, Q931GetIEPtr(pMes->DateTime,pMes->buf), OBuf, &Octet)) != 0) return rc; - + } + /* Signal */ - if(Q931IsIEPresent(pMes->Signal)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Signal)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Low Layer Compatibility */ - if(Q931IsIEPresent(pMes->LLComp)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_LOW_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->LLComp,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->LLComp)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_LOW_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->LLComp,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* High Layer Compatibility */ - if(Q931IsIEPresent(pMes->HLComp)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->HLComp)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet)) != 0) return rc; + } *OSize = Octet; - - return rc; + return rc; } /***************************************************************************** - Function: Q931Umes_ConnectAck + Function: Q931Umes_ConnectAck *****************************************************************************/ L3INT Q931Umes_ConnectAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; - while(IOff < Size) - { - switch(IBuf[IOff]) - { + while (IOff < Size) { + switch (IBuf[IOff]) { case Q931ie_DISPLAY: case Q931ie_SIGNAL: rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; default: @@ -394,131 +395,61 @@ L3INT Q931Umes_ConnectAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Gener break; } } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_ConnectAck + Function: Q931Pmes_ConnectAck *****************************************************************************/ L3INT Q931Pmes_ConnectAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3INT rc = Q931E_NO_ERROR; Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; L3INT Octet = 0; /* Q931 Message Header */ Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); /* Display */ - if(Q931IsIEPresent(pMes->Display)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Display)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Signal */ - if(Q931IsIEPresent(pMes->Signal)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Signal)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet)) != 0) return rc; + } *OSize = Octet; - - return rc; + return rc; } /***************************************************************************** - Function: Q931Umes_Disconnect + Function: Q931Umes_Disconnect *****************************************************************************/ L3INT Q931Umes_Disconnect(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; - while(IOff < Size) - { - switch(IBuf[IOff]) - { + while (IOff < Size) { + switch (IBuf[IOff]) { case Q931ie_CAUSE: case Q931ie_PROGRESS_INDICATOR: case Q931ie_DISPLAY: case Q931ie_SIGNAL: case Q931ie_FACILITY: rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_Disconnect - -*****************************************************************************/ -L3INT Q931Pmes_Disconnect(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - L3INT rc = Q931E_NO_ERROR; - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Cause */ - if(Q931IsIEPresent(pMes->Cause)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CAUSE](pTrunk, Q931GetIEPtr(pMes->Cause,pMes->buf), OBuf, &Octet))!=0) - return rc; - - /* Progress indicator */ - if(Q931IsIEPresent(pMes->ProgInd)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet))!=0) - return rc; - - /* Display */ - if(Q931IsIEPresent(pMes->Display)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) - return rc; - - /* Signal */ - if(Q931IsIEPresent(pMes->Signal)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet))!=0) - return rc; - - *OSize = Octet; - - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_Information - -*****************************************************************************/ -L3INT Q931Umes_Information(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; - - while(IOff < Size) - { - switch(IBuf[IOff]) - { - case Q931ie_SENDING_COMPLETE: - case Q931ie_DISPLAY: - case Q931ie_KEYPAD_FACILITY: - case Q931ie_CALLED_PARTY_NUMBER: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; default: @@ -528,132 +459,203 @@ L3INT Q931Umes_Information(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Gene } mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_Information + Function: Q931Pmes_Disconnect + +*****************************************************************************/ +L3INT Q931Pmes_Disconnect(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) +{ + Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; + L3INT Octet = 0; + + /* Q931 Message Header */ + Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); + + /* Cause */ + if (Q931IsIEPresent(pMes->Cause)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CAUSE](pTrunk, Q931GetIEPtr(pMes->Cause,pMes->buf), OBuf, &Octet)) != 0) + return rc; + } + + /* Progress indicator */ + if (Q931IsIEPresent(pMes->ProgInd)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet)) != 0) + return rc; + } + + /* Display */ + if (Q931IsIEPresent(pMes->Display)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) + return rc; + } + + /* Signal */ + if (Q931IsIEPresent(pMes->Signal)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet)) != 0) + return rc; + } + + *OSize = Octet; + return rc; +} + +/***************************************************************************** + + Function: Q931Umes_Information + +*****************************************************************************/ +L3INT Q931Umes_Information(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) +{ + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; + + while (IOff < Size) { + switch (IBuf[IOff]) { + case Q931ie_SENDING_COMPLETE: + case Q931ie_DISPLAY: + case Q931ie_KEYPAD_FACILITY: + case Q931ie_CALLED_PARTY_NUMBER: + rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); + if (rc != Q931E_NO_ERROR) + return rc; + break; + default: + return Q931E_ILLEGAL_IE; + break; + } + } + + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; +} + +/***************************************************************************** + + Function: Q931Pmes_Information *****************************************************************************/ L3INT Q931Pmes_Information(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3INT rc = Q931E_NO_ERROR; Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; L3INT Octet = 0; /* Q931 Message Header */ Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - /* Sending Complete */ - if(Q931IsIEPresent(pMes->SendComplete)) + /* Sending Complete */ + if (Q931IsIEPresent(pMes->SendComplete)) { OBuf[Octet++] = (L3UCHAR)(pMes->SendComplete & 0x00ff); + } /* Display */ - if(Q931IsIEPresent(pMes->Display)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Display)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Keypad Facility */ - if(Q931IsIEPresent(pMes->KeypadFac)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_KEYPAD_FACILITY](pTrunk, Q931GetIEPtr(pMes->KeypadFac,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->KeypadFac)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_KEYPAD_FACILITY](pTrunk, Q931GetIEPtr(pMes->KeypadFac,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Signal */ - if(Q931IsIEPresent(pMes->Signal)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Signal)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Called Party number */ - if(Q931IsIEPresent(pMes->CalledNum)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CalledNum,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->CalledNum)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CalledNum,pMes->buf), OBuf, &Octet)) != 0) return rc; + } *OSize = Octet; - - return rc; + return rc; } /***************************************************************************** - Function: Q931Umes_Notify + Function: Q931Umes_Notify *****************************************************************************/ L3INT Q931Umes_Notify(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; - while(IOff < Size) - { - switch(IBuf[IOff]) - { + while (IOff < Size) { + switch (IBuf[IOff]) { case Q931ie_BEARER_CAPABILITY: case Q931ie_NOTIFICATION_INDICATOR: case Q931ie_DISPLAY: rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; } } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_Notify + Function: Q931Pmes_Notify *****************************************************************************/ L3INT Q931Pmes_Notify(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3INT rc = Q931E_NO_ERROR; Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; L3INT Octet = 0; /* Q931 Message Header */ Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); /* Bearer capability */ - if(Q931IsIEPresent(pMes->BearerCap)) - { - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->BearerCap)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet)) != 0) return rc; } /* Display */ - if(Q931IsIEPresent(pMes->Display)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Display)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) return rc; + } *OSize = Octet; - - return rc; + return rc; } /***************************************************************************** - Function: Q931Umes_Progress + Function: Q931Umes_Progress *****************************************************************************/ L3INT Q931Umes_Progress(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; - while(IOff < Size) - { - switch(IBuf[IOff]) - { + while (IOff < Size) { + switch (IBuf[IOff]) { case Q931ie_BEARER_CAPABILITY: case Q931ie_CAUSE: case Q931ie_PROGRESS_INDICATOR: case Q931ie_DISPLAY: case Q931ie_HIGH_LAYER_COMPATIBILITY: rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; default: @@ -661,72 +663,76 @@ L3INT Q931Umes_Progress(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic break; } } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_Progress + Function: Q931Pmes_Progress *****************************************************************************/ L3INT Q931Pmes_Progress(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3INT rc = Q931E_NO_ERROR; Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; L3INT Octet = 0; /* Q931 Message Header */ Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); /* Bearer capability */ - if(Q931IsIEPresent(pMes->BearerCap)) - { - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->BearerCap)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet)) != 0) return rc; } /* Cause */ - if(Q931IsIEPresent(pMes->Cause)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CAUSE](pTrunk, Q931GetIEPtr(pMes->Cause,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Cause)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CAUSE](pTrunk, Q931GetIEPtr(pMes->Cause,pMes->buf), OBuf, &Octet)) != 0) return rc; + } + /* Progress indicator */ - if(Q931IsIEPresent(pMes->ProgInd)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->ProgInd)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet)) != 0) return rc; + } + /* Display */ - if(Q931IsIEPresent(pMes->Display)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Display)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) return rc; + } + /* High Layer Compatibility */ - if(Q931IsIEPresent(pMes->HLComp)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->HLComp)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet)) != 0) return rc; + } *OSize = Octet; - - return rc; + return rc; } /***************************************************************************** - Function: Q931Umes_Release + Function: Q931Umes_Release *****************************************************************************/ L3INT Q931Umes_Release(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; - while(IOff < Size) - { - switch(IBuf[IOff]) - { + while (IOff < Size) { + switch (IBuf[IOff]) { case Q931ie_CAUSE: case Q931ie_DISPLAY: case Q931ie_SIGNAL: rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; default: @@ -734,61 +740,64 @@ L3INT Q931Umes_Release(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic break; } } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_Release + Function: Q931Pmes_Release *****************************************************************************/ L3INT Q931Pmes_Release(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3INT rc = Q931E_NO_ERROR; Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; L3INT Octet = 0; /* Q931 Message Header */ Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); /* Cause */ - if(Q931IsIEPresent(pMes->Cause)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CAUSE](pTrunk, Q931GetIEPtr(pMes->Cause,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Cause)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CAUSE](pTrunk, Q931GetIEPtr(pMes->Cause,pMes->buf), OBuf, &Octet)) != 0) return rc; + } + /* Display */ - if(Q931IsIEPresent(pMes->Display)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Display)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) return rc; + } + /* Signal */ - if(Q931IsIEPresent(pMes->Signal)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Signal)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet)) != 0) return rc; + } *OSize = Octet; - - return rc; + return rc; } /***************************************************************************** - Function: Q931Umes_ReleaseComplete + Function: Q931Umes_ReleaseComplete *****************************************************************************/ L3INT Q931Umes_ReleaseComplete(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; - while(IOff < Size) - { - switch(IBuf[IOff]) - { + while (IOff < Size) { + switch (IBuf[IOff]) { case Q931ie_CAUSE: case Q931ie_DISPLAY: case Q931ie_SIGNAL: rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; default: @@ -796,183 +805,130 @@ L3INT Q931Umes_ReleaseComplete(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_ break; } } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_ReleaseComplete + Function: Q931Pmes_ReleaseComplete *****************************************************************************/ L3INT Q931Pmes_ReleaseComplete(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3INT rc = Q931E_NO_ERROR; Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; L3INT Octet = 0; /* Q931 Message Header */ Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); /* Cause */ - if(Q931IsIEPresent(pMes->Cause)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CAUSE](pTrunk, Q931GetIEPtr(pMes->Cause,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Cause)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CAUSE](pTrunk, Q931GetIEPtr(pMes->Cause,pMes->buf), OBuf, &Octet)) != 0) return rc; + } + /* Display */ - if(Q931IsIEPresent(pMes->Display)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Display)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) return rc; + } + /* Signal */ - if(Q931IsIEPresent(pMes->Signal)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Signal)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet)) != 0) return rc; + } *OSize = Octet; - - return rc; + return rc; } /***************************************************************************** - Function: Q931Umes_Restart + Function: Q931Umes_Restart *****************************************************************************/ L3INT Q931Umes_Restart(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; - while(IOff < Size) - { - switch(IBuf[IOff]) - { - case Q931ie_CHANNEL_IDENTIFICATION: - case Q931ie_DISPLAY: - case Q931ie_RESTART_INDICATOR: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + while (IOff < Size) { + switch (IBuf[IOff]) { + case Q931ie_CHANNEL_IDENTIFICATION: + case Q931ie_DISPLAY: + case Q931ie_RESTART_INDICATOR: + rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); + if (rc != Q931E_NO_ERROR) + return rc; + break; + default: + return Q931E_ILLEGAL_IE; + break; + } + } + + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_Restart + Function: Q931Pmes_Restart *****************************************************************************/ L3INT Q931Pmes_Restart(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3INT rc = Q931E_NO_ERROR; Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; L3INT Octet = 0; /* Q931 Message Header */ Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); /* ChanID */ - if(Q931IsIEPresent(pMes->ChanID)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->ChanID)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) return rc; + } + /* Display */ - if(Q931IsIEPresent(pMes->Display)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Display)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) return rc; + } + /* RestartInd */ - if(Q931IsIEPresent(pMes->RestartInd)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_RESTART_INDICATOR](pTrunk, Q931GetIEPtr(pMes->RestartInd,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->RestartInd)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_RESTART_INDICATOR](pTrunk, Q931GetIEPtr(pMes->RestartInd,pMes->buf), OBuf, &Octet)) != 0) return rc; + } *OSize = Octet; - return rc; } /***************************************************************************** - Function: Q931Umes_RestartAck + Function: Q931Umes_RestartAck *****************************************************************************/ L3INT Q931Umes_RestartAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT IOff, L3INT Size) { - L3INT OOff=0; - Q931mes_Generic *mes = (Q931mes_Generic*)OBuf; - L3INT rc=Q931E_NO_ERROR; - while(IOff < Size) - { - switch(IBuf[IOff]) - { - case Q931ie_CHANNEL_IDENTIFICATION: - case Q931ie_DISPLAY: - case Q931ie_RESTART_INDICATOR: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} + Q931mes_Generic *mes = (Q931mes_Generic*)OBuf; + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; -/***************************************************************************** - - Function: Q931Pmes_RestartAck - -*****************************************************************************/ -L3INT Q931Pmes_RestartAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - L3INT rc = Q931E_NO_ERROR; - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* ChanID */ - if(Q931IsIEPresent(pMes->ChanID)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet))!=0) - return rc; - /* Display */ - if(Q931IsIEPresent(pMes->Display)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) - return rc; - /* RestartInd */ - if(Q931IsIEPresent(pMes->RestartInd)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_RESTART_INDICATOR](pTrunk, Q931GetIEPtr(pMes->RestartInd,pMes->buf), OBuf, &Octet))!=0) - return rc; - - *OSize = Octet; - - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_Resume - -*****************************************************************************/ -L3INT Q931Umes_Resume(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; - - while(IOff < Size) - { - switch(IBuf[IOff]) - { - case Q931ie_CALL_IDENTITY: + while (IOff < Size) { + switch (IBuf[IOff]) { + case Q931ie_CHANNEL_IDENTIFICATION: + case Q931ie_DISPLAY: + case Q931ie_RESTART_INDICATOR: rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; default: @@ -980,52 +936,114 @@ L3INT Q931Umes_Resume(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic * break; } } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_Resume + Function: Q931Pmes_RestartAck + +*****************************************************************************/ +L3INT Q931Pmes_RestartAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) +{ + Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; + L3INT Octet = 0; + + /* Q931 Message Header */ + Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); + + /* ChanID */ + if (Q931IsIEPresent(pMes->ChanID)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) + return rc; + } + + /* Display */ + if (Q931IsIEPresent(pMes->Display)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) + return rc; + } + + /* RestartInd */ + if (Q931IsIEPresent(pMes->RestartInd)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_RESTART_INDICATOR](pTrunk, Q931GetIEPtr(pMes->RestartInd,pMes->buf), OBuf, &Octet)) != 0) + return rc; + } + + *OSize = Octet; + return rc; +} + +/***************************************************************************** + + Function: Q931Umes_Resume + +*****************************************************************************/ +L3INT Q931Umes_Resume(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) +{ + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; + + while (IOff < Size) { + switch (IBuf[IOff]) { + case Q931ie_CALL_IDENTITY: + rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); + if (rc != Q931E_NO_ERROR) + return rc; + break; + default: + return Q931E_ILLEGAL_IE; + break; + } + } + + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; +} + +/***************************************************************************** + + Function: Q931Pmes_Resume *****************************************************************************/ L3INT Q931Pmes_Resume(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3INT rc = Q931E_NO_ERROR; Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; L3INT Octet = 0; /* Q931 Message Header */ Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); /* Call Identity */ - if(Q931IsIEPresent(pMes->CallID)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CALL_IDENTITY](pTrunk, Q931GetIEPtr(pMes->CallID,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->CallID)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALL_IDENTITY](pTrunk, Q931GetIEPtr(pMes->CallID,pMes->buf), OBuf, &Octet)) != 0) return rc; + } *OSize = Octet; - - return rc; + return rc; } /***************************************************************************** - Function: Q931Umes_ResumeAck + Function: Q931Umes_ResumeAck *****************************************************************************/ L3INT Q931Umes_ResumeAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; - while(IOff < Size) - { - switch(IBuf[IOff]) - { + while (IOff < Size) { + switch (IBuf[IOff]) { case Q931ie_CHANNEL_IDENTIFICATION: case Q931ie_DISPLAY: rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; default: @@ -1035,57 +1053,56 @@ L3INT Q931Umes_ResumeAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generi } mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_ResumeAck + Function: Q931Pmes_ResumeAck *****************************************************************************/ L3INT Q931Pmes_ResumeAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3INT rc = Q931E_NO_ERROR; Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; L3INT Octet = 0; /* Q931 Message Header */ Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); /* Channel Identification */ - if(Q931IsIEPresent(pMes->ChanID)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->ChanID)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) return rc; + } + /* Display */ - if(Q931IsIEPresent(pMes->Display)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Display)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) return rc; + } *OSize = Octet; - return rc; } /***************************************************************************** - Function: Q931Umes_ResumeReject + Function: Q931Umes_ResumeReject *****************************************************************************/ L3INT Q931Umes_ResumeReject(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; - while(IOff < Size) - { - switch(IBuf[IOff]) - { + while (IOff < Size) { + switch (IBuf[IOff]) { case Q931ie_CAUSE: case Q931ie_DISPLAY: rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; default: @@ -1095,37 +1112,37 @@ L3INT Q931Umes_ResumeReject(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Gen } mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_ResumeReject + Function: Q931Pmes_ResumeReject *****************************************************************************/ L3INT Q931Pmes_ResumeReject(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3INT rc = Q931E_NO_ERROR; Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; L3INT Octet = 0; /* Q931 Message Header */ Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - /* Cause */ - if(Q931IsIEPresent(pMes->Cause)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CAUSE](pTrunk, Q931GetIEPtr(pMes->Cause,pMes->buf), OBuf, &Octet))!=0) + /* Cause */ + if (Q931IsIEPresent(pMes->Cause)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CAUSE](pTrunk, Q931GetIEPtr(pMes->Cause,pMes->buf), OBuf, &Octet)) != 0) return rc; + } - /* Display */ - if(Q931IsIEPresent(pMes->Display)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) + /* Display */ + if (Q931IsIEPresent(pMes->Display)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) return rc; + } *OSize = Octet; - return rc; } @@ -1141,25 +1158,22 @@ L3INT Q931Pmes_Segment(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT IS L3BOOL RetCode = L3FALSE; *OSize = 0; - return RetCode; } /***************************************************************************** - Function: Q931Umes_Setup + Function: Q931Umes_Setup *****************************************************************************/ L3INT Q931Umes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT ir=0; - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; + L3INT ir = 0; + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; - while(IOff < Size) - { - switch(IBuf[IOff]) - { + while (IOff < Size) { + switch (IBuf[IOff]) { case Q931ie_SENDING_COMPLETE: IOff++; break; @@ -1181,12 +1195,12 @@ L3INT Q931Umes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *m case Q931ie_HIGH_LAYER_COMPATIBILITY: case Q931ie_FACILITY: rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; case Q931ie_REPEAT_INDICATOR: - if(ir < 2) { + if (ir < 2) { rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); ir++; } else { @@ -1201,13 +1215,12 @@ L3INT Q931Umes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *m } mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_Setup + Function: Q931Pmes_Setup Decription: Pack a Q931mes_Generic into a real Q.931 message. The user will set up a SETUP message and issue this to the stack where it @@ -1225,105 +1238,308 @@ L3INT Q931Umes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *m *****************************************************************************/ L3INT Q931Pmes_Setup(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3INT rc = Q931E_NO_ERROR; Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; L3INT Octet = 0; /* Q931 Message Header */ Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); /* Sending Complete */ - if(Q931IsIEPresent(pMes->SendComplete)) + if (Q931IsIEPresent(pMes->SendComplete)) { OBuf[Octet++] = (L3UCHAR)Q931ie_SENDING_COMPLETE & 0xff; + } /* Repeat Indicator */ - if(Q931IsIEPresent(pMes->RepeatInd)) + if (Q931IsIEPresent(pMes->RepeatInd)) { OBuf[Octet++] = (L3UCHAR)Q931ie_REPEAT_INDICATOR & 0xff; + } /* Bearer capability */ - if(Q931IsIEPresent(pMes->BearerCap)) - { - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->BearerCap)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet)) != 0) return rc; - } - else - { - rc=Q931E_BEARERCAP; + } else { + rc = Q931E_BEARERCAP; } /* Channel Identification */ - if(Q931IsIEPresent(pMes->ChanID)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->ChanID)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Progress indicator */ - if(Q931IsIEPresent(pMes->ProgInd)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->ProgInd)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Network spesific facilities */ - if(Q931IsIEPresent(pMes->NetFac)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_NETWORK_SPECIFIC_FACILITIES](pTrunk, Q931GetIEPtr(pMes->NetFac,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->NetFac)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_NETWORK_SPECIFIC_FACILITIES](pTrunk, Q931GetIEPtr(pMes->NetFac,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Display */ - if(Q931IsIEPresent(pMes->Display)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Display)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Date/Time */ - if(Q931IsIEPresent(pMes->DateTime)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DATETIME](pTrunk, Q931GetIEPtr(pMes->DateTime,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->DateTime)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DATETIME](pTrunk, Q931GetIEPtr(pMes->DateTime,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Keypad Facility */ - if(Q931IsIEPresent(pMes->KeypadFac)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_KEYPAD_FACILITY](pTrunk, Q931GetIEPtr(pMes->KeypadFac,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->KeypadFac)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_KEYPAD_FACILITY](pTrunk, Q931GetIEPtr(pMes->KeypadFac,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Signal */ - if(Q931IsIEPresent(pMes->Signal)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Signal)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Calling Party Number */ - if(Q931IsIEPresent(pMes->CallingNum)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CallingNum,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->CallingNum)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CallingNum,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Calling Party Subaddress */ - if(Q931IsIEPresent(pMes->CallingSub)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CallingSub,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->CallingSub)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CallingSub,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Called Party number */ - if(Q931IsIEPresent(pMes->CalledNum)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CalledNum,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->CalledNum)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CalledNum,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Called party subaddress */ - if(Q931IsIEPresent(pMes->CalledSub)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CalledSub,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->CalledSub)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CalledSub,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Transit network selection */ - if(Q931IsIEPresent(pMes->TransNetSel)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_TRANSIT_NETWORK_SELECTION](pTrunk, Q931GetIEPtr(pMes->TransNetSel,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->TransNetSel)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_TRANSIT_NETWORK_SELECTION](pTrunk, Q931GetIEPtr(pMes->TransNetSel,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Repeat Indicator */ - if(Q931IsIEPresent(pMes->LLRepeatInd)) + if (Q931IsIEPresent(pMes->LLRepeatInd)) { rc = Q931E_UNKNOWN_IE;/* TODO */ + } /* Low Layer Compatibility */ - if(Q931IsIEPresent(pMes->LLComp)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_LOW_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->LLComp,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->LLComp)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_LOW_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->LLComp,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* High Layer Compatibility */ - if(Q931IsIEPresent(pMes->HLComp)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->HLComp)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet)) != 0) return rc; + } + + *OSize = Octet; + return rc; +} + +/***************************************************************************** + + Function: Q931Umes_SetupAck + +*****************************************************************************/ +L3INT Q931Umes_SetupAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) +{ + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; + + while (IOff < Size) { + switch (IBuf[IOff]) { + case Q931ie_CHANNEL_IDENTIFICATION: + case Q931ie_PROGRESS_INDICATOR: + case Q931ie_DISPLAY: + case Q931ie_SIGNAL: + rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); + if (rc != Q931E_NO_ERROR) + return rc; + break; + default: + return Q931E_ILLEGAL_IE; + break; + } + } + + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; +} + +/***************************************************************************** + + Function: Q931Pmes_SetupAck + +*****************************************************************************/ +L3INT Q931Pmes_SetupAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) +{ + Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; + L3INT Octet = 0; + + /* Q931 Message Header */ + Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); + + /* Channel Identification */ + if (Q931IsIEPresent(pMes->ChanID)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) + return rc; + } + + /* Progress indicator */ + if (Q931IsIEPresent(pMes->ProgInd)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet)) != 0) + return rc; + } + + /* Display */ + if (Q931IsIEPresent(pMes->Display)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) + return rc; + } + + /* Signal */ + if (Q931IsIEPresent(pMes->Signal)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet)) != 0) + return rc; + } + + *OSize = Octet; + return rc; +} + +/***************************************************************************** + + Function: Q931Umes_Status + +*****************************************************************************/ +L3INT Q931Umes_Status(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) +{ + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; + + while (IOff < Size) { + switch (IBuf[IOff]) { + case Q931ie_CAUSE: + case Q931ie_CALL_STATE: + case Q931ie_DISPLAY: + rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); + if (rc != Q931E_NO_ERROR) + return rc; + break; + default: + return Q931E_ILLEGAL_IE; + break; + } + } + + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; +} + + +/***************************************************************************** + + Function: Q931Pmes_Status + +*****************************************************************************/ +L3INT Q931Pmes_Status(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) +{ + Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; + L3INT Octet = 0; + + /* Q931 Message Header */ + Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); + + /* Cause */ + if (Q931IsIEPresent(pMes->Cause)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CAUSE](pTrunk, Q931GetIEPtr(pMes->Cause,pMes->buf), OBuf, &Octet)) != 0) + return rc; + } + + /* Call State */ + if (Q931IsIEPresent(pMes->CallState)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALL_STATE](pTrunk, Q931GetIEPtr(pMes->CallState,pMes->buf), OBuf, &Octet)) != 0) + return rc; + } + + /* Display */ + if (Q931IsIEPresent(pMes->Display)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) + return rc; + } + + *OSize = Octet; + return rc; +} + +/***************************************************************************** + + Function: Q931Umes_StatusEnquiry + +*****************************************************************************/ +L3INT Q931Umes_StatusEnquiry(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) +{ + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; + + while (IOff < Size) { + switch (IBuf[IOff]) { + case Q931ie_DISPLAY: + rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); + if (rc != Q931E_NO_ERROR) + return rc; + break; + default: + return Q931E_ILLEGAL_IE; + break; + } + } + + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; +} + +/***************************************************************************** + + Function: Q931Pmes_StatusEnquiry + +*****************************************************************************/ +L3INT Q931Pmes_StatusEnquiry(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) +{ + Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; + L3INT Octet = 0; + + /* Q931 Message Header */ + Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); + + /* Display */ + if (Q931IsIEPresent(pMes->Display)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) + return rc; + } *OSize = Octet; @@ -1332,24 +1548,19 @@ L3INT Q931Pmes_Setup(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISiz /***************************************************************************** - Function: Q931Umes_SetupAck + Function: Q931Umes_Suspend *****************************************************************************/ -L3INT Q931Umes_SetupAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) +L3INT Q931Umes_Suspend(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; - while(IOff < Size) - { - switch(IBuf[IOff]) - { - case Q931ie_CHANNEL_IDENTIFICATION: - case Q931ie_PROGRESS_INDICATOR: - case Q931ie_DISPLAY: - case Q931ie_SIGNAL: + while (IOff < Size) { + switch (IBuf[IOff]) { + case Q931ie_CALL_IDENTITY: rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; default: @@ -1357,234 +1568,50 @@ L3INT Q931Umes_SetupAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic break; } } + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_SetupAck - -*****************************************************************************/ -L3INT Q931Pmes_SetupAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - L3INT rc = Q931E_NO_ERROR; - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Channel Identification */ - if(Q931IsIEPresent(pMes->ChanID)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet))!=0) - return rc; - - /* Progress indicator */ - if(Q931IsIEPresent(pMes->ProgInd)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet))!=0) - return rc; - - /* Display */ - if(Q931IsIEPresent(pMes->Display)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) - return rc; - - /* Signal */ - if(Q931IsIEPresent(pMes->Signal)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet))!=0) - return rc; - - *OSize = Octet; - - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_Status - -*****************************************************************************/ -L3INT Q931Umes_Status(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; - - while(IOff < Size) - { - switch(IBuf[IOff]) - { - case Q931ie_CAUSE: - case Q931ie_CALL_STATE: - case Q931ie_DISPLAY: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - - -/***************************************************************************** - - Function: Q931Pmes_Status - -*****************************************************************************/ -L3INT Q931Pmes_Status(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - L3INT rc = Q931E_NO_ERROR; - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Cause */ - if(Q931IsIEPresent(pMes->Cause)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CAUSE](pTrunk, Q931GetIEPtr(pMes->Cause,pMes->buf), OBuf, &Octet))!=0) - return rc; - /* Call State */ - if(Q931IsIEPresent(pMes->CallState)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CALL_STATE](pTrunk, Q931GetIEPtr(pMes->CallState,pMes->buf), OBuf, &Octet))!=0) - return rc; - /* Display */ - if(Q931IsIEPresent(pMes->Display)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) - return rc; - - *OSize = Octet; - - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_StatusEnquiry - -*****************************************************************************/ -L3INT Q931Umes_StatusEnquiry(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; - - while(IOff < Size) - { - switch(IBuf[IOff]) - { - case Q931ie_DISPLAY: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_StatusEnquiry - -*****************************************************************************/ -L3INT Q931Pmes_StatusEnquiry(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) -{ - L3INT rc = Q931E_NO_ERROR; - Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; - L3INT Octet = 0; - - /* Q931 Message Header */ - Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Display */ - if(Q931IsIEPresent(pMes->Display)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) - return rc; - - *OSize = Octet; - - return rc; -} - -/***************************************************************************** - - Function: Q931Umes_Suspend - -*****************************************************************************/ -L3INT Q931Umes_Suspend(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) -{ - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; - - while(IOff < Size) - { - switch(IBuf[IOff]) - { - case Q931ie_CALL_IDENTITY: - rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) - return rc; - break; - default: - return Q931E_ILLEGAL_IE; - break; - } - } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: Q931Pmes_Suspend + Function: Q931Pmes_Suspend *****************************************************************************/ L3INT Q931Pmes_Suspend(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3INT rc = Q931E_NO_ERROR; Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; L3INT Octet = 0; /* Q931 Message Header */ Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); /* Call Identity */ - if(Q931IsIEPresent(pMes->CallID)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CALL_IDENTITY](pTrunk, Q931GetIEPtr(pMes->CallID,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->CallID)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALL_IDENTITY](pTrunk, Q931GetIEPtr(pMes->CallID,pMes->buf), OBuf, &Octet)) != 0) return rc; + } *OSize = Octet; - - return rc; + return rc; } /***************************************************************************** - Function: Q931Umes_SuspendAck + Function: Q931Umes_SuspendAck *****************************************************************************/ L3INT Q931Umes_SuspendAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; - while(IOff < Size) - - { - switch(IBuf[IOff]) - { + while (IOff < Size) { + switch (IBuf[IOff]) { case Q931ie_DISPLAY: rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; default: @@ -1592,52 +1619,51 @@ L3INT Q931Umes_SuspendAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Gener break; } } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_SuspendAck + Function: Q931Pmes_SuspendAck *****************************************************************************/ L3INT Q931Pmes_SuspendAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3INT rc = Q931E_NO_ERROR; Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; L3INT Octet = 0; /* Q931 Message Header */ Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); /* Display */ - if(Q931IsIEPresent(pMes->Display)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Display)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) return rc; + } *OSize = Octet; - - return rc; + return rc; } /***************************************************************************** - Function: Q931Umes_SuspendReject + Function: Q931Umes_SuspendReject *****************************************************************************/ L3INT Q931Umes_SuspendReject(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; - while(IOff < Size) - { - switch(IBuf[IOff]) - { + while (IOff < Size) { + switch (IBuf[IOff]) { case Q931ie_CAUSE: case Q931ie_DISPLAY: rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; default: @@ -1645,93 +1671,93 @@ L3INT Q931Umes_SuspendReject(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Ge break; } } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_SuspendReject + Function: Q931Pmes_SuspendReject *****************************************************************************/ L3INT Q931Pmes_SuspendReject(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3INT rc = Q931E_NO_ERROR; Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; L3INT Octet = 0; /* Q931 Message Header */ Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); /* Cause */ - if(Q931IsIEPresent(pMes->Cause)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CAUSE](pTrunk, Q931GetIEPtr(pMes->Cause,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Cause)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CAUSE](pTrunk, Q931GetIEPtr(pMes->Cause,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Display */ - if(Q931IsIEPresent(pMes->Display)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Display)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) return rc; + } *OSize = Octet; - - return rc; + return rc; } /***************************************************************************** - Function: Q931Umes_UserInformation + Function: Q931Umes_UserInformation *****************************************************************************/ L3INT Q931Umes_UserInformation(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT I, L3INT O) { - L3BOOL RetCode = L3FALSE; + L3BOOL RetCode = L3FALSE; - NoWarning(mes); - NoWarning(IBuf); + NoWarning(mes); + NoWarning(IBuf); - return RetCode; + return RetCode; } /***************************************************************************** - Function: Q931Pmes_UserInformation + Function: Q931Pmes_UserInformation *****************************************************************************/ L3INT Q931Pmes_UserInformation(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3BOOL RetCode = L3FALSE; + L3BOOL RetCode = L3FALSE; - NoWarning(OBuf); - NoWarning(IBuf); + NoWarning(OBuf); + NoWarning(IBuf); *OSize = 0; - return RetCode; + return RetCode; } /***************************************************************************** - Function: Q931Umes_Service + Function: Q931Umes_Service *****************************************************************************/ L3INT Q931Umes_Service(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; - while(IOff < Size) - { - switch(IBuf[IOff]) - { + while (IOff < Size) { + switch (IBuf[IOff]) { case Q931ie_CHANNEL_IDENTIFICATION: rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; case Q931ie_CHANGE_STATUS: rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; default: @@ -1739,60 +1765,60 @@ L3INT Q931Umes_Service(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic break; } } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_Service + Function: Q931Pmes_Service *****************************************************************************/ L3INT Q931Pmes_Service(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3INT rc = Q931E_NO_ERROR; Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; L3INT Octet = 0; /* Q931 Message Header */ Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); /* Display */ - if(Q931IsIEPresent(pMes->ChanID)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->ChanID)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) return rc; + } - if(Q931IsIEPresent(pMes->ChangeStatus)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CHANGE_STATUS](pTrunk, Q931GetIEPtr(pMes->ChangeStatus,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->ChangeStatus)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANGE_STATUS](pTrunk, Q931GetIEPtr(pMes->ChangeStatus,pMes->buf), OBuf, &Octet)) != 0) return rc; + } *OSize = Octet; - - return rc; + return rc; } /***************************************************************************** - Function: Q931Umes_ServiceAck + Function: Q931Umes_ServiceAck *****************************************************************************/ L3INT Q931Umes_ServiceAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; - while(IOff < Size) - { - switch(IBuf[IOff]) - { + while (IOff < Size) { + switch (IBuf[IOff]) { case Q931ie_CHANNEL_IDENTIFICATION: rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; case Q931ie_CHANGE_STATUS: rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; default: @@ -1800,34 +1826,35 @@ L3INT Q931Umes_ServiceAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Gener break; } } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_ServiceAck + Function: Q931Pmes_ServiceAck *****************************************************************************/ L3INT Q931Pmes_ServiceAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3INT rc = Q931E_NO_ERROR; Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; + L3INT rc = Q931E_NO_ERROR; L3INT Octet = 0; /* Q931 Message Header */ Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - if(Q931IsIEPresent(pMes->ChangeStatus)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CHANGE_STATUS](pTrunk, Q931GetIEPtr(pMes->ChangeStatus,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->ChangeStatus)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANGE_STATUS](pTrunk, Q931GetIEPtr(pMes->ChangeStatus,pMes->buf), OBuf, &Octet)) != 0) return rc; + } - if(Q931IsIEPresent(pMes->ChanID)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->ChanID)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) return rc; - + } *OSize = Octet; - - return rc; + return rc; } diff --git a/libs/freetdm/src/isdn/Q932mes.c b/libs/freetdm/src/isdn/Q932mes.c index 8e011deb31..574499a241 100644 --- a/libs/freetdm/src/isdn/Q932mes.c +++ b/libs/freetdm/src/isdn/Q932mes.c @@ -13,12 +13,12 @@ modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of the Case Labs, Ltd nor the names of its contributors + * Neither the name of the Case Labs, Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -39,248 +39,248 @@ /***************************************************************************** - Function: Q932Umes_Facility + Function: Q932Umes_Facility *****************************************************************************/ L3INT Q932Umes_Facility(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; + L3INT OOff = 0; /* TODO */ - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_Facility + Function: Q931Pmes_Facility *****************************************************************************/ L3INT Q932Pmes_Facility(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3BOOL RetCode = L3FALSE; + L3BOOL RetCode = L3FALSE; - NoWarning(OBuf); - NoWarning(IBuf); + NoWarning(OBuf); + NoWarning(IBuf); - return RetCode; + return RetCode; } /***************************************************************************** - Function: Q932Umes_Hold + Function: Q932Umes_Hold *****************************************************************************/ L3INT Q932Umes_Hold(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; + L3INT OOff = 0; /* TODO */ - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_Hold + Function: Q931Pmes_Hold *****************************************************************************/ L3INT Q932Pmes_Hold(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3BOOL RetCode = L3FALSE; + L3BOOL RetCode = L3FALSE; - NoWarning(OBuf); - NoWarning(IBuf); + NoWarning(OBuf); + NoWarning(IBuf); - return RetCode; + return RetCode; } /***************************************************************************** - Function: Q932Umes_HoldAck + Function: Q932Umes_HoldAck *****************************************************************************/ L3INT Q932Umes_HoldAck(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; + L3INT OOff = 0; /* TODO */ - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_HoldAck + Function: Q931Pmes_HoldAck *****************************************************************************/ L3INT Q932Pmes_HoldAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3BOOL RetCode = L3FALSE; + L3BOOL RetCode = L3FALSE; - NoWarning(OBuf); - NoWarning(IBuf); + NoWarning(OBuf); + NoWarning(IBuf); - return RetCode; + return RetCode; } /***************************************************************************** - Function: Q932Umes_HoldReject + Function: Q932Umes_HoldReject *****************************************************************************/ L3INT Q932Umes_HoldReject(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; + L3INT OOff = 0; /* TODO */ - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_HoldReject + Function: Q931Pmes_HoldReject *****************************************************************************/ L3INT Q932Pmes_HoldReject(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3BOOL RetCode = L3FALSE; + L3BOOL RetCode = L3FALSE; - NoWarning(OBuf); - NoWarning(IBuf); + NoWarning(OBuf); + NoWarning(IBuf); - return RetCode; + return RetCode; } /***************************************************************************** - Function: Q932Umes_Register + Function: Q932Umes_Register *****************************************************************************/ L3INT Q932Umes_Register(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; + L3INT OOff = 0; /* TODO */ - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_Register + Function: Q931Pmes_Register *****************************************************************************/ L3INT Q932Pmes_Register(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3BOOL RetCode = L3FALSE; + L3BOOL RetCode = L3FALSE; - NoWarning(OBuf); - NoWarning(IBuf); + NoWarning(OBuf); + NoWarning(IBuf); - return RetCode; + return RetCode; } /***************************************************************************** - Function: Q932Umes_Retrieve + Function: Q932Umes_Retrieve *****************************************************************************/ L3INT Q932Umes_Retrieve(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; + L3INT OOff = 0; /* TODO */ - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_Retrieve + Function: Q931Pmes_Retrieve *****************************************************************************/ L3INT Q932Pmes_Retrieve(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3BOOL RetCode = L3FALSE; + L3BOOL RetCode = L3FALSE; - NoWarning(OBuf); - NoWarning(IBuf); + NoWarning(OBuf); + NoWarning(IBuf); - return RetCode; + return RetCode; } /***************************************************************************** - Function: Q932Umes_RetrieveAck + Function: Q932Umes_RetrieveAck *****************************************************************************/ L3INT Q932Umes_RetrieveAck(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; + L3INT OOff = 0; /* TODO */ - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_RetrieveAck + Function: Q931Pmes_RetrieveAck *****************************************************************************/ L3INT Q932Pmes_RetrieveAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3BOOL RetCode = L3FALSE; + L3BOOL RetCode = L3FALSE; - NoWarning(OBuf); - NoWarning(IBuf); + NoWarning(OBuf); + NoWarning(IBuf); - return RetCode; + return RetCode; } /***************************************************************************** - Function: Q932Umes_RetrieveReject + Function: Q932Umes_RetrieveReject *****************************************************************************/ L3INT Q932Umes_RetrieveReject(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT OOff=0; + L3INT OOff = 0; /* TODO */ - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: Q931Pmes_RetrieveReject + Function: Q931Pmes_RetrieveReject *****************************************************************************/ L3INT Q932Pmes_RetrieveReject(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3BOOL RetCode = L3FALSE; + L3BOOL RetCode = L3FALSE; - NoWarning(OBuf); - NoWarning(IBuf); + NoWarning(OBuf); + NoWarning(IBuf); - return RetCode; + return RetCode; } diff --git a/libs/freetdm/src/isdn/include/DMS.h b/libs/freetdm/src/isdn/include/DMS.h index 35d10d7b5b..605a61aa6e 100644 --- a/libs/freetdm/src/isdn/include/DMS.h +++ b/libs/freetdm/src/isdn/include/DMS.h @@ -4,18 +4,17 @@ Contents: Header and definition for the National ISDN dialect. The header contents the following parts: - - - Definition of codes + - Definition of codes - Definition of information elements (nationalie_). - Definition of messages (nationalmes_). - - Function prototypes. + - Function prototypes. Description: The National ISDN dialect here covers ???? - Related Files: national.h National ISDN Definitions - nationalie.c National ISDN IE encoders/coders - nationalStateTE.c National ISDN TE State Engine - nationalStateNT.c National ISDN NT State Engine + Related Files: national.h National ISDN Definitions + nationalie.c National ISDN IE encoders/coders + nationalStateTE.c National ISDN TE State Engine + nationalStateNT.c National ISDN NT State Engine License/Copyright: @@ -77,8 +76,6 @@ L3INT DMSPmes_0x07(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3INT DMSUmes_0x0f(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size); L3INT DMSPmes_0x0f(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize); - - /***************************************************************************** Q.931 Process Function Prototyping. Implemented in nationalStateTE.c @@ -88,7 +85,6 @@ L3INT DMSPmes_0x0f(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3INT DMSProc0x0fTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom); L3INT DMSProc0x07TE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom); - void DMSCreateTE(L3UCHAR i); void DMSCreateNT(L3UCHAR i); diff --git a/libs/freetdm/src/isdn/include/Q931.h b/libs/freetdm/src/isdn/include/Q931.h index 2687930485..8673b71fe8 100644 --- a/libs/freetdm/src/isdn/include/Q931.h +++ b/libs/freetdm/src/isdn/include/Q931.h @@ -157,7 +157,6 @@ *****************************************************************************/ typedef enum { - Q931E_NO_ERROR = 0, Q931E_UNKNOWN_MESSAGE = -3001, @@ -190,7 +189,6 @@ typedef enum { Q931E_SEGMENT = -3028, Q931E_SIGNAL = -3029, Q931E_GENERIC_DIGITS = -3030 - } q931_error_t; /* The q931_error_t enum should be kept in sync with the q931_error_names array in Q931.c */ @@ -563,61 +561,61 @@ typedef struct *****************************************************************************/ typedef struct { - L3UINT Size; /* Size of message in bytes */ - L3UCHAR ProtDisc; /* Protocol Discriminator */ - L3UCHAR MesType; /* Message type */ - L3UCHAR CRVFlag; /* Call reference value flag */ - L3INT CRV; /* Call reference value */ + L3UINT Size; /* Size of message in bytes */ + L3UCHAR ProtDisc; /* Protocol Discriminator */ + L3UCHAR MesType; /* Message type */ + L3UCHAR CRVFlag; /* Call reference value flag */ + L3INT CRV; /* Call reference value */ - ie Shift; - ie MoreData; - ie SendComplete; - ie CongestionLevel; - ie RepeatInd; + ie Shift; + ie MoreData; + ie SendComplete; + ie CongestionLevel; + ie RepeatInd; - ie Segment; /* Segmented message */ - ie BearerCap; /* Bearer Capability */ - ie Cause; /* Cause */ - ie CallState; /* Call State */ - ie CallID; /* Call Identity */ - ie ChanID; /* Channel Identification */ - ie ChangeStatus; /* Change Staus */ - ie ProgInd; /* Progress Indicator */ - ie NetFac; /* Network Spesific Facilities */ - ie NotifInd; /* Notification Indicator */ - ie Display; /* Display */ - ie DateTime; /* Date/Time */ - ie KeypadFac; /* Keypad Facility */ - ie Signal; /* Signal */ - ie InfoRate; /* Information rate */ - ie EndEndTxDelay; /* End to End Transmit Delay */ - ie TransDelSelInd; /* Transmit Delay Sel. and Ind. */ - ie PackParam; /* Packed Layer Binary parameters */ - ie PackWinSize; /* Packet Layer Window Size */ - ie PackSize; /* Packed Size */ - ie ClosedUserGrp; /* Closed User Group */ - ie RevChargeInd; /* Reverse Charging Indicator */ - ie CalledNum; /* Called Party Number */ - ie CalledSub; /* Called Party subaddress */ - ie CallingNum; /* Calling Party Number */ - ie CallingSub; /* Calling Party Subaddress */ - ie RedirNum; /* Redirection Number */ - ie TransNetSel; /* Transmit Network Selection */ - ie LLRepeatInd; /* Repeat Indicator 2 LLComp */ - ie RestartWin; /* Restart Window */ - ie RestartInd; /* Restart Indicator */ - ie LLComp; /* Low Layer Compatibility */ - ie HLComp; /* High Layer Compatibility */ - ie UserUser; /* User-user */ - ie Escape; /* Escape for extension */ - ie Switchhook; - ie FeatAct; - ie FeatInd; - ie GenericDigits; + ie Segment; /* Segmented message */ + ie BearerCap; /* Bearer Capability */ + ie Cause; /* Cause */ + ie CallState; /* Call State */ + ie CallID; /* Call Identity */ + ie ChanID; /* Channel Identification */ + ie ChangeStatus; /* Change Staus */ + ie ProgInd; /* Progress Indicator */ + ie NetFac; /* Network Spesific Facilities */ + ie NotifInd; /* Notification Indicator */ + ie Display; /* Display */ + ie DateTime; /* Date/Time */ + ie KeypadFac; /* Keypad Facility */ + ie Signal; /* Signal */ + ie InfoRate; /* Information rate */ + ie EndEndTxDelay; /* End to End Transmit Delay */ + ie TransDelSelInd; /* Transmit Delay Sel. and Ind. */ + ie PackParam; /* Packed Layer Binary parameters */ + ie PackWinSize; /* Packet Layer Window Size */ + ie PackSize; /* Packed Size */ + ie ClosedUserGrp; /* Closed User Group */ + ie RevChargeInd; /* Reverse Charging Indicator */ + ie CalledNum; /* Called Party Number */ + ie CalledSub; /* Called Party subaddress */ + ie CallingNum; /* Calling Party Number */ + ie CallingSub; /* Calling Party Subaddress */ + ie RedirNum; /* Redirection Number */ + ie TransNetSel; /* Transmit Network Selection */ + ie LLRepeatInd; /* Repeat Indicator 2 LLComp */ + ie RestartWin; /* Restart Window */ + ie RestartInd; /* Restart Indicator */ + ie LLComp; /* Low Layer Compatibility */ + ie HLComp; /* High Layer Compatibility */ + ie UserUser; /* User-user */ + ie Escape; /* Escape for extension */ + ie Switchhook; + ie FeatAct; + ie FeatInd; + ie GenericDigits; - L3UCHAR buf[1]; /* Buffer for IE's */ + L3UCHAR buf[1]; /* Buffer for IE's */ -}Q931mes_Generic; +} Q931mes_Generic; /***************************************************************************** @@ -723,19 +721,19 @@ struct Q931_Call struct Q931_TrunkInfo { - Q931NetUser_t NetUser; /* Network/User Mode. */ + Q931NetUser_t NetUser; /* Network/User Mode. */ Q931_TrunkType_t TrunkType; /* Trunk Line Type. */ - Q931Dialect_t Dialect; /* Q.931 Based dialect index. */ + Q931Dialect_t Dialect; /* Q.931 Based dialect index. */ - Q931Tx34CB_t Q931Tx34CBProc; - Q931Tx32CB_t Q931Tx32CBProc; - Q931ErrorCB_t Q931ErrorCBProc; - Q931LogCB_t Q931LogCBProc; + Q931Tx34CB_t Q931Tx34CBProc; + Q931Tx32CB_t Q931Tx32CBProc; + Q931ErrorCB_t Q931ErrorCBProc; + Q931LogCB_t Q931LogCBProc; void *PrivateData32; void *PrivateData34; void *PrivateDataLog; - Q931LogLevel_t loglevel; + Q931LogLevel_t loglevel; L3UCHAR Enabled; /* Enabled/Disabled */ /* 0 = Disabled */ @@ -779,7 +777,7 @@ struct Q931_TrunkInfo L3INT CRV; /* Associated CRV */ - }ch[Q931MAXCHPERTRUNK]; + } ch[Q931MAXCHPERTRUNK]; /* Active Call information indentified by CRV. See Q931AllocateCRV for */ /* initialization of call table. */ @@ -802,7 +800,7 @@ typedef struct L3INT State; L3INT Message; L3UCHAR Direction; -}Q931State; +} Q931State; /***************************************************************************** @@ -844,7 +842,7 @@ extern q931timer_t Q931Timer[Q931MAXDLCT][Q931MAXTIMER]; size of 'header'. *****************************************************************************/ -#define Q931GetIETotSize(ie) (((ie.InfoID & 0x80) !=0) ? 1:ie.LenIE)+2) +#define Q931GetIETotSize(ie) (((ie.InfoID & 0x80) != 0) ? 1 : ie.LenIE) + 2) /***************************************************************************** @@ -855,7 +853,7 @@ extern q931timer_t Q931Timer[Q931MAXDLCT][Q931MAXTIMER]; Description: Return TRUE if the Information Element is included. *****************************************************************************/ -#define Q931IsIEPresent(x) ((x & 0x8000) != 0) +#define Q931IsIEPresent(x) ((x & 0x8000) != 0) /***************************************************************************** @@ -872,7 +870,7 @@ extern q931timer_t Q931Timer[Q931MAXDLCT][Q931MAXTIMER]; *****************************************************************************/ #define Q931GetIEOffset(x) (x & 0x7fff) -#define Q931GetIEValue(x) (x & 0x7fff) +#define Q931GetIEValue(x) (x & 0x7fff) /***************************************************************************** @@ -894,7 +892,7 @@ extern q931timer_t Q931Timer[Q931MAXDLCT][Q931MAXTIMER]; Description: Set an information element. *****************************************************************************/ -#define Q931SetIE(x,o) {x = (ie)(o) | 0x8000;} +#define Q931SetIE(x,o) { x = (ie)(o) | 0x8000; } /***************************************************************************** @@ -906,7 +904,7 @@ extern q931timer_t Q931Timer[Q931MAXDLCT][Q931MAXTIMER]; that the octet is extended. *****************************************************************************/ -#define IsQ931Ext(x) ((x&0x80)==0) +#define IsQ931Ext(x) ((x & 0x80) == 0) /***************************************************************************** @@ -933,7 +931,7 @@ extern q931timer_t Q931Timer[Q931MAXDLCT][Q931MAXTIMER]; warning for the initial empty functions. *****************************************************************************/ -#define NoWarning(x) (x=x) +#define NoWarning(x) (x = x) /***************************************************************************** diff --git a/libs/freetdm/src/isdn/include/Q931ie.h b/libs/freetdm/src/isdn/include/Q931ie.h index 2acb937702..65dba4e261 100644 --- a/libs/freetdm/src/isdn/include/Q931ie.h +++ b/libs/freetdm/src/isdn/include/Q931ie.h @@ -54,7 +54,7 @@ typedef enum { } q931_codeset_t; -/* Single octet information elements */ +/* Single octet information elements */ #define Q931ie_SHIFT 0x90 /* 1001 ---- */ #define Q931ie_MORE_DATA 0xa0 /* 1010 ---- */ #define Q931ie_SENDING_COMPLETE 0xa1 /* 1010 0001 */ @@ -98,12 +98,11 @@ typedef enum { #define Q931ie_ESCAPE_FOR_EX 0x7f /* 0111 1111 */ /* Variable Length Codeset 6 Information Elements */ - -#define Q931ie_GENERIC_DIGITS 0x37 /* 0011 0111 */ +#define Q931ie_GENERIC_DIGITS 0x37 /* 0011 0111 */ /* Variable Length Information Element to shut up BRI testing */ -#define Q931ie_CONNECTED_NUMBER 0x4c /* 0100 1101 */ -#define Q931ie_FACILITY 0x1c /* 0001 1101 */ +#define Q931ie_CONNECTED_NUMBER 0x4c /* 0100 1101 */ +#define Q931ie_FACILITY 0x1c /* 0001 1101 */ /***************************************************************************** @@ -114,10 +113,9 @@ typedef enum { *****************************************************************************/ -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 00000100 for Bearer Capability */ - L3UCHAR Size; /* Length of Information Element */ L3UCHAR CodStand; /* Coding Standard. */ @@ -286,7 +284,8 @@ typedef struct L3UCHAR AL3Info1; /* additional layer 3 info 1 */ L3UCHAR AL3Info2; /* additional layer 3 info 2 */ -}Q931ie_BearerCap; + +} Q931ie_BearerCap; /***************************************************************************** @@ -295,12 +294,13 @@ typedef struct *****************************************************************************/ -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 00010000 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR CallId[1]; /* Call identity */ -}Q931ie_CallID; + +} Q931ie_CallID; /***************************************************************************** @@ -309,13 +309,14 @@ typedef struct *****************************************************************************/ -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 00010100 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR CodStand; /* Coding Standard */ L3UCHAR CallState; /* Call State Value */ -}Q931ie_CallState; + +} Q931ie_CallState; /***************************************************************************** @@ -324,8 +325,8 @@ typedef struct Description: Cause IE as described in Q.850 *****************************************************************************/ -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 00010100 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR CodStand; /* Coding Standard */ @@ -333,21 +334,23 @@ typedef struct L3UCHAR Recom; /* Recommendation */ L3UCHAR Value; /* Cause Value */ L3UCHAR Diag[1]; /* Optional Diagnostics Field */ -}Q931ie_Cause; + +} Q931ie_Cause; /***************************************************************************** Struct: Q931ie_CalledNum *****************************************************************************/ -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 01110000 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR TypNum; /* Type of Number */ L3UCHAR NumPlanID; /* Numbering plan identification */ L3UCHAR Digit[1]; /* Digit (IA5) */ -}Q931ie_CalledNum; + +} Q931ie_CalledNum; /***************************************************************************** @@ -357,14 +360,15 @@ typedef struct *****************************************************************************/ -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 01110001 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR TypNum; /* Type of subaddress */ L3UCHAR OddEvenInd; /* Odd/Even indicator */ L3UCHAR Digit[1]; /* digits */ -}Q931ie_CalledSub; + +} Q931ie_CalledSub; /***************************************************************************** @@ -374,8 +378,8 @@ typedef struct *****************************************************************************/ -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 01101100 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR TypNum; /* Type of number */ @@ -383,7 +387,8 @@ typedef struct L3UCHAR PresInd; /* Presentation indicator */ L3UCHAR ScreenInd; /* Screening indicator */ L3UCHAR Digit[1]; /* Number digits (IA5) */ -}Q931ie_CallingNum; + +} Q931ie_CallingNum; /***************************************************************************** @@ -393,14 +398,15 @@ typedef struct *****************************************************************************/ -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 01101101 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR TypNum; /* Type of subaddress */ L3UCHAR OddEvenInd; /* Odd/Even indicator */ L3UCHAR Digit[1]; /* digits */ -}Q931ie_CallingSub; + +} Q931ie_CallingSub; /***************************************************************************** @@ -418,8 +424,8 @@ typedef struct *****************************************************************************/ -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 00011000 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR IntIDPresent; /* Int. id. present */ @@ -460,7 +466,8 @@ typedef struct /* 1001 : H12 channel units */ L3UCHAR ChanSlot; /* Channel number */ -}Q931ie_ChanID; + +} Q931ie_ChanID; /***************************************************************************** @@ -470,8 +477,8 @@ typedef struct *****************************************************************************/ -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 00101001 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR Year; /* Year */ @@ -485,7 +492,7 @@ typedef struct /* 1 : Hour present */ /* 2 : Hour and Minute present */ /* 3 : Hour, Minute and Second present */ -}Q931ie_DateTime; +} Q931ie_DateTime; /***************************************************************************** @@ -495,12 +502,13 @@ typedef struct *****************************************************************************/ -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 00101000 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR Display[1]; /* Display information (IA5) */ -}Q931ie_Display; + +} Q931ie_Display; /***************************************************************************** @@ -510,8 +518,8 @@ typedef struct *****************************************************************************/ -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 01111101 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR CodStand; /* Coding standard */ @@ -520,7 +528,8 @@ typedef struct L3UCHAR HLCharID; /* High layer characteristics id. */ L3UCHAR EHLCharID; /* Extended high layer character. id. */ L3UCHAR EVideoTlfCharID; /* Ext. videotelephony char. id. */ -}Q931ie_HLComp; + +} Q931ie_HLComp; /***************************************************************************** @@ -530,12 +539,12 @@ typedef struct *****************************************************************************/ -typedef struct -{ +typedef struct { L3UCHAR IEId; /* 00101100 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR KeypadFac[1]; /* dynamic buffer */ -}Q931ie_KeypadFac; + +} Q931ie_KeypadFac; /***************************************************************************** @@ -545,8 +554,8 @@ typedef struct *****************************************************************************/ -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 01111100 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR CodStand; /* Coding standard */ @@ -750,7 +759,8 @@ typedef struct L3UCHAR PackWinSize; /* Packet window size */ L3UCHAR AddL3Info; /* Additional Layer 3 protocol info */ -}Q931ie_LLComp; + +} Q931ie_LLComp; /***************************************************************************** @@ -760,8 +770,8 @@ typedef struct *****************************************************************************/ -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 00100000 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR LenNetID; /* Length of network facilities id. */ @@ -769,7 +779,8 @@ typedef struct L3UCHAR NetIDPlan; /* Network identification plan. */ L3UCHAR NetFac; /* Network specific facility spec. */ L3UCHAR NetID[1]; /* Network id. (IA5) */ -}Q931ie_NetFac; + +} Q931ie_NetFac; /***************************************************************************** @@ -779,12 +790,13 @@ typedef struct *****************************************************************************/ -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 00100000 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR Notification; /* Notification descriptor */ -}Q931ie_NotifInd; + +} Q931ie_NotifInd; /***************************************************************************** @@ -794,14 +806,15 @@ typedef struct *****************************************************************************/ -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 00011110 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR CodStand; /* Coding standard */ L3UCHAR Location; /* Location */ L3UCHAR ProgDesc; /* Progress description */ -}Q931ie_ProgInd; + +} Q931ie_ProgInd; /***************************************************************************** @@ -811,20 +824,23 @@ typedef struct *****************************************************************************/ -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 00000000 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR FSI; /* First segment indicator */ L3UCHAR NumSegRem; /* Number of segments remaining */ L3UCHAR SegType; /* Segment message type */ -}Q931ie_Segment; -typedef struct -{ +} Q931ie_Segment; + + +typedef struct { + L3UCHAR IEId; /* 00000000 */ L3UCHAR Size; /* Length of Information Element */ -}Q931ie_SendComplete; + +} Q931ie_SendComplete; /***************************************************************************** @@ -834,8 +850,8 @@ typedef struct *****************************************************************************/ -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 00000000 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR Signal; /* Signal value */ @@ -859,7 +875,7 @@ typedef struct /* 01000110 Alerting on - pattern 6 */ /* 01000111 Alerting on - pattern 7 */ /* 01001111 Alerting off */ -}Q931ie_Signal; +} Q931ie_Signal; /***************************************************************************** @@ -869,12 +885,13 @@ typedef struct *****************************************************************************/ #ifdef Q931_X25_SUPPORT -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 00000000 */ L3UCHAR Size; /* Length of Information Element */ L3ULONG TxDSIValue; /* Trans. delay sel. & ind. value */ -}Q931ie_TransDelSelInd; + +} Q931ie_TransDelSelInd; #endif /***************************************************************************** @@ -885,14 +902,15 @@ typedef struct *****************************************************************************/ -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 01111000 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR Type; /* Type of network identifier */ L3UCHAR NetIDPlan; /* Network idetification plan */ L3UCHAR NetID[1]; /* Network identification(IA5) */ -}Q931ie_TransNetSel; + +} Q931ie_TransNetSel; /***************************************************************************** @@ -902,13 +920,14 @@ typedef struct *****************************************************************************/ -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 01111110 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR ProtDisc; /* Protocol discriminator */ L3UCHAR User[1]; /* User information */ -}Q931ie_UserUser; + +} Q931ie_UserUser; /***************************************************************************** @@ -918,13 +937,14 @@ typedef struct *****************************************************************************/ #ifdef Q931_X25_SUPPORT -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 01000111 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR CUGInd; /* CUG indication */ L3UCHAR CUG[1]; /* CUG index code (IA5) */ -}Q931ie_ClosedUserGrp; + +} Q931ie_ClosedUserGrp; #endif /***************************************************************************** @@ -934,12 +954,13 @@ typedef struct Description: Congestion Level *****************************************************************************/ -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 01000111 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR CongLevel; /* Conguestion Level */ -}Q931ie_CongLevel; + +} Q931ie_CongLevel; /***************************************************************************** @@ -949,14 +970,15 @@ typedef struct *****************************************************************************/ #ifdef Q931_X25_SUPPORT -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 01000010 */ L3UCHAR Size; /* Length of Information Element */ L3ULONG CumTxDelay; /* Cumulative transit delay value */ L3ULONG ReqTxDelay; /* Requested end to end transit delay */ L3ULONG MaxTxDelay; /* Maximum transit delay */ -}Q931ie_EndEndTxDelay; + +} Q931ie_EndEndTxDelay; #endif /***************************************************************************** @@ -967,15 +989,16 @@ typedef struct *****************************************************************************/ #ifdef Q931_X25_SUPPORT -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 01100000 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR InInfoRate; /* Incoming information rate */ L3UCHAR OutInfoRate; /* Outgoing information rate */ L3UCHAR MinInInfoRate; /* Minimum incoming information rate */ L3UCHAR MinOutInfoRate; /* Minimum outgoing information rate */ -}Q931ie_InfoRate; + +} Q931ie_InfoRate; #endif /***************************************************************************** @@ -986,15 +1009,16 @@ typedef struct *****************************************************************************/ #ifdef Q931_X25_SUPPORT -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 01000100 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR FastSel; /* Fast selected */ L3UCHAR ExpData; /* Exp. data */ L3UCHAR DelConf; /* Delivery conf */ L3UCHAR Modulus; /* Modulus */ -}Q931ie_PackParam; + +} Q931ie_PackParam; #endif /***************************************************************************** @@ -1005,13 +1029,14 @@ typedef struct *****************************************************************************/ #ifdef Q931_X25_SUPPORT -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 01000101 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR ForwardValue; /* Forward value */ L3UCHAR BackwardValue; /* Backward value */ -}Q931ie_PackWinSize; + +} Q931ie_PackWinSize; #endif /***************************************************************************** @@ -1022,13 +1047,14 @@ typedef struct *****************************************************************************/ #ifdef Q931_X25_SUPPORT -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 01000110 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR ForwardValue; /* Forward value */ L3UCHAR BackwardValue; /* Backward value */ -}Q931ie_PackSize; + +} Q931ie_PackSize; #endif /***************************************************************************** @@ -1039,8 +1065,8 @@ typedef struct *****************************************************************************/ #ifdef Q931_X25_SUPPORT -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 01110100 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR TypeNum; /* Type of number */ @@ -1049,19 +1075,20 @@ typedef struct L3UCHAR ScreenInd; /* Screening indicator */ L3UCHAR Reason; /* Reason for redirection */ L3UCHAR Digit[1]; /* Number digits (IA5) */ -}Q931ie_RedirNum; + +} Q931ie_RedirNum; #endif -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 01110100 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR RepeatInd; /* 0010 Prioritized list for selecting */ /* one possible. */ -}Q931ie_RepeatInd; +} Q931ie_RepeatInd; + +typedef struct { -typedef struct -{ L3UCHAR IEId; /* 01110100 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR Spare; /* Spare */ @@ -1069,10 +1096,10 @@ typedef struct /* 000 Indicate channels */ /* 110 Single interface */ /* 111 All interfaces */ -}Q931ie_RestartInd; +} Q931ie_RestartInd; + +typedef struct { -typedef struct -{ L3UCHAR IEId; /* 01110100 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR Preference; /* Preference 0 = reserved, 1 = channel */ @@ -1081,7 +1108,7 @@ typedef struct /* 000 In service */ /* 001 Maintenance */ /* 010 Out of service */ -}Q931ie_ChangeStatus; +} Q931ie_ChangeStatus; /***************************************************************************** @@ -1090,13 +1117,14 @@ typedef struct *****************************************************************************/ -typedef struct -{ +typedef struct { + L3UCHAR IEId; /* 00110111 */ L3UCHAR Size; /* Length of Information Element */ L3UCHAR Type; /* Type of number */ L3UCHAR Encoding; /* Encoding of number */ L3UCHAR Digit[1]; /* Number digits (IA5) */ + } Q931ie_GenericDigits; diff --git a/libs/freetdm/src/isdn/include/Q932.h b/libs/freetdm/src/isdn/include/Q932.h index 34ba9ffa4b..9b69a34a02 100644 --- a/libs/freetdm/src/isdn/include/Q932.h +++ b/libs/freetdm/src/isdn/include/Q932.h @@ -53,7 +53,7 @@ /***************************************************************************** Q.932 Additional EI Codes *****************************************************************************/ -#define Q932ie_FACILITY 0x1c /* 0001 1100 */ +#define Q932ie_FACILITY 0x1c /* 0001 1100 */ /***************************************************************************** Function Prototypes. diff --git a/libs/freetdm/src/isdn/include/mfifo.h b/libs/freetdm/src/isdn/include/mfifo.h index 477362466b..4c1d850d81 100644 --- a/libs/freetdm/src/isdn/include/mfifo.h +++ b/libs/freetdm/src/isdn/include/mfifo.h @@ -44,11 +44,10 @@ Description: Message Index used to index a dynamic size Message FIFO. *****************************************************************************/ -typedef struct _mindex -{ +typedef struct _mindex { int offset; /* offset to message in buf */ int size; /* size of message in bytes */ -}MINDEX; +} MINDEX; /***************************************************************************** @@ -58,8 +57,7 @@ typedef struct _mindex queue. *****************************************************************************/ -typedef struct -{ +typedef struct { int first; /* first out */ int last; /* last in + 1 */ int bsize; /* buffer size */ diff --git a/libs/freetdm/src/isdn/include/national.h b/libs/freetdm/src/isdn/include/national.h index c47daf4ed9..cff26aa4a4 100644 --- a/libs/freetdm/src/isdn/include/national.h +++ b/libs/freetdm/src/isdn/include/national.h @@ -3,19 +3,18 @@ FileName: national.h Contents: Header and definition for the National ISDN dialect. The - header contents the following parts: - - - Definition of codes + header contents the following parts: + - Definition of codes - Definition of information elements (nationalie_). - Definition of messages (nationalmes_). - - Function prototypes. + - Function prototypes. - Description: The National ISDN dialect here covers ???? + Description: The National ISDN dialect here covers ???? - Related Files: national.h National ISDN Definitions - nationalie.c National ISDN IE encoders/coders - nationalStateTE.c National ISDN TE State Engine - nationalStateNT.c National ISDN NT State Engine + Related Files: national.h National ISDN Definitions + nationalie.c National ISDN IE encoders/coders + nationalStateTE.c National ISDN TE State Engine + nationalStateNT.c National ISDN NT State Engine License/Copyright: @@ -75,15 +74,12 @@ L3INT nationalPmes_Setup(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT #include "DMS.h" - /***************************************************************************** Q.931 Process Function Prototyping. Implemented in nationalStateTE.c *****************************************************************************/ - - void nationalCreateTE(L3UCHAR i); void nationalCreateNT(L3UCHAR i); diff --git a/libs/freetdm/src/isdn/mfifo.c b/libs/freetdm/src/isdn/mfifo.c index 64dbcedfcc..28528f9b64 100644 --- a/libs/freetdm/src/isdn/mfifo.c +++ b/libs/freetdm/src/isdn/mfifo.c @@ -1,38 +1,38 @@ /***************************************************************************** - Filename: mfifo.c + Filename: mfifo.c Description: mfifo is a message orriented fifo system with support of - both message and byte per byte retriaval of messages. + both message and byte per byte retriaval of messages. - The fifo has been designed with two usages in mind: + The fifo has been designed with two usages in mind: - - Queueing of frames for hdlc and feeding out byte per byte - with the possibility of re-sending of frames etc. + - Queueing of frames for hdlc and feeding out byte per byte + with the possibility of re-sending of frames etc. - - fifo for messages of dynamic size. + - fifo for messages of dynamic size. - The fifo is allocated on top of any buffer and creates an - index of message in the queue. The user can write/read - messages or write messages and read the message one byte - at the time. + The fifo is allocated on top of any buffer and creates an + index of message in the queue. The user can write/read + messages or write messages and read the message one byte + at the time. - Interface: - MFIFOCreate Create/reset/initialize fifo. - MFIFOClear Clear FIFO. - MFIFOWriteMes Write message into fifo - * MFIFOReadMes Read message from fifo. - MFIFOGetMesPtr Get ptr to next message. - MFIFOKillNext Kill next message. + Interface: + MFIFOCreate Create/reset/initialize fifo. + MFIFOClear Clear FIFO. + MFIFOWriteMes Write message into fifo + * MFIFOReadMes Read message from fifo. + MFIFOGetMesPtr Get ptr to next message. + MFIFOKillNext Kill next message. - * currently not implemented. + * currently not implemented. - Note: The message will always be saved continuously. If there is not - sufficient space at the end of the buffer, the fifo will skip - the last bytes and save the message at the top of the buffer. + Note: The message will always be saved continuously. If there is not + sufficient space at the end of the buffer, the fifo will skip + the last bytes and save the message at the top of the buffer. - This is required to allow direct ptr access to messages - stored in the queue. + This is required to allow direct ptr access to messages + stored in the queue. License/Copyright: @@ -43,12 +43,12 @@ modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of the Case Labs, Ltd nor the names of its contributors + * Neither the name of the Case Labs, Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -71,40 +71,40 @@ /***************************************************************************** - Function: MFIFOCreate + Function: MFIFOCreate Description: Creates a fifo on top of an existing buffer. - Parameters: buf ptr to buffer. - size size of buffer in bytes. - index size of index entries (max no messages). + Parameters: buf ptr to buffer. + size size of buffer in bytes. + index size of index entries (max no messages). Return value: 0 if failure, 1 if ok. *****************************************************************************/ int MFIFOCreate(unsigned char *buf, int size, int index) { - MFIFO *mf = (MFIFO *)buf; - - mf->first = mf->last = 0; - mf->ixsize = index; - mf->buf = &buf[sizeof(MFIFO) + (sizeof(MINDEX) * index)]; + MFIFO *mf = (MFIFO *)buf; + + mf->first = mf->last = 0; + mf->ixsize = index; + mf->buf = &buf[sizeof(MFIFO) + (sizeof(MINDEX) * index)]; - if(mf->buf > &buf[size]) - return 0; + if (mf->buf > &buf[size]) + return 0; - mf->bsize = size - sizeof(MFIFO) - (sizeof(MINDEX) * index); + mf->bsize = size - sizeof(MFIFO) - (sizeof(MINDEX) * index); - return 1; + return 1; } /***************************************************************************** - Function: MFIFOClear + Function: MFIFOClear Description: Clear the FIFO - Paremeters: buf ptr to fifo + Paremeters: buf ptr to fifo Return Value: none @@ -118,91 +118,91 @@ void MFIFOClear(unsigned char * buf) /***************************************************************************** - Function: MFIFOGetLBOffset + Function: MFIFOGetLBOffset Description: Helper function caclulating offset to the 'first out' byte. - Paremeters: buf ptr to fifo + Paremeters: buf ptr to fifo Return Value: offset. *****************************************************************************/ int MFIFOGetLBOffset(unsigned char *buf) { - MFIFO *mf = (MFIFO *)buf; + MFIFO *mf = (MFIFO *)buf; - if(mf->last != mf->first) - return mf->ix[mf->last].offset; - - return 0; + if (mf->last != mf->first) + return mf->ix[mf->last].offset; + + return 0; } /***************************************************************************** - Function: MFIFOGetFBOffset + Function: MFIFOGetFBOffset Description: Helper function calculating the offset to the 'first in' - byte in the buffer. This is the position the next byte - entering the fifo will occupy. + byte in the buffer. This is the position the next byte + entering the fifo will occupy. - Paremeters: buf ptr to fifo + Paremeters: buf ptr to fifo Return Value: offset *****************************************************************************/ int MFIFOGetFBOffset(unsigned char *buf) { - MFIFO *mf = (MFIFO *)buf; - int x; + MFIFO *mf = (MFIFO *)buf; + int x; - if(mf->last == mf->first) - return 0; + if (mf->last == mf->first) + return 0; - x = mf->first - 1; + x = mf->first - 1; - if(x < 0) - x = mf->ixsize - 1; + if (x < 0) + x = mf->ixsize - 1; - return mf->ix[x].offset + mf->ix[x].size; + return mf->ix[x].offset + mf->ix[x].size; } /***************************************************************************** - Function: MFIFOWriteIX + Function: MFIFOWriteIX Description: Helper function writing a calculated entry. The function - will perform a memcpy to move the message and set the index - values as well as increase the 'first in' index. + will perform a memcpy to move the message and set the index + values as well as increase the 'first in' index. - Paremeters: buf ptr to fifo - mes ptr to message - size size of message in bytes. - ix index to index entry. - off offset to position to receive the message + Paremeters: buf ptr to fifo + mes ptr to message + size size of message in bytes. + ix index to index entry. + off offset to position to receive the message Return Value: none *****************************************************************************/ void MFIFOWriteIX(unsigned char *buf, unsigned char *mes, int size, int ix, int off) { - MFIFO *mf = (MFIFO *)buf; - int x; + MFIFO *mf = (MFIFO *)buf; + int x; - memcpy(&mf->buf[off], mes, size); - mf->ix[ix].offset = off; - mf->ix[ix].size = size; + memcpy(&mf->buf[off], mes, size); + mf->ix[ix].offset = off; + mf->ix[ix].size = size; - x = mf->first + 1; + x = mf->first + 1; - if(x >= mf->ixsize) - x = 0; + if (x >= mf->ixsize) + x = 0; - mf->first = x; + mf->first = x; } /***************************************************************************** - Function: MFIFOWriteMes + Function: MFIFOWriteMes Description: @@ -213,51 +213,46 @@ void MFIFOWriteIX(unsigned char *buf, unsigned char *mes, int size, int ix, int *****************************************************************************/ int MFIFOWriteMes(unsigned char *buf, unsigned char *mes, int size) { - MFIFO *mf = (MFIFO *)buf; - int of, ol, x; + MFIFO *mf = (MFIFO *)buf; + int of, ol, x; - x = mf->first + 1; + x = mf->first + 1; - if(x >= mf->ixsize) - x = 0; + if (x >= mf->ixsize) + x = 0; - if(x == mf->last) - return 0; /* full queue */ + if (x == mf->last) + return 0; /* full queue */ - of = MFIFOGetFBOffset(buf); - ol = MFIFOGetLBOffset(buf); - if(mf->last == mf->first) /* empty queue */ - { - mf->first = mf->last = 0; /* optimize */ + of = MFIFOGetFBOffset(buf); + ol = MFIFOGetLBOffset(buf); + if (mf->last == mf->first) { /* empty queue */ + mf->first = mf->last = 0; /* optimize */ - MFIFOWriteIX(buf, mes, size, mf->first, 0); - return 1; - } - else if(of > ol) - { - if(mf->bsize - of >= size) - { - MFIFOWriteIX(buf, mes, size, mf->first, of); - return 1; - } - else if(ol > size) - { - MFIFOWriteIX(buf, mes, size, mf->first, ol); - return 1; - } - } - else if(ol - of > size) - { - MFIFOWriteIX(buf, mes, size, mf->first, of); - return 1; - } + MFIFOWriteIX(buf, mes, size, mf->first, 0); + return 1; + } + else if (of > ol) { + if (mf->bsize - of >= size) { + MFIFOWriteIX(buf, mes, size, mf->first, of); + return 1; + } + else if (ol > size) { + MFIFOWriteIX(buf, mes, size, mf->first, ol); + return 1; + } + } + else if (ol - of > size) { + MFIFOWriteIX(buf, mes, size, mf->first, of); + return 1; + } - return 0; + return 0; } /***************************************************************************** - Function: MFIFOGetMesPtr + Function: MFIFOGetMesPtr Description: @@ -270,7 +265,7 @@ unsigned char * MFIFOGetMesPtr(unsigned char *buf, int *size) { MFIFO *mf = (MFIFO *)buf; - if(mf->first == mf->last) { + if (mf->first == mf->last) { return NULL; } @@ -280,7 +275,7 @@ unsigned char * MFIFOGetMesPtr(unsigned char *buf, int *size) /***************************************************************************** - Function: MFIFOKillNext + Function: MFIFOKillNext Description: @@ -291,18 +286,17 @@ unsigned char * MFIFOGetMesPtr(unsigned char *buf, int *size) *****************************************************************************/ void MFIFOKillNext(unsigned char *buf) { - MFIFO *mf = (MFIFO *)buf; - int x; + MFIFO *mf = (MFIFO *)buf; + int x; - if(mf->first != mf->last) - { - x = mf->last + 1; - if(x >= mf->ixsize) { - x = 0; + if (mf->first != mf->last) { + x = mf->last + 1; + if (x >= mf->ixsize) { + x = 0; + } + + mf->last = x; } - - mf->last = x; - } } @@ -319,16 +313,16 @@ unsigned char * MFIFOGetMesPtrOffset(unsigned char *buf, int *size, const int po MFIFO *mf = (MFIFO *)buf; int x; - if(mf->first == mf->last) { + if (mf->first == mf->last) { return NULL; } - if(pos < 0 || pos >= mf->ixsize) { + if (pos < 0 || pos >= mf->ixsize) { return NULL; } x = pos - mf->last; - if(x < 0) { + if (x < 0) { x += (mf->ixsize - 1); } @@ -345,10 +339,10 @@ int MFIFOGetMesCount(unsigned char *buf) { MFIFO *mf = (MFIFO *)buf; - if(mf->first == mf->last) { + if (mf->first == mf->last) { return 0; } - else if(mf->first > mf->last) { + else if (mf->first > mf->last) { return mf->first - mf->last; } else { @@ -367,42 +361,37 @@ int MFIFOWriteMesOverwrite(unsigned char *buf, unsigned char *mes, int size) x = mf->first + 1; - if(x >= mf->ixsize) + if (x >= mf->ixsize) x = 0; - if(x == mf->last) { + if (x == mf->last) { /* advance last pointer */ mf->last++; - if(mf->last >= mf->ixsize) + if (mf->last >= mf->ixsize) mf->last = 0; } of = MFIFOGetFBOffset(buf); ol = MFIFOGetLBOffset(buf); - if(mf->last == mf->first) /* empty queue */ - { + if (mf->last == mf->first) { /* empty queue */ mf->first = mf->last = 0; /* optimize */ MFIFOWriteIX(buf, mes, size, mf->first, 0); return 1; } - else if(of > ol) - { - if(mf->bsize - of >= size) - { + else if (of > ol) { + if (mf->bsize - of >= size) { MFIFOWriteIX(buf, mes, size, mf->first, of); return 1; } - else if(ol > size) - { + else if (ol > size) { MFIFOWriteIX(buf, mes, size, mf->first, ol); return 1; } } - else if(ol - of > size) - { + else if (ol - of > size) { MFIFOWriteIX(buf, mes, size, mf->first, of); return 1; } diff --git a/libs/freetdm/src/isdn/nationalStateNT.c b/libs/freetdm/src/isdn/nationalStateNT.c index 29f766e073..48d649f2df 100644 --- a/libs/freetdm/src/isdn/nationalStateNT.c +++ b/libs/freetdm/src/isdn/nationalStateNT.c @@ -4,11 +4,11 @@ Contents: National ISDN State Engine for NT (Network Mode). - The controlling state engine for Q.931 is the state engine - on the NT side. The state engine on the TE side is a slave - of this. The TE side maintain it's own states as described in - ITU-T Q931, but will in raise conditions be overridden by - the NT side. + The controlling state engine for Q.931 is the state engine + on the NT side. The state engine on the TE side is a slave + of this. The TE side maintain it's own states as described in + ITU-T Q931, but will in raise conditions be overridden by + the NT side. License/Copyright: @@ -22,12 +22,12 @@ modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of the Case Labs, Ltd nor the names of its contributors + * Neither the name of the Case Labs, Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -57,66 +57,66 @@ *****************************************************************************/ void nationalCreateNT(L3UCHAR i) { - Q931SetMesProc(Q931mes_ALERTING, i,Q931ProcAlertingNT, Q931Umes_Alerting, Q931Pmes_Alerting); - Q931SetMesProc(Q931mes_CALL_PROCEEDING, i,Q931ProcCallProceedingNT, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); - Q931SetMesProc(Q931mes_CONNECT, i,Q931ProcConnectNT, Q931Umes_Connect, Q931Pmes_Connect); - Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i,Q931ProcConnectAckNT, Q931Umes_ConnectAck, Q931Pmes_ConnectAck); - Q931SetMesProc(Q931mes_PROGRESS, i,Q931ProcProgressNT, Q931Umes_Progress, Q931Pmes_Progress); - Q931SetMesProc(Q931mes_SETUP, i,Q931ProcSetupNT, nationalUmes_Setup, nationalPmes_Setup); - Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i,Q931ProcSetupAckNT, Q931Umes_SetupAck, Q931Pmes_SetupAck); - Q931SetMesProc(Q931mes_RESUME, i,Q931ProcResumeNT, Q931Umes_Resume, Q931Pmes_Resume); - Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i,Q931ProcResumeAckNT, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); - Q931SetMesProc(Q931mes_RESUME_REJECT, i,Q931ProcResumeRejectNT, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); - Q931SetMesProc(Q931mes_SUSPEND, i,Q931ProcSuspendNT, Q931Umes_Suspend, Q931Pmes_Suspend); - Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i,Q931ProcSuspendAckNT, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); - Q931SetMesProc(Q931mes_SUSPEND_REJECT, i,Q931ProcSuspendRejectNT, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); - Q931SetMesProc(Q931mes_USER_INFORMATION, i,Q931ProcUserInformationNT, Q931Umes_UserInformation, Q931Pmes_UserInformation); - Q931SetMesProc(Q931mes_DISCONNECT, i,Q931ProcDisconnectNT, Q931Umes_Disconnect, Q931Pmes_Disconnect); - Q931SetMesProc(Q931mes_RELEASE, i,Q931ProcReleaseNT, Q931Umes_Release, Q931Pmes_Release); - Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i,Q931ProcReleaseCompleteNT, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); - Q931SetMesProc(Q931mes_RESTART, i,Q931ProcRestartNT, Q931Umes_Restart, Q931Pmes_Restart); - Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i,Q931ProcRestartAckNT, Q931Umes_RestartAck, Q931Pmes_RestartAck); - Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i,Q931ProcCongestionControlNT, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); - Q931SetMesProc(Q931mes_INFORMATION, i,Q931ProcInformationNT, Q931Umes_Information, Q931Pmes_Information); - Q931SetMesProc(Q931mes_NOTIFY, i,Q931ProcNotifyNT, Q931Umes_Notify, Q931Pmes_Notify); - Q931SetMesProc(Q931mes_STATUS, i,Q931ProcStatusNT, Q931Umes_Status, Q931Pmes_Status); - Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i,Q931ProcStatusEnquiryNT, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); - Q931SetMesProc(Q931mes_SEGMENT, i,Q931ProcSegmentNT, Q931Umes_Segment, Q931Pmes_Segment); + Q931SetMesProc(Q931mes_ALERTING, i, Q931ProcAlertingNT, Q931Umes_Alerting, Q931Pmes_Alerting); + Q931SetMesProc(Q931mes_CALL_PROCEEDING, i, Q931ProcCallProceedingNT, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); + Q931SetMesProc(Q931mes_CONNECT, i, Q931ProcConnectNT, Q931Umes_Connect, Q931Pmes_Connect); + Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i, Q931ProcConnectAckNT, Q931Umes_ConnectAck, Q931Pmes_ConnectAck); + Q931SetMesProc(Q931mes_PROGRESS, i, Q931ProcProgressNT, Q931Umes_Progress, Q931Pmes_Progress); + Q931SetMesProc(Q931mes_SETUP, i, Q931ProcSetupNT, nationalUmes_Setup, nationalPmes_Setup); + Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i, Q931ProcSetupAckNT, Q931Umes_SetupAck, Q931Pmes_SetupAck); + Q931SetMesProc(Q931mes_RESUME, i, Q931ProcResumeNT, Q931Umes_Resume, Q931Pmes_Resume); + Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i, Q931ProcResumeAckNT, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); + Q931SetMesProc(Q931mes_RESUME_REJECT, i, Q931ProcResumeRejectNT, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); + Q931SetMesProc(Q931mes_SUSPEND, i, Q931ProcSuspendNT, Q931Umes_Suspend, Q931Pmes_Suspend); + Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i, Q931ProcSuspendAckNT, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); + Q931SetMesProc(Q931mes_SUSPEND_REJECT, i, Q931ProcSuspendRejectNT, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); + Q931SetMesProc(Q931mes_USER_INFORMATION, i, Q931ProcUserInformationNT, Q931Umes_UserInformation, Q931Pmes_UserInformation); + Q931SetMesProc(Q931mes_DISCONNECT, i, Q931ProcDisconnectNT, Q931Umes_Disconnect, Q931Pmes_Disconnect); + Q931SetMesProc(Q931mes_RELEASE, i, Q931ProcReleaseNT, Q931Umes_Release, Q931Pmes_Release); + Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i, Q931ProcReleaseCompleteNT, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); + Q931SetMesProc(Q931mes_RESTART, i, Q931ProcRestartNT, Q931Umes_Restart, Q931Pmes_Restart); + Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i, Q931ProcRestartAckNT, Q931Umes_RestartAck, Q931Pmes_RestartAck); + Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i, Q931ProcCongestionControlNT, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); + Q931SetMesProc(Q931mes_INFORMATION, i, Q931ProcInformationNT, Q931Umes_Information, Q931Pmes_Information); + Q931SetMesProc(Q931mes_NOTIFY, i, Q931ProcNotifyNT, Q931Umes_Notify, Q931Pmes_Notify); + Q931SetMesProc(Q931mes_STATUS, i, Q931ProcStatusNT, Q931Umes_Status, Q931Pmes_Status); + Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i, Q931ProcStatusEnquiryNT, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); + Q931SetMesProc(Q931mes_SEGMENT, i, Q931ProcSegmentNT, Q931Umes_Segment, Q931Pmes_Segment); - Q931SetMesProc(Q932mes_FACILITY, i,Q932ProcFacilityNT, Q932Umes_Facility, Q932Pmes_Facility); - Q931SetMesProc(Q932mes_HOLD, i,Q932ProcHoldNT, Q932Umes_Hold, Q932Pmes_Hold); - Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i,Q932ProcHoldAckNT, Q932Umes_HoldAck, Q932Pmes_HoldAck); - Q931SetMesProc(Q932mes_HOLD_REJECT, i,Q932ProcHoldRejectNT, Q932Umes_HoldReject, Q932Pmes_HoldReject); - Q931SetMesProc(Q932mes_REGISTER, i,Q932ProcRegisterNT, Q932Umes_Register, Q932Pmes_Register); - Q931SetMesProc(Q932mes_RETRIEVE, i,Q932ProcRetrieveNT, Q932Umes_Retrieve, Q932Pmes_Retrieve); - Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE,i,Q932ProcRetrieveAckNT, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); - Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i,Q932ProcRetrieveRejectNT, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); + Q931SetMesProc(Q932mes_FACILITY, i, Q932ProcFacilityNT, Q932Umes_Facility, Q932Pmes_Facility); + Q931SetMesProc(Q932mes_HOLD, i, Q932ProcHoldNT, Q932Umes_Hold, Q932Pmes_Hold); + Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i, Q932ProcHoldAckNT, Q932Umes_HoldAck, Q932Pmes_HoldAck); + Q931SetMesProc(Q932mes_HOLD_REJECT, i, Q932ProcHoldRejectNT, Q932Umes_HoldReject, Q932Pmes_HoldReject); + Q931SetMesProc(Q932mes_REGISTER, i, Q932ProcRegisterNT, Q932Umes_Register, Q932Pmes_Register); + Q931SetMesProc(Q932mes_RETRIEVE, i, Q932ProcRetrieveNT, Q932Umes_Retrieve, Q932Pmes_Retrieve); + Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE, i, Q932ProcRetrieveAckNT, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); + Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i, Q932ProcRetrieveRejectNT, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); /* Set up the IE encoder/decoder handle table.*/ - Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i,Q931Pie_Segment, Q931Uie_Segment); - Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i,Q931Pie_BearerCap, Q931Uie_BearerCap); - Q931SetIEProc(Q931ie_CAUSE, i,Q931Pie_Cause, Q931Uie_Cause); - Q931SetIEProc(Q931ie_CALL_IDENTITY, i,Q931Pie_CallID, Q931Uie_CallID); - Q931SetIEProc(Q931ie_CALL_STATE, i,Q931Pie_CallState, Q931Uie_CallState); - Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i,Q931Pie_ChanID, Q931Uie_ChanID); - Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i,Q931Pie_ProgInd, Q931Uie_ProgInd); - Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i,Q931Pie_NetFac, Q931Uie_NetFac); - Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i,Q931Pie_NotifInd, Q931Uie_NotifInd); - Q931SetIEProc(Q931ie_DISPLAY, i,Q931Pie_Display, Q931Uie_Display); - Q931SetIEProc(Q931ie_DATETIME, i,Q931Pie_DateTime, Q931Uie_DateTime); - Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i,Q931Pie_KeypadFac, Q931Uie_KeypadFac); - Q931SetIEProc(Q931ie_SIGNAL, i,Q931Pie_Signal, Q931Uie_Signal); - Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i,Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i,Q931Pie_CallingNum, Q931Uie_CallingNum); - Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i,Q931Pie_CallingSub, Q931Uie_CallingSub); - Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i,Q931Pie_CalledNum, Q931Uie_CalledNum); - Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i,Q931Pie_CalledSub, Q931Uie_CalledSub); - Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i,Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_RESTART_INDICATOR, i,Q931Pie_RestartInd, Q931Uie_RestartInd); - Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i,Q931Pie_LLComp, Q931Uie_LLComp); - Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i,Q931Pie_HLComp, Q931Uie_HLComp); - Q931SetIEProc(Q931ie_USER_USER, i,Q931Pie_UserUser, Q931Uie_UserUser); - Q931SetIEProc(Q931ie_GENERIC_DIGITS, i,Q931Pie_GenericDigits, Q931Uie_GenericDigits); + Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i, Q931Pie_Segment, Q931Uie_Segment); + Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i, Q931Pie_BearerCap, Q931Uie_BearerCap); + Q931SetIEProc(Q931ie_CAUSE, i, Q931Pie_Cause, Q931Uie_Cause); + Q931SetIEProc(Q931ie_CALL_IDENTITY, i, Q931Pie_CallID, Q931Uie_CallID); + Q931SetIEProc(Q931ie_CALL_STATE, i, Q931Pie_CallState, Q931Uie_CallState); + Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i, Q931Pie_ChanID, Q931Uie_ChanID); + Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i, Q931Pie_ProgInd, Q931Uie_ProgInd); + Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i, Q931Pie_NetFac, Q931Uie_NetFac); + Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i, Q931Pie_NotifInd, Q931Uie_NotifInd); + Q931SetIEProc(Q931ie_DISPLAY, i, Q931Pie_Display, Q931Uie_Display); + Q931SetIEProc(Q931ie_DATETIME, i, Q931Pie_DateTime, Q931Uie_DateTime); + Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i, Q931Pie_KeypadFac, Q931Uie_KeypadFac); + Q931SetIEProc(Q931ie_SIGNAL, i, Q931Pie_Signal, Q931Uie_Signal); + Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); + Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i, Q931Pie_CallingNum, Q931Uie_CallingNum); + Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i, Q931Pie_CallingSub, Q931Uie_CallingSub); + Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i, Q931Pie_CalledNum, Q931Uie_CalledNum); + Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i, Q931Pie_CalledSub, Q931Uie_CalledSub); + Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); + Q931SetIEProc(Q931ie_RESTART_INDICATOR, i, Q931Pie_RestartInd, Q931Uie_RestartInd); + Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i, Q931Pie_LLComp, Q931Uie_LLComp); + Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i, Q931Pie_HLComp, Q931Uie_HLComp); + Q931SetIEProc(Q931ie_USER_USER, i, Q931Pie_UserUser, Q931Uie_UserUser); + Q931SetIEProc(Q931ie_GENERIC_DIGITS, i, Q931Pie_GenericDigits, Q931Uie_GenericDigits); /* The following define a state machine. The point is that the Message */ /* procs can when search this to find out if the message/state */ diff --git a/libs/freetdm/src/isdn/nationalStateTE.c b/libs/freetdm/src/isdn/nationalStateTE.c index 99dcec3b9a..a50ae3debd 100644 --- a/libs/freetdm/src/isdn/nationalStateTE.c +++ b/libs/freetdm/src/isdn/nationalStateTE.c @@ -4,18 +4,18 @@ Contents: National ISDN State Engine for TE (User Mode). - The controlling state engine for Q.931 is the state engine - on the NT side. The state engine on the TE side is a slave - of this. The TE side maintain it's own states as described in - ITU-T Q931, but will in raise conditions be overridden by - the NT side. + The controlling state engine for Q.931 is the state engine + on the NT side. The state engine on the TE side is a slave + of this. The TE side maintain it's own states as described in + ITU-T Q931, but will in raise conditions be overridden by + the NT side. - This reference implementation uses a process per message, - meaning that each message must check call states. This - is easier for dialect maintenance as each message proc - can be replaced individually. A new TE variant only - need to copy the Q931CreateTE and replace those procs or - need to override. + This reference implementation uses a process per message, + meaning that each message must check call states. This + is easier for dialect maintenance as each message proc + can be replaced individually. A new TE variant only + need to copy the Q931CreateTE and replace those procs or + need to override. License/Copyright: @@ -29,12 +29,12 @@ modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of the Case Labs, Ltd nor the names of its contributors + * Neither the name of the Case Labs, Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -65,152 +65,152 @@ extern L3INT Q931L4HeaderSpace; *****************************************************************************/ void nationalCreateTE(L3UCHAR i) { - Q931SetMesProc(Q931mes_ALERTING, i,Q931ProcAlertingTE, Q931Umes_Alerting, Q931Pmes_Alerting); - Q931SetMesProc(Q931mes_CALL_PROCEEDING, i,Q931ProcCallProceedingTE, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); - Q931SetMesProc(Q931mes_CONNECT, i,DMSProc0x07TE, DMSUmes_0x07, DMSPmes_0x07); - Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i,DMSProc0x0fTE, DMSUmes_0x0f, DMSPmes_0x0f); - Q931SetMesProc(Q931mes_PROGRESS, i,Q931ProcProgressTE, Q931Umes_Progress, Q931Pmes_Progress); - Q931SetMesProc(Q931mes_SETUP, i,Q931ProcSetupTE, nationalUmes_Setup, nationalPmes_Setup); - Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i,Q931ProcSetupAckTE, Q931Umes_SetupAck, Q931Pmes_SetupAck); - Q931SetMesProc(Q931mes_RESUME, i,Q931ProcResumeTE, Q931Umes_Resume, Q931Pmes_Resume); - Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i,Q931ProcResumeAckTE, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); - Q931SetMesProc(Q931mes_RESUME_REJECT, i,Q931ProcResumeRejectTE, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); - Q931SetMesProc(Q931mes_SUSPEND, i,Q931ProcSuspendTE, Q931Umes_Suspend, Q931Pmes_Suspend); - Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i,Q931ProcSuspendAckTE, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); - Q931SetMesProc(Q931mes_SUSPEND_REJECT, i,Q931ProcSuspendRejectTE, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); - Q931SetMesProc(Q931mes_USER_INFORMATION, i,Q931ProcUserInformationTE, Q931Umes_UserInformation, Q931Pmes_UserInformation); - Q931SetMesProc(Q931mes_DISCONNECT, i,Q931ProcDisconnectTE, Q931Umes_Disconnect, Q931Pmes_Disconnect); - Q931SetMesProc(Q931mes_RELEASE, i,Q931ProcReleaseTE, Q931Umes_Release, Q931Pmes_Release); - Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i,Q931ProcReleaseCompleteTE, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); - Q931SetMesProc(Q931mes_RESTART, i,Q931ProcRestartTE, Q931Umes_Restart, Q931Pmes_Restart); - Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i,Q931ProcRestartAckTE, Q931Umes_RestartAck, Q931Pmes_RestartAck); - Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i,Q931ProcCongestionControlTE, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); - Q931SetMesProc(Q931mes_INFORMATION, i,Q931ProcInformationTE, Q931Umes_Information, Q931Pmes_Information); - Q931SetMesProc(Q931mes_NOTIFY, i,Q931ProcNotifyTE, Q931Umes_Notify, Q931Pmes_Notify); - Q931SetMesProc(Q931mes_STATUS, i,Q931ProcStatusTE, Q931Umes_Status, Q931Pmes_Status); - Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i,Q931ProcStatusEnquiryTE, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); - Q931SetMesProc(Q931mes_SEGMENT, i,Q931ProcSegmentTE, Q931Umes_Segment, Q931Pmes_Segment); + Q931SetMesProc(Q931mes_ALERTING, i, Q931ProcAlertingTE, Q931Umes_Alerting, Q931Pmes_Alerting); + Q931SetMesProc(Q931mes_CALL_PROCEEDING, i, Q931ProcCallProceedingTE, Q931Umes_CallProceeding, Q931Pmes_CallProceeding); + Q931SetMesProc(Q931mes_CONNECT, i, DMSProc0x07TE, DMSUmes_0x07, DMSPmes_0x07); + Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE, i, DMSProc0x0fTE, DMSUmes_0x0f, DMSPmes_0x0f); + Q931SetMesProc(Q931mes_PROGRESS, i, Q931ProcProgressTE, Q931Umes_Progress, Q931Pmes_Progress); + Q931SetMesProc(Q931mes_SETUP, i, Q931ProcSetupTE, nationalUmes_Setup, nationalPmes_Setup); + Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE, i, Q931ProcSetupAckTE, Q931Umes_SetupAck, Q931Pmes_SetupAck); + Q931SetMesProc(Q931mes_RESUME, i, Q931ProcResumeTE, Q931Umes_Resume, Q931Pmes_Resume); + Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE, i, Q931ProcResumeAckTE, Q931Umes_ResumeAck, Q931Pmes_ResumeAck); + Q931SetMesProc(Q931mes_RESUME_REJECT, i, Q931ProcResumeRejectTE, Q931Umes_ResumeReject, Q931Pmes_ResumeReject); + Q931SetMesProc(Q931mes_SUSPEND, i, Q931ProcSuspendTE, Q931Umes_Suspend, Q931Pmes_Suspend); + Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE, i, Q931ProcSuspendAckTE, Q931Umes_SuspendAck, Q931Pmes_SuspendAck); + Q931SetMesProc(Q931mes_SUSPEND_REJECT, i, Q931ProcSuspendRejectTE, Q931Umes_SuspendReject, Q931Pmes_SuspendReject); + Q931SetMesProc(Q931mes_USER_INFORMATION, i, Q931ProcUserInformationTE, Q931Umes_UserInformation, Q931Pmes_UserInformation); + Q931SetMesProc(Q931mes_DISCONNECT, i, Q931ProcDisconnectTE, Q931Umes_Disconnect, Q931Pmes_Disconnect); + Q931SetMesProc(Q931mes_RELEASE, i, Q931ProcReleaseTE, Q931Umes_Release, Q931Pmes_Release); + Q931SetMesProc(Q931mes_RELEASE_COMPLETE, i, Q931ProcReleaseCompleteTE, Q931Umes_ReleaseComplete, Q931Pmes_ReleaseComplete); + Q931SetMesProc(Q931mes_RESTART, i, Q931ProcRestartTE, Q931Umes_Restart, Q931Pmes_Restart); + Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE, i, Q931ProcRestartAckTE, Q931Umes_RestartAck, Q931Pmes_RestartAck); + Q931SetMesProc(Q931mes_CONGESTION_CONTROL, i, Q931ProcCongestionControlTE, Q931Umes_CongestionControl, Q931Pmes_CongestionControl); + Q931SetMesProc(Q931mes_INFORMATION, i, Q931ProcInformationTE, Q931Umes_Information, Q931Pmes_Information); + Q931SetMesProc(Q931mes_NOTIFY, i, Q931ProcNotifyTE, Q931Umes_Notify, Q931Pmes_Notify); + Q931SetMesProc(Q931mes_STATUS, i, Q931ProcStatusTE, Q931Umes_Status, Q931Pmes_Status); + Q931SetMesProc(Q931mes_STATUS_ENQUIRY, i, Q931ProcStatusEnquiryTE, Q931Umes_StatusEnquiry, Q931Pmes_StatusEnquiry); + Q931SetMesProc(Q931mes_SEGMENT, i, Q931ProcSegmentTE, Q931Umes_Segment, Q931Pmes_Segment); - Q931SetMesProc(Q932mes_FACILITY, i,Q932ProcFacilityTE, Q932Umes_Facility, Q932Pmes_Facility); - Q931SetMesProc(Q932mes_HOLD, i,Q932ProcHoldTE, Q932Umes_Hold, Q932Pmes_Hold); - Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i,Q932ProcHoldAckTE, Q932Umes_HoldAck, Q932Pmes_HoldAck); - Q931SetMesProc(Q932mes_HOLD_REJECT, i,Q932ProcHoldRejectTE, Q932Umes_HoldReject, Q932Pmes_HoldReject); - Q931SetMesProc(Q932mes_REGISTER, i,Q932ProcRegisterTE, Q932Umes_Register, Q932Pmes_Register); - Q931SetMesProc(Q932mes_RETRIEVE, i,Q932ProcRetrieveTE, Q932Umes_Retrieve, Q932Pmes_Retrieve); - Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE,i,Q932ProcRetrieveAckTE, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); - Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i,Q932ProcRetrieveRejectTE, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); + Q931SetMesProc(Q932mes_FACILITY, i, Q932ProcFacilityTE, Q932Umes_Facility, Q932Pmes_Facility); + Q931SetMesProc(Q932mes_HOLD, i, Q932ProcHoldTE, Q932Umes_Hold, Q932Pmes_Hold); + Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE, i, Q932ProcHoldAckTE, Q932Umes_HoldAck, Q932Pmes_HoldAck); + Q931SetMesProc(Q932mes_HOLD_REJECT, i, Q932ProcHoldRejectTE, Q932Umes_HoldReject, Q932Pmes_HoldReject); + Q931SetMesProc(Q932mes_REGISTER, i, Q932ProcRegisterTE, Q932Umes_Register, Q932Pmes_Register); + Q931SetMesProc(Q932mes_RETRIEVE, i, Q932ProcRetrieveTE, Q932Umes_Retrieve, Q932Pmes_Retrieve); + Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE, i, Q932ProcRetrieveAckTE, Q932Umes_RetrieveAck, Q932Pmes_RetrieveAck); + Q931SetMesProc(Q932mes_RETRIEVE_REJECT, i, Q932ProcRetrieveRejectTE, Q932Umes_RetrieveReject, Q932Pmes_RetrieveReject); /* Set up the IE encoder/decoder handle table.*/ - Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i,Q931Pie_Segment, Q931Uie_Segment); - Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i,Q931Pie_BearerCap, Q931Uie_BearerCap); - Q931SetIEProc(Q931ie_CAUSE, i,Q931Pie_Cause, Q931Uie_Cause); - Q931SetIEProc(Q931ie_CALL_IDENTITY, i,Q931Pie_CallID, Q931Uie_CallID); - Q931SetIEProc(Q931ie_CALL_STATE, i,Q931Pie_CallState, Q931Uie_CallState); - Q931SetIEProc(Q931ie_CHANGE_STATUS, i,Q931Pie_ChangeStatus, Q931Uie_ChangeStatus); - Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i,Q931Pie_ChanID, Q931Uie_ChanID); - Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i,Q931Pie_ProgInd, Q931Uie_ProgInd); - Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i,Q931Pie_NetFac, Q931Uie_NetFac); - Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i,Q931Pie_NotifInd, Q931Uie_NotifInd); - Q931SetIEProc(Q931ie_DISPLAY, i,Q931Pie_Display, Q931Uie_Display); - Q931SetIEProc(Q931ie_DATETIME, i,Q931Pie_DateTime, Q931Uie_DateTime); - Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i,Q931Pie_KeypadFac, Q931Uie_KeypadFac); - Q931SetIEProc(Q931ie_SIGNAL, i,Q931Pie_Signal, Q931Uie_Signal); - Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i,Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i,Q931Pie_CallingNum, Q931Uie_CallingNum); - Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i,Q931Pie_CallingSub, Q931Uie_CallingSub); - Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i,Q931Pie_CalledNum, Q931Uie_CalledNum); - Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i,Q931Pie_CalledSub, Q931Uie_CalledSub); - Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i,Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_RESTART_INDICATOR, i,Q931Pie_RestartInd, Q931Uie_RestartInd); - Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i,Q931Pie_LLComp, Q931Uie_LLComp); - Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i,Q931Pie_HLComp, Q931Uie_HLComp); - Q931SetIEProc(Q931ie_USER_USER, i,Q931Pie_UserUser, Q931Uie_UserUser); - Q931SetIEProc(Q931ie_GENERIC_DIGITS, i,Q931Pie_GenericDigits, Q931Uie_GenericDigits); + Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE, i, Q931Pie_Segment, Q931Uie_Segment); + Q931SetIEProc(Q931ie_BEARER_CAPABILITY, i, Q931Pie_BearerCap, Q931Uie_BearerCap); + Q931SetIEProc(Q931ie_CAUSE, i, Q931Pie_Cause, Q931Uie_Cause); + Q931SetIEProc(Q931ie_CALL_IDENTITY, i, Q931Pie_CallID, Q931Uie_CallID); + Q931SetIEProc(Q931ie_CALL_STATE, i, Q931Pie_CallState, Q931Uie_CallState); + Q931SetIEProc(Q931ie_CHANGE_STATUS, i, Q931Pie_ChangeStatus, Q931Uie_ChangeStatus); + Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION, i, Q931Pie_ChanID, Q931Uie_ChanID); + Q931SetIEProc(Q931ie_PROGRESS_INDICATOR, i, Q931Pie_ProgInd, Q931Uie_ProgInd); + Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES, i, Q931Pie_NetFac, Q931Uie_NetFac); + Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR, i, Q931Pie_NotifInd, Q931Uie_NotifInd); + Q931SetIEProc(Q931ie_DISPLAY, i, Q931Pie_Display, Q931Uie_Display); + Q931SetIEProc(Q931ie_DATETIME, i, Q931Pie_DateTime, Q931Uie_DateTime); + Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i, Q931Pie_KeypadFac, Q931Uie_KeypadFac); + Q931SetIEProc(Q931ie_SIGNAL, i, Q931Pie_Signal, Q931Uie_Signal); + Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); + Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i, Q931Pie_CallingNum, Q931Uie_CallingNum); + Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i, Q931Pie_CallingSub, Q931Uie_CallingSub); + Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i, Q931Pie_CalledNum, Q931Uie_CalledNum); + Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i, Q931Pie_CalledSub, Q931Uie_CalledSub); + Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION, i, Q931Pie_TransNetSel, Q931Uie_TransNetSel); + Q931SetIEProc(Q931ie_RESTART_INDICATOR, i, Q931Pie_RestartInd, Q931Uie_RestartInd); + Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY, i, Q931Pie_LLComp, Q931Uie_LLComp); + Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY, i, Q931Pie_HLComp, Q931Uie_HLComp); + Q931SetIEProc(Q931ie_USER_USER, i, Q931Pie_UserUser, Q931Uie_UserUser); + Q931SetIEProc(Q931ie_GENERIC_DIGITS, i, Q931Pie_GenericDigits, Q931Uie_GenericDigits); Q931SetIEProc(Q931ie_CONNECTED_NUMBER, i, Q931Pie_Generic, Q931Uie_Generic); Q931SetIEProc(Q931ie_FACILITY, i, Q931Pie_Generic, Q931Uie_Generic); - /* The following define a state machine. The point is that the Message */ - /* procs can when search this to find out if the message/state */ - /* combination is legale. If not, the proc for unexpected message apply.*/ + /* The following define a state machine. The point is that the Message + * procs can when search this to find out if the message/state + * combination is legale. If not, the proc for unexpected message apply. + */ /* State 0 Idle */ - Q931AddStateEntry(i,Q931_U0, Q931mes_RESUME, 2); - Q931AddStateEntry(i,Q931_U0, Q931mes_SETUP, 4); - Q931AddStateEntry(i,Q931_U0, Q931mes_SETUP, 2); - Q931AddStateEntry(i,Q931_U0, Q931mes_STATUS, 4); - Q931AddStateEntry(i,Q931_U0, Q931mes_RELEASE, 4); - Q931AddStateEntry(i,Q931_U0, Q931mes_RELEASE_COMPLETE,4); + Q931AddStateEntry(i, Q931_U0, Q931mes_RESUME, 2); + Q931AddStateEntry(i, Q931_U0, Q931mes_SETUP, 4); + Q931AddStateEntry(i, Q931_U0, Q931mes_SETUP, 2); + Q931AddStateEntry(i, Q931_U0, Q931mes_STATUS, 4); + Q931AddStateEntry(i, Q931_U0, Q931mes_RELEASE, 4); + Q931AddStateEntry(i, Q931_U0, Q931mes_RELEASE_COMPLETE, 4); /* State 1 Call Initiating */ - Q931AddStateEntry(i,Q931_U1, Q931mes_DISCONNECT, 2); - Q931AddStateEntry(i,Q931_U1, Q931mes_SETUP_ACKNOWLEDGE, 4); - Q931AddStateEntry(i,Q931_U1, Q931mes_RELEASE_COMPLETE,4); - Q931AddStateEntry(i,Q931_U1, Q931mes_CALL_PROCEEDING, 4); - Q931AddStateEntry(i,Q931_U1, Q931mes_ALERTING, 4); - Q931AddStateEntry(i,Q931_U1, Q931mes_CONNECT, 4); + Q931AddStateEntry(i, Q931_U1, Q931mes_DISCONNECT, 2); + Q931AddStateEntry(i, Q931_U1, Q931mes_SETUP_ACKNOWLEDGE, 4); + Q931AddStateEntry(i, Q931_U1, Q931mes_RELEASE_COMPLETE, 4); + Q931AddStateEntry(i, Q931_U1, Q931mes_CALL_PROCEEDING, 4); + Q931AddStateEntry(i, Q931_U1, Q931mes_ALERTING, 4); + Q931AddStateEntry(i, Q931_U1, Q931mes_CONNECT, 4); /* State 2 Overlap Sending */ - Q931AddStateEntry(i,Q931_U2, Q931mes_INFORMATION, 2); - Q931AddStateEntry(i,Q931_U2, Q931mes_CALL_PROCEEDING, 4); - Q931AddStateEntry(i,Q931_U2, Q931mes_ALERTING, 4); - Q931AddStateEntry(i,Q931_U2, Q931mes_PROGRESS, 4); - Q931AddStateEntry(i,Q931_U2, Q931mes_CONNECT, 4); - Q931AddStateEntry(i,Q931_U2, Q931mes_RELEASE, 2); + Q931AddStateEntry(i, Q931_U2, Q931mes_INFORMATION, 2); + Q931AddStateEntry(i, Q931_U2, Q931mes_CALL_PROCEEDING, 4); + Q931AddStateEntry(i, Q931_U2, Q931mes_ALERTING, 4); + Q931AddStateEntry(i, Q931_U2, Q931mes_PROGRESS, 4); + Q931AddStateEntry(i, Q931_U2, Q931mes_CONNECT, 4); + Q931AddStateEntry(i, Q931_U2, Q931mes_RELEASE, 2); /* State 3 Outgoing Call Proceeding */ - Q931AddStateEntry(i,Q931_U3, Q931mes_PROGRESS, 4); - Q931AddStateEntry(i,Q931_U3, Q931mes_ALERTING, 4); - Q931AddStateEntry(i,Q931_U3, Q931mes_CONNECT, 4); - Q931AddStateEntry(i,Q931_U3, Q931mes_RELEASE, 2); + Q931AddStateEntry(i, Q931_U3, Q931mes_PROGRESS, 4); + Q931AddStateEntry(i, Q931_U3, Q931mes_ALERTING, 4); + Q931AddStateEntry(i, Q931_U3, Q931mes_CONNECT, 4); + Q931AddStateEntry(i, Q931_U3, Q931mes_RELEASE, 2); /* State 4 Call Delivered */ - Q931AddStateEntry(i,Q931_U4, Q931mes_CONNECT, 4); + Q931AddStateEntry(i, Q931_U4, Q931mes_CONNECT, 4); /* State 6 Call Precent */ - Q931AddStateEntry(i,Q931_U6, Q931mes_INFORMATION, 2); - Q931AddStateEntry(i,Q931_U6, Q931mes_ALERTING, 2); - Q931AddStateEntry(i,Q931_U6, Q931mes_CALL_PROCEEDING,2); - Q931AddStateEntry(i,Q931_U6, Q931mes_CONNECT, 2); - Q931AddStateEntry(i,Q931_U6, Q931mes_RELEASE_COMPLETE,2); - Q931AddStateEntry(i,Q931_U6, Q931mes_RELEASE, 4); - Q931AddStateEntry(i,Q931_U6, Q931mes_DISCONNECT, 4); + Q931AddStateEntry(i, Q931_U6, Q931mes_INFORMATION, 2); + Q931AddStateEntry(i, Q931_U6, Q931mes_ALERTING, 2); + Q931AddStateEntry(i, Q931_U6, Q931mes_CALL_PROCEEDING, 2); + Q931AddStateEntry(i, Q931_U6, Q931mes_CONNECT, 2); + Q931AddStateEntry(i, Q931_U6, Q931mes_RELEASE_COMPLETE, 2); + Q931AddStateEntry(i, Q931_U6, Q931mes_RELEASE, 4); + Q931AddStateEntry(i, Q931_U6, Q931mes_DISCONNECT, 4); /* State 7 Call Received */ - Q931AddStateEntry(i,Q931_U7, Q931mes_CONNECT, 2); + Q931AddStateEntry(i, Q931_U7, Q931mes_CONNECT, 2); /* State 8 Connect request */ - Q931AddStateEntry(i,Q931_U8, Q931mes_CONNECT_ACKNOWLEDGE, 4); + Q931AddStateEntry(i, Q931_U8, Q931mes_CONNECT_ACKNOWLEDGE, 4); /* State 9 Incoming Call Proceeding */ - Q931AddStateEntry(i,Q931_U9, Q931mes_CONNECT, 2); - Q931AddStateEntry(i,Q931_U9, Q931mes_ALERTING, 2); - Q931AddStateEntry(i,Q931_U9, Q931mes_PROGRESS, 2); + Q931AddStateEntry(i, Q931_U9, Q931mes_CONNECT, 2); + Q931AddStateEntry(i, Q931_U9, Q931mes_ALERTING, 2); + Q931AddStateEntry(i, Q931_U9, Q931mes_PROGRESS, 2); /* State 10 Active */ - Q931AddStateEntry(i,Q931_U10, Q931mes_SUSPEND, 2); - Q931AddStateEntry(i,Q931_U10, Q931mes_NOTIFY, 4); - Q931AddStateEntry(i,Q931_U10, Q931mes_NOTIFY, 2); + Q931AddStateEntry(i, Q931_U10, Q931mes_SUSPEND, 2); + Q931AddStateEntry(i, Q931_U10, Q931mes_NOTIFY, 4); + Q931AddStateEntry(i, Q931_U10, Q931mes_NOTIFY, 2); /* State 11 Disconnect Request */ - Q931AddStateEntry(i,Q931_U11, Q931mes_RELEASE, 4); - Q931AddStateEntry(i,Q931_U11, Q931mes_DISCONNECT, 4); - Q931AddStateEntry(i,Q931_U11, Q931mes_NOTIFY, 4); + Q931AddStateEntry(i, Q931_U11, Q931mes_RELEASE, 4); + Q931AddStateEntry(i, Q931_U11, Q931mes_DISCONNECT, 4); + Q931AddStateEntry(i, Q931_U11, Q931mes_NOTIFY, 4); /* State 12 Disconnect Ind */ - Q931AddStateEntry(i,Q931_U12, Q931mes_RELEASE, 4); - Q931AddStateEntry(i,Q931_U12, Q931mes_RELEASE, 2); + Q931AddStateEntry(i, Q931_U12, Q931mes_RELEASE, 4); + Q931AddStateEntry(i, Q931_U12, Q931mes_RELEASE, 2); /* State 15 Suspend Request */ - Q931AddStateEntry(i,Q931_U15, Q931mes_SUSPEND_ACKNOWLEDGE, 4); - Q931AddStateEntry(i,Q931_U15, Q931mes_SUSPEND_REJECT, 4); - Q931AddStateEntry(i,Q931_U15, Q931mes_DISCONNECT, 4); - Q931AddStateEntry(i,Q931_U15, Q931mes_RELEASE, 4); + Q931AddStateEntry(i, Q931_U15, Q931mes_SUSPEND_ACKNOWLEDGE, 4); + Q931AddStateEntry(i, Q931_U15, Q931mes_SUSPEND_REJECT, 4); + Q931AddStateEntry(i, Q931_U15, Q931mes_DISCONNECT, 4); + Q931AddStateEntry(i, Q931_U15, Q931mes_RELEASE, 4); /* TODO - Q931AddStateEntry(i,Q931_U17, - Q931AddStateEntry(i,Q931_U19, - Q931AddStateEntry(i,Q931_U25, + Q931AddStateEntry(i, Q931_U17, + Q931AddStateEntry(i, Q931_U19, + Q931AddStateEntry(i, Q931_U25, */ } - diff --git a/libs/freetdm/src/isdn/nationalmes.c b/libs/freetdm/src/isdn/nationalmes.c index 90f7a1b1a3..5ef69014b5 100644 --- a/libs/freetdm/src/isdn/nationalmes.c +++ b/libs/freetdm/src/isdn/nationalmes.c @@ -1,13 +1,13 @@ /***************************************************************************** - FileName: nationalmes.c + FileName: nationalmes.c - Contents: Pack/Unpack functions. These functions will unpack a National ISDN - message from the bit packed original format into structs - that contains variables sized by the user. It will also pack - the struct back into a Q.931 message as required. + Contents: Pack/Unpack functions. These functions will unpack a National ISDN + message from the bit packed original format into structs + that contains variables sized by the user. It will also pack + the struct back into a Q.931 message as required. - See national.h for description. + See national.h for description. License/Copyright: @@ -21,12 +21,12 @@ modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of the Case Labs, Ltd nor the names of its contributors + * Neither the name of the Case Labs, Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -48,19 +48,18 @@ /***************************************************************************** - Function: nationalUmes_Setup + Function: nationalUmes_Setup *****************************************************************************/ L3INT nationalUmes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size) { - L3INT ir=0; - L3INT OOff=0; - L3INT rc=Q931E_NO_ERROR; + L3INT ir = 0; + L3INT OOff = 0; + L3INT rc = Q931E_NO_ERROR; L3UCHAR last_codeset = 0, codeset = 0; L3UCHAR shift_lock = 1; - while(IOff < Size) - { + while (IOff < Size) { if (!shift_lock) { codeset = last_codeset; } @@ -75,8 +74,7 @@ L3INT nationalUmes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generi } if (codeset == 0) { - switch(IBuf[IOff]) - { + switch (IBuf[IOff]) { case Q931ie_SENDING_COMPLETE: case Q931ie_BEARER_CAPABILITY: case Q931ie_CHANNEL_IDENTIFICATION: @@ -94,11 +92,11 @@ L3INT nationalUmes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generi case Q931ie_LOW_LAYER_COMPATIBILITY: case Q931ie_HIGH_LAYER_COMPATIBILITY: rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; case Q931ie_REPEAT_INDICATOR: - if(ir < 2) { + if (ir < 2) { rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); ir++; } else { @@ -110,11 +108,10 @@ L3INT nationalUmes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generi break; } } else if (codeset == 6) { - switch(IBuf[IOff]) - { + switch (IBuf[IOff]) { case Q931ie_GENERIC_DIGITS: rc = Q931Uie[pTrunk->Dialect][IBuf[IOff]](pTrunk, mes, &IBuf[IOff], &mes->buf[OOff], &IOff, &OOff); - if(rc != Q931E_NO_ERROR) + if (rc != Q931E_NO_ERROR) return rc; break; default: @@ -126,13 +123,13 @@ L3INT nationalUmes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generi return Q931E_ILLEGAL_IE; } } - mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; - return Q931E_NO_ERROR; + mes->Size = sizeof(Q931mes_Generic) - 1 + OOff; + return Q931E_NO_ERROR; } /***************************************************************************** - Function: nationalPmes_Setup + Function: nationalPmes_Setup Decription: Pack a Q931mes_Generic into a real Q.931 message. The user will set up a SETUP message and issue this to the stack where it @@ -150,109 +147,121 @@ L3INT nationalUmes_Setup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generi *****************************************************************************/ L3INT nationalPmes_Setup(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize) { - L3INT rc = Q931E_NO_ERROR; + L3INT rc = Q931E_NO_ERROR; Q931mes_Generic *pMes = (Q931mes_Generic *)IBuf; L3INT Octet = 0; /* Q931 Message Header */ Q931MesgHeader(pTrunk, pMes, OBuf, *OSize, &Octet); - - /* Sending Complete */ - if(Q931IsIEPresent(pMes->SendComplete)) + + /* Sending Complete */ + if (Q931IsIEPresent(pMes->SendComplete)) { OBuf[Octet++] = (L3UCHAR)(pMes->SendComplete & 0x00ff); + } /* Repeat Indicator */ - if(Q931IsIEPresent(pMes->RepeatInd)) + if (Q931IsIEPresent(pMes->RepeatInd)) { OBuf[Octet++] = (L3UCHAR)(pMes->RepeatInd & 0x00ff); + } /* Bearer capability */ - if(Q931IsIEPresent(pMes->BearerCap)) - { - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->BearerCap)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_BEARER_CAPABILITY](pTrunk, Q931GetIEPtr(pMes->BearerCap,pMes->buf), OBuf, &Octet)) != 0) return rc; } - else - { - rc=Q931E_BEARERCAP; + else { + rc = Q931E_BEARERCAP; } /* Channel Identification */ - if(Q931IsIEPresent(pMes->ChanID)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->ChanID)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CHANNEL_IDENTIFICATION](pTrunk, Q931GetIEPtr(pMes->ChanID,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Progress indicator */ - if(Q931IsIEPresent(pMes->ProgInd)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->ProgInd)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_PROGRESS_INDICATOR](pTrunk, Q931GetIEPtr(pMes->ProgInd,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Network spesific facilities */ - if(Q931IsIEPresent(pMes->NetFac)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_NETWORK_SPECIFIC_FACILITIES](pTrunk, Q931GetIEPtr(pMes->NetFac,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->NetFac)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_NETWORK_SPECIFIC_FACILITIES](pTrunk, Q931GetIEPtr(pMes->NetFac,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Display */ - if(Q931IsIEPresent(pMes->Display)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Display)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DISPLAY](pTrunk, Q931GetIEPtr(pMes->Display,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Date/Time */ - if(Q931IsIEPresent(pMes->DateTime)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_DATETIME](pTrunk, Q931GetIEPtr(pMes->DateTime,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->DateTime)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_DATETIME](pTrunk, Q931GetIEPtr(pMes->DateTime,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Keypad Facility */ - if(Q931IsIEPresent(pMes->KeypadFac)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_KEYPAD_FACILITY](pTrunk, Q931GetIEPtr(pMes->KeypadFac,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->KeypadFac)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_KEYPAD_FACILITY](pTrunk, Q931GetIEPtr(pMes->KeypadFac,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Signal */ - if(Q931IsIEPresent(pMes->Signal)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->Signal)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_SIGNAL](pTrunk, Q931GetIEPtr(pMes->Signal,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Calling Party Number */ - if(Q931IsIEPresent(pMes->CallingNum)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CallingNum,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->CallingNum)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CallingNum,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Calling Party Subaddress */ - if(Q931IsIEPresent(pMes->CallingSub)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CallingSub,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->CallingSub)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLING_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CallingSub,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Called Party number */ - if(Q931IsIEPresent(pMes->CalledNum)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CalledNum,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->CalledNum)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_NUMBER](pTrunk, Q931GetIEPtr(pMes->CalledNum,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Called party subaddress */ - if(Q931IsIEPresent(pMes->CalledSub)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CalledSub,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->CalledSub)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_CALLED_PARTY_SUBADDRESS](pTrunk, Q931GetIEPtr(pMes->CalledSub,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Transit network selection */ - if(Q931IsIEPresent(pMes->TransNetSel)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_TRANSIT_NETWORK_SELECTION](pTrunk, Q931GetIEPtr(pMes->TransNetSel,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->TransNetSel)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_TRANSIT_NETWORK_SELECTION](pTrunk, Q931GetIEPtr(pMes->TransNetSel,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* Repeat Indicator */ - if(Q931IsIEPresent(pMes->LLRepeatInd)) + if (Q931IsIEPresent(pMes->LLRepeatInd)) { rc = Q931E_UNKNOWN_IE;/* TODO */ + } /* Low Layer Compatibility */ - if(Q931IsIEPresent(pMes->LLComp)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_LOW_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->LLComp,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->LLComp)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_LOW_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->LLComp,pMes->buf), OBuf, &Octet)) != 0) return rc; + } /* High Layer Compatibility */ - if(Q931IsIEPresent(pMes->HLComp)) - if((rc=Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet))!=0) + if (Q931IsIEPresent(pMes->HLComp)) { + if ((rc = Q931Pie[pTrunk->Dialect][Q931ie_HIGH_LAYER_COMPATIBILITY](pTrunk, Q931GetIEPtr(pMes->HLComp,pMes->buf), OBuf, &Octet)) != 0) return rc; + } *OSize = Octet; - - return rc; + return rc; } - -