root/src/isdn/DMSStateTE.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. DMSCreateTE
  2. DMSProc0x0fTE
  3. DMSProc0x07TE

   1 /*****************************************************************************
   2 
   3   FileName:             DMSStateTE.c
   4 
   5   Contents:             DMS-100 ISDN State Engine for TE (User Mode).
   6 
   7                         The controlling state engine for Q.931 is the state engine
   8                         on the NT side. The state engine on the TE side is a slave 
   9                         of this. The TE side maintain it's own states as described in
  10                         ITU-T Q931, but will in raise conditions be overridden by 
  11                         the NT side.
  12 
  13                         This reference implementation uses a process per message,
  14                         meaning that each message must check call states. This
  15                         is easier for dialect maintenance as each message proc
  16                         can be replaced individually. A new TE variant only
  17                         need to copy the Q931CreateTE and replace those procs or
  18                         need to override.
  19 
  20   License/Copyright:
  21 
  22   Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved.
  23   email:janvb@caselaboratories.com  
  24 
  25   Copyright (c) 2007, Michael Jerris. All rights reserved.
  26   email:mike@jerris.com  
  27 
  28   Redistribution and use in source and binary forms, with or without 
  29   modification, are permitted provided that the following conditions are 
  30   met:
  31 
  32         * Redistributions of source code must retain the above copyright notice, 
  33           this list of conditions and the following disclaimer.
  34         * Redistributions in binary form must reproduce the above copyright notice, 
  35           this list of conditions and the following disclaimer in the documentation 
  36           and/or other materials provided with the distribution.
  37         * Neither the name of the Case Labs, Ltd nor the names of its contributors 
  38           may be used to endorse or promote products derived from this software 
  39           without specific prior written permission.
  40 
  41   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
  42   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
  43   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
  44   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
  45   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
  46   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
  47   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
  48   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
  49   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  50   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
  51   POSSIBILITY OF SUCH DAMAGE.
  52 *****************************************************************************/
  53 
  54 #include "DMS.h"
  55 extern L3INT Q931L4HeaderSpace;
  56 
  57 /*****************************************************************************
  58   Function:             DMSCreateTE
  59 
  60   Description:  Will create the National TE as a Dialect in the stack. The first
  61                                 bulk set up the message handlers, the second bulk the IE
  62                                 encoders/coders, and the last bulk set up the state table.
  63 
  64   Parameters:   i               Dialect index
  65 *****************************************************************************/
  66 void DMSCreateTE(L3UCHAR i)
  67 {
  68         Q931SetMesProc(Q931mes_ALERTING,             i, Q931ProcAlertingTE,          Q931Umes_Alerting,          Q931Pmes_Alerting);
  69         Q931SetMesProc(Q931mes_CALL_PROCEEDING,      i, Q931ProcCallProceedingTE,    Q931Umes_CallProceeding,    Q931Pmes_CallProceeding);
  70         Q931SetMesProc(Q931mes_CONNECT,              i, DMSProc0x07TE,               DMSUmes_0x07,               DMSPmes_0x07);
  71         Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE,  i, DMSProc0x0fTE,               DMSUmes_0x0f,               DMSPmes_0x0f);
  72         Q931SetMesProc(Q931mes_PROGRESS,             i, Q931ProcProgressTE,          Q931Umes_Progress,          Q931Pmes_Progress);
  73         Q931SetMesProc(Q931mes_SETUP,                i, Q931ProcSetupTE,             DMSUmes_Setup,              DMSPmes_Setup);
  74         Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE,    i, Q931ProcSetupAckTE,          Q931Umes_SetupAck,          Q931Pmes_SetupAck);
  75         Q931SetMesProc(Q931mes_RESUME,               i, Q931ProcResumeTE,            Q931Umes_Resume,            Q931Pmes_Resume);
  76         Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE,   i, Q931ProcResumeAckTE,         Q931Umes_ResumeAck,         Q931Pmes_ResumeAck);
  77         Q931SetMesProc(Q931mes_RESUME_REJECT,        i, Q931ProcResumeRejectTE,      Q931Umes_ResumeReject,      Q931Pmes_ResumeReject);
  78         Q931SetMesProc(Q931mes_SUSPEND,              i, Q931ProcSuspendTE,           Q931Umes_Suspend,           Q931Pmes_Suspend);
  79         Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE,  i, Q931ProcSuspendAckTE,        Q931Umes_SuspendAck,        Q931Pmes_SuspendAck);
  80         Q931SetMesProc(Q931mes_SUSPEND_REJECT,       i, Q931ProcSuspendRejectTE,     Q931Umes_SuspendReject,     Q931Pmes_SuspendReject);
  81         Q931SetMesProc(Q931mes_USER_INFORMATION,     i, Q931ProcUserInformationTE,   Q931Umes_UserInformation,   Q931Pmes_UserInformation);
  82         Q931SetMesProc(Q931mes_DISCONNECT,           i, Q931ProcDisconnectTE,        Q931Umes_Disconnect,        Q931Pmes_Disconnect);
  83         Q931SetMesProc(Q931mes_RELEASE,              i, Q931ProcReleaseTE,           Q931Umes_Release,           Q931Pmes_Release);
  84         Q931SetMesProc(Q931mes_RELEASE_COMPLETE,     i, Q931ProcReleaseCompleteTE,   Q931Umes_ReleaseComplete,   Q931Pmes_ReleaseComplete);
  85         Q931SetMesProc(Q931mes_RESTART,              i, Q931ProcRestartTE,           Q931Umes_Restart,           Q931Pmes_Restart);
  86         Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE,  i, Q931ProcRestartAckTE,        Q931Umes_RestartAck,        Q931Pmes_RestartAck);
  87         Q931SetMesProc(Q931mes_CONGESTION_CONTROL,   i, Q931ProcCongestionControlTE, Q931Umes_CongestionControl, Q931Pmes_CongestionControl);
  88         Q931SetMesProc(Q931mes_INFORMATION,          i, Q931ProcInformationTE,       Q931Umes_Information,       Q931Pmes_Information);
  89         Q931SetMesProc(Q931mes_NOTIFY,               i, Q931ProcNotifyTE,            Q931Umes_Notify,            Q931Pmes_Notify);
  90         Q931SetMesProc(Q931mes_STATUS,               i, Q931ProcStatusTE,            Q931Umes_Status,            Q931Pmes_Status);
  91         Q931SetMesProc(Q931mes_STATUS_ENQUIRY,       i, Q931ProcStatusEnquiryTE,     Q931Umes_StatusEnquiry,     Q931Pmes_StatusEnquiry);
  92         Q931SetMesProc(Q931mes_SEGMENT,              i, Q931ProcSegmentTE,           Q931Umes_Segment,           Q931Pmes_Segment);
  93 
  94         Q931SetMesProc(Q932mes_FACILITY,             i, Q932ProcFacilityTE,          Q932Umes_Facility,          Q932Pmes_Facility);
  95         Q931SetMesProc(Q932mes_HOLD,                 i, Q932ProcHoldTE,              Q932Umes_Hold,              Q932Pmes_Hold);
  96         Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE,     i, Q932ProcHoldAckTE,           Q932Umes_HoldAck,           Q932Pmes_HoldAck);
  97         Q931SetMesProc(Q932mes_HOLD_REJECT,          i, Q932ProcHoldRejectTE,        Q932Umes_HoldReject,        Q932Pmes_HoldReject);
  98         Q931SetMesProc(Q932mes_REGISTER,             i, Q932ProcRegisterTE,          Q932Umes_Register,          Q932Pmes_Register);
  99         Q931SetMesProc(Q932mes_RETRIEVE,             i, Q932ProcRetrieveTE,          Q932Umes_Retrieve,          Q932Pmes_Retrieve);
 100         Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE, i, Q932ProcRetrieveAckTE,       Q932Umes_RetrieveAck,       Q932Pmes_RetrieveAck);
 101         Q931SetMesProc(Q932mes_RETRIEVE_REJECT,      i, Q932ProcRetrieveRejectTE,    Q932Umes_RetrieveReject,    Q932Pmes_RetrieveReject);
 102 
 103         /* Set up the IE encoder/decoder handle table.*/ 
 104         Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE,                i, Q931Pie_Segment,       Q931Uie_Segment);
 105         Q931SetIEProc(Q931ie_BEARER_CAPABILITY,                i, Q931Pie_BearerCap,     Q931Uie_BearerCap);
 106         Q931SetIEProc(Q931ie_CAUSE,                            i, Q931Pie_Cause,         Q931Uie_Cause);
 107         Q931SetIEProc(Q931ie_CALL_IDENTITY,                    i, Q931Pie_CallID,        Q931Uie_CallID);
 108         Q931SetIEProc(Q931ie_CALL_STATE,                       i, Q931Pie_CallState,     Q931Uie_CallState);
 109         Q931SetIEProc(Q931ie_CHANGE_STATUS,                    i, Q931Pie_ChangeStatus,  Q931Uie_ChangeStatus);
 110         Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION,           i, Q931Pie_ChanID,        Q931Uie_ChanID);
 111         Q931SetIEProc(Q931ie_PROGRESS_INDICATOR,               i, Q931Pie_ProgInd,       Q931Uie_ProgInd);
 112         Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES,      i, Q931Pie_NetFac,        Q931Uie_NetFac);
 113         Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR,           i, Q931Pie_NotifInd,      Q931Uie_NotifInd);
 114         Q931SetIEProc(Q931ie_DISPLAY,                          i, Q931Pie_Display,       Q931Uie_Display);
 115         Q931SetIEProc(Q931ie_DATETIME,                         i, Q931Pie_DateTime,      Q931Uie_DateTime);
 116         Q931SetIEProc(Q931ie_KEYPAD_FACILITY,                  i, Q931Pie_KeypadFac,     Q931Uie_KeypadFac);
 117         Q931SetIEProc(Q931ie_SIGNAL,                           i, Q931Pie_Signal,        Q931Uie_Signal);
 118         Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND,  i, Q931Pie_TransNetSel,   Q931Uie_TransNetSel);
 119         Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER,             i, Q931Pie_CallingNum,    Q931Uie_CallingNum);
 120         Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS,         i, Q931Pie_CallingSub,    Q931Uie_CallingSub);
 121         Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER,              i, Q931Pie_CalledNum,     Q931Uie_CalledNum);
 122         Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS,          i, Q931Pie_CalledSub,     Q931Uie_CalledSub);
 123         Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION,        i, Q931Pie_TransNetSel,   Q931Uie_TransNetSel);
 124         Q931SetIEProc(Q931ie_RESTART_INDICATOR,                i, Q931Pie_RestartInd,    Q931Uie_RestartInd);
 125         Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY,          i, Q931Pie_LLComp,        Q931Uie_LLComp);
 126         Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY,         i, Q931Pie_HLComp,        Q931Uie_HLComp);
 127         Q931SetIEProc(Q931ie_USER_USER,                        i, Q931Pie_UserUser,      Q931Uie_UserUser);
 128         Q931SetIEProc(Q931ie_GENERIC_DIGITS,                   i, Q931Pie_GenericDigits, Q931Uie_GenericDigits);
 129 
 130         /* The following define a state machine. The point is that the Message  */
 131         /* procs can when search this to find out if the message/state                  */
 132         /* combination is legale. If not, the proc for unexpected message apply.*/
 133 
 134         /* State 0 Idle */
 135         Q931AddStateEntry(i, Q931_U0, Q931mes_RESUME,           2);
 136         Q931AddStateEntry(i, Q931_U0, Q931mes_SETUP,            4);
 137         Q931AddStateEntry(i, Q931_U0, Q931mes_SETUP,            2);
 138         Q931AddStateEntry(i, Q931_U0, Q931mes_STATUS,           4);
 139         Q931AddStateEntry(i, Q931_U0, Q931mes_RELEASE,          4);
 140         Q931AddStateEntry(i, Q931_U0, Q931mes_RELEASE_COMPLETE, 4);
 141 
 142         /* State 1 Call Initiating */
 143         Q931AddStateEntry(i, Q931_U1, Q931mes_DISCONNECT,        2);
 144         Q931AddStateEntry(i, Q931_U1, Q931mes_SETUP_ACKNOWLEDGE, 4);
 145         Q931AddStateEntry(i, Q931_U1, Q931mes_RELEASE_COMPLETE,  4);
 146         Q931AddStateEntry(i, Q931_U1, Q931mes_CALL_PROCEEDING,   4);
 147         Q931AddStateEntry(i, Q931_U1, Q931mes_ALERTING,          4);
 148         Q931AddStateEntry(i, Q931_U1, Q931mes_CONNECT,           4);
 149 
 150         /* State 2 Overlap Sending */
 151         Q931AddStateEntry(i, Q931_U2, Q931mes_INFORMATION,     2);
 152         Q931AddStateEntry(i, Q931_U2, Q931mes_CALL_PROCEEDING, 4);
 153         Q931AddStateEntry(i, Q931_U2, Q931mes_ALERTING,        4);
 154         Q931AddStateEntry(i, Q931_U2, Q931mes_PROGRESS,        4);
 155         Q931AddStateEntry(i, Q931_U2, Q931mes_CONNECT,         4);
 156         Q931AddStateEntry(i, Q931_U2, Q931mes_RELEASE,         2);
 157 
 158         /* State 3 Outgoing Call Proceeding */
 159         Q931AddStateEntry(i, Q931_U3, Q931mes_PROGRESS, 4);
 160         Q931AddStateEntry(i, Q931_U3, Q931mes_ALERTING, 4);
 161         Q931AddStateEntry(i, Q931_U3, Q931mes_CONNECT,  4);
 162         Q931AddStateEntry(i, Q931_U3, Q931mes_RELEASE,  2);
 163 
 164         /* State 4 Call Delivered */
 165         Q931AddStateEntry(i, Q931_U4, Q931mes_CONNECT, 4);
 166 
 167         /* State 6 Call Precent */
 168         Q931AddStateEntry(i, Q931_U6, Q931mes_INFORMATION,      2);     
 169         Q931AddStateEntry(i, Q931_U6, Q931mes_ALERTING,         2);     
 170         Q931AddStateEntry(i, Q931_U6, Q931mes_CALL_PROCEEDING,  2);     
 171         Q931AddStateEntry(i, Q931_U6, Q931mes_CONNECT,          2);     
 172         Q931AddStateEntry(i, Q931_U6, Q931mes_RELEASE_COMPLETE, 2);     
 173         Q931AddStateEntry(i, Q931_U6, Q931mes_RELEASE,          4);     
 174         Q931AddStateEntry(i, Q931_U6, Q931mes_DISCONNECT,       4);     
 175 
 176         /* State 7 Call Received */
 177         Q931AddStateEntry(i, Q931_U7, Q931mes_CONNECT, 2);
 178 
 179         /* State 8 Connect request */
 180         Q931AddStateEntry(i, Q931_U8, Q931mes_CONNECT_ACKNOWLEDGE, 4);
 181 
 182         /* State 9 Incoming Call Proceeding */
 183         Q931AddStateEntry(i, Q931_U9, Q931mes_CONNECT,  2);
 184         Q931AddStateEntry(i, Q931_U9, Q931mes_ALERTING, 2);
 185         Q931AddStateEntry(i, Q931_U9, Q931mes_PROGRESS, 2);
 186 
 187         /* State 10 Active */
 188         Q931AddStateEntry(i, Q931_U10, Q931mes_SUSPEND, 2);
 189         Q931AddStateEntry(i, Q931_U10, Q931mes_NOTIFY,  4);
 190         Q931AddStateEntry(i, Q931_U10, Q931mes_NOTIFY,  2);
 191 
 192         /* State 11 Disconnect Request */
 193         Q931AddStateEntry(i, Q931_U11, Q931mes_RELEASE,    4);
 194         Q931AddStateEntry(i, Q931_U11, Q931mes_DISCONNECT, 4);
 195         Q931AddStateEntry(i, Q931_U11, Q931mes_NOTIFY,     4);
 196 
 197         /* State 12 Disconnect Ind */
 198         Q931AddStateEntry(i, Q931_U12, Q931mes_RELEASE, 4);
 199         Q931AddStateEntry(i, Q931_U12, Q931mes_RELEASE, 2);
 200 
 201         /* State 15 Suspend Request */
 202         Q931AddStateEntry(i, Q931_U15, Q931mes_SUSPEND_ACKNOWLEDGE, 4);
 203         Q931AddStateEntry(i, Q931_U15, Q931mes_SUSPEND_REJECT,      4);
 204         Q931AddStateEntry(i, Q931_U15, Q931mes_DISCONNECT,          4);
 205         Q931AddStateEntry(i, Q931_U15, Q931mes_RELEASE,             4);
 206 
 207 /* TODO
 208         Q931AddStateEntry(i, Q931_U17,
 209         Q931AddStateEntry(i, Q931_U19,
 210         Q931AddStateEntry(i, Q931_U25,
 211 */
 212 }
 213 
 214 /*****************************************************************************
 215 
 216   Function:             DMSProc0x0fTE
 217 
 218 *****************************************************************************/
 219 L3INT DMSProc0x0fTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom)
 220 {
 221         Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace];
 222         L3INT callIndex;
 223         L3INT ret = Q931E_NO_ERROR;
 224 
 225         if (pMes->ProtDisc == 8) {
 226                 /* Find the call using CRV */
 227                 ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex);
 228                 if (ret != Q931E_NO_ERROR)
 229                         return ret;
 230 
 231                 /* TODO chack against state table for illegal or unexpected message here*/
 232 
 233                 /* TODO - Set correct timer here */
 234                 Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303);
 235         }
 236         if (iFrom == 4) {
 237                 /* TODO Add proc here*/
 238                 ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size);
 239         }
 240         else if (iFrom == 2) {
 241                 /* TODO Add proc here*/
 242                 ret = Q931Tx34(pTrunk, buf, pMes->Size);
 243 
 244                 if (pMes->ProtDisc == 3 && pTrunk->autoServiceAck) {
 245                         Q931AckService(pTrunk, buf);
 246                 }
 247         }
 248         return ret;
 249 
 250 }
 251 
 252 /*****************************************************************************
 253 
 254   Function:             DMSProc0x07TE
 255 
 256 *****************************************************************************/
 257 L3INT DMSProc0x07TE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom)
 258 {
 259         Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace];
 260         L3INT callIndex;
 261         L3INT ret = Q931E_NO_ERROR;
 262 
 263         if (pMes->ProtDisc == 8) {
 264                 /* Find the call using CRV */
 265                 ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex);
 266                 if (ret != Q931E_NO_ERROR)
 267                         return ret;
 268 
 269                 /* TODO chack against state table for illegal or unexpected message here*/
 270 
 271                 /* TODO - Set correct timer here */
 272                 Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303);
 273         }
 274         if (iFrom == 4) {
 275                 /* TODO Add proc here*/
 276                 ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size);
 277         }
 278         else if (iFrom == 2) {
 279                 /* TODO Add proc here*/
 280                 ret = Q931Tx34(pTrunk, buf, pMes->Size);
 281         }
 282         return ret;
 283 
 284 }

/* [<][>][^][v][top][bottom][index][help] */