root/src/isdn/5ESSStateTE.c

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

DEFINITIONS

This source file includes following definitions.
  1. ATT5ESSCreateTE
  2. ATT5ESSProc0x0fTE
  3. ATT5ESSProc0x07TE

   1 /*****************************************************************************

   2 

   3   FileName:     5ESSStateTE.c

   4 

   5   Contents:     AT&T 5ESS 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   Copyright (c) 2007, Michael S. Collins, All rights reserved.

  29   email:mcollins@fcnetwork.com

  30   

  31   Redistribution and use in source and binary forms, with or without 

  32   modification, are permitted provided that the following conditions are 

  33   met:

  34 

  35         * Redistributions of source code must retain the above copyright notice, 

  36         this list of conditions and the following disclaimer.

  37         * Redistributions in binary form must reproduce the above copyright notice, 

  38         this list of conditions and the following disclaimer in the documentation 

  39         and/or other materials provided with the distribution.

  40         * Neither the name of the Case Labs, Ltd nor the names of its contributors 

  41         may be used to endorse or promote products derived from this software 

  42         without specific prior written permission.

  43 

  44   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 

  45   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 

  46   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 

  47   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 

  48   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 

  49   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 

  50   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 

  51   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 

  52   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 

  53   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 

  54   POSSIBILITY OF SUCH DAMAGE.

  55 *****************************************************************************/
  56 
  57 #include "5ESS.h"
  58 extern L3INT Q931L4HeaderSpace;
  59 
  60 /*****************************************************************************

  61   Function:     ATT5ESSCreateTE

  62 

  63   Description:  Will create the AT&T 5ESS TE as a Dialect in the stack. The first

  64                     bulk set up the message handlers, the second bulk the IE

  65                     encoders/coders, and the last bulk set up the state table.

  66 

  67   Parameters:   i       Dialect index

  68 *****************************************************************************/
  69 void ATT5ESSCreateTE(L3UCHAR i)
  70 {
  71         Q931SetMesProc(Q931mes_ALERTING,             i, Q931ProcAlertingTE,          Q931Umes_Alerting,          Q931Pmes_Alerting);
  72         Q931SetMesProc(Q931mes_CALL_PROCEEDING,      i, Q931ProcCallProceedingTE,    Q931Umes_CallProceeding,    Q931Pmes_CallProceeding);
  73         Q931SetMesProc(Q931mes_CONNECT,              i, ATT5ESSProc0x07TE,           ATT5ESSUmes_0x07,           ATT5ESSPmes_0x07);
  74         Q931SetMesProc(Q931mes_CONNECT_ACKNOWLEDGE,  i, ATT5ESSProc0x0fTE,           ATT5ESSUmes_0x0f,           ATT5ESSPmes_0x0f);
  75         Q931SetMesProc(Q931mes_PROGRESS,             i, Q931ProcProgressTE,          Q931Umes_Progress,          Q931Pmes_Progress);
  76         Q931SetMesProc(Q931mes_SETUP,                i, Q931ProcSetupTE,             ATT5ESSUmes_Setup,          ATT5ESSPmes_Setup);
  77         Q931SetMesProc(Q931mes_SETUP_ACKNOWLEDGE,    i, Q931ProcSetupAckTE,          Q931Umes_SetupAck,          Q931Pmes_SetupAck);
  78         Q931SetMesProc(Q931mes_RESUME,               i, Q931ProcResumeTE,            Q931Umes_Resume,            Q931Pmes_Resume);
  79         Q931SetMesProc(Q931mes_RESUME_ACKNOWLEDGE,   i, Q931ProcResumeAckTE,         Q931Umes_ResumeAck,         Q931Pmes_ResumeAck);
  80         Q931SetMesProc(Q931mes_RESUME_REJECT,        i, Q931ProcResumeRejectTE,      Q931Umes_ResumeReject,      Q931Pmes_ResumeReject);
  81         Q931SetMesProc(Q931mes_SUSPEND,              i, Q931ProcSuspendTE,           Q931Umes_Suspend,           Q931Pmes_Suspend);
  82         Q931SetMesProc(Q931mes_SUSPEND_ACKNOWLEDGE,  i, Q931ProcSuspendAckTE,        Q931Umes_SuspendAck,        Q931Pmes_SuspendAck);
  83         Q931SetMesProc(Q931mes_SUSPEND_REJECT,       i, Q931ProcSuspendRejectTE,     Q931Umes_SuspendReject,     Q931Pmes_SuspendReject);
  84         Q931SetMesProc(Q931mes_USER_INFORMATION,     i, Q931ProcUserInformationTE,   Q931Umes_UserInformation,   Q931Pmes_UserInformation);
  85         Q931SetMesProc(Q931mes_DISCONNECT,           i, Q931ProcDisconnectTE,        Q931Umes_Disconnect,        Q931Pmes_Disconnect);
  86         Q931SetMesProc(Q931mes_RELEASE,              i, Q931ProcReleaseTE,           Q931Umes_Release,           Q931Pmes_Release);
  87         Q931SetMesProc(Q931mes_RELEASE_COMPLETE,     i, Q931ProcReleaseCompleteTE,   Q931Umes_ReleaseComplete,   Q931Pmes_ReleaseComplete);
  88         Q931SetMesProc(Q931mes_RESTART,              i, Q931ProcRestartTE,           Q931Umes_Restart,           Q931Pmes_Restart);
  89         Q931SetMesProc(Q931mes_RESTART_ACKNOWLEDGE,  i, Q931ProcRestartAckTE,        Q931Umes_RestartAck,        Q931Pmes_RestartAck);
  90         Q931SetMesProc(Q931mes_CONGESTION_CONTROL,   i, Q931ProcCongestionControlTE, Q931Umes_CongestionControl, Q931Pmes_CongestionControl);
  91         Q931SetMesProc(Q931mes_INFORMATION,          i, Q931ProcInformationTE,       Q931Umes_Information,       Q931Pmes_Information);
  92         Q931SetMesProc(Q931mes_NOTIFY,               i, Q931ProcNotifyTE,            Q931Umes_Notify,            Q931Pmes_Notify);
  93         Q931SetMesProc(Q931mes_STATUS,               i, Q931ProcStatusTE,            Q931Umes_Status,            Q931Pmes_Status);
  94         Q931SetMesProc(Q931mes_STATUS_ENQUIRY,       i, Q931ProcStatusEnquiryTE,     Q931Umes_StatusEnquiry,     Q931Pmes_StatusEnquiry);
  95         Q931SetMesProc(Q931mes_SEGMENT,              i, Q931ProcSegmentTE,           Q931Umes_Segment,           Q931Pmes_Segment);
  96 
  97         Q931SetMesProc(Q932mes_FACILITY,             i, Q932ProcFacilityTE,          Q932Umes_Facility,          Q932Pmes_Facility);
  98         Q931SetMesProc(Q932mes_HOLD,                 i, Q932ProcHoldTE,              Q932Umes_Hold,              Q932Pmes_Hold);
  99         Q931SetMesProc(Q932mes_HOLD_ACKNOWLEDGE,     i, Q932ProcHoldAckTE,           Q932Umes_HoldAck,           Q932Pmes_HoldAck);
 100         Q931SetMesProc(Q932mes_HOLD_REJECT,          i, Q932ProcHoldRejectTE,        Q932Umes_HoldReject,        Q932Pmes_HoldReject);
 101         Q931SetMesProc(Q932mes_REGISTER,             i, Q932ProcRegisterTE,          Q932Umes_Register,          Q932Pmes_Register);
 102         Q931SetMesProc(Q932mes_RETRIEVE,             i, Q932ProcRetrieveTE,          Q932Umes_Retrieve,          Q932Pmes_Retrieve);
 103         Q931SetMesProc(Q932mes_RETRIEVE_ACKNOWLEDGE, i, Q932ProcRetrieveAckTE,       Q932Umes_RetrieveAck,       Q932Pmes_RetrieveAck);
 104         Q931SetMesProc(Q932mes_RETRIEVE_REJECT,      i, Q932ProcRetrieveRejectTE,    Q932Umes_RetrieveReject,    Q932Pmes_RetrieveReject);
 105 
 106         /* Set up the IE encoder/decoder handle table.*/ 
 107         Q931SetIEProc(Q931ie_SEGMENTED_MESSAGE,                i, Q931Pie_Segment,           Q931Uie_Segment);
 108         Q931SetIEProc(Q931ie_BEARER_CAPABILITY,                i, Q931Pie_BearerCap,         Q931Uie_BearerCap);
 109         Q931SetIEProc(Q931ie_CAUSE,                            i, Q931Pie_Cause,             Q931Uie_Cause);
 110         Q931SetIEProc(Q931ie_CALL_IDENTITY,                    i, Q931Pie_CallID,            Q931Uie_CallID);
 111         Q931SetIEProc(Q931ie_CALL_STATE,                       i, Q931Pie_CallState,         Q931Uie_CallState);
 112         Q931SetIEProc(Q931ie_CHANGE_STATUS,                    i, Q931Pie_ChangeStatus,      Q931Uie_ChangeStatus);
 113         Q931SetIEProc(Q931ie_CHANNEL_IDENTIFICATION,           i, Q931Pie_ChanID,            Q931Uie_ChanID);
 114         Q931SetIEProc(Q931ie_PROGRESS_INDICATOR,               i, Q931Pie_ProgInd,           Q931Uie_ProgInd);
 115         Q931SetIEProc(Q931ie_NETWORK_SPECIFIC_FACILITIES,      i, Q931Pie_NetFac,            Q931Uie_NetFac);
 116         Q931SetIEProc(Q931ie_NOTIFICATION_INDICATOR,           i, Q931Pie_NotifInd,          Q931Uie_NotifInd);
 117         Q931SetIEProc(Q931ie_DISPLAY,                          i, Q931Pie_Display,           Q931Uie_Display);
 118         Q931SetIEProc(Q931ie_DATETIME,                         i, Q931Pie_DateTime,          Q931Uie_DateTime);
 119         Q931SetIEProc(Q931ie_KEYPAD_FACILITY,                  i, Q931Pie_KeypadFac,         Q931Uie_KeypadFac);
 120         Q931SetIEProc(Q931ie_SIGNAL,                           i, Q931Pie_Signal,            Q931Uie_Signal);
 121         Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND,  i, Q931Pie_TransNetSel,       Q931Uie_TransNetSel);
 122         Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER,             i, Q931Pie_CallingNum,        Q931Uie_CallingNum);
 123         Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS,         i, Q931Pie_CallingSub,        Q931Uie_CallingSub);
 124         Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER,              i, Q931Pie_CalledNum,         Q931Uie_CalledNum);
 125         Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS,          i, Q931Pie_CalledSub,         Q931Uie_CalledSub);
 126         Q931SetIEProc(Q931ie_TRANSIT_NETWORK_SELECTION,        i, Q931Pie_TransNetSel,       Q931Uie_TransNetSel);
 127         Q931SetIEProc(Q931ie_RESTART_INDICATOR,                i, Q931Pie_RestartInd,        Q931Uie_RestartInd);
 128         Q931SetIEProc(Q931ie_LOW_LAYER_COMPATIBILITY,          i, Q931Pie_LLComp,            Q931Uie_LLComp);
 129         Q931SetIEProc(Q931ie_HIGH_LAYER_COMPATIBILITY,         i, Q931Pie_HLComp,            Q931Uie_HLComp);
 130         Q931SetIEProc(Q931ie_USER_USER,                        i, Q931Pie_UserUser,          Q931Uie_UserUser);
 131         Q931SetIEProc(Q931ie_GENERIC_DIGITS,                   i, Q931Pie_GenericDigits,     Q931Uie_GenericDigits);
 132 
 133         Q931SetIEProc(Q931ie_CONNECTED_NUMBER, i, Q931Pie_Generic, Q931Uie_Generic);
 134         Q931SetIEProc(Q931ie_FACILITY,         i, Q931Pie_Generic, Q931Uie_Generic);
 135 
 136         /* The following define a state machine. The point is that the Message  */
 137         /* procs can when search this to find out if the message/state          */
 138         /* combination is legale. If not, the proc for unexpected message apply.*/
 139 
 140         /* State 0 Idle */
 141         Q931AddStateEntry(i, Q931_U0,    Q931mes_RESUME,             2);
 142         Q931AddStateEntry(i, Q931_U0,    Q931mes_SETUP,              4);
 143         Q931AddStateEntry(i, Q931_U0,    Q931mes_SETUP,              2);
 144         Q931AddStateEntry(i, Q931_U0,    Q931mes_STATUS,             4);
 145         Q931AddStateEntry(i, Q931_U0,    Q931mes_RELEASE,            4);
 146         Q931AddStateEntry(i, Q931_U0,    Q931mes_RELEASE_COMPLETE,   4);
 147 
 148         /* State 1 Call Initiating */
 149         Q931AddStateEntry(i, Q931_U1,    Q931mes_DISCONNECT,         2);
 150         Q931AddStateEntry(i, Q931_U1,    Q931mes_SETUP_ACKNOWLEDGE,  4);
 151         Q931AddStateEntry(i, Q931_U1,    Q931mes_RELEASE_COMPLETE,   4);
 152         Q931AddStateEntry(i, Q931_U1,    Q931mes_CALL_PROCEEDING,    4);
 153         Q931AddStateEntry(i, Q931_U1,    Q931mes_ALERTING,           4);
 154         Q931AddStateEntry(i, Q931_U1,    Q931mes_CONNECT,            4);
 155 
 156         /* State 2 Overlap Sending */
 157         Q931AddStateEntry(i, Q931_U2,    Q931mes_INFORMATION,        2);
 158         Q931AddStateEntry(i, Q931_U2,    Q931mes_CALL_PROCEEDING,    4);
 159         Q931AddStateEntry(i, Q931_U2,    Q931mes_ALERTING,           4);
 160         Q931AddStateEntry(i, Q931_U2,    Q931mes_PROGRESS,           4);
 161         Q931AddStateEntry(i, Q931_U2,    Q931mes_CONNECT,            4);
 162         Q931AddStateEntry(i, Q931_U2,    Q931mes_RELEASE,            2);
 163 
 164         /* State 3 Outgoing Call Proceeding */
 165         Q931AddStateEntry(i, Q931_U3,    Q931mes_PROGRESS,           4);
 166         Q931AddStateEntry(i, Q931_U3,    Q931mes_ALERTING,           4);
 167         Q931AddStateEntry(i, Q931_U3,    Q931mes_CONNECT,            4);
 168         Q931AddStateEntry(i, Q931_U3,    Q931mes_RELEASE,            2);
 169 
 170         /* State 4 Call Delivered */
 171         Q931AddStateEntry(i, Q931_U4,    Q931mes_CONNECT,            4);
 172 
 173         /* State 6 Call Precent */
 174         Q931AddStateEntry(i, Q931_U6,    Q931mes_INFORMATION,        2);
 175         Q931AddStateEntry(i, Q931_U6,    Q931mes_ALERTING,           2);
 176         Q931AddStateEntry(i, Q931_U6,    Q931mes_CALL_PROCEEDING,    2);
 177         Q931AddStateEntry(i, Q931_U6,    Q931mes_CONNECT,            2);
 178         Q931AddStateEntry(i, Q931_U6,    Q931mes_RELEASE_COMPLETE,   2);
 179         Q931AddStateEntry(i, Q931_U6,    Q931mes_RELEASE,            4);
 180         Q931AddStateEntry(i, Q931_U6,    Q931mes_DISCONNECT,         4);
 181 
 182         /* State 7 Call Received */
 183         Q931AddStateEntry(i, Q931_U7,    Q931mes_CONNECT,            2);
 184 
 185         /* State 8 Connect request */
 186         Q931AddStateEntry(i, Q931_U8,    Q931mes_CONNECT_ACKNOWLEDGE, 4);
 187 
 188         /* State 9 Incoming Call Proceeding */
 189         Q931AddStateEntry(i, Q931_U9,    Q931mes_CONNECT,            2);
 190         Q931AddStateEntry(i, Q931_U9,    Q931mes_ALERTING,           2);
 191         Q931AddStateEntry(i, Q931_U9,    Q931mes_PROGRESS,           2);
 192 
 193         /* State 10 Active */
 194         Q931AddStateEntry(i, Q931_U10,   Q931mes_SUSPEND,            2);
 195         Q931AddStateEntry(i, Q931_U10,   Q931mes_NOTIFY,             4);
 196         Q931AddStateEntry(i, Q931_U10,   Q931mes_NOTIFY,             2);
 197 
 198         /* State 11 Disconnect Request */
 199         Q931AddStateEntry(i, Q931_U11,   Q931mes_RELEASE,            4);
 200         Q931AddStateEntry(i, Q931_U11,   Q931mes_DISCONNECT,         4);
 201         Q931AddStateEntry(i, Q931_U11,   Q931mes_NOTIFY,             4);
 202 
 203         /* State 12 Disconnect Ind */
 204         Q931AddStateEntry(i, Q931_U12,   Q931mes_RELEASE,            4);
 205         Q931AddStateEntry(i, Q931_U12,   Q931mes_RELEASE,            2);
 206 
 207         /* State 15 Suspend Request */
 208         Q931AddStateEntry(i, Q931_U15,   Q931mes_SUSPEND_ACKNOWLEDGE, 4);
 209         Q931AddStateEntry(i, Q931_U15,   Q931mes_SUSPEND_REJECT,      4);
 210         Q931AddStateEntry(i, Q931_U15,   Q931mes_DISCONNECT,          4);
 211         Q931AddStateEntry(i, Q931_U15,   Q931mes_RELEASE,             4);
 212 
 213 /* TODO

 214         Q931AddStateEntry(i, Q931_U17, 

 215         Q931AddStateEntry(i, Q931_U19, 

 216         Q931AddStateEntry(i, Q931_U25, 

 217 */
 218 }
 219 
 220 /*****************************************************************************

 221 

 222   Function:             ATT5ESSProc0x0fTE

 223 

 224 *****************************************************************************/
 225 L3INT ATT5ESSProc0x0fTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom)
 226 {
 227         Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace];
 228         L3INT callIndex;
 229         L3INT ret = Q931E_NO_ERROR;
 230 
 231         if (pMes->ProtDisc == 8) {
 232                 /* Find the call using CRV */
 233                 ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex);
 234                 if (ret != Q931E_NO_ERROR)
 235                         return ret;
 236 
 237                 /* TODO chack against state table for illegal or unexpected message here*/
 238 
 239                 /* TODO - Set correct timer here */
 240                 Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303);
 241         }
 242         if (iFrom == 4) {
 243                 /* TODO Add proc here*/
 244                 ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size);
 245         }
 246         else if (iFrom ==2) {
 247                 /* TODO Add proc here*/
 248                 ret = Q931Tx34(pTrunk, buf, pMes->Size);
 249 
 250                 if (pMes->ProtDisc == 3 && pTrunk->autoServiceAck) {
 251                         printf("autoServiceAck is on, responding to Service Req from network...\n");
 252                         Q931AckService(pTrunk, buf);
 253                 }
 254         }
 255         return ret;
 256 
 257 }
 258 
 259 /*****************************************************************************

 260 

 261   Function:             ATT5ESSProc0x07TE

 262 

 263 *****************************************************************************/
 264 L3INT ATT5ESSProc0x07TE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom)
 265 {
 266         Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace];
 267         L3INT callIndex;
 268         L3INT ret = Q931E_NO_ERROR;
 269 
 270         if (pMes->ProtDisc == 8) {
 271                 /* Find the call using CRV */
 272                 ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex);
 273                 if (ret != Q931E_NO_ERROR)
 274                         return ret;
 275 
 276                 /* TODO chack against state table for illegal or unexpected message here*/
 277 
 278                 /* TODO - Set correct timer here */
 279                 Q931StartTimer(pTrunk, callIndex, Q931_TIMER_T303);
 280         }
 281         if (iFrom == 4) {
 282                 /* TODO Add proc here*/
 283                 ret = Q931Tx32Data(pTrunk, 0, buf, pMes->Size);
 284         }
 285         else if (iFrom == 2) {
 286                 /* TODO Add proc here*/
 287                 ret = Q931Tx34(pTrunk, buf, pMes->Size);
 288         }
 289         return ret;
 290 
 291 }

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