Q931.h

Go to the documentation of this file.
00001 /******************************************************************************
00002 
00003   FileName:         Q931.h
00004 
00005   Contents:         Header and definition for the ITU-T Q.931 stack. The 
00006                     header contents the following parts:
00007 
00008                     - Definition of codes
00009                     - Definition of information elements (Q931ie_).
00010                     - Definition of messages (Q931mes_).
00011                     - Definitian of variables (var_).
00012                     - Function prototypes.
00013 
00014   Description:          The Q.931 stack provided here covers ITU-T Q.931 w/Q.932
00015                     supplementary services for both PRI, BRI and variants. 
00016                     The stack is generic and designed to deal with variants as
00017                     needed.
00018 
00019                     The stack uses the following interface functions:
00020 
00021                     - Q931Initialize    Initialize the Q.931 stack.
00022                     - Q931Rx23                  Receive a message from layer 2
00023                     - Q931Tx32                  Send a message to layer 2
00024                     - Q931Rx43                  Receive a message from layer 4 or above.
00025                     - Q931Tx34                  Send a message to layer 4 or above.
00026                     - Q931TimeTick              Periodical timer processing.
00027                     - Q931ErrorProc             Callback for stack error message.
00028 
00029                     The protocol is a module with no external dependencies and
00030                     can easely be ported to any operating system like Windows,
00031                     Linux, rtos and others.
00032 
00033   Related Files:        Q931.h                          Q.931 Definitions
00034                     Q931.c                              Q.931 Interface Functions.
00035                     Q931api.c                   Low level L4 API functions.
00036 
00037                     Q932.h                              Q.932 Suplementary Services
00038                     Q932mes.c                   Q.932 encoders/coders
00039 
00040                     Q931mes.c                   Q.931 Message encoders/coders
00041                     Q931ie.c                    Q.931 IE encoders/coders
00042                     Q931StateTE.c               Generic Q.931 TE State Engine
00043                     Q931StateNT.c               Generic Q.931 NT State Engine
00044 
00045   Design Note 1:        For each variant please add separate files starting with 
00046                     the variant short-name as follows:
00047 
00048                     <variant>.h                 Spesific headers needed.
00049                     <variant>mes.c              Message encoders/decores.
00050                     <variant>ie.c               IE encoders/decoders.
00051                     <variant>StateTE.c  TE side state engine.
00052                     <variant>StateNT.c  NT side state engine.
00053 
00054   Design Note 2:        The stack is deliberatly made non-threading. Use 1 
00055                     thread per Trunk, but lock access from the timertick
00056                     and rx, tx functions. And make sure the callbacks only
00057                     dump messages to a queue, no time-consuming processing
00058                     inside stack processing. 
00059 
00060                     All stack processing is async 'fire and forget', meaning
00061                     that there are not, and should not be any time-consuming
00062                     processing within the stack-time. The best way to thread 
00063                     a stack is to use one single thread that signal 5 queues.
00064                     
00065                     - Incoming L2 queue.
00066                     - Incoming L4 queue.
00067                     - Outgoing L2 queue.
00068                     - Outgoing L4 queue.
00069                     - Error/Trace queue.
00070 
00071   Design Note 3:        DSP optimization. The L3 (Rx23) can be called directly
00072                     from a HDLC receiver without usage of queues for optimized 
00073                     processing. But keep in mind that Q.931 calls Tx34 or Tx32 
00074                     as part     of receiving a message from Layer 2.
00075 
00076   License/Copyright:
00077 
00078   Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved.
00079   email:janvb@caselaboratories.com  
00080 
00081   Redistribution and use in source and binary forms, with or without 
00082   modification, are permitted provided that the following conditions are 
00083   met:
00084 
00085     * Redistributions of source code must retain the above copyright notice, 
00086           this list of conditions and the following disclaimer.
00087     * Redistributions in binary form must reproduce the above copyright notice, 
00088           this list of conditions and the following disclaimer in the documentation 
00089           and/or other materials provided with the distribution.
00090     * Neither the name of the Case Labs, Ltd nor the names of its contributors 
00091           may be used to endorse or promote products derived from this software 
00092           without specific prior written permission.
00093 
00094   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
00095   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
00096   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
00097   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
00098   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
00099   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
00100   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
00101   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
00102   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
00103   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
00104   POSSIBILITY OF SUCH DAMAGE.
00105 ******************************************************************************/
00106 
00107 #ifndef _Q931_NL
00108 #define _Q931_NL
00109 
00110 #include <string.h>
00111 
00112 /*****************************************************************************
00113 
00114   Enum helper macros  <Need description of these macros>
00115 
00116 *****************************************************************************/
00117 #if 0
00118 #define Q931_ENUM_NAMES(_NAME, _STRINGS) static const char * _NAME [] = { _STRINGS , NULL };
00119 #define Q931_STR2ENUM_P(_FUNC1, _FUNC2, _TYPE) _TYPE _FUNC1 (const char *name); const char * _FUNC2 (_TYPE type);
00120 #define Q931_STR2ENUM(_FUNC1, _FUNC2, _TYPE, _STRINGS, _MAX)    \
00121         _TYPE _FUNC1 (const char *name)                                                         \
00122         {                                                                                                               \
00123                 int i;                                                                                          \
00124                 _TYPE t = _MAX ;                                                                        \
00125                                                                                                                         \
00126                 for (i = 0; i < _MAX ; i++) {                                           \
00127                         if (!strcasecmp(name, _STRINGS[i])) {                   \
00128                                 t = (_TYPE) i;                                                          \
00129                                 break;                                                                          \
00130                         }                                                                                               \
00131                 }                                                                                                       \
00132                                                                                                                         \
00133                 return t;                                                                                       \
00134         }                                                                                                               \
00135         const char * _FUNC2 (_TYPE type)                                                \
00136         {                                                                                                               \
00137                 if (type > _MAX) {                                                                      \
00138                         type = _MAX;                                                                    \
00139                 }                                                                                                       \
00140                 return _STRINGS[(int)type];                                                     \
00141         }                                                                                                               \
00142 #endif
00143 
00144 /*****************************************************************************
00145 
00146   Error Codes
00147 
00148 *****************************************************************************/
00149 /* hmmm... */
00150 typedef enum {
00151         Q931E_NO_ERROR              = 0,
00152 
00153         Q931E_UNKNOWN_MESSAGE       = -3001,
00154         Q931E_ILLEGAL_IE            = -3002,
00155         Q931E_UNKNOWN_IE            = -3003,
00156         Q931E_BEARERCAP             = -3004,
00157         Q931E_HLCOMP                = -3005,
00158         Q931E_LLCOMP                = -3006,
00159         Q931E_INTERNAL              = -3007,
00160         Q931E_MISSING_CB            = -3008,
00161         Q931E_UNEXPECTED_MESSAGE    = -3009,
00162         Q931E_ILLEGAL_MESSAGE       = -3010,
00163         Q931E_TOMANYCALLS           = -3011,
00164         Q931E_INVALID_CRV           = -3012,
00165         Q931E_CALLID                = -3013,
00166         Q931E_CALLSTATE             = -3014,
00167         Q931E_CALLEDSUB             = -3015,
00168         Q931E_CALLEDNUM             = -3016,
00169         Q931E_CALLINGNUM            = -3017,
00170         Q931E_CALLINGSUB            = -3018,
00171         Q931E_CAUSE                 = -3019,
00172         Q931E_CHANID                = -3020,
00173         Q931E_DATETIME              = -3021,
00174         Q931E_DISPLAY               = -3022,
00175         Q931E_KEYPADFAC             = -3023,
00176         Q931E_NETFAC                = -3024,
00177         Q931E_NOTIFIND              = -3025,
00178         Q931E_PROGIND               = -3026,
00179         Q931E_RESTARTIND            = -3027,
00180         Q931E_SEGMENT               = -3028,
00181         Q931E_SIGNAL                = -3029,
00182         Q931E_GENERIC_DIGITS        = -3030,
00183         Q931E_MANDATORY_IE_MISSING  = -3031,
00184         Q931E_UNRECOGNIZED_MESSAGE  = -3032,
00185 } q931_error_t;
00186 
00187 /* The q931_error_t enum should be kept in sync with the q931_error_names array in Q931.c */ 
00188 
00189 const char *q931_error_to_name(q931_error_t error);
00190 
00191 /*****************************************************************************
00192 
00193         Some speed optimization can be achieved by changing all variables to the 
00194         word size of your processor. A 32 bit processor has to do a lot of extra 
00195         work to read a packed 8 bit integer. Changing all fields to 32 bit integer 
00196         will result in usage of some extra space, but will speed up the stack.
00197 
00198         The stack has been designed to allow L3UCHAR etc. to be any size of 8 bit
00199         or larger.
00200 
00201 *****************************************************************************/
00202 /* public */
00203 #define L3CHAR   char                   /* Min 8 bit */
00204 #define L3UCHAR  unsigned char          /* Min 8 bit */
00205 #define L3USHORT unsigned short         /* Min 16 bit unsigned */
00206 #define L3UINT   unsigned int           /* Min 16 bit unsigned */
00207 #define L3INT    int                    /* Min 16 bit signed */
00208 #define L3ULONG  unsigned long          /* Min 32 bit */
00209 #define L3BOOL   char                   /* Min 1 bit, valuse 0 & 1 only */
00210 
00211 #define L3TRUE  1
00212 #define L3FALSE 0 
00213 
00214 /*****************************************************************************
00215 
00216   Global defines.
00217 
00218 *****************************************************************************/
00219 /* public */
00220 typedef L3USHORT ie;                /* Special data type to hold a dynamic  */
00221                                     /* or optional information element as   */
00222                                     /* part of a message struct. MSB = 1    */
00223                                     /* indicate that the ie is present, the */
00224                                     /* last 15 bits is an offset ( or the   */
00225                                     /* value for single octet ) to the      */
00226                                     /* struct holding the ie. Offset = 0    */
00227                                     /* is buf[1] etc.                       */
00228                                     /* ie == 0xffff indicates error         */
00229 
00230 /*****************************************************************************
00231         
00232         MAXTRUNKS sets how many physical trunks this system might have. This 
00233         number should be keept at a minimum since it will use global space.
00234 
00235         It is recommended that you leave MAXCHPERTRUNK as is
00236 
00237 *****************************************************************************/
00238 /* some probably private */
00239 #define Q931_LOGBUFSIZE 1024            /* size of logging buffer               */
00240 
00241 #define Q931L4BUF       1000            /* size of message buffer               */
00242 
00243 #define Q931L2BUF       300             /* size of message buffer               */
00244 
00245 #define Q931MAXTRUNKS   4               /* Total number of trunks that will be  */
00246                                         /* processed by this instance of the    */
00247                                         /* stack                                */
00248 
00249 #define Q931MAXCHPERTRUNK       32      /* Number of channels per trunk. The    */
00250                                         /* stack uses a static set of 32        */
00251                                         /* channels regardless if it is E1, T1  */
00252                                         /* or BRI that actually is used.        */
00253 
00254 #define Q931MAXCALLPERTRUNK     (Q931MAXCHPERTRUNK * 2)
00255                                         /* Number of max active CRV per trunk.  */
00256                                         /* Q.931 can have more calls than there */
00257                                         /* are channels.                        */
00258 
00259 /* private? */
00260 #define Q931_IS_BRI(x)          ((x)->TrunkType == Q931_TrType_BRI || (x)->TrunkType == Q931_TrType_BRI_PTMP)
00261 #define Q931_IS_PRI(x)          (!Q931_IS_BRI(x))
00262 
00263 #define Q931_IS_PTP(x)          ((x)->TrunkType != Q931_TrType_BRI_PTMP)
00264 #define Q931_IS_PTMP(X)         ((x)->TrunkType == Q931_TrType_BRI_PTMP)
00265 
00266 #define Q931_BRI_MAX_CRV        127
00267 #define Q931_PRI_MAX_CRV        32767
00268 
00269 /*****************************************************************************
00270 
00271   The following defines control the dialect switch tables and should only be
00272   changed when a new dialect needs to be inserted into the stack.   
00273 
00274   This stack uses an array of functions to know which function to call as   
00275   it receives a SETUP message etc. A new dialect can when choose to use
00276   the proc etc. for standard Q.931 or insert a modified proc.
00277 
00278   This technique has also been used to distinguish between user and network
00279   mode to make the code as easy to read and maintainable as possible.
00280 
00281   A message and IE index have been used to save space. These indexes allowes
00282   the message or IE code to be used directly and will give back a new index
00283   into the table.
00284 
00285 *****************************************************************************/
00286 
00287 /* WARNING! Initialize Q931CreateDialectCB[] will NULL when increasing the */
00288 /* Q931MAXDLCT value to avoid Q931Initialize from crashing if one entry is */
00289 /* not used.                                                               */
00290 #define Q931MAXDLCT     8       /* Max dialects included in this        */
00291                                 /* compile. User and Network count as   */
00292                                 /* one dialect each.                    */
00293 
00294 #define Q931MAXMES      128             /* Number of messages                           */
00295 #define Q931MAXIE       255             /* Number of IE                                 */
00296 #define Q931MAXUSEDIE   50              /* Maximum number of ie types per Dialect       */
00297 #define Q931MAXCODESETS 7               /* Maximum number of codests (by spec, 0-7)     */
00298 #define Q931MAXSTATE    100             /* Size of state tables                         */
00299 #define Q931MAXTIMER    25              /* Maximum number of timers                     */
00300 
00301 
00302 /*****************************************************************************
00303 
00304   Q.931 Message codes
00305   
00306 *****************************************************************************/
00307 /* goal: private */
00308 #define Q931mes_ALERTING             0x01 /* 0000 0001                   */        
00309 #define Q931mes_CALL_PROCEEDING      0x02 /* 0000 0010                   */
00310 #define Q931mes_CONNECT              0x07 /* 0000 0111                   */
00311 #define Q931mes_CONNECT_ACKNOWLEDGE  0x0f /* 0000 1111                   */
00312 #define Q931mes_PROGRESS             0x03 /* 0000 0011                   */
00313 #define Q931mes_SETUP                0x05 /* 0000 0101                   */
00314 #define Q931mes_SETUP_ACKNOWLEDGE    0x0d /* 0000 1101                   */
00315 #define Q931mes_RESUME               0x26 /* 0010 0110                   */
00316 #define Q931mes_RESUME_ACKNOWLEDGE   0x2e /* 0010 1110                   */
00317 #define Q931mes_RESUME_REJECT        0x22 /* 0010 0010                   */
00318 #define Q931mes_SUSPEND              0x25 /* 0010 0101                   */
00319 #define Q931mes_SUSPEND_ACKNOWLEDGE  0x2d /* 0010 1101                   */
00320 #define Q931mes_SUSPEND_REJECT       0x21 /* 0010 0001                   */
00321 #define Q931mes_USER_INFORMATION     0x20 /* 0010 0000                   */
00322 #define Q931mes_DISCONNECT           0x45 /* 0100 0101                   */
00323 #define Q931mes_RELEASE              0x4d /* 0100 1101                   */
00324 #define Q931mes_RELEASE_COMPLETE     0x5a /* 0101 1010                   */
00325 #define Q931mes_RESTART              0x46 /* 0100 0110                   */
00326 #define Q931mes_RESTART_ACKNOWLEDGE  0x4e /* 0100 1110                   */
00327 #define Q931mes_CONGESTION_CONTROL   0x79 /* 0111 1001                   */
00328 #define Q931mes_INFORMATION          0x7b /* 0111 1011                   */
00329 #define Q931mes_NOTIFY               0x6e /* 0110 1110                   */
00330 #define Q931mes_STATUS               0x7d /* 0111 1101                   */
00331 #define Q931mes_STATUS_ENQUIRY       0x75 /* 0111 0101                   */
00332 #define Q931mes_SEGMENT              0x60 /* 0110 0000                   */
00333 #define Q931mes_FACILITY             0x62 /* 0110 0010                   */
00334 
00335 /* AT&T 5ESS */
00336 #define Q931mes_SERVICE              0x0f /* 0000 1111  (ProtDisc 3)     */
00337 #define Q931mes_SERVICE_ACKNOWLEDGE  0x07 /* 0000 0111  (ProtDisc 3)     */
00338 
00339 #define Q931mes_FACILITY_ACKNOWLEDGE 0x6a /* 0110 1010                   */
00340 #define Q931mes_FACILITY_REJECT      0x72 /* 0111 0010                   */
00341 #define Q931mes_REGISTER             0x64 /* 0110 0100                   */
00342 
00343 #ifdef Q931PRIVATE
00344 
00347 enum {
00348         Q931_IEF_NONE        = 0,               
00349         Q931_IEF_MANDATORY   = (1 << 0),        
00351         /*
00352          * Direction of IE
00353          */
00354         Q931_IEF_TO_NET      = (1 << 14),       
00355         Q931_IEF_TO_USER     = (1 << 15),       
00356 };
00357 
00358 enum {
00359         /*
00360          * Codesets
00361          */
00362         Q931_IE_CODESET_0   = (1 << 0),         
00363         Q931_IE_CODESET_1   = (1 << 1),         
00364         Q931_IE_CODESET_2   = (1 << 2),         
00365         Q931_IE_CODESET_3   = (1 << 3),         
00366         Q931_IE_CODESET_4   = (1 << 4),         
00367         Q931_IE_CODESET_5   = (1 << 5),         
00368         Q931_IE_CODESET_6   = (1 << 6),         
00369         Q931_IE_CODESET_7   = (1 << 7),         
00370 };
00371 
00372 #define Q931_IEF_TO_BOTH    (Q931_IEF_TO_NET | Q931_IEF_TO_USER)
00373 #define Q931_IE_CODESET_ALL (Q931_IE_CODESET_0 | Q931_IE_CODESET_1 | Q931_IE_CODESET_2 | Q931_IE_CODESET_3 | Q931_IE_CODESET_4 | Q931_IE_CODESET_5 | Q931_IE_CODESET_6 | Q931_IE_CODESET_7)
00374 
00375 /*
00376  * TODO: better names...
00377  */
00378 struct Q931MessageIEEntry {
00379         L3UCHAR id;             
00380         L3UCHAR minsize;        
00381         L3UCHAR maxsize;        
00382         L3UCHAR codeset;        
00383         L3INT   flags;          
00384 };
00385 
00386 struct Q931MessageIE {
00387         L3UCHAR id;                                     
00388         L3UCHAR protdisc;                               
00389         struct Q931MessageIEEntry ies[Q931MAXIE];       
00390 };
00391 
00392 
00398 enum {
00399         MSGF_FROM_L2 = 2,
00400         MSGF_FROM_L4 = 4,
00401         MSGF_FROM_BOTH = 6,
00402 };
00403 #endif
00404 
00409 enum {
00410         Q931_TIMER_NONE = 0,
00411         Q931_TIMER_T300,                /* */
00412         Q931_TIMER_T301,
00413         Q931_TIMER_T302,
00414         Q931_TIMER_T303,
00415         Q931_TIMER_T304,
00416         Q931_TIMER_T305,
00417         Q931_TIMER_T306,
00418         Q931_TIMER_T307,
00419         Q931_TIMER_T308,
00420         Q931_TIMER_T309,
00421         Q931_TIMER_T310,
00422         Q931_TIMER_T311,
00423         Q931_TIMER_T312,
00424         Q931_TIMER_T313,
00425         Q931_TIMER_T314,
00426         Q931_TIMER_T315,
00427         Q931_TIMER_T316,
00428         Q931_TIMER_T317,
00429         Q931_TIMER_T318,
00430         Q931_TIMER_T319,
00431         Q931_TIMER_T320,
00432         Q931_TIMER_T321,
00433         Q931_TIMER_T322,
00434 };
00435 
00439 enum {
00440         Q931_TON_UNKNOWN                = 0x00,
00441         Q931_TON_INTERNATIONAL          = 0x01,
00442         Q931_TON_NATIONAL               = 0x02,
00443         Q931_TON_NETWORK_SPECIFIC       = 0x03,
00444         Q931_TON_SUBSCRIBER_NUMBER      = 0x04,
00445         Q931_TON_ABBREVIATED_NUMBER     = 0x06,
00446         Q931_TON_RESERVED               = 0x07
00447 };
00448 
00452 enum {
00453         Q931_NUMPLAN_UNKNOWN            = 0x00,
00454         Q931_NUMPLAN_E164               = 0x01,
00455         Q931_NUMPLAN_X121               = 0x03,
00456         Q931_NUMPLAN_F69                = 0x04,
00457         Q931_NUMPLAN_NATIONAL           = 0x08,
00458         Q931_NUMPLAN_PRIVATE            = 0x09,
00459         Q931_NUMPLAN_RESERVED           = 0x0e
00460 };
00461 
00465 enum {
00466         Q931_PRES_ALLOWED               = 0x00,
00467         Q931_PRES_RESTRICTED            = 0x01,
00468         Q931_PRES_NOT_AVAILABLE         = 0x02,
00469         Q931_PRES_RESERVED              = 0x03
00470 };
00471 
00475 enum {
00476         Q931_SCREEN_USER_NOT_SCREENED           = 0x00,
00477         Q931_SCREEN_USER_VERIFIED_PASSED        = 0x01,
00478         Q931_SCREEN_USER_VERIFIED_FAILED        = 0x02,
00479         Q931_SCREEN_NETWORK                     = 0x03
00480 };
00481 
00485 enum {
00486         Q931_CODING_ITU         = 0x00,
00487         Q931_CODING_ISO         = 0x01,
00488         Q931_CODING_NATIONAL    = 0x02,
00489         Q931_CODING_NETWORK     = 0x03
00490 };
00491 
00495 enum {
00496         Q931_HLCHAR_TELEPHONY   = 0x01,
00497         Q931_HLCHAR_FAX_G23     = 0x04,
00498         Q931_HLCHAR_FAX_G4      = 0x21,
00499         Q931_HLCHAR_FAX_G4II    = 0x24,
00500         Q931_HLCHAR_T102        = 0x32,
00501         Q931_HLCHAR_T101        = 0x33,
00502         Q931_HLCHAR_F60         = 0x35,
00503         Q931_HLCHAR_X400        = 0x38,
00504         Q931_HLCHAR_X200        = 0x41
00505 };
00506 
00510 enum {
00511         Q931_UIL1P_V110         = 0x01,
00512         Q931_UIL1P_I460         = 0x01,
00513         Q931_UIL1P_X30          = 0x01,
00514 
00515         Q931_UIL1P_G711U        = 0x02,
00516         Q931_UIL1P_G711A        = 0x03,
00517         Q931_UIL1P_G721         = 0x04,
00518 
00519         Q931_UIL1P_H221         = 0x05,
00520         Q931_UIL1P_H242         = 0x05,
00521 
00522         Q931_UIL1P_H223         = 0x06,
00523         Q931_UIL1P_H245         = 0x06,
00524 
00525         Q931_UIL1P_RATE_ADAP    = 0x07,
00526 
00527         Q931_UIL1P_V120         = 0x08,
00528         Q931_UIL1P_X31          = 0x09
00529 };
00530 
00534 enum {
00535         Q931_ITC_SPEECH                 = 0x00,
00536         Q931_ITC_UNRESTRICTED           = 0x08,
00537         Q931_ITC_RESTRICTED             = 0x09,
00538         Q931_ITC_3K1_AUDIO              = 0x10,
00539         Q931_ITC_UNRESTRICTED_TONES     = 0x11,
00540         Q931_ITC_VIDEO                  = 0x18
00541 };
00542 
00546 enum {
00547         Q931_ITR_PACKET = 0x00,
00548         Q931_ITR_64K    = 0x10,
00549         Q931_ITR_128K   = 0x11,
00550         Q931_ITR_384K   = 0x13,
00551         Q931_ITR_1536K  = 0x15,
00552         Q931_ITR_1920K  = 0x17,
00553         Q931_ITR_MULTI  = 0x18
00554 };
00555 
00559 enum {
00560         Q931_CODESET_0 = 0,
00561         Q931_CODESET_1,
00562         Q931_CODESET_2,
00563         Q931_CODESET_3,
00564         Q931_CODESET_4,
00565         Q931_CODESET_5,
00566         Q931_CODESET_6,
00567         Q931_CODESET_7,
00568 };
00569 #define Q931_CODESET_ALL        0x07
00570 
00571 /*
00572  * ITU-T Q.850 cause codes and helper functions
00573  */
00574 #include "Q850.h"
00575 
00576 /*****************************************************************************
00577 
00578   Struct:       Q931mes_Header
00579 
00580   Description:  Used to read the header & message code.
00581 
00582 *****************************************************************************/
00583 /* private */
00584 typedef struct {
00585         L3UINT  Size;           /* Size of message in bytes             */
00586         L3UCHAR ProtDisc;       /* Protocol Discriminator               */
00587         L3UCHAR MesType;        /* Message type                         */
00588         L3UCHAR CRVFlag;        /* Call reference value flag            */
00589         L3INT   CRV;            /* Call reference value                 */
00590 
00591 } Q931mes_Header;
00592 
00593 /*****************************************************************************
00594 
00595   Struct:       Q931mes_Generic
00596 
00597   Description:  Generic header containing all IE's. This is not used, but is
00598                                 provided in case a proprietary variant needs it.
00599 
00600 *****************************************************************************/
00601 /* private (well, that's the goal) */
00602 typedef struct {
00603         L3UINT          Size;           /* Size of message in bytes             */
00604         L3UCHAR         ProtDisc;       /* Protocol Discriminator               */
00605         L3UCHAR         MesType;        /* Message type                         */
00606         L3UCHAR         CRVFlag;        /* Call reference value flag            */
00607         L3INT           CRV;            /* Call reference value                 */
00608 
00609         /* WARNING: don't touch anything above this line (TODO: use Q931mes_Header directly to make sure it's the same) */
00610 
00611         L3UCHAR         Tei;            /* TEI                                  */
00612 
00613         ie              Shift;
00614         ie              MoreData;
00615         ie              SendComplete;
00616         ie              CongestionLevel;
00617         ie              RepeatInd;
00618 
00619         ie              Segment;        /* Segmented message                    */
00620         ie              BearerCap;      /* Bearer Capability                    */
00621         ie              Cause;          /* Cause                                */
00622         ie              CallState;      /* Call State                           */
00623         ie              CallID;                 /* Call Identity                        */
00624         ie              ChanID;         /* Channel Identification               */
00625         ie              ChangeStatus;   /* Change Staus                         */
00626         ie              ProgInd;        /* Progress Indicator                   */
00627         ie              NetFac;         /* Network Spesific Facilities          */
00628         ie              NotifInd;       /* Notification Indicator               */
00629         ie              Display;        /* Display                              */
00630         ie              DateTime;       /* Date/Time                            */
00631         ie              KeypadFac;      /* Keypad Facility                      */
00632         ie              Signal;         /* Signal                               */
00633         ie              InfoRate;       /* Information rate                     */
00634         ie              EndEndTxDelay;  /* End to End Transmit Delay            */
00635         ie              TransDelSelInd; /* Transmit Delay Sel. and Ind.         */
00636         ie              PackParam;      /* Packed Layer Binary parameters       */
00637         ie              PackWinSize;    /* Packet Layer Window Size             */
00638         ie              PackSize;       /* Packed Size                          */
00639         ie              ClosedUserGrp;  /* Closed User Group                    */
00640         ie              RevChargeInd;   /* Reverse Charging Indicator           */
00641         ie              CalledNum;      /* Called Party Number                  */
00642         ie              CalledSub;      /* Called Party subaddress              */
00643         ie              CallingNum;     /* Calling Party Number                 */
00644         ie              CallingSub;     /* Calling Party Subaddress             */
00645         ie              RedirNum;       /* Redirection Number                   */
00646         ie              TransNetSel;    /* Transmit Network Selection           */
00647         ie              LLRepeatInd;    /* Repeat Indicator 2 LLComp            */
00648         ie              RestartWin;     /* Restart Window                       */
00649         ie              RestartInd;     /* Restart Indicator                    */
00650         ie              LLComp;         /* Low Layer Compatibility              */
00651         ie              HLComp;         /* High Layer Compatibility             */
00652         ie              UserUser;       /* User-user                            */
00653         ie              Escape;         /* Escape for extension                 */
00654         ie              Switchhook;
00655         ie              FeatAct;
00656         ie              FeatInd;
00657         ie              GenericDigits;
00658 
00659         L3UCHAR         buf[1];                 /* Buffer for IE's                                              */
00660 
00661 } Q931mes_Generic;
00662 
00663 /*****************************************************************************
00664 
00665   Struct:       Q931_TrunkInfo
00666 
00667   Description:  TrunkInfo is the struct entry used to store Q.931 related 
00668                 information and state for E1/T1/J1 trunks and associated 
00669                 channels in the system. 
00670 
00671                                 The user should store this information outside this stack
00672                                 and needs to feed the interface functions with a pointer to
00673                                 the TrunkInfo entry.
00674 
00675 *****************************************************************************/
00676 /* public */
00677 typedef struct Q931_TrunkInfo Q931_TrunkInfo_t;
00678 
00682 typedef enum {
00683     Q931_LOG_NONE = -1,
00684     Q931_LOG_EMERG,
00685     Q931_LOG_ALERT,
00686     Q931_LOG_CRIT,
00687     Q931_LOG_ERROR,
00688     Q931_LOG_WARNING,
00689     Q931_LOG_NOTICE,
00690     Q931_LOG_INFO,
00691     Q931_LOG_DEBUG
00692 } Q931LogLevel_t;
00693 
00697 typedef enum {
00698         Q931_TE = 0,                    
00699         Q931_NT                         
00700 } Q931NetUser_t;
00701 
00702 typedef enum {                                  /* Dialect enum */
00703         Q931_Dialect_Q931 = 0,
00704         Q931_Dialect_National,
00705         Q931_Dialect_DMS,
00706         Q931_Dialect_5ESS,
00707         Q931_Dialect_DSS1,              
00709         Q931_Dialect_Count
00710 } Q931Dialect_t;
00711 #define DIALECT_STRINGS "q931", "national", "dms", "5ess", "dss1"
00712 Q931_STR2ENUM_P(q931_str2Q931Dialect_type, q931_Q931Dialect_type2str, Q931Dialect_t)
00713 
00714 
00717 typedef enum {
00718         Q931_TrType_E1 = 0,                     
00719         Q931_TrType_T1,                         
00720         Q931_TrType_J1,                         
00721         Q931_TrType_BRI,                        
00722         Q931_TrType_BRI_PTMP                    
00723 } Q931_TrunkType_t;
00724 
00728 typedef enum {
00729         Q931_TrState_NoAlignment = 0,           
00730         Q931_TrState_Aligning,                  
00731         Q931_TrState_Aligned                    
00732 } Q931_TrunkState_t;
00733 
00737 typedef enum {
00738         Q931_ChType_NotUsed = 0,                
00739         Q931_ChType_B,                          
00740         Q931_ChType_D,                          
00741         Q931_ChType_Sync                        
00742 } Q931_ChanType_t;
00743 
00744 #ifdef Q931PRIVATE
00745 
00749 enum {
00750         Q931_TFLAG_STATUS_ENQUIRY   = (1 <<  0),        
00752         Q931_TFLAG_AUTO_SETUP_ACK   = (1 << 16),        
00753         Q931_TFLAG_AUTO_SERVICE_ACK = (1 << 17),        
00754         Q931_TFLAG_AUTO_CONNECT_ACK = (1 << 18),        
00755         Q931_TFLAG_AUTO_RESTART_ACK = (1 << 19),        
00757         /*
00758          * Message check relaxation flags (use with care...)
00759          */
00760         Q931_TFLAG_IGNORE_UNKNOWN_MSG = (1 << 29),      
00762         /*
00763          * IE check relaxation flags (use with care...)
00764          */
00765         Q931_TFLAG_IGNORE_UNKNOWN_IE = (1 << 30),       
00766         Q931_TFLAG_IGNORE_ILLEGAL_IE = (1 << 31),       
00767 };
00768 
00769 /* private: Low-level access */
00770 void Q931TrunkSetFlag(Q931_TrunkInfo_t *trunk, const L3INT flag);
00771 void Q931TrunkClearFlag(Q931_TrunkInfo_t *trunk, L3INT flag);
00772 void Q931TrunkClearAllFlags(Q931_TrunkInfo_t *trunk);
00773 L3BOOL Q931TrunkIsSetFlag(const Q931_TrunkInfo_t *trunk, const L3INT flag);
00774 #endif
00775 
00776 /* public: High-level access */
00777 void Q931TrunkSetAutoSetupAck(Q931_TrunkInfo_t *trunk, L3BOOL enable);
00778 void Q931TrunkSetAutoServiceAck(Q931_TrunkInfo_t *trunk, L3BOOL enable);
00779 void Q931TrunkSetAutoRestartAck(Q931_TrunkInfo_t *trunk, L3BOOL enable);
00780 void Q931TrunkSetAutoConnectAck(Q931_TrunkInfo_t *trunk, L3BOOL enable);
00781 void Q931TrunkSetStatusEnquiry(Q931_TrunkInfo_t *trunk, L3BOOL enable);
00782 void Q931TrunkSetIgnoreUnknownMsg(Q931_TrunkInfo_t *trunk, L3BOOL enable);
00783 void Q931TrunkSetIgnoreUnknownIEs(Q931_TrunkInfo_t *trunk, L3BOOL enable);
00784 void Q931TrunkSetIgnoreIllegalIEs(Q931_TrunkInfo_t *trunk, L3BOOL enable);
00785 
00786 L3BOOL Q931TrunkGetAutoSetupAck(Q931_TrunkInfo_t *trunk);
00787 L3BOOL Q931TrunkGetAutoServiceAck(Q931_TrunkInfo_t *trunk);
00788 L3BOOL Q931TrunkGetAutoRestartAck(Q931_TrunkInfo_t *trunk);
00789 L3BOOL Q931TrunkGetAutoConnectAck(Q931_TrunkInfo_t *trunk);
00790 L3BOOL Q931TrunkGetStatusEnquiry(Q931_TrunkInfo_t *trunk);
00791 L3BOOL Q931TrunkGetIgnoreUnknownMsg(Q931_TrunkInfo_t *trunk);
00792 L3BOOL Q931TrunkGetIgnoreUnknownIEs(Q931_TrunkInfo_t *trunk);
00793 L3BOOL Q931TrunkGetIgnoreIllegalIEs(Q931_TrunkInfo_t *trunk);
00794 
00795 void Q931TrunkSetRelaxedMode(Q931_TrunkInfo_t *trunk, L3BOOL enable);
00796 
00797 /* public */
00798 typedef L3INT (*Q931Tx34CB_t)  (void *, L3UCHAR *, L3INT);
00799 typedef L3INT (*Q931Tx32CB_t)  (void *, L3INT, L3UCHAR, L3UCHAR *, L3INT);
00800 typedef L3INT (*Q931ErrorCB_t) (void *, L3INT, L3INT, L3INT);
00801 typedef L3INT (*Q931LogCB_t)   (void *, Q931LogLevel_t, char *, L3INT);
00802 
00803 struct Q931Dialect;
00804 
00805 /*****************************************************************************
00806  * Q.931 Call API
00807  *****************************************************************************/
00808 #include "Q931call.h"
00809 
00810 /* public, needs cleanup */
00811 struct Q931_TrunkInfo
00812 {
00813         Q931NetUser_t           NetUser;        /* Network/User Mode.         */
00814         Q931_TrunkType_t        TrunkType;      /* Trunk Line Type.           */
00815         struct Q931Dialect      *Dialect;       /* Dialect handle             */
00816 
00817         Q931Tx34CB_t     Q931Tx34CBProc;
00818         Q931Tx32CB_t     Q931Tx32CBProc;
00819         Q931ErrorCB_t    Q931ErrorCBProc;
00820         Q931LogCB_t      Q931LogCBProc;
00821         void *PrivateData32;
00822         void *PrivateData34;
00823         void *PrivateDataLog;
00824 
00825         Q931CallEventCB_t CallEventCBProc;
00826         void *PrivateDataCallEventCB;
00827 
00828         Q931LogLevel_t   loglevel;
00829 
00830         L3UCHAR     Enabled;        /* Enabled/Disabled                     */
00831                                     /*  0 = Disabled                        */
00832                                     /*  1 = Enabled                         */
00833 
00834         Q931_TrunkState_t TrunkState;
00835 
00836         L3INT   LastCRV;            /* Last used crv for the trunk.         */
00837 
00838         L3UCHAR L3Buf[Q931L4BUF];               /* message buffer for messages to be    */
00839                                     /* send from Q.931 L4.                  */
00840 
00841         L3UCHAR L2Buf[Q931L2BUF];               /* buffer for messages send to L2.      */
00842 
00843         /* The auto flags below switch on/off automatic Ack messages. SETUP ACK */
00844         /* as an example can be sent by the stack in response to SETUP to buy   */
00845         /* time in processing on L4. Setting this to true will cause the stack  */
00846         /* to automatically send this.                                                                                  */
00847         L3INT   flags;
00848 
00849         /* channel array holding info per channel. Usually defined to 32                */
00850         /* channels to fit an E1 since T1/J1 and BRI will fit inside a E1.              */
00851         struct _charray
00852         {
00853                 Q931_ChanType_t ChanType;   /* Unused, B, D, Sync */
00854 
00855                 L3UCHAR Available;          /* Channel Available Flag               */
00856                                             /*  0 : Avaiabled                       */
00857                                             /*  1 : Used                            */
00858 
00859                 L3INT   CRV;                /* Associated CRV                       */
00860 
00861         } ch[Q931MAXCHPERTRUNK];
00862 
00863         /* Active Call information indentified by CRV. See Q931AllocateCRV for  */
00864         /* initialization of call table.                                        */
00865         struct Q931_Call        call[Q931MAXCALLPERTRUNK];      
00866 };
00867 
00868 /*****************************************************************************
00869   
00870   Struct:               Q931State
00871 
00872   Description:  Define a Q931 State, legal events and next state for each
00873                                 event. Used to simplify the state engine logic. Each state
00874                                 engine defines its own state table and the logic need only
00875                                 call a helper function to check if the message is legal
00876                                 at this stage.
00877 
00878 *****************************************************************************/
00879 /* private */
00880 #ifdef Q931PRIVATE
00881 typedef struct
00882 {
00883         L3INT           State;          
00884         L3INT           Message;        
00885         L3UCHAR         Flags;          
00886 } Q931State;
00887 #endif
00888 
00889 /*****************************************************************************
00890 
00891   Proc table external references. 
00892 
00893   The proc tables are defined in Q931.c and initialized in Q931Initialize.
00894 
00895 *****************************************************************************/
00896 /* mostly private stuff, some typedefs public */
00897 typedef L3INT (q931proc_func_t) (Q931_TrunkInfo_t *pTrunk, L3UCHAR *, L3INT);
00898 
00899 typedef L3INT (q931umes_func_t) (Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT IOff, L3INT Size);
00900 typedef L3INT (q931pmes_func_t) (Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize);
00901 
00902 typedef L3INT (q931uie_func_t) (Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff);
00903 typedef L3INT (q931pie_func_t) (Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet);
00904 
00905 typedef L3INT (q931timeout_func_t) (Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
00906 typedef L3ULONG q931timer_t;
00907 
00908 /* private */
00909 #ifdef Q931PRIVATE
00910 L3INT Q931Proc(Q931_TrunkInfo_t *pTrunk, L3UCHAR *buf, L3INT iFrom);
00911 L3INT Q931ProcInvalid(Q931_TrunkInfo_t *pTrunk, L3UCHAR *buf, L3INT iFrom);
00912 L3INT Q931Umes(Q931_TrunkInfo_t *pTrunk, L3UCHAR id, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT IOff, L3INT Size);
00913 L3INT Q931Pmes(Q931_TrunkInfo_t *pTrunk, L3UCHAR id, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize);
00914 L3INT Q931Uie(Q931_TrunkInfo_t *pTrunk, L3UCHAR id, Q931mes_Generic *pMes, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *IOff, L3INT *OOff);
00915 L3INT Q931Pie(Q931_TrunkInfo_t *pTrunk, L3UCHAR id, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet);
00916 L3INT Q931Timeout(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call, L3UCHAR timer);
00917 
00918 L3BOOL Q931UieIsNull(Q931_TrunkInfo_t *pTrunk, L3UCHAR id);
00919 L3BOOL Q931PieIsNull(Q931_TrunkInfo_t *pTrunk, L3UCHAR id);
00920 
00921 #include "Q931dialect.h"
00922 #endif
00923 
00924 /*****************************************************************************
00925     
00926   Macro:        GetIETotoSize
00927 
00928   Syntax:       L3INT GetIETotSize(InfoElem ie);
00929 
00930   Description:  Compute the total size in bytes of an info element including 
00931                 size of 'header'.    
00932 
00933 *****************************************************************************/
00934 #define Q931GetIETotSize(ie) (((ie.InfoID & 0x80) != 0) ? 1 : ie.LenIE) + 2)
00935 
00936 /*****************************************************************************
00937 
00938   Macro:        IsIEPresent
00939 
00940   Syntax:       BOOL IsIEPresent(ie InfoElement);
00941 
00942   Description:  Return TRUE if the Information Element is included.
00943 
00944 *****************************************************************************/
00945 #define Q931IsIEPresent(x) ((x & 0x8000) != 0)
00946 
00947 /*****************************************************************************
00948 
00949   Macro:        GetIEOffset and GetIEValue
00950     
00951   Syntax:       L3INT GetIEOffset(ie InfoElement)
00952                 L3INT GetIEValue(ie InfoElement)
00953 
00954   Description:  Returns the offset (or the value )to the Information Element.
00955 
00956   Note:         GetIEValue assumes that the 15 lsb bit is the value of a 
00957                 single octet information element. This macro can not be used
00958                 on a variable information element.
00959 
00960 *****************************************************************************/
00961 #define Q931GetIEOffset(x) (x & 0x7fff)
00962 #define Q931GetIEValue(x)  (x & 0x7fff)
00963 
00964 /*****************************************************************************
00965 
00966   Macro:        Q931GetIEPtr
00967 
00968   Syntax:       void * Q931GetIEPtr(ie InfoElement, L3UCHAR * Buf);
00969 
00970   Description:  Compute a Ptr to the information element.
00971 
00972 *****************************************************************************/
00973 #define Q931GetIEPtr(ie,buf) ((void *)&buf[Q931GetIEOffset(ie)])
00974 
00975 /*****************************************************************************
00976 
00977   Macro:        SetIE
00978 
00979   Syntax:       void SetIE(ie InfoElement, L3INT Offset);
00980 
00981   Description:  Set an information element.
00982 
00983 *****************************************************************************/
00984 #define Q931SetIE(x,o) { x = (ie)(o) | 0x8000; }
00985 
00986 /*****************************************************************************
00987 
00988   Macro:        IsQ931Ext
00989 
00990   Syntax        BOOL IsQ931Ext(L3UCHAR c)
00991 
00992   Description:  Return true Check if the msb (bit 8) is 0. This indicate
00993                 that the octet is extended.
00994 
00995 *****************************************************************************/
00996 #define IsQ931Ext(x) ((x & 0x80) == 0)
00997 
00998 /*****************************************************************************
00999 
01000   Macro:        ieGetOctet
01001 
01002   Syntax:       unsigned L3UCHAR ieGetOctet(L3INT e)
01003 
01004   Description:  Macro to fetch one byte from an integer. Mostly used to 
01005                 avoid warnings.
01006 
01007 *****************************************************************************/
01008 #define ieGetOctet(x) ((L3UCHAR)(x))
01009 
01010 /*****************************************************************************
01011 
01012   Macro:        NoWarning
01013 
01014   Syntax:       void NoWarning(x)
01015 
01016   Description:  Macro to suppress unreferenced formal parameter warnings
01017 
01018                 Used during creation of the stack since the stack is 
01019                 developed for Warning Level 4 and this creates a lot of 
01020                 warning for the initial empty functions.
01021 
01022 *****************************************************************************/
01023 #define NoWarning(x) (x = x)
01024 
01025 /*****************************************************************************
01026 
01027   External references. See Q931.c for details.
01028 
01029 *****************************************************************************/
01030 
01031 #include "Q931ie.h"
01032 #include "Q932.h"
01033 
01034 /*****************************************************************************
01035 
01036   Q.931 Message Pack/Unpack functions. Implemented in Q931mes.c
01037 
01038 *****************************************************************************/
01039 #ifdef Q931PRIVATE
01040 
01041 /* private */
01042 L3INT Q931Pmes_UserInformation(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize);
01043 L3INT Q931Pmes_Restart(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize);
01044 L3INT Q931Pmes_RestartAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize);
01045 L3INT Q931Pmes_CongestionControl(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize);
01046 L3INT Q931Pmes_Segment(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize);
01047 L3INT Q931Pmes_Service(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize);
01048 L3INT Q931Pmes_ServiceAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize);
01049 
01050 /* private */
01051 L3INT Q931Umes_UserInformation(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O);
01052 L3INT Q931Umes_Restart(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O);
01053 L3INT Q931Umes_RestartAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O);
01054 L3INT Q931Umes_CongestionControl(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O);
01055 L3INT Q931Umes_Segment(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT I, L3INT O);
01056 L3INT Q931Umes_Service(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size);
01057 L3INT Q931Umes_ServiceAck(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size);
01058 
01059 #endif
01060 
01061 /*****************************************************************************
01062 
01063   Q.931 Process Function Prototyping. Implemented in Q931StateTE.c
01064 
01065 *****************************************************************************/
01066 #ifdef Q931PRIVATE
01067 
01068 /* private */
01069 L3INT Q931ProcAlertingTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01070 L3INT Q931ProcCallProceedingTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01071 L3INT Q931ProcConnectTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01072 L3INT Q931ProcConnectAckTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01073 L3INT Q931ProcProgressTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01074 L3INT Q931ProcSetupTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01075 L3INT Q931ProcSetupAckTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01076 L3INT Q931ProcResumeTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01077 L3INT Q931ProcResumeAckTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01078 L3INT Q931ProcResumeRejectTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01079 L3INT Q931ProcSuspendTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01080 L3INT Q931ProcSuspendAckTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01081 L3INT Q931ProcSuspendRejectTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01082 L3INT Q931ProcUserInformationTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01083 L3INT Q931ProcDisconnectTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01084 L3INT Q931ProcReleaseTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01085 L3INT Q931ProcReleaseCompleteTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01086 L3INT Q931ProcRestartTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01087 L3INT Q931ProcRestartAckTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01088 L3INT Q931ProcCongestionControlTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01089 L3INT Q931ProcInformationTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01090 L3INT Q931ProcNotifyTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01091 L3INT Q931ProcStatusTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01092 L3INT Q931ProcStatusEnquiryTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01093 L3INT Q931ProcSegmentTE(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01094 
01095 L3INT Q931ProcTimeoutT301TE(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01096 L3INT Q931ProcTimeoutT302TE(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01097 L3INT Q931ProcTimeoutT303TE(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01098 L3INT Q931ProcTimeoutT304TE(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01099 L3INT Q931ProcTimeoutT305TE(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01100 L3INT Q931ProcTimeoutT308TE(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01101 L3INT Q931ProcTimeoutT309TE(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01102 L3INT Q931ProcTimeoutT310TE(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01103 L3INT Q931ProcTimeoutT311TE(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01104 L3INT Q931ProcTimeoutT313TE(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01105 L3INT Q931ProcTimeoutT314TE(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01106 L3INT Q931ProcTimeoutT316TE(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01107 L3INT Q931ProcTimeoutT317TE(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01108 L3INT Q931ProcTimeoutT318TE(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01109 L3INT Q931ProcTimeoutT319TE(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01110 L3INT Q931ProcTimeoutT321TE(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01111 L3INT Q931ProcTimeoutT322TE(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01112 
01113 
01114 /* private */
01115 L3INT Q931ProcAlertingNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01116 L3INT Q931ProcCallProceedingNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01117 L3INT Q931ProcConnectNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01118 L3INT Q931ProcConnectAckNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01119 L3INT Q931ProcProgressNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01120 L3INT Q931ProcSetupNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01121 L3INT Q931ProcSetupAckNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01122 L3INT Q931ProcResumeNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01123 L3INT Q931ProcResumeAckNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01124 L3INT Q931ProcResumeRejectNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01125 L3INT Q931ProcSuspendNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01126 L3INT Q931ProcSuspendAckNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01127 L3INT Q931ProcSuspendRejectNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01128 L3INT Q931ProcUserInformationNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01129 L3INT Q931ProcDisconnectNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01130 L3INT Q931ProcReleaseNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01131 L3INT Q931ProcReleaseCompleteNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01132 L3INT Q931ProcRestartNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01133 L3INT Q931ProcRestartAckNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01134 L3INT Q931ProcCongestionControlNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01135 L3INT Q931ProcInformationNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01136 L3INT Q931ProcNotifyNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01137 L3INT Q931ProcStatusNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01138 L3INT Q931ProcStatusEnquiryNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01139 L3INT Q931ProcSegmentNT(Q931_TrunkInfo_t *pTrunk,L3UCHAR * b, L3INT iFrom);
01140 
01141 L3INT Q931ProcTimeoutT301NT(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01142 L3INT Q931ProcTimeoutT302NT(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01143 L3INT Q931ProcTimeoutT303NT(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01144 L3INT Q931ProcTimeoutT304NT(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01145 L3INT Q931ProcTimeoutT305NT(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01146 L3INT Q931ProcTimeoutT306NT(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01147 L3INT Q931ProcTimeoutT307NT(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01148 L3INT Q931ProcTimeoutT308NT(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01149 L3INT Q931ProcTimeoutT309NT(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01150 L3INT Q931ProcTimeoutT310NT(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01151 L3INT Q931ProcTimeoutT312NT(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01152 L3INT Q931ProcTimeoutT313NT(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01153 L3INT Q931ProcTimeoutT314NT(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01154 L3INT Q931ProcTimeoutT316NT(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01155 L3INT Q931ProcTimeoutT317NT(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01156 L3INT Q931ProcTimeoutT320NT(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01157 L3INT Q931ProcTimeoutT321NT(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01158 L3INT Q931ProcTimeoutT322NT(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01159 
01160 
01161 L3INT Q931ProcUnknownMessage(Q931_TrunkInfo_t *pTrunk,L3UCHAR *buf, L3INT iFrom);
01162 L3INT Q931ProcUnexpectedMessage(Q931_TrunkInfo_t *pTrunk,L3UCHAR *buf, L3INT iFrom);
01163 
01164 #endif
01165 
01166 /*****************************************************************************
01167 
01168   Interface Function Prototypes. Implemented in Q931.c
01169 
01170 *****************************************************************************/
01171 /* public */
01172 void    Q931TimerTick(Q931_TrunkInfo_t *pTrunk);
01173 
01174 L3INT   Q931Rx23(Q931_TrunkInfo_t *pTrunk, L3INT ind, L3UCHAR tei, L3UCHAR * Mes, L3INT Size);
01175 L3INT   Q931Tx32Data(Q931_TrunkInfo_t *pTrunk, L3UCHAR bcast, L3UCHAR * Mes, L3INT Size);
01176 L3INT   Q931Rx43(Q931_TrunkInfo_t *pTrunk, L3UCHAR * Mes, L3INT Size);
01177 L3INT   Q931Tx34(Q931_TrunkInfo_t *pTrunk, L3UCHAR * Mes, L3INT Size);
01178 
01179 void    Q931SetError(Q931_TrunkInfo_t *pTrunk,L3INT ErrID, L3INT ErrPar1, L3INT ErrPar2);       /* private ? */
01180 
01181 /* private, Q931dialect.h(?) */
01182 #ifdef Q931PRIVATE
01183 void    Q931CreateTE(struct Q931Dialect *d);
01184 void    Q931CreateNT(struct Q931Dialect *d);
01185 #endif
01186 
01187 /* public */
01188 void Q931Initialize(void);
01189 void Q931SetGetTimeCB(L3ULONG (*callback)(void));
01190 
01191 /* private */
01192 L3INT Q931InitMesSetup(Q931mes_Generic *p);
01193 L3INT Q931InitMesRestartAck(Q931mes_Generic * pMes);
01194 L3INT Q931InitMesGeneric(Q931mes_Generic *pMes);
01195 
01196 L3INT Q931ReleaseCRV(Q931_TrunkInfo_t *pTrunk, L3INT CRV);      /* legacy, public for now, still needed by ozmod_isdn */
01197 
01198 /* private */
01199 #ifdef Q931PRIVATE
01200 L3ULONG Q931GetTime(void);
01201 
01202 void    Q931AddStateEntry(L3UCHAR iD, L3INT iState, L3INT iMes, L3UCHAR cDir);
01203 L3BOOL  Q931IsEventLegal(L3UCHAR iD, L3INT iState, L3INT iMes, L3UCHAR cDir);
01204 #endif
01205 
01206 
01207 /*****************************************************************************
01208 
01209   Q.931 Low Level API Function Prototyping. Implemented in Q931API.c
01210 
01211 *****************************************************************************/
01212 /* private */
01213 #ifdef Q931PRIVATE
01214 L3INT Q931GetUniqueCRV(Q931_TrunkInfo_t *pTrunk);
01215 #endif
01216 
01217 /* public, helper functions */
01218 ie Q931AppendIE(L3UCHAR *pm, L3UCHAR *pi);
01219 
01220 L3INT Q931InitIEBearerCap(Q931ie_BearerCap *p);
01221 L3INT Q931InitIEChanID(Q931ie_ChanID *p);
01222 L3INT Q931InitIEProgInd(Q931ie_ProgInd *p);
01223 L3INT Q931InitIENetFac(Q931ie_NetFac * pIE);
01224 L3INT Q931InitIEDisplay(Q931ie_Display * pIE);
01225 L3INT Q931InitIEDateTime(Q931ie_DateTime * pIE);
01226 L3INT Q931InitIEKeypadFac(Q931ie_KeypadFac * pIE);
01227 L3INT Q931InitIESignal(Q931ie_Signal * pIE);
01228 L3INT Q931InitIECallingNum(Q931ie_CallingNum * pIE);
01229 L3INT Q931InitIECallingSub(Q931ie_CallingSub * pIE);
01230 L3INT Q931InitIECalledNum(Q931ie_CalledNum * pIE);
01231 L3INT Q931InitIECalledSub(Q931ie_CalledSub * pIE);
01232 L3INT Q931InitIETransNetSel(Q931ie_TransNetSel * pIE);
01233 L3INT Q931InitIELLComp(Q931ie_LLComp * pIE);
01234 L3INT Q931InitIEHLComp(Q931ie_HLComp * pIE);
01235 
01236 /* hmm... */
01237 L3INT Q931Disconnect(Q931_TrunkInfo_t *pTrunk, L3INT iTo, L3INT iCRV, L3INT iCause);
01238 L3INT Q931Release(Q931_TrunkInfo_t *pTrunk, L3UCHAR *buf, struct Q931_Call *call, L3UCHAR causeval);
01239 L3INT Q931ReleaseComplete(Q931_TrunkInfo_t *pTrunk, L3UCHAR *buf, struct Q931_Call *call, L3UCHAR causeval);
01240 L3INT Q931AckRestart(Q931_TrunkInfo_t *pTrunk, L3UCHAR *buf);
01241 L3INT Q931AckConnect(struct Q931_Call *call);
01242 L3INT Q931AckSetup(Q931_TrunkInfo_t *pTrunk, L3UCHAR *buf);
01243 L3INT Q931AckService(Q931_TrunkInfo_t *pTrunk, L3UCHAR *buf);
01244 
01245 /* public */
01246 L3INT Q931InitTrunk(Q931_TrunkInfo_t *pTrunk,
01247                                                 Q931Dialect_t Dialect,
01248                                                 Q931NetUser_t NetUser,
01249                                                 Q931_TrunkType_t TrunkType,
01250                                                 Q931Tx34CB_t Q931Tx34CBProc,
01251                                                 Q931Tx32CB_t Q931Tx32CBProc,
01252                                                 Q931ErrorCB_t Q931ErrorCBProc,
01253                                                 void *PrivateData32,
01254                                                 void *PrivateData34);
01255 L3INT Q931Start(Q931_TrunkInfo_t *trunk);
01256 
01257 /* private? */
01258 L3INT Q931GetMesSize(Q931mes_Generic *pMes);
01259 L3INT Q931InitMesResume(Q931mes_Generic * pMes);
01260 
01261 /* private */
01262 #ifdef Q931PRIVATE
01263 L3INT Q931Log(Q931_TrunkInfo_t *trunk, Q931LogLevel_t level, const char *fmt, ...);
01264 #endif
01265 
01266 /* public */
01267 void Q931SetLogCB(Q931_TrunkInfo_t *trunk, Q931LogCB_t func, void *priv);
01268 void Q931SetLogLevel(Q931_TrunkInfo_t *trunk, Q931LogLevel_t level);
01269 
01270 /* private? clashing with Q931SetHeaderSpace() */
01271 void Q931SetL4HeaderSpace(L3INT space);
01272 void Q931SetL2HeaderSpace(L3INT space);
01273 
01274 /* private, dummy functions */
01275 #ifdef Q931PRIVATE
01276 L3INT Q931ProcDummy(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b,L3INT c);
01277 L3INT Q931UmesDummy(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, Q931mes_Generic *OBuf, L3INT IOff, L3INT Size);
01278 L3INT Q931PmesDummy(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize);
01279 L3INT Q931UieDummy(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff);
01280 L3INT Q931PieDummy(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet);
01281 L3INT Q931TxDummy(Q931_TrunkInfo_t *pTrunk, L3UCHAR * b, L3INT n);
01282 L3INT Q931TimeoutDummy(Q931_TrunkInfo_t *pTrunk, struct Q931_Call *call);
01283 
01284 /* private */
01285 L3INT Q931MesgHeader(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *mes, L3UCHAR *OBuf, L3INT Size, L3INT *IOff);
01286 
01287 /* private, new */
01288 L3INT Q931StatusEnquiryResponse(Q931_TrunkInfo_t *pTrunk, L3UCHAR *buf, struct Q931_Call *call, L3UCHAR causeval);
01289 
01290 /* one Q931Umes to rule them all (private) */
01291 L3INT Q931Umes_Generic(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, Q931mes_Generic *mes, L3INT IOff, L3INT Size);
01292 L3INT Q931Pmes_Generic(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize);
01293 #endif
01294 
01295 /* bad example function for new l4 call control api */
01296 L3INT Q931CallSendStatus(const struct Q931_Call *call, const L3UCHAR causeval);
01297 
01298 #endif /* _Q931_NL */

Generated on Tue Apr 7 17:38:19 2009 for mod_ssh by  doxygen 1.5.4