root/src/isdn/nationalStateTE.c

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

DEFINITIONS

This source file includes following definitions.
  1. nationalCreateTE

   1 /*****************************************************************************
   2 
   3   FileName:             nationalStateTE.c
   4 
   5   Contents:             National 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 "national.h"
  55 extern L3INT Q931L4HeaderSpace;
  56 
  57 /*****************************************************************************
  58   Function:             nationalCreateTE
  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 nationalCreateTE(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,             nationalUmes_Setup,         nationalPmes_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         Q931SetIEProc(Q931ie_CONNECTED_NUMBER, i, Q931Pie_Generic, Q931Uie_Generic);
 131         Q931SetIEProc(Q931ie_FACILITY,         i, Q931Pie_Generic, Q931Uie_Generic);
 132         Q931SetIEProc(Q931ie_REDIRECTING_NUMBER, i, Q931Pie_Generic, Q931Uie_Generic);
 133 
 134         /* The following define a state machine. The point is that the Message
 135          * procs can when search this to find out if the message/state
 136          * combination is legale. If not, the proc for unexpected message apply.
 137          */
 138 
 139         /* State 0 Idle */
 140         Q931AddStateEntry(i, Q931_U0, Q931mes_RESUME,           2);
 141         Q931AddStateEntry(i, Q931_U0, Q931mes_SETUP,            4);
 142         Q931AddStateEntry(i, Q931_U0, Q931mes_SETUP,            2);
 143         Q931AddStateEntry(i, Q931_U0, Q931mes_STATUS,           4);
 144         Q931AddStateEntry(i, Q931_U0, Q931mes_RELEASE,          4);
 145         Q931AddStateEntry(i, Q931_U0, Q931mes_RELEASE_COMPLETE, 4);
 146 
 147         /* State 1 Call Initiating */
 148         Q931AddStateEntry(i, Q931_U1, Q931mes_DISCONNECT,        2);
 149         Q931AddStateEntry(i, Q931_U1, Q931mes_SETUP_ACKNOWLEDGE, 4);
 150         Q931AddStateEntry(i, Q931_U1, Q931mes_RELEASE_COMPLETE,  4);
 151         Q931AddStateEntry(i, Q931_U1, Q931mes_CALL_PROCEEDING,   4);
 152         Q931AddStateEntry(i, Q931_U1, Q931mes_ALERTING,          4);
 153         Q931AddStateEntry(i, Q931_U1, Q931mes_CONNECT,           4);
 154 
 155         /* State 2 Overlap Sending */
 156         Q931AddStateEntry(i, Q931_U2, Q931mes_INFORMATION,     2);
 157         Q931AddStateEntry(i, Q931_U2, Q931mes_CALL_PROCEEDING, 4);
 158         Q931AddStateEntry(i, Q931_U2, Q931mes_ALERTING,        4);
 159         Q931AddStateEntry(i, Q931_U2, Q931mes_PROGRESS,        4);
 160         Q931AddStateEntry(i, Q931_U2, Q931mes_CONNECT,         4);
 161         Q931AddStateEntry(i, Q931_U2, Q931mes_RELEASE,         2);
 162 
 163         /* State 3 Outgoing Call Proceeding */
 164         Q931AddStateEntry(i, Q931_U3, Q931mes_PROGRESS, 4);
 165         Q931AddStateEntry(i, Q931_U3, Q931mes_ALERTING, 4);
 166         Q931AddStateEntry(i, Q931_U3, Q931mes_CONNECT,  4);
 167         Q931AddStateEntry(i, Q931_U3, Q931mes_RELEASE,  2);
 168 
 169         /* State 4 Call Delivered */
 170         Q931AddStateEntry(i, Q931_U4, Q931mes_CONNECT, 4);
 171 
 172         /* State 6 Call Precent */
 173         Q931AddStateEntry(i, Q931_U6, Q931mes_INFORMATION,      2);     
 174         Q931AddStateEntry(i, Q931_U6, Q931mes_ALERTING,         2);     
 175         Q931AddStateEntry(i, Q931_U6, Q931mes_CALL_PROCEEDING,  2);     
 176         Q931AddStateEntry(i, Q931_U6, Q931mes_CONNECT,          2);     
 177         Q931AddStateEntry(i, Q931_U6, Q931mes_RELEASE_COMPLETE, 2);     
 178         Q931AddStateEntry(i, Q931_U6, Q931mes_RELEASE,          4);     
 179         Q931AddStateEntry(i, Q931_U6, Q931mes_DISCONNECT,       4);     
 180 
 181         /* State 7 Call Received */
 182         Q931AddStateEntry(i, Q931_U7, Q931mes_CONNECT, 2);
 183 
 184         /* State 8 Connect request */
 185         Q931AddStateEntry(i, Q931_U8, Q931mes_CONNECT_ACKNOWLEDGE, 4);
 186 
 187         /* State 9 Incoming Call Proceeding */
 188         Q931AddStateEntry(i, Q931_U9, Q931mes_CONNECT,  2);
 189         Q931AddStateEntry(i, Q931_U9, Q931mes_ALERTING, 2);
 190         Q931AddStateEntry(i, Q931_U9, Q931mes_PROGRESS, 2);
 191 
 192         /* State 10 Active */
 193         Q931AddStateEntry(i, Q931_U10, Q931mes_SUSPEND, 2);
 194         Q931AddStateEntry(i, Q931_U10, Q931mes_NOTIFY,  4);
 195         Q931AddStateEntry(i, Q931_U10, Q931mes_NOTIFY,  2);
 196 
 197         /* State 11 Disconnect Request */
 198         Q931AddStateEntry(i, Q931_U11, Q931mes_RELEASE,    4);
 199         Q931AddStateEntry(i, Q931_U11, Q931mes_DISCONNECT, 4);
 200         Q931AddStateEntry(i, Q931_U11, Q931mes_NOTIFY,     4);
 201 
 202         /* State 12 Disconnect Ind */
 203         Q931AddStateEntry(i, Q931_U12, Q931mes_RELEASE, 4);
 204         Q931AddStateEntry(i, Q931_U12, Q931mes_RELEASE, 2);
 205 
 206         /* State 15 Suspend Request */
 207         Q931AddStateEntry(i, Q931_U15, Q931mes_SUSPEND_ACKNOWLEDGE, 4);
 208         Q931AddStateEntry(i, Q931_U15, Q931mes_SUSPEND_REJECT,      4);
 209         Q931AddStateEntry(i, Q931_U15, Q931mes_DISCONNECT,          4);
 210         Q931AddStateEntry(i, Q931_U15, Q931mes_RELEASE,             4);
 211 
 212 /* TODO
 213         Q931AddStateEntry(i, Q931_U17,
 214         Q931AddStateEntry(i, Q931_U19,
 215         Q931AddStateEntry(i, Q931_U25,
 216 */
 217 }

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